2008-05-02 [wwp] 3.4.0cvs20
[claws.git] / src / prefs_folder_item.c
index 20effe940f9d43707f2171bf0dccb93a3db9b3a5..fd502334d2ad000e659fc50fe9fdc879642f85f6 100644 (file)
@@ -85,6 +85,7 @@ struct _FolderItemGeneralPage
        GtkWidget *entry_folder_chmod;
        GtkWidget *folder_color_btn;
        GtkWidget *checkbtn_enable_processing;
+       GtkWidget *checkbtn_enable_processing_when_opening;
        GtkWidget *checkbtn_newmailcheck;
        GtkWidget *checkbtn_offlinesync;
        GtkWidget *label_offlinesync;
@@ -97,6 +98,7 @@ struct _FolderItemGeneralPage
        GtkWidget *folder_chmod_rec_checkbtn;
        GtkWidget *folder_color_rec_checkbtn;
        GtkWidget *enable_processing_rec_checkbtn;
+       GtkWidget *enable_processing_when_opening_rec_checkbtn;
        GtkWidget *newmailcheck_rec_checkbtn;
        GtkWidget *offlinesync_rec_checkbtn;
 
@@ -148,13 +150,16 @@ struct _FolderItemTemplatesPage
        GtkWidget *window;
        GtkWidget *table;
        GtkWidget *checkbtn_compose_with_format;
+       GtkWidget *compose_override_from_format;
        GtkWidget *compose_subject_format;
        GtkWidget *compose_body_format;
        GtkWidget *checkbtn_reply_with_format;
        GtkWidget *reply_quotemark;
+       GtkWidget *reply_override_from_format;
        GtkWidget *reply_body_format;
        GtkWidget *checkbtn_forward_with_format;
        GtkWidget *forward_quotemark;
+       GtkWidget *forward_override_from_format;
        GtkWidget *forward_body_format;
 
        /* apply to sub folders */
@@ -214,6 +219,7 @@ static void prefs_folder_item_general_create_widget_func(PrefsPage * page_,
        GtkWidget *folder_color;
        GtkWidget *folder_color_btn;
        GtkWidget *checkbtn_enable_processing;
+       GtkWidget *checkbtn_enable_processing_when_opening;
        GtkWidget *checkbtn_newmailcheck;
        GtkWidget *checkbtn_offlinesync;
        GtkWidget *label_offlinesync;
@@ -225,6 +231,7 @@ static void prefs_folder_item_general_create_widget_func(PrefsPage * page_,
        GtkWidget *folder_chmod_rec_checkbtn;
        GtkWidget *folder_color_rec_checkbtn;
        GtkWidget *enable_processing_rec_checkbtn;
+       GtkWidget *enable_processing_when_opening_rec_checkbtn;
        GtkWidget *newmailcheck_rec_checkbtn;
        GtkWidget *offlinesync_rec_checkbtn;
        GtkTooltips *tooltips;
@@ -233,7 +240,7 @@ static void prefs_folder_item_general_create_widget_func(PrefsPage * page_,
        page->item         = item;
 
        /* Table */
-       table = gtk_table_new(10, 4, FALSE);
+       table = gtk_table_new(11, 4, FALSE);
        gtk_container_set_border_width (GTK_CONTAINER (table), VBOX_BORDER);
        gtk_table_set_row_spacings(GTK_TABLE(table), 4);
        gtk_table_set_col_spacings(GTK_TABLE(table), 4);
@@ -422,7 +429,8 @@ static void prefs_folder_item_general_create_widget_func(PrefsPage * page_,
        rowcount++;
 
        /* Enable processing at startup */
-       checkbtn_enable_processing = gtk_check_button_new_with_label(_("Process at start-up"));
+       checkbtn_enable_processing =
+               gtk_check_button_new_with_label(_("Run Processing rules at start-up"));
        gtk_table_attach(GTK_TABLE(table), checkbtn_enable_processing, 0, 2, 
                         rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
 
@@ -435,6 +443,21 @@ static void prefs_folder_item_general_create_widget_func(PrefsPage * page_,
        
        rowcount++;
 
+       /* Enable processing rules when opening folder */
+       checkbtn_enable_processing_when_opening =
+               gtk_check_button_new_with_label(_("Run Processing rules when opening"));
+       gtk_table_attach(GTK_TABLE(table), checkbtn_enable_processing_when_opening, 0, 2, 
+                        rowcount, rowcount + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
+
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_processing_when_opening), 
+                                    item->prefs->enable_processing_when_opening);
+
+       enable_processing_when_opening_rec_checkbtn = gtk_check_button_new();
+       gtk_table_attach(GTK_TABLE(table), enable_processing_when_opening_rec_checkbtn, 3, 4, 
+                        rowcount, rowcount + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
+       
+       rowcount++;
+
        /* Check folder for new mail */
        checkbtn_newmailcheck = gtk_check_button_new_with_label(_("Scan for new mail"));
        gtk_tooltips_set_tip(tooltips, checkbtn_newmailcheck,
@@ -550,6 +573,7 @@ static void prefs_folder_item_general_create_widget_func(PrefsPage * page_,
        page->entry_folder_chmod = entry_folder_chmod;
        page->folder_color_btn = folder_color_btn;
        page->checkbtn_enable_processing = checkbtn_enable_processing;
+       page->checkbtn_enable_processing_when_opening = checkbtn_enable_processing_when_opening;
        page->checkbtn_newmailcheck = checkbtn_newmailcheck;
        page->checkbtn_offlinesync = checkbtn_offlinesync;
        page->label_offlinesync = label_offlinesync;
@@ -561,6 +585,7 @@ static void prefs_folder_item_general_create_widget_func(PrefsPage * page_,
        page->folder_chmod_rec_checkbtn      = folder_chmod_rec_checkbtn;
        page->folder_color_rec_checkbtn      = folder_color_rec_checkbtn;
        page->enable_processing_rec_checkbtn = enable_processing_rec_checkbtn;
+       page->enable_processing_when_opening_rec_checkbtn = enable_processing_when_opening_rec_checkbtn;
        page->newmailcheck_rec_checkbtn      = newmailcheck_rec_checkbtn;
        page->offlinesync_rec_checkbtn       = offlinesync_rec_checkbtn;
 
@@ -628,6 +653,11 @@ static void general_save_folder_prefs(FolderItem *folder, FolderItemGeneralPage
                        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_enable_processing));
        }
 
+       if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->enable_processing_when_opening_rec_checkbtn))) {
+               prefs->enable_processing_when_opening = 
+                       gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_enable_processing_when_opening));
+       }
+
        if (all ||  gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->newmailcheck_rec_checkbtn))) {
                prefs->newmailcheck = 
                        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_newmailcheck));
