Merge lp:~khurshid-alam/unity-control-center/uoa-panel into lp:unity-control-center

Proposed by Khurshid Alam on 2018-02-13
Status: Merged
Approved by: Jeremy Bicha on 2018-02-16
Approved revision: 12914
Merged at revision: 12911
Proposed branch: lp:~khurshid-alam/unity-control-center/uoa-panel
Merge into: lp:unity-control-center
Diff against target: 1925 lines (+1733/-3)
22 files modified
configure.ac (+43/-1)
debian/control (+3/-1)
debian/libunity-control-center1.symbols (+3/-0)
panels/Makefile.am (+4/-0)
panels/online-accounts/Makefile.am (+52/-0)
panels/online-accounts/cc-online-accounts-panel.c (+985/-0)
panels/online-accounts/cc-online-accounts-panel.h (+65/-0)
panels/online-accounts/icons/16x16/Makefile.am (+14/-0)
panels/online-accounts/icons/22x22/Makefile.am (+14/-0)
panels/online-accounts/icons/24x24/Makefile.am (+14/-0)
panels/online-accounts/icons/256x256/Makefile.am (+14/-0)
panels/online-accounts/icons/32x32/Makefile.am (+14/-0)
panels/online-accounts/icons/48x48/Makefile.am (+14/-0)
panels/online-accounts/icons/Makefile.am (+23/-0)
panels/online-accounts/online-accounts-module.c (+33/-0)
panels/online-accounts/online-accounts.gresource.xml (+6/-0)
panels/online-accounts/online-accounts.ui (+270/-0)
panels/online-accounts/unity-online-accounts-panel.desktop.in.in (+15/-0)
po/POTFILES.in (+4/-1)
shell/Makefile.am (+2/-0)
shell/list-box-helper.c (+110/-0)
shell/list-box-helper.h (+31/-0)
To merge this branch: bzr merge lp:~khurshid-alam/unity-control-center/uoa-panel
Reviewer Review Type Date Requested Status
Jeremy Bicha 2018-02-13 Approve on 2018-02-16
Review via email: mp+337618@code.launchpad.net

Commit message

Import gnome online-accounts panel into unity-control-center
Reference: https://bugzilla.gnome.org/show_bug.cgi?id=774222
Reference: https://github.com/linuxmint/cinnamon-control-center/pull/181

Description of the change

Import gnome online-accounts panel into unity-control-center
Reference: https://bugzilla.gnome.org/show_bug.cgi?id=774222
Reference: https://github.com/linuxmint/cinnamon-control-center/pull/181

PPA: ppa:unity7maintainers/unity7-desktop

Community forum thread: https://community.ubuntu.com/t/testing-online-accounts-in-unity-control-center-bionic/3910

To post a comment you must log in.
Jeremy Bicha (jbicha) wrote :

https://bileto.ubuntu.com/#/ticket/3158

This will be part of the gnome-desktop3 transition which is currently held up by a few things (glib needs to migrate, libglvnd needs to be promoted to main, and I'm having trouble with Unity FTBFS)
https://people.canonical.com/~ubuntu-archive/transitions/html/gnome-desktop3.html

Jeremy Bicha (jbicha) wrote :

Thank you! This is a very useful feature! :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2017-12-07 05:41:33 +0000
3+++ configure.ac 2018-02-13 09:06:22 +0000
4@@ -119,7 +119,7 @@
5 SCHEMAS_REQUIRED_VERSION=3.15.4
6 LIBWACOM_REQUIRED_VERSION=0.7
7 CLUTTER_REQUIRED_VERSION=1.11.3
8-GOA_REQUIRED_VERSION=3.5.90
9+GOA_REQUIRED_VERSION=3.18.0
10 ACCOUNTSSERVICE_REQUIRED_VERSION=0.6.30
11
12 COMMON_MODULES="gtk+-3.0 >= $GTK_REQUIRED_VERSION
13@@ -262,6 +262,34 @@
14 esac
15 AM_CONDITIONAL(BUILD_WACOM, [test x"$have_wacom" = x"yes"])
16
17+# Online accounts
18+AC_ARG_ENABLE(onlineaccounts, AC_HELP_STRING([--disable-onlineaccounts], [disable online-accounts panel]),
19+ [case "${enableval}" in
20+ yes) enable_onlineaccounts=yes ;;
21+ no) enable_onlineaccounts=no ;;
22+ *) AC_MSG_ERROR(bad value ${enableval} for --disable-onlineaccounts) ;;
23+ esac],
24+ [enable_onlineaccounts=yes]) dnl Enabled by default
25+
26+if test "x$enable_onlineaccounts" = xyes; then
27+ PKG_CHECK_MODULES(ONLINE_ACCOUNTS_PANEL, $COMMON_MODULES goa-1.0
28+ goa-backend-1.0 >= $GOA_REQUIRED_VERSION,
29+ [have_onlineaccounts=yes], have_onlineaccounts=no)
30+ if test "x$have_onlineaccounts" = xno ; then
31+ AC_MSG_ERROR(*** Gnome Online Accounts not found ***)
32+ fi
33+
34+ AC_DEFINE(BUILD_ONLINE_ACCOUNTS, 1, [Define to 1 to build the online-accounts panel])
35+
36+ if test x${have_onlineaccounts} = xyes; then
37+ AC_DEFINE(HAVE_ONLINE_ACCOUNTS, 1, [Define to 1 if Gnome Online Accounts is available])
38+ fi
39+fi
40+
41+AM_CONDITIONAL(BUILD_ONLINE_ACCOUNTS, [test x$have_onlineaccounts = xyes])
42+AC_SUBST(ONLINE_ACCOUNTS_CFLAGS)
43+AC_SUBST(ONLINE_ACCOUNTS_LIBS)
44+
45 # This is a hard-dependency for the region and user-accounts panels
46 PKG_CHECK_MODULES(ISOCODES, iso-codes)
47
48@@ -495,6 +523,15 @@
49 panels/wacom/Makefile
50 panels/wacom/calibrator/Makefile
51 panels/wacom/unity-wacom-panel.desktop.in
52+panels/online-accounts/Makefile
53+panels/online-accounts/unity-online-accounts-panel.desktop.in
54+panels/online-accounts/icons/Makefile
55+panels/online-accounts/icons/16x16/Makefile
56+panels/online-accounts/icons/22x22/Makefile
57+panels/online-accounts/icons/24x24/Makefile
58+panels/online-accounts/icons/32x32/Makefile
59+panels/online-accounts/icons/48x48/Makefile
60+panels/online-accounts/icons/256x256/Makefile
61 po/Makefile.in
62 shell/appdata/Makefile
63 shell/Makefile
64@@ -538,4 +575,9 @@
65 else
66 AC_MSG_NOTICE([ Region panel Fcitx support disabled])
67 fi
68+if test "x$have_onlineaccounts" = "xyes"; then
69+ AC_MSG_NOTICE([** Online-Accounts support (Online-Accounts panel)])
70+else
71+ AC_MSG_NOTICE([ Online-Accounts support disabled])
72+fi
73 AC_MSG_NOTICE([End options])
74
75=== modified file 'debian/control'
76--- debian/control 2017-09-30 22:30:57 +0000
77+++ debian/control 2018-02-13 09:06:22 +0000
78@@ -29,7 +29,8 @@
79 libgnome-desktop-3-dev (>= 3.5.91),
80 libgnome-menu-3-dev,
81 libgnomekbd-dev,
82- libgoa-1.0-dev (>= 3.5.90),
83+ libgoa-1.0-dev (>= 3.18.0),
84+ libgoa-backend-1.0-dev (>= 3.18.0),
85 libgtk-3-dev (>= 3.10.0),
86 libgtop2-dev,
87 libibus-1.0-dev (>= 1.5.0),
88@@ -73,6 +74,7 @@
89 gnome-desktop3-data,
90 adwaita-icon-theme,
91 gnome-menus (>= 2.12.0),
92+ gnome-online-accounts,
93 unity-settings-daemon,
94 gnome-settings-daemon-schemas (>= 3.16),
95 gsettings-desktop-schemas (>= 3.15.4),
96
97=== modified file 'debian/libunity-control-center1.symbols'
98--- debian/libunity-control-center1.symbols 2014-06-26 02:58:37 +0000
99+++ debian/libunity-control-center1.symbols 2018-02-13 09:06:22 +0000
100@@ -18,6 +18,9 @@
101 cc_editable_entry_set_text@Base 14.04.0
102 cc_editable_entry_set_weight@Base 14.04.0
103 cc_editable_entry_set_width_chars@Base 14.04.3+14.04.20140225
104+ cc_list_box_adjust_scrolling@Base 15.04.0+17.10.20171225
105+ cc_list_box_setup_scrolling@Base 15.04.0+17.10.20171225
106+ cc_list_box_update_header_func@Base 15.04.0+17.10.20171225
107 cc_panel_get_display_name@Base 14.04.0
108 cc_panel_get_help_uri@Base 14.04.0
109 cc_panel_get_permission@Base 14.04.0
110
111=== modified file 'panels/Makefile.am'
112--- panels/Makefile.am 2017-12-07 05:41:33 +0000
113+++ panels/Makefile.am 2018-02-13 09:06:22 +0000
114@@ -28,4 +28,8 @@
115 SUBDIRS += network
116 endif
117
118+if BUILD_ONLINE_ACCOUNTS
119+SUBDIRS += online-accounts
120+endif
121+
122 -include $(top_srcdir)/git.mk
123
124=== added directory 'panels/online-accounts'
125=== added file 'panels/online-accounts/Makefile.am'
126--- panels/online-accounts/Makefile.am 1970-01-01 00:00:00 +0000
127+++ panels/online-accounts/Makefile.am 2018-02-13 09:06:22 +0000
128@@ -0,0 +1,52 @@
129+cappletname = online-accounts
130+
131+SUBDIRS = icons
132+
133+uidir = $(pkgdatadir)/ui/online-accounts
134+dist_ui_DATA = \
135+ online-accounts.ui
136+
137+INCLUDES = \
138+ $(PANEL_CFLAGS) \
139+ $(ONLINE_ACCOUNTS_PANEL_CFLAGS) \
140+ -DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
141+ -DG_LOG_DOMAIN="\"$(PACKAGE)\"" \
142+ -DGNOMECC_UI_DIR="\"$(uidir)\"" \
143+ -DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
144+ $(NULL)
145+
146+ccpanelsdir = $(PANELS_DIR)
147+ccpanels_LTLIBRARIES = libonline-accounts.la
148+
149+BUILT_SOURCES = \
150+ cc-online-accounts-resources.c \
151+ cc-online-accounts-resources.h
152+
153+libonline_accounts_la_SOURCES = \
154+ $(BUILT_SOURCES) \
155+ online-accounts-module.c \
156+ cc-online-accounts-panel.c \
157+ cc-online-accounts-panel.h
158+
159+libonline_accounts_la_LIBADD = \
160+ $(PANEL_LIBS) \
161+ $(ONLINE_ACCOUNTS_PANEL_LIBS)
162+
163+libonline_accounts_la_LDFLAGS = $(PANEL_LDFLAGS)
164+
165+resource_files = $(shell glib-compile-resources --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/online-accounts.gresource.xml)
166+cc-online-accounts-resources.c: online-accounts.gresource.xml $(resource_files)
167+ $(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-source --c-name cc_online_accounts $<
168+cc-online-accounts-resources.h: online-accounts.gresource.xml $(resource_files)
169+ $(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-header --c-name cc_online_accounts $<
170+
171+@INTLTOOL_DESKTOP_RULE@
172+
173+desktopdir = $(datadir)/applications
174+desktop_in_files = unity-online-accounts-panel.desktop.in
175+desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
176+
177+CLEANFILES = $(desktop_in_files) $(desktop_DATA) $(BUILT_SOURCES)
178+EXTRA_DIST = $(resource_files) online-accounts.gresource.xml
179+
180+-include $(top_srcdir)/git.mk
181
182=== added file 'panels/online-accounts/cc-online-accounts-panel.c'
183--- panels/online-accounts/cc-online-accounts-panel.c 1970-01-01 00:00:00 +0000
184+++ panels/online-accounts/cc-online-accounts-panel.c 2018-02-13 09:06:22 +0000
185@@ -0,0 +1,985 @@
186+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
187+/*
188+ * Copyright (C) 2011, 2012 Red Hat, Inc.
189+ *
190+ * This library is free software; you can redistribute it and/or
191+ * modify it under the terms of the GNU Lesser General Public
192+ * License as published by the Free Software Foundation; either
193+ * version 2 of the License, or (at your option) any later version.
194+ *
195+ * This library is distributed in the hope that it will be useful,
196+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
197+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
198+ * Lesser General Public License for more details.
199+ *
200+ * You should have received a copy of the GNU Lesser General
201+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
202+ *
203+ * Author: David Zeuthen <davidz@redhat.com>
204+ */
205+
206+#include "config.h"
207+
208+#include <gio/gio.h>
209+#include <string.h>
210+#include <glib/gi18n.h>
211+
212+#define GOA_API_IS_SUBJECT_TO_CHANGE
213+#include <goa/goa.h>
214+#define GOA_BACKEND_API_IS_SUBJECT_TO_CHANGE
215+#include <goabackend/goabackend.h>
216+
217+#include "cc-online-accounts-panel.h"
218+#include "cc-online-accounts-resources.h"
219+
220+#include "shell/list-box-helper.h"
221+
222+struct _CcGoaPanel
223+{
224+ CcPanel parent_instance;
225+
226+ GoaClient *client;
227+ GoaObject *active_object;
228+ GoaObject *removed_object;
229+
230+ GtkWidget *accounts_frame;
231+ GtkWidget *accounts_listbox;
232+ GtkWidget *edit_account_dialog;
233+ GtkWidget *edit_account_headerbar;
234+ GtkWidget *more_providers_row;
235+ GtkWidget *new_account_vbox;
236+ GtkWidget *notification_label;
237+ GtkWidget *notification_revealer;
238+ GtkWidget *offline_label;
239+ GtkWidget *providers_listbox;
240+ GtkWidget *remove_account_button;
241+ GtkWidget *stack;
242+ GtkWidget *accounts_vbox;
243+
244+ guint remove_account_timeout_id;
245+};
246+
247+static gboolean on_edit_account_dialog_delete_event (CcGoaPanel *self);
248+
249+static void on_listbox_row_activated (CcGoaPanel *self,
250+ GtkListBoxRow *activated_row);
251+
252+static void fill_accounts_listbox (CcGoaPanel *self);
253+
254+static void on_account_added (GoaClient *client,
255+ GoaObject *object,
256+ gpointer user_data);
257+
258+static void on_account_changed (GoaClient *client,
259+ GoaObject *object,
260+ gpointer user_data);
261+
262+static void on_account_removed (GoaClient *client,
263+ GoaObject *object,
264+ gpointer user_data);
265+
266+static void select_account_by_id (CcGoaPanel *panel,
267+ const gchar *account_id);
268+
269+static void get_all_providers_cb (GObject *source,
270+ GAsyncResult *res,
271+ gpointer user_data);
272+
273+static void show_page_account (CcGoaPanel *panel,
274+ GoaObject *object);
275+
276+static void on_remove_button_clicked (CcGoaPanel *self);
277+
278+static void on_notification_closed (GtkButton *button,
279+ CcGoaPanel *self);
280+
281+static void on_undo_button_clicked (GtkButton *button,
282+ CcGoaPanel *self);
283+
284+CC_PANEL_REGISTER (CcGoaPanel, cc_goa_panel);
285+
286+enum {
287+ PROP_0,
288+ PROP_PARAMETERS
289+};
290+
291+/* ---------------------------------------------------------------------------------------------------- */
292+
293+static void
294+reset_headerbar (CcGoaPanel *self)
295+{
296+ gtk_header_bar_set_title (GTK_HEADER_BAR (self->edit_account_headerbar), NULL);
297+ gtk_header_bar_set_subtitle (GTK_HEADER_BAR (self->edit_account_headerbar), NULL);
298+ gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (self->edit_account_headerbar), TRUE);
299+
300+ /* Remove any leftover widgets */
301+ gtk_container_foreach (GTK_CONTAINER (self->edit_account_headerbar),
302+ (GtkCallback) gtk_widget_destroy,
303+ NULL);
304+
305+}
306+
307+/* ---------------------------------------------------------------------------------------------------- */
308+
309+static void
310+add_provider_row (CcGoaPanel *self,
311+ GoaProvider *provider)
312+{
313+ GIcon *icon;
314+ GoaProviderFeatures features;
315+ GtkWidget *image;
316+ GtkWidget *label;
317+ GtkWidget *row;
318+ GtkWidget *row_grid;
319+ gchar *markup;
320+ gchar *name;
321+
322+ row = gtk_list_box_row_new ();
323+
324+ row_grid = gtk_grid_new ();
325+ gtk_orientable_set_orientation (GTK_ORIENTABLE (row_grid), GTK_ORIENTATION_HORIZONTAL);
326+ gtk_grid_set_column_spacing (GTK_GRID (row_grid), 6);
327+ gtk_container_add (GTK_CONTAINER (row), row_grid);
328+
329+ if (provider == NULL)
330+ {
331+ g_object_set_data (G_OBJECT (row), "goa-provider", NULL);
332+ icon = g_themed_icon_new_with_default_fallbacks ("goa-account");
333+ name = g_strdup (C_("Online Account", "Other"));
334+ }
335+ else
336+ {
337+ g_object_set_data_full (G_OBJECT (row), "goa-provider", g_object_ref (provider), g_object_unref);
338+ icon = goa_provider_get_provider_icon (provider, NULL);
339+ name = goa_provider_get_provider_name (provider, NULL);
340+ }
341+
342+ image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);
343+ gtk_container_add (GTK_CONTAINER (row_grid), image);
344+ g_object_set (image, "margin", 6, NULL);
345+
346+ markup = g_strdup_printf ("<b>%s</b>", name);
347+ label = gtk_label_new (NULL);
348+ gtk_label_set_markup (GTK_LABEL (label), markup);
349+ gtk_container_add (GTK_CONTAINER (row_grid), label);
350+
351+ /* Check if the row should be shown initially */
352+ features = goa_provider_get_provider_features (provider);
353+
354+ if ((features & GOA_PROVIDER_FEATURE_BRANDED) != 0)
355+ gtk_widget_show_all (row);
356+
357+ gtk_container_add (GTK_CONTAINER (self->providers_listbox), row);
358+
359+ g_free (markup);
360+ g_free (name);
361+ g_object_unref (icon);
362+}
363+
364+static gint
365+sort_providers_func (GtkListBoxRow *a,
366+ GtkListBoxRow *b,
367+ gpointer user_data)
368+{
369+ GoaProvider *a_provider, *b_provider;
370+ CcGoaPanel *self;
371+ gboolean a_branded, b_branded;
372+
373+ self = user_data;
374+
375+ if (a == GTK_LIST_BOX_ROW (self->more_providers_row))
376+ return 1;
377+ else if (b == GTK_LIST_BOX_ROW (self->more_providers_row))
378+ return -1;
379+
380+ a_provider = g_object_get_data (G_OBJECT (a), "goa-provider");
381+ b_provider = g_object_get_data (G_OBJECT (b), "goa-provider");
382+
383+ a_branded = (goa_provider_get_provider_features (a_provider) & GOA_PROVIDER_FEATURE_BRANDED) != 0;
384+ b_branded = (goa_provider_get_provider_features (b_provider) & GOA_PROVIDER_FEATURE_BRANDED) != 0;
385+
386+ if (a_branded != b_branded)
387+ {
388+ if (a_branded)
389+ return -1;
390+ else
391+ return 1;
392+ }
393+
394+ return gtk_list_box_row_get_index (b) - gtk_list_box_row_get_index (a);
395+}
396+
397+static void
398+show_non_branded_providers (CcGoaPanel *self)
399+{
400+ GList *children, *l;
401+
402+ children = gtk_container_get_children (GTK_CONTAINER (self->providers_listbox));
403+
404+ for (l = children; l != NULL; l = l->next)
405+ {
406+ GoaProvider *provider = g_object_get_data (l->data, "goa-provider");
407+
408+ if (!provider)
409+ continue;
410+
411+ if ((goa_provider_get_provider_features (provider) & GOA_PROVIDER_FEATURE_BRANDED) == 0)
412+ gtk_widget_show_all (l->data);
413+ }
414+
415+ gtk_widget_hide (self->more_providers_row);
416+
417+ g_list_free (children);
418+}
419+
420+static void
421+add_account (CcGoaPanel *self,
422+ GoaProvider *provider,
423+ GVariant *preseed)
424+{
425+ GoaObject *object;
426+ GError *error;
427+
428+ error = NULL;
429+
430+ gtk_container_foreach (GTK_CONTAINER (self->new_account_vbox),
431+ (GtkCallback) gtk_widget_destroy,
432+ NULL);
433+
434+ reset_headerbar (self);
435+
436+ /* Move to the new account page */
437+ gtk_stack_set_visible_child_name (GTK_STACK (self->stack), "new-account");
438+
439+ /* Reset the dialog size */
440+ gtk_window_resize (GTK_WINDOW (self->edit_account_dialog), 1, 1);
441+
442+ /* This spins gtk_dialog_run() */
443+ object = goa_provider_add_account (provider,
444+ self->client,
445+ GTK_DIALOG (self->edit_account_dialog),
446+ GTK_BOX (self->new_account_vbox),
447+ &error);
448+
449+ if (preseed)
450+ goa_provider_set_preseed_data (provider, preseed);
451+
452+ if (object == NULL)
453+ gtk_widget_hide (self->edit_account_dialog);
454+ else
455+ show_page_account (self, object);
456+}
457+
458+static void
459+on_provider_row_activated (CcGoaPanel *self,
460+ GtkListBoxRow *activated_row)
461+{
462+ GoaProvider *provider;
463+
464+ /* Show More row */
465+ if (activated_row == GTK_LIST_BOX_ROW (self->more_providers_row))
466+ {
467+ show_non_branded_providers (self);
468+ return;
469+ }
470+
471+ provider = g_object_get_data (G_OBJECT (activated_row), "goa-provider");
472+
473+ add_account (self, provider, NULL);
474+}
475+
476+/* ---------------------------------------------------------------------------------------------------- */
477+
478+static gint
479+sort_func (GtkListBoxRow *a,
480+ GtkListBoxRow *b,
481+ gpointer user_data)
482+{
483+ GoaObject *a_obj, *b_obj;
484+ GoaAccount *a_account, *b_account;
485+
486+ a_obj = g_object_get_data (G_OBJECT (a), "goa-object");
487+ a_account = goa_object_peek_account (a_obj);
488+
489+ b_obj = g_object_get_data (G_OBJECT (b), "goa-object");
490+ b_account = goa_object_peek_account (b_obj);
491+
492+ return g_strcmp0 (goa_account_get_id (a_account), goa_account_get_id (b_account));
493+}
494+
495+static void
496+command_add (CcGoaPanel *panel,
497+ GVariant *parameters)
498+{
499+ GVariant *v, *preseed = NULL;
500+ GoaProvider *provider = NULL;
501+ const gchar *provider_name = NULL;
502+
503+ g_assert (panel != NULL);
504+ g_assert (parameters != NULL);
505+
506+ switch (g_variant_n_children (parameters))
507+ {
508+ case 3:
509+ g_variant_get_child (parameters, 2, "v", &preseed);
510+ case 2:
511+ g_variant_get_child (parameters, 1, "v", &v);
512+ if (g_variant_is_of_type (v, G_VARIANT_TYPE_STRING))
513+ provider_name = g_variant_get_string (v, NULL);
514+ else
515+ g_warning ("Wrong type for the second argument (provider name) GVariant, expected 's' but got '%s'",
516+ (gchar *)g_variant_get_type (v));
517+ g_variant_unref (v);
518+ break;
519+ default:
520+ g_warning ("Unexpected parameters found, ignore request");
521+ goto out;
522+ }
523+
524+ if (provider_name != NULL)
525+ {
526+ provider = goa_provider_get_for_provider_type (provider_name);
527+ if (provider == NULL)
528+ {
529+ g_warning ("Unable to get a provider for type '%s'", provider_name);
530+ goto out;
531+ }
532+
533+ add_account (panel, provider, preseed);
534+ }
535+
536+out:
537+ g_clear_object (&provider);
538+ g_clear_pointer (&preseed, g_variant_unref);
539+}
540+
541+static void
542+cc_goa_panel_set_property (GObject *object,
543+ guint property_id,
544+ const GValue *value,
545+ GParamSpec *pspec)
546+{
547+ switch (property_id)
548+ {
549+ case PROP_PARAMETERS:
550+ {
551+ GVariant *parameters, *v;
552+ const gchar *first_arg = NULL;
553+
554+ parameters = g_value_get_variant (value);
555+ if (parameters == NULL)
556+ return;
557+
558+ if (g_variant_n_children (parameters) > 0)
559+ {
560+ g_variant_get_child (parameters, 0, "v", &v);
561+ if (g_variant_is_of_type (v, G_VARIANT_TYPE_STRING))
562+ first_arg = g_variant_get_string (v, NULL);
563+ else
564+ g_warning ("Wrong type for the second argument GVariant, expected 's' but got '%s'",
565+ (gchar *)g_variant_get_type (v));
566+ g_variant_unref (v);
567+ }
568+
569+ if (g_strcmp0 (first_arg, "add") == 0)
570+ command_add (CC_GOA_PANEL (object), parameters);
571+ else if (first_arg != NULL)
572+ select_account_by_id (CC_GOA_PANEL (object), first_arg);
573+
574+ return;
575+ }
576+ }
577+
578+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
579+}
580+
581+static void
582+cc_goa_panel_dispose (GObject *object)
583+{
584+ CcGoaPanel *panel = CC_GOA_PANEL (object);
585+
586+ /* Must be destroyed in dispose, not finalize. */
587+ g_clear_pointer (&panel->edit_account_dialog, gtk_widget_destroy);
588+
589+ G_OBJECT_CLASS (cc_goa_panel_parent_class)->dispose (object);
590+}
591+
592+static void
593+cc_goa_panel_finalize (GObject *object)
594+{
595+ CcGoaPanel *panel = CC_GOA_PANEL (object);
596+
597+ g_clear_object (&panel->client);
598+
599+ G_OBJECT_CLASS (cc_goa_panel_parent_class)->finalize (object);
600+}
601+
602+static void
603+cc_goa_panel_init (CcGoaPanel *panel)
604+{
605+ GError *error;
606+ GNetworkMonitor *monitor;
607+
608+ g_resources_register (cc_online_accounts_get_resource ());
609+
610+ gtk_widget_init_template (GTK_WIDGET (panel));
611+
612+ gtk_list_box_set_header_func (GTK_LIST_BOX (panel->accounts_listbox),
613+ cc_list_box_update_header_func,
614+ NULL,
615+ NULL);
616+ gtk_list_box_set_sort_func (GTK_LIST_BOX (panel->accounts_listbox),
617+ sort_func,
618+ panel,
619+ NULL);
620+
621+ gtk_list_box_set_header_func (GTK_LIST_BOX (panel->providers_listbox),
622+ cc_list_box_update_header_func,
623+ NULL,
624+ NULL);
625+ gtk_list_box_set_sort_func (GTK_LIST_BOX (panel->providers_listbox),
626+ sort_providers_func,
627+ panel,
628+ NULL);
629+
630+ monitor = g_network_monitor_get_default();
631+
632+ g_object_bind_property (monitor, "network-available",
633+ panel->offline_label, "visible",
634+ G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN);
635+
636+ g_object_bind_property (monitor, "network-available",
637+ panel->providers_listbox, "sensitive",
638+ G_BINDING_SYNC_CREATE);
639+
640+ /* TODO: probably want to avoid _sync() ... */
641+ error = NULL;
642+ panel->client = goa_client_new_sync (NULL /* GCancellable */, &error);
643+ if (panel->client == NULL)
644+ {
645+ g_warning ("Error getting a GoaClient: %s (%s, %d)",
646+ error->message, g_quark_to_string (error->domain), error->code);
647+ gtk_widget_set_sensitive (GTK_WIDGET (panel), FALSE);
648+ g_error_free (error);
649+ return;
650+ }
651+
652+ g_signal_connect (panel->client,
653+ "account-added",
654+ G_CALLBACK (on_account_added),
655+ panel);
656+
657+ g_signal_connect (panel->client,
658+ "account-changed",
659+ G_CALLBACK (on_account_changed),
660+ panel);
661+
662+ g_signal_connect (panel->client,
663+ "account-removed",
664+ G_CALLBACK (on_account_removed),
665+ panel);
666+
667+ fill_accounts_listbox (panel);
668+ goa_provider_get_all (get_all_providers_cb, panel);
669+
670+ gtk_widget_show (GTK_WIDGET (panel));
671+}
672+
673+static const char *
674+cc_goa_panel_get_help_uri (CcPanel *panel)
675+{
676+ return "help:gnome-help/accounts";
677+}
678+
679+static void
680+cc_goa_panel_constructed (GObject *object)
681+{
682+ CcGoaPanel *self = CC_GOA_PANEL (object);
683+ GtkWindow *parent;
684+
685+ /* Setup account editor dialog */
686+ parent = GTK_WINDOW (cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (self))));
687+
688+ gtk_window_set_transient_for (GTK_WINDOW (self->edit_account_dialog), parent);
689+
690+ G_OBJECT_CLASS (cc_goa_panel_parent_class)->constructed (object);
691+}
692+
693+static void
694+cc_goa_panel_class_init (CcGoaPanelClass *klass)
695+{
696+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
697+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
698+ CcPanelClass *panel_class = CC_PANEL_CLASS (klass);
699+
700+ panel_class->get_help_uri = cc_goa_panel_get_help_uri;
701+
702+ object_class->set_property = cc_goa_panel_set_property;
703+ object_class->finalize = cc_goa_panel_finalize;
704+ object_class->constructed = cc_goa_panel_constructed;
705+ object_class->dispose = cc_goa_panel_dispose;
706+
707+ //g_object_class_override_property (object_class, PROP_PARAMETERS, "parameters");
708+
709+ gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/online-accounts/online-accounts.ui");
710+
711+ gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, accounts_frame);
712+ gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, accounts_listbox);
713+ gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, accounts_vbox);
714+ gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, edit_account_dialog);
715+ gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, edit_account_headerbar);
716+ gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, more_providers_row);
717+ gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, new_account_vbox);
718+ gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, notification_label);
719+ gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, notification_revealer);
720+ gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, offline_label);
721+ gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, providers_listbox);
722+ gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, remove_account_button);
723+ gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, stack);
724+
725+ gtk_widget_class_bind_template_callback (widget_class, on_edit_account_dialog_delete_event);
726+ gtk_widget_class_bind_template_callback (widget_class, on_listbox_row_activated);
727+ gtk_widget_class_bind_template_callback (widget_class, on_notification_closed);
728+ gtk_widget_class_bind_template_callback (widget_class, on_provider_row_activated);
729+ gtk_widget_class_bind_template_callback (widget_class, on_remove_button_clicked);
730+ gtk_widget_class_bind_template_callback (widget_class, on_undo_button_clicked);
731+}
732+
733+/* ---------------------------------------------------------------------------------------------------- */
734+
735+static void
736+show_page_nothing_selected (CcGoaPanel *panel)
737+{
738+}
739+
740+static void
741+show_page_account (CcGoaPanel *panel,
742+ GoaObject *object)
743+{
744+ GList *children;
745+ GList *l;
746+ GoaProvider *provider;
747+ GoaAccount *account;
748+ gboolean is_locked;
749+ const gchar *provider_name;
750+ const gchar *provider_type;
751+ gchar *title;
752+
753+ provider = NULL;
754+
755+ panel->active_object = object;
756+ reset_headerbar (panel);
757+
758+ /* Move to the account editor page */
759+ gtk_stack_set_visible_child_name (GTK_STACK (panel->stack), "editor");
760+
761+ /* Out with the old */
762+ children = gtk_container_get_children (GTK_CONTAINER (panel->accounts_vbox));
763+ for (l = children; l != NULL; l = l->next)
764+ gtk_container_remove (GTK_CONTAINER (panel->accounts_vbox), GTK_WIDGET (l->data));
765+ g_list_free (children);
766+
767+ account = goa_object_peek_account (object);
768+
769+ is_locked = goa_account_get_is_locked (account);
770+ gtk_widget_set_visible (panel->remove_account_button, !is_locked);
771+
772+ provider_type = goa_account_get_provider_type (account);
773+ provider = goa_provider_get_for_provider_type (provider_type);
774+
775+ if (provider != NULL)
776+ {
777+ goa_provider_show_account (provider,
778+ panel->client,
779+ object,
780+ GTK_BOX (panel->accounts_vbox),
781+ NULL,
782+ NULL);
783+ }
784+
785+ provider_name = goa_account_get_provider_name (account);
786+ /* translators: This is the title of the "Show Account" dialog. The
787+ * %s is the name of the provider. e.g., 'Google'. */
788+ title = g_strdup_printf (_("%s Account"), provider_name);
789+ gtk_header_bar_set_title (GTK_HEADER_BAR (panel->edit_account_headerbar), title);
790+ g_free (title);
791+
792+ /* Reset the dialog size */
793+ gtk_window_resize (GTK_WINDOW (panel->edit_account_dialog), 1, 1);
794+
795+ gtk_widget_show_all (panel->accounts_vbox);
796+ gtk_widget_show (panel->edit_account_dialog);
797+
798+ g_clear_object (&provider);
799+}
800+
801+/* ---------------------------------------------------------------------------------------------------- */
802+
803+static void
804+select_account_by_id (CcGoaPanel *panel,
805+ const gchar *account_id)
806+{
807+ GList *children, *l;
808+
809+ children = gtk_container_get_children (GTK_CONTAINER (panel->accounts_listbox));
810+
811+ for (l = children; l != NULL; l = l->next)
812+ {
813+ GoaAccount *account;
814+ GoaObject *row_object;
815+
816+ row_object = g_object_get_data (l->data, "goa-object");
817+ account = goa_object_peek_account (row_object);
818+
819+ if (g_strcmp0 (goa_account_get_id (account), account_id) == 0)
820+ {
821+ show_page_account (panel, row_object);
822+ break;
823+ }
824+ }
825+
826+ g_list_free (children);
827+}
828+
829+static gboolean
830+on_edit_account_dialog_delete_event (CcGoaPanel *self)
831+{
832+ self->active_object = NULL;
833+ gtk_widget_hide (self->edit_account_dialog);
834+ return TRUE;
835+}
836+
837+static void
838+on_listbox_row_activated (CcGoaPanel *self,
839+ GtkListBoxRow *activated_row)
840+{
841+ GoaObject *object;
842+
843+ object = g_object_get_data (G_OBJECT (activated_row), "goa-object");
844+ show_page_account (self, object);
845+}
846+
847+static void
848+fill_accounts_listbox (CcGoaPanel *self)
849+{
850+ GList *accounts, *l;
851+
852+ accounts = goa_client_get_accounts (self->client);
853+
854+ if (accounts == NULL)
855+ {
856+ show_page_nothing_selected (self);
857+ }
858+ else
859+ {
860+ for (l = accounts; l != NULL; l = l->next)
861+ on_account_added (self->client, l->data, self);
862+ }
863+
864+ g_list_free_full (accounts, g_object_unref);
865+}
866+
867+/* ---------------------------------------------------------------------------------------------------- */
868+
869+typedef void (*RowForAccountCallback) (CcGoaPanel *self, GtkWidget *row, GList *other_rows);
870+
871+static void
872+hide_row_for_account (CcGoaPanel *self, GtkWidget *row, GList *other_rows)
873+{
874+ gtk_widget_hide (row);
875+ gtk_widget_set_visible (self->accounts_frame, other_rows != NULL);
876+}
877+
878+static void
879+remove_row_for_account (CcGoaPanel *self, GtkWidget *row, GList *other_rows)
880+{
881+ gtk_widget_destroy (row);
882+ gtk_widget_set_visible (self->accounts_frame, other_rows != NULL);
883+}
884+
885+static void
886+show_row_for_account (CcGoaPanel *self, GtkWidget *row, GList *other_rows)
887+{
888+ gtk_widget_show (row);
889+ gtk_widget_show (self->accounts_frame);
890+}
891+
892+static void
893+modify_row_for_account (CcGoaPanel *self,
894+ GoaObject *object,
895+ RowForAccountCallback callback)
896+{
897+ GList *children, *l;
898+
899+ children = gtk_container_get_children (GTK_CONTAINER (self->accounts_listbox));
900+
901+ for (l = children; l != NULL; l = l->next)
902+ {
903+ GoaObject *row_object;
904+
905+ row_object = g_object_get_data (G_OBJECT (l->data), "goa-object");
906+ if (row_object == object)
907+ {
908+ GtkWidget *row = GTK_WIDGET (l->data);
909+
910+ children = g_list_remove_link (children, l);
911+ callback (self, row, children);
912+ g_list_free (l);
913+ break;
914+ }
915+ }
916+
917+ g_list_free (children);
918+}
919+
920+/* ---------------------------------------------------------------------------------------------------- */
921+
922+static void
923+on_account_added (GoaClient *client,
924+ GoaObject *object,
925+ gpointer user_data)
926+{
927+ CcGoaPanel *self = user_data;
928+ GtkWidget *row, *icon, *label, *box;
929+ GoaAccount *account;
930+ GError *error;
931+ GIcon *gicon;
932+ gchar* title = NULL;
933+
934+ account = goa_object_peek_account (object);
935+
936+ /* The main grid */
937+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
938+ gtk_widget_show (box);
939+
940+ /* The provider icon */
941+ icon = gtk_image_new ();
942+
943+ error = NULL;
944+ gicon = g_icon_new_for_string (goa_account_get_provider_icon (account), &error);
945+ if (error != NULL)
946+ {
947+ g_warning ("Error creating GIcon for account: %s (%s, %d)",
948+ error->message,
949+ g_quark_to_string (error->domain),
950+ error->code);
951+
952+ g_clear_error (&error);
953+ }
954+ else
955+ {
956+ gtk_image_set_from_gicon (GTK_IMAGE (icon), gicon, GTK_ICON_SIZE_DIALOG);
957+ }
958+
959+ g_object_set (icon, "margin", 6, NULL);
960+
961+ gtk_container_add (GTK_CONTAINER (box), icon);
962+
963+ /* The name of the provider */
964+ title = g_strdup_printf ("<b>%s</b>\n<small>%s</small>",
965+ goa_account_get_provider_name (account),
966+ goa_account_get_presentation_identity (account));
967+
968+ label = g_object_new (GTK_TYPE_LABEL,
969+ "ellipsize", PANGO_ELLIPSIZE_END,
970+ "label", title,
971+ "xalign", 0.0,
972+ "use-markup", TRUE,
973+ "hexpand", TRUE,
974+ NULL);
975+ gtk_container_add (GTK_CONTAINER (box), label);
976+
977+ /* "Needs attention" icon */
978+ icon = gtk_image_new_from_icon_name ("dialog-warning-symbolic", GTK_ICON_SIZE_BUTTON);
979+ gtk_widget_set_no_show_all (icon, TRUE);
980+ g_object_set (icon, "margin_end", 30, NULL);
981+ g_object_bind_property (goa_object_peek_account (object),
982+ "attention-needed",
983+ icon,
984+ "visible",
985+ G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
986+ gtk_container_add (GTK_CONTAINER (box), icon);
987+
988+ /* The row */
989+ row = gtk_list_box_row_new ();
990+ g_object_set_data (G_OBJECT (row), "goa-object", object);
991+ gtk_container_add (GTK_CONTAINER (row), box);
992+
993+ /* Add to the listbox */
994+ gtk_container_add (GTK_CONTAINER (self->accounts_listbox), row);
995+ gtk_widget_show_all (row);
996+ gtk_widget_show (self->accounts_frame);
997+
998+ g_clear_pointer (&title, g_free);
999+ g_clear_object (&gicon);
1000+}
1001+
1002+static void
1003+on_account_changed (GoaClient *client,
1004+ GoaObject *object,
1005+ gpointer user_data)
1006+{
1007+ CcGoaPanel *panel = CC_GOA_PANEL (user_data);
1008+
1009+ if (panel->active_object != object)
1010+ return;
1011+
1012+ show_page_account (panel, panel->active_object);
1013+}
1014+
1015+static void
1016+on_account_removed (GoaClient *client,
1017+ GoaObject *object,
1018+ gpointer user_data)
1019+{
1020+ CcGoaPanel *self = user_data;
1021+ modify_row_for_account (self, object, remove_row_for_account);
1022+}
1023+
1024+/* ---------------------------------------------------------------------------------------------------- */
1025+
1026+static void
1027+get_all_providers_cb (GObject *source,
1028+ GAsyncResult *res,
1029+ gpointer user_data)
1030+{
1031+ CcGoaPanel *self = user_data;
1032+ GList *providers;
1033+ GList *l;
1034+
1035+ providers = NULL;
1036+ if (!goa_provider_get_all_finish (&providers, res, NULL))
1037+ return;
1038+
1039+ for (l = providers; l != NULL; l = l->next)
1040+ {
1041+ GoaProvider *provider;
1042+ provider = GOA_PROVIDER (l->data);
1043+
1044+ add_provider_row (self, provider);
1045+ }
1046+
1047+ g_list_free_full (providers, g_object_unref);
1048+}
1049+
1050+
1051+/* ---------------------------------------------------------------------------------------------------- */
1052+
1053+static void
1054+cancel_notification_timeout (CcGoaPanel *self)
1055+{
1056+ if (self->remove_account_timeout_id == 0)
1057+ return;
1058+
1059+ g_source_remove (self->remove_account_timeout_id);
1060+
1061+ self->remove_account_timeout_id = 0;
1062+}
1063+
1064+static void
1065+remove_account_cb (GoaAccount *account,
1066+ GAsyncResult *res,
1067+ gpointer user_data)
1068+{
1069+ CcGoaPanel *panel = CC_GOA_PANEL (user_data);
1070+ GError *error;
1071+
1072+ error = NULL;
1073+ if (!goa_account_call_remove_finish (account, res, &error))
1074+ {
1075+ GtkWidget *dialog;
1076+ dialog = gtk_message_dialog_new (GTK_WINDOW (cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (panel)))),
1077+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
1078+ GTK_MESSAGE_ERROR,
1079+ GTK_BUTTONS_CLOSE,
1080+ _("Error removing account"));
1081+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
1082+ "%s",
1083+ error->message);
1084+ gtk_widget_show_all (dialog);
1085+ gtk_dialog_run (GTK_DIALOG (dialog));
1086+ gtk_widget_destroy (dialog);
1087+ g_error_free (error);
1088+ }
1089+ g_object_unref (panel);
1090+}
1091+
1092+static void
1093+on_notification_closed (GtkButton *button,
1094+ CcGoaPanel *self)
1095+{
1096+ goa_account_call_remove (goa_object_peek_account (self->removed_object),
1097+ NULL, /* GCancellable */
1098+ (GAsyncReadyCallback) remove_account_cb,
1099+ g_object_ref (self));
1100+
1101+ gtk_revealer_set_reveal_child (GTK_REVEALER (self->notification_revealer), FALSE);
1102+
1103+ cancel_notification_timeout (self);
1104+ self->removed_object = NULL;
1105+}
1106+
1107+static void
1108+on_undo_button_clicked (GtkButton *button,
1109+ CcGoaPanel *self)
1110+{
1111+ /* Simply show the account row and hide the notification */
1112+ modify_row_for_account (self, self->removed_object, show_row_for_account);
1113+ gtk_revealer_set_reveal_child (GTK_REVEALER (self->notification_revealer), FALSE);
1114+
1115+ cancel_notification_timeout (self);
1116+ self->removed_object = NULL;
1117+}
1118+
1119+static gboolean
1120+on_remove_account_timeout (gpointer user_data)
1121+{
1122+ on_notification_closed (NULL, user_data);
1123+ return G_SOURCE_REMOVE;
1124+}
1125+
1126+static void
1127+on_remove_button_clicked (CcGoaPanel *panel)
1128+{
1129+ GoaAccount *account;
1130+ gchar *label;
1131+
1132+ if (panel->active_object == NULL)
1133+ return;
1134+
1135+ if (panel->removed_object != NULL)
1136+ on_notification_closed (NULL, panel);
1137+
1138+ panel->removed_object = panel->active_object;
1139+ panel->active_object = NULL;
1140+
1141+ account = goa_object_peek_account (panel->removed_object);
1142+ /* Translators: The %s is the username (eg., debarshi.ray@gmail.com
1143+ * or rishi).
1144+ */
1145+ label = g_strdup_printf (_("<b>%s</b> removed"), goa_account_get_presentation_identity (account));
1146+ gtk_label_set_markup (GTK_LABEL (panel->notification_label), label);
1147+ gtk_revealer_set_reveal_child (GTK_REVEALER (panel->notification_revealer), TRUE);
1148+
1149+ modify_row_for_account (panel, panel->removed_object, hide_row_for_account);
1150+ gtk_widget_hide (panel->edit_account_dialog);
1151+
1152+ panel->remove_account_timeout_id = g_timeout_add_seconds (10, on_remove_account_timeout, panel);
1153+
1154+ g_free (label);
1155+}
1156+
1157+
1158+/* ---------------------------------------------------------------------------------------------------- */
1159+
1160+void
1161+cc_goa_panel_register (GIOModule *module)
1162+{
1163+ textdomain (GETTEXT_PACKAGE);
1164+ bindtextdomain (GETTEXT_PACKAGE, "/usr/share/locale");
1165+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
1166+ cc_goa_panel_register_type (G_TYPE_MODULE (module));
1167+ g_io_extension_point_implement (CC_SHELL_PANEL_EXTENSION_POINT,
1168+ CC_TYPE_GOA_PANEL,
1169+ "online-accounts", 0);
1170+}
1171
1172=== added file 'panels/online-accounts/cc-online-accounts-panel.h'
1173--- panels/online-accounts/cc-online-accounts-panel.h 1970-01-01 00:00:00 +0000
1174+++ panels/online-accounts/cc-online-accounts-panel.h 2018-02-13 09:06:22 +0000
1175@@ -0,0 +1,65 @@
1176+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
1177+/*
1178+ * Copyright (C) 2011 Red Hat, Inc.
1179+ *
1180+ * This library is free software; you can redistribute it and/or
1181+ * modify it under the terms of the GNU Lesser General Public
1182+ * License as published by the Free Software Foundation; either
1183+ * version 2 of the License, or (at your option) any later version.
1184+ *
1185+ * This library is distributed in the hope that it will be useful,
1186+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1187+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1188+ * Lesser General Public License for more details.
1189+ *
1190+ * You should have received a copy of the GNU Lesser General
1191+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
1192+ *
1193+ * Author: David Zeuthen <davidz@redhat.com>
1194+ */
1195+
1196+#ifndef __GOA_PANEL_H__
1197+#define __GOA_PANEL_H__
1198+
1199+#include <shell/cc-panel.h>
1200+
1201+G_BEGIN_DECLS
1202+
1203+#define CC_TYPE_GOA_PANEL (cc_goa_panel_get_type ())
1204+
1205+#define CC_GOA_PANEL(obj) \
1206+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
1207+ CC_TYPE_GOA_PANEL, CcGoaPanel))
1208+
1209+#define CC_GOA_PANEL_CLASS(klass) \
1210+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
1211+ CC_TYPE_GOA_PANEL, CcGoaPanelClass))
1212+
1213+#define CC_IS_GOA_PANEL(obj) \
1214+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
1215+ CC_TYPE_GOA_PANEL))
1216+
1217+#define CC_IS_GOA_PANEL_CLASS(klass) \
1218+ (G_TYPE_CHECK_CLASS_TYPE ((klass), \
1219+ CC_TYPE_GOA_PANEL))
1220+
1221+#define CC_GOA_PANEL_GET_CLASS(obj) \
1222+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
1223+ CC_TYPE_GOA_PANEL, CcGoaPanelClass))
1224+
1225+typedef struct _CcGoaPanel CcGoaPanel;
1226+typedef struct _CcGoaPanelClass CcGoaPanelClass;
1227+typedef struct _CcGoaPanelPrivate CcGoaPanelPrivate;
1228+
1229+struct _CcGoaPanelClass
1230+{
1231+ CcPanelClass parent_class;
1232+};
1233+
1234+GType cc_goa_panel_get_type (void) G_GNUC_CONST;
1235+
1236+void cc_goa_panel_register (GIOModule *module);
1237+
1238+G_END_DECLS
1239+
1240+#endif /* __GOA_PANEL_H__ */
1241
1242=== added directory 'panels/online-accounts/icons'
1243=== added directory 'panels/online-accounts/icons/16x16'
1244=== added file 'panels/online-accounts/icons/16x16/Makefile.am'
1245--- panels/online-accounts/icons/16x16/Makefile.am 1970-01-01 00:00:00 +0000
1246+++ panels/online-accounts/icons/16x16/Makefile.am 2018-02-13 09:06:22 +0000
1247@@ -0,0 +1,14 @@
1248+NULL =
1249+
1250+icondir = $(datadir)/icons/hicolor/16x16/apps
1251+icon_DATA = \
1252+ unity-online-accounts.png \
1253+ $(NULL)
1254+
1255+EXTRA_DIST = \
1256+ $(icon_DATA)
1257+
1258+clean-local :
1259+ rm -f *~
1260+
1261+-include $(top_srcdir)/git.mk
1262
1263=== added file 'panels/online-accounts/icons/16x16/unity-online-accounts.png'
1264Binary files panels/online-accounts/icons/16x16/unity-online-accounts.png 1970-01-01 00:00:00 +0000 and panels/online-accounts/icons/16x16/unity-online-accounts.png 2018-02-13 09:06:22 +0000 differ
1265=== added directory 'panels/online-accounts/icons/22x22'
1266=== added file 'panels/online-accounts/icons/22x22/Makefile.am'
1267--- panels/online-accounts/icons/22x22/Makefile.am 1970-01-01 00:00:00 +0000
1268+++ panels/online-accounts/icons/22x22/Makefile.am 2018-02-13 09:06:22 +0000
1269@@ -0,0 +1,14 @@
1270+NULL =
1271+
1272+icondir = $(datadir)/icons/hicolor/22x22/apps
1273+icon_DATA = \
1274+ unity-online-accounts.png \
1275+ $(NULL)
1276+
1277+EXTRA_DIST = \
1278+ $(icon_DATA)
1279+
1280+clean-local :
1281+ rm -f *~
1282+
1283+-include $(top_srcdir)/git.mk
1284
1285=== added file 'panels/online-accounts/icons/22x22/unity-online-accounts.png'
1286Binary files panels/online-accounts/icons/22x22/unity-online-accounts.png 1970-01-01 00:00:00 +0000 and panels/online-accounts/icons/22x22/unity-online-accounts.png 2018-02-13 09:06:22 +0000 differ
1287=== added directory 'panels/online-accounts/icons/24x24'
1288=== added file 'panels/online-accounts/icons/24x24/Makefile.am'
1289--- panels/online-accounts/icons/24x24/Makefile.am 1970-01-01 00:00:00 +0000
1290+++ panels/online-accounts/icons/24x24/Makefile.am 2018-02-13 09:06:22 +0000
1291@@ -0,0 +1,14 @@
1292+NULL =
1293+
1294+icondir = $(datadir)/icons/hicolor/24x24/apps
1295+icon_DATA = \
1296+ unity-online-accounts.png \
1297+ $(NULL)
1298+
1299+EXTRA_DIST = \
1300+ $(icon_DATA)
1301+
1302+clean-local :
1303+ rm -f *~
1304+
1305+-include $(top_srcdir)/git.mk
1306
1307=== added file 'panels/online-accounts/icons/24x24/unity-online-accounts.png'
1308Binary files panels/online-accounts/icons/24x24/unity-online-accounts.png 1970-01-01 00:00:00 +0000 and panels/online-accounts/icons/24x24/unity-online-accounts.png 2018-02-13 09:06:22 +0000 differ
1309=== added directory 'panels/online-accounts/icons/256x256'
1310=== added file 'panels/online-accounts/icons/256x256/Makefile.am'
1311--- panels/online-accounts/icons/256x256/Makefile.am 1970-01-01 00:00:00 +0000
1312+++ panels/online-accounts/icons/256x256/Makefile.am 2018-02-13 09:06:22 +0000
1313@@ -0,0 +1,14 @@
1314+NULL =
1315+
1316+icondir = $(datadir)/icons/hicolor/256x256/apps
1317+icon_DATA = \
1318+ unity-online-accounts.png \
1319+ $(NULL)
1320+
1321+EXTRA_DIST = \
1322+ $(icon_DATA)
1323+
1324+clean-local :
1325+ rm -f *~
1326+
1327+-include $(top_srcdir)/git.mk
1328
1329=== added file 'panels/online-accounts/icons/256x256/unity-online-accounts.png'
1330Binary files panels/online-accounts/icons/256x256/unity-online-accounts.png 1970-01-01 00:00:00 +0000 and panels/online-accounts/icons/256x256/unity-online-accounts.png 2018-02-13 09:06:22 +0000 differ
1331=== added directory 'panels/online-accounts/icons/32x32'
1332=== added file 'panels/online-accounts/icons/32x32/Makefile.am'
1333--- panels/online-accounts/icons/32x32/Makefile.am 1970-01-01 00:00:00 +0000
1334+++ panels/online-accounts/icons/32x32/Makefile.am 2018-02-13 09:06:22 +0000
1335@@ -0,0 +1,14 @@
1336+NULL =
1337+
1338+icondir = $(datadir)/icons/hicolor/32x32/apps
1339+icon_DATA = \
1340+ unity-online-accounts.png \
1341+ $(NULL)
1342+
1343+EXTRA_DIST = \
1344+ $(icon_DATA)
1345+
1346+clean-local :
1347+ rm -f *~
1348+
1349+-include $(top_srcdir)/git.mk
1350
1351=== added file 'panels/online-accounts/icons/32x32/unity-online-accounts.png'
1352Binary files panels/online-accounts/icons/32x32/unity-online-accounts.png 1970-01-01 00:00:00 +0000 and panels/online-accounts/icons/32x32/unity-online-accounts.png 2018-02-13 09:06:22 +0000 differ
1353=== added directory 'panels/online-accounts/icons/48x48'
1354=== added file 'panels/online-accounts/icons/48x48/Makefile.am'
1355--- panels/online-accounts/icons/48x48/Makefile.am 1970-01-01 00:00:00 +0000
1356+++ panels/online-accounts/icons/48x48/Makefile.am 2018-02-13 09:06:22 +0000
1357@@ -0,0 +1,14 @@
1358+NULL =
1359+
1360+icondir = $(datadir)/icons/hicolor/48x48/apps
1361+icon_DATA = \
1362+ unity-online-accounts.png \
1363+ $(NULL)
1364+
1365+EXTRA_DIST = \
1366+ $(icon_DATA)
1367+
1368+clean-local :
1369+ rm -f *~
1370+
1371+-include $(top_srcdir)/git.mk
1372
1373=== added file 'panels/online-accounts/icons/48x48/unity-online-accounts.png'
1374Binary files panels/online-accounts/icons/48x48/unity-online-accounts.png 1970-01-01 00:00:00 +0000 and panels/online-accounts/icons/48x48/unity-online-accounts.png 2018-02-13 09:06:22 +0000 differ
1375=== added file 'panels/online-accounts/icons/Makefile.am'
1376--- panels/online-accounts/icons/Makefile.am 1970-01-01 00:00:00 +0000
1377+++ panels/online-accounts/icons/Makefile.am 2018-02-13 09:06:22 +0000
1378@@ -0,0 +1,23 @@
1379+
1380+SUBDIRS = 16x16 22x22 24x24 32x32 48x48 256x256
1381+
1382+gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor
1383+
1384+if MAINTAINER_MODE
1385+
1386+install-data-hook:
1387+ @-if test -z "$(DESTDIR)"; then \
1388+ echo "Updating Gtk icon cache."; \
1389+ $(gtk_update_icon_cache); \
1390+ else \
1391+ echo "*** Icon cache not updated. After install, run this:"; \
1392+ echo "*** $(gtk_update_icon_cache)"; \
1393+ fi
1394+
1395+endif
1396+
1397+clean-local :
1398+ rm -f *~
1399+
1400+
1401+-include $(top_srcdir)/git.mk
1402
1403=== added file 'panels/online-accounts/online-accounts-module.c'
1404--- panels/online-accounts/online-accounts-module.c 1970-01-01 00:00:00 +0000
1405+++ panels/online-accounts/online-accounts-module.c 2018-02-13 09:06:22 +0000
1406@@ -0,0 +1,33 @@
1407+/*
1408+ * Copyright (C) 2011 Red Hat, Inc
1409+ *
1410+ * This program is free software; you can redistribute it and/or modify
1411+ * it under the terms of the GNU General Public License as published by
1412+ * the Free Software Foundation; either version 2 of the License, or
1413+ * (at your option) any later version.
1414+ *
1415+ * This program is distributed in the hope that it will be useful,
1416+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1417+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1418+ * GNU General Public License for more details.
1419+ *
1420+ * You should have received a copy of the GNU General Public License
1421+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
1422+ *
1423+ */
1424+
1425+#include <config.h>
1426+#include "cc-online-accounts-panel.h"
1427+#include <glib/gi18n.h>
1428+
1429+void
1430+g_io_module_load (GIOModule *module)
1431+{
1432+ /* register the panel */
1433+ cc_goa_panel_register (module);
1434+}
1435+
1436+void
1437+g_io_module_unload (GIOModule *module)
1438+{
1439+}
1440
1441=== added file 'panels/online-accounts/online-accounts.gresource.xml'
1442--- panels/online-accounts/online-accounts.gresource.xml 1970-01-01 00:00:00 +0000
1443+++ panels/online-accounts/online-accounts.gresource.xml 2018-02-13 09:06:22 +0000
1444@@ -0,0 +1,6 @@
1445+<?xml version="1.0" encoding="UTF-8"?>
1446+<gresources>
1447+ <gresource prefix="/org/gnome/control-center/online-accounts">
1448+ <file preprocess="xml-stripblanks">online-accounts.ui</file>
1449+ </gresource>
1450+</gresources>
1451
1452=== added file 'panels/online-accounts/online-accounts.ui'
1453--- panels/online-accounts/online-accounts.ui 1970-01-01 00:00:00 +0000
1454+++ panels/online-accounts/online-accounts.ui 2018-02-13 09:06:22 +0000
1455@@ -0,0 +1,270 @@
1456+<?xml version="1.0" encoding="UTF-8"?>
1457+<interface>
1458+ <!-- interface-requires gtk+ 3.0 -->
1459+ <template class="CcGoaPanel" parent="CcPanel">
1460+ <property name="visible">True</property>
1461+ <property name="can_focus">False</property>
1462+ <child>
1463+ <object class="GtkOverlay">
1464+ <property name="visible">True</property>
1465+ <property name="can_focus">False</property>
1466+ <child type="overlay">
1467+ <object class="GtkRevealer" id="notification_revealer">
1468+ <property name="visible">True</property>
1469+ <property name="can_focus">False</property>
1470+ <property name="halign">center</property>
1471+ <property name="valign">start</property>
1472+ <property name="transition_type">slide-down</property>
1473+ <child>
1474+ <object class="GtkFrame">
1475+ <property name="visible">True</property>
1476+ <property name="can_focus">False</property>
1477+ <child>
1478+ <object class="GtkBox">
1479+ <property name="visible">True</property>
1480+ <property name="can_focus">False</property>
1481+ <property name="spacing">12</property>
1482+ <child>
1483+ <object class="GtkLabel" id="notification_label">
1484+ <property name="visible">True</property>
1485+ <property name="can_focus">False</property>
1486+ <property name="use_markup">True</property>
1487+ </object>
1488+ </child>
1489+ <child>
1490+ <object class="GtkButton" id="undo_button">
1491+ <property name="visible">True</property>
1492+ <property name="can_focus">True</property>
1493+ <property name="label" translatable="yes">Undo</property>
1494+ <signal name="clicked" handler="on_undo_button_clicked" object="CcGoaPanel" swapped="no" />
1495+ </object>
1496+ </child>
1497+ <child>
1498+ <object class="GtkButton">
1499+ <property name="visible">True</property>
1500+ <property name="can_focus">True</property>
1501+ <property name="relief">none</property>
1502+ <signal name="clicked" handler="on_notification_closed" object="CcGoaPanel" swapped="no" />
1503+ <child>
1504+ <object class="GtkImage">
1505+ <property name="visible">True</property>
1506+ <property name="can_focus">False</property>
1507+ <property name="icon-name">window-close-symbolic</property>
1508+ </object>
1509+ </child>
1510+ </object>
1511+ </child>
1512+ </object>
1513+ </child>
1514+ <style>
1515+ <class name="app-notification" />
1516+ </style>
1517+ </object>
1518+ </child>
1519+ </object>
1520+ </child>
1521+ <child>
1522+ <object class="GtkScrolledWindow">
1523+ <property name="visible">True</property>
1524+ <property name="can_focus">True</property>
1525+ <property name="hscrollbar_policy">never</property>
1526+ <property name="min_content_height">500</property>
1527+ <child>
1528+ <object class="GtkGrid">
1529+ <property name="visible">True</property>
1530+ <property name="can_focus">False</property>
1531+ <property name="row-spacing">18</property>
1532+ <property name="column-spacing">18</property>
1533+ <property name="orientation">vertical</property>
1534+ <property name="margin_start">32</property>
1535+ <property name="margin_end">32</property>
1536+ <property name="margin_top">32</property>
1537+ <property name="margin_bottom">22</property>
1538+ <property name="hexpand">True</property>
1539+ <property name="width-request">300</property>
1540+
1541+ <!--
1542+ Stub boxes to pull the widgets to the middle, and yet allow them to
1543+ grow and cover a third of the available space
1544+ -->
1545+ <child>
1546+ <object class="GtkBox">
1547+ <property name="visible">True</property>
1548+ <property name="hexpand">True</property>
1549+ </object>
1550+ <packing>
1551+ <property name="top-attach">0</property>
1552+ <property name="left-attach">0</property>
1553+ </packing>
1554+ </child>
1555+
1556+ <child>
1557+ <object class="GtkBox">
1558+ <property name="visible">True</property>
1559+ <property name="hexpand">True</property>
1560+ </object>
1561+ <packing>
1562+ <property name="top-attach">0</property>
1563+ <property name="left-attach">2</property>
1564+ </packing>
1565+ </child>
1566+
1567+ <child>
1568+ <object class="GtkBox">
1569+ <property name="visible">True</property>
1570+ <property name="can_focus">False</property>
1571+ <property name="spacing">12</property>
1572+ <property name="orientation">vertical</property>
1573+ <property name="hexpand">True</property>
1574+ <property name="width-request">300</property>
1575+ <child>
1576+ <object class="GtkLabel" id="offline_label">
1577+ <property name="visible">True</property>
1578+ <property name="can_focus">False</property>
1579+ <property name="wrap">True</property>
1580+ <property name="label" translatable="yes">No internet connection — connect to set up new online accounts</property>
1581+ </object>
1582+ </child>
1583+ <child>
1584+ <object class="GtkFrame" id="accounts_frame">
1585+ <property name="can_focus">False</property>
1586+ <child>
1587+ <object class="GtkListBox" id="accounts_listbox">
1588+ <property name="visible">True</property>
1589+ <property name="can_focus">True</property>
1590+ <property name="selection_mode">none</property>
1591+ <signal name="row-activated" handler="on_listbox_row_activated" object="CcGoaPanel" swapped="yes" />
1592+ </object>
1593+ </child>
1594+ </object>
1595+ </child>
1596+ <child>
1597+ <object class="GtkLabel">
1598+ <property name="visible">True</property>
1599+ <property name="can_focus">False</property>
1600+ <property name="margin-top">24</property>
1601+ <property name="xalign">0</property>
1602+ <property name="label" translatable="yes">Add an account</property>
1603+ <attributes>
1604+ <attribute name="weight" value="bold" />
1605+ </attributes>
1606+ </object>
1607+ </child>
1608+ <child>
1609+ <object class="GtkFrame">
1610+ <property name="visible">True</property>
1611+ <property name="can_focus">False</property>
1612+ <child>
1613+ <object class="GtkListBox" id="providers_listbox">
1614+ <property name="visible">True</property>
1615+ <property name="can_focus">True</property>
1616+ <property name="selection_mode">none</property>
1617+ <signal name="row-activated" handler="on_provider_row_activated" object="CcGoaPanel" swapped="yes" />
1618+ <child>
1619+ <object class="GtkListBoxRow" id="more_providers_row">
1620+ <property name="visible">True</property>
1621+ <property name="can_focus">True</property>
1622+ <child>
1623+ <object class="GtkImage">
1624+ <property name="visible">True</property>
1625+ <property name="can_focus">False</property>
1626+ <property name="hexpand">True</property>
1627+ <property name="margin">22</property>
1628+ <property name="icon-name">view-more-symbolic</property>
1629+ </object>
1630+ </child>
1631+ </object>
1632+ </child>
1633+ </object>
1634+ </child>
1635+ </object>
1636+ </child>
1637+ </object>
1638+ <packing>
1639+ <property name="top-attach">0</property>
1640+ <property name="left-attach">1</property>
1641+ </packing>
1642+ </child>
1643+ </object>
1644+ </child>
1645+ </object>
1646+ </child>
1647+ </object>
1648+ </child>
1649+ </template>
1650+ <object class="GtkDialog" id="edit_account_dialog">
1651+ <property name="can_focus">False</property>
1652+ <property name="type_hint">dialog</property>
1653+ <property name="use_header_bar">1</property>
1654+ <property name="resizable">True</property>
1655+ <property name="modal">True</property>
1656+ <signal name="delete-event" handler="on_edit_account_dialog_delete_event" object="CcGoaPanel" swapped="yes" />
1657+ <child type="titlebar">
1658+ <object class="GtkHeaderBar" id="edit_account_headerbar">
1659+ <property name="visible">True</property>
1660+ <property name="can_focus">False</property>
1661+ <property name="show_close_button">False</property>
1662+ </object>
1663+ </child>
1664+ <child internal-child="vbox">
1665+ <object class="GtkBox">
1666+ <property name="can_focus">False</property>
1667+ <property name="orientation">vertical</property>
1668+ <property name="border_width">0</property>
1669+ <child>
1670+ <object class="GtkStack" id="stack">
1671+ <property name="visible">True</property>
1672+ <property name="can_focus">False</property>
1673+ <property name="transition_type">crossfade</property>
1674+ <property name="homogeneous">False</property>
1675+ <child>
1676+ <object class="GtkBox" id="new_account_vbox">
1677+ <property name="visible">True</property>
1678+ <property name="can_focus">False</property>
1679+ </object>
1680+ <packing>
1681+ <property name="name">new-account</property>
1682+ </packing>
1683+ </child>
1684+ <child>
1685+ <object class="GtkBox">
1686+ <property name="visible">True</property>
1687+ <property name="can_focus">False</property>
1688+ <property name="margin">24</property>
1689+ <property name="spacing">24</property>
1690+ <property name="orientation">vertical</property>
1691+ <child>
1692+ <object class="GtkBox" id="accounts_vbox">
1693+ <property name="visible">True</property>
1694+ <property name="can_focus">False</property>
1695+ <property name="vexpand">True</property>
1696+ <property name="orientation">vertical</property>
1697+ <property name="margin-start">18</property>
1698+ <property name="margin-end">18</property>
1699+ <property name="spacing">18</property>
1700+ </object>
1701+ </child>
1702+ <child>
1703+ <object class="GtkButton" id="remove_account_button">
1704+ <property name="visible">True</property>
1705+ <property name="can_focus">True</property>
1706+ <property name="valign">end</property>
1707+ <property name="halign">end</property>
1708+ <property name="label" translatable="yes">Remove Account</property>
1709+ <signal name="clicked" handler="on_remove_button_clicked" object="CcGoaPanel" swapped="yes" />
1710+ <style>
1711+ <class name="destructive-action" />
1712+ </style>
1713+ </object>
1714+ </child>
1715+ </object>
1716+ <packing>
1717+ <property name="name">editor</property>
1718+ </packing>
1719+ </child>
1720+ </object>
1721+ </child>
1722+ </object>
1723+ </child>
1724+ </object>
1725+</interface>
1726
1727=== added file 'panels/online-accounts/unity-online-accounts-panel.desktop.in.in'
1728--- panels/online-accounts/unity-online-accounts-panel.desktop.in.in 1970-01-01 00:00:00 +0000
1729+++ panels/online-accounts/unity-online-accounts-panel.desktop.in.in 2018-02-13 09:06:22 +0000
1730@@ -0,0 +1,15 @@
1731+[Desktop Entry]
1732+Exec=unity-control-center online-accounts
1733+Icon=unity-online-accounts
1734+Terminal=false
1735+Type=Application
1736+NoDisplay=false
1737+StartupNotify=true
1738+Categories=GNOME;GTK;Settings;DesktopSettings;X-Unity-Settings-Panel;X-GNOME-PersonalSettings;OnlineAccounts;
1739+OnlyShowIn=Unity;
1740+X-Unity-Settings-Panel=online-accounts
1741+# Translators: those are keywords for the online-accounts control-center panel
1742+Keywords=Google;Facebook;Twitter;Yahoo;Web;Online;Chat;Calendar;Mail;Contact;ownCloud;Kerberos;IMAP;SMTP;Pocket;ReadItLater;
1743+Name=Online Accounts
1744+Comment=Connect your online accounts
1745+X-Ubuntu-Gettext-Domain=unity-control-center
1746
1747=== modified file 'po/POTFILES.in'
1748--- po/POTFILES.in 2017-12-07 05:45:44 +0000
1749+++ po/POTFILES.in 2018-02-13 09:06:22 +0000
1750@@ -92,7 +92,10 @@
1751 panels/screen-sharing/vino-message-box.c
1752 panels/screen-sharing/cc-screen-sharing-panel.c
1753 panels/screen-sharing/unity-screen-sharing-panel.desktop.in.in
1754-[type: gettext/glade]panels/screen-sharing/cc-screen-sharing-panel.ui
1755+[type: gettext/glade]panels/screen-sharing/screen-sharing-panel.ui
1756+panels/online-accounts/cc-online-accounts-panel.c
1757+panels/online-accounts/unity-online-accounts-panel.desktop.in.in
1758+[type: gettext/glade]panels/online-accounts/online-accounts.ui
1759 panels/sound/cc-sound-panel.c
1760 panels/sound/gvc-balance-bar.c
1761 panels/sound/gvc-channel-bar.c
1762
1763=== modified file 'shell/Makefile.am'
1764--- shell/Makefile.am 2017-04-06 13:23:05 +0000
1765+++ shell/Makefile.am 2018-02-13 09:06:22 +0000
1766@@ -54,6 +54,8 @@
1767 cc-shell.h \
1768 cc-editable-entry.c \
1769 cc-editable-entry.h \
1770+ list-box-helper.h \
1771+ list-box-helper.c \
1772 $(NULL)
1773
1774 libunity_control_center_la_LDFLAGS = \
1775
1776=== added file 'shell/list-box-helper.c'
1777--- shell/list-box-helper.c 1970-01-01 00:00:00 +0000
1778+++ shell/list-box-helper.c 2018-02-13 09:06:22 +0000
1779@@ -0,0 +1,110 @@
1780+/*
1781+ * Copyright (C) 2014 Red Hat, Inc
1782+ *
1783+ * This program is free software; you can redistribute it and/or modify
1784+ * it under the terms of the GNU General Public License as published by
1785+ * the Free Software Foundation; either version 2 of the License, or
1786+ * (at your option) any later version.
1787+ *
1788+ * This program is distributed in the hope that it will be useful,
1789+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1790+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1791+ * GNU General Public License for more details.
1792+ *
1793+ * You should have received a copy of the GNU General Public License
1794+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
1795+ *
1796+ */
1797+
1798+#include "list-box-helper.h"
1799+
1800+#define MAX_ROWS_VISIBLE 5
1801+
1802+void
1803+cc_list_box_update_header_func (GtkListBoxRow *row,
1804+ GtkListBoxRow *before,
1805+ gpointer user_data)
1806+{
1807+ GtkWidget *current;
1808+
1809+ if (before == NULL)
1810+ {
1811+ gtk_list_box_row_set_header (row, NULL);
1812+ return;
1813+ }
1814+
1815+ current = gtk_list_box_row_get_header (row);
1816+ if (current == NULL)
1817+ {
1818+ current = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
1819+ gtk_widget_show (current);
1820+ gtk_list_box_row_set_header (row, current);
1821+ }
1822+}
1823+
1824+void
1825+cc_list_box_adjust_scrolling (GtkListBox *listbox)
1826+{
1827+ GtkWidget *scrolled_window;
1828+ GList *children;
1829+ guint n_rows, num_max_rows;
1830+
1831+ scrolled_window = g_object_get_data (G_OBJECT (listbox), "cc-scrolling-scrolled-window");
1832+ if (!scrolled_window)
1833+ return;
1834+
1835+ children = gtk_container_get_children (GTK_CONTAINER (listbox));
1836+ n_rows = g_list_length (children);
1837+
1838+ num_max_rows = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (listbox), "cc-max-rows-visible"));
1839+
1840+ if (n_rows >= num_max_rows)
1841+ {
1842+ gint total_row_height = 0;
1843+ GList *l;
1844+ guint i;
1845+
1846+ for (l = children, i = 0; l != NULL && i < num_max_rows; l = l->next, i++) {
1847+ gint row_height;
1848+ gtk_widget_get_preferred_height (GTK_WIDGET (l->data), &row_height, NULL);
1849+ total_row_height += row_height;
1850+ }
1851+
1852+ gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (scrolled_window), total_row_height);
1853+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1854+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1855+ }
1856+ else
1857+ {
1858+ gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (scrolled_window), -1);
1859+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1860+ GTK_POLICY_NEVER, GTK_POLICY_NEVER);
1861+ }
1862+
1863+ g_list_free (children);
1864+}
1865+
1866+void
1867+cc_list_box_setup_scrolling (GtkListBox *listbox,
1868+ guint num_max_rows)
1869+{
1870+ GtkWidget *parent;
1871+ GtkWidget *scrolled_window;
1872+
1873+ parent = gtk_widget_get_parent (GTK_WIDGET (listbox));
1874+ scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1875+ gtk_widget_show (scrolled_window);
1876+
1877+ g_object_ref (listbox);
1878+ gtk_container_remove (GTK_CONTAINER (parent), GTK_WIDGET (listbox));
1879+ gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (listbox));
1880+ g_object_unref (listbox);
1881+
1882+ gtk_container_add (GTK_CONTAINER (parent), scrolled_window);
1883+
1884+ if (num_max_rows == 0)
1885+ num_max_rows = MAX_ROWS_VISIBLE;
1886+
1887+ g_object_set_data (G_OBJECT (listbox), "cc-scrolling-scrolled-window", scrolled_window);
1888+ g_object_set_data (G_OBJECT (listbox), "cc-max-rows-visible", GUINT_TO_POINTER (num_max_rows));
1889+}
1890
1891=== added file 'shell/list-box-helper.h'
1892--- shell/list-box-helper.h 1970-01-01 00:00:00 +0000
1893+++ shell/list-box-helper.h 2018-02-13 09:06:22 +0000
1894@@ -0,0 +1,31 @@
1895+/*
1896+ * Copyright (C) 2014 Red Hat, Inc
1897+ *
1898+ * This program is free software; you can redistribute it and/or modify
1899+ * it under the terms of the GNU General Public License as published by
1900+ * the Free Software Foundation; either version 2 of the License, or
1901+ * (at your option) any later version.
1902+ *
1903+ * This program is distributed in the hope that it will be useful,
1904+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1905+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1906+ * GNU General Public License for more details.
1907+ *
1908+ * You should have received a copy of the GNU General Public License
1909+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
1910+ *
1911+ */
1912+
1913+#include <gtk/gtk.h>
1914+
1915+void
1916+cc_list_box_update_header_func (GtkListBoxRow *row,
1917+ GtkListBoxRow *before,
1918+ gpointer user_data);
1919+
1920+void
1921+cc_list_box_adjust_scrolling (GtkListBox *listbox);
1922+
1923+void
1924+cc_list_box_setup_scrolling (GtkListBox *listbox,
1925+ guint num_rows);

Subscribers

People subscribed via source and target branches