From 625a06c0a0781025693a6299b721b6bc7a065c1a Mon Sep 17 00:00:00 2001 From: Martin Matuska Date: Fri, 5 Aug 2016 14:58:37 +0200 Subject: support back and forward mouse buttons to navigate Fixes https://github.com/mate-desktop/caja/issues/78 Co-Authored-By: Oliver Joos Co-Authored-By: Nelson Benitez Leon --- src/caja-navigation-window.c | 4 ++++ src/caja-navigation-window.h | 4 ++++ src/file-manager/fm-list-view.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+) (limited to 'src') diff --git a/src/caja-navigation-window.c b/src/caja-navigation-window.c index a0c75ae6..f5127b8f 100644 --- a/src/caja-navigation-window.c +++ b/src/caja-navigation-window.c @@ -570,7 +570,11 @@ caja_navigation_window_key_press_event (GtkWidget *widget, return GTK_WIDGET_CLASS (caja_navigation_window_parent_class)->key_press_event (widget, event); } +#if GTK_CHECK_VERSION(3, 0, 0) static gboolean +#else +gboolean +#endif caja_navigation_window_button_press_event (GtkWidget *widget, GdkEventButton *event) { diff --git a/src/caja-navigation-window.h b/src/caja-navigation-window.h index 18c713bd..231d140c 100644 --- a/src/caja-navigation-window.h +++ b/src/caja-navigation-window.h @@ -115,5 +115,9 @@ gboolean caja_navigation_window_is_in_temporary_navigation_bar (GtkWidget *widge CajaNavigationWindow *window); gboolean caja_navigation_window_is_in_temporary_search_bar (GtkWidget *widget, CajaNavigationWindow *window); +#if !GTK_CHECK_VERSION(3, 0, 0) +gboolean caja_window_button_press_event (GtkWidget *widget, + GdkEventButton *event); +#endif #endif diff --git a/src/file-manager/fm-list-view.c b/src/file-manager/fm-list-view.c index 46f6c143..999254d0 100644 --- a/src/file-manager/fm-list-view.c +++ b/src/file-manager/fm-list-view.c @@ -665,6 +665,9 @@ button_press_callback (GtkWidget *widget, GdkEventButton *event, gpointer callba FMListView *view; GtkTreeView *tree_view; GtkTreePath *path; +#if !GTK_CHECK_VERSION(3, 0, 0) + GtkWidget *caja_window; +#endif gboolean call_parent; GtkTreeSelection *selection; GtkWidgetClass *tree_view_class; @@ -680,6 +683,14 @@ button_press_callback (GtkWidget *widget, GdkEventButton *event, gpointer callba tree_view_class = GTK_WIDGET_GET_CLASS (tree_view); selection = gtk_tree_view_get_selection (tree_view); +#if GTK_CHECK_VERSION(3, 0, 0) + /* Don't handle extra mouse buttons here */ + if (event->button > 5) + { + return FALSE; + } +#endif + if (event->window != gtk_tree_view_get_bin_window (tree_view)) { return FALSE; @@ -849,6 +860,13 @@ button_press_callback (GtkWidget *widget, GdkEventButton *event, gpointer callba } } +#if !GTK_CHECK_VERSION(3, 0, 0) + if (event->button > 5) { + caja_window = GTK_WIDGET (fm_directory_view_get_caja_window (FM_DIRECTORY_VIEW (view))); + call_parent = !caja_navigation_window_button_press_event (caja_window, event); + } +#endif + if (call_parent) { tree_view_class->button_press_event (widget, event); @@ -887,10 +905,22 @@ button_press_callback (GtkWidget *widget, GdkEventButton *event, gpointer callba view->details->double_click_path[1] = view->details->double_click_path[0]; view->details->double_click_path[0] = NULL; } +#if GTK_CHECK_VERSION(3, 0, 0) /* Deselect if people click outside any row. It's OK to let default code run; it won't reselect anything. */ gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (tree_view)); tree_view_class->button_press_event (widget, event); +#else + if (event->button > 5) { + caja_window = GTK_WIDGET (fm_directory_view_get_caja_window (FM_DIRECTORY_VIEW (view))); + call_parent = !caja_navigation_window_button_press_event (caja_window, event); + } else { + /* Deselect if people click outside any row. It's OK to + let default code run; it won't reselect anything. */ + gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (tree_view)); + tree_view_class->button_press_event (widget, event); + } +#endif if (event->button == 3) { -- cgit v1.2.1