ayatana-commits team mailing list archive
-
ayatana-commits team
-
Mailing list archive
-
Message #01560
[Merge] lp:~ted/indicator-appmenu/hiding-entries into lp:indicator-appmenu
Ted Gould has proposed merging lp:~ted/indicator-appmenu/hiding-entries into lp:indicator-appmenu.
Requested reviews:
Indicator Applet Developers (indicator-applet-developers)
Support for visibility and enabled properties for items on the main menubar.
--
https://code.launchpad.net/~ted/indicator-appmenu/hiding-entries/+merge/27085
Your team ayatana-commits is subscribed to branch lp:indicator-appmenu.
=== modified file 'src/window-menus.c'
--- src/window-menus.c 2010-06-04 04:00:09 +0000
+++ src/window-menus.c 2010-06-08 21:05:36 +0000
@@ -299,6 +299,28 @@
return;
}
+/* Respond to properties changing on the menu item so that we can
+ properly hide and show them. */
+static void
+menu_prop_changed (DbusmenuMenuitem * item, const gchar * property, const GValue * value, gpointer user_data)
+{
+ IndicatorObjectEntry * entry = (IndicatorObjectEntry *)user_data;
+
+ if (!g_strcmp0(property, DBUSMENU_MENUITEM_PROP_VISIBLE)) {
+ if (g_value_get_boolean(value)) {
+ gtk_widget_show(GTK_WIDGET(entry->label));
+ } else {
+ gtk_widget_hide(GTK_WIDGET(entry->label));
+ }
+ } else if (!g_strcmp0(property, DBUSMENU_MENUITEM_PROP_ENABLED)) {
+ gtk_widget_set_sensitive(GTK_WIDGET(entry->label), g_value_get_boolean(value));
+ } else if (!g_strcmp0(property, DBUSMENU_MENUITEM_PROP_LABEL)) {
+ gtk_label_set_text(entry->label, g_value_get_string(value));
+ }
+
+ return;
+}
+
/* We can't go until we have some kids. Really, it's important. */
static void
menu_child_realized (DbusmenuMenuitem * child, gpointer user_data)
@@ -326,7 +348,12 @@
gtk_menu_detach(entry->menu);
}
- gtk_widget_show(GTK_WIDGET(entry->label));
+ g_signal_connect(G_OBJECT(newentry), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(menu_prop_changed), entry);
+
+ if (dbusmenu_menuitem_property_get_bool(newentry, DBUSMENU_MENUITEM_PROP_VISIBLE)) {
+ gtk_widget_show(GTK_WIDGET(entry->label));
+ }
+ gtk_widget_set_sensitive(GTK_WIDGET(entry->label), dbusmenu_menuitem_property_get_bool(newentry, DBUSMENU_MENUITEM_PROP_ENABLED));
g_array_append_val(priv->entries, entry);
Follow ups