[gnome-control-center] online-accounts: Improve the layout when there is no configured account



commit 8138227ae3961cc6b39e17ddcb3465107970bbc3
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed Jun 20 14:15:38 2012 +0200

    online-accounts: Improve the layout when there is no configured account
    
    Use a GtkButton instead of a GtkLabel to incite the user to configure
    a new account, and insensitize the GtkBox on the left.
    
    Fixes: https://bugzilla.gnome.org/672421

 panels/online-accounts/cc-online-accounts-panel.c |   49 +++++++++++-
 panels/online-accounts/online-accounts.ui         |   84 +++++++++++++++++----
 2 files changed, 115 insertions(+), 18 deletions(-)
---
diff --git a/panels/online-accounts/cc-online-accounts-panel.c b/panels/online-accounts/cc-online-accounts-panel.c
index 729b025..7aeaa94 100644
--- a/panels/online-accounts/cc-online-accounts-panel.c
+++ b/panels/online-accounts/cc-online-accounts-panel.c
@@ -67,6 +67,9 @@ static void on_toolbar_add_button_clicked (GtkToolButton *button,
 static void on_toolbar_remove_button_clicked (GtkToolButton *button,
                                               gpointer       user_data);
 
+static void on_add_button_clicked (GtkButton *button,
+                                   gpointer   user_data);
+
 static void on_account_changed (GoaClient  *client,
                                 GoaObject  *object,
                                 gpointer    user_data);
@@ -98,6 +101,7 @@ goa_panel_finalize (GObject *object)
 static void
 goa_panel_init (GoaPanel *panel)
 {
+  GtkWidget *button;
   GtkWidget *w;
   GError *error;
   GtkStyleContext *context;
@@ -140,6 +144,12 @@ goa_panel_init (GoaPanel *panel)
                     G_CALLBACK (on_tree_view_selection_changed),
                     panel);
 
+  button = GTK_WIDGET (gtk_builder_get_object (panel->builder, "accounts-button-add"));
+  g_signal_connect (button,
+                    "clicked",
+                    G_CALLBACK (on_add_button_clicked),
+                    panel);
+
   panel->accounts_vbox = GTK_WIDGET (gtk_builder_get_object (panel->builder, "accounts-vbox"));
 
   /* TODO: probably want to avoid _sync() ... */
@@ -271,7 +281,16 @@ show_page (GoaPanel *panel,
 static void
 show_page_nothing_selected (GoaPanel *panel)
 {
+  GtkWidget *box;
+  GtkWidget *label;
+
   show_page (panel, 0);
+
+  box = GTK_WIDGET (gtk_builder_get_object (panel->builder, "accounts-tree-box"));
+  gtk_widget_set_sensitive (box, FALSE);
+
+  label = GTK_WIDGET (gtk_builder_get_object (panel->builder, "accounts-tree-label"));
+  gtk_widget_show (label);
 }
 
 static void
@@ -339,6 +358,7 @@ show_page_account (GoaPanel  *panel,
 {
   GList *children;
   GList *l;
+  GtkWidget *box;
   GtkWidget *grid;
   GtkWidget *left_grid;
   GtkWidget *right_grid;
@@ -351,6 +371,11 @@ show_page_account (GoaPanel  *panel,
   provider = NULL;
 
   show_page (panel, 1);
+  box = GTK_WIDGET (gtk_builder_get_object (panel->builder, "accounts-tree-box"));
+  gtk_widget_set_sensitive (box, TRUE);
+
+  label = GTK_WIDGET (gtk_builder_get_object (panel->builder, "accounts-tree-label"));
+  gtk_widget_hide (label);
 
   /* Out with the old */
   children = gtk_container_get_children (GTK_CONTAINER (panel->accounts_vbox));
@@ -459,10 +484,8 @@ on_account_changed (GoaClient  *client,
 /* ---------------------------------------------------------------------------------------------------- */
 
 static void
-on_toolbar_add_button_clicked (GtkToolButton *button,
-                               gpointer       user_data)
+add_account (GoaPanel *panel)
 {
-  GoaPanel *panel = GOA_PANEL (user_data);
   GtkWindow *parent;
   GtkWidget *dialog;
   gint response;
@@ -541,6 +564,16 @@ on_toolbar_add_button_clicked (GtkToolButton *button,
   g_list_free (providers);
 }
 
+/* ---------------------------------------------------------------------------------------------------- */
+
+static void
+on_toolbar_add_button_clicked (GtkToolButton *button,
+                               gpointer       user_data)
+{
+  GoaPanel *panel = GOA_PANEL (user_data);
+  add_account (panel);
+}
+
 static void
 remove_account_cb (GoaAccount    *account,
                    GAsyncResult  *res,
@@ -611,3 +644,13 @@ on_toolbar_remove_button_clicked (GtkToolButton *button,
       g_object_unref (object);
     }
 }
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static void
+on_add_button_clicked (GtkButton *button,
+                       gpointer   user_data)
+{
+  GoaPanel *panel = GOA_PANEL (user_data);
+  add_account (panel);
+}
diff --git a/panels/online-accounts/online-accounts.ui b/panels/online-accounts/online-accounts.ui
index fe9a091..108bf73 100644
--- a/panels/online-accounts/online-accounts.ui
+++ b/panels/online-accounts/online-accounts.ui
@@ -16,27 +16,44 @@
             <property name="orientation">vertical</property>
             <property name="spacing">0</property>
             <child>
-              <object class="GtkScrolledWindow" id="accounts-tree-scrolledwindow">
+              <object class="GtkOverlay" id="accounts-tree-overlay">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="hscrollbar_policy">never</property>
-                <property name="shadow_type">in</property>
-                <property name="min_content_height">250</property>
                 <child>
-                  <object class="GtkTreeView" id="accounts-tree-treeview">
-                    <property name="width_request">200</property>
+                  <object class="GtkScrolledWindow" id="accounts-tree-scrolledwindow">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                    <property name="headers_visible">False</property>
-                    <property name="show_expanders">False</property>
-                    <property name="level_indentation">12</property>
-                    <child internal-child="selection">
-                      <object class="GtkTreeSelection" id="treeview-selection">
-                        <property name="mode">browse</property>
+                    <property name="hscrollbar_policy">never</property>
+                    <property name="shadow_type">in</property>
+                    <property name="min_content_height">250</property>
+                    <child>
+                      <object class="GtkTreeView" id="accounts-tree-treeview">
+                        <property name="width_request">200</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="headers_visible">False</property>
+                        <property name="show_expanders">False</property>
+                        <property name="level_indentation">12</property>
+                        <child internal-child="selection">
+                          <object class="GtkTreeSelection" id="treeview-selection">
+                            <property name="mode">browse</property>
+                          </object>
+                        </child>
                       </object>
                     </child>
                   </object>
                 </child>
+                <child type="overlay">
+                  <object class="GtkLabel" id="accounts-tree-label">
+                    <property name="can_focus">False</property>
+                    <property name="halign">center</property>
+                    <property name="valign">center</property>
+                    <property name="no-show-all">True</property>
+                    <property name="justify">center</property>
+                    <property name="label" translatable="yes">No online accounts configured</property>
+                    <property name="max-width-chars">18</property>
+                    <property name="wrap">True</property>
+                  </object>
+                </child>
               </object>
               <packing>
                 <property name="expand">True</property>
@@ -98,11 +115,48 @@
               <object class="GtkAlignment" id="alignment2">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
+                <property name="bottom_padding">18</property>
                 <child>
-                  <object class="GtkLabel" id="label4">
+                  <object class="GtkBox" id="box1">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="label" translatable="yes">Select an account</property>
+                    <property name="valign">center</property>
+                    <property name="vexpand">True</property>
+                    <property name="orientation">vertical</property>
+                    <property name="spacing">6</property>
+                    <child>
+                      <object class="GtkButton" id="accounts-button-add">
+                        <property name="label" translatable="yes">Add an online account</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">True</property>
+                        <property name="halign">center</property>
+                        <property name="use_action_appearance">False</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label3">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Adding an account allows your applications to access it for documents, mail, contacts, calendar, chat and more.</property>
+                        <property name="justify">center</property>
+                        <property name="wrap">True</property>
+                        <style>
+                          <class name="dim-label"/>
+                        </style>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
                   </object>
                 </child>
               </object>



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