2007-10-05 [paul] 3.0.2cvs13
[claws.git] / src / prefs_actions.c
index 33f2e5d4712ac07ec3a88fe9e4cbb1d90540cb9e..a6eb2eed4525f73873f155bce9d5df846f88bd66 100644 (file)
@@ -1,10 +1,10 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto & The Sylpheed Claws Team
+ * Copyright (C) 1999-2007 Hiroyuki Yamamoto & 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,
@@ -13,8 +13,8 @@
  * 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
@@ -70,6 +70,7 @@ static struct Actions
 } actions;
 
 static int modified = FALSE;
+static int modified_list = FALSE;
 
 /* widget creating functions */
 static void prefs_actions_create       (MainWindow *mainwin);
@@ -152,9 +153,8 @@ static void prefs_actions_create(MainWindow *mainwin)
        GtkWidget *confirm_area;
 
        GtkWidget *vbox1;
+       GtkWidget *table;
 
-       GtkWidget *entry_vbox;
-       GtkWidget *hbox;
        GtkWidget *name_label;
        GtkWidget *name_entry;
        GtkWidget *cmd_label;
@@ -180,7 +180,7 @@ static void prefs_actions_create(MainWindow *mainwin)
 
        debug_print("Creating actions configuration window...\n");
 
-       window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+       window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "prefs_actions");
 
        gtk_container_set_border_width(GTK_CONTAINER (window), 8);
        gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
@@ -215,33 +215,42 @@ static void prefs_actions_create(MainWindow *mainwin)
                         G_CALLBACK(manual_open_with_anchor_cb),
                         MANUAL_ANCHOR_ACTIONS);
 
-       vbox1 = gtk_vbox_new(FALSE, 8);
+       vbox1 = gtk_vbox_new(FALSE, VSPACING);
        gtk_widget_show(vbox1);
        gtk_box_pack_start(GTK_BOX(vbox), vbox1, TRUE, TRUE, 0);
        gtk_container_set_border_width(GTK_CONTAINER(vbox1), 2);
 
-       entry_vbox = gtk_vbox_new(FALSE, 4);
-       gtk_box_pack_start(GTK_BOX(vbox1), entry_vbox, FALSE, FALSE, 0);
-
-       hbox = gtk_hbox_new(FALSE, 8);
-       gtk_box_pack_start(GTK_BOX(entry_vbox), hbox, FALSE, FALSE, 0);
-
-       name_label = gtk_label_new(_("Menu name:"));
-       gtk_box_pack_start(GTK_BOX(hbox), name_label, FALSE, FALSE, 0);
-
-       name_entry = gtk_entry_new();
-       gtk_box_pack_start(GTK_BOX(hbox), name_entry, TRUE, TRUE, 0);
-
-       hbox = gtk_hbox_new(FALSE, 8);
-       gtk_box_pack_start(GTK_BOX(entry_vbox), hbox, TRUE, TRUE, 0);
-
-       cmd_label = gtk_label_new(_("Command line:"));
-       gtk_box_pack_start(GTK_BOX(hbox), cmd_label, FALSE, FALSE, 0);
-
-       cmd_entry = gtk_entry_new();
-       gtk_box_pack_start(GTK_BOX(hbox), cmd_entry, TRUE, TRUE, 0);
-
-       gtk_widget_show_all(entry_vbox);
+       table = gtk_table_new(2, 2, FALSE);
+       gtk_table_set_row_spacings (GTK_TABLE (table), VSPACING_NARROW_2);
+       gtk_table_set_col_spacings (GTK_TABLE (table), 4);
+       gtk_widget_show(table);
+       gtk_box_pack_start (GTK_BOX (vbox1), table, FALSE, FALSE, 0);
+
+       name_label = gtk_label_new (_("Menu name"));
+       gtk_widget_show (name_label);
+       gtk_misc_set_alignment (GTK_MISC (name_label), 1, 0.5);
+       gtk_table_attach (GTK_TABLE (table), name_label, 0, 1, 0, 1,
+                         (GtkAttachOptions) (GTK_FILL),
+                         (GtkAttachOptions) (0), 0, 0);
+
+       name_entry = gtk_entry_new ();
+       gtk_widget_show (name_entry);
+       gtk_table_attach (GTK_TABLE (table), name_entry, 1, 2, 0, 1,
+                         (GtkAttachOptions) (GTK_FILL|GTK_EXPAND),
+                         (GtkAttachOptions) (0), 0, 0);
+
+       cmd_label = gtk_label_new (_("Command line"));
+       gtk_widget_show (cmd_label);
+       gtk_misc_set_alignment (GTK_MISC (cmd_label), 1, 0.5);
+       gtk_table_attach (GTK_TABLE (table), cmd_label, 0, 1, 1, 2,
+                         (GtkAttachOptions) (GTK_FILL),
+                         (GtkAttachOptions) (0), 0, 0);
+
+       cmd_entry = gtk_entry_new ();
+       gtk_widget_show (cmd_entry);
+       gtk_table_attach (GTK_TABLE (table), cmd_entry, 1, 2, 1, 2,
+                         (GtkAttachOptions) (GTK_FILL|GTK_EXPAND),
+                         (GtkAttachOptions) (0), 0, 0);
 
        /* register / substitute / delete */
 
@@ -280,7 +289,7 @@ static void prefs_actions_create(MainWindow *mainwin)
 #if GTK_CHECK_VERSION(2, 8, 0)
        info_btn = gtk_button_new_from_stock(GTK_STOCK_INFO);
 #else
-       info_btn = gtk_button_new_with_label(_("Information"));
+       info_btn = gtk_button_new_with_label(_("Info..."));
 #endif
        gtk_widget_show(info_btn);
        gtk_box_pack_end(GTK_BOX(reg_hbox), info_btn, FALSE, FALSE, 0);
