From f1e63c4979bef60f4f39dda987116a6d67a7e09c Mon Sep 17 00:00:00 2001 From: Anton Lazarev Date: Sat, 26 Aug 2023 18:49:13 -0700 Subject: [PATCH] history-box: compose with GtkBin instead of subclassing GtkStack Part-of: --- src/calls-history-box.c | 8 ++++--- src/calls-history-box.h | 2 +- src/ui/history-box.ui | 53 ++++++++++++++++++++++------------------- 3 files changed, 35 insertions(+), 28 deletions(-) diff --git a/src/calls-history-box.c b/src/calls-history-box.c index 7b2b466..f56ef12 100644 --- a/src/calls-history-box.c +++ b/src/calls-history-box.c @@ -39,8 +39,9 @@ #define CALLS_HISTORY_INCREASE_N_PAGES_THRESHOLD 2 struct _CallsHistoryBox { - GtkStack parent_instance; + GtkBin parent_instance; + GtkStack *stack; GtkListBox *history; GtkScrolledWindow *scrolled_window; GtkAdjustment *scroll_adjustment; @@ -54,7 +55,7 @@ struct _CallsHistoryBox { }; -G_DEFINE_TYPE (CallsHistoryBox, calls_history_box, GTK_TYPE_STACK); +G_DEFINE_TYPE (CallsHistoryBox, calls_history_box, GTK_TYPE_BIN); enum { @@ -80,7 +81,7 @@ on_model_changed (GListModel *model, else child_name = "history"; - gtk_stack_set_visible_child_name (GTK_STACK (self), child_name); + gtk_stack_set_visible_child_name (self->stack, child_name); } @@ -256,6 +257,7 @@ calls_history_box_class_init (CallsHistoryBoxClass *klass) gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Calls/ui/history-box.ui"); + gtk_widget_class_bind_template_child (widget_class, CallsHistoryBox, stack); gtk_widget_class_bind_template_child (widget_class, CallsHistoryBox, history); gtk_widget_class_bind_template_child (widget_class, CallsHistoryBox, scrolled_window); } diff --git a/src/calls-history-box.h b/src/calls-history-box.h index 4c94ec3..a82bbc4 100644 --- a/src/calls-history-box.h +++ b/src/calls-history-box.h @@ -33,7 +33,7 @@ G_BEGIN_DECLS #define CALLS_TYPE_HISTORY_BOX (calls_history_box_get_type ()) -G_DECLARE_FINAL_TYPE (CallsHistoryBox, calls_history_box, CALLS, HISTORY_BOX, GtkStack); +G_DECLARE_FINAL_TYPE (CallsHistoryBox, calls_history_box, CALLS, HISTORY_BOX, GtkBin); CallsHistoryBox *calls_history_box_new (GListModel *model); diff --git a/src/ui/history-box.ui b/src/ui/history-box.ui index 48671ff..c9f9559 100644 --- a/src/ui/history-box.ui +++ b/src/ui/history-box.ui @@ -2,41 +2,46 @@ -