From cc8293dacbdf1d1f74b94588e51d1fe3dcc5f021 Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Wed, 7 Mar 2012 10:09:35 +0200 Subject: Fix a build error: include locale.h --- src/session-service.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/session-service.c b/src/session-service.c index 6ee18e9..76ec047 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -25,6 +25,7 @@ with this program. If not, see . #include +#include #include #include -- cgit v1.2.3 From db65e23e1fa51bf8c18f59d126e7c397fba2a206 Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Wed, 7 Mar 2012 11:36:37 +0200 Subject: Add Web Accounts menu item Also, listen for the webcredentials service signals, to know when to set the alert disposition on the menu item. --- src/Makefile.am | 4 +- src/user-menu-mgr.c | 7 ++ src/webcredentials-mgr.c | 166 +++++++++++++++++++++++++++++++++++++++++++++++ src/webcredentials-mgr.h | 50 ++++++++++++++ 4 files changed, 226 insertions(+), 1 deletion(-) create mode 100644 src/webcredentials-mgr.c create mode 100644 src/webcredentials-mgr.h (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index a1e443e..2201da0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -109,7 +109,9 @@ indicator_session_service_SOURCES = \ user-menu-mgr.c \ device-menu-mgr.h \ device-menu-mgr.c \ - sane-rules.h + sane-rules.h \ + webcredentials-mgr.c \ + webcredentials-mgr.h if BUILD_APT indicator_session_service_SOURCES += \ diff --git a/src/user-menu-mgr.c b/src/user-menu-mgr.c index 3f4bdc4..5b2aefb 100644 --- a/src/user-menu-mgr.c +++ b/src/user-menu-mgr.c @@ -24,6 +24,7 @@ with this program. If not, see . #include "dbusmenu-shared.h" #include "lock-helper.h" #include "users-service-dbus.h" +#include "webcredentials-mgr.h" static GSettings* settings = NULL; static DbusmenuMenuitem *switch_menuitem = NULL; @@ -32,6 +33,7 @@ struct _UserMenuMgr { GObject parent_instance; UsersServiceDbus* users_dbus_interface; + WebcredentialsMgr *webcredentials_mgr; DbusmenuMenuitem* root_item; gint user_count; SessionDbus* session_dbus_interface; @@ -71,6 +73,7 @@ static void user_menu_mgr_init (UserMenuMgr *self) { self->users_dbus_interface = g_object_new (USERS_SERVICE_DBUS_TYPE, NULL); + self->webcredentials_mgr = webcredentials_mgr_new (); self->root_item = dbusmenu_menuitem_new (); g_signal_connect (G_OBJECT (self->users_dbus_interface), "user-added", @@ -259,6 +262,10 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self, gboolean greeter_mode) DBUSMENU_CLIENT_TYPES_SEPARATOR); dbusmenu_menuitem_child_append (self->root_item, separator1); + DbusmenuMenuitem *webcredentials_item = + webcredentials_mgr_get_menu_item (self->webcredentials_mgr); + dbusmenu_menuitem_child_append (self->root_item, webcredentials_item); + DbusmenuMenuitem * user_accounts_item = dbusmenu_menuitem_new(); dbusmenu_menuitem_property_set (user_accounts_item, DBUSMENU_MENUITEM_PROP_TYPE, diff --git a/src/webcredentials-mgr.c b/src/webcredentials-mgr.c new file mode 100644 index 0000000..8b44a95 --- /dev/null +++ b/src/webcredentials-mgr.c @@ -0,0 +1,166 @@ +/* +Copyright 2012 Canonical Ltd. + +Authors: + Alberto Mardegan + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#include +#include + +#include "webcredentials-mgr.h" + +#include + +struct _WebcredentialsMgr +{ + GObject parent_instance; + GDBusProxy *proxy; + DbusmenuMenuitem *menu_item; +}; + +#define WEBCREDENTIALS_OBJECT_PATH "/com/canonical/indicators/webcredentials" +#define WEBCREDENTIALS_BUS_NAME "com.canonical.indicators.webcredentials" +#define WEBCREDENTIALS_INTERFACE WEBCREDENTIALS_BUS_NAME + +G_DEFINE_TYPE (WebcredentialsMgr, webcredentials_mgr, G_TYPE_OBJECT); + +static void +update_disposition (WebcredentialsMgr *self, GVariant *error_status_prop) +{ + gboolean error_status; + + error_status = g_variant_get_boolean (error_status_prop); + dbusmenu_menuitem_property_set (self->menu_item, + DBUSMENU_MENUITEM_PROP_DISPOSITION, + error_status ? + DBUSMENU_MENUITEM_DISPOSITION_ALERT : + DBUSMENU_MENUITEM_DISPOSITION_NORMAL); +} + +static void +on_properties_changed (GDBusProxy *proxy, + GVariant *changed_properties, + GStrv invalidated_properties, + WebcredentialsMgr *self) +{ + if (g_variant_n_children (changed_properties) > 0) { + GVariantIter *iter; + const gchar *key; + GVariant *value; + + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_loop (iter, "{&sv}", &key, &value)) { + if (g_strcmp0 (key, "ErrorStatus") == 0) { + update_disposition (self, value); + } + } + g_variant_iter_free (iter); + } +} + +static void +on_menu_item_activated (DbusmenuMenuitem *menu_item, + guint timestamp, + WebcredentialsMgr *self) +{ + GError *error = NULL; + + if (!g_spawn_command_line_async("gnome-control-center credentials", &error)) + { + g_warning("Unable to show control centre: %s", error->message); + g_error_free(error); + } +} + +static void +webcredentials_mgr_init (WebcredentialsMgr *self) +{ + GError *error = NULL; + GVariant *error_status_prop; + + self->menu_item = dbusmenu_menuitem_new (); + dbusmenu_menuitem_property_set (self->menu_item, + DBUSMENU_MENUITEM_PROP_TYPE, + DBUSMENU_CLIENT_TYPES_DEFAULT); + dbusmenu_menuitem_property_set (self->menu_item, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Web Accounts…")); + g_signal_connect (self->menu_item, + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK (on_menu_item_activated), + self); + + self->proxy = + g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, + G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, + NULL, + WEBCREDENTIALS_BUS_NAME, + WEBCREDENTIALS_OBJECT_PATH, + WEBCREDENTIALS_INTERFACE, + NULL, + &error); + if (G_UNLIKELY (error != NULL)) { + g_warning ("Couldn't create webcredentials proxy: %s", error->message); + g_clear_error (&error); + return; + } + + g_signal_connect (self->proxy, "g-properties-changed", + G_CALLBACK (on_properties_changed), self); + + error_status_prop = + g_dbus_proxy_get_cached_property (self->proxy, "ErrorStatus"); + if (error_status_prop != NULL) { + update_disposition (self, error_status_prop); + g_variant_unref (error_status_prop); + } +} + +static void +webcredentials_mgr_dispose (GObject *object) +{ + WebcredentialsMgr *self = WEBCREDENTIALS_MGR (object); + + if (self->proxy != NULL) { + g_object_unref (self->proxy); + self->proxy = NULL; + } + + if (self->menu_item != NULL) { + g_object_unref (self->menu_item); + self->menu_item = NULL; + } + + G_OBJECT_CLASS (webcredentials_mgr_parent_class)->dispose (object); +} + +static void +webcredentials_mgr_class_init (WebcredentialsMgrClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + object_class->dispose = webcredentials_mgr_dispose; +} + +WebcredentialsMgr *webcredentials_mgr_new () +{ + return g_object_new (WEBCREDENTIALS_TYPE_MGR, NULL); +} + +DbusmenuMenuitem *webcredentials_mgr_get_menu_item (WebcredentialsMgr *self) +{ + g_return_val_if_fail (WEBCREDENTIALS_IS_MGR (self), NULL); + return self->menu_item; +} diff --git a/src/webcredentials-mgr.h b/src/webcredentials-mgr.h new file mode 100644 index 0000000..6c16ea0 --- /dev/null +++ b/src/webcredentials-mgr.h @@ -0,0 +1,50 @@ +/* +Copyright 2012 Canonical Ltd. + +Authors: + Alberto Mardegan + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#ifndef _WEBCREDENTIALS_MGR_H_ +#define _WEBCREDENTIALS_MGR_H_ + +#include +#include + +G_BEGIN_DECLS + +#define WEBCREDENTIALS_TYPE_MGR (webcredentials_mgr_get_type ()) +#define WEBCREDENTIALS_MGR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WEBCREDENTIALS_TYPE_MGR, WebcredentialsMgr)) +#define WEBCREDENTIALS_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WEBCREDENTIALS_TYPE_MGR, WebcredentialsMgrClass)) +#define WEBCREDENTIALS_IS_MGR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WEBCREDENTIALS_TYPE_MGR)) +#define WEBCREDENTIALS_IS_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WEBCREDENTIALS_TYPE_MGR)) +#define WEBCREDENTIALS_MGR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WEBCREDENTIALS_TYPE_MGR, WebcredentialsMgrClass)) + +typedef struct _WebcredentialsMgrClass WebcredentialsMgrClass; +typedef struct _WebcredentialsMgr WebcredentialsMgr; + +struct _WebcredentialsMgrClass +{ + GObjectClass parent_class; +}; + +GType webcredentials_mgr_get_type (void) G_GNUC_CONST; +WebcredentialsMgr *webcredentials_mgr_new (void); + +DbusmenuMenuitem *webcredentials_mgr_get_menu_item (WebcredentialsMgr *self); + +G_END_DECLS + +#endif /* _WEBCREDENTIALS_MGR_H_ */ -- cgit v1.2.3 From 0f662c6404c8feea54028126f3010ac24d48317e Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Tue, 21 Aug 2012 10:31:27 +0300 Subject: Add Online Accounts item to session menu. --- src/session-menu-mgr.c | 19 +++++++++++++++++++ src/session-service.c | 1 - src/webcredentials-mgr.c | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/session-menu-mgr.c b/src/session-menu-mgr.c index 96fc2a0..1a66a44 100644 --- a/src/session-menu-mgr.c +++ b/src/session-menu-mgr.c @@ -33,6 +33,7 @@ with this program. If not, see . #include "session-menu-mgr.h" #include "shared-names.h" #include "users-service-dbus.h" +#include "webcredentials-mgr.h" #define DEBUG_SHOW_ALL FALSE @@ -88,6 +89,8 @@ struct _SessionMenuMgr DbusmenuMenuitem * lock_mi; DbusmenuMenuitem * lock_switch_mi; DbusmenuMenuitem * guest_mi; + DbusmenuMenuitem * online_accounts_mi; + DbusmenuMenuitem * online_accounts_separator; DbusmenuMenuitem * logout_mi; DbusmenuMenuitem * suspend_mi; DbusmenuMenuitem * hibernate_mi; @@ -113,6 +116,7 @@ struct _SessionMenuMgr DBusUPower * upower_proxy; SessionDbus * session_dbus; UsersServiceDbus * users_dbus_facade; + WebcredentialsMgr * webcredentials_mgr; }; static SwitcherMode get_switcher_mode (SessionMenuMgr *); @@ -192,6 +196,9 @@ session_menu_mgr_init (SessionMenuMgr *mgr) G_CALLBACK(on_guest_logged_in_changed), mgr); init_upower_proxy (mgr); + + /* Online accounts menu item */ + mgr->webcredentials_mgr = webcredentials_mgr_new (); } static void @@ -212,6 +219,7 @@ session_menu_mgr_dispose (GObject *object) g_clear_object (&mgr->users_dbus_facade); g_clear_object (&mgr->top_mi); g_clear_object (&mgr->session_dbus); + g_clear_object (&mgr->webcredentials_mgr); g_slist_free (mgr->user_menuitems); mgr->user_menuitems = NULL; @@ -412,6 +420,10 @@ update_session_menuitems (SessionMenuMgr * mgr) gboolean v; GSettings * s = mgr->indicator_settings; + v = !mgr->greeter_mode; + mi_set_visible (mgr->online_accounts_mi, v); + mi_set_visible (mgr->online_accounts_separator, v); + v = !mgr->greeter_mode && !is_this_live_session() && !g_settings_get_boolean (mgr->lockdown_settings, "disable-log-out") @@ -463,6 +475,13 @@ build_session_menuitems (SessionMenuMgr* mgr) { DbusmenuMenuitem * mi; + mi = mgr->online_accounts_mi = + webcredentials_mgr_get_menu_item (mgr->webcredentials_mgr); + dbusmenu_menuitem_child_append (mgr->top_mi, mi); + + mi = mgr->online_accounts_separator = mi_new_separator (); + dbusmenu_menuitem_child_append (mgr->top_mi, mi); + mi = mgr->logout_mi = mi_new (_("Log Out\342\200\246")); dbusmenu_menuitem_child_append (mgr->top_mi, mi); g_signal_connect_swapped (mi, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, diff --git a/src/session-service.c b/src/session-service.c index 6d5a7f3..91bbccd 100644 --- a/src/session-service.c +++ b/src/session-service.c @@ -26,7 +26,6 @@ with this program. If not, see . #include "config.h" -#include #include #include diff --git a/src/webcredentials-mgr.c b/src/webcredentials-mgr.c index 8b44a95..17c3e46 100644 --- a/src/webcredentials-mgr.c +++ b/src/webcredentials-mgr.c @@ -97,7 +97,7 @@ webcredentials_mgr_init (WebcredentialsMgr *self) DBUSMENU_CLIENT_TYPES_DEFAULT); dbusmenu_menuitem_property_set (self->menu_item, DBUSMENU_MENUITEM_PROP_LABEL, - _("Web Accounts…")); + _("Online Accounts\342\200\246")); g_signal_connect (self->menu_item, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (on_menu_item_activated), -- cgit v1.2.3 From 8ebef3969c9b69dc0fe24cd2ad33530a2e0b0e4c Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Tue, 21 Aug 2012 10:38:09 +0300 Subject: Class rename Rename the class from Webcredentials to OnlineAccounts, for improved consistency. --- src/Makefile.am | 4 +- src/online-accounts-mgr.c | 166 ++++++++++++++++++++++++++++++++++++++++++++++ src/online-accounts-mgr.h | 50 ++++++++++++++ src/session-menu-mgr.c | 10 +-- src/webcredentials-mgr.c | 166 ---------------------------------------------- src/webcredentials-mgr.h | 50 -------------- 6 files changed, 223 insertions(+), 223 deletions(-) create mode 100644 src/online-accounts-mgr.c create mode 100644 src/online-accounts-mgr.h delete mode 100644 src/webcredentials-mgr.c delete mode 100644 src/webcredentials-mgr.h (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index b28ca4a..cd82812 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -134,8 +134,8 @@ indicator_session_service_SOURCES = \ users-service-dbus.c \ session-menu-mgr.h \ session-menu-mgr.c \ - webcredentials-mgr.c \ - webcredentials-mgr.h + online-accounts-mgr.c \ + online-accounts-mgr.h indicator_session_service_CFLAGS = \ $(SESSIONSERVICE_CFLAGS) \ diff --git a/src/online-accounts-mgr.c b/src/online-accounts-mgr.c new file mode 100644 index 0000000..ccdea39 --- /dev/null +++ b/src/online-accounts-mgr.c @@ -0,0 +1,166 @@ +/* +Copyright 2012 Canonical Ltd. + +Authors: + Alberto Mardegan + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#include +#include + +#include "online_accounts-mgr.h" + +#include + +struct _OnlineAccountsMgr +{ + GObject parent_instance; + GDBusProxy *proxy; + DbusmenuMenuitem *menu_item; +}; + +#define ONLINE_ACCOUNTS_OBJECT_PATH "/com/canonical/indicators/webcredentials" +#define ONLINE_ACCOUNTS_BUS_NAME "com.canonical.indicators.webcredentials" +#define ONLINE_ACCOUNTS_INTERFACE ONLINE_ACCOUNTS_BUS_NAME + +G_DEFINE_TYPE (OnlineAccountsMgr, online_accounts_mgr, G_TYPE_OBJECT); + +static void +update_disposition (OnlineAccountsMgr *self, GVariant *error_status_prop) +{ + gboolean error_status; + + error_status = g_variant_get_boolean (error_status_prop); + dbusmenu_menuitem_property_set (self->menu_item, + DBUSMENU_MENUITEM_PROP_DISPOSITION, + error_status ? + DBUSMENU_MENUITEM_DISPOSITION_ALERT : + DBUSMENU_MENUITEM_DISPOSITION_NORMAL); +} + +static void +on_properties_changed (GDBusProxy *proxy, + GVariant *changed_properties, + GStrv invalidated_properties, + OnlineAccountsMgr *self) +{ + if (g_variant_n_children (changed_properties) > 0) { + GVariantIter *iter; + const gchar *key; + GVariant *value; + + g_variant_get (changed_properties, "a{sv}", &iter); + while (g_variant_iter_loop (iter, "{&sv}", &key, &value)) { + if (g_strcmp0 (key, "ErrorStatus") == 0) { + update_disposition (self, value); + } + } + g_variant_iter_free (iter); + } +} + +static void +on_menu_item_activated (DbusmenuMenuitem *menu_item, + guint timestamp, + OnlineAccountsMgr *self) +{ + GError *error = NULL; + + if (!g_spawn_command_line_async("gnome-control-center credentials", &error)) + { + g_warning("Unable to show control center: %s", error->message); + g_error_free(error); + } +} + +static void +online_accounts_mgr_init (OnlineAccountsMgr *self) +{ + GError *error = NULL; + GVariant *error_status_prop; + + self->menu_item = dbusmenu_menuitem_new (); + dbusmenu_menuitem_property_set (self->menu_item, + DBUSMENU_MENUITEM_PROP_TYPE, + DBUSMENU_CLIENT_TYPES_DEFAULT); + dbusmenu_menuitem_property_set (self->menu_item, + DBUSMENU_MENUITEM_PROP_LABEL, + _("Online Accounts\342\200\246")); + g_signal_connect (self->menu_item, + DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, + G_CALLBACK (on_menu_item_activated), + self); + + self->proxy = + g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, + G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, + NULL, + ONLINE_ACCOUNTS_BUS_NAME, + ONLINE_ACCOUNTS_OBJECT_PATH, + ONLINE_ACCOUNTS_INTERFACE, + NULL, + &error); + if (G_UNLIKELY (error != NULL)) { + g_warning ("Couldn't create online_accounts proxy: %s", error->message); + g_clear_error (&error); + return; + } + + g_signal_connect (self->proxy, "g-properties-changed", + G_CALLBACK (on_properties_changed), self); + + error_status_prop = + g_dbus_proxy_get_cached_property (self->proxy, "ErrorStatus"); + if (error_status_prop != NULL) { + update_disposition (self, error_status_prop); + g_variant_unref (error_status_prop); + } +} + +static void +online_accounts_mgr_dispose (GObject *object) +{ + OnlineAccountsMgr *self = ONLINE_ACCOUNTS_MGR (object); + + if (self->proxy != NULL) { + g_object_unref (self->proxy); + self->proxy = NULL; + } + + if (self->menu_item != NULL) { + g_object_unref (self->menu_item); + self->menu_item = NULL; + } + + G_OBJECT_CLASS (online_accounts_mgr_parent_class)->dispose (object); +} + +static void +online_accounts_mgr_class_init (OnlineAccountsMgrClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + object_class->dispose = online_accounts_mgr_dispose; +} + +OnlineAccountsMgr *online_accounts_mgr_new () +{ + return g_object_new (ONLINE_ACCOUNTS_TYPE_MGR, NULL); +} + +DbusmenuMenuitem *online_accounts_mgr_get_menu_item (OnlineAccountsMgr *self) +{ + g_return_val_if_fail (ONLINE_ACCOUNTS_IS_MGR (self), NULL); + return self->menu_item; +} diff --git a/src/online-accounts-mgr.h b/src/online-accounts-mgr.h new file mode 100644 index 0000000..16c0461 --- /dev/null +++ b/src/online-accounts-mgr.h @@ -0,0 +1,50 @@ +/* +Copyright 2012 Canonical Ltd. + +Authors: + Alberto Mardegan + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#ifndef _ONLINE_ACCOUNTS_MGR_H_ +#define _ONLINE_ACCOUNTS_MGR_H_ + +#include +#include + +G_BEGIN_DECLS + +#define ONLINE_ACCOUNTS_TYPE_MGR (online_accounts_mgr_get_type ()) +#define ONLINE_ACCOUNTS_MGR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ONLINE_ACCOUNTS_TYPE_MGR, OnlineAccountsMgr)) +#define ONLINE_ACCOUNTS_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ONLINE_ACCOUNTS_TYPE_MGR, OnlineAccountsMgrClass)) +#define ONLINE_ACCOUNTS_IS_MGR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ONLINE_ACCOUNTS_TYPE_MGR)) +#define ONLINE_ACCOUNTS_IS_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ONLINE_ACCOUNTS_TYPE_MGR)) +#define ONLINE_ACCOUNTS_MGR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ONLINE_ACCOUNTS_TYPE_MGR, OnlineAccountsMgrClass)) + +typedef struct _OnlineAccountsMgrClass OnlineAccountsMgrClass; +typedef struct _OnlineAccountsMgr OnlineAccountsMgr; + +struct _OnlineAccountsMgrClass +{ + GObjectClass parent_class; +}; + +GType online_accounts_mgr_get_type (void) G_GNUC_CONST; +OnlineAccountsMgr *online_accounts_mgr_new (void); + +DbusmenuMenuitem *online_accounts_mgr_get_menu_item (OnlineAccountsMgr *self); + +G_END_DECLS + +#endif /* _ONLINE_ACCOUNTS_MGR_H_ */ diff --git a/src/session-menu-mgr.c b/src/session-menu-mgr.c index 1a66a44..72a4735 100644 --- a/src/session-menu-mgr.c +++ b/src/session-menu-mgr.c @@ -33,7 +33,7 @@ with this program. If not, see . #include "session-menu-mgr.h" #include "shared-names.h" #include "users-service-dbus.h" -#include "webcredentials-mgr.h" +#include "online_accounts-mgr.h" #define DEBUG_SHOW_ALL FALSE @@ -116,7 +116,7 @@ struct _SessionMenuMgr DBusUPower * upower_proxy; SessionDbus * session_dbus; UsersServiceDbus * users_dbus_facade; - WebcredentialsMgr * webcredentials_mgr; + OnlineAccountsMgr * online_accounts_mgr; }; static SwitcherMode get_switcher_mode (SessionMenuMgr *); @@ -198,7 +198,7 @@ session_menu_mgr_init (SessionMenuMgr *mgr) init_upower_proxy (mgr); /* Online accounts menu item */ - mgr->webcredentials_mgr = webcredentials_mgr_new (); + mgr->online_accounts_mgr = online_accounts_mgr_new (); } static void @@ -219,7 +219,7 @@ session_menu_mgr_dispose (GObject *object) g_clear_object (&mgr->users_dbus_facade); g_clear_object (&mgr->top_mi); g_clear_object (&mgr->session_dbus); - g_clear_object (&mgr->webcredentials_mgr); + g_clear_object (&mgr->online_accounts_mgr); g_slist_free (mgr->user_menuitems); mgr->user_menuitems = NULL; @@ -476,7 +476,7 @@ build_session_menuitems (SessionMenuMgr* mgr) DbusmenuMenuitem * mi; mi = mgr->online_accounts_mi = - webcredentials_mgr_get_menu_item (mgr->webcredentials_mgr); + online_accounts_mgr_get_menu_item (mgr->online_accounts_mgr); dbusmenu_menuitem_child_append (mgr->top_mi, mi); mi = mgr->online_accounts_separator = mi_new_separator (); diff --git a/src/webcredentials-mgr.c b/src/webcredentials-mgr.c deleted file mode 100644 index 17c3e46..0000000 --- a/src/webcredentials-mgr.c +++ /dev/null @@ -1,166 +0,0 @@ -/* -Copyright 2012 Canonical Ltd. - -Authors: - Alberto Mardegan - -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published -by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program. If not, see . -*/ - -#include -#include - -#include "webcredentials-mgr.h" - -#include - -struct _WebcredentialsMgr -{ - GObject parent_instance; - GDBusProxy *proxy; - DbusmenuMenuitem *menu_item; -}; - -#define WEBCREDENTIALS_OBJECT_PATH "/com/canonical/indicators/webcredentials" -#define WEBCREDENTIALS_BUS_NAME "com.canonical.indicators.webcredentials" -#define WEBCREDENTIALS_INTERFACE WEBCREDENTIALS_BUS_NAME - -G_DEFINE_TYPE (WebcredentialsMgr, webcredentials_mgr, G_TYPE_OBJECT); - -static void -update_disposition (WebcredentialsMgr *self, GVariant *error_status_prop) -{ - gboolean error_status; - - error_status = g_variant_get_boolean (error_status_prop); - dbusmenu_menuitem_property_set (self->menu_item, - DBUSMENU_MENUITEM_PROP_DISPOSITION, - error_status ? - DBUSMENU_MENUITEM_DISPOSITION_ALERT : - DBUSMENU_MENUITEM_DISPOSITION_NORMAL); -} - -static void -on_properties_changed (GDBusProxy *proxy, - GVariant *changed_properties, - GStrv invalidated_properties, - WebcredentialsMgr *self) -{ - if (g_variant_n_children (changed_properties) > 0) { - GVariantIter *iter; - const gchar *key; - GVariant *value; - - g_variant_get (changed_properties, "a{sv}", &iter); - while (g_variant_iter_loop (iter, "{&sv}", &key, &value)) { - if (g_strcmp0 (key, "ErrorStatus") == 0) { - update_disposition (self, value); - } - } - g_variant_iter_free (iter); - } -} - -static void -on_menu_item_activated (DbusmenuMenuitem *menu_item, - guint timestamp, - WebcredentialsMgr *self) -{ - GError *error = NULL; - - if (!g_spawn_command_line_async("gnome-control-center credentials", &error)) - { - g_warning("Unable to show control centre: %s", error->message); - g_error_free(error); - } -} - -static void -webcredentials_mgr_init (WebcredentialsMgr *self) -{ - GError *error = NULL; - GVariant *error_status_prop; - - self->menu_item = dbusmenu_menuitem_new (); - dbusmenu_menuitem_property_set (self->menu_item, - DBUSMENU_MENUITEM_PROP_TYPE, - DBUSMENU_CLIENT_TYPES_DEFAULT); - dbusmenu_menuitem_property_set (self->menu_item, - DBUSMENU_MENUITEM_PROP_LABEL, - _("Online Accounts\342\200\246")); - g_signal_connect (self->menu_item, - DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, - G_CALLBACK (on_menu_item_activated), - self); - - self->proxy = - g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, - G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, - NULL, - WEBCREDENTIALS_BUS_NAME, - WEBCREDENTIALS_OBJECT_PATH, - WEBCREDENTIALS_INTERFACE, - NULL, - &error); - if (G_UNLIKELY (error != NULL)) { - g_warning ("Couldn't create webcredentials proxy: %s", error->message); - g_clear_error (&error); - return; - } - - g_signal_connect (self->proxy, "g-properties-changed", - G_CALLBACK (on_properties_changed), self); - - error_status_prop = - g_dbus_proxy_get_cached_property (self->proxy, "ErrorStatus"); - if (error_status_prop != NULL) { - update_disposition (self, error_status_prop); - g_variant_unref (error_status_prop); - } -} - -static void -webcredentials_mgr_dispose (GObject *object) -{ - WebcredentialsMgr *self = WEBCREDENTIALS_MGR (object); - - if (self->proxy != NULL) { - g_object_unref (self->proxy); - self->proxy = NULL; - } - - if (self->menu_item != NULL) { - g_object_unref (self->menu_item); - self->menu_item = NULL; - } - - G_OBJECT_CLASS (webcredentials_mgr_parent_class)->dispose (object); -} - -static void -webcredentials_mgr_class_init (WebcredentialsMgrClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - object_class->dispose = webcredentials_mgr_dispose; -} - -WebcredentialsMgr *webcredentials_mgr_new () -{ - return g_object_new (WEBCREDENTIALS_TYPE_MGR, NULL); -} - -DbusmenuMenuitem *webcredentials_mgr_get_menu_item (WebcredentialsMgr *self) -{ - g_return_val_if_fail (WEBCREDENTIALS_IS_MGR (self), NULL); - return self->menu_item; -} diff --git a/src/webcredentials-mgr.h b/src/webcredentials-mgr.h deleted file mode 100644 index 6c16ea0..0000000 --- a/src/webcredentials-mgr.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -Copyright 2012 Canonical Ltd. - -Authors: - Alberto Mardegan - -This program is free software: you can redistribute it and/or modify it -under the terms of the GNU General Public License version 3, as published -by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranties of -MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program. If not, see . -*/ - -#ifndef _WEBCREDENTIALS_MGR_H_ -#define _WEBCREDENTIALS_MGR_H_ - -#include -#include - -G_BEGIN_DECLS - -#define WEBCREDENTIALS_TYPE_MGR (webcredentials_mgr_get_type ()) -#define WEBCREDENTIALS_MGR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WEBCREDENTIALS_TYPE_MGR, WebcredentialsMgr)) -#define WEBCREDENTIALS_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WEBCREDENTIALS_TYPE_MGR, WebcredentialsMgrClass)) -#define WEBCREDENTIALS_IS_MGR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WEBCREDENTIALS_TYPE_MGR)) -#define WEBCREDENTIALS_IS_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WEBCREDENTIALS_TYPE_MGR)) -#define WEBCREDENTIALS_MGR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WEBCREDENTIALS_TYPE_MGR, WebcredentialsMgrClass)) - -typedef struct _WebcredentialsMgrClass WebcredentialsMgrClass; -typedef struct _WebcredentialsMgr WebcredentialsMgr; - -struct _WebcredentialsMgrClass -{ - GObjectClass parent_class; -}; - -GType webcredentials_mgr_get_type (void) G_GNUC_CONST; -WebcredentialsMgr *webcredentials_mgr_new (void); - -DbusmenuMenuitem *webcredentials_mgr_get_menu_item (WebcredentialsMgr *self); - -G_END_DECLS - -#endif /* _WEBCREDENTIALS_MGR_H_ */ -- cgit v1.2.3 From ff3294e7afb6a92d72608bd311533807a77a7857 Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Tue, 21 Aug 2012 11:21:08 +0300 Subject: Fix build --- src/online-accounts-mgr.c | 2 +- src/session-menu-mgr.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/online-accounts-mgr.c b/src/online-accounts-mgr.c index ccdea39..4abba00 100644 --- a/src/online-accounts-mgr.c +++ b/src/online-accounts-mgr.c @@ -20,7 +20,7 @@ with this program. If not, see . #include #include -#include "online_accounts-mgr.h" +#include "online-accounts-mgr.h" #include diff --git a/src/session-menu-mgr.c b/src/session-menu-mgr.c index 72a4735..8f42871 100644 --- a/src/session-menu-mgr.c +++ b/src/session-menu-mgr.c @@ -33,7 +33,7 @@ with this program. If not, see . #include "session-menu-mgr.h" #include "shared-names.h" #include "users-service-dbus.h" -#include "online_accounts-mgr.h" +#include "online-accounts-mgr.h" #define DEBUG_SHOW_ALL FALSE -- cgit v1.2.3 From 51a9de1eef7f64636d7eee6959a786616cc8c56b Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 22 Aug 2012 12:42:11 -0500 Subject: in gtk-logout-helper's 'switch off' dialog, don't show a 'restart' button anymore --- src/dialog.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src') diff --git a/src/dialog.c b/src/dialog.c index c46ac80..7c562d5 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -227,12 +227,6 @@ logout_dialog_new (LogoutDialogType type) NULL); } - if (type == LOGOUT_DIALOG_TYPE_SHUTDOWN) { - const gchar * restart_text; - restart_text = g_dpgettext2 (NULL, "button", button_strings[LOGOUT_DIALOG_TYPE_RESTART]); - gtk_dialog_add_button (GTK_DIALOG(dialog), restart_text, GTK_RESPONSE_HELP); - } - gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); /* The following is a workaround to fix an issue in GtkMessageDialog -- cgit v1.2.3 From 0a7f9ed274047c0228a5a5f9e053308e755bf89d Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Thu, 23 Aug 2012 15:05:00 +0300 Subject: Show Online Accounts only when needed --- src/session-menu-mgr.c | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/session-menu-mgr.c b/src/session-menu-mgr.c index 8f42871..643abd1 100644 --- a/src/session-menu-mgr.c +++ b/src/session-menu-mgr.c @@ -90,7 +90,6 @@ struct _SessionMenuMgr DbusmenuMenuitem * lock_switch_mi; DbusmenuMenuitem * guest_mi; DbusmenuMenuitem * online_accounts_mi; - DbusmenuMenuitem * online_accounts_separator; DbusmenuMenuitem * logout_mi; DbusmenuMenuitem * suspend_mi; DbusmenuMenuitem * hibernate_mi; @@ -370,6 +369,29 @@ mi_new (const char * label) return mi; } +static void +check_online_accounts_status (SessionMenuMgr * mgr, DbusmenuMenuitem * mi) +{ + const gchar *disposition; + gboolean on_alert; + + disposition = + dbusmenu_menuitem_property_get (mi, DBUSMENU_MENUITEM_PROP_DISPOSITION); + on_alert = g_strcmp0 (disposition, DBUSMENU_MENUITEM_DISPOSITION_ALERT) == 0; + + mi_set_visible (mi, on_alert); +} + +static void +on_online_accounts_changed (SessionMenuMgr * mgr, const gchar * property, + GVariant *value, DbusmenuMenuitem *mi) +{ + if (g_strcmp0 (property, DBUSMENU_MENUITEM_PROP_DISPOSITION) == 0) + { + check_online_accounts_status(mgr, mi); + } +} + /*** **** Admin Menuitems **** @@ -404,6 +426,14 @@ build_admin_menuitems (SessionMenuMgr * mgr) G_CALLBACK(action_func_spawn_async), CMD_SYSTEM_SETTINGS); + mi = mgr->online_accounts_mi = + online_accounts_mgr_get_menu_item (mgr->online_accounts_mgr); + dbusmenu_menuitem_child_append (mgr->top_mi, mi); + g_signal_connect_swapped (mi, DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, + G_CALLBACK(on_online_accounts_changed), + mgr); + check_online_accounts_status (mgr, mi); + mi = mi_new_separator (); dbusmenu_menuitem_child_append (mgr->top_mi, mi); } @@ -420,10 +450,6 @@ update_session_menuitems (SessionMenuMgr * mgr) gboolean v; GSettings * s = mgr->indicator_settings; - v = !mgr->greeter_mode; - mi_set_visible (mgr->online_accounts_mi, v); - mi_set_visible (mgr->online_accounts_separator, v); - v = !mgr->greeter_mode && !is_this_live_session() && !g_settings_get_boolean (mgr->lockdown_settings, "disable-log-out") @@ -475,13 +501,6 @@ build_session_menuitems (SessionMenuMgr* mgr) { DbusmenuMenuitem * mi; - mi = mgr->online_accounts_mi = - online_accounts_mgr_get_menu_item (mgr->online_accounts_mgr); - dbusmenu_menuitem_child_append (mgr->top_mi, mi); - - mi = mgr->online_accounts_separator = mi_new_separator (); - dbusmenu_menuitem_child_append (mgr->top_mi, mi); - mi = mgr->logout_mi = mi_new (_("Log Out\342\200\246")); dbusmenu_menuitem_child_append (mgr->top_mi, mi); g_signal_connect_swapped (mi, DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, -- cgit v1.2.3 From 3bcd1a92caefa661b4f0451bd91d66867e09a7c5 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 30 Aug 2012 20:33:11 -0500 Subject: add a disposition handler to indicator-session --- src/indicator-session.c | 150 ++++++++++++++++++++++++++++++++++++++++++------ src/shared-names.h | 4 +- 2 files changed, 137 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/indicator-session.c b/src/indicator-session.c index 3038948..d22cd33 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -63,6 +63,7 @@ struct _IndicatorSession GCancellable * service_proxy_cancel; GDBusProxy * service_proxy; GSettings * settings; + DbusmenuClient * menu_client; }; static gboolean greeter_mode; @@ -82,6 +83,8 @@ static gboolean build_restart_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); +static void on_menu_layout_updated (DbusmenuClient * client, IndicatorSession * session); +static void indicator_session_update_icon (IndicatorSession * self); static void indicator_session_update_users_label (IndicatorSession* self, const gchar* name); static void service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data); @@ -116,8 +119,6 @@ indicator_session_class_init (IndicatorSessionClass *klass) static void indicator_session_init (IndicatorSession *self) { - const gchar * icon_name; - self->settings = g_settings_new ("com.canonical.indicator.session"); /* Now let's fire these guys up. */ @@ -130,12 +131,11 @@ indicator_session_init (IndicatorSession *self) greeter_mode = !g_strcmp0(g_getenv("INDICATOR_GREETER_MODE"), "1"); self->entry.name_hint = PACKAGE; - self->entry.accessible_desc = _("Session Menu"); self->entry.label = GTK_LABEL (gtk_label_new ("User Name")); - icon_name = greeter_mode ? GREETER_ICON_DEFAULT : ICON_DEFAULT; - self->entry.image = GTK_IMAGE (gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON)); + self->entry.image = GTK_IMAGE (gtk_image_new()); self->entry.menu = GTK_MENU (dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT)); + indicator_session_update_icon (self); g_settings_bind (self->settings, "show-real-name-on-panel", self->entry.label, "visible", G_SETTINGS_BIND_GET); @@ -146,14 +146,17 @@ indicator_session_init (IndicatorSession *self) g_object_ref_sink (self->entry.image); // set up the handlers - DbusmenuClient * menu_client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(DBUSMENU_GTKMENU(self->entry.menu))); - dbusmenu_client_add_type_handler (menu_client, + self->menu_client = DBUSMENU_CLIENT(dbusmenu_gtkmenu_get_client(DBUSMENU_GTKMENU(self->entry.menu))); + g_signal_connect (self->menu_client, "layout-updated", + G_CALLBACK(on_menu_layout_updated), self); + + dbusmenu_client_add_type_handler (self->menu_client, USER_ITEM_TYPE, new_user_item); - dbusmenu_client_add_type_handler (menu_client, + dbusmenu_client_add_type_handler (self->menu_client, RESTART_ITEM_TYPE, build_restart_item); - dbusmenu_gtkclient_set_accel_group (DBUSMENU_GTKCLIENT(menu_client), + dbusmenu_gtkclient_set_accel_group (DBUSMENU_GTKCLIENT(self->menu_client), gtk_accel_group_new()); } @@ -339,13 +342,6 @@ receive_signal (GDBusProxy * proxy, g_variant_get (parameters, "(&s)", &username); indicator_session_update_users_label (self, username); } - else if (!g_strcmp0(signal_name, "RestartRequired")) - { - const gchar * icon_name = greeter_mode ? GREETER_ICON_RESTART : ICON_RESTART; - gtk_image_set_from_icon_name (GTK_IMAGE(self->entry.image), icon_name, GTK_ICON_SIZE_MENU); - self->entry.accessible_desc = _("Device Menu (reboot required)"); - g_signal_emit (G_OBJECT(self), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE_ID, 0, &self->entry); - } } @@ -412,3 +408,125 @@ indicator_session_update_users_label (IndicatorSession * self, { gtk_label_set_text (self->entry.label, name ? name : ""); } + +/*** +**** Disposition +***/ + +enum +{ + DISPOSITION_NORMAL, + DISPOSITION_INFO, + DISPOSITION_WARNING, + DISPOSITION_ALERT +}; + +static void +indicator_session_update_from_disposition (IndicatorSession * indicator, + int disposition) +{ + const gchar * icon; + const gchar * a11y; + + if (disposition == DISPOSITION_NORMAL) + a11y = _("Session Menu"); + else + a11y = _("Session Menu (attention required)"); + + if (greeter_mode) + { + if (disposition == DISPOSITION_NORMAL) + icon = GREETER_ICON_DEFAULT; + else + icon = GREETER_ICON_RESTART; + } + else + { + if (disposition == DISPOSITION_NORMAL) + icon = ICON_DEFAULT; + else if (disposition == DISPOSITION_INFO) + icon = ICON_INFO; + else + icon = ICON_ALERT; + } + + g_debug (G_STRLOC" setting icon to \"%s\", a11y to \"%s\"", icon, a11y); + gtk_image_set_from_icon_name (GTK_IMAGE(indicator->entry.image), + icon, + GTK_ICON_SIZE_BUTTON); + indicator->entry.accessible_desc = a11y; + g_signal_emit (indicator, + INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE_ID, + 0, + &indicator->entry); +} + +static int +calculate_disposition (IndicatorSession * indicator) +{ + GList * l; + DbusmenuMenuitem * root = dbusmenu_client_get_root (indicator->menu_client); + GList * children = dbusmenu_menuitem_get_children (root); + int ret = DISPOSITION_NORMAL; + + for (l=children; l!=NULL; l=l->next) + { + int val; + const gchar * key = DBUSMENU_MENUITEM_PROP_DISPOSITION; + const gchar * val_str = dbusmenu_menuitem_property_get (l->data, key); + + if (!g_strcmp0 (val_str, DBUSMENU_MENUITEM_DISPOSITION_ALERT)) + val = DISPOSITION_ALERT; + else if (!g_strcmp0 (val_str, DBUSMENU_MENUITEM_DISPOSITION_WARNING)) + val = DISPOSITION_WARNING; + else if (!g_strcmp0 (val_str, DBUSMENU_MENUITEM_DISPOSITION_INFORMATIVE)) + val = DISPOSITION_INFO; + else + val = DISPOSITION_NORMAL; + + if (ret < val) + ret = val; + } + + return ret; +} + +static void +indicator_session_update_icon (IndicatorSession * indicator) +{ + const int disposition = calculate_disposition (indicator); + indicator_session_update_from_disposition (indicator, disposition); +} + +static void +on_menuitem_property_changed (DbusmenuMenuitem * mi, + gchar * property, + GValue * value, + gpointer indicator) +{ + if (!g_strcmp0 (property, DBUSMENU_MENUITEM_PROP_DISPOSITION)) + indicator_session_update_icon (indicator); +} + +static void +on_menu_layout_updated (DbusmenuClient * client, IndicatorSession * session) +{ + GList * l; + DbusmenuMenuitem * root = dbusmenu_client_get_root (client); + GList * children = dbusmenu_menuitem_get_children (root); + static GQuark tag = 0; + + if (G_UNLIKELY (tag == 0)) + { + tag = g_quark_from_static_string ("x-tagged-by-indicator-session"); + } + + for (l=children; l!=NULL; l=l->next) + { + if (g_object_get_qdata (l->data, tag) == NULL) + { + g_object_set_qdata (l->data, tag, GINT_TO_POINTER(1)); + g_signal_connect (l->data, "property-changed", G_CALLBACK(on_menuitem_property_changed), session); + } + } +} diff --git a/src/shared-names.h b/src/shared-names.h index dcda182..e82aef8 100644 --- a/src/shared-names.h +++ b/src/shared-names.h @@ -41,7 +41,9 @@ with this program. If not, see . #define RESTART_ITEM_ICON "restart-icon" #define ICON_DEFAULT "system-devices-panel" -#define ICON_RESTART "system-devices-panel-alert" +#define ICON_INFO "system-devices-panel-information" +#define ICON_ALERT "system-devices-panel-alert" + #define GREETER_ICON_DEFAULT "system-shutdown-panel" #define GREETER_ICON_RESTART "system-shutdown-panel-restart" -- cgit v1.2.3 From 64cf80553784cdee851cf7112fdc468ab46a61be Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 31 Aug 2012 07:16:03 -0500 Subject: have the a11y text follow the SystemMenu spec --- src/indicator-session.c | 62 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/indicator-session.c b/src/indicator-session.c index d22cd33..72e3a0b 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -84,7 +84,7 @@ static gboolean build_restart_item (DbusmenuMenuitem * newitem, DbusmenuClient * client, gpointer user_data); static void on_menu_layout_updated (DbusmenuClient * client, IndicatorSession * session); -static void indicator_session_update_icon (IndicatorSession * self); +static void indicator_session_update_icon_and_a11y (IndicatorSession * self); static void indicator_session_update_users_label (IndicatorSession* self, const gchar* name); static void service_connection_cb (IndicatorServiceManager * sm, gboolean connected, gpointer user_data); @@ -135,11 +135,17 @@ indicator_session_init (IndicatorSession *self) self->entry.image = GTK_IMAGE (gtk_image_new()); self->entry.menu = GTK_MENU (dbusmenu_gtkmenu_new(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT)); - indicator_session_update_icon (self); + indicator_session_update_icon_and_a11y (self); g_settings_bind (self->settings, "show-real-name-on-panel", self->entry.label, "visible", G_SETTINGS_BIND_GET); + /* show-real-name-on-panel affects the a11y string */ + g_signal_connect_swapped (self->settings, + "notify::show-real-name-on-panel", + G_CALLBACK(indicator_session_update_icon_and_a11y), + self); + gtk_widget_show (GTK_WIDGET(self->entry.menu)); gtk_widget_show (GTK_WIDGET(self->entry.image)); g_object_ref_sink (self->entry.menu); @@ -422,16 +428,36 @@ enum }; static void -indicator_session_update_from_disposition (IndicatorSession * indicator, - int disposition) +indicator_session_update_a11y_from_disposition (IndicatorSession * indicator, + int disposition) { - const gchar * icon; - const gchar * a11y; + GString * a11y = g_string_new (_("System")); - if (disposition == DISPOSITION_NORMAL) - a11y = _("Session Menu"); - else - a11y = _("Session Menu (attention required)"); + if (g_settings_get_boolean (indicator->settings, "show-real-name-on-panel")) + { + const gchar * username = gtk_label_get_text (indicator->entry.label); + g_string_append_printf (a11y, " %s", username); + } + + if (disposition != DISPOSITION_NORMAL) + { + g_string_append (a11y, _(" (Attention Required)")); + } + + g_debug (G_STRLOC" setting a11y to \"%s\"", a11y->str); + g_clear_pointer (&indicator->entry.accessible_desc, g_free); + indicator->entry.accessible_desc = g_string_free (a11y, FALSE); + g_signal_emit (indicator, + INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE_ID, + 0, + &indicator->entry); +} + +static void +indicator_session_update_icon_from_disposition (IndicatorSession * indicator, + int disposition) +{ + const gchar * icon; if (greeter_mode) { @@ -450,17 +476,12 @@ indicator_session_update_from_disposition (IndicatorSession * indicator, icon = ICON_ALERT; } - g_debug (G_STRLOC" setting icon to \"%s\", a11y to \"%s\"", icon, a11y); + g_debug (G_STRLOC" setting icon to \"%s\"", icon); gtk_image_set_from_icon_name (GTK_IMAGE(indicator->entry.image), icon, GTK_ICON_SIZE_BUTTON); - indicator->entry.accessible_desc = a11y; - g_signal_emit (indicator, - INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE_ID, - 0, - &indicator->entry); } - + static int calculate_disposition (IndicatorSession * indicator) { @@ -492,10 +513,11 @@ calculate_disposition (IndicatorSession * indicator) } static void -indicator_session_update_icon (IndicatorSession * indicator) +indicator_session_update_icon_and_a11y (IndicatorSession * indicator) { const int disposition = calculate_disposition (indicator); - indicator_session_update_from_disposition (indicator, disposition); + indicator_session_update_a11y_from_disposition (indicator, disposition); + indicator_session_update_icon_from_disposition (indicator, disposition); } static void @@ -505,7 +527,7 @@ on_menuitem_property_changed (DbusmenuMenuitem * mi, gpointer indicator) { if (!g_strcmp0 (property, DBUSMENU_MENUITEM_PROP_DISPOSITION)) - indicator_session_update_icon (indicator); + indicator_session_update_icon_and_a11y (indicator); } static void -- cgit v1.2.3 From ed7d1fd6fd9d035156a15e8b0ed695de5e8e3f60 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 31 Aug 2012 11:28:21 -0500 Subject: revise indicator_session_update_a11y_from_disposition() to be easier to internationalize --- src/indicator-session.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/indicator-session.c b/src/indicator-session.c index 72e3a0b..ec95328 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -431,22 +431,22 @@ static void indicator_session_update_a11y_from_disposition (IndicatorSession * indicator, int disposition) { - GString * a11y = g_string_new (_("System")); - - if (g_settings_get_boolean (indicator->settings, "show-real-name-on-panel")) - { - const gchar * username = gtk_label_get_text (indicator->entry.label); - g_string_append_printf (a11y, " %s", username); - } - - if (disposition != DISPOSITION_NORMAL) - { - g_string_append (a11y, _(" (Attention Required)")); - } + gchar * a11y; + const gchar * username = gtk_label_get_text (indicator->entry.label); + const gboolean need_attn = disposition != DISPOSITION_NORMAL; + const gboolean show_name = g_settings_get_boolean (indicator->settings, + "show-real-name-on-panel"); + + if (show_name && need_attn) + a11y = g_strdup_printf (_("System %s (Attention Required)"), username); + else if (show_name) + a11y = g_strdup_printf (_("System %s"), username); + else + a11y = g_strdup (_("System")); - g_debug (G_STRLOC" setting a11y to \"%s\"", a11y->str); + g_debug (G_STRLOC" setting a11y to \"%s\"", a11y); g_clear_pointer (&indicator->entry.accessible_desc, g_free); - indicator->entry.accessible_desc = g_string_free (a11y, FALSE); + indicator->entry.accessible_desc = a11y; g_signal_emit (indicator, INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE_ID, 0, -- cgit v1.2.3 From 8c9120287ace0a37c26c38bfa94b1fd06dfa5578 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 31 Aug 2012 11:36:06 -0500 Subject: add a11y case for attention needed, but username display disabled --- src/indicator-session.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/indicator-session.c b/src/indicator-session.c index ec95328..aa328dd 100644 --- a/src/indicator-session.c +++ b/src/indicator-session.c @@ -441,6 +441,8 @@ indicator_session_update_a11y_from_disposition (IndicatorSession * indicator, a11y = g_strdup_printf (_("System %s (Attention Required)"), username); else if (show_name) a11y = g_strdup_printf (_("System %s"), username); + else if (need_attn) + a11y = g_strdup (_("System (Attention Required)")); else a11y = g_strdup (_("System")); -- cgit v1.2.3