window: Replace child names with widget references
Using child names can cause code to be broken if a name is changed - this wont be picked up as an error in the compiler.
This commit is contained in:
parent
3316f51866
commit
c2567b9c3e
2 changed files with 22 additions and 19 deletions
|
@ -58,6 +58,7 @@ struct _CcWindow
|
|||
GtkWidget *header;
|
||||
GtkWidget *header_box;
|
||||
GtkWidget *main_leaflet;
|
||||
GtkWidget *sidebar_box;
|
||||
GtkWidget *list_scrolled;
|
||||
GtkWidget *panel_headerbar;
|
||||
GtkWidget *search_scrolled;
|
||||
|
@ -129,11 +130,25 @@ remove_all_custom_widgets (CcWindow *self)
|
|||
CC_EXIT;
|
||||
}
|
||||
|
||||
static void
|
||||
show_panel (CcWindow *self)
|
||||
{
|
||||
hdy_leaflet_set_visible_child (HDY_LEAFLET (self->main_leaflet), self->stack);
|
||||
hdy_leaflet_set_visible_child (HDY_LEAFLET (self->header_box), self->panel_headerbar);
|
||||
}
|
||||
|
||||
static void
|
||||
show_sidebar (CcWindow *self)
|
||||
{
|
||||
hdy_leaflet_set_visible_child (HDY_LEAFLET (self->main_leaflet), self->sidebar_box);
|
||||
hdy_leaflet_set_visible_child (HDY_LEAFLET (self->header_box), self->header);
|
||||
}
|
||||
|
||||
static void
|
||||
on_sidebar_activated_cb (CcPanel *panel,
|
||||
CcWindow *self)
|
||||
{
|
||||
hdy_leaflet_set_visible_child_name (HDY_LEAFLET (self->main_leaflet), "panel");
|
||||
show_panel (self);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -415,7 +430,7 @@ set_active_panel_from_id (CcShell *shell,
|
|||
{
|
||||
g_object_set (G_OBJECT (self->current_panel), "parameters", parameters, NULL);
|
||||
if (force_moving_to_the_panel || self->previous_list_view == view)
|
||||
hdy_leaflet_set_visible_child_name (HDY_LEAFLET (self->main_leaflet), "panel");
|
||||
show_panel (self);
|
||||
self->previous_list_view = view;
|
||||
CC_RETURN (TRUE);
|
||||
}
|
||||
|
@ -451,7 +466,7 @@ set_active_panel_from_id (CcShell *shell,
|
|||
add_current_panel_to_history (shell, start_id);
|
||||
|
||||
if (force_moving_to_the_panel)
|
||||
hdy_leaflet_set_visible_child_name (HDY_LEAFLET (self->main_leaflet), "panel");
|
||||
show_panel (self);
|
||||
|
||||
g_free (self->current_panel_id);
|
||||
self->current_panel_id = g_strdup (start_id);
|
||||
|
@ -575,9 +590,9 @@ search_entry_activate_cb (GtkEntry *entry,
|
|||
|
||||
static void
|
||||
back_button_clicked_cb (GtkButton *button,
|
||||
CcWindow *shell)
|
||||
CcWindow *self)
|
||||
{
|
||||
hdy_leaflet_set_visible_child_name (HDY_LEAFLET (shell->main_leaflet), "sidebar");
|
||||
show_sidebar (self);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -851,7 +866,7 @@ cc_window_constructed (GObject *object)
|
|||
self);
|
||||
|
||||
update_headerbar_buttons (self);
|
||||
hdy_leaflet_set_visible_child_name (HDY_LEAFLET (self->main_leaflet), "sidebar");
|
||||
show_sidebar (self);
|
||||
|
||||
G_OBJECT_CLASS (cc_window_parent_class)->constructed (object);
|
||||
}
|
||||
|
@ -919,6 +934,7 @@ cc_window_class_init (CcWindowClass *klass)
|
|||
gtk_widget_class_bind_template_child (widget_class, CcWindow, header_sizegroup);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcWindow, list_scrolled);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcWindow, main_leaflet);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcWindow, sidebar_box);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcWindow, panel_headerbar);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcWindow, panel_list);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcWindow, previous_button);
|
||||
|
|
|
@ -76,9 +76,6 @@
|
|||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">sidebar</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparator" id="panel_separator">
|
||||
|
@ -102,9 +99,6 @@
|
|||
<class name="background"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">panel</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
@ -121,7 +115,6 @@
|
|||
<property name="mode-transition-duration" bind-source="main_leaflet" bind-property="mode-transition-duration" bind-flags="bidirectional|sync-create"/>
|
||||
<property name="child-transition-type" bind-source="main_leaflet" bind-property="child-transition-type" bind-flags="bidirectional|sync-create"/>
|
||||
<property name="child-transition-duration" bind-source="main_leaflet" bind-property="child-transition-duration" bind-flags="bidirectional|sync-create"/>
|
||||
<property name="visible-child-name" bind-source="main_leaflet" bind-property="visible-child-name" bind-flags="bidirectional|sync-create"/>
|
||||
<signal name="notify::visible-child" handler="notify_header_visible_child_cb" swapped="no"/>
|
||||
<signal name="notify::fold" handler="notify_fold_cb" object="CcWindow" after="yes" swapped="no"/>
|
||||
<child>
|
||||
|
@ -201,9 +194,6 @@
|
|||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">sidebar</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparator" id="header_separator">
|
||||
|
@ -270,9 +260,6 @@
|
|||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">panel</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue