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

Proposed by Khurshid Alam
Status: Merged
Approved by: Jeremy Bícha
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 Bícha Approve
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.
Revision history for this message
Jeremy Bícha (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

Revision history for this message
Jeremy Bícha (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
=== modified file 'configure.ac'
--- configure.ac 2017-12-07 05:41:33 +0000
+++ configure.ac 2018-02-13 09:06:22 +0000
@@ -119,7 +119,7 @@
119SCHEMAS_REQUIRED_VERSION=3.15.4119SCHEMAS_REQUIRED_VERSION=3.15.4
120LIBWACOM_REQUIRED_VERSION=0.7120LIBWACOM_REQUIRED_VERSION=0.7
121CLUTTER_REQUIRED_VERSION=1.11.3121CLUTTER_REQUIRED_VERSION=1.11.3
122GOA_REQUIRED_VERSION=3.5.90122GOA_REQUIRED_VERSION=3.18.0
123ACCOUNTSSERVICE_REQUIRED_VERSION=0.6.30123ACCOUNTSSERVICE_REQUIRED_VERSION=0.6.30
124124
125COMMON_MODULES="gtk+-3.0 >= $GTK_REQUIRED_VERSION125COMMON_MODULES="gtk+-3.0 >= $GTK_REQUIRED_VERSION
@@ -262,6 +262,34 @@
262esac262esac
263AM_CONDITIONAL(BUILD_WACOM, [test x"$have_wacom" = x"yes"])263AM_CONDITIONAL(BUILD_WACOM, [test x"$have_wacom" = x"yes"])
264264
265# Online accounts
266AC_ARG_ENABLE(onlineaccounts, AC_HELP_STRING([--disable-onlineaccounts], [disable online-accounts panel]),
267 [case "${enableval}" in
268 yes) enable_onlineaccounts=yes ;;
269 no) enable_onlineaccounts=no ;;
270 *) AC_MSG_ERROR(bad value ${enableval} for --disable-onlineaccounts) ;;
271 esac],
272 [enable_onlineaccounts=yes]) dnl Enabled by default
273
274if test "x$enable_onlineaccounts" = xyes; then
275 PKG_CHECK_MODULES(ONLINE_ACCOUNTS_PANEL, $COMMON_MODULES goa-1.0
276 goa-backend-1.0 >= $GOA_REQUIRED_VERSION,
277 [have_onlineaccounts=yes], have_onlineaccounts=no)
278 if test "x$have_onlineaccounts" = xno ; then
279 AC_MSG_ERROR(*** Gnome Online Accounts not found ***)
280 fi
281
282 AC_DEFINE(BUILD_ONLINE_ACCOUNTS, 1, [Define to 1 to build the online-accounts panel])
283
284 if test x${have_onlineaccounts} = xyes; then
285 AC_DEFINE(HAVE_ONLINE_ACCOUNTS, 1, [Define to 1 if Gnome Online Accounts is available])
286 fi
287fi
288
289AM_CONDITIONAL(BUILD_ONLINE_ACCOUNTS, [test x$have_onlineaccounts = xyes])
290AC_SUBST(ONLINE_ACCOUNTS_CFLAGS)
291AC_SUBST(ONLINE_ACCOUNTS_LIBS)
292
265# This is a hard-dependency for the region and user-accounts panels293# This is a hard-dependency for the region and user-accounts panels
266PKG_CHECK_MODULES(ISOCODES, iso-codes)294PKG_CHECK_MODULES(ISOCODES, iso-codes)
267295
@@ -495,6 +523,15 @@
495panels/wacom/Makefile523panels/wacom/Makefile
496panels/wacom/calibrator/Makefile524panels/wacom/calibrator/Makefile
497panels/wacom/unity-wacom-panel.desktop.in525panels/wacom/unity-wacom-panel.desktop.in
526panels/online-accounts/Makefile
527panels/online-accounts/unity-online-accounts-panel.desktop.in
528panels/online-accounts/icons/Makefile
529panels/online-accounts/icons/16x16/Makefile
530panels/online-accounts/icons/22x22/Makefile
531panels/online-accounts/icons/24x24/Makefile
532panels/online-accounts/icons/32x32/Makefile
533panels/online-accounts/icons/48x48/Makefile
534panels/online-accounts/icons/256x256/Makefile
498po/Makefile.in535po/Makefile.in
499shell/appdata/Makefile536shell/appdata/Makefile
500shell/Makefile537shell/Makefile
@@ -538,4 +575,9 @@
538else575else
539 AC_MSG_NOTICE([ Region panel Fcitx support disabled])576 AC_MSG_NOTICE([ Region panel Fcitx support disabled])
540fi577fi
578if test "x$have_onlineaccounts" = "xyes"; then
579 AC_MSG_NOTICE([** Online-Accounts support (Online-Accounts panel)])
580else
581 AC_MSG_NOTICE([ Online-Accounts support disabled])
582fi
541AC_MSG_NOTICE([End options])583AC_MSG_NOTICE([End options])
542584
=== modified file 'debian/control'
--- debian/control 2017-09-30 22:30:57 +0000
+++ debian/control 2018-02-13 09:06:22 +0000
@@ -29,7 +29,8 @@
29 libgnome-desktop-3-dev (>= 3.5.91),29 libgnome-desktop-3-dev (>= 3.5.91),
30 libgnome-menu-3-dev,30 libgnome-menu-3-dev,
31 libgnomekbd-dev,31 libgnomekbd-dev,
32 libgoa-1.0-dev (>= 3.5.90),32 libgoa-1.0-dev (>= 3.18.0),
33 libgoa-backend-1.0-dev (>= 3.18.0),
33 libgtk-3-dev (>= 3.10.0),34 libgtk-3-dev (>= 3.10.0),
34 libgtop2-dev,35 libgtop2-dev,
35 libibus-1.0-dev (>= 1.5.0),36 libibus-1.0-dev (>= 1.5.0),
@@ -73,6 +74,7 @@
73 gnome-desktop3-data,74 gnome-desktop3-data,
74 adwaita-icon-theme,75 adwaita-icon-theme,
75 gnome-menus (>= 2.12.0),76 gnome-menus (>= 2.12.0),
77 gnome-online-accounts,
76 unity-settings-daemon,78 unity-settings-daemon,
77 gnome-settings-daemon-schemas (>= 3.16),79 gnome-settings-daemon-schemas (>= 3.16),
78 gsettings-desktop-schemas (>= 3.15.4),80 gsettings-desktop-schemas (>= 3.15.4),
7981
=== modified file 'debian/libunity-control-center1.symbols'
--- debian/libunity-control-center1.symbols 2014-06-26 02:58:37 +0000
+++ debian/libunity-control-center1.symbols 2018-02-13 09:06:22 +0000
@@ -18,6 +18,9 @@
18 cc_editable_entry_set_text@Base 14.04.018 cc_editable_entry_set_text@Base 14.04.0
19 cc_editable_entry_set_weight@Base 14.04.019 cc_editable_entry_set_weight@Base 14.04.0
20 cc_editable_entry_set_width_chars@Base 14.04.3+14.04.2014022520 cc_editable_entry_set_width_chars@Base 14.04.3+14.04.20140225
21 cc_list_box_adjust_scrolling@Base 15.04.0+17.10.20171225
22 cc_list_box_setup_scrolling@Base 15.04.0+17.10.20171225
23 cc_list_box_update_header_func@Base 15.04.0+17.10.20171225
21 cc_panel_get_display_name@Base 14.04.024 cc_panel_get_display_name@Base 14.04.0
22 cc_panel_get_help_uri@Base 14.04.025 cc_panel_get_help_uri@Base 14.04.0
23 cc_panel_get_permission@Base 14.04.026 cc_panel_get_permission@Base 14.04.0
2427
=== modified file 'panels/Makefile.am'
--- panels/Makefile.am 2017-12-07 05:41:33 +0000
+++ panels/Makefile.am 2018-02-13 09:06:22 +0000
@@ -28,4 +28,8 @@
28SUBDIRS += network28SUBDIRS += network
29endif29endif
3030
31if BUILD_ONLINE_ACCOUNTS
32SUBDIRS += online-accounts
33endif
34
31-include $(top_srcdir)/git.mk35-include $(top_srcdir)/git.mk
3236
=== added directory 'panels/online-accounts'
=== added file 'panels/online-accounts/Makefile.am'
--- panels/online-accounts/Makefile.am 1970-01-01 00:00:00 +0000
+++ panels/online-accounts/Makefile.am 2018-02-13 09:06:22 +0000
@@ -0,0 +1,52 @@
1cappletname = online-accounts
2
3SUBDIRS = icons
4
5uidir = $(pkgdatadir)/ui/online-accounts
6dist_ui_DATA = \
7 online-accounts.ui
8
9INCLUDES = \
10 $(PANEL_CFLAGS) \
11 $(ONLINE_ACCOUNTS_PANEL_CFLAGS) \
12 -DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
13 -DG_LOG_DOMAIN="\"$(PACKAGE)\"" \
14 -DGNOMECC_UI_DIR="\"$(uidir)\"" \
15 -DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
16 $(NULL)
17
18ccpanelsdir = $(PANELS_DIR)
19ccpanels_LTLIBRARIES = libonline-accounts.la
20
21BUILT_SOURCES = \
22 cc-online-accounts-resources.c \
23 cc-online-accounts-resources.h
24
25libonline_accounts_la_SOURCES = \
26 $(BUILT_SOURCES) \
27 online-accounts-module.c \
28 cc-online-accounts-panel.c \
29 cc-online-accounts-panel.h
30
31libonline_accounts_la_LIBADD = \
32 $(PANEL_LIBS) \
33 $(ONLINE_ACCOUNTS_PANEL_LIBS)
34
35libonline_accounts_la_LDFLAGS = $(PANEL_LDFLAGS)
36
37resource_files = $(shell glib-compile-resources --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/online-accounts.gresource.xml)
38cc-online-accounts-resources.c: online-accounts.gresource.xml $(resource_files)
39 $(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-source --c-name cc_online_accounts $<
40cc-online-accounts-resources.h: online-accounts.gresource.xml $(resource_files)
41 $(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-header --c-name cc_online_accounts $<
42
43@INTLTOOL_DESKTOP_RULE@
44
45desktopdir = $(datadir)/applications
46desktop_in_files = unity-online-accounts-panel.desktop.in
47desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
48
49CLEANFILES = $(desktop_in_files) $(desktop_DATA) $(BUILT_SOURCES)
50EXTRA_DIST = $(resource_files) online-accounts.gresource.xml
51
52-include $(top_srcdir)/git.mk
053
=== added file 'panels/online-accounts/cc-online-accounts-panel.c'
--- panels/online-accounts/cc-online-accounts-panel.c 1970-01-01 00:00:00 +0000
+++ panels/online-accounts/cc-online-accounts-panel.c 2018-02-13 09:06:22 +0000
@@ -0,0 +1,985 @@
1/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2/*
3 * Copyright (C) 2011, 2012 Red Hat, Inc.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
17 *
18 * Author: David Zeuthen <davidz@redhat.com>
19 */
20
21#include "config.h"
22
23#include <gio/gio.h>
24#include <string.h>
25#include <glib/gi18n.h>
26
27#define GOA_API_IS_SUBJECT_TO_CHANGE
28#include <goa/goa.h>
29#define GOA_BACKEND_API_IS_SUBJECT_TO_CHANGE
30#include <goabackend/goabackend.h>
31
32#include "cc-online-accounts-panel.h"
33#include "cc-online-accounts-resources.h"
34
35#include "shell/list-box-helper.h"
36
37struct _CcGoaPanel
38{
39 CcPanel parent_instance;
40
41 GoaClient *client;
42 GoaObject *active_object;
43 GoaObject *removed_object;
44
45 GtkWidget *accounts_frame;
46 GtkWidget *accounts_listbox;
47 GtkWidget *edit_account_dialog;
48 GtkWidget *edit_account_headerbar;
49 GtkWidget *more_providers_row;
50 GtkWidget *new_account_vbox;
51 GtkWidget *notification_label;
52 GtkWidget *notification_revealer;
53 GtkWidget *offline_label;
54 GtkWidget *providers_listbox;
55 GtkWidget *remove_account_button;
56 GtkWidget *stack;
57 GtkWidget *accounts_vbox;
58
59 guint remove_account_timeout_id;
60};
61
62static gboolean on_edit_account_dialog_delete_event (CcGoaPanel *self);
63
64static void on_listbox_row_activated (CcGoaPanel *self,
65 GtkListBoxRow *activated_row);
66
67static void fill_accounts_listbox (CcGoaPanel *self);
68
69static void on_account_added (GoaClient *client,
70 GoaObject *object,
71 gpointer user_data);
72
73static void on_account_changed (GoaClient *client,
74 GoaObject *object,
75 gpointer user_data);
76
77static void on_account_removed (GoaClient *client,
78 GoaObject *object,
79 gpointer user_data);
80
81static void select_account_by_id (CcGoaPanel *panel,
82 const gchar *account_id);
83
84static void get_all_providers_cb (GObject *source,
85 GAsyncResult *res,
86 gpointer user_data);
87
88static void show_page_account (CcGoaPanel *panel,
89 GoaObject *object);
90
91static void on_remove_button_clicked (CcGoaPanel *self);
92
93static void on_notification_closed (GtkButton *button,
94 CcGoaPanel *self);
95
96static void on_undo_button_clicked (GtkButton *button,
97 CcGoaPanel *self);
98
99CC_PANEL_REGISTER (CcGoaPanel, cc_goa_panel);
100
101enum {
102 PROP_0,
103 PROP_PARAMETERS
104};
105
106/* ---------------------------------------------------------------------------------------------------- */
107
108static void
109reset_headerbar (CcGoaPanel *self)
110{
111 gtk_header_bar_set_title (GTK_HEADER_BAR (self->edit_account_headerbar), NULL);
112 gtk_header_bar_set_subtitle (GTK_HEADER_BAR (self->edit_account_headerbar), NULL);
113 gtk_header_bar_set_show_close_button (GTK_HEADER_BAR (self->edit_account_headerbar), TRUE);
114
115 /* Remove any leftover widgets */
116 gtk_container_foreach (GTK_CONTAINER (self->edit_account_headerbar),
117 (GtkCallback) gtk_widget_destroy,
118 NULL);
119
120}
121
122/* ---------------------------------------------------------------------------------------------------- */
123
124static void
125add_provider_row (CcGoaPanel *self,
126 GoaProvider *provider)
127{
128 GIcon *icon;
129 GoaProviderFeatures features;
130 GtkWidget *image;
131 GtkWidget *label;
132 GtkWidget *row;
133 GtkWidget *row_grid;
134 gchar *markup;
135 gchar *name;
136
137 row = gtk_list_box_row_new ();
138
139 row_grid = gtk_grid_new ();
140 gtk_orientable_set_orientation (GTK_ORIENTABLE (row_grid), GTK_ORIENTATION_HORIZONTAL);
141 gtk_grid_set_column_spacing (GTK_GRID (row_grid), 6);
142 gtk_container_add (GTK_CONTAINER (row), row_grid);
143
144 if (provider == NULL)
145 {
146 g_object_set_data (G_OBJECT (row), "goa-provider", NULL);
147 icon = g_themed_icon_new_with_default_fallbacks ("goa-account");
148 name = g_strdup (C_("Online Account", "Other"));
149 }
150 else
151 {
152 g_object_set_data_full (G_OBJECT (row), "goa-provider", g_object_ref (provider), g_object_unref);
153 icon = goa_provider_get_provider_icon (provider, NULL);
154 name = goa_provider_get_provider_name (provider, NULL);
155 }
156
157 image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);
158 gtk_container_add (GTK_CONTAINER (row_grid), image);
159 g_object_set (image, "margin", 6, NULL);
160
161 markup = g_strdup_printf ("<b>%s</b>", name);
162 label = gtk_label_new (NULL);
163 gtk_label_set_markup (GTK_LABEL (label), markup);
164 gtk_container_add (GTK_CONTAINER (row_grid), label);
165
166 /* Check if the row should be shown initially */
167 features = goa_provider_get_provider_features (provider);
168
169 if ((features & GOA_PROVIDER_FEATURE_BRANDED) != 0)
170 gtk_widget_show_all (row);
171
172 gtk_container_add (GTK_CONTAINER (self->providers_listbox), row);
173
174 g_free (markup);
175 g_free (name);
176 g_object_unref (icon);
177}
178
179static gint
180sort_providers_func (GtkListBoxRow *a,
181 GtkListBoxRow *b,
182 gpointer user_data)
183{
184 GoaProvider *a_provider, *b_provider;
185 CcGoaPanel *self;
186 gboolean a_branded, b_branded;
187
188 self = user_data;
189
190 if (a == GTK_LIST_BOX_ROW (self->more_providers_row))
191 return 1;
192 else if (b == GTK_LIST_BOX_ROW (self->more_providers_row))
193 return -1;
194
195 a_provider = g_object_get_data (G_OBJECT (a), "goa-provider");
196 b_provider = g_object_get_data (G_OBJECT (b), "goa-provider");
197
198 a_branded = (goa_provider_get_provider_features (a_provider) & GOA_PROVIDER_FEATURE_BRANDED) != 0;
199 b_branded = (goa_provider_get_provider_features (b_provider) & GOA_PROVIDER_FEATURE_BRANDED) != 0;
200
201 if (a_branded != b_branded)
202 {
203 if (a_branded)
204 return -1;
205 else
206 return 1;
207 }
208
209 return gtk_list_box_row_get_index (b) - gtk_list_box_row_get_index (a);
210}
211
212static void
213show_non_branded_providers (CcGoaPanel *self)
214{
215 GList *children, *l;
216
217 children = gtk_container_get_children (GTK_CONTAINER (self->providers_listbox));
218
219 for (l = children; l != NULL; l = l->next)
220 {
221 GoaProvider *provider = g_object_get_data (l->data, "goa-provider");
222
223 if (!provider)
224 continue;
225
226 if ((goa_provider_get_provider_features (provider) & GOA_PROVIDER_FEATURE_BRANDED) == 0)
227 gtk_widget_show_all (l->data);
228 }
229
230 gtk_widget_hide (self->more_providers_row);
231
232 g_list_free (children);
233}
234
235static void
236add_account (CcGoaPanel *self,
237 GoaProvider *provider,
238 GVariant *preseed)
239{
240 GoaObject *object;
241 GError *error;
242
243 error = NULL;
244
245 gtk_container_foreach (GTK_CONTAINER (self->new_account_vbox),
246 (GtkCallback) gtk_widget_destroy,
247 NULL);
248
249 reset_headerbar (self);
250
251 /* Move to the new account page */
252 gtk_stack_set_visible_child_name (GTK_STACK (self->stack), "new-account");
253
254 /* Reset the dialog size */
255 gtk_window_resize (GTK_WINDOW (self->edit_account_dialog), 1, 1);
256
257 /* This spins gtk_dialog_run() */
258 object = goa_provider_add_account (provider,
259 self->client,
260 GTK_DIALOG (self->edit_account_dialog),
261 GTK_BOX (self->new_account_vbox),
262 &error);
263
264 if (preseed)
265 goa_provider_set_preseed_data (provider, preseed);
266
267 if (object == NULL)
268 gtk_widget_hide (self->edit_account_dialog);
269 else
270 show_page_account (self, object);
271}
272
273static void
274on_provider_row_activated (CcGoaPanel *self,
275 GtkListBoxRow *activated_row)
276{
277 GoaProvider *provider;
278
279 /* Show More row */
280 if (activated_row == GTK_LIST_BOX_ROW (self->more_providers_row))
281 {
282 show_non_branded_providers (self);
283 return;
284 }
285
286 provider = g_object_get_data (G_OBJECT (activated_row), "goa-provider");
287
288 add_account (self, provider, NULL);
289}
290
291/* ---------------------------------------------------------------------------------------------------- */
292
293static gint
294sort_func (GtkListBoxRow *a,
295 GtkListBoxRow *b,
296 gpointer user_data)
297{
298 GoaObject *a_obj, *b_obj;
299 GoaAccount *a_account, *b_account;
300
301 a_obj = g_object_get_data (G_OBJECT (a), "goa-object");
302 a_account = goa_object_peek_account (a_obj);
303
304 b_obj = g_object_get_data (G_OBJECT (b), "goa-object");
305 b_account = goa_object_peek_account (b_obj);
306
307 return g_strcmp0 (goa_account_get_id (a_account), goa_account_get_id (b_account));
308}
309
310static void
311command_add (CcGoaPanel *panel,
312 GVariant *parameters)
313{
314 GVariant *v, *preseed = NULL;
315 GoaProvider *provider = NULL;
316 const gchar *provider_name = NULL;
317
318 g_assert (panel != NULL);
319 g_assert (parameters != NULL);
320
321 switch (g_variant_n_children (parameters))
322 {
323 case 3:
324 g_variant_get_child (parameters, 2, "v", &preseed);
325 case 2:
326 g_variant_get_child (parameters, 1, "v", &v);
327 if (g_variant_is_of_type (v, G_VARIANT_TYPE_STRING))
328 provider_name = g_variant_get_string (v, NULL);
329 else
330 g_warning ("Wrong type for the second argument (provider name) GVariant, expected 's' but got '%s'",
331 (gchar *)g_variant_get_type (v));
332 g_variant_unref (v);
333 break;
334 default:
335 g_warning ("Unexpected parameters found, ignore request");
336 goto out;
337 }
338
339 if (provider_name != NULL)
340 {
341 provider = goa_provider_get_for_provider_type (provider_name);
342 if (provider == NULL)
343 {
344 g_warning ("Unable to get a provider for type '%s'", provider_name);
345 goto out;
346 }
347
348 add_account (panel, provider, preseed);
349 }
350
351out:
352 g_clear_object (&provider);
353 g_clear_pointer (&preseed, g_variant_unref);
354}
355
356static void
357cc_goa_panel_set_property (GObject *object,
358 guint property_id,
359 const GValue *value,
360 GParamSpec *pspec)
361{
362 switch (property_id)
363 {
364 case PROP_PARAMETERS:
365 {
366 GVariant *parameters, *v;
367 const gchar *first_arg = NULL;
368
369 parameters = g_value_get_variant (value);
370 if (parameters == NULL)
371 return;
372
373 if (g_variant_n_children (parameters) > 0)
374 {
375 g_variant_get_child (parameters, 0, "v", &v);
376 if (g_variant_is_of_type (v, G_VARIANT_TYPE_STRING))
377 first_arg = g_variant_get_string (v, NULL);
378 else
379 g_warning ("Wrong type for the second argument GVariant, expected 's' but got '%s'",
380 (gchar *)g_variant_get_type (v));
381 g_variant_unref (v);
382 }
383
384 if (g_strcmp0 (first_arg, "add") == 0)
385 command_add (CC_GOA_PANEL (object), parameters);
386 else if (first_arg != NULL)
387 select_account_by_id (CC_GOA_PANEL (object), first_arg);
388
389 return;
390 }
391 }
392
393 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
394}
395
396static void
397cc_goa_panel_dispose (GObject *object)
398{
399 CcGoaPanel *panel = CC_GOA_PANEL (object);
400
401 /* Must be destroyed in dispose, not finalize. */
402 g_clear_pointer (&panel->edit_account_dialog, gtk_widget_destroy);
403
404 G_OBJECT_CLASS (cc_goa_panel_parent_class)->dispose (object);
405}
406
407static void
408cc_goa_panel_finalize (GObject *object)
409{
410 CcGoaPanel *panel = CC_GOA_PANEL (object);
411
412 g_clear_object (&panel->client);
413
414 G_OBJECT_CLASS (cc_goa_panel_parent_class)->finalize (object);
415}
416
417static void
418cc_goa_panel_init (CcGoaPanel *panel)
419{
420 GError *error;
421 GNetworkMonitor *monitor;
422
423 g_resources_register (cc_online_accounts_get_resource ());
424
425 gtk_widget_init_template (GTK_WIDGET (panel));
426
427 gtk_list_box_set_header_func (GTK_LIST_BOX (panel->accounts_listbox),
428 cc_list_box_update_header_func,
429 NULL,
430 NULL);
431 gtk_list_box_set_sort_func (GTK_LIST_BOX (panel->accounts_listbox),
432 sort_func,
433 panel,
434 NULL);
435
436 gtk_list_box_set_header_func (GTK_LIST_BOX (panel->providers_listbox),
437 cc_list_box_update_header_func,
438 NULL,
439 NULL);
440 gtk_list_box_set_sort_func (GTK_LIST_BOX (panel->providers_listbox),
441 sort_providers_func,
442 panel,
443 NULL);
444
445 monitor = g_network_monitor_get_default();
446
447 g_object_bind_property (monitor, "network-available",
448 panel->offline_label, "visible",
449 G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN);
450
451 g_object_bind_property (monitor, "network-available",
452 panel->providers_listbox, "sensitive",
453 G_BINDING_SYNC_CREATE);
454
455 /* TODO: probably want to avoid _sync() ... */
456 error = NULL;
457 panel->client = goa_client_new_sync (NULL /* GCancellable */, &error);
458 if (panel->client == NULL)
459 {
460 g_warning ("Error getting a GoaClient: %s (%s, %d)",
461 error->message, g_quark_to_string (error->domain), error->code);
462 gtk_widget_set_sensitive (GTK_WIDGET (panel), FALSE);
463 g_error_free (error);
464 return;
465 }
466
467 g_signal_connect (panel->client,
468 "account-added",
469 G_CALLBACK (on_account_added),
470 panel);
471
472 g_signal_connect (panel->client,
473 "account-changed",
474 G_CALLBACK (on_account_changed),
475 panel);
476
477 g_signal_connect (panel->client,
478 "account-removed",
479 G_CALLBACK (on_account_removed),
480 panel);
481
482 fill_accounts_listbox (panel);
483 goa_provider_get_all (get_all_providers_cb, panel);
484
485 gtk_widget_show (GTK_WIDGET (panel));
486}
487
488static const char *
489cc_goa_panel_get_help_uri (CcPanel *panel)
490{
491 return "help:gnome-help/accounts";
492}
493
494static void
495cc_goa_panel_constructed (GObject *object)
496{
497 CcGoaPanel *self = CC_GOA_PANEL (object);
498 GtkWindow *parent;
499
500 /* Setup account editor dialog */
501 parent = GTK_WINDOW (cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (self))));
502
503 gtk_window_set_transient_for (GTK_WINDOW (self->edit_account_dialog), parent);
504
505 G_OBJECT_CLASS (cc_goa_panel_parent_class)->constructed (object);
506}
507
508static void
509cc_goa_panel_class_init (CcGoaPanelClass *klass)
510{
511 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
512 GObjectClass *object_class = G_OBJECT_CLASS (klass);
513 CcPanelClass *panel_class = CC_PANEL_CLASS (klass);
514
515 panel_class->get_help_uri = cc_goa_panel_get_help_uri;
516
517 object_class->set_property = cc_goa_panel_set_property;
518 object_class->finalize = cc_goa_panel_finalize;
519 object_class->constructed = cc_goa_panel_constructed;
520 object_class->dispose = cc_goa_panel_dispose;
521
522 //g_object_class_override_property (object_class, PROP_PARAMETERS, "parameters");
523
524 gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/online-accounts/online-accounts.ui");
525
526 gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, accounts_frame);
527 gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, accounts_listbox);
528 gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, accounts_vbox);
529 gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, edit_account_dialog);
530 gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, edit_account_headerbar);
531 gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, more_providers_row);
532 gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, new_account_vbox);
533 gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, notification_label);
534 gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, notification_revealer);
535 gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, offline_label);
536 gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, providers_listbox);
537 gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, remove_account_button);
538 gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, stack);
539
540 gtk_widget_class_bind_template_callback (widget_class, on_edit_account_dialog_delete_event);
541 gtk_widget_class_bind_template_callback (widget_class, on_listbox_row_activated);
542 gtk_widget_class_bind_template_callback (widget_class, on_notification_closed);
543 gtk_widget_class_bind_template_callback (widget_class, on_provider_row_activated);
544 gtk_widget_class_bind_template_callback (widget_class, on_remove_button_clicked);
545 gtk_widget_class_bind_template_callback (widget_class, on_undo_button_clicked);
546}
547
548/* ---------------------------------------------------------------------------------------------------- */
549
550static void
551show_page_nothing_selected (CcGoaPanel *panel)
552{
553}
554
555static void
556show_page_account (CcGoaPanel *panel,
557 GoaObject *object)
558{
559 GList *children;
560 GList *l;
561 GoaProvider *provider;
562 GoaAccount *account;
563 gboolean is_locked;
564 const gchar *provider_name;
565 const gchar *provider_type;
566 gchar *title;
567
568 provider = NULL;
569
570 panel->active_object = object;
571 reset_headerbar (panel);
572
573 /* Move to the account editor page */
574 gtk_stack_set_visible_child_name (GTK_STACK (panel->stack), "editor");
575
576 /* Out with the old */
577 children = gtk_container_get_children (GTK_CONTAINER (panel->accounts_vbox));
578 for (l = children; l != NULL; l = l->next)
579 gtk_container_remove (GTK_CONTAINER (panel->accounts_vbox), GTK_WIDGET (l->data));
580 g_list_free (children);
581
582 account = goa_object_peek_account (object);
583
584 is_locked = goa_account_get_is_locked (account);
585 gtk_widget_set_visible (panel->remove_account_button, !is_locked);
586
587 provider_type = goa_account_get_provider_type (account);
588 provider = goa_provider_get_for_provider_type (provider_type);
589
590 if (provider != NULL)
591 {
592 goa_provider_show_account (provider,
593 panel->client,
594 object,
595 GTK_BOX (panel->accounts_vbox),
596 NULL,
597 NULL);
598 }
599
600 provider_name = goa_account_get_provider_name (account);
601 /* translators: This is the title of the "Show Account" dialog. The
602 * %s is the name of the provider. e.g., 'Google'. */
603 title = g_strdup_printf (_("%s Account"), provider_name);
604 gtk_header_bar_set_title (GTK_HEADER_BAR (panel->edit_account_headerbar), title);
605 g_free (title);
606
607 /* Reset the dialog size */
608 gtk_window_resize (GTK_WINDOW (panel->edit_account_dialog), 1, 1);
609
610 gtk_widget_show_all (panel->accounts_vbox);
611 gtk_widget_show (panel->edit_account_dialog);
612
613 g_clear_object (&provider);
614}
615
616/* ---------------------------------------------------------------------------------------------------- */
617
618static void
619select_account_by_id (CcGoaPanel *panel,
620 const gchar *account_id)
621{
622 GList *children, *l;
623
624 children = gtk_container_get_children (GTK_CONTAINER (panel->accounts_listbox));
625
626 for (l = children; l != NULL; l = l->next)
627 {
628 GoaAccount *account;
629 GoaObject *row_object;
630
631 row_object = g_object_get_data (l->data, "goa-object");
632 account = goa_object_peek_account (row_object);
633
634 if (g_strcmp0 (goa_account_get_id (account), account_id) == 0)
635 {
636 show_page_account (panel, row_object);
637 break;
638 }
639 }
640
641 g_list_free (children);
642}
643
644static gboolean
645on_edit_account_dialog_delete_event (CcGoaPanel *self)
646{
647 self->active_object = NULL;
648 gtk_widget_hide (self->edit_account_dialog);
649 return TRUE;
650}
651
652static void
653on_listbox_row_activated (CcGoaPanel *self,
654 GtkListBoxRow *activated_row)
655{
656 GoaObject *object;
657
658 object = g_object_get_data (G_OBJECT (activated_row), "goa-object");
659 show_page_account (self, object);
660}
661
662static void
663fill_accounts_listbox (CcGoaPanel *self)
664{
665 GList *accounts, *l;
666
667 accounts = goa_client_get_accounts (self->client);
668
669 if (accounts == NULL)
670 {
671 show_page_nothing_selected (self);
672 }
673 else
674 {
675 for (l = accounts; l != NULL; l = l->next)
676 on_account_added (self->client, l->data, self);
677 }
678
679 g_list_free_full (accounts, g_object_unref);
680}
681
682/* ---------------------------------------------------------------------------------------------------- */
683
684typedef void (*RowForAccountCallback) (CcGoaPanel *self, GtkWidget *row, GList *other_rows);
685
686static void
687hide_row_for_account (CcGoaPanel *self, GtkWidget *row, GList *other_rows)
688{
689 gtk_widget_hide (row);
690 gtk_widget_set_visible (self->accounts_frame, other_rows != NULL);
691}
692
693static void
694remove_row_for_account (CcGoaPanel *self, GtkWidget *row, GList *other_rows)
695{
696 gtk_widget_destroy (row);
697 gtk_widget_set_visible (self->accounts_frame, other_rows != NULL);
698}
699
700static void
701show_row_for_account (CcGoaPanel *self, GtkWidget *row, GList *other_rows)
702{
703 gtk_widget_show (row);
704 gtk_widget_show (self->accounts_frame);
705}
706
707static void
708modify_row_for_account (CcGoaPanel *self,
709 GoaObject *object,
710 RowForAccountCallback callback)
711{
712 GList *children, *l;
713
714 children = gtk_container_get_children (GTK_CONTAINER (self->accounts_listbox));
715
716 for (l = children; l != NULL; l = l->next)
717 {
718 GoaObject *row_object;
719
720 row_object = g_object_get_data (G_OBJECT (l->data), "goa-object");
721 if (row_object == object)
722 {
723 GtkWidget *row = GTK_WIDGET (l->data);
724
725 children = g_list_remove_link (children, l);
726 callback (self, row, children);
727 g_list_free (l);
728 break;
729 }
730 }
731
732 g_list_free (children);
733}
734
735/* ---------------------------------------------------------------------------------------------------- */
736
737static void
738on_account_added (GoaClient *client,
739 GoaObject *object,
740 gpointer user_data)
741{
742 CcGoaPanel *self = user_data;
743 GtkWidget *row, *icon, *label, *box;
744 GoaAccount *account;
745 GError *error;
746 GIcon *gicon;
747 gchar* title = NULL;
748
749 account = goa_object_peek_account (object);
750
751 /* The main grid */
752 box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
753 gtk_widget_show (box);
754
755 /* The provider icon */
756 icon = gtk_image_new ();
757
758 error = NULL;
759 gicon = g_icon_new_for_string (goa_account_get_provider_icon (account), &error);
760 if (error != NULL)
761 {
762 g_warning ("Error creating GIcon for account: %s (%s, %d)",
763 error->message,
764 g_quark_to_string (error->domain),
765 error->code);
766
767 g_clear_error (&error);
768 }
769 else
770 {
771 gtk_image_set_from_gicon (GTK_IMAGE (icon), gicon, GTK_ICON_SIZE_DIALOG);
772 }
773
774 g_object_set (icon, "margin", 6, NULL);
775
776 gtk_container_add (GTK_CONTAINER (box), icon);
777
778 /* The name of the provider */
779 title = g_strdup_printf ("<b>%s</b>\n<small>%s</small>",
780 goa_account_get_provider_name (account),
781 goa_account_get_presentation_identity (account));
782
783 label = g_object_new (GTK_TYPE_LABEL,
784 "ellipsize", PANGO_ELLIPSIZE_END,
785 "label", title,
786 "xalign", 0.0,
787 "use-markup", TRUE,
788 "hexpand", TRUE,
789 NULL);
790 gtk_container_add (GTK_CONTAINER (box), label);
791
792 /* "Needs attention" icon */
793 icon = gtk_image_new_from_icon_name ("dialog-warning-symbolic", GTK_ICON_SIZE_BUTTON);
794 gtk_widget_set_no_show_all (icon, TRUE);
795 g_object_set (icon, "margin_end", 30, NULL);
796 g_object_bind_property (goa_object_peek_account (object),
797 "attention-needed",
798 icon,
799 "visible",
800 G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
801 gtk_container_add (GTK_CONTAINER (box), icon);
802
803 /* The row */
804 row = gtk_list_box_row_new ();
805 g_object_set_data (G_OBJECT (row), "goa-object", object);
806 gtk_container_add (GTK_CONTAINER (row), box);
807
808 /* Add to the listbox */
809 gtk_container_add (GTK_CONTAINER (self->accounts_listbox), row);
810 gtk_widget_show_all (row);
811 gtk_widget_show (self->accounts_frame);
812
813 g_clear_pointer (&title, g_free);
814 g_clear_object (&gicon);
815}
816
817static void
818on_account_changed (GoaClient *client,
819 GoaObject *object,
820 gpointer user_data)
821{
822 CcGoaPanel *panel = CC_GOA_PANEL (user_data);
823
824 if (panel->active_object != object)
825 return;
826
827 show_page_account (panel, panel->active_object);
828}
829
830static void
831on_account_removed (GoaClient *client,
832 GoaObject *object,
833 gpointer user_data)
834{
835 CcGoaPanel *self = user_data;
836 modify_row_for_account (self, object, remove_row_for_account);
837}
838
839/* ---------------------------------------------------------------------------------------------------- */
840
841static void
842get_all_providers_cb (GObject *source,
843 GAsyncResult *res,
844 gpointer user_data)
845{
846 CcGoaPanel *self = user_data;
847 GList *providers;
848 GList *l;
849
850 providers = NULL;
851 if (!goa_provider_get_all_finish (&providers, res, NULL))
852 return;
853
854 for (l = providers; l != NULL; l = l->next)
855 {
856 GoaProvider *provider;
857 provider = GOA_PROVIDER (l->data);
858
859 add_provider_row (self, provider);
860 }
861
862 g_list_free_full (providers, g_object_unref);
863}
864
865
866/* ---------------------------------------------------------------------------------------------------- */
867
868static void
869cancel_notification_timeout (CcGoaPanel *self)
870{
871 if (self->remove_account_timeout_id == 0)
872 return;
873
874 g_source_remove (self->remove_account_timeout_id);
875
876 self->remove_account_timeout_id = 0;
877}
878
879static void
880remove_account_cb (GoaAccount *account,
881 GAsyncResult *res,
882 gpointer user_data)
883{
884 CcGoaPanel *panel = CC_GOA_PANEL (user_data);
885 GError *error;
886
887 error = NULL;
888 if (!goa_account_call_remove_finish (account, res, &error))
889 {
890 GtkWidget *dialog;
891 dialog = gtk_message_dialog_new (GTK_WINDOW (cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (panel)))),
892 GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
893 GTK_MESSAGE_ERROR,
894 GTK_BUTTONS_CLOSE,
895 _("Error removing account"));
896 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
897 "%s",
898 error->message);
899 gtk_widget_show_all (dialog);
900 gtk_dialog_run (GTK_DIALOG (dialog));
901 gtk_widget_destroy (dialog);
902 g_error_free (error);
903 }
904 g_object_unref (panel);
905}
906
907static void
908on_notification_closed (GtkButton *button,
909 CcGoaPanel *self)
910{
911 goa_account_call_remove (goa_object_peek_account (self->removed_object),
912 NULL, /* GCancellable */
913 (GAsyncReadyCallback) remove_account_cb,
914 g_object_ref (self));
915
916 gtk_revealer_set_reveal_child (GTK_REVEALER (self->notification_revealer), FALSE);
917
918 cancel_notification_timeout (self);
919 self->removed_object = NULL;
920}
921
922static void
923on_undo_button_clicked (GtkButton *button,
924 CcGoaPanel *self)
925{
926 /* Simply show the account row and hide the notification */
927 modify_row_for_account (self, self->removed_object, show_row_for_account);
928 gtk_revealer_set_reveal_child (GTK_REVEALER (self->notification_revealer), FALSE);
929
930 cancel_notification_timeout (self);
931 self->removed_object = NULL;
932}
933
934static gboolean
935on_remove_account_timeout (gpointer user_data)
936{
937 on_notification_closed (NULL, user_data);
938 return G_SOURCE_REMOVE;
939}
940
941static void
942on_remove_button_clicked (CcGoaPanel *panel)
943{
944 GoaAccount *account;
945 gchar *label;
946
947 if (panel->active_object == NULL)
948 return;
949
950 if (panel->removed_object != NULL)
951 on_notification_closed (NULL, panel);
952
953 panel->removed_object = panel->active_object;
954 panel->active_object = NULL;
955
956 account = goa_object_peek_account (panel->removed_object);
957 /* Translators: The %s is the username (eg., debarshi.ray@gmail.com
958 * or rishi).
959 */
960 label = g_strdup_printf (_("<b>%s</b> removed"), goa_account_get_presentation_identity (account));
961 gtk_label_set_markup (GTK_LABEL (panel->notification_label), label);
962 gtk_revealer_set_reveal_child (GTK_REVEALER (panel->notification_revealer), TRUE);
963
964 modify_row_for_account (panel, panel->removed_object, hide_row_for_account);
965 gtk_widget_hide (panel->edit_account_dialog);
966
967 panel->remove_account_timeout_id = g_timeout_add_seconds (10, on_remove_account_timeout, panel);
968
969 g_free (label);
970}
971
972
973/* ---------------------------------------------------------------------------------------------------- */
974
975void
976cc_goa_panel_register (GIOModule *module)
977{
978 textdomain (GETTEXT_PACKAGE);
979 bindtextdomain (GETTEXT_PACKAGE, "/usr/share/locale");
980 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
981 cc_goa_panel_register_type (G_TYPE_MODULE (module));
982 g_io_extension_point_implement (CC_SHELL_PANEL_EXTENSION_POINT,
983 CC_TYPE_GOA_PANEL,
984 "online-accounts", 0);
985}
0986
=== added file 'panels/online-accounts/cc-online-accounts-panel.h'
--- panels/online-accounts/cc-online-accounts-panel.h 1970-01-01 00:00:00 +0000
+++ panels/online-accounts/cc-online-accounts-panel.h 2018-02-13 09:06:22 +0000
@@ -0,0 +1,65 @@
1/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2/*
3 * Copyright (C) 2011 Red Hat, Inc.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
17 *
18 * Author: David Zeuthen <davidz@redhat.com>
19 */
20
21#ifndef __GOA_PANEL_H__
22#define __GOA_PANEL_H__
23
24#include <shell/cc-panel.h>
25
26G_BEGIN_DECLS
27
28#define CC_TYPE_GOA_PANEL (cc_goa_panel_get_type ())
29
30#define CC_GOA_PANEL(obj) \
31 (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
32 CC_TYPE_GOA_PANEL, CcGoaPanel))
33
34#define CC_GOA_PANEL_CLASS(klass) \
35 (G_TYPE_CHECK_CLASS_CAST ((klass), \
36 CC_TYPE_GOA_PANEL, CcGoaPanelClass))
37
38#define CC_IS_GOA_PANEL(obj) \
39 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
40 CC_TYPE_GOA_PANEL))
41
42#define CC_IS_GOA_PANEL_CLASS(klass) \
43 (G_TYPE_CHECK_CLASS_TYPE ((klass), \
44 CC_TYPE_GOA_PANEL))
45
46#define CC_GOA_PANEL_GET_CLASS(obj) \
47 (G_TYPE_INSTANCE_GET_CLASS ((obj), \
48 CC_TYPE_GOA_PANEL, CcGoaPanelClass))
49
50typedef struct _CcGoaPanel CcGoaPanel;
51typedef struct _CcGoaPanelClass CcGoaPanelClass;
52typedef struct _CcGoaPanelPrivate CcGoaPanelPrivate;
53
54struct _CcGoaPanelClass
55{
56 CcPanelClass parent_class;
57};
58
59GType cc_goa_panel_get_type (void) G_GNUC_CONST;
60
61void cc_goa_panel_register (GIOModule *module);
62
63G_END_DECLS
64
65#endif /* __GOA_PANEL_H__ */
066
=== added directory 'panels/online-accounts/icons'
=== added directory 'panels/online-accounts/icons/16x16'
=== added file 'panels/online-accounts/icons/16x16/Makefile.am'
--- panels/online-accounts/icons/16x16/Makefile.am 1970-01-01 00:00:00 +0000
+++ panels/online-accounts/icons/16x16/Makefile.am 2018-02-13 09:06:22 +0000
@@ -0,0 +1,14 @@
1NULL =
2
3icondir = $(datadir)/icons/hicolor/16x16/apps
4icon_DATA = \
5 unity-online-accounts.png \
6 $(NULL)
7
8EXTRA_DIST = \
9 $(icon_DATA)
10
11clean-local :
12 rm -f *~
13
14-include $(top_srcdir)/git.mk
015
=== added file 'panels/online-accounts/icons/16x16/unity-online-accounts.png'
1Binary 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 differ16Binary 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
=== added directory 'panels/online-accounts/icons/22x22'
=== added file 'panels/online-accounts/icons/22x22/Makefile.am'
--- panels/online-accounts/icons/22x22/Makefile.am 1970-01-01 00:00:00 +0000
+++ panels/online-accounts/icons/22x22/Makefile.am 2018-02-13 09:06:22 +0000
@@ -0,0 +1,14 @@
1NULL =
2
3icondir = $(datadir)/icons/hicolor/22x22/apps
4icon_DATA = \
5 unity-online-accounts.png \
6 $(NULL)
7
8EXTRA_DIST = \
9 $(icon_DATA)
10
11clean-local :
12 rm -f *~
13
14-include $(top_srcdir)/git.mk
015
=== added file 'panels/online-accounts/icons/22x22/unity-online-accounts.png'
1Binary 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 differ16Binary 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
=== added directory 'panels/online-accounts/icons/24x24'
=== added file 'panels/online-accounts/icons/24x24/Makefile.am'
--- panels/online-accounts/icons/24x24/Makefile.am 1970-01-01 00:00:00 +0000
+++ panels/online-accounts/icons/24x24/Makefile.am 2018-02-13 09:06:22 +0000
@@ -0,0 +1,14 @@
1NULL =
2
3icondir = $(datadir)/icons/hicolor/24x24/apps
4icon_DATA = \
5 unity-online-accounts.png \
6 $(NULL)
7
8EXTRA_DIST = \
9 $(icon_DATA)
10
11clean-local :
12 rm -f *~
13
14-include $(top_srcdir)/git.mk
015
=== added file 'panels/online-accounts/icons/24x24/unity-online-accounts.png'
1Binary 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 differ16Binary 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
=== added directory 'panels/online-accounts/icons/256x256'
=== added file 'panels/online-accounts/icons/256x256/Makefile.am'
--- panels/online-accounts/icons/256x256/Makefile.am 1970-01-01 00:00:00 +0000
+++ panels/online-accounts/icons/256x256/Makefile.am 2018-02-13 09:06:22 +0000
@@ -0,0 +1,14 @@
1NULL =
2
3icondir = $(datadir)/icons/hicolor/256x256/apps
4icon_DATA = \
5 unity-online-accounts.png \
6 $(NULL)
7
8EXTRA_DIST = \
9 $(icon_DATA)
10
11clean-local :
12 rm -f *~
13
14-include $(top_srcdir)/git.mk
015
=== added file 'panels/online-accounts/icons/256x256/unity-online-accounts.png'
1Binary 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 differ16Binary 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
=== added directory 'panels/online-accounts/icons/32x32'
=== added file 'panels/online-accounts/icons/32x32/Makefile.am'
--- panels/online-accounts/icons/32x32/Makefile.am 1970-01-01 00:00:00 +0000
+++ panels/online-accounts/icons/32x32/Makefile.am 2018-02-13 09:06:22 +0000
@@ -0,0 +1,14 @@
1NULL =
2
3icondir = $(datadir)/icons/hicolor/32x32/apps
4icon_DATA = \
5 unity-online-accounts.png \
6 $(NULL)
7
8EXTRA_DIST = \
9 $(icon_DATA)
10
11clean-local :
12 rm -f *~
13
14-include $(top_srcdir)/git.mk
015
=== added file 'panels/online-accounts/icons/32x32/unity-online-accounts.png'
1Binary 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 differ16Binary 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
=== added directory 'panels/online-accounts/icons/48x48'
=== added file 'panels/online-accounts/icons/48x48/Makefile.am'
--- panels/online-accounts/icons/48x48/Makefile.am 1970-01-01 00:00:00 +0000
+++ panels/online-accounts/icons/48x48/Makefile.am 2018-02-13 09:06:22 +0000
@@ -0,0 +1,14 @@
1NULL =
2
3icondir = $(datadir)/icons/hicolor/48x48/apps
4icon_DATA = \
5 unity-online-accounts.png \
6 $(NULL)
7
8EXTRA_DIST = \
9 $(icon_DATA)
10
11clean-local :
12 rm -f *~
13
14-include $(top_srcdir)/git.mk
015
=== added file 'panels/online-accounts/icons/48x48/unity-online-accounts.png'
1Binary 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 differ16Binary 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
=== added file 'panels/online-accounts/icons/Makefile.am'
--- panels/online-accounts/icons/Makefile.am 1970-01-01 00:00:00 +0000
+++ panels/online-accounts/icons/Makefile.am 2018-02-13 09:06:22 +0000
@@ -0,0 +1,23 @@
1
2SUBDIRS = 16x16 22x22 24x24 32x32 48x48 256x256
3
4gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor
5
6if MAINTAINER_MODE
7
8install-data-hook:
9 @-if test -z "$(DESTDIR)"; then \
10 echo "Updating Gtk icon cache."; \
11 $(gtk_update_icon_cache); \
12 else \
13 echo "*** Icon cache not updated. After install, run this:"; \
14 echo "*** $(gtk_update_icon_cache)"; \
15 fi
16
17endif
18
19clean-local :
20 rm -f *~
21
22
23-include $(top_srcdir)/git.mk
024
=== added file 'panels/online-accounts/online-accounts-module.c'
--- panels/online-accounts/online-accounts-module.c 1970-01-01 00:00:00 +0000
+++ panels/online-accounts/online-accounts-module.c 2018-02-13 09:06:22 +0000
@@ -0,0 +1,33 @@
1/*
2 * Copyright (C) 2011 Red Hat, Inc
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
16 *
17 */
18
19#include <config.h>
20#include "cc-online-accounts-panel.h"
21#include <glib/gi18n.h>
22
23void
24g_io_module_load (GIOModule *module)
25{
26 /* register the panel */
27 cc_goa_panel_register (module);
28}
29
30void
31g_io_module_unload (GIOModule *module)
32{
33}
034
=== added file 'panels/online-accounts/online-accounts.gresource.xml'
--- panels/online-accounts/online-accounts.gresource.xml 1970-01-01 00:00:00 +0000
+++ panels/online-accounts/online-accounts.gresource.xml 2018-02-13 09:06:22 +0000
@@ -0,0 +1,6 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<gresources>
3 <gresource prefix="/org/gnome/control-center/online-accounts">
4 <file preprocess="xml-stripblanks">online-accounts.ui</file>
5 </gresource>
6</gresources>
07
=== added file 'panels/online-accounts/online-accounts.ui'
--- panels/online-accounts/online-accounts.ui 1970-01-01 00:00:00 +0000
+++ panels/online-accounts/online-accounts.ui 2018-02-13 09:06:22 +0000
@@ -0,0 +1,270 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<interface>
3 <!-- interface-requires gtk+ 3.0 -->
4 <template class="CcGoaPanel" parent="CcPanel">
5 <property name="visible">True</property>
6 <property name="can_focus">False</property>
7 <child>
8 <object class="GtkOverlay">
9 <property name="visible">True</property>
10 <property name="can_focus">False</property>
11 <child type="overlay">
12 <object class="GtkRevealer" id="notification_revealer">
13 <property name="visible">True</property>
14 <property name="can_focus">False</property>
15 <property name="halign">center</property>
16 <property name="valign">start</property>
17 <property name="transition_type">slide-down</property>
18 <child>
19 <object class="GtkFrame">
20 <property name="visible">True</property>
21 <property name="can_focus">False</property>
22 <child>
23 <object class="GtkBox">
24 <property name="visible">True</property>
25 <property name="can_focus">False</property>
26 <property name="spacing">12</property>
27 <child>
28 <object class="GtkLabel" id="notification_label">
29 <property name="visible">True</property>
30 <property name="can_focus">False</property>
31 <property name="use_markup">True</property>
32 </object>
33 </child>
34 <child>
35 <object class="GtkButton" id="undo_button">
36 <property name="visible">True</property>
37 <property name="can_focus">True</property>
38 <property name="label" translatable="yes">Undo</property>
39 <signal name="clicked" handler="on_undo_button_clicked" object="CcGoaPanel" swapped="no" />
40 </object>
41 </child>
42 <child>
43 <object class="GtkButton">
44 <property name="visible">True</property>
45 <property name="can_focus">True</property>
46 <property name="relief">none</property>
47 <signal name="clicked" handler="on_notification_closed" object="CcGoaPanel" swapped="no" />
48 <child>
49 <object class="GtkImage">
50 <property name="visible">True</property>
51 <property name="can_focus">False</property>
52 <property name="icon-name">window-close-symbolic</property>
53 </object>
54 </child>
55 </object>
56 </child>
57 </object>
58 </child>
59 <style>
60 <class name="app-notification" />
61 </style>
62 </object>
63 </child>
64 </object>
65 </child>
66 <child>
67 <object class="GtkScrolledWindow">
68 <property name="visible">True</property>
69 <property name="can_focus">True</property>
70 <property name="hscrollbar_policy">never</property>
71 <property name="min_content_height">500</property>
72 <child>
73 <object class="GtkGrid">
74 <property name="visible">True</property>
75 <property name="can_focus">False</property>
76 <property name="row-spacing">18</property>
77 <property name="column-spacing">18</property>
78 <property name="orientation">vertical</property>
79 <property name="margin_start">32</property>
80 <property name="margin_end">32</property>
81 <property name="margin_top">32</property>
82 <property name="margin_bottom">22</property>
83 <property name="hexpand">True</property>
84 <property name="width-request">300</property>
85
86 <!--
87 Stub boxes to pull the widgets to the middle, and yet allow them to
88 grow and cover a third of the available space
89 -->
90 <child>
91 <object class="GtkBox">
92 <property name="visible">True</property>
93 <property name="hexpand">True</property>
94 </object>
95 <packing>
96 <property name="top-attach">0</property>
97 <property name="left-attach">0</property>
98 </packing>
99 </child>
100
101 <child>
102 <object class="GtkBox">
103 <property name="visible">True</property>
104 <property name="hexpand">True</property>
105 </object>
106 <packing>
107 <property name="top-attach">0</property>
108 <property name="left-attach">2</property>
109 </packing>
110 </child>
111
112 <child>
113 <object class="GtkBox">
114 <property name="visible">True</property>
115 <property name="can_focus">False</property>
116 <property name="spacing">12</property>
117 <property name="orientation">vertical</property>
118 <property name="hexpand">True</property>
119 <property name="width-request">300</property>
120 <child>
121 <object class="GtkLabel" id="offline_label">
122 <property name="visible">True</property>
123 <property name="can_focus">False</property>
124 <property name="wrap">True</property>
125 <property name="label" translatable="yes">No internet connection — connect to set up new online accounts</property>
126 </object>
127 </child>
128 <child>
129 <object class="GtkFrame" id="accounts_frame">
130 <property name="can_focus">False</property>
131 <child>
132 <object class="GtkListBox" id="accounts_listbox">
133 <property name="visible">True</property>
134 <property name="can_focus">True</property>
135 <property name="selection_mode">none</property>
136 <signal name="row-activated" handler="on_listbox_row_activated" object="CcGoaPanel" swapped="yes" />
137 </object>
138 </child>
139 </object>
140 </child>
141 <child>
142 <object class="GtkLabel">
143 <property name="visible">True</property>
144 <property name="can_focus">False</property>
145 <property name="margin-top">24</property>
146 <property name="xalign">0</property>
147 <property name="label" translatable="yes">Add an account</property>
148 <attributes>
149 <attribute name="weight" value="bold" />
150 </attributes>
151 </object>
152 </child>
153 <child>
154 <object class="GtkFrame">
155 <property name="visible">True</property>
156 <property name="can_focus">False</property>
157 <child>
158 <object class="GtkListBox" id="providers_listbox">
159 <property name="visible">True</property>
160 <property name="can_focus">True</property>
161 <property name="selection_mode">none</property>
162 <signal name="row-activated" handler="on_provider_row_activated" object="CcGoaPanel" swapped="yes" />
163 <child>
164 <object class="GtkListBoxRow" id="more_providers_row">
165 <property name="visible">True</property>
166 <property name="can_focus">True</property>
167 <child>
168 <object class="GtkImage">
169 <property name="visible">True</property>
170 <property name="can_focus">False</property>
171 <property name="hexpand">True</property>
172 <property name="margin">22</property>
173 <property name="icon-name">view-more-symbolic</property>
174 </object>
175 </child>
176 </object>
177 </child>
178 </object>
179 </child>
180 </object>
181 </child>
182 </object>
183 <packing>
184 <property name="top-attach">0</property>
185 <property name="left-attach">1</property>
186 </packing>
187 </child>
188 </object>
189 </child>
190 </object>
191 </child>
192 </object>
193 </child>
194 </template>
195 <object class="GtkDialog" id="edit_account_dialog">
196 <property name="can_focus">False</property>
197 <property name="type_hint">dialog</property>
198 <property name="use_header_bar">1</property>
199 <property name="resizable">True</property>
200 <property name="modal">True</property>
201 <signal name="delete-event" handler="on_edit_account_dialog_delete_event" object="CcGoaPanel" swapped="yes" />
202 <child type="titlebar">
203 <object class="GtkHeaderBar" id="edit_account_headerbar">
204 <property name="visible">True</property>
205 <property name="can_focus">False</property>
206 <property name="show_close_button">False</property>
207 </object>
208 </child>
209 <child internal-child="vbox">
210 <object class="GtkBox">
211 <property name="can_focus">False</property>
212 <property name="orientation">vertical</property>
213 <property name="border_width">0</property>
214 <child>
215 <object class="GtkStack" id="stack">
216 <property name="visible">True</property>
217 <property name="can_focus">False</property>
218 <property name="transition_type">crossfade</property>
219 <property name="homogeneous">False</property>
220 <child>
221 <object class="GtkBox" id="new_account_vbox">
222 <property name="visible">True</property>
223 <property name="can_focus">False</property>
224 </object>
225 <packing>
226 <property name="name">new-account</property>
227 </packing>
228 </child>
229 <child>
230 <object class="GtkBox">
231 <property name="visible">True</property>
232 <property name="can_focus">False</property>
233 <property name="margin">24</property>
234 <property name="spacing">24</property>
235 <property name="orientation">vertical</property>
236 <child>
237 <object class="GtkBox" id="accounts_vbox">
238 <property name="visible">True</property>
239 <property name="can_focus">False</property>
240 <property name="vexpand">True</property>
241 <property name="orientation">vertical</property>
242 <property name="margin-start">18</property>
243 <property name="margin-end">18</property>
244 <property name="spacing">18</property>
245 </object>
246 </child>
247 <child>
248 <object class="GtkButton" id="remove_account_button">
249 <property name="visible">True</property>
250 <property name="can_focus">True</property>
251 <property name="valign">end</property>
252 <property name="halign">end</property>
253 <property name="label" translatable="yes">Remove Account</property>
254 <signal name="clicked" handler="on_remove_button_clicked" object="CcGoaPanel" swapped="yes" />
255 <style>
256 <class name="destructive-action" />
257 </style>
258 </object>
259 </child>
260 </object>
261 <packing>
262 <property name="name">editor</property>
263 </packing>
264 </child>
265 </object>
266 </child>
267 </object>
268 </child>
269 </object>
270</interface>
0271
=== added file 'panels/online-accounts/unity-online-accounts-panel.desktop.in.in'
--- panels/online-accounts/unity-online-accounts-panel.desktop.in.in 1970-01-01 00:00:00 +0000
+++ panels/online-accounts/unity-online-accounts-panel.desktop.in.in 2018-02-13 09:06:22 +0000
@@ -0,0 +1,15 @@
1[Desktop Entry]
2Exec=unity-control-center online-accounts
3Icon=unity-online-accounts
4Terminal=false
5Type=Application
6NoDisplay=false
7StartupNotify=true
8Categories=GNOME;GTK;Settings;DesktopSettings;X-Unity-Settings-Panel;X-GNOME-PersonalSettings;OnlineAccounts;
9OnlyShowIn=Unity;
10X-Unity-Settings-Panel=online-accounts
11# Translators: those are keywords for the online-accounts control-center panel
12Keywords=Google;Facebook;Twitter;Yahoo;Web;Online;Chat;Calendar;Mail;Contact;ownCloud;Kerberos;IMAP;SMTP;Pocket;ReadItLater;
13Name=Online Accounts
14Comment=Connect your online accounts
15X-Ubuntu-Gettext-Domain=unity-control-center
016
=== modified file 'po/POTFILES.in'
--- po/POTFILES.in 2017-12-07 05:45:44 +0000
+++ po/POTFILES.in 2018-02-13 09:06:22 +0000
@@ -92,7 +92,10 @@
92panels/screen-sharing/vino-message-box.c92panels/screen-sharing/vino-message-box.c
93panels/screen-sharing/cc-screen-sharing-panel.c93panels/screen-sharing/cc-screen-sharing-panel.c
94panels/screen-sharing/unity-screen-sharing-panel.desktop.in.in94panels/screen-sharing/unity-screen-sharing-panel.desktop.in.in
95[type: gettext/glade]panels/screen-sharing/cc-screen-sharing-panel.ui95[type: gettext/glade]panels/screen-sharing/screen-sharing-panel.ui
96panels/online-accounts/cc-online-accounts-panel.c
97panels/online-accounts/unity-online-accounts-panel.desktop.in.in
98[type: gettext/glade]panels/online-accounts/online-accounts.ui
96panels/sound/cc-sound-panel.c99panels/sound/cc-sound-panel.c
97panels/sound/gvc-balance-bar.c100panels/sound/gvc-balance-bar.c
98panels/sound/gvc-channel-bar.c101panels/sound/gvc-channel-bar.c
99102
=== modified file 'shell/Makefile.am'
--- shell/Makefile.am 2017-04-06 13:23:05 +0000
+++ shell/Makefile.am 2018-02-13 09:06:22 +0000
@@ -54,6 +54,8 @@
54 cc-shell.h \54 cc-shell.h \
55 cc-editable-entry.c \55 cc-editable-entry.c \
56 cc-editable-entry.h \56 cc-editable-entry.h \
57 list-box-helper.h \
58 list-box-helper.c \
57 $(NULL)59 $(NULL)
5860
59libunity_control_center_la_LDFLAGS = \61libunity_control_center_la_LDFLAGS = \
6062
=== added file 'shell/list-box-helper.c'
--- shell/list-box-helper.c 1970-01-01 00:00:00 +0000
+++ shell/list-box-helper.c 2018-02-13 09:06:22 +0000
@@ -0,0 +1,110 @@
1/*
2 * Copyright (C) 2014 Red Hat, Inc
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
16 *
17 */
18
19#include "list-box-helper.h"
20
21#define MAX_ROWS_VISIBLE 5
22
23void
24cc_list_box_update_header_func (GtkListBoxRow *row,
25 GtkListBoxRow *before,
26 gpointer user_data)
27{
28 GtkWidget *current;
29
30 if (before == NULL)
31 {
32 gtk_list_box_row_set_header (row, NULL);
33 return;
34 }
35
36 current = gtk_list_box_row_get_header (row);
37 if (current == NULL)
38 {
39 current = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
40 gtk_widget_show (current);
41 gtk_list_box_row_set_header (row, current);
42 }
43}
44
45void
46cc_list_box_adjust_scrolling (GtkListBox *listbox)
47{
48 GtkWidget *scrolled_window;
49 GList *children;
50 guint n_rows, num_max_rows;
51
52 scrolled_window = g_object_get_data (G_OBJECT (listbox), "cc-scrolling-scrolled-window");
53 if (!scrolled_window)
54 return;
55
56 children = gtk_container_get_children (GTK_CONTAINER (listbox));
57 n_rows = g_list_length (children);
58
59 num_max_rows = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (listbox), "cc-max-rows-visible"));
60
61 if (n_rows >= num_max_rows)
62 {
63 gint total_row_height = 0;
64 GList *l;
65 guint i;
66
67 for (l = children, i = 0; l != NULL && i < num_max_rows; l = l->next, i++) {
68 gint row_height;
69 gtk_widget_get_preferred_height (GTK_WIDGET (l->data), &row_height, NULL);
70 total_row_height += row_height;
71 }
72
73 gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (scrolled_window), total_row_height);
74 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
75 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
76 }
77 else
78 {
79 gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (scrolled_window), -1);
80 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
81 GTK_POLICY_NEVER, GTK_POLICY_NEVER);
82 }
83
84 g_list_free (children);
85}
86
87void
88cc_list_box_setup_scrolling (GtkListBox *listbox,
89 guint num_max_rows)
90{
91 GtkWidget *parent;
92 GtkWidget *scrolled_window;
93
94 parent = gtk_widget_get_parent (GTK_WIDGET (listbox));
95 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
96 gtk_widget_show (scrolled_window);
97
98 g_object_ref (listbox);
99 gtk_container_remove (GTK_CONTAINER (parent), GTK_WIDGET (listbox));
100 gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (listbox));
101 g_object_unref (listbox);
102
103 gtk_container_add (GTK_CONTAINER (parent), scrolled_window);
104
105 if (num_max_rows == 0)
106 num_max_rows = MAX_ROWS_VISIBLE;
107
108 g_object_set_data (G_OBJECT (listbox), "cc-scrolling-scrolled-window", scrolled_window);
109 g_object_set_data (G_OBJECT (listbox), "cc-max-rows-visible", GUINT_TO_POINTER (num_max_rows));
110}
0111
=== added file 'shell/list-box-helper.h'
--- shell/list-box-helper.h 1970-01-01 00:00:00 +0000
+++ shell/list-box-helper.h 2018-02-13 09:06:22 +0000
@@ -0,0 +1,31 @@
1/*
2 * Copyright (C) 2014 Red Hat, Inc
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
16 *
17 */
18
19#include <gtk/gtk.h>
20
21void
22cc_list_box_update_header_func (GtkListBoxRow *row,
23 GtkListBoxRow *before,
24 gpointer user_data);
25
26void
27cc_list_box_adjust_scrolling (GtkListBox *listbox);
28
29void
30cc_list_box_setup_scrolling (GtkListBox *listbox,
31 guint num_rows);

Subscribers

People subscribed via source and target branches