2005-08-01 [colin] 1.9.13cvs4
authorColin Leroy <colin@colino.net>
Mon, 1 Aug 2005 17:18:42 +0000 (17:18 +0000)
committerColin Leroy <colin@colino.net>
Mon, 1 Aug 2005 17:18:42 +0000 (17:18 +0000)
* src/folderview.c
* src/folderview.h
* src/mainwindow.c
* src/prefs_fonts.c
* src/prefs_summaries.c
* src/prefs_themes.c
* src/summaryview.c
* src/summaryview.h
* src/textview.c
* src/textview.h
Fix instant-apply of summary and folderview-related prefs
Fix erroneous g_free and alertpanels in prefs_theme
Add instant-apply for fonts
Defer applying of prefs a little bit so it's done only
once even if requested by multiples prefs pages

13 files changed:
ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/folderview.c
src/folderview.h
src/mainwindow.c
src/prefs_fonts.c
src/prefs_summaries.c
src/prefs_themes.c
src/summaryview.c
src/summaryview.h
src/textview.c
src/textview.h

index 1684da4d832026b9fecbbb6de8a03c8851e78b35..b1d1876af4f222239d4c44128dd31765974926ff 100644 (file)
@@ -1,3 +1,21 @@
+2005-08-01 [colin]     1.9.13cvs4
+
+       * src/folderview.c
+       * src/folderview.h
+       * src/mainwindow.c
+       * src/prefs_fonts.c
+       * src/prefs_summaries.c
+       * src/prefs_themes.c
+       * src/summaryview.c
+       * src/summaryview.h
+       * src/textview.c
+       * src/textview.h
+               Fix instant-apply of summary and folderview-related prefs
+               Fix erroneous g_free and alertpanels in prefs_theme
+               Add instant-apply for fonts
+               Defer applying of prefs a little bit so it's done only
+               once even if requested by multiples prefs pages
+
 2005-08-01 [paul]      1.9.13cvs3
 
        * src/main.c
index f1085369c3a63ad86438e5a2b0bc2c808cba3e41..165067996f6cbb529406ea4ae9ec30a3b4d53249 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.5.2.1 -r 1.5.2.2 doc/man/sylpheed.1;  cvs diff -u -r 1.1.4.13 -r 1.1.4.14 src/etpan/imap-thread.c;  ) > 1.9.13cvs1.patchset
 ( cvs diff -u -r 1.395.2.97 -r 1.395.2.98 src/summaryview.c;  ) > 1.9.13cvs2.patchset
 ( cvs diff -u -r 1.115.2.45 -r 1.115.2.46 src/main.c;  cvs diff -u -r 1.1.4.2 -r 1.1.4.3 src/etpan/etpan-thread-manager-types.h;  ) > 1.9.13cvs3.patchset
+( cvs diff -u -r 1.207.2.47 -r 1.207.2.48 src/folderview.c;  cvs diff -u -r 1.20.2.4 -r 1.20.2.5 src/folderview.h;  cvs diff -u -r 1.274.2.46 -r 1.274.2.47 src/mainwindow.c;  cvs diff -u -r 1.4.2.10 -r 1.4.2.11 src/prefs_fonts.c;  cvs diff -u -r 1.1.2.5 -r 1.1.2.6 src/prefs_summaries.c;  cvs diff -u -r 1.3.2.21 -r 1.3.2.22 src/prefs_themes.c;  cvs diff -u -r 1.395.2.98 -r 1.395.2.99 src/summaryview.c;  cvs diff -u -r 1.68.2.9 -r 1.68.2.10 src/summaryview.h;  cvs diff -u -r 1.96.2.65 -r 1.96.2.66 src/textview.c;  cvs diff -u -r 1.12.2.6 -r 1.12.2.7 src/textview.h;  ) > 1.9.13cvs4.patchset
index 020eb5418e79fff30c9e21822818e42726746db0..a1f0164e2e8f653ddf9a90a61411a62f31314e25 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=13
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=3
+EXTRA_VERSION=4
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 783ce55be01516712c395d17623d7d026c3dbe28..2af41e3f1674d11f5dd84428507b29a37e123373 100644 (file)
@@ -2059,6 +2059,14 @@ void folderview_set_target_folder_color(gint color_op)
 
 void folderview_reflect_prefs_pixmap_theme(FolderView *folderview)
 {
+}
+
+void folderview_reflect_prefs(void)
+{
+       FolderView *folderview = mainwindow_get_mainwindow()->folderview;
+       normal_style = normal_color_style = bold_style = 
+               bold_color_style = bold_tgtfold_style = NULL;
+
        folderview_init(folderview);
        folderview_set_all();
 }
