window,image_view: Move fullscreen controls to the image view

Allan Day's latest mockups have the fullscreen icon on the bottom
left of the image. This commit moves the icon there, using a
GtkExpression for the icon name.
This commit is contained in:
Christopher Davis 2022-07-10 19:39:03 -04:00
parent 689f975bf0
commit 9ba6cced6c
4 changed files with 32 additions and 21 deletions

View file

@ -17,12 +17,15 @@
</child> </child>
<child type="overlay"> <child type="overlay">
<object class="GtkBox" id="controls_box"> <object class="GtkBox" id="controls_box">
<property name="halign">center</property>
<property name="valign">end</property> <property name="valign">end</property>
<property name="margin-start">18</property>
<property name="margin-end">18</property>
<property name="margin-top">18</property>
<property name="margin-bottom">18</property> <property name="margin-bottom">18</property>
<property name="spacing">12</property> <property name="spacing">12</property>
<child> <child>
<object class="GtkButton" id="prev_button"> <object class="GtkButton" id="prev_button">
<property name="halign">start</property>
<property name="icon-name">go-previous-symbolic</property> <property name="icon-name">go-previous-symbolic</property>
<property name="action-name">iv.previous</property> <property name="action-name">iv.previous</property>
<property name="tooltip-text" translatable="yes">Previous Image</property> <property name="tooltip-text" translatable="yes">Previous Image</property>
@ -43,6 +46,25 @@
</style> </style>
</object> </object>
</child> </child>
<child>
<object class="GtkButton" id="fullscreen_button">
<property name="hexpand">True</property>
<property name="halign">end</property>
<binding name="icon-name">
<closure type="gchararray" function="get_fullscreen_icon">
<lookup type="GtkWindow" name="fullscreened">
<lookup type="GtkWidget" name="root">LpImageView</lookup>
</lookup>
</closure>
</binding>
<property name="action-name">win.toggle-fullscreen</property>
<property name="tooltip-text" translatable="yes">Toggle Fullscreen</property>
<style>
<class name="osd"/>
<class name="circular"/>
</style>
</object>
</child>
</object> </object>
</child> </child>
</object> </object>

View file

@ -30,13 +30,6 @@
<property name="tooltip-text" translatable="yes">Primary Menu</property> <property name="tooltip-text" translatable="yes">Primary Menu</property>
</object> </object>
</child> </child>
<child type="end">
<object class="GtkButton" id="fullscreen_button">
<property name="icon-name">view-fullscreen-symbolic</property>
<property name="action-name">win.toggle-fullscreen</property>
<property name="tooltip-text" translatable="yes">Toggle Fullscreen</property>
</object>
</child>
</object> </object>
</property> </property>
<property name="content"> <property name="content">

View file

@ -349,6 +349,15 @@ impl LpImageView {
} }
} }
#[template_callback]
fn get_fullscreen_icon(&self, fullscreened: bool) -> &'static str {
if fullscreened {
"view-restore-symbolic"
} else {
"view-fullscreen-symbolic"
}
}
pub fn set_wallpaper(&self) -> anyhow::Result<()> { pub fn set_wallpaper(&self) -> anyhow::Result<()> {
let wallpaper = self.uri().context("No URI for current file")?; let wallpaper = self.uri().context("No URI for current file")?;
let ctx = glib::MainContext::default(); let ctx = glib::MainContext::default();

View file

@ -62,8 +62,6 @@ mod imp {
#[template_child] #[template_child]
pub menu_button: TemplateChild<gtk::MenuButton>, pub menu_button: TemplateChild<gtk::MenuButton>,
#[template_child] #[template_child]
pub fullscreen_button: TemplateChild<gtk::Button>,
#[template_child]
pub toast_overlay: TemplateChild<adw::ToastOverlay>, pub toast_overlay: TemplateChild<adw::ToastOverlay>,
#[template_child] #[template_child]
pub stack: TemplateChild<gtk::Stack>, pub stack: TemplateChild<gtk::Stack>,
@ -219,20 +217,9 @@ impl LpWindow {
if fullscreen { if fullscreen {
imp.flap.set_fold_policy(adw::FlapFoldPolicy::Always); imp.flap.set_fold_policy(adw::FlapFoldPolicy::Always);
imp.headerbar.add_css_class("osd"); imp.headerbar.add_css_class("osd");
imp.menu_button.unparent();
imp.fullscreen_button.unparent();
imp.headerbar.pack_end(&*imp.fullscreen_button);
imp.headerbar.pack_end(&*imp.menu_button);
imp.fullscreen_button.set_icon_name("view-restore-symbolic");
} else { } else {
imp.flap.set_fold_policy(adw::FlapFoldPolicy::Never); imp.flap.set_fold_policy(adw::FlapFoldPolicy::Never);
imp.headerbar.remove_css_class("osd"); imp.headerbar.remove_css_class("osd");
imp.menu_button.unparent();
imp.fullscreen_button.unparent();
imp.headerbar.pack_end(&*imp.menu_button);
imp.headerbar.pack_end(&*imp.fullscreen_button);
imp.fullscreen_button
.set_icon_name("view-fullscreen-symbolic");
} }
self.set_fullscreened(fullscreen); self.set_fullscreened(fullscreen);