diff options
author | Ted Gould <ted@canonical.com> | 2009-08-26 15:25:37 -0500 |
---|---|---|
committer | Ted Gould <ted@canonical.com> | 2009-08-26 15:25:37 -0500 |
commit | 340e506debd81bb6f2dff5ee56e02ebf3b20b5dc (patch) | |
tree | a4ee58e39cf2b3b0b6f12520f52877dbdc8ae8a3 | |
parent | 749c283bbaaffff3ca4622ec32df6300ab08b559 (diff) | |
download | libdbusmenu-340e506debd81bb6f2dff5ee56e02ebf3b20b5dc.tar.gz libdbusmenu-340e506debd81bb6f2dff5ee56e02ebf3b20b5dc.tar.bz2 libdbusmenu-340e506debd81bb6f2dff5ee56e02ebf3b20b5dc.zip |
Centralize visiblity processing and changes to the prop value.
-rw-r--r-- | libdbusmenu-gtk/client.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index d3efb08..afa8bb3 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -104,14 +104,27 @@ menu_pressed_cb (GtkMenuItem * gmi, DbusmenuMenuitem * mi) return TRUE; } +/* Process the visible property */ +static void +process_visible (GtkMenuItem * gmi, const gchar * value) +{ + if (value == NULL || !g_strcmp0(value, "true")) { + gtk_widget_show(GTK_WIDGET(gmi)); + } else { + gtk_widget_hide(GTK_WIDGET(gmi)); + } + return; +} + /* Whenever we have a property change on a DbusmenuMenuitem we need to be responsive to that. */ static void menu_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, gchar * value, GtkMenuItem * gmi) { - if (!g_strcmp0(prop, "label")) { + if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_LABEL)) { gtk_menu_item_set_label(gmi, value); - gtk_widget_show(GTK_WIDGET(gmi)); + } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_VISIBLE)) { + process_visible(gmi, value); } return; @@ -157,6 +170,8 @@ base_new_menuitem (DbusmenuMenuitem * mi, GtkMenuItem * gmi, DbusmenuGtkClient * /* Life insurance */ g_object_weak_ref(G_OBJECT(mi), destoryed_dbusmenuitem_cb, gmi); + process_visible(gmi, dbusmenu_menuitem_property_get(mi, DBUSMENU_MENUITEM_PROP_VISIBLE)); + return; } @@ -271,7 +286,6 @@ new_item_normal (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusmenu GtkMenuItem * gmi; gmi = GTK_MENU_ITEM(gtk_menu_item_new_with_label(dbusmenu_menuitem_property_get(newitem, "label"))); - gtk_widget_show(GTK_WIDGET(gmi)); base_new_menuitem(newitem, gmi, DBUSMENU_GTKCLIENT(client)); if (parent != NULL) { @@ -287,7 +301,6 @@ new_item_seperator (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm GtkMenuItem * gmi; gmi = GTK_MENU_ITEM(gtk_separator_menu_item_new()); - gtk_widget_show(GTK_WIDGET(gmi)); base_new_menuitem(newitem, gmi, DBUSMENU_GTKCLIENT(client)); if (parent != NULL) { |