Remove more markup from translatable strings
[claws.git] / src / gtk / pluginwindow.c
index 67381f77d5324099e1c200263c1e0da8f884f352..02bc891ae87e23a3a2c9f8eeab83ce7dc152cfe5 100644 (file)
@@ -1,10 +1,10 @@
 /*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto and the Sylpheed-Claws Team
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2015 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
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
+#include "claws-features.h"
 #endif
 
 #include <glib.h>
@@ -35,6 +35,8 @@
 #include "alertpanel.h"
 #include "prefs_common.h"
 #include "../inc.h"
+#include "manual.h"
+#include "manage_window.h"
 
 enum {
        PLUGINWINDOW_NAME,              /*<! plugin name */
@@ -51,6 +53,8 @@ typedef struct _PluginWindow
        GtkWidget *unload_btn;
 
        Plugin *selected_plugin;
+       
+       gboolean loading;
 } PluginWindow;
 
 static GtkListStore* pluginwindow_create_data_store    (void);
@@ -64,12 +68,23 @@ 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();
        inc_unlock();
 }
 
+static gint pluginwindow_delete_cb(GtkWidget *widget, GdkEventAny *event,
+                                 PluginWindow *pluginwindow)
+{
+       if (pluginwindow->loading)
+               return FALSE;
+       close_cb(NULL,pluginwindow);
+       return TRUE;
+}
+
 static void set_plugin_list(PluginWindow *pluginwindow)
 {
        GSList *plugins, *cur, *unloaded;
@@ -121,11 +136,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);
 }
 
@@ -170,8 +184,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);
 }
@@ -181,12 +197,12 @@ static void load_cb(GtkButton *button, PluginWindow *pluginwindow)
        GList *file_list;
 
        file_list = filesel_select_multiple_files_open_with_filter(
-                       _("Select Plugin to load"), get_plugin_dir(), 
+                       _("Select the Plugins to load"), get_plugin_dir(), 
                        "*." G_MODULE_SUFFIX);
 
        if (file_list) {
                GList *tmp;
-
+               pluginwindow->loading = TRUE;
                for ( tmp = file_list; tmp; tmp = tmp->next) {
                        gchar *file, *error = NULL;
 
@@ -194,9 +210,11 @@ static void load_cb(GtkButton *button, PluginWindow *pluginwindow)
                        if (!file) continue;
                        plugin_load(file, &error);
                        if (error != NULL) {
+                               gchar *basename = g_path_get_basename(file);
                                alertpanel_error(
-                               _("The following error occured while loading the plugin [%s] :\n%s\n"),
-                               file, error);
+                               _("The following error occurred while loading %s :\n\n%s\n"),
+                               basename, error);
+                               g_free(basename);
                                g_free(error);
                        }
 
@@ -204,7 +222,7 @@ static void load_cb(GtkButton *button, PluginWindow *pluginwindow)
                        set_plugin_list(pluginwindow);
                        g_free(file);
                }
-
+               pluginwindow->loading = FALSE;
                g_list_free(file_list);
        }               
 }
@@ -214,21 +232,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 :
@@ -244,7 +262,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;
@@ -254,7 +272,6 @@ static void pluginwindow_size_allocate_cb(GtkWidget *widget,
 void pluginwindow_create()
 {
        PluginWindow *pluginwindow;
-       /* ---------------------- code made by glade ---------------------- */
        GtkWidget *window;
        GtkWidget *vbox1;
        GtkWidget *hbox2;
@@ -265,33 +282,47 @@ void pluginwindow_create()
        GtkWidget *label13;
        GtkWidget *scrolledwindow3;
        GtkWidget *plugin_desc;
-       GtkWidget *hbuttonbox1, *hbox3;
+       GtkWidget *hbuttonbox1;
+       GtkWidget *hbuttonbox2;
+       GtkWidget *help_btn;
        GtkWidget *load_btn;
        GtkWidget *unload_btn;
        GtkWidget *close_btn;
-       GtkWidget *get_more_btn;
+       gchar *markup, *span;
+       GtkWidget *desc_lbl;
+       GtkWidget *vbox3;
+       GtkWidget *hbox_info;
        static GdkGeometry geometry;
-       
+
        debug_print("Creating plugins window...\n");
 
        pluginwindow = g_new0(PluginWindow, 1);
 
-       window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+       window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "pluginwindow");
        gtk_container_set_border_width(GTK_CONTAINER(window), 8);
        gtk_window_set_title(GTK_WINDOW(window), _("Plugins"));
        gtk_window_set_modal(GTK_WINDOW(window), TRUE);
+       manage_window_set_transient(GTK_WINDOW(window));
 
        vbox1 = gtk_vbox_new(FALSE, 4);
        gtk_widget_show(vbox1);
        gtk_container_add(GTK_CONTAINER(window), vbox1);
+       gtk_box_set_homogeneous(GTK_BOX(vbox1), FALSE);
+       gtk_widget_realize(window);
 
        hbox2 = gtk_hbox_new(FALSE, 8);
        gtk_widget_show(hbox2);
        gtk_box_pack_start(GTK_BOX(vbox1), hbox2, TRUE, TRUE, 0);
 
+       vbox3 = gtk_vbox_new(FALSE, 4);
+       gtk_widget_show(vbox3);
+       gtk_box_pack_start(GTK_BOX(hbox2), vbox3, FALSE, FALSE, 0);
+
        scrolledwindow2 = gtk_scrolled_window_new(NULL, NULL);
        gtk_widget_show(scrolledwindow2);
-       gtk_box_pack_start(GTK_BOX(hbox2), scrolledwindow2, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(vbox3), scrolledwindow2, TRUE, TRUE, 0);
+       gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow2),
+                                       GTK_SHADOW_ETCHED_IN);
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW
                                       (scrolledwindow2), GTK_POLICY_NEVER,
                                       GTK_POLICY_AUTOMATIC);
