[ekiga/ds-gsettings3] GmMenuAddon: Ported TOGGLE_ENTRY and RADIO_MENU_ENTRY to GSettings.
- From: Damien Sandras <dsandras src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga/ds-gsettings3] GmMenuAddon: Ported TOGGLE_ENTRY and RADIO_MENU_ENTRY to GSettings.
- Date: Mon, 11 Nov 2013 17:07:01 +0000 (UTC)
commit ce83ff57a565f54d39df110dd33a1261de6c9a6e
Author: Damien Sandras <dsandras beip be>
Date: Mon Nov 11 18:03:25 2013 +0100
GmMenuAddon: Ported TOGGLE_ENTRY and RADIO_MENU_ENTRY to GSettings.
I don't like having GSettings things in the callbacks, but that is a pure
port of the old code. Things can be improved at a later stage if required.
lib/gui/gmmenuaddon.c | 21 ++++++++++++++++++---
lib/gui/gmmenuaddon.h | 23 ++++++++++++-----------
2 files changed, 30 insertions(+), 14 deletions(-)
---
diff --git a/lib/gui/gmmenuaddon.c b/lib/gui/gmmenuaddon.c
index 7619afa..6556cea 100644
--- a/lib/gui/gmmenuaddon.c
+++ b/lib/gui/gmmenuaddon.c
@@ -132,17 +132,24 @@ menu_item_selected (GtkWidget *w,
/* The public functions */
+// FIXME: I'm not particularly happy with those public callbacks
+// because they require a GSettings parameter to be passed
+// to the GtkMenu structure...
void
radio_menu_changed_cb (GtkWidget *widget,
gpointer data)
{
GSList *group = NULL;
+ GSettings *settings = NULL;
int group_last_pos = 0;
int active = 0;
g_return_if_fail (data != NULL);
+ settings = g_object_get_data (G_OBJECT (widget), "settings");
+ g_return_if_fail (settings != NULL);
+
group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (widget));
group_last_pos = g_slist_length (group) - 1; /* If length 1, last pos is 0 */
@@ -159,7 +166,7 @@ radio_menu_changed_cb (GtkWidget *widget,
group = g_slist_next (group);
}
- gm_conf_set_int ((gchar *) data, group_last_pos - active);
+ g_settings_set_int (settings, (gchar *) data, group_last_pos - active);
}
}
@@ -168,10 +175,14 @@ void
toggle_menu_changed_cb (GtkWidget *widget,
gpointer data)
{
+ GSettings *settings = NULL;
g_return_if_fail (data != NULL);
- gm_conf_set_bool ((gchar *) data,
- gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)));
+ settings = g_object_get_data (G_OBJECT (widget), "settings");
+ g_return_if_fail (settings != NULL);
+
+ g_settings_set_boolean (settings, (gchar *) data,
+ gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)));
}
@@ -219,6 +230,8 @@ gtk_build_menu (GtkWidget *menubar,
else if (menu [i].type == MENU_TOGGLE_ENTRY) {
menu [i].widget = gtk_check_menu_item_new_with_mnemonic (menu_name);
+ if (menu [i].settings)
+ g_object_set_data (G_OBJECT (menu [i].widget), "settings", menu [i].settings);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu [i].widget),
menu [i].enabled);
}
@@ -229,6 +242,8 @@ gtk_build_menu (GtkWidget *menubar,
menu [i].widget = gtk_radio_menu_item_new_with_mnemonic (group,
menu_name);
+ if (menu [i].settings)
+ g_object_set_data (G_OBJECT (menu [i].widget), "settings", menu [i].settings);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu [i].widget),
menu [i].enabled);
diff --git a/lib/gui/gmmenuaddon.h b/lib/gui/gmmenuaddon.h
index 0a640bb..2cb3009 100644
--- a/lib/gui/gmmenuaddon.h
+++ b/lib/gui/gmmenuaddon.h
@@ -67,6 +67,7 @@ typedef struct _MenuEntry {
gboolean stock_is_theme;
guint accel;
MenuEntryType type;
+ GSettings *settings;
GCallback func;
GClosureNotify clofunc;
gpointer data;
@@ -77,31 +78,31 @@ typedef struct _MenuEntry {
#define GTK_MENU_SEPARATOR \
-{NULL, NULL, NULL, NULL, FALSE, 0, MENU_SEP, NULL, NULL, NULL, NULL, TRUE, TRUE}
+{NULL, NULL, NULL, NULL, FALSE, 0, MENU_SEP, NULL, NULL, NULL, NULL, NULL, TRUE, TRUE}
#define GTK_MENU_ENTRY(a, b, c, d, e, f, g, h) \
-{a, b, c, d, FALSE, e, MENU_ENTRY, f, NULL, g, NULL, TRUE, h}
+{a, b, c, d, FALSE, e, MENU_ENTRY, NULL, f, NULL, g, NULL, TRUE, h}
#define GTK_MENU_THEME_ENTRY(a, b, c, d, e, f, g, h) \
-{a, b, c, d, TRUE, e, MENU_ENTRY, f, NULL, g, NULL, TRUE, h}
+{a, b, c, d, TRUE, e, MENU_ENTRY, NULL, f, NULL, g, NULL, TRUE, h}
#define GTK_MENU_ENTRY_WITH_CLOSURE(a, b, c, d, e, f, g, h, i) \
-{a, b, c, d, FALSE, e, MENU_ENTRY, f, g, h, NULL, TRUE, i}
+{a, b, c, d, FALSE, e, MENU_ENTRY, NULL, f, g, h, NULL, TRUE, i}
-#define GTK_MENU_RADIO_ENTRY(a, b, c, d, e, f, g, h, i) \
-{a, b, c, d, FALSE, e, MENU_RADIO_ENTRY, f, NULL, g, NULL, h, i}
+#define GTK_MENU_RADIO_ENTRY(a, b, c, d, e, f, g, h, i, j) \
+{a, b, c, d, FALSE, e, MENU_RADIO_ENTRY, f, g, NULL, h, NULL, i, j}
-#define GTK_MENU_TOGGLE_ENTRY(a, b, c, d, e, f, g, h, i) \
-{a, b, c, d, FALSE, e, MENU_TOGGLE_ENTRY, f, NULL, g, NULL, h, i}
+#define GTK_MENU_TOGGLE_ENTRY(a, b, c, d, e, f, g, h, i, j) \
+{a, b, c, d, FALSE, e, MENU_TOGGLE_ENTRY, f, g, NULL, h, NULL, i, j}
#define GTK_MENU_NEW(a) \
-{NULL, a, NULL, NULL, FALSE, 0, MENU_NEW, NULL, NULL, NULL, NULL, TRUE, TRUE}
+{NULL, a, NULL, NULL, FALSE, 0, MENU_NEW, NULL, NULL, NULL, NULL, NULL, TRUE, TRUE}
#define GTK_SUBMENU_NEW(a, b) \
-{a, b, NULL, NULL, FALSE, 0, MENU_SUBMENU_NEW, NULL, NULL, NULL, NULL, TRUE, TRUE}
+{a, b, NULL, NULL, FALSE, 0, MENU_SUBMENU_NEW, NULL, NULL, NULL, NULL, NULL, TRUE, TRUE}
#define GTK_MENU_END \
-{NULL, NULL, NULL, NULL, FALSE, 0, MENU_END, NULL, NULL, NULL, NULL, TRUE, TRUE}
+{NULL, NULL, NULL, NULL, FALSE, 0, MENU_END, NULL, NULL, NULL, NULL, NULL, TRUE, TRUE}
/* DESCRIPTION : This callback is called when the user
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]