@@ -663,6 +693,7 @@ static gboolean general_save_recurse_func(GNode *node, gpointer data)
              gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->folder_chmod_rec_checkbtn)) ||
              gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->folder_color_rec_checkbtn)) ||
              gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->enable_processing_rec_checkbtn)) ||
+             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->enable_processing_when_opening_rec_checkbtn)) ||
              gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->newmailcheck_rec_checkbtn)) ||
              gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->offlinesync_rec_checkbtn))))
                return TRUE;
@@ -864,7 +895,7 @@ static void prefs_folder_item_compose_create_widget_func(PrefsPage * page_,
                if (item->folder->klass->type != F_NEWS && ac_prefs->protocol == A_NNTP)
                        continue;
 
-               COMBOBOX_ADD (optmenu_default_account_menu,
+               COMBOBOX_ADD_ESCAPED (optmenu_default_account_menu,
                                        ac_prefs->account_name?ac_prefs->account_name : _("Untitled"),
                                        ac_prefs->account_id);
 
@@ -972,8 +1003,6 @@ static void prefs_folder_item_compose_create_widget_func(PrefsPage * page_,
        page->default_alt_dictionary_rec_checkbtn = default_alt_dictionary_rec_checkbtn;
 #endif
 
-       address_completion_start(page->window);
-
        page->page.widget = table;
 }
 
@@ -985,7 +1014,6 @@ static void prefs_folder_item_compose_destroy_widget_func(PrefsPage *page_)
                address_completion_unregister_entry(GTK_ENTRY(page->entry_default_to));
        if (page->entry_default_reply_to)
                address_completion_unregister_entry(GTK_ENTRY(page->entry_default_reply_to));
-       address_completion_end(page->window);
 }
 
 /** \brief  Save the prefs in page to folder.
@@ -1125,6 +1153,7 @@ static void prefs_folder_item_templates_create_widget_func(PrefsPage * page_,
        GtkWidget *notebook;
        GtkWidget *vbox;
        GtkWidget *page_vbox;
+       GtkWidget *no_save_warning;
        GtkWidget *new_msg_format_rec_checkbtn;
        GtkWidget *reply_format_rec_checkbtn;
        GtkWidget *forward_format_rec_checkbtn;
@@ -1134,6 +1163,17 @@ static void prefs_folder_item_templates_create_widget_func(PrefsPage * page_,
        page_vbox = gtk_vbox_new (FALSE, 0);
        gtk_widget_show (page_vbox);
        
+       if (!can_save) {
+               no_save_warning = gtk_label_new(
+                       _("<i>These preferences will not be saved as this folder "
+                       "is a top-level one. However you can use them to set them "
+                       "to the whole mailbox tree using \"Apply to subfolders\".</i>"));
+               gtk_label_set_use_markup(GTK_LABEL(no_save_warning), TRUE);
+               gtk_label_set_line_wrap(GTK_LABEL(no_save_warning), TRUE);
+               gtk_misc_set_alignment(GTK_MISC(no_save_warning), 0.0, 0.5);
+               gtk_box_pack_start(GTK_BOX(page_vbox), no_save_warning, FALSE, FALSE, 4);
+       }
+
        /* Notebook */
        notebook = gtk_notebook_new();
        gtk_widget_show(notebook);
@@ -1149,9 +1189,12 @@ static void prefs_folder_item_templates_create_widget_func(PrefsPage * page_,
                                window,
                                vbox,
                                &page->checkbtn_compose_with_format,
+                               &page->compose_override_from_format,
                                &page->compose_subject_format,
                                &page->compose_body_format,
-                               FALSE);
+                               FALSE, FALSE);
+       address_completion_register_entry(GTK_ENTRY(page->compose_override_from_format),
+                       TRUE);
 
        new_msg_format_rec_checkbtn = gtk_check_button_new_with_label(
                        _("Apply to subfolders"));
