aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2014-03-27 13:16:10 +0100
committerLars Uebernickel <lars.uebernickel@canonical.com>2014-03-27 13:16:10 +0100
commitb5fe1d71145ecb8b9e31e7baafc89a46506dae4c (patch)
treeaed323b18d645594a38ca015ec076976a6d5e812
parent7614e880579dce57aca4ba01dca328d03a1271fc (diff)
downloadayatana-ido-b5fe1d71145ecb8b9e31e7baafc89a46506dae4c.tar.gz
ayatana-ido-b5fe1d71145ecb8b9e31e7baafc89a46506dae4c.tar.bz2
ayatana-ido-b5fe1d71145ecb8b9e31e7baafc89a46506dae4c.zip
Expose IdoBasicMenuItem as com.canonical.indicator.basic
-rw-r--r--src/idobasicmenuitem.c59
-rw-r--r--src/idobasicmenuitem.h3
-rw-r--r--src/idomenuitemfactory.c3
3 files changed, 65 insertions, 0 deletions
diff --git a/src/idobasicmenuitem.c b/src/idobasicmenuitem.c
index d5ab0de..c023b7b 100644
--- a/src/idobasicmenuitem.c
+++ b/src/idobasicmenuitem.c
@@ -305,3 +305,62 @@ ido_basic_menu_item_set_secondary_text (IdoBasicMenuItem * self, const char * se
NULL);
}
}
+
+static void
+ido_basic_menu_item_activate (GtkMenuItem *item,
+ gpointer user_data)
+{
+ IdoActionHelper *helper = user_data;
+
+ ido_action_helper_activate (helper);
+}
+
+GtkMenuItem *
+ido_basic_menu_item_new_from_model (GMenuItem * menu_item,
+ GActionGroup * actions)
+{
+ GtkWidget *item;
+ gchar *label;
+ gchar *action;
+ GVariant *serialized_icon;
+
+ item = ido_basic_menu_item_new ();
+
+ if (g_menu_item_get_attribute (menu_item, "label", "s", &label))
+ {
+ ido_basic_menu_item_set_text (IDO_BASIC_MENU_ITEM (item), label);
+ g_free (label);
+ }
+
+ serialized_icon = g_menu_item_get_attribute_value (menu_item, "icon", NULL);
+ if (serialized_icon)
+ {
+ GIcon *icon;
+
+ icon = g_icon_deserialize (serialized_icon);
+ ido_basic_menu_item_set_icon (IDO_BASIC_MENU_ITEM (item), icon);
+
+ g_object_unref (icon);
+ g_variant_unref (serialized_icon);
+ }
+
+ if (g_menu_item_get_attribute (menu_item, "action", "s", &action))
+ {
+ IdoActionHelper *helper;
+ GVariant *target;
+
+ target = g_menu_item_get_attribute_value (menu_item, "target", NULL);
+
+ helper = ido_action_helper_new (item, actions, action, target);
+ g_signal_connect_object (item, "activate",
+ G_CALLBACK (ido_basic_menu_item_activate), helper,
+ 0);
+ g_signal_connect_swapped (item, "destroy", G_CALLBACK (g_object_unref), helper);
+
+ if (target)
+ g_variant_unref (target);
+ g_free (action);
+ }
+
+ return GTK_MENU_ITEM (item);
+}
diff --git a/src/idobasicmenuitem.h b/src/idobasicmenuitem.h
index da1216e..6a4b83a 100644
--- a/src/idobasicmenuitem.h
+++ b/src/idobasicmenuitem.h
@@ -64,6 +64,9 @@ void ido_basic_menu_item_set_text (IdoBasicMenuItem * self,
void ido_basic_menu_item_set_secondary_text (IdoBasicMenuItem * self,
const char * text);
+GtkMenuItem * ido_basic_menu_item_new_from_model (GMenuItem * menuitem,
+ GActionGroup * actions);
+
G_END_DECLS
#endif
diff --git a/src/idomenuitemfactory.c b/src/idomenuitemfactory.c
index 7f5d932..cb10cce 100644
--- a/src/idomenuitemfactory.c
+++ b/src/idomenuitemfactory.c
@@ -75,6 +75,9 @@ ido_menu_item_factory_create_menu_item (UbuntuMenuItemFactory *factory,
else if (g_str_equal (type, "com.canonical.indicator.alarm"))
item = ido_alarm_menu_item_new_from_model (menuitem, actions);
+ else if (g_str_equal (type, "com.canonical.indicator.basic"))
+ item = ido_basic_menu_item_new_from_model (menuitem, actions);
+
else if (g_str_equal (type, "com.canonical.indicator.progress"))
item = ido_progress_menu_item_new_from_model (menuitem, actions);