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/im-application-list.c | 15 +++++++-------- src/messages-service.c | 8 ++++++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/im-application-list.c b/src/im-application-list.c index d766f24..c5e34b7 100644 --- a/src/im-application-list.c +++ b/src/im-application-list.c @@ -304,22 +304,21 @@ im_application_list_class_init (ImApplicationListClass *klass) static void im_application_list_init (ImApplicationList *list) { + const GActionEntry action_entries[] = { + { "messages", NULL, NULL, "('', 'indicator-messages', 'Messages', true)", NULL }, + { "remove-all", im_application_list_remove_all } + }; + GSimpleActionGroup *actions; - GSimpleAction *remove_all_action; list->applications = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, application_free); - list->muxer = g_action_muxer_new (); actions = g_simple_action_group_new (); + g_simple_action_group_add_entries (actions, action_entries, G_N_ELEMENTS (action_entries), list); - remove_all_action = g_simple_action_new ("remove-all", NULL); - g_signal_connect (remove_all_action, "activate", G_CALLBACK (im_application_list_remove_all), list); - - g_simple_action_group_insert (actions, G_ACTION (remove_all_action)); - + list->muxer = g_action_muxer_new (); g_action_muxer_insert (list->muxer, NULL, G_ACTION_GROUP (actions)); - g_object_unref (remove_all_action); g_object_unref (actions); } 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(-) 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(+) 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 From 4bfe4198605a873fdede8b7cf454b4134ce2ce52 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Thu, 29 Nov 2012 20:44:38 +0100 Subject: ImApplicationList: specify right number of args for 'message-added' This fixes a crash on arm, because g_signal_emit was called with one argument too many. --- src/im-application-list.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/im-application-list.c b/src/im-application-list.c index c5e34b7..f0bf362 100644 --- a/src/im-application-list.c +++ b/src/im-application-list.c @@ -269,7 +269,8 @@ im_application_list_class_init (ImApplicationListClass *klass) NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, - 8, + 9, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, -- cgit v1.2.3 From e3aaed0ef166af28b3a819f1ffe04905a421874f Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Fri, 30 Nov 2012 11:18:55 +0100 Subject: 12.10.6-0ubuntu1phablet3 --- debian/changelog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/debian/changelog b/debian/changelog index d30e1f1..a1a6b2d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +indicator-messages (12.10.6-0ubuntu1phablet3) quantal; urgency=low + + [Lars Uebernickel] + * expose root menu item of which the indicator menu is a submenu + * fix crash in im-application-list on arm + + -- Lars Uebernickel Thu, 29 Nov 2012 21:44:19 +0100 + indicator-messages (12.10.6-0ubuntu1phablet2) quantal; urgency=low [Lars Uebernickel] -- cgit v1.2.3