From 624b6e5dd7bd32fc3f57b8c423c52f0d6738d0a7 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Tue, 18 Sep 2012 16:10:15 +0200 Subject: libmessaging-menu: don't call SetStatus(OFFLINE) for all apps Only notify the service about status if the application has actually called messaging_menu_app_set_status. This saves a d-bus call per non-chat application and - more importantly - doesn't make the messaging menu go into "unknown status" mode when one application is reporting 'online' status. --- libmessaging-menu/messaging-menu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'libmessaging-menu/messaging-menu.c') diff --git a/libmessaging-menu/messaging-menu.c b/libmessaging-menu/messaging-menu.c index 8066b35..fe2583b 100644 --- a/libmessaging-menu/messaging-menu.c +++ b/libmessaging-menu/messaging-menu.c @@ -102,6 +102,7 @@ struct _MessagingMenuApp GDesktopAppInfo *appinfo; int registered; /* -1 for unknown */ MessagingMenuStatus status; + gboolean status_set; GSimpleActionGroup *source_actions; GMenu *menu; @@ -370,7 +371,8 @@ created_messages_service (GObject *source_object, messaging_menu_app_register (app); else if (app->registered == FALSE) messaging_menu_app_unregister (app); - messaging_menu_app_set_status (app, app->status); + if (app->status_set) + messaging_menu_app_set_status (app, app->status); } static void @@ -410,7 +412,7 @@ static void messaging_menu_app_init (MessagingMenuApp *app) { app->registered = -1; - app->status = MESSAGING_MENU_STATUS_OFFLINE; + app->status_set = FALSE; app->cancellable = g_cancellable_new (); @@ -538,6 +540,7 @@ messaging_menu_app_set_status (MessagingMenuApp *app, status <= MESSAGING_MENU_STATUS_OFFLINE); app->status = status; + app->status_set = TRUE; /* state will be synced right after connecting to the service */ if (!app->messages_service) -- cgit v1.2.3 From da9fde78ca62bd0b05dfbee3e024fd776c29c373 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Tue, 18 Sep 2012 16:17:57 +0200 Subject: libmessaging-menu: don't set app->status when global status changes The application's status only changes when it calls _set_status, so it's wrong to set the internal status when the global status changes. This shouldn't be a problem in practice, as app->status is not accessible from the API. --- libmessaging-menu/messaging-menu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'libmessaging-menu/messaging-menu.c') diff --git a/libmessaging-menu/messaging-menu.c b/libmessaging-menu/messaging-menu.c index fe2583b..1b2e694 100644 --- a/libmessaging-menu/messaging-menu.c +++ b/libmessaging-menu/messaging-menu.c @@ -580,8 +580,7 @@ global_status_changed (IndicatorMessagesService *service, status = status_from_string (status_str); g_return_if_fail (status >= 0); - app->status = (MessagingMenuStatus)status; - g_signal_emit (app, signals[STATUS_CHANGED], 0, app->status); + g_signal_emit (app, signals[STATUS_CHANGED], 0, status); } static void -- cgit v1.2.3 From 24ee0b6602960f35712adbf668099e06b8ebfb25 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Tue, 18 Sep 2012 21:54:37 +0200 Subject: Set the global chat status more intelligently Up until now, the global chat status was set every time an application called _set_status. Thus, global status really meant "status of the app that last changed the status". Now, the service remembers the chat status for each application and sets the global status as a combination of all of application statuses. If applications have different statuses, the menu items are shown in an inconsistent state. This is implemented in IdoMenuItem by making it accept state as an array of strings in addition to a single string. It is drawn inconsistent if the state contains the menu item's target value in addition to other values. When the global status is changed through the messaging menu, the service doesn't update the action immediately anymore. Instead, it notifies all applications about the change via the "status-changed" signal. Applications must call _set_state to acknowledge that they have indeed changed their state. This is consistent with libmessaging-menu's documentation and design. Also, the SetStatus D-Bus call was missing a "desktop-id" parameter to tell the menu which application changed status. Changing this doesn't break existing apps, as the D-Bus interface is considered private to indicator-messages. --- libmessaging-menu/messaging-menu.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libmessaging-menu/messaging-menu.c') diff --git a/libmessaging-menu/messaging-menu.c b/libmessaging-menu/messaging-menu.c index 1b2e694..8a95b0a 100644 --- a/libmessaging-menu/messaging-menu.c +++ b/libmessaging-menu/messaging-menu.c @@ -547,6 +547,7 @@ messaging_menu_app_set_status (MessagingMenuApp *app, return; indicator_messages_service_call_set_status (app->messages_service, + g_app_info_get_id (G_APP_INFO (app->appinfo)), status_ids [status], app->cancellable, NULL, NULL); -- cgit v1.2.3