[Commits] [SCM] claws branch, master, updated. 3.12.0-71-g8bc08f3

ticho at claws-mail.org ticho at claws-mail.org
Fri Aug 28 11:41:15 CEST 2015


The branch, master has been updated
       via  8bc08f388d4f8cd6a8f76a7d0383c16f0cea572f (commit)
       via  4cf741e58e39af25d3ccd00b91197f5df9adc054 (commit)
       via  f3593ce1b2b2c33681e0e251e317478c45533cbb (commit)
       via  f0cc04183e634bec1265a8e9e0cd1037125f2034 (commit)
       via  05a137be880855c9e002fa30cdab705ac66fd64a (commit)
      from  4721a112b006dab3524fad9ad1c641c1eac73024 (commit)

Summary of changes:
 src/gtk/prefswindow.c   |   63 +++++++++++------------------------------------
 src/gtk/prefswindow.h   |   62 ++++++++++++++++++++++++++++++++++++++++++++--
 src/prefs_account.c     |    2 +-
 src/prefs_folder_item.c |    9 ++++---
 src/prefs_gtk.c         |   11 ++++++++-
 5 files changed, 90 insertions(+), 57 deletions(-)


- Log -----------------------------------------------------------------
commit 8bc08f388d4f8cd6a8f76a7d0383c16f0cea572f
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Thu Aug 27 13:09:46 2015 +0200

    Add a PrefsWindow callback for apply button, and use it for common preferences to save them to disk.
    
    Fixes bug #3467 for "click Apply, then click Cancel" scenario.

diff --git a/src/gtk/prefswindow.c b/src/gtk/prefswindow.c
index dd910fd..f6c840b 100644
--- a/src/gtk/prefswindow.c
+++ b/src/gtk/prefswindow.c
@@ -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);
 }
 
 /*!
diff --git a/src/gtk/prefswindow.h b/src/gtk/prefswindow.h
index c7e92a6..8916e97 100644
--- a/src/gtk/prefswindow.h
+++ b/src/gtk/prefswindow.h
@@ -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
diff --git a/src/prefs_account.c b/src/prefs_account.c
index dfe4c17..cd84c81 100644
--- a/src/prefs_account.c
+++ b/src/prefs_account.c
@@ -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();
 
diff --git a/src/prefs_folder_item.c b/src/prefs_folder_item.c
index 37be0a2..0afce45 100644
--- a/src/prefs_folder_item.c
+++ b/src/prefs_folder_item.c
@@ -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);
diff --git a/src/prefs_gtk.c b/src/prefs_gtk.c
index 4eb554e..a2f1660 100644
--- a/src/prefs_gtk.c
+++ b/src/prefs_gtk.c
@@ -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)

commit 4cf741e58e39af25d3ccd00b91197f5df9adc054
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Thu Aug 27 12:08:08 2015 +0200

    Use PrefsWindow's close_cb callback to save common prefs to disk, if OK or Apply button was pressed.
    
    Fixes bug #3467.

diff --git a/src/prefs_gtk.c b/src/prefs_gtk.c
index 843f9c9..4eb554e 100644
--- a/src/prefs_gtk.c
+++ b/src/prefs_gtk.c
@@ -934,11 +934,20 @@ void prefs_set_spinbtn(PrefParam *pparam)
 
 static GSList *prefs_pages = NULL;
 
+static void prefs_gtk_window_closed_cb(PrefsWindow *prefswindow)
+{
+	if (prefswindow == NULL)
+		return;
+
+	if (prefswindow->dialog_response > PREFSWINDOW_RESPONSE_CANCEL)
+		prefs_common_write_config();
+}
+
 void prefs_gtk_open(void)
 {
 	prefswindow_open(_("Preferences"), prefs_pages, NULL,
 			&prefs_common.prefswin_width, &prefs_common.prefswin_height,
-			NULL, NULL);
+			NULL, prefs_gtk_window_closed_cb);
 }
 
 void prefs_gtk_register_page(PrefsPage *page)

commit f3593ce1b2b2c33681e0e251e317478c45533cbb
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Thu Aug 27 12:05:07 2015 +0200

    Added dialog_response member to PrefsWindow.

diff --git a/src/gtk/prefswindow.c b/src/gtk/prefswindow.c
index 16ef9e3..dd910fd 100644
--- a/src/gtk/prefswindow.c
+++ b/src/gtk/prefswindow.c
@@ -120,6 +120,8 @@ static void apply_button_clicked(GtkButton *button, gpointer user_data)
 {
 	PrefsWindow *prefswindow = (PrefsWindow *) user_data;
 
+	prefswindow->dialog_response = PREFSWINDOW_RESPONSE_APPLY;
+
 	save_all_pages(prefswindow->prefs_pages);
 #ifdef GENERIC_UMPC
 	prefs_show_sections(prefswindow);
@@ -146,6 +148,8 @@ static void ok_button_clicked(GtkButton *button, gpointer user_data)
 {
 	PrefsWindow *prefswindow = (PrefsWindow *) user_data;
 
+	prefswindow->dialog_response = PREFSWINDOW_RESPONSE_OK;
+
 	if (query_can_close_all_pages(prefswindow->prefs_pages)) {
 		save_all_pages(prefswindow->prefs_pages);
 		close_prefs_window(prefswindow);
@@ -411,6 +415,7 @@ void prefswindow_open_full(const gchar *title, GSList *prefs_pages,
 	prefswindow->save_height = save_height;
 	prefswindow->open_cb = open_cb;
 	prefswindow->close_cb = close_cb;
+	prefswindow->dialog_response = PREFSWINDOW_RESPONSE_CANCEL;
 
 	prefswindow->window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "prefswindow");
 	gtk_window_set_title(GTK_WINDOW(prefswindow->window), title);
diff --git a/src/gtk/prefswindow.h b/src/gtk/prefswindow.h
index 20db56d..c7e92a6 100644
--- a/src/gtk/prefswindow.h
+++ b/src/gtk/prefswindow.h
@@ -77,6 +77,7 @@ struct _PrefsWindow
 	gint *save_height;
 	PrefsCloseCallbackFunc open_cb;
 	PrefsCloseCallbackFunc close_cb;
+	gint dialog_response; /* Useful for close_cb callbacks */
 
 	GtkWidget *empty_page;
 
@@ -85,6 +86,13 @@ struct _PrefsWindow
 	GDestroyNotify func;
 };
 
+enum
+{
+	PREFSWINDOW_RESPONSE_CANCEL,
+	PREFSWINDOW_RESPONSE_OK,
+	PREFSWINDOW_RESPONSE_APPLY
+};
+
 struct _PrefsTreeNode
 {
 	PrefsPage *page;

commit f0cc04183e634bec1265a8e9e0cd1037125f2034
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Thu Aug 27 12:00:00 2015 +0200

    Pass PrefsWindow pointer instead of GtkWindow to prefswindow's open and close callbacks.

diff --git a/src/gtk/prefswindow.c b/src/gtk/prefswindow.c
index dfcc41a..16ef9e3 100644
--- a/src/gtk/prefswindow.c
+++ b/src/gtk/prefswindow.c
@@ -133,7 +133,7 @@ static void close_prefs_window(PrefsWindow *prefswindow)
 	close_all_pages(prefswindow->prefs_pages);
 
 	if (prefswindow->close_cb)
-		prefswindow->close_cb(GTK_WINDOW(prefswindow->window));
+		prefswindow->close_cb(prefswindow);
 
 	gtk_widget_destroy(prefswindow->window);
 	g_slist_free(prefswindow->prefs_pages);
@@ -484,7 +484,7 @@ void prefswindow_open_full(const gchar *title, GSList *prefs_pages,
 							preload_pages);
 
 	if (open_cb)
-		open_cb(GTK_WINDOW(prefswindow->window));
+		open_cb(prefswindow);
 
 	gtk_widget_grab_focus(prefswindow->tree_view);
 
diff --git a/src/gtk/prefswindow.h b/src/gtk/prefswindow.h
index d8530a8..20db56d 100644
--- a/src/gtk/prefswindow.h
+++ b/src/gtk/prefswindow.h
@@ -30,8 +30,8 @@ typedef void (*PrefsCreateWidgetFunc) (PrefsPage *, GtkWindow *window, gpointer)
 typedef void (*PrefsDestroyWidgetFunc) (PrefsPage *);
 typedef void (*PrefsSavePageFunc) (PrefsPage *);
 typedef gboolean (*PrefsCanClosePageFunc) (PrefsPage *);
-typedef void (*PrefsOpenCallbackFunc) (GtkWindow *);
-typedef void (*PrefsCloseCallbackFunc) (GtkWindow *);
+typedef void (*PrefsOpenCallbackFunc) (PrefsWindow *);
+typedef void (*PrefsCloseCallbackFunc) (PrefsWindow *);
 
 struct _PrefsPage
 {
diff --git a/src/prefs_folder_item.c b/src/prefs_folder_item.c
index 14309f8..37be0a2 100644
--- a/src/prefs_folder_item.c
+++ b/src/prefs_folder_item.c
@@ -1859,14 +1859,14 @@ static void register_templates_page(void)
 
 static GSList *prefs_pages = NULL;
 
-static void prefs_folder_item_address_completion_start(GtkWindow * window)
+static void prefs_folder_item_address_completion_start(PrefsWindow *window)
 {
-	address_completion_start(GTK_WIDGET(window));
+	address_completion_start(window->window);
 }
 
-static void prefs_folder_item_address_completion_end(GtkWindow * window)
+static void prefs_folder_item_address_completion_end(PrefsWindow *window)
 {
-	address_completion_end(GTK_WIDGET(window));
+	address_completion_end(window->window);
 }
 
 void prefs_folder_item_open(FolderItem *item)

commit 05a137be880855c9e002fa30cdab705ac66fd64a
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Thu Aug 27 11:56:13 2015 +0200

    Moved struct and enum declarations from prefswindow.c to .h.

diff --git a/src/gtk/prefswindow.c b/src/gtk/prefswindow.c
index 0b407d3..dfcc41a 100644
--- a/src/gtk/prefswindow.c
+++ b/src/gtk/prefswindow.c
@@ -34,52 +34,6 @@
 #include "prefs_common.h"
 #include "gtk/manage_window.h"
 
-enum { 
-	PREFS_PAGE_TITLE,		/* page title */
-	PREFS_PAGE_DATA,		/* PrefsTreeNode data */	
-	PREFS_PAGE_DATA_AUTO_FREE,	/* auto free for PREFS_PAGE_DATA */
-	PREFS_PAGE_WEIGHT,		/* weight */
-	PREFS_PAGE_INDEX,		/* index in original page list */
-	N_PREFS_PAGE_COLUMNS
-};
-
-typedef struct _PrefsWindow PrefsWindow;
-typedef struct _PrefsTreeNode PrefsTreeNode;
-
-struct _PrefsWindow
-{
-	GtkWidget *window;
-	GtkWidget *vbox;
-	GtkWidget *paned;
-	GtkWidget *scrolledwindow1;
-	GtkWidget *tree_view;
-	GtkWidget *table2;
-	GtkWidget *pagelabel;
-	GtkWidget *labelframe;
-	GtkWidget *vbox2;
-	GtkWidget *notebook;
-	GtkWidget *confirm_area;
-	GtkWidget *ok_btn;
-	GtkWidget *cancel_btn;
-	GtkWidget *apply_btn;
-	gint *save_width;
-	gint *save_height;
-	PrefsCloseCallbackFunc open_cb;
-	PrefsCloseCallbackFunc close_cb;
-
-	GtkWidget *empty_page;
-
-	gpointer   	 data;
-	GSList	  	*prefs_pages;
-	GDestroyNotify func;
-};
-
-struct _PrefsTreeNode
-{
-	PrefsPage *page;
-	gfloat     treeweight; /* GTK2: not used */
-};
-
 static void prefs_size_allocate_cb(GtkWidget *widget,
 							 GtkAllocation *allocation, gpointer *user_data);
 static GtkTreeStore *prefswindow_create_data_store	(void);
diff --git a/src/gtk/prefswindow.h b/src/gtk/prefswindow.h
index 5a0c9a9..d8530a8 100644
--- a/src/gtk/prefswindow.h
+++ b/src/gtk/prefswindow.h
@@ -24,6 +24,7 @@
 #include <gtk/gtk.h>
 
 typedef struct _PrefsPage PrefsPage;
+typedef struct _PrefsWindow PrefsWindow;
 
 typedef void (*PrefsCreateWidgetFunc) (PrefsPage *, GtkWindow *window, gpointer);
 typedef void (*PrefsDestroyWidgetFunc) (PrefsPage *);
@@ -45,6 +46,51 @@ struct _PrefsPage
 	PrefsCanClosePageFunc	  can_close;
 };
 
+enum {
+	PREFS_PAGE_TITLE,		/* page title */
+	PREFS_PAGE_DATA,		/* PrefsTreeNode data */
+	PREFS_PAGE_DATA_AUTO_FREE,	/* auto free for PREFS_PAGE_DATA */
+	PREFS_PAGE_WEIGHT,		/* weight */
+	PREFS_PAGE_INDEX,		/* index in original page list */
+	N_PREFS_PAGE_COLUMNS
+};
+
+typedef struct _PrefsTreeNode PrefsTreeNode;
+
+struct _PrefsWindow
+{
+	GtkWidget *window;
+	GtkWidget *vbox;
+	GtkWidget *paned;
+	GtkWidget *scrolledwindow1;
+	GtkWidget *tree_view;
+	GtkWidget *table2;
+	GtkWidget *pagelabel;
+	GtkWidget *labelframe;
+	GtkWidget *vbox2;
+	GtkWidget *notebook;
+	GtkWidget *confirm_area;
+	GtkWidget *ok_btn;
+	GtkWidget *cancel_btn;
+	GtkWidget *apply_btn;
+	gint *save_width;
+	gint *save_height;
+	PrefsCloseCallbackFunc open_cb;
+	PrefsCloseCallbackFunc close_cb;
+
+	GtkWidget *empty_page;
+
+	gpointer   	 data;
+	GSList	  	*prefs_pages;
+	GDestroyNotify func;
+};
+
+struct _PrefsTreeNode
+{
+	PrefsPage *page;
+	gfloat     treeweight; /* GTK2: not used */
+};
+
 void prefswindow_open_full		(const gchar *title, 
 					 GSList *prefs_pages,
 					 gpointer data,

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list