[gnome-online-accounts] provider: Use an info bar for accounts needing attention



commit 0506f878d54a52109b4b6d7375adf356ed67e768
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Apr 27 16:43:43 2017 -0300

    provider: Use an info bar for accounts needing attention
    
    Per the mockups at [1], use a GtkInfoBar to show the expired
    credentials widgets. The margins and spacing are set around the GtkGrid
    containing the account description because they are no longer set on
    the higher level GtkBoxes.
    
    Some changes by Debarshi Ray.
    
    [1] 
https://raw.githubusercontent.com/gnome-design-team/gnome-mockups/master/system-settings/online-accounts/aday-alt/online-accounts-account-dialogs.png
    
    https://bugzilla.gnome.org/show_bug.cgi?id=779368

 src/goabackend/goaimapsmtpprovider.c  |    7 +++++--
 src/goabackend/goaprovider.c          |    7 +++++--
 src/goabackend/goatelepathyprovider.c |    7 +++++--
 src/goabackend/goautils.c             |   30 ++++++++++++++++++------------
 4 files changed, 33 insertions(+), 18 deletions(-)
---
diff --git a/src/goabackend/goaimapsmtpprovider.c b/src/goabackend/goaimapsmtpprovider.c
index c48dc81..f0af116 100644
--- a/src/goabackend/goaimapsmtpprovider.c
+++ b/src/goabackend/goaimapsmtpprovider.c
@@ -1521,9 +1521,14 @@ show_account (GoaProvider         *provider,
 
   row = 0;
 
+  goa_utils_account_add_attention_needed (client, object, provider, vbox);
+
   grid = gtk_grid_new ();
   gtk_widget_set_halign (grid, GTK_ALIGN_CENTER);
   gtk_widget_set_hexpand (grid, TRUE);
+  gtk_widget_set_margin_end (grid, 42);
+  gtk_widget_set_margin_start (grid, 42);
+  gtk_widget_set_margin_top (grid, 24);
   gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
   gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
   gtk_box_pack_start (vbox, grid, FALSE, TRUE, 0);
@@ -1569,8 +1574,6 @@ show_account (GoaProvider         *provider,
       show_label (GTK_WIDGET (grid), row++, _("SMTP"), value_str);
   g_free (value_str_1);
   g_free (value_str);
-
-  goa_utils_account_add_attention_needed (client, object, provider, vbox);
 }
 
 /* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/goabackend/goaprovider.c b/src/goabackend/goaprovider.c
index 8691c39..8b4629c 100644
--- a/src/goabackend/goaprovider.c
+++ b/src/goabackend/goaprovider.c
@@ -587,9 +587,14 @@ goa_provider_show_account_real (GoaProvider         *provider,
 
   row = 0;
 
+  goa_utils_account_add_attention_needed (client, object, provider, vbox);
+
   grid = gtk_grid_new ();
   gtk_widget_set_halign (grid, GTK_ALIGN_CENTER);
   gtk_widget_set_hexpand (grid, TRUE);
+  gtk_widget_set_margin_end (grid, 42);
+  gtk_widget_set_margin_start (grid, 42);
+  gtk_widget_set_margin_top (grid, 24);
   gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
   gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
   gtk_box_pack_start (vbox, grid, FALSE, TRUE, 0);
@@ -612,8 +617,6 @@ goa_provider_show_account_real (GoaProvider         *provider,
           label = NULL;
         }
     }
-
-  goa_utils_account_add_attention_needed (client, object, provider, vbox);
 }
 
 /* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/goabackend/goatelepathyprovider.c b/src/goabackend/goatelepathyprovider.c
index 465d415..1b380ae 100644
--- a/src/goabackend/goatelepathyprovider.c
+++ b/src/goabackend/goatelepathyprovider.c
@@ -942,9 +942,14 @@ show_account (GoaProvider         *provider,
   GtkWidget *button_box = NULL;
   gint row = 0;
 
+  goa_utils_account_add_attention_needed (client, object, provider, vbox);
+
   grid = gtk_grid_new ();
   gtk_widget_set_halign (grid, GTK_ALIGN_CENTER);
   gtk_widget_set_hexpand (grid, TRUE);
+  gtk_widget_set_margin_end (grid, 42);
+  gtk_widget_set_margin_start (grid, 42);
+  gtk_widget_set_margin_top (grid, 24);
   gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
   gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
   gtk_box_pack_start (vbox, grid, FALSE, TRUE, 0);
@@ -979,8 +984,6 @@ show_account (GoaProvider         *provider,
 
   goa_util_add_row_widget (GTK_GRID (grid), row++, NULL, button_box);
 
-  goa_utils_account_add_attention_needed (client, object, provider, vbox);
-
   edit_data_unref (data);
 }
 
diff --git a/src/goabackend/goautils.c b/src/goabackend/goautils.c
index 7bbc42c..8c6ce71 100644
--- a/src/goabackend/goautils.c
+++ b/src/goabackend/goautils.c
@@ -66,13 +66,17 @@ attention_needed_data_free (AttentionNeededData *data)
 }
 
 static void
-goa_utils_account_add_attention_needed_button_clicked (GtkButton *button, gpointer user_data)
+goa_utils_account_add_attention_needed_info_bar_response (GtkInfoBar *info_bar,
+                                                          gint        response_id,
+                                                          gpointer    user_data)
 {
   AttentionNeededData *data = (AttentionNeededData *) user_data;
   GtkWidget *parent;
   GError *error;
 
-  parent = gtk_widget_get_toplevel (GTK_WIDGET (button));
+  g_return_if_fail (response_id == GTK_RESPONSE_OK);
+
+  parent = gtk_widget_get_toplevel (GTK_WIDGET (info_bar));
   if (!gtk_widget_is_toplevel (parent))
     {
       g_warning ("Unable to find a toplevel GtkWindow");
@@ -106,9 +110,10 @@ goa_utils_account_add_attention_needed (GoaClient *client, GoaObject *object, Go
 {
   AttentionNeededData *data;
   GoaAccount *account;
-  GtkWidget *button;
+  GtkWidget *content_area;
   GtkWidget *grid;
   GtkWidget *image;
+  GtkWidget *info_bar;
   GtkWidget *label;
   GtkWidget *labels_grid;
 
@@ -116,12 +121,15 @@ goa_utils_account_add_attention_needed (GoaClient *client, GoaObject *object, Go
   if (!goa_account_get_attention_needed (account))
     return;
 
+  info_bar = gtk_info_bar_new ();
+  gtk_container_add (GTK_CONTAINER (vbox), info_bar);
+
+  content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar));
+
   grid = gtk_grid_new ();
   gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), GTK_ORIENTATION_HORIZONTAL);
   gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
-  gtk_widget_set_margin_top (grid, 18);
-  gtk_widget_set_margin_bottom (grid, 6);
-  gtk_box_pack_end (vbox, grid, FALSE, TRUE, 0);
+  gtk_container_add (GTK_CONTAINER (content_area), grid);
 
   image = gtk_image_new_from_icon_name ("dialog-warning", GTK_ICON_SIZE_SMALL_TOOLBAR);
   gtk_widget_set_valign (image, GTK_ALIGN_CENTER);
@@ -145,14 +153,12 @@ goa_utils_account_add_attention_needed (GoaClient *client, GoaObject *object, Go
   gtk_style_context_add_class (gtk_widget_get_style_context (label), "dim-label");
   gtk_container_add (GTK_CONTAINER (labels_grid), label);
 
-  button = gtk_button_new_with_mnemonic (_("_Sign In"));
-  gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
-  gtk_container_add (GTK_CONTAINER (grid), button);
+  gtk_info_bar_add_button (GTK_INFO_BAR (info_bar), _("_Sign In"), GTK_RESPONSE_OK);
 
   data = attention_needed_data_new (client, object, provider);
-  g_signal_connect_data (button,
-                         "clicked",
-                         G_CALLBACK (goa_utils_account_add_attention_needed_button_clicked),
+  g_signal_connect_data (info_bar,
+                         "response",
+                         G_CALLBACK (goa_utils_account_add_attention_needed_info_bar_response),
                          data,
                          (GClosureNotify) attention_needed_data_free,
                          0);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]