[gnome-software/wip/exalm/libadwaita-beta: 68/71] update-dialog: Use AdwLeaflet:can-navigate-back
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/exalm/libadwaita-beta: 68/71] update-dialog: Use AdwLeaflet:can-navigate-back
- Date: Tue, 25 Jan 2022 07:54:25 +0000 (UTC)
commit aaafbe4bbf2b9bd8dd5c1bd66d7bb3ff147569bf
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Wed Dec 8 02:20:21 2021 +0500
update-dialog: Use AdwLeaflet:can-navigate-back
A bit earlier the can-swipe-property in libadwaita got replaced with
can-navigate-back which also handles shortcuts and mouse buttons. Use it.
src/gs-update-dialog.c | 32 --------------------------------
src/gs-update-dialog.ui | 15 +--------------
2 files changed, 1 insertion(+), 46 deletions(-)
---
diff --git a/src/gs-update-dialog.c b/src/gs-update-dialog.c
index 9ba715fb0..70519247a 100644
--- a/src/gs-update-dialog.c
+++ b/src/gs-update-dialog.c
@@ -217,36 +217,6 @@ gs_update_dialog_show_update_details (GsUpdateDialog *dialog, GsApp *app)
adw_leaflet_set_visible_child (ADW_LEAFLET (dialog->leaflet), page);
}
-static gboolean
-key_pressed_cb (GtkEventControllerKey *key_controller,
- guint keyval,
- guint keycode,
- GdkModifierType state,
- GsUpdateDialog *dialog)
-{
- gboolean is_rtl = gtk_widget_get_direction (GTK_WIDGET (dialog)) == GTK_TEXT_DIR_RTL;
-
- if ((!is_rtl && state == GDK_ALT_MASK && keyval == GDK_KEY_Left) ||
- (is_rtl && state == GDK_ALT_MASK && keyval == GDK_KEY_Right) ||
- keyval == GDK_KEY_Back) {
- adw_leaflet_navigate (ADW_LEAFLET (dialog->leaflet), ADW_NAVIGATION_DIRECTION_BACK);
- return GDK_EVENT_STOP;
- }
-
- return GDK_EVENT_PROPAGATE;
-}
-
-static void
-button_pressed_cb (GtkGestureClick *click_gesture,
- gint n_press,
- gdouble x,
- gdouble y,
- GsUpdateDialog *dialog)
-{
- adw_leaflet_navigate (ADW_LEAFLET (dialog->leaflet), ADW_NAVIGATION_DIRECTION_BACK);
- gtk_gesture_set_state (GTK_GESTURE (click_gesture), GTK_EVENT_SEQUENCE_CLAIMED);
-}
-
static void
gs_update_dialog_get_property (GObject *object,
guint prop_id,
@@ -390,9 +360,7 @@ gs_update_dialog_class_init (GsUpdateDialogClass *klass)
gtk_widget_class_bind_template_child (widget_class, GsUpdateDialog, spinner);
gtk_widget_class_bind_template_child (widget_class, GsUpdateDialog, stack);
gtk_widget_class_bind_template_child (widget_class, GsUpdateDialog, window_title);
- gtk_widget_class_bind_template_callback (widget_class, button_pressed_cb);
gtk_widget_class_bind_template_callback (widget_class, leaflet_child_transition_cb);
- gtk_widget_class_bind_template_callback (widget_class, key_pressed_cb);
gtk_widget_class_add_binding_action (widget_class, GDK_KEY_Escape, 0, "window.close", NULL);
}
diff --git a/src/gs-update-dialog.ui b/src/gs-update-dialog.ui
index fbbac57cc..ae527740e 100644
--- a/src/gs-update-dialog.ui
+++ b/src/gs-update-dialog.ui
@@ -9,22 +9,9 @@
<property name="default-width">640</property>
<property name="default-height">576</property>
- <child>
- <object class="GtkEventControllerKey">
- <signal name="key-pressed" handler="key_pressed_cb"/>
- </object>
- </child>
- <child>
- <object class="GtkGestureClick">
- <!-- Mouse hardware back button -->
- <property name="button">8</property>
- <signal name="pressed" handler="button_pressed_cb"/>
- </object>
- </child>
-
<child>
<object class="AdwLeaflet" id="leaflet">
- <property name="can_swipe_back">True</property>
+ <property name="can-navigate-back">True</property>
<property name="can-unfold">False</property>
<!-- We need both signals to support the animations being disabled, as
notify::child-transition-running isn't emitted in that case. -->
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]