Add a PrefsWindow callback for apply button, and use it for common preferences to...
authorAndrej Kacian <ticho@claws-mail.org>
Thu, 27 Aug 2015 11:09:46 +0000 (13:09 +0200)
committerAndrej Kacian <ticho@claws-mail.org>
Fri, 28 Aug 2015 09:40:11 +0000 (11:40 +0200)
Fixes bug #3467 for "click Apply, then click Cancel" scenario.

src/gtk/prefswindow.c
src/gtk/prefswindow.h
src/prefs_account.c
src/prefs_folder_item.c
src/prefs_gtk.c

index dd910fd..f6c840b 100644 (file)
@@ -126,6 +126,9 @@ static void apply_button_clicked(GtkButton *button, gpointer user_data)
 #ifdef GENERIC_UMPC
        prefs_show_sections(prefswindow);
 #endif
+
+       if (prefswindow->apply_cb)
+               prefswindow->apply_cb(prefswindow);
 }
 
 static void close_prefs_window(PrefsWindow *prefswindow)
@@ -398,6 +401,7 @@ void prefswindow_open_full(const gchar *title, GSList *prefs_pages,
                                                         gint *save_width, gint *save_height,
                                                         gboolean preload_pages,
                                                         PrefsOpenCallbackFunc open_cb,
+                                                        PrefsApplyCallbackFunc apply_cb,
                                                         PrefsCloseCallbackFunc close_cb)
 {
        PrefsWindow *prefswindow;
@@ -414,6 +418,7 @@ void prefswindow_open_full(const gchar *title, GSList *prefs_pages,
        prefswindow->save_width = save_width;
        prefswindow->save_height = save_height;
        prefswindow->open_cb = open_cb;
+       prefswindow->apply_cb = apply_cb;
        prefswindow->close_cb = close_cb;
        prefswindow->dialog_response = PREFSWINDOW_RESPONSE_CANCEL;
 
@@ -567,10 +572,11 @@ void prefswindow_open_full(const gchar *title, GSList *prefs_pages,
 void prefswindow_open(const gchar *title, GSList *prefs_pages, gpointer data,
                                         gint *save_width, gint *save_height,
                                         PrefsOpenCallbackFunc open_cb,
+                                        PrefsApplyCallbackFunc apply_cb,
                                         PrefsCloseCallbackFunc close_cb)
 {
        prefswindow_open_full(title, prefs_pages, data, NULL, save_width, save_height,
-                                                 FALSE, open_cb, close_cb);
+                                                 FALSE, open_cb, apply_cb, close_cb);
 }
 
 /*!
index c7e92a6..8916e97 100644 (file)
@@ -31,6 +31,7 @@ typedef void (*PrefsDestroyWidgetFunc) (PrefsPage *);
 typedef void (*PrefsSavePageFunc) (PrefsPage *);
 typedef gboolean (*PrefsCanClosePageFunc) (PrefsPage *);
 typedef void (*PrefsOpenCallbackFunc) (PrefsWindow *);
+typedef void (*PrefsApplyCallbackFunc) (PrefsWindow *);
 typedef void (*PrefsCloseCallbackFunc) (PrefsWindow *);
 
 struct _PrefsPage
@@ -76,6 +77,7 @@ struct _PrefsWindow
        gint *save_width;
        gint *save_height;
        PrefsCloseCallbackFunc open_cb;
+       PrefsApplyCallbackFunc apply_cb;
        PrefsCloseCallbackFunc close_cb;
        gint dialog_response; /* Useful for close_cb callbacks */
 
@@ -106,6 +108,7 @@ void prefswindow_open_full          (const gchar *title,
                                         gint *save_width, gint *save_height,
                                         gboolean preload_pages,
                                         PrefsOpenCallbackFunc open_cb,
+                                        PrefsApplyCallbackFunc apply_cb,
                                         PrefsCloseCallbackFunc close_cb);
 
 void prefswindow_open                  (const gchar *title, 
@@ -113,6 +116,7 @@ void prefswindow_open                       (const gchar *title,
                                         gpointer data,
                                         gint *save_width, gint *save_height,
                                         PrefsOpenCallbackFunc open_cb,
+                                        PrefsApplyCallbackFunc apply_cb,
                                         PrefsCloseCallbackFunc close_cb);
 
 #endif
index dfe4c17..cd84c81 100644 (file)
@@ -3729,7 +3729,7 @@ PrefsAccount *prefs_account_open(PrefsAccount *ac_prefs, gboolean *dirty)
 
        prefswindow_open_full(title, prefs_pages, ac_prefs, destroy_dialog,
                        &prefs_common.editaccountwin_width, &prefs_common.editaccountwin_height,
-                       TRUE, NULL, NULL);
+                       TRUE, NULL, NULL, NULL);
        g_free(title);
        gtk_main();
 
index 37be0a2..0afce45 100644 (file)
@@ -1897,6 +1897,7 @@ void prefs_folder_item_open(FolderItem *item)
        prefswindow_open(title, pages, item,
                        &prefs_common.folderitemwin_width, &prefs_common.folderitemwin_height,
                        prefs_folder_item_address_completion_start,
+                       NULL,
                        prefs_folder_item_address_completion_end);
 
        g_slist_free(pages);
index 4eb554e..a2f1660 100644 (file)
@@ -947,7 +947,7 @@ void prefs_gtk_open(void)
 {
        prefswindow_open(_("Preferences"), prefs_pages, NULL,
                        &prefs_common.prefswin_width, &prefs_common.prefswin_height,
-                       NULL, prefs_gtk_window_closed_cb);
+                       NULL, prefs_gtk_window_closed_cb, prefs_gtk_window_closed_cb);
 }
 
 void prefs_gtk_register_page(PrefsPage *page)