index ffe4a0599c480eca99826a3ce5ccfc0499385a8c..d4c633ff900b536a6021ba134405bcfe62a22e32 100644 (file)
@@ -105,6 +105,7 @@ void folderview_set_target_folder_color (gint               color_op);
 
 void folderview_reflect_prefs_pixmap_theme     (FolderView *folderview);
 
+void folderview_reflect_prefs          (void);
 void folderview_register_popup         (FolderViewPopup        *fpopup);
 void folderview_unregister_popup       (FolderViewPopup        *fpopup);
 void folderview_update_search_icon     (FolderItem             *item,  
index 3d3d728fdf3686f8d489e4b8bf2d4b44f401ae8e..cb09d569f734284e4e6c091d85a004e0ae9a5086 100644 (file)
@@ -1213,13 +1213,16 @@ static void main_window_menu_callback_unblock(MainWindow *mainwin)
                mainwin->menu_lock_count--;
 }
 
+static guint prefs_tag = 0;
+
 void main_window_reflect_prefs_all(void)
 {
        main_window_reflect_prefs_all_real(FALSE);
 }
 
-void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
+static gboolean reflect_prefs_timeout_cb(gboolean *data) 
 {
+       gboolean pixmap_theme_changed = *data;
        GList *cur;
        MainWindow *mainwin;
        GtkWidget *pixmap;
@@ -1257,9 +1260,19 @@ void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
                                          prefs_common.display_header_pane);
 
                textview_reflect_prefs(mainwin->messageview->mimeview->textview);
-
+               folderview_reflect_prefs();
+               summary_reflect_prefs();
                summary_redisplay_msg(mainwin->summaryview);
        }
+       prefs_tag = 0;
+       return FALSE;
+}
+
+void main_window_reflect_prefs_all_real(gboolean pixmap_theme_changed)
+{
+       if (prefs_tag == 0 || pixmap_theme_changed) {
+               prefs_tag = g_timeout_add(500, reflect_prefs_timeout_cb, &pixmap_theme_changed);
+       }
 }
 
 void main_window_set_summary_column(void)
index 9705ac35a681add192e076cd71fd66da67043310..cd911ad2922485754dfbd3b97842612fefc78464 100644 (file)
@@ -58,7 +58,6 @@ void prefs_fonts_create_widget(PrefsPage *_page, GtkWindow *window,
        GtkWidget *entry_boldfont;
        GtkWidget *tmplabel;
        GtkWidget *vbox;
-       GtkWidget *hint_label;
 
        table = gtk_table_new(7, 2, FALSE);
        gtk_widget_show(table);
@@ -123,15 +122,6 @@ void prefs_fonts_create_widget(PrefsPage *_page, GtkWindow *window,
                         (GtkAttachOptions) GTK_FILL,
                         (GtkAttachOptions) (0), 0, 0);
        
-       hint_label = gtk_label_new (_("You will need to restart for the "
-                                     "changes to take effect"));
-       gtk_label_set_justify (GTK_LABEL (hint_label), GTK_JUSTIFY_LEFT);
-       gtkut_widget_set_small_font_size (hint_label);
-       gtk_widget_show (hint_label);
-       gtk_box_pack_start (GTK_BOX (vbox), 
-                           hint_label, FALSE, FALSE, 0);
-       gtk_misc_set_alignment(GTK_MISC(hint_label), 0.5, 0.5);
-
        prefs_fonts->window                = GTK_WIDGET(window);
        prefs_fonts->entry_folderviewfont  = entry_folderviewfont;
        prefs_fonts->entry_messageviewfont = entry_messageviewfont;
@@ -159,6 +149,8 @@ void prefs_fonts_save(PrefsPage *_page)
        g_free(prefs_common.boldfont);
        prefs_common.boldfont   = g_strdup(gtk_font_button_get_font_name
                (GTK_FONT_BUTTON(fonts->entry_boldfont)));
+               
+       main_window_reflect_prefs_all();
 }
 
 static void prefs_fonts_destroy_widget(PrefsPage *_page)
