[gnome-control-center/wip/gbsneto/new-goa-panel: 4/25] online-accounts: use a dialog to manage the online account



commit 83f63f890c42cd4233f0a9bbc0bec113af5f562f
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Nov 9 15:38:53 2016 -0200

    online-accounts: use a dialog to manage the online account
    
    Following the mockups, the Online Accounts panel shall use
    a modal dialog to edit online accounts.
    
    This commit moves the current widgets to a dialog, and show
    this dialog whenever an account is selected.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=774222

 panels/online-accounts/cc-online-accounts-panel.c |   33 ++++++-
 panels/online-accounts/online-accounts.ui         |  104 ++++++++++++---------
 2 files changed, 85 insertions(+), 52 deletions(-)
---
diff --git a/panels/online-accounts/cc-online-accounts-panel.c 
b/panels/online-accounts/cc-online-accounts-panel.c
index 1622e01..6e584bc 100644
--- a/panels/online-accounts/cc-online-accounts-panel.c
+++ b/panels/online-accounts/cc-online-accounts-panel.c
@@ -45,6 +45,8 @@ struct _CcGoaPanel
   GtkWidget *accounts_tree_box;
   GtkWidget *accounts_tree_label;
   GtkWidget *add_account_button;
+  GtkWidget *edit_account_dialog;
+  GtkWidget *edit_account_headerbar;
   GtkWidget *toolbar;
   GtkWidget *toolbar_add_button;
   GtkWidget *toolbar_remove_button;
@@ -268,6 +270,20 @@ cc_goa_panel_get_help_uri (CcPanel *panel)
 }
 
 static void
+cc_goa_panel_constructed (GObject *object)
+{
+  CcGoaPanel *self = CC_GOA_PANEL (object);
+  GtkWindow *parent;
+
+  /* Setup account editor dialog */
+  parent = GTK_WINDOW (cc_shell_get_toplevel (cc_panel_get_shell (CC_PANEL (self))));
+
+  gtk_window_set_transient_for (GTK_WINDOW (self->edit_account_dialog), parent);
+
+  G_OBJECT_CLASS (cc_goa_panel_parent_class)->constructed (object);
+}
+
+static void
 cc_goa_panel_class_init (CcGoaPanelClass *klass)
 {
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
@@ -278,6 +294,7 @@ cc_goa_panel_class_init (CcGoaPanelClass *klass)
 
   object_class->set_property = cc_goa_panel_set_property;
   object_class->finalize = cc_goa_panel_finalize;
+  object_class->constructed = cc_goa_panel_constructed;
 
   g_object_class_override_property (object_class, PROP_PARAMETERS, "parameters");
 
@@ -289,6 +306,8 @@ cc_goa_panel_class_init (CcGoaPanelClass *klass)
   gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, accounts_tree_label);
   gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, accounts_vbox);
   gtk_widget_class_bind_template_child (widget_class, CcGoaPanel, add_account_button);
+  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, 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);
@@ -353,7 +372,15 @@ show_page_account (CcGoaPanel  *panel,
                                  NULL);
     }
 
+  /* Setup the dialog */
+  gtk_header_bar_set_title (GTK_HEADER_BAR (panel->edit_account_headerbar),
+                            goa_account_get_provider_name (account));
+
+  gtk_header_bar_set_subtitle (GTK_HEADER_BAR (panel->edit_account_headerbar),
+                               goa_account_get_presentation_identity (account));
+
   gtk_widget_show_all (panel->accounts_vbox);
+  gtk_widget_show (panel->edit_account_dialog);
 
   g_clear_object (&provider);
 }
@@ -385,8 +412,6 @@ select_account_by_id (CcGoaPanel  *panel,
         }
     }
 
-  gtk_list_box_select_row (GTK_LIST_BOX (panel->accounts_listbox), account_row);
-
   g_list_free (children);
 }
 
@@ -425,9 +450,6 @@ fill_accounts_listbox (CcGoaPanel *self)
   for (l = accounts; l != NULL; l = l->next)
     on_account_added (self->client, l->data, self);
 
-  /* Select the first row */
-  gtk_list_box_select_row (listbox, gtk_list_box_get_row_at_index (listbox, 0));
-
   g_list_free_full (accounts, g_object_unref);
 }
 
@@ -552,7 +574,6 @@ on_account_removed (GoaClient *client,
 
       if (row_object == object)
         {
-          gtk_list_box_select_row (GTK_LIST_BOX (self->accounts_listbox), prev ? prev->data : NULL);
           gtk_widget_destroy (l->data);
           break;
         }
diff --git a/panels/online-accounts/online-accounts.ui b/panels/online-accounts/online-accounts.ui
index 2167db2..18ba771 100644
--- a/panels/online-accounts/online-accounts.ui
+++ b/panels/online-accounts/online-accounts.ui
@@ -104,6 +104,28 @@
             </child>
           </object>
         </child>
+      </object>
+    </child>
+  </template>
+  <object class="GtkDialog" id="edit_account_dialog">
+    <property name="can_focus">False</property>
+    <property name="type_hint">dialog</property>
+    <property name="use_header_bar">1</property>
+    <property name="resizable">False</property>
+    <property name="modal">True</property>
+    <signal name="delete-event" handler="gtk_widget_hide_on_delete" swapped="no" />
+    <child type="titlebar">
+      <object class="GtkHeaderBar" id="edit_account_headerbar">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="show_close_button">True</property>
+      </object>
+    </child>
+    <child internal-child="vbox">
+      <object class="GtkBox">
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="margin">18</property>
         <child>
           <object class="GtkNotebook" id="accounts_notebook">
             <property name="visible">True</property>
@@ -111,59 +133,49 @@
             <property name="show_tabs">False</property>
             <property name="show_border">False</property>
             <child>
-              <object class="GtkAlignment" id="alignment2">
+              <object class="GtkBox" id="box1">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="bottom_padding">18</property>
+                <property name="valign">center</property>
+                <property name="vexpand">True</property>
+                <property name="orientation">vertical</property>
+                <property name="spacing">6</property>
                 <child>
-                  <object class="GtkBox" id="box1">
+                  <object class="GtkButton" id="add_account_button">
+                    <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>
+                    <signal name="clicked" handler="on_add_button_clicked" object="CcGoaPanel" swapped="no" 
/>
+                  </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="valign">center</property>
-                    <property name="vexpand">True</property>
-                    <property name="orientation">vertical</property>
-                    <property name="spacing">6</property>
-                    <child>
-                      <object class="GtkButton" id="add_account_button">
-                        <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>
-                        <signal name="clicked" handler="on_add_button_clicked" object="CcGoaPanel" 
swapped="no" />
-                      </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>
-                        <property name="max_width_chars">40</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>
+                    <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>
+                    <property name="max_width_chars">40</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>
-              <packing>
-                <property name="tab_fill">False</property>
-              </packing>
             </child>
             <child type="tab">
               <object class="GtkLabel" id="label1">
@@ -218,5 +230,5 @@
         </child>
       </object>
     </child>
-  </template>
+  </object>
 </interface>


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