@@ -301,6 +332,13 @@ void pluginwindow_create()
        gtk_container_add(GTK_CONTAINER(scrolledwindow2), plugin_list_view);
        gtk_widget_grab_focus(GTK_WIDGET(plugin_list_view));
 
+       gtkut_stock_button_set_create(&hbuttonbox1,
+                               &load_btn, _("Load..."),
+                               &unload_btn, _("Unload"),
+                               NULL, NULL);
+       gtk_widget_show(hbuttonbox1);
+       gtk_box_pack_start(GTK_BOX(vbox3), hbuttonbox1, FALSE, FALSE, 0);
+       
        vbox2 = gtk_vbox_new(FALSE, 0);
        gtk_widget_show(vbox2);
        gtk_box_pack_start(GTK_BOX(hbox2), vbox2, TRUE, TRUE, 0);
@@ -318,6 +356,8 @@ void pluginwindow_create()
        scrolledwindow3 = gtk_scrolled_window_new(NULL, NULL);
        gtk_widget_show(scrolledwindow3);
        gtk_box_pack_start(GTK_BOX(vbox2), scrolledwindow3, TRUE, TRUE, 0);
+       gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow3),
+                                       GTK_SHADOW_ETCHED_IN);
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW
                                       (scrolledwindow3), GTK_POLICY_NEVER,
                                       GTK_POLICY_ALWAYS);
@@ -326,53 +366,56 @@ void pluginwindow_create()
        gtk_widget_show(plugin_desc);
        gtk_container_add(GTK_CONTAINER(scrolledwindow3), plugin_desc);
 