index f6c628ceea9724dbadc9f7f43a43f4b82744dec2..36e4e49c9d28213d7b225e1bf41ad2028aeeacdb 100644 (file)
@@ -978,6 +978,7 @@ void prefs_summaries_save(PrefsPage *_page)
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
        prefs_common.next_unread_msg_dialog = GPOINTER_TO_INT
                (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
+       main_window_reflect_prefs_all();
 }
 
 static void prefs_summaries_destroy_widget(PrefsPage *_page)
index 0a8d7d119575f5c9020141f1361195ffd90120f0..dc7fc965c569849f13d4c2e2b3ad5dcf3932f2b4 100644 (file)
@@ -431,9 +431,10 @@ static void prefs_themes_btn_remove_clicked_cb(GtkWidget *widget, gpointer data)
 
        val = alertpanel(alert_title,
                         _("Are you sure you want to remove this theme?"),
-                        GTK_STOCK_YES, GTK_STOCK_NO, GTK_STOCK_CANCEL);
+                        GTK_STOCK_YES, GTK_STOCK_NO, NULL);
        g_free(alert_title);
-       if (G_ALERTALTERNATE == val) {
+
+       if (G_ALERTDEFAULT == val) {
                gchar *status = NULL;
                
                prefs_themes_foreach_file(theme_str, prefs_themes_file_remove, &status); 
@@ -455,7 +456,6 @@ static void prefs_themes_btn_remove_clicked_cb(GtkWidget *widget, gpointer data)
                        prefs_themes_get_theme_info(tdata);
                }
        }
-       g_free(theme_str);
 }
 
 static void prefs_themes_btn_install_clicked_cb(GtkWidget *widget, gpointer data)
@@ -486,14 +486,14 @@ static void prefs_themes_btn_install_clicked_cb(GtkWidget *widget, gpointer data
        if (file_exist(themeinfo, FALSE) == FALSE) {
                val = alertpanel(alert_title,
                                 _("This folder doesn't seem to be a theme folder.\nInstall anyway?"),
-                                GTK_STOCK_YES, GTK_STOCK_NO, GTK_STOCK_CANCEL);
+                                GTK_STOCK_YES, GTK_STOCK_NO, NULL);
                if (G_ALERTDEFAULT != val)
                        goto end_inst;
        }
        if (getuid() == 0) {
                val = alertpanel(alert_title,
                                 _("Do you want to install theme for all users?"),
-                                GTK_STOCK_YES, GTK_STOCK_NO, GTK_STOCK_CANCEL);
+                                GTK_STOCK_YES, GTK_STOCK_NO, NULL);
                switch (val) {
                case G_ALERTDEFAULT:
                        cinfo->dest = g_strconcat(PACKAGE_DATA_DIR, G_DIR_SEPARATOR_S,
index 7273db7f728642271ea19100443276cbf0c600b0..a0d83f5e1db4db94809bb239da215487c4988f7a 100644 (file)
@@ -630,40 +630,11 @@ SummaryView *summary_create(void)
        return summaryview;
 }
 
-void summary_init(SummaryView *summaryview)
+static void summary_set_fonts(SummaryView *summaryview)
 {
-       GtkWidget *pixmap;
        PangoFontDescription *font_desc;
        gint size;
 
-       gtk_widget_realize(summaryview->ctree);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_MARK,
-                        &markxpm, &markxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_DELETED,
-                        &deletedxpm, &deletedxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_NEW,
-                        &newxpm, &newxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_UNREAD,
-                        &unreadxpm, &unreadxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_REPLIED,
-                        &repliedxpm, &repliedxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_FORWARDED,
-                        &forwardedxpm, &forwardedxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_CLIP,
-                        &clipxpm, &clipxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_LOCKED,
-                        &lockedxpm, &lockedxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_IGNORETHREAD,
-                        &ignorethreadxpm, &ignorethreadxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_CLIP_KEY,
-                        &clipkeyxpm, &clipkeyxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_KEY,
-                        &keyxpm, &keyxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_GPG_SIGNED,
-                        &gpgsignedxpm, &gpgsignedxpmmask);
-       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_CLIP_GPG_SIGNED,
-                        &clipgpgsignedxpm, &clipgpgsignedxpmmask);
-
        font_desc = pango_font_description_from_string(NORMAL_FONT);
        gtk_widget_modify_font(summaryview->ctree, font_desc);
        pango_font_description_free(font_desc);
