Merge lp:~mardy/indicator-session/online-accounts into lp:indicator-session/12.10

Proposed by Alberto Mardegan
Status: Merged
Approved by: Charles Kerr
Approved revision: 352
Merged at revision: 352
Proposed branch: lp:~mardy/indicator-session/online-accounts
Merge into: lp:indicator-session/12.10
Diff against target: 343 lines (+258/-1)
5 files modified
po/POTFILES.in (+1/-0)
src/Makefile.am (+3/-1)
src/online-accounts-mgr.c (+166/-0)
src/online-accounts-mgr.h (+50/-0)
src/session-menu-mgr.c (+38/-0)
To merge this branch: bzr merge lp:~mardy/indicator-session/online-accounts
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
Matthew Paul Thomas (community) design Approve
jenkins (community) continuous-integration Approve
Review via email: mp+120509@code.launchpad.net

Commit message

Add the "Online Accounts" item to the session menu.

This item, beside opening the Online Accounts applet of the GNOME Control Center, also acts as an indicator, by turning red when some accounts need to be re-authenticated.

Description of the change

Add the "Online Accounts" item to the session menu.

This item, beside opening the Online Accounts applet of the GNOME Control Center, also acts as an indicator, by turning red when some accounts need to be re-authenticated.

To post a comment you must log in.
Revision history for this message
jenkins (martin-mrazik+qa) wrote :
review: Needs Fixing (continuous-integration)
351. By Alberto Mardegan

Fix build

Revision history for this message
jenkins (martin-mrazik+qa) wrote :
review: Approve (continuous-integration)
Revision history for this message
Matthew Paul Thomas (mpt) wrote :

Sorry, "Online Accounts" is not in the design for the system menu because it would be inappropriate there. Ubuntu 12.10 will no longer have a session menu. And part of the merger of the user and session menus was removing all links to individual panels, leaving only "System Settings". Compare with "User Accounts", which used to be in the user menu (like Online Accounts was in 11.10), but which isn't in the combined menu either. <https://wiki.ubuntu.com/SystemMenu>

review: Disapprove (design)
352. By Alberto Mardegan

Show Online Accounts only when needed

Revision history for this message
Alberto Mardegan (mardy) wrote :

Hi Matthew, I updated the patch according to John Lea and Calum Pringle suggestions: not the "Online Accounts..." item is shown only if there are some accounts needing the user's attention (and when it's shown, it's shown in red). I hope that that's an acceptable compromise.

However, they also wanted that in error conditions the icon of the system menu would turn red, and I didn't find a way to do that. Setting the "alert" disposition on mgr->top_mi doesn't seem to produce any effect. I hope that some reviewer can give me some hints on how to do that.

(Though ideally, I think that this should be a feature of DbusmenuItem itself: when any of the child items is in "alert" disposition, the parent item should also visually deliver the alert)

Revision history for this message
jenkins (martin-mrazik+qa) wrote :
review: Approve (continuous-integration)
Revision history for this message
Matthew Paul Thomas (mpt) :
review: Approve (design)
Revision history for this message
Charles Kerr (charlesk) wrote :

Alberto, there does exist a system-devices-panel-alert alert icon for flagging this information, but the mechanism to activate it isn't plugged in ATM because all of the events that used to trigger it were removed in the 12.10 redesign.

This patch looks fine. I'll merge it, then add a separate patch on top of it to trigger the icon change.

review: Approve
Revision history for this message
Charles Kerr (charlesk) wrote :
Revision history for this message
Alberto Mardegan (mardy) wrote :

