From 27aee437014a139253162654481d3731404c6ddc Mon Sep 17 00:00:00 2001 From: Mike Massonnet Date: Tue, 16 Oct 2012 00:01:29 +0200 Subject: [PATCH] Use multimedia keys Back and Forward for moving in the history. --- configure.ac.in | 6 ++++++ thunar/thunar-window.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/configure.ac.in b/configure.ac.in index 462706b..8348dd1 100644 --- a/configure.ac.in +++ b/configure.ac.in @@ -118,6 +118,12 @@ AC_CHECK_HEADERS([ctype.h errno.h fcntl.h grp.h limits.h locale.h memory.h \ sys/mman.h sys/param.h sys/stat.h sys/time.h sys/types.h \ sys/uio.h sys/wait.h time.h]) +dnl ********************************* +dnl *** Check for multimedia keys *** +dnl ********************************* + +AC_CHECK_HEADERS([X11/XF86keysym.h]) + dnl ************************************ dnl *** Check for standard functions *** dnl ************************************ diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c index 2d2ca0e..d0c31b2 100644 --- a/thunar/thunar-window.c +++ b/thunar/thunar-window.c @@ -30,6 +30,10 @@ #include #endif +#ifdef HAVE_X11_XF86KEYSYM_H +#include +#endif + #include #include @@ -114,6 +118,8 @@ static void thunar_window_realize (GtkWidget static void thunar_window_unrealize (GtkWidget *widget); static gboolean thunar_window_configure_event (GtkWidget *widget, GdkEventConfigure *event); +static gboolean thunar_window_key_press_event (GtkWidget *widget, + GdkEventKey *event); static void thunar_window_merge_custom_preferences (ThunarWindow *window); static void thunar_window_merge_go_actions (ThunarWindow *window); static void thunar_window_install_location_bar (ThunarWindow *window, @@ -385,6 +391,7 @@ thunar_window_class_init (ThunarWindowClass *klass) gtkwidget_class->realize = thunar_window_realize; gtkwidget_class->unrealize = thunar_window_unrealize; gtkwidget_class->configure_event = thunar_window_configure_event; + gtkwidget_class->key_press_event = thunar_window_key_press_event; klass->back = thunar_window_back; klass->reload = thunar_window_reload; @@ -1360,6 +1367,47 @@ thunar_window_configure_event (GtkWidget *widget, +static gboolean +thunar_window_key_press_event (GtkWidget *widget, + GdkEventKey *event) +{ + ThunarWindow *window = THUNAR_WINDOW (widget); + GtkAction *action = NULL; + +#ifdef HAVE_X11_XF86KEYSYM_H + switch (event->keyval) + { + case XF86XK_Back: + action = gtk_action_group_get_action (window->action_group, "back"); + g_assert (action != NULL); + break; + + case XF86XK_Forward: + action = gtk_action_group_get_action (window->action_group, "forward"); + g_assert (action != NULL); + break; + + default: + break; + } + + if (action != NULL && gtk_action_is_sensitive (action)) + { + gtk_action_activate (action); + return TRUE; + } +#endif + + if (GTK_WIDGET_CLASS (thunar_window_parent_class)->key_press_event (widget, event)) + { + return TRUE; + } + + return FALSE; +} + + + static void thunar_window_install_location_bar (ThunarWindow *window, GType type) -- 1.7.11.4