@@ -689,12 +660,47 @@ void summary_init(SummaryView *summaryview)
 
        font_desc = pango_font_description_new();
        size = pango_font_description_get_size
-               (summaryview->statlabel_folder->style->font_desc);
+               (summaryview->ctree->style->font_desc);
        pango_font_description_set_size(font_desc, size * PANGO_SCALE_SMALL);
        gtk_widget_modify_font(summaryview->statlabel_folder, font_desc);
        gtk_widget_modify_font(summaryview->statlabel_select, font_desc);
        gtk_widget_modify_font(summaryview->statlabel_msgs, font_desc);
        pango_font_description_free(font_desc);
+}
+
+void summary_init(SummaryView *summaryview)
+{
+       GtkWidget *pixmap;
+
+       gtk_widget_realize(summaryview->ctree);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_MARK,
+                        &markxpm, &markxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_DELETED,
+                        &deletedxpm, &deletedxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_NEW,
+                        &newxpm, &newxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_UNREAD,
+                        &unreadxpm, &unreadxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_REPLIED,
+                        &repliedxpm, &repliedxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_FORWARDED,
+                        &forwardedxpm, &forwardedxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_CLIP,
+                        &clipxpm, &clipxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_LOCKED,
+                        &lockedxpm, &lockedxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_IGNORETHREAD,
+                        &ignorethreadxpm, &ignorethreadxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_CLIP_KEY,
+                        &clipkeyxpm, &clipkeyxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_KEY,
+                        &keyxpm, &keyxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_GPG_SIGNED,
+                        &gpgsignedxpm, &gpgsignedxpmmask);
+       stock_pixmap_gdk(summaryview->ctree, STOCK_PIXMAP_CLIP_GPG_SIGNED,
+                        &clipgpgsignedxpm, &clipgpgsignedxpmmask);
+
+       summary_set_fonts(summaryview);
 
        pixmap = stock_pixmap_widget(summaryview->hbox_l, STOCK_PIXMAP_DIR_OPEN);
        gtk_box_pack_start(GTK_BOX(summaryview->hbox_l), pixmap, FALSE, FALSE, 4);
@@ -2018,6 +2024,16 @@ static void summary_set_column_titles(SummaryView *summaryview)
        }
 }
 
+void summary_reflect_prefs(void)
+{
+       SummaryView *summaryview = mainwindow_get_mainwindow()->summaryview;
+       bold_style = bold_marked_style = bold_deleted_style = 
+               small_style = small_marked_style = small_deleted_style = NULL;
+       summary_set_fonts(summaryview);
+       summary_set_column_titles(summaryview);
+       summary_show(summaryview, summaryview->folder_item);
+}
+
 void summary_sort(SummaryView *summaryview,
                  FolderSortKey sort_key, FolderSortType sort_type)
 {
index 77933cb0f04ad0b618c00dc53c646bd349b6d6d1..921138b05146d757b79d0a69ba1a9c0398d139f0 100644 (file)
@@ -284,5 +284,5 @@ void summary_save_prefs_to_folderitem
 void summaryview_export_mbox_list (SummaryView *summaryview);
 void summaryview_lock(SummaryView *summaryview, FolderItem *item);
 void summaryview_unlock(SummaryView *summaryview, FolderItem *item);
-
+void summary_reflect_prefs(void);
 #endif /* __SUMMARY_H__ */
index 09c59dc3545e74cdefba161f0e0bc79f859a5967..6bbe95817faa0a0c8a8f4a5761685415f3424c38 100644 (file)
@@ -328,7 +328,7 @@ static void textview_create_tags(GtkTextView *text, TextView *textview)
        GtkTextBuffer *buffer;
        GtkTextTag *tag;
        static PangoFontDescription *font_desc, *bold_font_desc;
-
+       
        if (!font_desc)
                font_desc = pango_font_description_from_string
                        (NORMAL_FONT);
@@ -376,8 +376,7 @@ static void textview_create_tags(GtkTextView *text, TextView *textview)
                                   "foreground-gdk", &uri_color,
                                   "underline", PANGO_UNDERLINE_SINGLE,
                                   NULL);