-       hbox3 = gtk_hbox_new(FALSE, 0);
-       gtk_widget_show(hbox3);
-       hbuttonbox1 = gtk_hbutton_box_new();
-       gtk_widget_show(hbuttonbox1);
-
-       gtk_widget_realize(window);
-       get_more_btn = gtkut_get_link_btn(window, PLUGINS_URI, _("Get more..."));
-       gtk_misc_set_alignment(GTK_MISC(GTK_BIN(get_more_btn)->child), 0, 0.5);
-       gtk_widget_show(get_more_btn);
-
-       gtk_box_pack_start(GTK_BOX(hbox3), get_more_btn, TRUE, TRUE, 0);
-       gtk_box_pack_start(GTK_BOX(hbox3), hbuttonbox1, FALSE, FALSE, 0);
-       gtk_box_pack_start(GTK_BOX(vbox1), hbox3, FALSE, FALSE, 0);
-       gtk_button_box_set_layout(GTK_BUTTON_BOX(hbuttonbox1),
-                                 GTK_BUTTONBOX_END);
-       gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbuttonbox1), 6);
-
-       load_btn = gtk_button_new_with_label(_("Load Plugin..."));
-       gtk_widget_show(load_btn);
-       gtk_container_add(GTK_CONTAINER(hbuttonbox1), load_btn);
-       GTK_WIDGET_SET_FLAGS(load_btn, GTK_CAN_DEFAULT);
-
-       unload_btn = gtk_button_new_with_label(_("Unload Plugin"));
-       gtk_widget_show(unload_btn);
-       gtk_container_add(GTK_CONTAINER(hbuttonbox1), unload_btn);
-       GTK_WIDGET_SET_FLAGS(unload_btn, GTK_CAN_DEFAULT);
-
-       close_btn = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
-       gtk_widget_show(close_btn);
-       gtk_container_add(GTK_CONTAINER(hbuttonbox1), close_btn);
-       GTK_WIDGET_SET_FLAGS(close_btn, GTK_CAN_DEFAULT);
-       /* ----------------------------------------------------------- */
+       hbox_info = gtk_hbox_new(FALSE, 5);
+       gtk_widget_show(hbox_info);
+       
+       desc_lbl = gtk_label_new("");
+       span = g_strdup_printf("<a href=\"%s\"><span underline=\"none\">", PLUGINS_URI);
+       markup = g_strdup_printf(_("For more information about plugins see the "
+                                          "%sClaws Mail website%s."), span, "</span></a>");
+       gtk_label_set_markup(GTK_LABEL(desc_lbl), markup);
+       g_free(markup);
+       g_free(span);
+       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);
+
+       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);
+
+       gtkut_stock_button_set_create_with_help(&hbuttonbox2, &help_btn,
+                       &close_btn, GTK_STOCK_CLOSE,
+                       NULL, NULL, NULL, NULL);
+
+       gtk_box_set_spacing(GTK_BOX(hbuttonbox2), 6);
+       gtk_widget_show(hbuttonbox2);
+       gtk_box_pack_end(GTK_BOX(vbox1), hbuttonbox2, FALSE, FALSE, 0);
 
        gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(plugin_desc), GTK_WRAP_WORD);
        gtk_widget_set_sensitive(GTK_WIDGET(unload_btn), FALSE);
 
-
-       g_signal_connect(G_OBJECT(load_btn), "released",
+       g_signal_connect(G_OBJECT(help_btn), "clicked",
+                        G_CALLBACK(manual_open_with_anchor_cb),
+                        MANUAL_ANCHOR_PLUGINS);
+       g_signal_connect(G_OBJECT(load_btn), "clicked",
                         G_CALLBACK(load_cb), pluginwindow);
-       g_signal_connect(G_OBJECT(unload_btn), "released",
+       g_signal_connect(G_OBJECT(unload_btn), "clicked",
                         G_CALLBACK(unload_cb), pluginwindow);
-       g_signal_connect(G_OBJECT(close_btn), "released",
+       g_signal_connect(G_OBJECT(close_btn), "clicked",
                         G_CALLBACK(close_cb), pluginwindow);
        g_signal_connect(G_OBJECT(window), "size_allocate",
                         G_CALLBACK(pluginwindow_size_allocate_cb), NULL);
        g_signal_connect(G_OBJECT(window), "key_press_event",
                           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"));
+
+       CLAWS_SET_TIP(unload_btn,
+                       _("Unload the selected plugin"));
 
        pluginwindow->window = window;
        pluginwindow->plugin_list_view = plugin_list_view;
@@ -385,13 +428,13 @@ void pluginwindow_create()
        inc_lock();
 
        if (!geometry.min_height) {
-               geometry.min_width = 480;
+               geometry.min_width = -1;
                geometry.min_height = 300;
        }
 
        gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
                                      GDK_HINT_MIN_SIZE);
-       gtk_widget_set_size_request(window, prefs_common.pluginswin_width,
+       gtk_window_set_default_size(GTK_WINDOW(window), prefs_common.pluginswin_width,
                                    prefs_common.pluginswin_height);
 
        gtk_widget_show(window);
@@ -416,7 +459,7 @@ static GtkWidget *pluginwindow_list_view_create(PluginWindow *pluginwindow)
        list_view = GTK_TREE_VIEW(gtk_tree_view_new_with_model(model));
        g_object_unref(model);  
 
-       gtk_tree_view_set_rules_hint(list_view, prefs_common.enable_rules_hint);
+       gtk_tree_view_set_rules_hint(list_view, prefs_common.use_stripes_everywhere);
        gtk_tree_view_set_search_column (list_view, 0);
 
        selector = gtk_tree_view_get_selection(list_view);
@@ -437,7 +480,7 @@ static void pluginwindow_create_list_view_columns(GtkWidget *list_view)
 
        renderer = gtk_cell_renderer_text_new();
        column = gtk_tree_view_column_new_with_attributes
-               (_("Plugins"),
+               (_("Loaded plugins"),
                 renderer,
                 "text", PLUGINWINDOW_NAME,
                 "style", PLUGINWINDOW_STYLE,