Compare commits

...

5 Commits

Author SHA1 Message Date
Georges Basile Stavracas Neto
fd095e82e0 online-accounts: Only show the accounts list when there are accounts
When the user has no account set, the current implementation of the Online
Accounts panel shows a weird 1px line that is the empty list.

Fix that by only showing the list when there are accounts available.

https://bugzilla.gnome.org/show_bug.cgi?id=774222
2017-02-16 12:28:07 +01:00
Georges Basile Stavracas Neto
572b853349 online-accounts: Make the account editor box vertical
When credentials expire, they're being added horizontally since
this is the default value of the GtkOrientable:orientation property.

Fix that by making the account editor box vertical, and adding some
spacing.

https://bugzilla.gnome.org/show_bug.cgi?id=774222
2017-02-16 12:27:33 +01:00
Georges Basile Stavracas Neto
219d628fb0 online-accounts: Align the panel widgets in the middle
The current implementation of the Online Accounts panel allows
2 states: either the widgets of the panel fill the whole horizontal
space, or they shrink and fill only the absolutely minimum. The
ideal solution, however, is to make them grow with the panel.

Fix that by turn the main box into a GtkGrid, and adding stub widgets
that expand horizontally and pull the main widgets to the middle,
allowing them to cover at most 1/3 of the screen.

https://bugzilla.gnome.org/show_bug.cgi?id=774222
2017-02-16 12:26:20 +01:00
Georges Basile Stavracas Neto
d615242528 online-accounts: Add an offline message label
When offline, we currently block the new accounts listbox
so that users can't add new accounts. There is, however,
no visual indication that we're offline, besides the listbox.

Fix that by adding a descriptive label that's only visible
when offline.

https://bugzilla.gnome.org/show_bug.cgi?id=774222
2017-02-16 12:12:17 +01:00
Georges Basile Stavracas Neto
eaceeb7201 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
2017-02-16 12:11:56 +01:00
2 changed files with 168 additions and 6 deletions

View File

@@ -42,12 +42,15 @@ struct _CcGoaPanel
GoaObject *active_object;
GoaObject *removed_object;
GtkWidget *accounts_frame;
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;
GtkWidget *offline_label;
GtkWidget *providers_listbox;
GtkWidget *remove_account_button;
GtkWidget *stack;
@@ -123,6 +126,7 @@ add_provider_row (CcGoaPanel *self,
GoaProvider *provider)
{
GIcon *icon;
GoaProviderFeatures features;
GtkWidget *image;
GtkWidget *label;
GtkWidget *row;
@@ -131,7 +135,6 @@ add_provider_row (CcGoaPanel *self,
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);
@@ -159,13 +162,75 @@ 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 == GTK_LIST_BOX_ROW (self->more_providers_row))
return 1;
else if (b == GTK_LIST_BOX_ROW (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)
{
if (a_branded)
return -1;
else
return 1;
}
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 (CcGoaPanel *self,
GtkListBoxRow *activated_row)
@@ -174,6 +239,13 @@ on_provider_row_activated (CcGoaPanel *self,
GoaObject *object;
GError *error;
/* Show More row */
if (activated_row == GTK_LIST_BOX_ROW (self->more_providers_row))
{
show_non_branded_providers (self);
return;
}
error = NULL;
provider = g_object_get_data (G_OBJECT (activated_row), "goa-provider");
@@ -339,9 +411,17 @@ 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();
g_object_bind_property (monitor, "network-available",
panel->offline_label, "visible",
G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN);
g_object_bind_property (monitor, "network-available",
panel->providers_listbox, "sensitive",
G_BINDING_SYNC_CREATE);
@@ -376,7 +456,7 @@ cc_goa_panel_init (CcGoaPanel *panel)
fill_accounts_listbox (panel);
goa_provider_get_all (get_all_providers_cb, panel);
gtk_widget_show_all (GTK_WIDGET (panel));
gtk_widget_show (GTK_WIDGET (panel));
}
static const char *
@@ -416,13 +496,16 @@ cc_goa_panel_class_init (CcGoaPanelClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/online-accounts/online-accounts.ui");
gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, accounts_frame);
gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, accounts_listbox);
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);
gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, offline_label);
gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, providers_listbox);
gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, remove_account_button);
gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, stack);
@@ -637,6 +720,7 @@ on_account_added (GoaClient *client,
/* Add to the listbox */
gtk_container_add (GTK_CONTAINER (self->accounts_listbox), row);
gtk_widget_show_all (row);
gtk_widget_show (self->accounts_frame);
g_clear_pointer (&title, g_free);
g_clear_object (&gicon);
@@ -674,10 +758,14 @@ on_account_removed (GoaClient *client,
if (row_object == object)
{
gtk_widget_destroy (l->data);
children = g_list_remove (children, l->data);
break;
}
}
/* Hide the list if we removed the last account */
gtk_widget_set_visible (self->accounts_frame, children != NULL);
g_list_free (children);
}

View File

@@ -70,10 +70,11 @@
<property name="hscrollbar_policy">never</property>
<property name="min_content_height">350</property>
<child>
<object class="GtkBox">
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">18</property>
<property name="row-spacing">18</property>
<property name="column-spacing">18</property>
<property name="orientation">vertical</property>
<property name="margin_start">32</property>
<property name="margin_end">32</property>
@@ -81,6 +82,35 @@
<property name="margin_bottom">18</property>
<property name="hexpand">True</property>
<property name="width-request">300</property>
<!--
Stub boxes to pull the widgets to the middle, and yet allow them to
grow and cover a third of the available space
-->
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="top-attach">0</property>
<property name="left-attach">0</property>
<property name="height">5</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="top-attach">0</property>
<property name="left-attach">2</property>
<property name="height">5</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
@@ -90,10 +120,25 @@
<attribute name="scale" value="1.66" />
</attributes>
</object>
<packing>
<property name="top-attach">0</property>
<property name="left-attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="offline_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="wrap">True</property>
<property name="label" translatable="yes">No internet connection — connect to setup new online accounts</property>
</object>
<packing>
<property name="top-attach">1</property>
<property name="left-attach">1</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="accounts_frame">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkListBox" id="accounts_listbox">
@@ -104,6 +149,10 @@
</object>
</child>
</object>
<packing>
<property name="top-attach">2</property>
<property name="left-attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
@@ -116,6 +165,10 @@
<attribute name="weight" value="bold" />
</attributes>
</object>
<packing>
<property name="top-attach">3</property>
<property name="left-attach">1</property>
</packing>
</child>
<child>
<object class="GtkFrame">
@@ -127,9 +180,28 @@
<property name="can_focus">True</property>
<property name="selection_mode">none</property>
<signal name="row-activated" handler="on_provider_row_activated" object="CcGoaPanel" swapped="yes" />
<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>
<packing>
<property name="top-attach">4</property>
<property name="left-attach">1</property>
</packing>
</child>
</object>
</child>
@@ -183,6 +255,8 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
</object>
</child>
<child>