[gnome-builder] workbench: jump between editor and docs with <Control>1 and <Control>2
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] workbench: jump between editor and docs with <Control>1 and <Control>2
- Date: Thu, 11 Sep 2014 23:47:36 +0000 (UTC)
commit c52786bbb53ca3fd630df28f10efec0fec0c759d
Author: Christian Hergert <christian hergert me>
Date: Thu Sep 11 16:47:26 2014 -0700
workbench: jump between editor and docs with <Control>1 and <Control>2
src/resources/keybindings/default.ini | 4 +++
src/workbench/gb-workbench.c | 37 +++++++++++++++++++++++++++++---
2 files changed, 37 insertions(+), 4 deletions(-)
---
diff --git a/src/resources/keybindings/default.ini b/src/resources/keybindings/default.ini
index df04815..a45f0af 100644
--- a/src/resources/keybindings/default.ini
+++ b/src/resources/keybindings/default.ini
@@ -1,3 +1,7 @@
+[win]
+workspace1 = <Control>1
+workspace2 = <Control>2
+
[workbench]
close-tab = <Control>W
find = <Control>F
diff --git a/src/workbench/gb-workbench.c b/src/workbench/gb-workbench.c
index accb35c..b3f4f40 100644
--- a/src/workbench/gb-workbench.c
+++ b/src/workbench/gb-workbench.c
@@ -124,8 +124,8 @@ gb_workbench_stack_child_changed (GbWorkbench *workbench,
}
static void
-load_actions (GbWorkbench *workbench,
- GbWorkspace *workspace)
+gb_workbench_load_workspace_actions (GbWorkbench *workbench,
+ GbWorkspace *workspace)
{
GActionGroup *group;
const gchar *name;
@@ -154,8 +154,34 @@ gb_workbench_realize (GtkWidget *widget)
}
static void
+on_workspace1_activate (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
+{
+ GbWorkbenchPrivate *priv = GB_WORKBENCH (user_data)->priv;
+ GtkWidget *child = gtk_stack_get_child_by_name (priv->stack, "editor");
+ gtk_stack_set_visible_child (priv->stack, child);
+ gtk_widget_grab_focus (child);
+}
+
+static void
+on_workspace2_activate (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
+{
+ GbWorkbenchPrivate *priv = GB_WORKBENCH (user_data)->priv;
+ GtkWidget *child = gtk_stack_get_child_by_name (priv->stack, "devhelp");
+ gtk_stack_set_visible_child (priv->stack, child);
+ gtk_widget_grab_focus (child);
+}
+
+static void
gb_workbench_constructed (GObject *object)
{
+ static const GActionEntry actions[] = {
+ { "workspace1", on_workspace1_activate },
+ { "workspace2", on_workspace2_activate },
+ };
GbWorkbenchPrivate *priv;
GbWorkbench *workbench = (GbWorkbench *)object;
GtkApplication *app;
@@ -167,8 +193,8 @@ gb_workbench_constructed (GObject *object)
priv = workbench->priv;
- load_actions (workbench, GB_WORKSPACE (priv->editor));
- load_actions (workbench, GB_WORKSPACE (priv->devhelp));
+ gb_workbench_load_workspace_actions (workbench, GB_WORKSPACE (priv->editor));
+ gb_workbench_load_workspace_actions (workbench, GB_WORKSPACE (priv->devhelp));
app = GTK_APPLICATION (g_application_get_default ());
menu = gtk_application_get_menu_by_id (app, "gear-menu");
@@ -183,6 +209,9 @@ gb_workbench_constructed (GObject *object)
gb_workbench_stack_child_changed (workbench, NULL, priv->stack);
+ g_action_map_add_action_entries (G_ACTION_MAP (workbench), actions,
+ G_N_ELEMENTS (actions), workbench);
+
G_OBJECT_CLASS (gb_workbench_parent_class)->constructed (object);
EXIT;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]