diff options
author | Ted Gould <ted@canonical.com> | 2009-09-02 16:07:11 -0500 |
---|---|---|
committer | Ted Gould <ted@canonical.com> | 2009-09-02 16:07:11 -0500 |
commit | e7c1a0be55b9f48aa2efd74462e67181f9e7a4d2 (patch) | |
tree | abf1f1b3e966fdf475d17bf0336f9fa738876a46 /libdbusmenu-gtk/client.c | |
parent | d3b9f1d9459e1476f305b9268b9280cf6bb0a25c (diff) | |
parent | f100a3d4ea985e2aff4365ee685825e5b81b576a (diff) | |
download | libdbusmenu-e7c1a0be55b9f48aa2efd74462e67181f9e7a4d2.tar.gz libdbusmenu-e7c1a0be55b9f48aa2efd74462e67181f9e7a4d2.tar.bz2 libdbusmenu-e7c1a0be55b9f48aa2efd74462e67181f9e7a4d2.zip |
Merging in the sensitivity branch. It adds a property for adjusting the sensitivity of menu items.
Diffstat (limited to 'libdbusmenu-gtk/client.c')
-rw-r--r-- | libdbusmenu-gtk/client.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 7271c37..b3d55d9 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -48,6 +48,9 @@ static gboolean new_item_normal (DbusmenuMenuitem * newitem, DbusmenuMenuite static gboolean new_item_seperator (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); static gboolean new_item_image (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); +static void process_visible (GtkMenuItem * gmi, const gchar * value); +static void process_sensitive (GtkMenuItem * gmi, const gchar * value); + /* GObject Stuff */ G_DEFINE_TYPE (DbusmenuGtkClient, dbusmenu_gtkclient, DBUSMENU_TYPE_CLIENT); @@ -116,6 +119,18 @@ process_visible (GtkMenuItem * gmi, const gchar * value) return; } +/* Process the sensitive property */ +static void +process_sensitive (GtkMenuItem * gmi, const gchar * value) +{ + if (value == NULL || !g_strcmp0(value, "true")) { + gtk_widget_set_sensitive(GTK_WIDGET(gmi), TRUE); + } else { + gtk_widget_set_sensitive(GTK_WIDGET(gmi), FALSE); + } + return; +} + /* Whenever we have a property change on a DbusmenuMenuitem we need to be responsive to that. */ static void @@ -125,6 +140,8 @@ menu_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, gchar * value, GtkMenu gtk_menu_item_set_label(gmi, value); } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_VISIBLE)) { process_visible(gmi, value); + } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_SENSITIVE)) { + process_sensitive(gmi, value); } return; @@ -171,6 +188,7 @@ dbusmenu_gtkclient_newitem_base (DbusmenuGtkClient * client, DbusmenuMenuitem * g_object_weak_ref(G_OBJECT(item), destoryed_dbusmenuitem_cb, gmi); process_visible(gmi, dbusmenu_menuitem_property_get(item, DBUSMENU_MENUITEM_PROP_VISIBLE)); + process_sensitive(gmi, dbusmenu_menuitem_property_get(item, DBUSMENU_MENUITEM_PROP_SENSITIVE)); if (parent != NULL) { new_child(parent, item, dbusmenu_menuitem_get_position(item, parent), DBUSMENU_GTKCLIENT(client)); |