[gnome-control-center] online-accounts: Add a providers listbox to the panel
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] online-accounts: Add a providers listbox to the panel
- Date: Tue, 3 Jan 2017 17:00:21 +0000 (UTC)
commit c26f8ae018900a557f88e18c1d818ca88dc225ff
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Nov 9 17:06:18 2016 -0200
online-accounts: Add a providers listbox to the panel
This commit starts moving the contents of the add account dialog
class to the panel itself, by adding a providers listbox below
the list of available account as per the new mockups. As a side effect,
this commit temporarily makes removing an account non-functional.
The next commits are focused on finishing this move and removing
the add account dialog.
https://bugzilla.gnome.org/show_bug.cgi?id=774222
panels/online-accounts/cc-online-accounts-panel.c | 148 +++++++++------------
panels/online-accounts/online-accounts.ui | 25 ++++
2 files changed, 91 insertions(+), 82 deletions(-)
---
diff --git a/panels/online-accounts/cc-online-accounts-panel.c
b/panels/online-accounts/cc-online-accounts-panel.c
index b628015..dfa3315 100644
--- a/panels/online-accounts/cc-online-accounts-panel.c
+++ b/panels/online-accounts/cc-online-accounts-panel.c
@@ -47,6 +47,7 @@ struct _CcGoaPanel
GtkWidget *accounts_tree_label;
GtkWidget *edit_account_dialog;
GtkWidget *edit_account_headerbar;
+ GtkWidget *providers_listbox;
GtkWidget *toolbar;
GtkWidget *toolbar_add_button;
GtkWidget *toolbar_remove_button;
@@ -79,9 +80,10 @@ static void on_account_removed (GoaClient *client,
static void select_account_by_id (CcGoaPanel *panel,
const gchar *account_id);
-static void add_account (CcGoaPanel *panel,
- GoaProvider *provider,
- GVariant *preseed);
+
+static void get_all_providers_cb (GObject *source,
+ GAsyncResult *res,
+ gpointer user_data);
CC_PANEL_REGISTER (CcGoaPanel, cc_goa_panel);
@@ -90,6 +92,58 @@ enum {
PROP_PARAMETERS
};
+/* ---------------------------------------------------------------------------------------------------- */
+
+static void
+add_provider_row (CcGoaPanel *self,
+ GoaProvider *provider)
+{
+ GIcon *icon;
+ GtkWidget *image;
+ GtkWidget *label;
+ GtkWidget *row;
+ GtkWidget *row_grid;
+ 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);
+ gtk_grid_set_column_spacing (GTK_GRID (row_grid), 6);
+ gtk_container_add (GTK_CONTAINER (row), row_grid);
+
+ if (provider == NULL)
+ {
+ g_object_set_data (G_OBJECT (row), "provider", NULL);
+ icon = g_themed_icon_new_with_default_fallbacks ("goa-account");
+ name = g_strdup (C_("Online Account", "Other"));
+ }
+ else
+ {
+ g_object_set_data_full (G_OBJECT (row), "goa-provider", g_object_ref (provider), g_object_unref);
+ icon = goa_provider_get_provider_icon (provider, NULL);
+ name = goa_provider_get_provider_name (provider, NULL);
+ }
+
+ image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);
+ gtk_container_add (GTK_CONTAINER (row_grid), image);
+
+ markup = g_strdup_printf ("<b>%s</b>", name);
+ label = gtk_label_new (NULL);
+ gtk_label_set_markup (GTK_LABEL (label), markup);
+ gtk_container_add (GTK_CONTAINER (row_grid), label);
+
+ gtk_widget_show_all (row);
+
+ g_free (markup);
+ g_free (name);
+ g_object_unref (icon);
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
static gint
sort_func (GtkListBoxRow *a,
GtkListBoxRow *b,
@@ -150,8 +204,6 @@ command_add (CcGoaPanel *panel,
}
}
- add_account (panel, provider, preseed);
-
out:
g_clear_object (&provider);
g_clear_pointer (&preseed, g_variant_unref);
@@ -225,6 +277,10 @@ cc_goa_panel_init (CcGoaPanel *panel)
monitor = g_network_monitor_get_default();
g_object_bind_property (monitor, "network-available",
+ panel->providers_listbox, "sensitive",
+ G_BINDING_SYNC_CREATE);
+
+ g_object_bind_property (monitor, "network-available",
panel->toolbar_add_button, "sensitive",
G_BINDING_SYNC_CREATE);
@@ -256,6 +312,7 @@ cc_goa_panel_init (CcGoaPanel *panel)
panel);
fill_accounts_listbox (panel);
+ goa_provider_get_all (get_all_providers_cb, panel);
gtk_widget_show_all (GTK_WIDGET (panel));
}
@@ -304,6 +361,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, providers_listbox);
gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, toolbar);
gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, toolbar_add_button);
gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, toolbar_remove_button);
@@ -570,100 +628,28 @@ on_account_removed (GoaClient *client,
/* ---------------------------------------------------------------------------------------------------- */
-typedef struct
-{
- CcGoaPanel *panel;
- GoaProvider *provider;
- GVariant *preseed;
-} AddAccountData;
-
static void
get_all_providers_cb (GObject *source,
GAsyncResult *res,
gpointer user_data)
{
- AddAccountData *data = user_data;
- GtkWindow *parent;
- GtkWidget *dialog;
+ CcGoaPanel *self = user_data;
GList *providers;
GList *l;
- GoaObject *object;
- GError *error;
providers = NULL;
if (!goa_provider_get_all_finish (&providers, res, NULL))
- goto out;
-
- parent = GTK_WINDOW (cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (data->panel))));
-
- dialog = goa_panel_add_account_dialog_new (data->panel->client);
- gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
+ return;
for (l = providers; l != NULL; l = l->next)
{
GoaProvider *provider;
provider = GOA_PROVIDER (l->data);
- goa_panel_add_account_dialog_add_provider (GOA_PANEL_ADD_ACCOUNT_DIALOG (dialog), provider);
- }
-
- goa_panel_add_account_dialog_set_preseed_data (GOA_PANEL_ADD_ACCOUNT_DIALOG (dialog),
- data->provider, data->preseed);
-
- gtk_widget_show_all (dialog);
- goa_panel_add_account_dialog_run (GOA_PANEL_ADD_ACCOUNT_DIALOG (dialog));
-
- error = NULL;
- object = goa_panel_add_account_dialog_get_account (GOA_PANEL_ADD_ACCOUNT_DIALOG (dialog), &error);
- gtk_widget_destroy (dialog);
-
- /* We might have an object even when error is set.
- * eg., if we failed to store the credentials in the keyring.
- */
-
- if (object != NULL)
- gtk_widget_hide (data->panel->accounts_tree_label);
-
- if (error != NULL)
- {
- if (!(error->domain == GOA_ERROR && error->code == GOA_ERROR_DIALOG_DISMISSED))
- {
- dialog = gtk_message_dialog_new (parent,
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- _("Error creating account"));
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- "%s",
- error->message);
- gtk_widget_show_all (dialog);
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- }
- g_error_free (error);
+ add_provider_row (self, provider);
}
g_list_free_full (providers, g_object_unref);
-
-out:
- g_clear_object (&data->panel);
- g_clear_object (&data->provider);
- g_clear_pointer (&data->preseed, g_variant_unref);
- g_slice_free (AddAccountData, data);
-}
-
-static void
-add_account (CcGoaPanel *panel,
- GoaProvider *provider,
- GVariant *preseed)
-{
- AddAccountData *data;
-
- data = g_slice_new0 (AddAccountData);
- data->panel = g_object_ref_sink (panel);
- data->provider = (provider != NULL ? g_object_ref (provider) : NULL);
- data->preseed = (preseed != NULL ? g_variant_ref (preseed) : NULL);
- goa_provider_get_all (get_all_providers_cb, data);
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -672,8 +658,6 @@ static void
on_toolbar_add_button_clicked (GtkToolButton *button,
gpointer user_data)
{
- CcGoaPanel *panel = CC_GOA_PANEL (user_data);
- add_account (panel, NULL, NULL);
}
static void
diff --git a/panels/online-accounts/online-accounts.ui b/panels/online-accounts/online-accounts.ui
index 677af2f..033ffd8 100644
--- a/panels/online-accounts/online-accounts.ui
+++ b/panels/online-accounts/online-accounts.ui
@@ -114,6 +114,31 @@
</child>
</object>
</child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin-top">24</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Add an account</property>
+ <attributes>
+ <attribute name="weight" value="bold" />
+ </attributes>
+ </object>
+ </child>
+ <child>
+ <object class="GtkFrame">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkListBox" id="providers_listbox">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="selection_mode">none</property>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]