update the Plugins window label to link to 'more inforamtion' rather than 'more plugi...
[claws.git] / src / gtk / pluginwindow.c
index 5d51de5df5092fd5bdcbc104acdc0cde754e9324..3f822e46bc7425230862e195b8b13f522240bfd8 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail Team
+ * Copyright (C) 1999-2012 Hiroyuki Yamamoto and the Claws Mail Team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -19,6 +19,7 @@
 
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
+#include "claws-features.h"
 #endif
 
 #include <glib.h>
@@ -53,6 +54,8 @@ typedef struct _PluginWindow
        GtkWidget *unload_btn;
 
        Plugin *selected_plugin;
+       
+       gboolean loading;
 } PluginWindow;
 
 static GtkListStore* pluginwindow_create_data_store    (void);
@@ -66,6 +69,8 @@ static gboolean pluginwindow_selected                 (GtkTreeSelection *selector,
 
 static void close_cb(GtkButton *button, PluginWindow *pluginwindow)
 {
+       if (pluginwindow->loading)
+               return;
        gtk_widget_destroy(pluginwindow->window);
        g_free(pluginwindow);
        plugin_save_list();
@@ -75,6 +80,8 @@ static void close_cb(GtkButton *button, PluginWindow *pluginwindow)
 static gint pluginwindow_delete_cb(GtkWidget *widget, GdkEventAny *event,
                                  PluginWindow *pluginwindow)
 {
+       if (pluginwindow->loading)
+               return FALSE;
        close_cb(NULL,pluginwindow);
        return TRUE;
 }
@@ -130,11 +137,10 @@ static void set_plugin_list(PluginWindow *pluginwindow)
                                   -1);
        }
 
-       if (pluginwindow->selected_plugin == NULL) { 
-               selection = gtk_tree_view_get_selection(GTK_TREE_VIEW
-                               (pluginwindow->plugin_list_view));
-               gtk_tree_selection_unselect_all(selection);                             
-       }               
+       selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(pluginwindow->plugin_list_view));
+       if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter))
+               gtk_tree_selection_select_iter(selection, &iter);
+               
        g_slist_free(plugins);
 }
 
@@ -179,8 +185,10 @@ static void unload_cb(GtkButton *button, PluginWindow *pluginwindow)
 {
        Plugin *plugin = pluginwindow->selected_plugin;
 
-       g_return_if_fail(plugin != NULL);
+       cm_return_if_fail(plugin != NULL);
+       pluginwindow->loading = TRUE;
        plugin_unload(plugin);
+       pluginwindow->loading = FALSE;
        pluginwindow->selected_plugin = NULL;
        set_plugin_list(pluginwindow);
 }
@@ -195,7 +203,7 @@ static void load_cb(GtkButton *button, PluginWindow *pluginwindow)
 
        if (file_list) {
                GList *tmp;
-
+               pluginwindow->loading = TRUE;
                for ( tmp = file_list; tmp; tmp = tmp->next) {
                        gchar *file, *error = NULL;
 
@@ -215,7 +223,7 @@ static void load_cb(GtkButton *button, PluginWindow *pluginwindow)
                        set_plugin_list(pluginwindow);
                        g_free(file);
                }
-
+               pluginwindow->loading = FALSE;
                g_list_free(file_list);
        }               
 }
@@ -225,21 +233,21 @@ static gboolean pluginwindow_key_pressed(GtkWidget *widget, GdkEventKey *event,
 {
        if (event) {
                switch (event->keyval) {
-                       case GDK_Escape : 
-                       case GDK_Return : 
-                       case GDK_KP_Enter :
+                       case GDK_KEY_Escape : 
+                       case GDK_KEY_Return : 
+                       case GDK_KEY_KP_Enter :
                                close_cb(NULL, pluginwindow);
                                break;
-                       case GDK_Insert : 
-                       case GDK_KP_Insert :
-                       case GDK_KP_Add : 
-                       case GDK_plus :
+                       case GDK_KEY_Insert : 
+                       case GDK_KEY_KP_Insert :
+                       case GDK_KEY_KP_Add : 
+                       case GDK_KEY_plus :
                                load_cb(NULL, pluginwindow);
                                break;
-                       case GDK_Delete : 
-                       case GDK_KP_Delete :
-                       case GDK_KP_Subtract : 
-                       case GDK_minus :
+                       case GDK_KEY_Delete : 
+                       case GDK_KEY_KP_Delete :
+                       case GDK_KEY_KP_Subtract : 
+                       case GDK_KEY_minus :
                                unload_cb(NULL, pluginwindow);
                                break;
                        default :
@@ -255,7 +263,7 @@ static gboolean pluginwindow_key_pressed(GtkWidget *widget, GdkEventKey *event,
 static void pluginwindow_size_allocate_cb(GtkWidget *widget,
                                         GtkAllocation *allocation)
 {
-       g_return_if_fail(allocation != NULL);
+       cm_return_if_fail(allocation != NULL);
 
        prefs_common.pluginswin_width = allocation->width;
        prefs_common.pluginswin_height = allocation->height;
@@ -281,12 +289,11 @@ void pluginwindow_create()
        GtkWidget *load_btn;
        GtkWidget *unload_btn;
        GtkWidget *close_btn;
-       GtkWidget *get_more_btn;
+       gchar *markup;
        GtkWidget *desc_lbl;
        GtkWidget *vbox3;
        GtkWidget *hbox_info;
        static GdkGeometry geometry;
-       CLAWS_TIP_DECL();       
 
        debug_print("Creating plugins window...\n");
 
@@ -363,16 +370,15 @@ void pluginwindow_create()
        hbox_info = gtk_hbox_new(FALSE, 5);
        gtk_widget_show(hbox_info);
        
-       desc_lbl = gtk_label_new(_("More plugins are available from the "
-                                  "Claws Mail website."));
+       desc_lbl = gtk_label_new("");
+       markup = g_markup_printf_escaped(_("For more information about plugins see the "
+                                          "<a href=\"%s\"><span underline=\"none\">Claws Mail website</span></a>."),PLUGINS_URI);
+       gtk_label_set_markup(GTK_LABEL(desc_lbl), markup);
+       g_free(markup);
        gtk_misc_set_alignment(GTK_MISC(desc_lbl), 0, 0.5);
        gtk_widget_show(desc_lbl);
        gtk_box_pack_start(GTK_BOX(hbox_info), desc_lbl, FALSE, FALSE, 0);
 
-       get_more_btn = gtkut_get_link_btn(window, PLUGINS_URI, _("Get more..."));
-       gtk_misc_set_alignment(GTK_MISC(gtk_bin_get_child(GTK_BIN((get_more_btn)))), 0, 0.5);
-       gtk_widget_show(get_more_btn);
-       gtk_box_pack_start(GTK_BOX(hbox_info), get_more_btn, FALSE, FALSE, 0);
        gtk_box_pack_start(GTK_BOX(hbox_info), gtk_label_new(""), TRUE, TRUE, 0);
        gtk_box_pack_start(GTK_BOX(vbox1), hbox_info, FALSE, FALSE, 0);
 
@@ -402,6 +408,7 @@ void pluginwindow_create()
                           G_CALLBACK(pluginwindow_key_pressed), pluginwindow);
        g_signal_connect(G_OBJECT(window), "delete_event",
                         G_CALLBACK(pluginwindow_delete_cb), pluginwindow);
+       MANAGE_WINDOW_SIGNALS_CONNECT(window);
 
        CLAWS_SET_TIP(load_btn,
                        _("Click here to load one or more plugins"));