[gthumb] browser: added support for back and forward mouse buttons
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] browser: added support for back and forward mouse buttons
- Date: Sun, 29 Nov 2020 16:10:29 +0000 (UTC)
commit 1578e069676d615ccf87c7a75eecaf00684abd28
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sun Nov 29 14:44:10 2020 +0100
browser: added support for back and forward mouse buttons
Fixes https://gitlab.gnome.org/GNOME/gthumb/-/issues/120
gthumb/gth-browser.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
gthumb/gth-window.c | 14 ++++++++++++++
gthumb/gth-window.h | 3 +++
3 files changed, 68 insertions(+)
---
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index 0e4af4f2..81034e49 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -134,6 +134,7 @@ struct _GthBrowserPrivate {
GtkWidget *progress_dialog;
GHashTable *named_dialogs;
+ GtkGesture *gesture;
/* Browser data */
@@ -2589,6 +2590,7 @@ gth_browser_finalize (GObject *object)
_g_object_list_unref (browser->priv->history);
gth_icon_cache_free (browser->priv->menu_icon_cache);
g_hash_table_unref (browser->priv->named_dialogs);
+ g_object_unref (browser->priv->gesture);
g_free (browser->priv->list_attributes);
_g_object_unref (browser->priv->folder_popup_file_data);
_g_object_unref (browser->priv->history_menu);
@@ -4199,6 +4201,47 @@ _gth_browser_register_fixed_viewer_control (GthBrowser *browser,
}
+static void
+browser_gesture_pressed_cb (GtkGestureMultiPress *gesture,
+ int n_press,
+ double x,
+ double y,
+ gpointer user_data)
+{
+ GthBrowser *browser = user_data;
+ guint button;
+
+ button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
+ switch (button) {
+ case 8: /* Back button */
+ switch (gth_window_get_current_page (GTH_WINDOW (browser))) {
+ case GTH_BROWSER_PAGE_VIEWER:
+ gth_window_activate_action (GTH_WINDOW (browser), "browser-mode", NULL);
+ break;
+ case GTH_BROWSER_PAGE_BROWSER:
+ gth_browser_go_back (browser, 1);
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case 9: /* Forward button */
+ switch (gth_window_get_current_page (GTH_WINDOW (browser))) {
+ case GTH_BROWSER_PAGE_BROWSER:
+ gth_browser_go_forward (browser, 1);
+ break;
+ default:
+ break;
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+
static gboolean
browser_key_press_cb (GthBrowser *browser,
GdkEventKey *event)
@@ -4357,6 +4400,14 @@ gth_browser_init (GthBrowser *browser)
G_CALLBACK (browser_key_press_cb),
browser);
+ browser->priv->gesture = gtk_gesture_multi_press_new (GTK_WIDGET (browser));
+ gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (browser->priv->gesture), 0);
+ gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (browser->priv->gesture),
GTK_PHASE_CAPTURE);
+ g_signal_connect (browser->priv->gesture,
+ "pressed",
+ G_CALLBACK (browser_gesture_pressed_cb),
+ browser);
+
/* ui actions */
g_action_map_add_action_entries (G_ACTION_MAP (browser),
diff --git a/gthumb/gth-window.c b/gthumb/gth-window.c
index ac82e167..e1352e91 100644
--- a/gthumb/gth-window.c
+++ b/gthumb/gth-window.c
@@ -807,6 +807,20 @@ gth_window_change_action_state (GthWindow *window,
}
+void
+gth_window_activate_action (GthWindow *window,
+ const char *action_name,
+ GVariant *parameter)
+{
+ GAction *action;
+
+ action = g_action_map_lookup_action (G_ACTION_MAP (window), action_name);
+ g_return_if_fail (action != NULL);
+
+ g_action_activate (action, parameter);
+}
+
+
void
gth_window_add_viewer_shortcuts (GthWindow *window,
const char *viewer_context,
diff --git a/gthumb/gth-window.h b/gthumb/gth-window.h
index f152e2e2..99e2ffa6 100644
--- a/gthumb/gth-window.h
+++ b/gthumb/gth-window.h
@@ -121,6 +121,9 @@ gboolean gth_window_get_action_state (GthWindow *window,
void gth_window_change_action_state (GthWindow *window,
const char *action_name,
gboolean value);
+void gth_window_activate_action (GthWindow *window,
+ const char *action_name,
+ GVariant *parameter);
void gth_window_add_viewer_shortcuts (GthWindow *window,
const char *viewer_context,
const GthShortcut *shortcuts,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]