From fadb6bfb9bfc8d1abe421b6b5041ddd5d84fcb44 Mon Sep 17 00:00:00 2001 From: Christopher Davis Date: Wed, 29 Jun 2022 21:12:12 -0400 Subject: [PATCH 1/3] image_view: Move controls to the bottom Per Allan Day's latest mockups --- data/gtk/image_view.ui | 55 +++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/data/gtk/image_view.ui b/data/gtk/image_view.ui index 88af8a38..5b55581b 100644 --- a/data/gtk/image_view.ui +++ b/data/gtk/image_view.ui @@ -16,34 +16,33 @@ - - start - center - 18 - 18 - go-previous-symbolic - iv.previous - Previous Image - - - - - - True - end - center - 18 - 18 - go-next-symbolic - iv.next - Next Image - + + center + end + 18 + 12 + + + go-previous-symbolic + iv.previous + Previous Image + + + + + + go-next-symbolic + iv.next + Next Image + + + -- GitLab From 689f975bf0975bc97cefa272b4097d4bec208d7b Mon Sep 17 00:00:00 2001 From: Christopher Davis Date: Fri, 1 Jul 2022 13:08:14 -0400 Subject: [PATCH 2/3] window: Add copy button to top left Allan Day's latest mockups put a copy button in the top left of the window. This commits adds the button and the toast along with it. --- data/gtk/window.ui | 7 +++++++ src/window.rs | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/data/gtk/window.ui b/data/gtk/window.ui index bf803d3f..52db0f3d 100644 --- a/data/gtk/window.ui +++ b/data/gtk/window.ui @@ -16,6 +16,13 @@ + + + edit-copy-symbolic + win.copy + Copy to Clipboard + + open-menu-symbolic diff --git a/src/window.rs b/src/window.rs index 95a6a28c..827f89ef 100644 --- a/src/window.rs +++ b/src/window.rs @@ -312,6 +312,11 @@ impl LpWindow { if let Err(e) = imp.image_view.copy() { log::error!("Failed to copy to clipboard: {}", e); + } else { + self.show_toast( + &"Image copied to clipboard".to_string(), + adw::ToastPriority::High, + ); } } -- GitLab From 9ba6cced6cb52200ac710549f3690b00e8782b41 Mon Sep 17 00:00:00 2001 From: Christopher Davis Date: Sun, 10 Jul 2022 19:39:03 -0400 Subject: [PATCH 3/3] 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. --- data/gtk/image_view.ui | 24 +++++++++++++++++++++++- data/gtk/window.ui | 7 ------- src/widgets/image_view.rs | 9 +++++++++ src/window.rs | 13 ------------- 4 files changed, 32 insertions(+), 21 deletions(-) diff --git a/data/gtk/image_view.ui b/data/gtk/image_view.ui index 5b55581b..397ed73f 100644 --- a/data/gtk/image_view.ui +++ b/data/gtk/image_view.ui @@ -17,12 +17,15 @@ - center end + 18 + 18 + 18 18 12 + start go-previous-symbolic iv.previous Previous Image @@ -43,6 +46,25 @@ + + + True + end + + + + LpImageView + + + + win.toggle-fullscreen + Toggle Fullscreen + + + diff --git a/data/gtk/window.ui b/data/gtk/window.ui index 52db0f3d..2ceed00c 100644 --- a/data/gtk/window.ui +++ b/data/gtk/window.ui @@ -30,13 +30,6 @@ Primary Menu - - - view-fullscreen-symbolic - win.toggle-fullscreen - Toggle Fullscreen - - diff --git a/src/widgets/image_view.rs b/src/widgets/image_view.rs index ec13b5f2..d7fbfb3b 100644 --- a/src/widgets/image_view.rs +++ b/src/widgets/image_view.rs @@ -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<()> { let wallpaper = self.uri().context("No URI for current file")?; let ctx = glib::MainContext::default(); diff --git a/src/window.rs b/src/window.rs index 827f89ef..663ff79b 100644 --- a/src/window.rs +++ b/src/window.rs @@ -62,8 +62,6 @@ mod imp { #[template_child] pub menu_button: TemplateChild, #[template_child] - pub fullscreen_button: TemplateChild, - #[template_child] pub toast_overlay: TemplateChild, #[template_child] pub stack: TemplateChild, @@ -219,20 +217,9 @@ impl LpWindow { if fullscreen { imp.flap.set_fold_policy(adw::FlapFoldPolicy::Always); 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 { imp.flap.set_fold_policy(adw::FlapFoldPolicy::Never); 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); -- GitLab