Skip to content
Snippets Groups Projects
Verified Commit b996e05f authored by Bruce Cowan's avatar Bruce Cowan :airplane:
Browse files

Switch page based on name, no need to store widget pointers this way

parent bf8f7eca
No related branches found
No related tags found
No related merge requests found
......@@ -63,14 +63,18 @@ template RugbyAppWindow : Adw.ApplicationWindow {
Stack stack {
StackPage {
child: Adw.StatusPage empty_page {
name: "empty_page";
child: Adw.StatusPage {
icon-name: "list";
title: "No possibilities";
};
}
StackPage {
child: ScrolledWindow list_page {
name: "list_page";
child: ScrolledWindow {
vexpand: true;
ListView listview {
......
......@@ -20,8 +20,6 @@ struct _RugbyAppWindow
GtkWidget *scorespin;
GtkWidget *tryspin;
GtkWidget *stack;
GtkWidget *empty_page;
GtkWidget *list_page;
GSettings *win_settings;
......@@ -39,9 +37,9 @@ list_store_items_changed_cb ( GListModel *model,
{
unsigned n_items = g_list_model_get_n_items (model);
if (n_items == 0)
gtk_stack_set_visible_child (GTK_STACK (self->stack), self->empty_page);
gtk_stack_set_visible_child_name (GTK_STACK (self->stack), "empty_page");
else
gtk_stack_set_visible_child (GTK_STACK (self->stack), self->list_page);
gtk_stack_set_visible_child_name (GTK_STACK (self->stack), "list_page");
}
static char *
......@@ -211,8 +209,6 @@ rugby_app_window_class_init (RugbyAppWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, RugbyAppWindow, scorespin);
gtk_widget_class_bind_template_child (widget_class, RugbyAppWindow, tryspin);
gtk_widget_class_bind_template_child (widget_class, RugbyAppWindow, stack);
gtk_widget_class_bind_template_child (widget_class, RugbyAppWindow, empty_page);
gtk_widget_class_bind_template_child (widget_class, RugbyAppWindow, list_page);
gtk_widget_class_bind_template_child (widget_class, RugbyAppWindow, try_filter);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment