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.
This commit is contained in:
parent
5893d4b764
commit
5d9567507c
2 changed files with 12 additions and 12 deletions
|
|
@ -44,9 +44,17 @@
|
||||||
<child>
|
<child>
|
||||||
<object class="AdwStatusPage" id="status_page">
|
<object class="AdwStatusPage" id="status_page">
|
||||||
<property name="title" translatable="yes">Image Viewer</property>
|
<property name="title" translatable="yes">Image Viewer</property>
|
||||||
<property name="description" translatable="yes">Click here or drag an image here to open a file.</property>
|
<property name="description" translatable="yes">Click "Open File…" or drag an image here.</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkGestureClick" id="open_gesture"/>
|
<object class="GtkButton">
|
||||||
|
<property name="halign">center</property>
|
||||||
|
<property name="label" translatable="yes">Open File…</property>
|
||||||
|
<property name="action-name">win.open</property>
|
||||||
|
<style>
|
||||||
|
<class name="pill"/>
|
||||||
|
<class name="suggested-action"/>
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
|
|
||||||
|
|
@ -65,8 +65,6 @@ mod imp {
|
||||||
pub status_page: TemplateChild<adw::StatusPage>,
|
pub status_page: TemplateChild<adw::StatusPage>,
|
||||||
#[template_child]
|
#[template_child]
|
||||||
pub image_view: TemplateChild<LpImageView>,
|
pub image_view: TemplateChild<LpImageView>,
|
||||||
#[template_child]
|
|
||||||
pub open_gesture: TemplateChild<gtk::GestureClick>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[glib::object_subclass]
|
#[glib::object_subclass]
|
||||||
|
|
@ -127,14 +125,8 @@ mod imp {
|
||||||
|
|
||||||
// For callbacks, you will want to reference the GTK docs on
|
// For callbacks, you will want to reference the GTK docs on
|
||||||
// the relevant signal to see which parameters you need.
|
// the relevant signal to see which parameters you need.
|
||||||
// In this case, we need none to react to the gesture,
|
// In this case, we need one to react to the signal,
|
||||||
// so "_" is used in all 4 spots.
|
// so we name it `iv` then use `_` for the other spots.
|
||||||
self.open_gesture
|
|
||||||
.connect_released(clone!(@weak obj => move |_, _, _, _| {
|
|
||||||
obj.pick_file();
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Property bindings didn't seem to work here
|
|
||||||
self.image_view.connect_notify_local(
|
self.image_view.connect_notify_local(
|
||||||
Some("filename"),
|
Some("filename"),
|
||||||
clone!(@weak obj => move |iv, _| {
|
clone!(@weak obj => move |iv, _| {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue