fix the fix
[claws.git] / src / prefs_template.c
index 732c7cf6312779ce57e0b102be497e1285fd3a15..77a34bed49c7dd1fefd39551a1f75e3bf78e3db5 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Claws Mail templates subsystem 
  * Copyright (C) 2001 Alexander Barinov
- * Copyright (C) 2001-2013 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 2001-2020 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
@@ -194,6 +194,7 @@ static void prefs_template_window_create(void)
        window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "prefs_template");
        gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
        gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
+       gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG);
 
        vbox = gtk_vbox_new(FALSE, 8);
        gtk_widget_show(vbox);
@@ -233,7 +234,7 @@ static void prefs_template_window_create(void)
 
                label = gtk_label_new( (i != 0) ?
                        prefs_common_translated_header_name(widgets_table[i].label) :
-                       widgets_table[i].label);
+                       _(widgets_table[i].label));
                gtk_widget_show(label);
                gtk_table_attach(GTK_TABLE(table), label, 0, 1, i, (i + 1),
                                (GtkAttachOptions) (GTK_FILL),
@@ -246,7 +247,7 @@ static void prefs_template_window_create(void)
                                (GtkAttachOptions) (GTK_EXPAND|GTK_SHRINK|GTK_FILL),
                                (GtkAttachOptions) 0, 0, 0);
                CLAWS_SET_TIP(*(widgets_table[i].entry),
-                               widgets_table[i].tooltips);
+                               _(widgets_table[i].tooltips));
        }
 
        /* template content */
@@ -294,7 +295,6 @@ static void prefs_template_window_create(void)
        arrow1 = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
        gtk_widget_show(arrow1);
        gtk_box_pack_start(GTK_BOX(hbox2), arrow1, FALSE, FALSE, 0);
-       gtk_widget_set_size_request(arrow1, -1, 16);
 
        hbox3 = gtk_hbox_new(TRUE, 4);
        gtk_widget_show(hbox3);
@@ -317,7 +317,7 @@ static void prefs_template_window_create(void)
        CLAWS_SET_TIP(subst_btn,
                        _("Replace the selected template in list with the template above"));
 
-       del_btn = gtk_button_new_with_mnemonic (_("Re_move"));
+       del_btn = gtk_button_new_with_mnemonic (_("D_elete"));
        gtk_button_set_image(GTK_BUTTON(del_btn),
                        gtk_image_new_from_stock(GTK_STOCK_REMOVE,GTK_ICON_SIZE_BUTTON));
        gtk_widget_show(del_btn);
@@ -369,7 +369,7 @@ static void prefs_template_window_create(void)
        CLAWS_SET_TIP(top_btn,
                        _("Move the selected template to the top"));
 
-       PACK_VSPACER(vbox3, spc_vbox, VSPACING_NARROW_2);
+       PACK_SPACER(vbox3, spc_vbox, VSPACING_NARROW_2);
 
        up_btn = gtk_button_new_from_stock(GTK_STOCK_GO_UP);
        gtk_widget_show(up_btn);
@@ -387,7 +387,7 @@ static void prefs_template_window_create(void)
        CLAWS_SET_TIP(down_btn,
                        _("Move the selected template down"));
 
-       PACK_VSPACER(vbox3, spc_vbox, VSPACING_NARROW_2);
+       PACK_SPACER(vbox3, spc_vbox, VSPACING_NARROW_2);
 
        bottom_btn = gtk_button_new_from_stock(GTK_STOCK_GOTO_BOTTOM);
        gtk_widget_show(bottom_btn);
@@ -571,8 +571,8 @@ static void prefs_template_ok_cb(gpointer action, gpointer data)
 
        if (modified && alertpanel(_("Entry not saved"),
                                 _("The entry was not saved. Close anyway?"),
-                                GTK_STOCK_CLOSE, g_strconcat("+", _("_Continue editing"), NULL),
-                                NULL) != G_ALERTDEFAULT) {
+                                GTK_STOCK_CLOSE, _("_Continue editing"), NULL,
+                                ALERTFOCUS_SECOND) != G_ALERTDEFAULT) {
                return;
        } 
 
@@ -596,13 +596,13 @@ static void prefs_template_cancel_cb(gpointer action, gpointer data)
 
        if (modified && alertpanel(_("Entry not saved"),
                                 _("The entry was not saved. Close anyway?"),
-                                GTK_STOCK_CLOSE, g_strconcat("+", _("_Continue editing"), NULL),
-                                NULL) != G_ALERTDEFAULT) {
+                                GTK_STOCK_CLOSE, _("_Continue editing"), NULL,
+                                ALERTFOCUS_SECOND) != G_ALERTDEFAULT) {
                return;
        } else if (modified_list && alertpanel(_("Templates list not saved"),
                                 _("The templates list has been modified. Close anyway?"),
-                                GTK_STOCK_CLOSE, g_strconcat("+", _("_Continue editing"), NULL),
-                                NULL) != G_ALERTDEFAULT) {
+                                GTK_STOCK_CLOSE, _("_Continue editing"), NULL,
+                                ALERTFOCUS_SECOND) != G_ALERTDEFAULT) {
                return;
        }
 
@@ -714,19 +714,11 @@ gboolean prefs_template_string_is_valid(gchar *string, gint *line, gboolean esca
                if (!parsed_buf) {
                        if (line)
                                *line = quote_fmt_get_line();
+                       quote_fmtlex_destroy();
                        return FALSE;
                }
-               if (email) {
-                       const gchar *start = strrchr(parsed_buf, '<');
-                       const gchar *end = strrchr(parsed_buf, '>');
-                       const gchar *at = strrchr(parsed_buf, '@');
-                       const gchar *space = strrchr(parsed_buf, ' ');
-                       if (!at)
-                               result = FALSE;
-                       if (at && space && (!start || !end || end < start || start < space))
-                               result = FALSE;
-               }
                quote_fmt_reset_vartable();
+               quote_fmtlex_destroy();
        }
        return result;
 }
@@ -911,8 +903,8 @@ static void prefs_template_delete_cb(gpointer action, gpointer data)
 
        if (alertpanel(_("Delete template"),
                       _("Do you really want to delete this template?"),
-                      GTK_STOCK_CANCEL, GTK_STOCK_DELETE,
-                      NULL) != G_ALERTALTERNATE)
+                      GTK_STOCK_CANCEL, GTK_STOCK_DELETE, NULL,
+                                        ALERTFOCUS_FIRST) != G_ALERTALTERNATE)
                return;
 
        gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
@@ -924,7 +916,8 @@ static void prefs_template_delete_all_cb(gpointer action, gpointer data)
 {
        if (alertpanel(_("Delete all templates"),
                          _("Do you really want to delete all the templates?"),
-                         GTK_STOCK_CANCEL, "+"GTK_STOCK_DELETE, NULL) == G_ALERTDEFAULT)
+                         GTK_STOCK_CANCEL, GTK_STOCK_DELETE, NULL,
+                               ALERTFOCUS_SECOND) == G_ALERTDEFAULT)
           return;
 
        prefs_template_clear_list();
@@ -1115,7 +1108,7 @@ static GtkWidget *prefs_template_popup_menu = NULL;
 
 static GtkActionEntry prefs_template_popup_entries[] =
 {
-       {"PrefsTemplatePopup",                  NULL, "PrefsTemplatePopup" },
+       {"PrefsTemplatePopup",                  NULL, "PrefsTemplatePopup", NULL, NULL, NULL },
        {"PrefsTemplatePopup/Delete",           NULL, N_("_Delete"), NULL, NULL, G_CALLBACK(prefs_template_delete_cb) },
        {"PrefsTemplatePopup/DeleteAll",        NULL, N_("Delete _all"), NULL, NULL, G_CALLBACK(prefs_template_delete_all_cb) },
        {"PrefsTemplatePopup/Duplicate",        NULL, N_("D_uplicate"), NULL, NULL, G_CALLBACK(prefs_template_duplicate_cb) },