mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2024-12-12 15:47:35 +00:00
main-window: Use HdyViewSwitcherTitle
This makes the code simpler.
This commit is contained in:
parent
6dba2c453b
commit
576ea55e9f
2 changed files with 10 additions and 70 deletions
|
@ -46,11 +46,7 @@ struct _CallsMainWindow
|
|||
|
||||
CallsInAppNotification *in_app_notification;
|
||||
|
||||
HdySqueezer *squeezer;
|
||||
GtkLabel *title_label;
|
||||
HdyViewSwitcher *wide_switcher;
|
||||
HdyViewSwitcher *narrow_switcher;
|
||||
HdyViewSwitcherBar *switcher_bar;
|
||||
HdyViewSwitcherTitle *title_switcher;
|
||||
GtkStack *main_stack;
|
||||
|
||||
GtkRevealer *permanent_error_revealer;
|
||||
|
@ -123,18 +119,6 @@ static const GActionEntry window_entries [] =
|
|||
};
|
||||
|
||||
|
||||
static gboolean
|
||||
set_switcher_bar_reveal (GBinding *binding,
|
||||
const GValue *from_value,
|
||||
GValue *to_value,
|
||||
gpointer title_label)
|
||||
{
|
||||
g_value_set_boolean (to_value, g_value_get_object (from_value) == title_label);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
set_property (GObject *object,
|
||||
guint property_id,
|
||||
|
@ -235,16 +219,6 @@ constructed (GObject *object)
|
|||
g_object_unref (simple_action_group);
|
||||
|
||||
|
||||
g_object_bind_property_full (self->squeezer,
|
||||
"visible-child",
|
||||
self->switcher_bar,
|
||||
"reveal",
|
||||
G_BINDING_SYNC_CREATE,
|
||||
set_switcher_bar_reveal,
|
||||
NULL,
|
||||
self->title_label,
|
||||
NULL);
|
||||
|
||||
g_signal_connect_swapped (calls_manager_get_default (),
|
||||
"notify::state",
|
||||
G_CALLBACK (state_changed_cb),
|
||||
|
@ -274,11 +248,7 @@ size_allocate (GtkWidget *widget,
|
|||
{
|
||||
CallsMainWindow *self = CALLS_MAIN_WINDOW (widget);
|
||||
|
||||
hdy_squeezer_set_child_enabled (self->squeezer,
|
||||
GTK_WIDGET (self->wide_switcher),
|
||||
allocation->width > 600);
|
||||
hdy_squeezer_set_child_enabled (self->squeezer,
|
||||
GTK_WIDGET (self->narrow_switcher),
|
||||
hdy_view_switcher_title_set_view_switcher_enabled (self->title_switcher,
|
||||
allocation->width > 400);
|
||||
|
||||
GTK_WIDGET_CLASS (calls_main_window_parent_class)->size_allocate (widget, allocation);
|
||||
|
@ -309,11 +279,7 @@ calls_main_window_class_init (CallsMainWindowClass *klass)
|
|||
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/sm/puri/calls/ui/main-window.ui");
|
||||
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, in_app_notification);
|
||||
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, squeezer);
|
||||
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, title_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, wide_switcher);
|
||||
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, narrow_switcher);
|
||||
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, switcher_bar);
|
||||
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, title_switcher);
|
||||
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, main_stack);
|
||||
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, permanent_error_revealer);
|
||||
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, permanent_error_label);
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stack">main_stack</property>
|
||||
<property name="reveal">True</property>
|
||||
<property name="reveal" bind-source="title_switcher" bind-property="title-visible" bind-flags="sync-create"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
@ -79,39 +79,13 @@
|
|||
<property name="centering_policy">strict</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="show_close_button">True</property>
|
||||
<property name="title">Calls</property>
|
||||
<property name="title" bind-source="CallsMainWindow" bind-property="title" bind-flags="sync-create"/>
|
||||
<child type="title">
|
||||
<object class="HdySqueezer" id="squeezer">
|
||||
<property name="visible">True</property>
|
||||
<property name="transition-type">crossfade</property>
|
||||
<child>
|
||||
<object class="HdyViewSwitcher" id="wide_switcher">
|
||||
<object class="HdyViewSwitcherTitle" id="title_switcher">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="policy">wide</property>
|
||||
<property name="stack">main_stack</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="HdyViewSwitcher" id="narrow_switcher">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="policy">narrow</property>
|
||||
<property name="stack">main_stack</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="title_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="label">Calls</property>
|
||||
<style>
|
||||
<class name="title"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<property name="title" bind-source="CallsMainWindow" bind-property="title" bind-flags="sync-create"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
|
Loading…
Reference in a new issue