window: bind properties in UI file

This is possible, and allows us to clean up constructed
a bit.
This commit is contained in:
Christopher Davis 2021-01-23 23:46:33 -08:00
parent f49ef9b2d9
commit f621fedbba
2 changed files with 2 additions and 13 deletions

View file

@ -11,6 +11,7 @@
<child>
<object class="GtkHeaderBar" id="headerbar">
<property name="css-classes">titlebar</property>
<property name="visible" bind-source="IvWindow" bind-property="fullscreened" bind-flags="sync-create|invert-boolean"/>
<child type="end">
<object class="GtkMenuButton" id="menu_button">
<property name="icon-name">open-menu-symbolic</property>
@ -40,6 +41,7 @@
</child>
<child>
<object class="IvImageView" id="image_view">
<property name="header-visible" bind-source="IvWindow" bind-property="fullscreened" bind-flags="sync-create"/>
<property name="primary-menu-model">primary_menu</property>
<property name="popover-menu-model">image_menu</property>
</object>

View file

@ -114,19 +114,6 @@ mod imp {
.connect_released(clone!(@weak obj => move |_, _, _, _| {
obj.pick_file();
}));
obj.bind_property("fullscreened", &*self.image_view, "header-visible")
.flags(glib::BindingFlags::SYNC_CREATE | glib::BindingFlags::BIDIRECTIONAL)
.build()
.unwrap();
obj.bind_property("fullscreened", &*self.headerbar, "visible")
.flags(
glib::BindingFlags::SYNC_CREATE
| glib::BindingFlags::BIDIRECTIONAL
| glib::BindingFlags::INVERT_BOOLEAN,
)
.build()
.unwrap();
}
}