[gnome-control-center/wip/gbsneto/new-goa-panel: 71/76] online-accounts: add a bottom row to display non-branded providers
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/gbsneto/new-goa-panel: 71/76] online-accounts: add a bottom row to display non-branded providers
- Date: Wed, 25 Jan 2017 22:53:47 +0000 (UTC)
commit fb85b46c728adb5527b2764ce4542e4e2eaabe09
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Nov 10 14:46:38 2016 -0200
online-accounts: add a bottom row to display non-branded providers
As per the mockups, and mimicking the dialog behavior, add a bottom
row that shows non-branded providers.
https://bugzilla.gnome.org/show_bug.cgi?id=774222
panels/online-accounts/cc-online-accounts-panel.c | 76 ++++++++++++++++++++-
panels/online-accounts/online-accounts.ui | 15 ++++
2 files changed, 88 insertions(+), 3 deletions(-)
---
diff --git a/panels/online-accounts/cc-online-accounts-panel.c
b/panels/online-accounts/cc-online-accounts-panel.c
index 9cc5408..7ff2e54 100644
--- a/panels/online-accounts/cc-online-accounts-panel.c
+++ b/panels/online-accounts/cc-online-accounts-panel.c
@@ -49,6 +49,7 @@ struct _CcGoaPanel
GtkWidget *accounts_listbox;
GtkWidget *edit_account_dialog;
GtkWidget *edit_account_headerbar;
+ GtkWidget *more_providers_row;
GtkWidget *new_account_vbox;
GtkWidget *notification_label;
GtkWidget *notification_revealer;
@@ -130,16 +131,16 @@ static void
add_provider_row (CcGoaPanel *self,
GoaProvider *provider)
{
- GIcon *icon;
+ GoaProviderFeatures features;
GtkWidget *image;
GtkWidget *label;
GtkWidget *row;
GtkWidget *row_grid;
+ GIcon *icon;
gchar *markup;
gchar *name;
row = gtk_list_box_row_new ();
- gtk_container_add (GTK_CONTAINER (self->providers_listbox), row);
row_grid = gtk_grid_new ();
gtk_orientable_set_orientation (GTK_ORIENTABLE (row_grid), GTK_ORIENTATION_HORIZONTAL);
@@ -167,13 +168,70 @@ add_provider_row (CcGoaPanel *self,
gtk_label_set_markup (GTK_LABEL (label), markup);
gtk_container_add (GTK_CONTAINER (row_grid), label);
- gtk_widget_show_all (row);
+ /* Check if the row should be shown initially */
+ features = goa_provider_get_provider_features (provider);
+
+ if ((features & GOA_PROVIDER_FEATURE_BRANDED) > 0)
+ gtk_widget_show_all (row);
+
+ gtk_container_add (GTK_CONTAINER (self->providers_listbox), row);
g_free (markup);
g_free (name);
g_object_unref (icon);
}
+static gint
+sort_providers_func (GtkListBoxRow *a,
+ GtkListBoxRow *b,
+ gpointer user_data)
+{
+ GoaProvider *a_provider, *b_provider;
+ CcGoaPanel *self;
+ gboolean a_branded, b_branded;
+
+ self = user_data;
+
+ if (a == (GtkListBoxRow*) self->more_providers_row)
+ return 1;
+ else if (b == (GtkListBoxRow*) self->more_providers_row)
+ return -1;
+
+ a_provider = g_object_get_data (G_OBJECT (a), "goa-provider");
+ b_provider = g_object_get_data (G_OBJECT (b), "goa-provider");
+
+ a_branded = (goa_provider_get_provider_features (a_provider) & GOA_PROVIDER_FEATURE_BRANDED) > 0;
+ b_branded = (goa_provider_get_provider_features (b_provider) & GOA_PROVIDER_FEATURE_BRANDED) > 0;
+
+ if (a_branded != b_branded)
+ return b_branded - a_branded;
+
+ return gtk_list_box_row_get_index (b) - gtk_list_box_row_get_index (a);
+}
+
+static void
+show_non_branded_providers (CcGoaPanel *self)
+{
+ GList *children, *l;
+
+ children = gtk_container_get_children (GTK_CONTAINER (self->providers_listbox));
+
+ for (l = children; l != NULL; l = l->next)
+ {
+ GoaProvider *provider = g_object_get_data (l->data, "goa-provider");
+
+ if (!provider)
+ continue;
+
+ if ((goa_provider_get_provider_features (provider) & GOA_PROVIDER_FEATURE_BRANDED) == 0)
+ gtk_widget_show_all (l->data);
+ }
+
+ gtk_widget_hide (self->more_providers_row);
+
+ g_list_free (children);
+}
+
static void
on_provider_row_activated (GtkListBox *listbox,
GtkListBoxRow *activated_row,
@@ -183,6 +241,13 @@ on_provider_row_activated (GtkListBox *listbox,
GoaObject *object;
GError *error;
+ /* Show More row */
+ if (activated_row == (GtkListBoxRow*) self->more_providers_row)
+ {
+ show_non_branded_providers (self);
+ return;
+ }
+
error = NULL;
provider = g_object_get_data (G_OBJECT (activated_row), "goa-provider");
@@ -357,6 +422,10 @@ cc_goa_panel_init (CcGoaPanel *panel)
cc_list_box_update_header_func,
NULL,
NULL);
+ gtk_list_box_set_sort_func (GTK_LIST_BOX (panel->providers_listbox),
+ sort_providers_func,
+ panel,
+ NULL);
monitor = g_network_monitor_get_default();
@@ -438,6 +507,7 @@ cc_goa_panel_class_init (CcGoaPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, accounts_vbox);
gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, edit_account_dialog);
gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, edit_account_headerbar);
+ gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, more_providers_row);
gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, new_account_vbox);
gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, notification_label);
gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, notification_revealer);
diff --git a/panels/online-accounts/online-accounts.ui b/panels/online-accounts/online-accounts.ui
index 652b761..f91a484 100644
--- a/panels/online-accounts/online-accounts.ui
+++ b/panels/online-accounts/online-accounts.ui
@@ -128,6 +128,21 @@
<property name="can_focus">True</property>
<property name="selection_mode">none</property>
<signal name="row-activated" handler="on_provider_row_activated" object="CcGoaPanel"
swapped="no" />
+ <child>
+ <object class="GtkListBoxRow" id="more_providers_row">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="margin">12</property>
+ <property name="icon-name">view-more-symbolic</property>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]