1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-06-25 05:09:30 +00:00

history-box: compose with GtkBin instead of subclassing GtkStack

Part-of: <https://gitlab.gnome.org/GNOME/calls/-/merge_requests/714>
This commit is contained in:
Anton Lazarev 2023-08-26 18:49:13 -07:00
parent 08603179c3
commit f1e63c4979
3 changed files with 35 additions and 28 deletions

View file

@ -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);
}

View file

@ -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);

View file

@ -2,41 +2,46 @@
<!-- Generated with glade 3.22.0 -->
<interface>
<requires lib="gtk+" version="3.22"/>
<template class="CallsHistoryBox" parent="GtkStack">
<template class="CallsHistoryBox" parent="GtkBin">
<child>
<object class="HdyStatusPage">
<object class="GtkStack" id="stack">
<property name="visible">True</property>
<property name="icon-name">call-start-symbolic</property>
<property name="title" translatable="yes">No Recent Calls</property>
</object>
<packing>
<property name="name">empty</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolled_window">
<property name="visible">True</property>
<property name="hscrollbar-policy">never</property>
<child>
<object class="HdyClamp">
<object class="HdyStatusPage">
<property name="visible">True</property>
<property name="icon-name">call-start-symbolic</property>
<property name="title" translatable="yes">No Recent Calls</property>
</object>
<packing>
<property name="name">empty</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolled_window">
<property name="visible">True</property>
<property name="hscrollbar-policy">never</property>
<child>
<object class="GtkListBox" id="history">
<object class="HdyClamp">
<property name="visible">True</property>
<property name="margin">12</property>
<property name="valign">start</property>
<style>
<class name="content"/>
</style>
<child>
<object class="GtkListBox" id="history">
<property name="visible">True</property>
<property name="margin">12</property>
<property name="valign">start</property>
<style>
<class name="content"/>
</style>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="name">history</property>
</packing>
</child>
</object>
<packing>
<property name="name">history</property>
</packing>
</child>
</template>
</interface>