@@ -1167,9 +1210,12 @@ static void prefs_folder_item_templates_create_widget_func(PrefsPage * page_,
                                window,
                                vbox,
                                &page->checkbtn_reply_with_format,
+                               &page->reply_override_from_format,
                                &page->reply_quotemark,
                                &page->reply_body_format,
-                               FALSE);
+                               FALSE, FALSE);
+       address_completion_register_entry(GTK_ENTRY(page->reply_override_from_format),
+                       TRUE);
 
        reply_format_rec_checkbtn = gtk_check_button_new_with_label(
                        _("Apply to subfolders"));
@@ -1185,9 +1231,12 @@ static void prefs_folder_item_templates_create_widget_func(PrefsPage * page_,
                                window,
                                vbox,
                                &page->checkbtn_forward_with_format,
+                               &page->forward_override_from_format,
                                &page->forward_quotemark,
                                &page->forward_body_format,
-                               FALSE);
+                               FALSE, FALSE);
+       address_completion_register_entry(GTK_ENTRY(page->forward_override_from_format),
+                       TRUE);
 
        forward_format_rec_checkbtn = gtk_check_button_new_with_label(
                        _("Apply to subfolders"));
@@ -1199,6 +1248,8 @@ static void prefs_folder_item_templates_create_widget_func(PrefsPage * page_,
 
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(page->checkbtn_compose_with_format),
                        item->prefs->compose_with_format);
+       pref_set_entry_from_pref(GTK_ENTRY(page->compose_override_from_format),
+                       item->prefs->compose_override_from_format);
        pref_set_entry_from_pref(GTK_ENTRY(page->compose_subject_format),
                        item->prefs->compose_subject_format);
        pref_set_textview_from_pref(GTK_TEXT_VIEW(page->compose_body_format),
@@ -1208,6 +1259,8 @@ static void prefs_folder_item_templates_create_widget_func(PrefsPage * page_,
                        item->prefs->reply_with_format);
        pref_set_entry_from_pref(GTK_ENTRY(page->reply_quotemark),
                        item->prefs->reply_quotemark);
+       pref_set_entry_from_pref(GTK_ENTRY(page->reply_override_from_format),
+                       item->prefs->reply_override_from_format);
        pref_set_textview_from_pref(GTK_TEXT_VIEW(page->reply_body_format),
                        item->prefs->reply_body_format);
 
@@ -1215,6 +1268,8 @@ static void prefs_folder_item_templates_create_widget_func(PrefsPage * page_,
                        item->prefs->forward_with_format);
        pref_set_entry_from_pref(GTK_ENTRY(page->forward_quotemark),
                        item->prefs->forward_quotemark);
+       pref_set_entry_from_pref(GTK_ENTRY(page->forward_override_from_format),
+                       item->prefs->forward_override_from_format);
        pref_set_textview_from_pref(GTK_TEXT_VIEW(page->forward_body_format),
                        item->prefs->forward_body_format);
 
@@ -1231,7 +1286,14 @@ static void prefs_folder_item_templates_create_widget_func(PrefsPage * page_,
 
 static void prefs_folder_item_templates_destroy_widget_func(PrefsPage *page_) 
 {
-       /* FolderItemTemplatesPage *page = (FolderItemTemplatesPage *) page_; */
+       FolderItemTemplatesPage *page = (FolderItemTemplatesPage *) page_;
+
+       if (page->compose_override_from_format)
+               address_completion_unregister_entry(GTK_ENTRY(page->compose_override_from_format));             
+       if (page->reply_override_from_format)
+               address_completion_unregister_entry(GTK_ENTRY(page->reply_override_from_format));               
+       if (page->forward_override_from_format)
+               address_completion_unregister_entry(GTK_ENTRY(page->forward_override_from_format));             
 }
 
 /** \brief  Save the prefs in page to folder.
@@ -1255,15 +1317,19 @@ static void templates_save_folder_prefs(FolderItem *folder, FolderItemTemplatesP
        /* save and check formats */
 
        if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->new_msg_format_rec_checkbtn))) {
+               
                prefs->compose_with_format =
                        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_compose_with_format));
