summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2017-07-26 00:17:12 +0200
committerCarlos Garnacho <carlosg@gnome.org>2017-08-07 17:22:37 +0200
commitaae95a43be1afdccd703529c2594716d90e6aeaf (patch)
tree82c388bf76f739970b9fe227811b4b1daca11dd4
parent25631200f79df674a526f556f8251ba6366d8a26 (diff)
downloadnautilus-aae95a43be1afdccd703529c2594716d90e6aeaf.tar.gz
window: Add tablet pad controller for common actions
Since nautilus is an important tool in the workflow of designers and other users of graphics tablets, make tablet pads useful by mapping a sensible set of actions that are not directly accessible with the stylus nor immediately require keyboard input. Tablet pads may vary a lot between devices, from 4 to 10+ buttons, besides rings/strips and multiple modes. It doesn't make a lot of sense for nautilus to handle those in detail, so this patch provides a mile-high support that should work reasonably well across the range of devices. Actions are made to apply on all modes, and the most sensible/less reachable options are assigned to lower button numbers. https://bugzilla.gnome.org/show_bug.cgi?id=785443
-rw-r--r--src/nautilus-window.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index bdfc024a7..951059a0a 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -143,6 +143,8 @@ typedef struct
guint bookmarks_id;
GQueue *tab_data_queue;
+
+ GtkPadController *pad_controller;
} NautilusWindowPrivate;
enum
@@ -186,6 +188,15 @@ static const struct
#endif
};
+static const GtkPadActionEntry pad_actions[] = {
+ { GTK_PAD_ACTION_BUTTON, 0, -1, N_("Parent folder"), "up" },
+ { GTK_PAD_ACTION_BUTTON, 1, -1, N_("Home"), "go-home" },
+ { GTK_PAD_ACTION_BUTTON, 2, -1, N_("New tab"), "new-tab" },
+ { GTK_PAD_ACTION_BUTTON, 3, -1, N_("Close current view"), "close-current-view" },
+ { GTK_PAD_ACTION_BUTTON, 4, -1, N_("Back"), "back" },
+ { GTK_PAD_ACTION_BUTTON, 5, -1, N_("Forward"), "forward" },
+};
+
static void
action_close_current_view (GSimpleAction *action,
GVariant *state,
@@ -2586,6 +2597,8 @@ nautilus_window_finalize (GObject *object)
g_queue_foreach (priv->tab_data_queue, (GFunc) free_restore_tab_data, NULL);
g_queue_free (priv->tab_data_queue);
+ g_object_unref (priv->pad_controller);
+
/* nautilus_window_close() should have run */
g_assert (priv->slots == NULL);
@@ -2917,6 +2930,12 @@ nautilus_window_init (NautilusWindow *window)
g_object_unref (window_group);
priv->tab_data_queue = g_queue_new();
+
+ priv->pad_controller = gtk_pad_controller_new (GTK_WINDOW (window),
+ G_ACTION_GROUP (window),
+ NULL);
+ gtk_pad_controller_set_action_entries (priv->pad_controller,
+ pad_actions, G_N_ELEMENTS (pad_actions));
}
static void