window: Bind headerbar opacity to controls

No purpose yet, but will help when we want to implement
fading. Need to have support for closures in Rust first.
This commit is contained in:
Christopher Davis 2021-09-24 05:58:55 -07:00
parent e45b89f854
commit 293dc3c124
3 changed files with 16 additions and 1 deletions

View file

@ -14,7 +14,7 @@
</object> </object>
</child> </child>
<child type="overlay"> <child type="overlay">
<object class="GtkBox"> <object class="GtkBox" id="controls">
<property name="vexpand">True</property> <property name="vexpand">True</property>
<child> <child>
<object class="GtkButton" id="prev_button"> <object class="GtkButton" id="prev_button">

View file

@ -15,6 +15,11 @@
<object class="GtkHeaderBar" id="headerbar"> <object class="GtkHeaderBar" id="headerbar">
<property name="css-classes">titlebar</property> <property name="css-classes">titlebar</property>
<property name="show_title_buttons" bind-source="IvWindow" bind-property="fullscreened" bind-flags="sync-create|invert-boolean"/> <property name="show_title_buttons" bind-source="IvWindow" bind-property="fullscreened" bind-flags="sync-create|invert-boolean"/>
<binding name="opacity">
<lookup type="GtkWidget" name="opacity">
<lookup name="controls">image_view</lookup>
</lookup>
</binding>
<child type="end"> <child type="end">
<object class="GtkMenuButton" id="menu_button"> <object class="GtkMenuButton" id="menu_button">
<property name="icon-name">open-menu-symbolic</property> <property name="icon-name">open-menu-symbolic</property>

View file

@ -44,6 +44,8 @@ mod imp {
#[template_child] #[template_child]
pub picture: TemplateChild<gtk::Picture>, pub picture: TemplateChild<gtk::Picture>,
#[template_child] #[template_child]
pub controls: TemplateChild<gtk::Box>,
#[template_child]
pub popover: TemplateChild<gtk::PopoverMenu>, pub popover: TemplateChild<gtk::PopoverMenu>,
#[template_child] #[template_child]
pub click_gesture: TemplateChild<gtk::GestureClick>, pub click_gesture: TemplateChild<gtk::GestureClick>,
@ -103,6 +105,13 @@ mod imp {
None, None,
glib::ParamFlags::READABLE, glib::ParamFlags::READABLE,
), ),
glib::ParamSpec::new_object(
"controls",
"Controls",
"The controls for the image view",
gtk::Box::static_type(),
glib::ParamFlags::READABLE,
),
] ]
}); });
@ -133,6 +142,7 @@ mod imp {
match psec.name() { match psec.name() {
"popover-menu-model" => self.popover_menu_model.borrow().to_value(), "popover-menu-model" => self.popover_menu_model.borrow().to_value(),
"filename" => self.filename.borrow().to_value(), "filename" => self.filename.borrow().to_value(),
"controls" => self.controls.to_value(),
_ => unimplemented!(), _ => unimplemented!(),
} }
} }