aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2009-12-08 16:42:08 -0600
committerTed Gould <ted@gould.cx>2009-12-08 16:42:08 -0600
commite0bf73e8c49059647c0b5dcd747f1234de95f010 (patch)
treeaa2887e3a679fc1e10aa86824a81d1c1b61d8a3d /src
parent4a19cb469fdbdbe9b7355fc9fdf44368fa9c9b6b (diff)
parent284188bb81f79d5fc98b01206a129ab6ccfc8f13 (diff)
downloadayatana-indicator-application-e0bf73e8c49059647c0b5dcd747f1234de95f010.tar.gz
ayatana-indicator-application-e0bf73e8c49059647c0b5dcd747f1234de95f010.tar.bz2
ayatana-indicator-application-e0bf73e8c49059647c0b5dcd747f1234de95f010.zip
Improved menu item parsing from Cody.
Diffstat (limited to 'src')
-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);