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

Add empty list status

parent d1aebb27
No related branches found
No related tags found
No related merge requests found
Pipeline #3563 passed
......@@ -34,19 +34,31 @@ template RugbyAppWindow : Adw.ApplicationWindow {
Adw.Clamp {
maximum-size: 600;
ScrolledWindow {
vexpand: true;
Stack stack {
StackPage {
child: Adw.StatusPage empty_page {
title: "No possibilities";
};
}
ListView listview {
styles ["rich-list"]
StackPage {
child: ScrolledWindow list_page {
vexpand: true;
model: NoSelection {
model: .RugbyListStore {
score: bind scorespin.value;
};
};
factory: BuilderListItemFactory {
resource: "/uk/me/bcowan/Rugby/gtk/score-item.ui";
ListView listview {
styles ["rich-list"]
model: NoSelection {
model: .RugbyListStore {
score: bind scorespin.value;
items-changed => list_store_items_changed_cb();
};
};
factory: BuilderListItemFactory {
resource: "/uk/me/bcowan/Rugby/gtk/score-item.ui";
};
}
};
}
}
......
......@@ -19,10 +19,27 @@ struct _RugbyAppWindow
GtkWidget *scorespin;
GtkWidget *menu_button;
GtkWidget *stack;
GtkWidget *empty_page;
GtkWidget *list_page;
};
G_DEFINE_TYPE (RugbyAppWindow, rugby_app_window, ADW_TYPE_APPLICATION_WINDOW)
static void
list_store_items_changed_cb ( GListModel *model,
G_GNUC_UNUSED unsigned position,
G_GNUC_UNUSED unsigned removed,
G_GNUC_UNUSED unsigned added,
RugbyAppWindow *self)
{
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);
else
gtk_stack_set_visible_child (GTK_STACK (self->stack), self->list_page);
}
static char *
item_tooltip_cb (GtkListItem *item)
{
......@@ -141,8 +158,12 @@ 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, menu_button);
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_callback (widget_class, item_tooltip_cb);
gtk_widget_class_bind_template_callback (widget_class, list_store_items_changed_cb);
}
RugbyAppWindow *
......
......@@ -72,6 +72,12 @@ process_data (RugbyListStore *self)
unsigned old_length = g_list_model_get_n_items (G_LIST_MODEL (self->items));
g_list_store_remove_all (self->items);
if (self->score == 0)
{
g_list_model_items_changed (G_LIST_MODEL (self), 0, old_length, 0);
return;
}
int max_tries = self->score / try_points;
int max_utries = self->score / utry_points;
......
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