[balsa/gtk3] Use common GAction-toggled callback
- From: Peter Bloomfield <PeterB src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/gtk3] Use common GAction-toggled callback
- Date: Tue, 23 Jul 2013 02:05:27 +0000 (UTC)
commit 1a544be506a2bf162745f6ab26c6f8411b3b90bf
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Mon Jul 22 22:04:20 2013 -0400
Use common GAction-toggled callback
* libbalsa/application-helpers.c (libbalsa_window_get_menu_bar),
(libbalsa_toggle_activated): install GAction-toggled callback.
* libbalsa/application-helpers.h: declare it.
* libbalsa/source-viewer.c: use it.
* src/main-window.c (bw_set_menus): ditto.
ChangeLog | 10 ++++++++
libbalsa/application-helpers.c | 27 +++++++++++++++++++++-
libbalsa/application-helpers.h | 3 ++
libbalsa/source-viewer.c | 16 +------------
src/main-window.c | 47 ++++++++++++---------------------------
5 files changed, 54 insertions(+), 49 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 519655b..8e61c0f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2013-07-22 Peter Bloomfield
+ Move GAction-toggled callback to application-helpers
+
+ * libbalsa/application-helpers.c (libbalsa_window_get_menu_bar),
+ (libbalsa_toggle_activated): install GAction-toggled callback.
+ * libbalsa/application-helpers.h: declare it.
+ * libbalsa/source-viewer.c: use it.
+ * src/main-window.c (bw_set_menus): ditto.
+
+2013-07-22 Peter Bloomfield
+
Make main-window a GtkApplicationWindow, and port menus from
GtkUIManager to GtkBuilder and from GtkAction to GAction
diff --git a/libbalsa/application-helpers.c b/libbalsa/application-helpers.c
index e1e4edc..923c686 100644
--- a/libbalsa/application-helpers.c
+++ b/libbalsa/application-helpers.c
@@ -18,8 +18,6 @@
/*
* Helpers for GtkApplicationWindow
- *
- * Currently only one helper
*/
#if defined(HAVE_CONFIG_H) && HAVE_CONFIG_H
@@ -188,3 +186,28 @@ libbalsa_window_get_menu_bar(GtkApplicationWindow * window,
return menu_bar;
}
+
+/*
+ * libbalsa_toggle_activated
+ *
+ * Callback for the "activated" signal of GAction with a boolean state
+ * Toggle the action's state
+ *
+ * action the GAction
+ * parameter not used
+ * user_data not used
+ */
+
+void
+libbalsa_toggle_activated(GSimpleAction * action,
+ GVariant * parameter,
+ gpointer user_data)
+{
+ GVariant *action_state;
+ gboolean state;
+
+ action_state = g_action_get_state(G_ACTION(action));
+ state = g_variant_get_boolean(action_state);
+ g_action_change_state(G_ACTION(action), g_variant_new_boolean(!state));
+ g_variant_unref(action_state);
+}
diff --git a/libbalsa/application-helpers.h b/libbalsa/application-helpers.h
index 91a41b6..3c5889c 100644
--- a/libbalsa/application-helpers.h
+++ b/libbalsa/application-helpers.h
@@ -36,5 +36,8 @@ GtkWidget *libbalsa_window_get_menu_bar(GtkApplicationWindow * window,
gint n_entries,
const gchar * ui_file,
GError ** error);
+void libbalsa_toggle_activated(GSimpleAction * action,
+ GVariant * parameter,
+ gpointer user_data);
#endif /* __LIBBALSA_APPLICATION_HELPERS_H__ */
diff --git a/libbalsa/source-viewer.c b/libbalsa/source-viewer.c
index 32610dd..5aff165 100644
--- a/libbalsa/source-viewer.c
+++ b/libbalsa/source-viewer.c
@@ -88,20 +88,6 @@ lsv_select_activated(GSimpleAction * action,
}
static void
-lsv_toggle_activated(GSimpleAction * action,
- GVariant * parameter,
- gpointer user_data)
-{
- GVariant *action_state;
- gboolean state;
-
- action_state = g_action_get_state(G_ACTION(action));
- state = g_variant_get_boolean(action_state);
- g_action_change_state(G_ACTION(action), g_variant_new_boolean(!state));
- g_variant_unref(action_state);
-}
-
-static void
lsv_show_message(const char *message, LibBalsaSourceViewerInfo * lsvi,
gboolean escape)
{
@@ -169,7 +155,7 @@ static GActionEntry win_entries[] = {
{"lsv-close", lsv_close_activated},
{"lsv-copy", lsv_copy_activated},
{"lsv-select", lsv_select_activated},
- {"lsv-escape", lsv_toggle_activated, NULL, "false",
+ {"lsv-escape", libbalsa_toggle_activated, NULL, "false",
lsv_escape_change_state}
};
diff --git a/src/main-window.c b/src/main-window.c
index 754adc5..7393640 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -34,6 +34,7 @@
#include <gdk/gdkkeysyms.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
+#include "application-helpers.h"
#include "imap-server.h"
#include "libbalsa.h"
#include "misc.h"
@@ -860,24 +861,6 @@ bw_actions_set_enabled(BalsaWindow * window,
*/
/*
- * Common callback for the "activated" signal of a toggle action
- */
-
-static void
-toggle_activated(GSimpleAction * action,
- GVariant * parameter,
- gpointer user_data)
-{
- GVariant *action_state;
- gboolean state;
-
- action_state = g_action_get_state(G_ACTION(action));
- state = g_variant_get_boolean(action_state);
- g_action_change_state(G_ACTION(action), g_variant_new_boolean(!state));
- g_variant_unref(action_state);
-}
-
-/*
* Common callback for the "activated" signal of a radio action
*/
@@ -1966,17 +1949,17 @@ bw_set_menus(BalsaWindow * window)
{"find-in-message", find_in_message_activated},
{"filters", filters_activated},
{"export-filters", export_filters_activated},
- {"show-mailbox-tree", toggle_activated, NULL, "false",
+ {"show-mailbox-tree", libbalsa_toggle_activated, NULL, "false",
show_mailbox_tree_change_state},
- {"show-mailbox-tabs", toggle_activated, NULL, "false",
+ {"show-mailbox-tabs", libbalsa_toggle_activated, NULL, "false",
show_mailbox_tabs_change_state},
- {"show-toolbar", toggle_activated, NULL, "false",
+ {"show-toolbar", libbalsa_toggle_activated, NULL, "false",
show_toolbar_change_state},
- {"show-statusbar", toggle_activated, NULL, "false",
+ {"show-statusbar", libbalsa_toggle_activated, NULL, "false",
show_statusbar_change_state},
- {"show-sos-bar", toggle_activated, NULL, "false",
+ {"show-sos-bar", libbalsa_toggle_activated, NULL, "false",
show_sos_bar_change_state},
- {"wrap", toggle_activated, NULL, "false",
+ {"wrap", libbalsa_toggle_activated, NULL, "false",
wrap_change_state},
{"headers", radio_activated, "s", "'none'",
header_change_state},
@@ -1993,21 +1976,21 @@ bw_set_menus(BalsaWindow * window)
{"previous-message", previous_message_activated},
{"next-unread", next_unread_activated},
{"next-flagged", next_flagged_activated},
- {"hide-deleted", toggle_activated, NULL, "false",
+ {"hide-deleted", libbalsa_toggle_activated, NULL, "false",
hide_change_state},
- {"hide-undeleted", toggle_activated, NULL, "false",
+ {"hide-undeleted", libbalsa_toggle_activated, NULL, "false",
hide_change_state},
- {"hide-read", toggle_activated, NULL, "false",
+ {"hide-read", libbalsa_toggle_activated, NULL, "false",
hide_change_state},
- {"hide-unread", toggle_activated, NULL, "false",
+ {"hide-unread", libbalsa_toggle_activated, NULL, "false",
hide_change_state},
- {"hide-flagged", toggle_activated, NULL, "false",
+ {"hide-flagged", libbalsa_toggle_activated, NULL, "false",
hide_change_state},
- {"hide-unflagged", toggle_activated, NULL, "false",
+ {"hide-unflagged", libbalsa_toggle_activated, NULL, "false",
hide_change_state},
- {"hide-answered", toggle_activated, NULL, "false",
+ {"hide-answered", libbalsa_toggle_activated, NULL, "false",
hide_change_state},
- {"hide-unanswered", toggle_activated, NULL, "false",
+ {"hide-unanswered", libbalsa_toggle_activated, NULL, "false",
hide_change_state},
{"reset-filter", reset_filter_activated},
{"mailbox-select-all", mailbox_select_all_activated},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]