diff options
author | Ted Gould <ted@gould.cx> | 2010-02-16 09:52:33 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-02-16 09:52:33 -0600 |
commit | 1b3b3fee28473858b6bf5dbd089fbf1b7e75ed35 (patch) | |
tree | 04443b8423328220080e6e06da9c568d14baf259 | |
parent | 5fef5a229127903de8e96132a0908d88a0f97723 (diff) | |
parent | 2cc377b1d730787d4d1ae15ebeaf8563f264813f (diff) | |
download | libayatana-appindicator-1b3b3fee28473858b6bf5dbd089fbf1b7e75ed35.tar.gz libayatana-appindicator-1b3b3fee28473858b6bf5dbd089fbf1b7e75ed35.tar.bz2 libayatana-appindicator-1b3b3fee28473858b6bf5dbd089fbf1b7e75ed35.zip |
* Upstream Merge
* Submenu support
* Updating menus
-rw-r--r-- | debian/changelog | 8 | ||||
-rw-r--r-- | example/simple-client.c | 5 | ||||
-rw-r--r-- | src/libappindicator/app-indicator.c | 92 |
3 files changed, 70 insertions, 35 deletions
diff --git a/debian/changelog b/debian/changelog index b16f347..6144070 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +indicator-application (0.0.13-0ubuntu3~ppa1) UNRELEASED; urgency=low + + * Upstream Merge + * Submenu support + * Updating menus + + -- Ted Gould <ted@ubuntu.com> Tue, 16 Feb 2010 09:52:08 -0600 + indicator-application (0.0.13-0ubuntu2) lucid; urgency=low * Backported lp:~bratsche/indicator-application/submenus to make the submenus diff --git a/example/simple-client.c b/example/simple-client.c index 997a446..a698b48 100644 --- a/example/simple-client.c +++ b/example/simple-client.c @@ -57,7 +57,6 @@ toggle_sensitivity_cb (GtkWidget *widget, gpointer data) { GtkWidget *target = (GtkWidget *)data; - gtk_menu_item_set_label (GTK_MENU_ITEM (target), "modified!!"); gtk_widget_set_sensitive (target, !GTK_WIDGET_IS_SENSITIVE (target)); } @@ -73,6 +72,7 @@ append_submenu (GtkWidget *item) { GtkWidget *menu; GtkWidget *mi; + GtkWidget *prev_mi; menu = gtk_menu_new (); @@ -81,10 +81,11 @@ append_submenu (GtkWidget *item) g_signal_connect (mi, "activate", G_CALLBACK (item_clicked_cb), "Sub 1"); + prev_mi = mi; mi = gtk_menu_item_new_with_label ("Sub 2"); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); g_signal_connect (mi, "activate", - G_CALLBACK (item_clicked_cb), "Sub 2"); + G_CALLBACK (toggle_sensitivity_cb), prev_mi); mi = gtk_menu_item_new_with_label ("Sub 3"); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index d179df7..0324a34 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -447,23 +447,23 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu switch (prop_id) { case PROP_ID: - if (priv->id != NULL) { - g_warning ("Resetting ID value when I already had a value of: %s", priv->id); - break; - } - - priv->id = g_strdup (g_value_get_string (value)); - - priv->clean_id = g_strdup(priv->id); - gchar * cleaner; - for (cleaner = priv->clean_id; *cleaner != '\0'; cleaner++) { - if (!g_ascii_isalnum(*cleaner)) { - *cleaner = '_'; - } - } + if (priv->id != NULL) { + g_warning ("Resetting ID value when I already had a value of: %s", priv->id); + break; + } + + priv->id = g_strdup (g_value_get_string (value)); + + priv->clean_id = g_strdup(priv->id); + gchar * cleaner; + for (cleaner = priv->clean_id; *cleaner != '\0'; cleaner++) { + if (!g_ascii_isalnum(*cleaner)) { + *cleaner = '_'; + } + } - check_connect (self); - break; + check_connect (self); + break; case PROP_CATEGORY: enum_val = g_enum_get_value_by_nick ((GEnumClass *) g_type_class_ref (APP_INDICATOR_TYPE_INDICATOR_CATEGORY), @@ -506,11 +506,11 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu break; case PROP_ICON_THEME_PATH: - if (priv->icon_path != NULL) { - g_free(priv->icon_path); - } - priv->icon_path = g_value_dup_string(value); - break; + if (priv->icon_path != NULL) { + g_free(priv->icon_path); + } + priv->icon_path = g_value_dup_string(value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -556,14 +556,14 @@ app_indicator_get_property (GObject * object, guint prop_id, GValue * value, GPa break; case PROP_MENU: - if (priv->menuservice != NULL) { - GValue strval = {0}; - g_value_init(&strval, G_TYPE_STRING); - g_object_get_property (G_OBJECT (priv->menuservice), DBUSMENU_SERVER_PROP_DBUS_OBJECT, &strval); - g_value_set_boxed(value, g_value_get_string(&strval)); - g_value_unset(&strval); - } - break; + if (priv->menuservice != NULL) { + GValue strval = { 0 }; + g_value_init(&strval, G_TYPE_STRING); + g_object_get_property (G_OBJECT (priv->menuservice), DBUSMENU_SERVER_PROP_DBUS_OBJECT, &strval); + g_value_set_boxed(value, g_value_get_string(&strval)); + g_value_unset(&strval); + } + break; case PROP_CONNECTED: g_value_set_boolean (value, priv->watcher_proxy != NULL ? TRUE : FALSE); @@ -1076,7 +1076,10 @@ update_stock_item (DbusmenuMenuitem *menuitem, DBUSMENU_MENUITEM_PROP_ICON_NAME, image->data.stock.stock_id); - if (stock.label != NULL) + const gchar * label = dbusmenu_menuitem_property_get (menuitem, + DBUSMENU_MENUITEM_PROP_LABEL); + + if (stock.label != NULL && label != NULL) { dbusmenu_menuitem_property_set (menuitem, DBUSMENU_MENUITEM_PROP_LABEL, @@ -1125,6 +1128,12 @@ widget_notify_cb (GtkWidget *widget, DBUSMENU_MENUITEM_PROP_LABEL, gtk_menu_item_get_label (GTK_MENU_ITEM (widget))); } + else if (pspec->name == g_intern_static_string ("visible")) + { + dbusmenu_menuitem_property_set_bool (child, + DBUSMENU_MENUITEM_PROP_VISIBLE, + gtk_widget_get_visible (widget)); + } } static void @@ -1259,14 +1268,22 @@ setup_dbusmenu (AppIndicator *self) return; } +static void +client_menu_changed (GtkWidget *widget, + GtkWidget *child, + AppIndicator *indicator) +{ + setup_dbusmenu (indicator); +} + /** app_indicator_set_menu: @self: The #AppIndicator @menu: A #GtkMenu to set - Sets the menu that should be shown when the Application Indicator - is clicked on in the panel. An application indicator will not - be rendered unless it has a menu. + Sets the menu that should be shown when the Application Indicator + is clicked on in the panel. An application indicator will not + be rendered unless it has a menu. **/ void app_indicator_set_menu (AppIndicator *self, GtkMenu *menu) @@ -1290,6 +1307,15 @@ app_indicator_set_menu (AppIndicator *self, GtkMenu *menu) setup_dbusmenu (self); check_connect (self); + + g_signal_connect (menu, + "add", + G_CALLBACK (client_menu_changed), + self); + g_signal_connect (menu, + "remove", + G_CALLBACK (client_menu_changed), + self); } /** |