[gnome-control-center] online-accounts: Replace GtkStack child names with widget references



commit ece1911f4097743fdfca35cd751641cc999c3d03
Author: Robert Ancell <robert ancell canonical com>
Date:   Wed Nov 20 15:03:00 2019 +1300

    online-accounts: Replace GtkStack child names with widget references
    
    The child names are easier to break if widgets are changed - this can't be
    detected by the compiler.

 panels/online-accounts/cc-online-accounts-panel.c | 6 ++++--
 panels/online-accounts/online-accounts.ui         | 8 +-------
 2 files changed, 5 insertions(+), 9 deletions(-)
---
diff --git a/panels/online-accounts/cc-online-accounts-panel.c 
b/panels/online-accounts/cc-online-accounts-panel.c
index 1d6d545dc..1e13dda85 100644
--- a/panels/online-accounts/cc-online-accounts-panel.c
+++ b/panels/online-accounts/cc-online-accounts-panel.c
@@ -42,6 +42,7 @@ struct _CcGoaPanel
   GtkListBox    *accounts_listbox;
   GtkDialog     *edit_account_dialog;
   GtkHeaderBar  *edit_account_headerbar;
+  GtkBox        *editor_box;
   GtkListBoxRow *more_providers_row;
   GtkBox        *new_account_vbox;
   GtkLabel      *notification_label;
@@ -255,7 +256,7 @@ add_account (CcGoaPanel  *self,
   reset_headerbar (self);
 
   /* Move to the new account page */
-  gtk_stack_set_visible_child_name (self->stack, "new-account");
+  gtk_stack_set_visible_child (self->stack, GTK_WIDGET (self->new_account_vbox));
 
   /* Reset the dialog size */
   gtk_window_resize (GTK_WINDOW (self->edit_account_dialog), 1, 1);
@@ -547,6 +548,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, editor_box);
   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);
@@ -590,7 +592,7 @@ show_page_account (CcGoaPanel  *panel,
   reset_headerbar (panel);
 
   /* Move to the account editor page */
-  gtk_stack_set_visible_child_name (panel->stack, "editor");
+  gtk_stack_set_visible_child (panel->stack, GTK_WIDGET (panel->editor_box));
 
   /* Out with the old */
   children = gtk_container_get_children (GTK_CONTAINER (panel->accounts_vbox));
diff --git a/panels/online-accounts/online-accounts.ui b/panels/online-accounts/online-accounts.ui
index bf5c6f902..a78f61e02 100644
--- a/panels/online-accounts/online-accounts.ui
+++ b/panels/online-accounts/online-accounts.ui
@@ -213,12 +213,9 @@
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
               </object>
-              <packing>
-                <property name="name">new-account</property>
-              </packing>
             </child>
             <child>
-              <object class="GtkBox">
+              <object class="GtkBox" id="editor_box">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="margin-bottom">24</property>
@@ -248,9 +245,6 @@
                   </object>
                 </child>
               </object>
-              <packing>
-                <property name="name">editor</property>
-              </packing>
             </child>
           </object>
         </child>


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