-
-       g_signal_connect(G_OBJECT(tag), "event",
+       g_signal_connect(G_OBJECT(tag), "event",
                          G_CALLBACK(textview_uri_button_pressed), textview);
  }
 
@@ -394,9 +393,19 @@ void textview_init(TextView *textview)
        textview_create_tags(GTK_TEXT_VIEW(textview->text), textview);
 }
 
-void textview_update_message_colors(void)
+#define CHANGE_TAG_COLOR(tagname, color) { \
+       tag = gtk_text_tag_table_lookup(tags, tagname); \
+       if (tag) \
+               g_object_set(G_OBJECT(tag), "foreground-gdk", color, NULL); \
+}
+
+static void textview_update_message_colors(TextView *textview)
 {
        GdkColor black = {0, 0, 0, 0};
+       GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview->text));
+
+       GtkTextTagTable *tags = gtk_text_buffer_get_tag_table(buffer);
+       GtkTextTag *tag = NULL;
 
        if (prefs_common.enable_color) {
                /* grab the quote colors, converting from an int to a GdkColor */
@@ -414,11 +423,21 @@ void textview_update_message_colors(void)
                quote_colors[0] = quote_colors[1] = quote_colors[2] = 
                        uri_color = emphasis_color = signature_color = black;
        }
+       CHANGE_TAG_COLOR("quote0", &quote_colors[0]);
+       CHANGE_TAG_COLOR("quote1", &quote_colors[1]);
+       CHANGE_TAG_COLOR("quote2", &quote_colors[2]);
+       CHANGE_TAG_COLOR("emphasis", &emphasis_color);
+       CHANGE_TAG_COLOR("signature", &signature_color);
+       CHANGE_TAG_COLOR("link", &uri_color);
+       CHANGE_TAG_COLOR("link-hover", &uri_color);
+
 }
+#undef CHANGE_TAG_COLOR
 
 void textview_reflect_prefs(TextView *textview)
 {
-       textview_update_message_colors();
+       textview_set_font(textview, NULL);
+       textview_update_message_colors(textview);
        gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(textview->text),
                                         prefs_common.textview_cursor_visible);
 }
@@ -426,19 +445,10 @@ void textview_reflect_prefs(TextView *textview)
 void textview_show_message(TextView *textview, MimeInfo *mimeinfo,
                           const gchar *file)
 {
-       FILE *fp;
-
-       if ((fp = fopen(file, "rb")) == NULL) {
-               FILE_OP_ERROR(file, "fopen");
-               return;
-       }
-
        textview_clear(textview);
 
        textview_add_parts(textview, mimeinfo);
 
-       fclose(fp);
-
        textview_set_position(textview, 0);
 }
 
@@ -1328,10 +1338,7 @@ static void textview_write_line(TextView *textview, const gchar *str,
                textview->is_in_signature = TRUE;
        }
 
-       if (prefs_common.enable_color)
-               textview_make_clickable_parts(textview, fg_color, "link", buf);
-       else
-               textview_make_clickable_parts(textview, fg_color, NULL, buf);
+       textview_make_clickable_parts(textview, fg_color, "link", buf);
 }
 
 void textview_write_link(TextView *textview, const gchar *str,
@@ -1571,13 +1578,9 @@ static void textview_show_header(TextView *textview, GPtrArray *headers)
                        gtk_text_buffer_insert_with_tags_by_name
                                (buffer, &iter, header->body, -1,
                                 "header", "emphasis", NULL);
-               } else if (prefs_common.enable_color) {
-                       textview_make_clickable_parts(textview, "header", "link",
-                                                     header->body);
-               } else {
-                       textview_make_clickable_parts(textview, "header", NULL,
-                                                     header->body);
                }
+               textview_make_clickable_parts(textview, "header", "link",
+                                                     header->body);
                gtk_text_buffer_get_end_iter (buffer, &iter);
                gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, "\n", 1,
                                                         "header", NULL);
index ede648d33abbfc4f8e4d83103acf8dfdd72864af..45fed4847591d3067a5d1d469ac861afbe56bd29 100644 (file)
@@ -65,7 +65,6 @@ struct _TextView
 
 TextView *textview_create              (void);
 void textview_init                     (TextView       *textview);
-void textview_update_message_colors    (void);
 void textview_reflect_prefs            (TextView       *textview);
 
 void textview_show_message     (TextView       *textview,