aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCody Russell <crussell@canonical.com>2009-12-08 16:34:01 -0600
committerCody Russell <crussell@canonical.com>2009-12-08 16:34:01 -0600
commit284188bb81f79d5fc98b01206a129ab6ccfc8f13 (patch)
tree81d7079c869523e208bf347049ef07be7c9487d4
parent95ecb480de8da2e06b07be2313537093bb47069a (diff)
downloadayatana-indicator-application-284188bb81f79d5fc98b01206a129ab6ccfc8f13.tar.gz
ayatana-indicator-application-284188bb81f79d5fc98b01206a129ab6ccfc8f13.tar.bz2
ayatana-indicator-application-284188bb81f79d5fc98b01206a129ab6ccfc8f13.zip
Beefed up and stuff.
-rw-r--r--src/libappindicator/app-indicator.c65
1 files changed, 61 insertions, 4 deletions
diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c
index bd72499..6f4a6fd 100644
--- a/src/libappindicator/app-indicator.c
+++ b/src/libappindicator/app-indicator.c
@@ -641,17 +641,74 @@ activate_menuitem (DbusmenuMenuitem *mi, gpointer user_data)
}
static void
+menuitem_iterate (GtkWidget *widget,
+ gpointer data)
+{
+ if (GTK_IS_LABEL (widget))
+ {
+ DbusmenuMenuitem *child = (DbusmenuMenuitem *)data;
+
+ dbusmenu_menuitem_property_set (child,
+ DBUSMENU_MENUITEM_PROP_LABEL,
+ gtk_label_get_text (GTK_LABEL (widget)));
+ }
+}
+
+static void
container_iterate (GtkWidget *widget,
gpointer data)
{
DbusmenuMenuitem *root = (DbusmenuMenuitem *)data;
DbusmenuMenuitem *child;
+ const gchar *label;
+ gboolean label_set = FALSE;
+
+ label = gtk_menu_item_get_label (GTK_MENU_ITEM (widget));
child = dbusmenu_menuitem_new ();
- dbusmenu_menuitem_property_set (child,
- DBUSMENU_MENUITEM_PROP_LABEL,
- gtk_menu_item_get_label (GTK_MENU_ITEM (widget)));
- g_signal_connect (G_OBJECT(child),
+
+ if (GTK_IS_IMAGE_MENU_ITEM (widget))
+ {
+ GtkWidget *image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (widget));
+
+ if (gtk_image_get_storage_type (GTK_IMAGE (image)) == GTK_IMAGE_STOCK)
+ {
+ GtkStockItem stock;
+
+ gtk_stock_lookup (GTK_IMAGE (image)->data.stock.stock_id, &stock);
+
+ dbusmenu_menuitem_property_set (child,
+ DBUSMENU_MENUITEM_PROP_ICON,
+ GTK_IMAGE (image)->data.stock.stock_id);
+
+ if (stock.label != NULL)
+ {
+ dbusmenu_menuitem_property_set (child,
+ DBUSMENU_MENUITEM_PROP_LABEL,
+ stock.label);
+ label_set = TRUE;
+ }
+ }
+ }
+
+ if (!label_set)
+ {
+ if (label != NULL)
+ {
+ dbusmenu_menuitem_property_set (child,
+ DBUSMENU_MENUITEM_PROP_LABEL,
+ label);
+ }
+ else
+ {
+ /* find label child widget */
+ gtk_container_forall (GTK_CONTAINER (widget),
+ menuitem_iterate,
+ child);
+ }
+ }
+
+ g_signal_connect (G_OBJECT (child),
DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
G_CALLBACK (activate_menuitem), widget);
dbusmenu_menuitem_child_append (root, child);