+               prefs->compose_override_from_format = pref_get_pref_from_entry(
+                               GTK_ENTRY(page->compose_override_from_format));
                prefs->compose_subject_format = pref_get_pref_from_entry(
                                GTK_ENTRY(page->compose_subject_format));
                prefs->compose_body_format = pref_get_pref_from_textview(
                                GTK_TEXT_VIEW(page->compose_body_format));
                quotefmt_check_new_msg_formats(prefs->compose_with_format,
-                                                                               prefs->compose_subject_format,
-                                                                               prefs->compose_body_format);
+                                               prefs->compose_override_from_format,
+                                               prefs->compose_subject_format,
+                                               prefs->compose_body_format);
        }
 
        if (all || gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->reply_format_rec_checkbtn))) {
@@ -1271,9 +1337,12 @@ static void templates_save_folder_prefs(FolderItem *folder, FolderItemTemplatesP
                        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_reply_with_format));
                prefs->reply_quotemark = gtk_editable_get_chars(
                                GTK_EDITABLE(page->reply_quotemark), 0, -1);
+               prefs->reply_override_from_format = pref_get_pref_from_entry(
+                               GTK_ENTRY(page->reply_override_from_format));
                prefs->reply_body_format = pref_get_pref_from_textview(
                                GTK_TEXT_VIEW(page->reply_body_format));
                quotefmt_check_reply_formats(prefs->reply_with_format,
+                                                                               prefs->reply_override_from_format,
                                                                                prefs->reply_quotemark,
                                                                                prefs->reply_body_format);
        }
@@ -1283,9 +1352,12 @@ static void templates_save_folder_prefs(FolderItem *folder, FolderItemTemplatesP
                        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->checkbtn_forward_with_format));
                prefs->forward_quotemark = gtk_editable_get_chars(
                                GTK_EDITABLE(page->forward_quotemark), 0, -1);
+               prefs->forward_override_from_format = pref_get_pref_from_entry(
+                               GTK_ENTRY(page->forward_override_from_format));
                prefs->forward_body_format = pref_get_pref_from_textview(
                                GTK_TEXT_VIEW(page->forward_body_format));
                quotefmt_check_forward_formats(prefs->forward_with_format,
+                                                                               prefs->forward_override_from_format,
                                                                                prefs->forward_quotemark,
                                                                                prefs->forward_body_format);
        }
@@ -1529,6 +1601,16 @@ static void register_templates_page(void)
 
 static GSList *prefs_pages = NULL;
 
+static void prefs_folder_item_address_completion_start(GtkWindow * window)
+{
+       address_completion_start(GTK_WIDGET(window));
+}
+
+static void prefs_folder_item_address_completion_end(GtkWindow * window)
+{
+       address_completion_end(GTK_WIDGET(window));
+}
+
 void prefs_folder_item_open(FolderItem *item)
 {
        gchar *id, *title;
@@ -1548,8 +1630,10 @@ void prefs_folder_item_open(FolderItem *item)
        title = g_strdup_printf (_("Properties for folder %s"), id);
        g_free (id);
        prefswindow_open(title, prefs_pages, item,
-                       &prefs_common.folderitemwin_width, &prefs_common.folderitemwin_height);
-       
+                       &prefs_common.folderitemwin_width, &prefs_common.folderitemwin_height,
+                       prefs_folder_item_address_completion_start,
+                       prefs_folder_item_address_completion_end);
+
        g_free (title);
 }