Thanks Charles!!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'po/POTFILES.in'
2--- po/POTFILES.in 2012-07-06 20:10:06 +0000
3+++ po/POTFILES.in 2012-08-23 12:07:22 +0000
4@@ -5,6 +5,7 @@
5 src/gen-session-dbus.xml.c
6 src/gtk-logout-helper.c
7 src/indicator-session.c
8+src/online-accounts-mgr.c
9 src/session-dbus.c
10 src/session-menu-mgr.c
11 src/session-service.c
12
13=== modified file 'src/Makefile.am'
14--- src/Makefile.am 2012-06-18 17:35:05 +0000
15+++ src/Makefile.am 2012-08-23 12:07:22 +0000
16@@ -133,7 +133,9 @@
17 users-service-dbus.h \
18 users-service-dbus.c \
19 session-menu-mgr.h \
20- session-menu-mgr.c
21+ session-menu-mgr.c \
22+ online-accounts-mgr.c \
23+ online-accounts-mgr.h
24
25 indicator_session_service_CFLAGS = \
26 $(SESSIONSERVICE_CFLAGS) \
27
28=== added file 'src/online-accounts-mgr.c'
29--- src/online-accounts-mgr.c 1970-01-01 00:00:00 +0000
30+++ src/online-accounts-mgr.c 2012-08-23 12:07:22 +0000
31@@ -0,0 +1,166 @@
32+/*
33+Copyright 2012 Canonical Ltd.
34+
35+Authors:
36+ Alberto Mardegan <alberto.mardegan@canonical.com>
37+
38+This program is free software: you can redistribute it and/or modify it
39+under the terms of the GNU General Public License version 3, as published
40+by the Free Software Foundation.
41+
42+This program is distributed in the hope that it will be useful, but
43+WITHOUT ANY WARRANTY; without even the implied warranties of
44+MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
45+PURPOSE. See the GNU General Public License for more details.
46+
47+You should have received a copy of the GNU General Public License along
48+with this program. If not, see <http://www.gnu.org/licenses/>.
49+*/
50+
51+#include <gio/gio.h>
52+#include <glib/gi18n.h>
53+
54+#include "online-accounts-mgr.h"
55+
56+#include <libdbusmenu-glib/client.h>
57+
58+struct _OnlineAccountsMgr
59+{
60+ GObject parent_instance;
61+ GDBusProxy *proxy;
62+ DbusmenuMenuitem *menu_item;
63+};
64+
65+#define ONLINE_ACCOUNTS_OBJECT_PATH "/com/canonical/indicators/webcredentials"
66+#define ONLINE_ACCOUNTS_BUS_NAME "com.canonical.indicators.webcredentials"
67+#define ONLINE_ACCOUNTS_INTERFACE ONLINE_ACCOUNTS_BUS_NAME
68+
69+G_DEFINE_TYPE (OnlineAccountsMgr, online_accounts_mgr, G_TYPE_OBJECT);
70+
71+static void
72+update_disposition (OnlineAccountsMgr *self, GVariant *error_status_prop)
73+{
74+ gboolean error_status;
75+
76+ error_status = g_variant_get_boolean (error_status_prop);
77+ dbusmenu_menuitem_property_set (self->menu_item,
78+ DBUSMENU_MENUITEM_PROP_DISPOSITION,
79+ error_status ?
80+ DBUSMENU_MENUITEM_DISPOSITION_ALERT :
81+ DBUSMENU_MENUITEM_DISPOSITION_NORMAL);
82+}
83+
84+static void
85+on_properties_changed (GDBusProxy *proxy,
86+ GVariant *changed_properties,
87+ GStrv invalidated_properties,
88+ OnlineAccountsMgr *self)
89+{
90+ if (g_variant_n_children (changed_properties) > 0) {
91+ GVariantIter *iter;
92+ const gchar *key;
93+ GVariant *value;
94+
95+ g_variant_get (changed_properties, "a{sv}", &iter);
96+ while (g_variant_iter_loop (iter, "{&sv}", &key, &value)) {
97+ if (g_strcmp0 (key, "ErrorStatus") == 0) {
98+ update_disposition (self, value);
99+ }
100+ }
101+ g_variant_iter_free (iter);
102+ }
103+}
104+
105+static void
106+on_menu_item_activated (DbusmenuMenuitem *menu_item,
107+ guint timestamp,
108+ OnlineAccountsMgr *self)
109+{
110+ GError *error = NULL;
111+
112+ if (!g_spawn_command_line_async("gnome-control-center credentials", &error))
113+ {
114+ g_warning("Unable to show control center: %s", error->message);
115+ g_error_free(error);
116+ }
117+}
118+
119+static void
120+online_accounts_mgr_init (OnlineAccountsMgr *self)
121+{
122+ GError *error = NULL;
123+ GVariant *error_status_prop;
124+
125+ self->menu_item = dbusmenu_menuitem_new ();
126+ dbusmenu_menuitem_property_set (self->menu_item,
127+ DBUSMENU_MENUITEM_PROP_TYPE,
128+ DBUSMENU_CLIENT_TYPES_DEFAULT);
129+ dbusmenu_menuitem_property_set (self->menu_item,
130+ DBUSMENU_MENUITEM_PROP_LABEL,
131+ _("Online Accounts\342\200\246"));
132+ g_signal_connect (self->menu_item,
133+ DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
134+ G_CALLBACK (on_menu_item_activated),
135+ self);
136+
137+ self->proxy =
138+ g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
139+ G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
140+ NULL,
141+ ONLINE_ACCOUNTS_BUS_NAME,
142+ ONLINE_ACCOUNTS_OBJECT_PATH,
143+ ONLINE_ACCOUNTS_INTERFACE,
144+ NULL,
145+ &error);
146+ if (G_UNLIKELY (error != NULL)) {
147+ g_warning ("Couldn't create online_accounts proxy: %s", error->message);
148+ g_clear_error (&error);
149+ return;
150+ }
151+
152+ g_signal_connect (self->proxy, "g-properties-changed",
153+ G_CALLBACK (on_properties_changed), self);
154+
155+ error_status_prop =
156+ g_dbus_proxy_get_cached_property (self->proxy, "ErrorStatus");
157+ if (error_status_prop != NULL) {
158+ update_disposition (self, error_status_prop);
159+ g_variant_unref (error_status_prop);
160+ }
161+}
162+
163+static void
164+online_accounts_mgr_dispose (GObject *object)
165+{
166+ OnlineAccountsMgr *self = ONLINE_ACCOUNTS_MGR (object);
167+
168+ if (self->proxy != NULL) {
169+ g_object_unref (self->proxy);
170+ self->proxy = NULL;
171+ }
172+
173+ if (self->menu_item != NULL) {
174+ g_object_unref (self->menu_item);
175+ self->menu_item = NULL;
176+ }
177+
178+ G_OBJECT_CLASS (online_accounts_mgr_parent_class)->dispose (object);
179+}
180+
181+static void
182+online_accounts_mgr_class_init (OnlineAccountsMgrClass *klass)
183+{
184+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
185+ object_class->dispose = online_accounts_mgr_dispose;
186+}
187+
188+OnlineAccountsMgr *online_accounts_mgr_new ()
189+{
190+ return g_object_new (ONLINE_ACCOUNTS_TYPE_MGR, NULL);
191+}
192+
193+DbusmenuMenuitem *online_accounts_mgr_get_menu_item (OnlineAccountsMgr *self)
194+{
195+ g_return_val_if_fail (ONLINE_ACCOUNTS_IS_MGR (self), NULL);
196+ return self->menu_item;
197+}
198
199=== added file 'src/online-accounts-mgr.h'
200--- src/online-accounts-mgr.h 1970-01-01 00:00:00 +0000
201+++ src/online-accounts-mgr.h 2012-08-23 12:07:22 +0000
202@@ -0,0 +1,50 @@
203+/*
204+Copyright 2012 Canonical Ltd.
205+
206+Authors:
207+ Alberto Mardegan <alberto.mardegan@canonical.com>
208+
209+This program is free software: you can redistribute it and/or modify it
210+under the terms of the GNU General Public License version 3, as published
211+by the Free Software Foundation.
212+
213+This program is distributed in the hope that it will be useful, but
214+WITHOUT ANY WARRANTY; without even the implied warranties of
215+MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
216+PURPOSE. See the GNU General Public License for more details.
217+
218+You should have received a copy of the GNU General Public License along
219+with this program. If not, see <http://www.gnu.org/licenses/>.
220+*/
221+
222+#ifndef _ONLINE_ACCOUNTS_MGR_H_
223+#define _ONLINE_ACCOUNTS_MGR_H_
224+
225+#include <glib-object.h>
226+#include <libdbusmenu-glib/menuitem.h>
227+
228+G_BEGIN_DECLS
229+
230+#define ONLINE_ACCOUNTS_TYPE_MGR (online_accounts_mgr_get_type ())
231+#define ONLINE_ACCOUNTS_MGR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ONLINE_ACCOUNTS_TYPE_MGR, OnlineAccountsMgr))
232+#define ONLINE_ACCOUNTS_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ONLINE_ACCOUNTS_TYPE_MGR, OnlineAccountsMgrClass))
233+#define ONLINE_ACCOUNTS_IS_MGR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ONLINE_ACCOUNTS_TYPE_MGR))
234+#define ONLINE_ACCOUNTS_IS_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ONLINE_ACCOUNTS_TYPE_MGR))
235+#define ONLINE_ACCOUNTS_MGR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ONLINE_ACCOUNTS_TYPE_MGR, OnlineAccountsMgrClass))
236+
237+typedef struct _OnlineAccountsMgrClass OnlineAccountsMgrClass;
238+typedef struct _OnlineAccountsMgr OnlineAccountsMgr;
239+
240+struct _OnlineAccountsMgrClass
241+{
242+ GObjectClass parent_class;
243+};
244+
245+GType online_accounts_mgr_get_type (void) G_GNUC_CONST;
246+OnlineAccountsMgr *online_accounts_mgr_new (void);
247+
248+DbusmenuMenuitem *online_accounts_mgr_get_menu_item (OnlineAccountsMgr *self);
249+
250+G_END_DECLS
251+
252+#endif /* _ONLINE_ACCOUNTS_MGR_H_ */
253
254=== modified file 'src/session-menu-mgr.c'
255--- src/session-menu-mgr.c 2012-07-04 05:17:57 +0000
256+++ src/session-menu-mgr.c 2012-08-23 12:07:22 +0000
257@@ -33,6 +33,7 @@
258 #include "session-menu-mgr.h"
259 #include "shared-names.h"
260 #include "users-service-dbus.h"
261+#include "online-accounts-mgr.h"
262
263 #define DEBUG_SHOW_ALL FALSE
264
265@@ -88,6 +89,7 @@
266 DbusmenuMenuitem * lock_mi;
267 DbusmenuMenuitem * lock_switch_mi;
268 DbusmenuMenuitem * guest_mi;
269+ DbusmenuMenuitem * online_accounts_mi;
270 DbusmenuMenuitem * logout_mi;
271 DbusmenuMenuitem * suspend_mi;
272 DbusmenuMenuitem * hibernate_mi;
273@@ -113,6 +115,7 @@
274 DBusUPower * upower_proxy;
275 SessionDbus * session_dbus;
276 UsersServiceDbus * users_dbus_facade;
277+ OnlineAccountsMgr * online_accounts_mgr;
278 };
279
280 static SwitcherMode get_switcher_mode (SessionMenuMgr *);
281@@ -192,6 +195,9 @@
282 G_CALLBACK(on_guest_logged_in_changed), mgr);
283
284 init_upower_proxy (mgr);
285+
286+ /* Online accounts menu item */
287+ mgr->online_accounts_mgr = online_accounts_mgr_new ();
288 }
289
290 static void
291@@ -212,6 +218,7 @@
292 g_clear_object (&mgr->users_dbus_facade);
293 g_clear_object (&mgr->top_mi);
294 g_clear_object (&mgr->session_dbus);
295+ g_clear_object (&mgr->online_accounts_mgr);
296
297 g_slist_free (mgr->user_menuitems);
298 mgr->user_menuitems = NULL;
299@@ -362,6 +369,29 @@
300 return mi;
301 }
302
303+static void
304+check_online_accounts_status (SessionMenuMgr * mgr, DbusmenuMenuitem * mi)
305+{
306+ const gchar *disposition;
307+ gboolean on_alert;
308+
309+ disposition =
310+ dbusmenu_menuitem_property_get (mi, DBUSMENU_MENUITEM_PROP_DISPOSITION);
311+ on_alert = g_strcmp0 (disposition, DBUSMENU_MENUITEM_DISPOSITION_ALERT) == 0;
312+
313+ mi_set_visible (mi, on_alert);
314+}
315+
316+static void
317+on_online_accounts_changed (SessionMenuMgr * mgr, const gchar * property,
318+ GVariant *value, DbusmenuMenuitem *mi)
319+{
320+ if (g_strcmp0 (property, DBUSMENU_MENUITEM_PROP_DISPOSITION) == 0)
321+ {
322+ check_online_accounts_status(mgr, mi);
323+ }
324+}
325+
326 /***
327 **** Admin Menuitems
328 **** <https://wiki.ubuntu.com/SystemMenu#Admin_items>
329@@ -396,6 +426,14 @@
330 G_CALLBACK(action_func_spawn_async),
331 CMD_SYSTEM_SETTINGS);
332
333+ mi = mgr->online_accounts_mi =
334+ online_accounts_mgr_get_menu_item (mgr->online_accounts_mgr);
335+ dbusmenu_menuitem_child_append (mgr->top_mi, mi);
336+ g_signal_connect_swapped (mi, DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED,
337+ G_CALLBACK(on_online_accounts_changed),
338+ mgr);
339+ check_online_accounts_status (mgr, mi);
340+
341 mi = mi_new_separator ();
342 dbusmenu_menuitem_child_append (mgr->top_mi, mi);
343 }

Subscribers

People subscribed via source and target branches