From 5d9567507c93761befeb11823d23dae74379c68a Mon Sep 17 00:00:00 2001 From: Christopher Davis Date: Wed, 22 Dec 2021 19:38:56 -0800 Subject: [PATCH] window: Add "Open File..." button, remove gesture This gives users a very intuitive way to open files. The gesture was awkard and didn't match any common patterns across GNOME. The button is simple and obvious. --- data/gtk/window.ui | 12 ++++++++++-- src/window.rs | 12 ++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/data/gtk/window.ui b/data/gtk/window.ui index b343c97..682a9a4 100644 --- a/data/gtk/window.ui +++ b/data/gtk/window.ui @@ -44,9 +44,17 @@ Image Viewer - Click here or drag an image here to open a file. + Click "Open File…" or drag an image here. - + + center + Open File… + win.open + + diff --git a/src/window.rs b/src/window.rs index a341c84..ff4cfdc 100644 --- a/src/window.rs +++ b/src/window.rs @@ -65,8 +65,6 @@ mod imp { pub status_page: TemplateChild, #[template_child] pub image_view: TemplateChild, - #[template_child] - pub open_gesture: TemplateChild, } #[glib::object_subclass] @@ -127,14 +125,8 @@ mod imp { // For callbacks, you will want to reference the GTK docs on // the relevant signal to see which parameters you need. - // In this case, we need none to react to the gesture, - // so "_" is used in all 4 spots. - self.open_gesture - .connect_released(clone!(@weak obj => move |_, _, _, _| { - obj.pick_file(); - })); - - // Property bindings didn't seem to work here + // In this case, we need one to react to the signal, + // so we name it `iv` then use `_` for the other spots. self.image_view.connect_notify_local( Some("filename"), clone!(@weak obj => move |iv, _| {