[gnome-builder] project-tree: focus project tree with <Ctrl>F9
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] project-tree: focus project tree with <Ctrl>F9
- Date: Mon, 13 Apr 2015 22:33:19 +0000 (UTC)
commit 7c8f3b117a9cd8aec29055b2d63e31a2a84e113f
Author: Christian Hergert <christian hergert me>
Date: Mon Apr 13 15:33:07 2015 -0700
project-tree: focus project tree with <Ctrl>F9
src/app/gb-application.c | 1 +
src/editor/gb-editor-workspace-actions.c | 39 ++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/src/app/gb-application.c b/src/app/gb-application.c
index eb9906f..bb34a0c 100644
--- a/src/app/gb-application.c
+++ b/src/app/gb-application.c
@@ -152,6 +152,7 @@ gb_application_load_keybindings (GbApplication *self)
g_autoptr(GSettings) settings = NULL;
g_autofree gchar *name = NULL;
static const struct { gchar *name; gchar *binding; } shared_bindings[] = {
+ { "workspace.focus-sidebar", "<ctrl>F9" },
{ "workspace.toggle-sidebar", "F9" },
{ "workbench.show-gear-menu", "F10" },
{ "workbench.global-search", "<ctrl>period" },
diff --git a/src/editor/gb-editor-workspace-actions.c b/src/editor/gb-editor-workspace-actions.c
index 669743b..1fd4995 100644
--- a/src/editor/gb-editor-workspace-actions.c
+++ b/src/editor/gb-editor-workspace-actions.c
@@ -93,7 +93,46 @@ gb_editor_workspace_actions_toggle_sidebar (GSimpleAction *action,
g_variant_unref (state);
}
+static gboolean
+focus_widget_timeout (gpointer data)
+{
+ gtk_widget_grab_focus (data);
+ g_object_unref (data);
+ return G_SOURCE_REMOVE;
+}
+
+static void
+gb_editor_workspace_actions_focus_sidebar (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
+{
+ GbEditorWorkspace *self = user_data;
+ GActionGroup *group;
+ GAction *show_action;
+
+ g_assert (GB_IS_EDITOR_WORKSPACE (self));
+
+ group = gtk_widget_get_action_group (GTK_WIDGET (self), "workspace");
+ show_action = g_action_map_lookup_action (G_ACTION_MAP (group), "show-sidebar");
+ gb_editor_workspace_actions_show_sidebar (G_SIMPLE_ACTION (show_action),
+ g_variant_new_boolean (TRUE),
+ user_data);
+
+ /*
+ * FIXME:
+ *
+ * I don't like that we have to delay focusing the widget.
+ * We should cleanup how sidebar toggle is managed so that things
+ * can be immiediately grabbed.
+ *
+ * Additionally, why is 0 not enough delay? There must be something
+ * else that is getting done in an idle handler causing issues.
+ */
+ g_timeout_add (1, focus_widget_timeout, g_object_ref (self->project_tree));
+}
+
static const GActionEntry GbEditorWorkspaceActions[] = {
+ { "focus-sidebar", gb_editor_workspace_actions_focus_sidebar },
{ "show-sidebar", NULL, NULL, "false", gb_editor_workspace_actions_show_sidebar },
{ "toggle-sidebar", gb_editor_workspace_actions_toggle_sidebar },
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]