From 83598a9e4fe059703faa806e7a9cdab1e6cb293c Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Wed, 28 Nov 2012 13:29:15 +0100 Subject: Add root menu item The action for that root item lives in ImApplicationList for now, because it owns the action group (which should probably factored into its own class at some point). --- src/messages-service.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/messages-service.c') diff --git a/src/messages-service.c b/src/messages-service.c index b3731a8..62abc81 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -200,7 +200,7 @@ got_bus (GObject *object, } g_dbus_connection_export_menu_model (bus, INDICATOR_MESSAGES_DBUS_OBJECT "/phone", - im_phone_menu_get_model (menu), &error); + G_MENU_MODEL (toplevel_menu), &error); if (error) { g_warning ("unable to export menu on dbus: %s", error->message); g_error_free (error); @@ -224,6 +224,7 @@ main (int argc, char ** argv) { GMainLoop * mainloop = NULL; IndicatorService * service = NULL; + GMenuItem *root; /* Glib init */ g_type_init(); @@ -255,7 +256,9 @@ main (int argc, char ** argv) menu = im_phone_menu_new (); toplevel_menu = g_menu_new (); - g_menu_append_submenu (toplevel_menu, NULL, im_phone_menu_get_model (menu)); + root = g_menu_item_new (NULL, "messages"); + g_menu_item_set_submenu (root, im_phone_menu_get_model (menu)); + g_menu_append_item (toplevel_menu, root); settings = g_settings_new ("com.canonical.indicator.messages"); @@ -274,6 +277,7 @@ main (int argc, char ** argv) g_main_loop_run(mainloop); /* Clean up */ + g_object_unref (root); g_object_unref (messages_service); g_object_unref (settings); g_object_unref (applications); -- cgit v1.2.3 From 8ff464d1a1d99e016b4719f090816c2c6f712abb Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Wed, 28 Nov 2012 13:42:34 +0100 Subject: messages-service.c: remove chat status action It isn't used right now (the action group wasn't even exported on the bus) and would need to be refactored anyway once chat status is added back in. --- src/messages-service.c | 91 -------------------------------------------------- 1 file changed, 91 deletions(-) (limited to 'src/messages-service.c') diff --git a/src/messages-service.c b/src/messages-service.c index 62abc81..6b8f26b 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -40,45 +40,9 @@ with this program. If not, see . static ImApplicationList *applications; static IndicatorMessagesService *messages_service; -static GSimpleActionGroup *actions; static GMenu *toplevel_menu; static ImPhoneMenu *menu; static GSettings *settings; -static gboolean draws_attention; -static const gchar *global_status[6]; /* max 5: available, away, busy, invisible, offline */ - -static gchar * -indicator_messages_get_icon_name () -{ - GString *name; - GIcon *icon; - gchar *iconstr; - - name = g_string_new ("indicator-messages"); - - if (global_status[0] != NULL) - { - if (global_status[1] != NULL) - g_string_append (name, "-mixed"); - else - g_string_append_printf (name, "-%s", global_status[0]); - } - - if (draws_attention) - g_string_append (name, "-new"); - - icon = g_themed_icon_new (name->str); - g_themed_icon_append_name (G_THEMED_ICON (icon), - draws_attention ? "indicator-messages-new" - : "indicator-messages"); - - iconstr = g_icon_to_string (icon); - - g_object_unref (icon); - g_string_free (name, TRUE); - - return iconstr; -} static void service_shutdown (IndicatorService * service, gpointer user_data) @@ -89,26 +53,6 @@ service_shutdown (IndicatorService * service, gpointer user_data) g_main_loop_quit(mainloop); } -static void -clear_action_activate (GSimpleAction *simple, - GVariant *param, - gpointer user_data) -{ - /* TODO */ -} - -static void -status_action_activate (GSimpleAction *action, - GVariant *parameter, - gpointer user_data) -{ - const gchar *status; - - status = g_variant_get_string (parameter, NULL); - - indicator_messages_service_emit_status_changed (messages_service, status); -} - static void register_application (IndicatorMessagesService *service, GDBusMethodInvocation *invocation, @@ -142,39 +86,6 @@ unregister_application (IndicatorMessagesService *service, indicator_messages_service_complete_unregister_application (service, invocation); } -static GSimpleActionGroup * -create_action_group (void) -{ - GSimpleActionGroup *actions; - GSimpleAction *messages; - GSimpleAction *clear; - GSimpleAction *status; - const gchar *default_status[] = { "offline", NULL }; - gchar *icon; - - actions = g_simple_action_group_new (); - - /* state of the messages action is its icon name */ - icon = indicator_messages_get_icon_name (); - messages = g_simple_action_new_stateful ("messages", G_VARIANT_TYPE ("s"), - g_variant_new_string (icon)); - - status = g_simple_action_new_stateful ("status", G_VARIANT_TYPE ("s"), - g_variant_new_strv (default_status, -1)); - g_signal_connect (status, "activate", G_CALLBACK (status_action_activate), NULL); - - clear = g_simple_action_new ("clear", NULL); - g_simple_action_set_enabled (clear, FALSE); - g_signal_connect (clear, "activate", G_CALLBACK (clear_action_activate), NULL); - - g_simple_action_group_insert (actions, G_ACTION (messages)); - g_simple_action_group_insert (actions, G_ACTION (status)); - g_simple_action_group_insert (actions, G_ACTION (clear)); - - g_free (icon); - return actions; -} - static void got_bus (GObject *object, GAsyncResult * res, @@ -246,8 +157,6 @@ main (int argc, char ** argv) g_bus_get (G_BUS_TYPE_SESSION, NULL, got_bus, NULL); - actions = create_action_group (); - g_signal_connect (messages_service, "handle-register-application", G_CALLBACK (register_application), NULL); g_signal_connect (messages_service, "handle-unregister-application", -- cgit v1.2.3 From 5c7569e03d770c5f29b0011b2b0ad04f0be2ff88 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Wed, 28 Nov 2012 14:09:26 +0100 Subject: Add x-canonical-type to the root item --- src/messages-service.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/messages-service.c') diff --git a/src/messages-service.c b/src/messages-service.c index 6b8f26b..61e786f 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -166,6 +166,7 @@ main (int argc, char ** argv) toplevel_menu = g_menu_new (); root = g_menu_item_new (NULL, "messages"); + g_menu_item_set_attribute (root, "x-canonical-type", "s", "com.canonical.indicator.root"); g_menu_item_set_submenu (root, im_phone_menu_get_model (menu)); g_menu_append_item (toplevel_menu, root); -- cgit v1.2.3