@@ -373,7 +382,7 @@ void prefs_actions_read_config(void)
 
                tmp = conv_codeset_strdup(buf, src_codeset, dest_codeset);
                if (!tmp) {
-                       g_warning("Faild to convert character set of action configuration\n");
+                       g_warning("Failed to convert character set of action configuration\n");
                        tmp = g_strdup(buf);
                }
 
@@ -400,7 +409,7 @@ void prefs_actions_write_config(void)
 
        rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ACTIONS_RC, NULL);
        if ((pfile= prefs_write_open(rcpath)) == NULL) {
-               g_warning("failed to write configuration to file\n");
+               g_warning("Failed to write configuration to file\n");
                g_free(rcpath);
                return;
        }
@@ -413,7 +422,7 @@ void prefs_actions_write_config(void)
 
                act = conv_codeset_strdup(tmp, src_codeset, dest_codeset);
                if (!act) {
-                       g_warning("Faild to convert character set of action configuration\n");
+                       g_warning("Failed to convert character set of action configuration\n");
                        act = g_strdup(act);
                }
 
@@ -447,7 +456,7 @@ static void prefs_actions_set_dialog(void)
        gtk_list_store_clear(store);
 
        prefs_actions_list_view_insert_action(actions.actions_list_view,
-                                             NULL, _("New"), FALSE);
+                                             NULL, _("(New)"), FALSE);
 
        for (cur = prefs_common.actions_list; cur != NULL; cur = cur->next) {
                gchar *action = (gchar *) cur->data;
@@ -560,8 +569,11 @@ static gint prefs_actions_clist_set_row(GtkTreeIter *row)
        }
 
        if (action_get_type(entry_text) == ACTION_ERROR) {
-               alertpanel_error(_("The command\n%s\nhas a syntax error."), 
-                                entry_text);
+               gchar *message;
+               message = g_markup_printf_escaped(_("The command\n%s\nhas a syntax error."),
+                                               entry_text);
+               alertpanel_error(message);
+               g_free(message);
                return -1;
        }
 
@@ -582,6 +594,7 @@ static void prefs_actions_register_cb(GtkWidget *w, gpointer data)
 {
        prefs_actions_clist_set_row(NULL);
        modified = FALSE;
+       modified_list = TRUE;
 }
 
 static void prefs_actions_substitute_cb(GtkWidget *w, gpointer data)
@@ -607,6 +620,7 @@ static void prefs_actions_substitute_cb(GtkWidget *w, gpointer data)
        gtk_tree_path_free(path_sel);
        gtk_tree_path_free(path_new);
        modified = FALSE;
+       modified_list = TRUE;
 }
 
 static void prefs_actions_delete_cb(GtkWidget *w, gpointer data)
@@ -634,6 +648,7 @@ static void prefs_actions_delete_cb(GtkWidget *w, gpointer data)
 
        prefs_common.actions_list = g_slist_remove(prefs_common.actions_list,
                                                   action);
+       modified_list = TRUE;
 }
 
 static void prefs_actions_up(GtkWidget *w, gpointer data)
@@ -679,6 +694,7 @@ static void prefs_actions_up(GtkWidget *w, gpointer data)
 
        gtk_list_store_swap(store, &iprev, &isel);
        prefs_actions_set_list();
+       modified_list = TRUE;
 }
 
 static void prefs_actions_down(GtkWidget *w, gpointer data)
@@ -712,6 +728,7 @@ static void prefs_actions_down(GtkWidget *w, gpointer data)
 
        gtk_list_store_swap(store, &next, &sel);
        prefs_actions_set_list();
+       modified_list = TRUE;
 }
 
 static gint prefs_actions_deleted(GtkWidget *widget, GdkEventAny *event,
@@ -743,8 +760,14 @@ static void prefs_actions_cancel(GtkWidget *w, gpointer data)
                                 GTK_STOCK_CLOSE, _("+_Continue editing"),
                                 NULL) != G_ALERTDEFAULT) {
                return;
+       } else if (modified_list && alertpanel(_("Actions list not saved"),
+                                _("The actions list has been modified. Close anyway?"),
+                                GTK_STOCK_CLOSE, _("+_Continue editing"), 
+                                NULL) != G_ALERTDEFAULT) {
+               return;
        }
        modified = FALSE;
+       modified_list = FALSE;
        prefs_actions_read_config();
        gtk_widget_hide(actions.window);
        inc_unlock();
@@ -763,8 +786,14 @@ static void prefs_actions_ok(GtkWidget *widget, gpointer data)
                                 GTK_STOCK_CLOSE, _("+_Continue editing"),
                                 NULL) != G_ALERTDEFAULT) {
                return;
+       } else if (modified_list && alertpanel(_("Actions list not saved"),
+                                _("The actions list has been modified. Close anyway?"),
+                                GTK_STOCK_CLOSE, _("+_Continue editing"), 
+                                NULL) != G_ALERTDEFAULT) {
+               return;
        }
        modified = FALSE;
+       modified_list = FALSE;
        prefs_actions_set_list();
        prefs_actions_write_config();
 
@@ -815,6 +844,7 @@ static gchar *actions_desc_strings[] = {
        "     %h",  N_("for a user provided hidden argument (e.g. password)"),
        "     %s",  N_("for the text selection"),
        "  %as{}",  N_("apply filtering actions between {} to selected messages"),
+       "     %%",  N_("for a literal %"),
        NULL, NULL
 };
 
@@ -889,7 +919,7 @@ static GtkWidget *prefs_actions_list_view_create(void)
        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_reorderable(list_view, TRUE);
 
        selector = gtk_tree_view_get_selection(list_view);