[gnome-builder/editor-layout] editor: SHIFT+K in VIM will now jump to documentation for keyword
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/editor-layout] editor: SHIFT+K in VIM will now jump to documentation for keyword
- Date: Mon, 1 Dec 2014 13:20:54 +0000 (UTC)
commit 99ff09684deb0c841a6d5380ff0edc5bc3df698b
Author: Christian Hergert <christian hergert me>
Date: Mon Dec 1 05:15:48 2014 -0800
editor: SHIFT+K in VIM will now jump to documentation for keyword
This should be somewhat like VIM but use a secondary pane for the info.
We might consider using the same pane and just CTRL+W to dismiss it.
src/devhelp/gb-devhelp-tab.c | 6 ++++
src/editor/gb-editor-frame.c | 59 ++++++++++++++++++++++++++++++++++++-
src/editor/gb-editor-workspace.c | 32 ++++++++++++++++++++
3 files changed, 95 insertions(+), 2 deletions(-)
---
diff --git a/src/devhelp/gb-devhelp-tab.c b/src/devhelp/gb-devhelp-tab.c
index 3290bd1..72f72df 100644
--- a/src/devhelp/gb-devhelp-tab.c
+++ b/src/devhelp/gb-devhelp-tab.c
@@ -53,6 +53,8 @@ void
gb_devhelp_tab_jump_to_keyword (GbDevhelpTab *tab,
const gchar *keyword)
{
+ gchar *title;
+
ENTRY;
g_return_if_fail (GB_IS_DEVHELP_TAB (tab));
@@ -60,6 +62,10 @@ gb_devhelp_tab_jump_to_keyword (GbDevhelpTab *tab,
dh_assistant_view_search (tab->priv->assistant_view, keyword);
+ title = g_strdup_printf (_("Documentation (%s)"), keyword);
+ gb_tab_set_title (GB_TAB (tab), title);
+ g_free (title);
+
EXIT;
}
diff --git a/src/editor/gb-editor-frame.c b/src/editor/gb-editor-frame.c
index 833f24d..2011f51 100644
--- a/src/editor/gb-editor-frame.c
+++ b/src/editor/gb-editor-frame.c
@@ -22,6 +22,7 @@
#include "gb-editor-frame.h"
#include "gb-editor-frame-private.h"
+#include "gb-editor-workspace.h"
#include "gb-log.h"
#include "gb-source-formatter.h"
#include "gb-string.h"
@@ -826,12 +827,12 @@ gb_editor_frame_on_command_toggled (GbEditorFrame *frame,
workbench = gb_widget_get_workbench (GTK_WIDGET (frame));
if (!workbench)
- return;
+ EXIT;
action = g_action_map_lookup_action (G_ACTION_MAP (workbench),
"toggle-command-bar");
if (!action)
- return;
+ EXIT;
params = g_variant_new_boolean (visible);
g_action_activate (action, params);
@@ -840,6 +841,55 @@ gb_editor_frame_on_command_toggled (GbEditorFrame *frame,
}
static void
+gb_editor_frame_on_jump_to_doc (GbEditorFrame *frame,
+ const gchar *search_text,
+ GbSourceVim *vim)
+{
+ GbWorkbench *workbench;
+ GAction *action;
+ GVariant *params;
+ GtkWidget *parent;
+
+ ENTRY;
+
+ g_return_if_fail (GB_IS_EDITOR_FRAME (frame));
+ g_return_if_fail (GB_IS_SOURCE_VIM (vim));
+
+ workbench = gb_widget_get_workbench (GTK_WIDGET (frame));
+ if (!workbench)
+ EXIT;
+
+ parent = GTK_WIDGET (frame);
+
+ /*
+ * TODO: I really want this to all just work by searching for muxed actions
+ * in Gtk+ directly. Matthias has some patches and Ryan needs to
+ * review them. This all becomes easier then.
+ */
+
+ while (parent && !GB_IS_EDITOR_WORKSPACE (parent))
+ parent = gtk_widget_get_parent (parent);
+
+ if (GB_IS_EDITOR_WORKSPACE (parent))
+ {
+ GActionGroup *group;
+
+ group = gb_workspace_get_actions (GB_WORKSPACE (parent));
+ action = g_action_map_lookup_action (G_ACTION_MAP (group),
+ "jump-to-doc");
+ if (!action)
+ EXIT;
+
+ params = g_variant_new_string (search_text);
+ g_action_activate (action, params);
+
+ EXIT;
+ }
+
+ EXIT;
+}
+
+static void
gb_editor_frame_grab_focus (GtkWidget *widget)
{
GbEditorFrame *frame = (GbEditorFrame *)widget;
@@ -926,6 +976,11 @@ gb_editor_frame_constructed (GObject *object)
G_CALLBACK (gb_editor_frame_on_command_toggled),
frame,
G_CONNECT_SWAPPED);
+ g_signal_connect_object (vim,
+ "jump-to-doc",
+ G_CALLBACK (gb_editor_frame_on_jump_to_doc),
+ frame,
+ G_CONNECT_SWAPPED);
g_signal_connect_object (priv->source_view,
"focus-in-event",
diff --git a/src/editor/gb-editor-workspace.c b/src/editor/gb-editor-workspace.c
index 8ab9721..45015a7 100644
--- a/src/editor/gb-editor-workspace.c
+++ b/src/editor/gb-editor-workspace.c
@@ -18,6 +18,7 @@
#include <glib/gi18n.h>
+#include "gb-devhelp-tab.h"
#include "gb-editor-workspace.h"
#include "gb-editor-workspace-private.h"
#include "gb-tab-grid.h"
@@ -213,6 +214,36 @@ new_tab (GSimpleAction *action,
}
static void
+jump_to_doc_tab (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ GbEditorWorkspace *workspace = user_data;
+ const gchar *search_text;
+ GbTab *tab;
+
+ search_text = g_variant_get_string (parameter, NULL);
+ if (!search_text || !*search_text)
+ return;
+
+ tab = gb_tab_grid_find_tab_typed (workspace->priv->tab_grid,
+ GB_TYPE_DEVHELP_TAB);
+
+ if (!tab)
+ {
+ tab = g_object_new (GB_TYPE_DEVHELP_TAB,
+ "visible", TRUE,
+ NULL);
+ gtk_container_add (GTK_CONTAINER (workspace->priv->tab_grid),
+ GTK_WIDGET (tab));
+ gb_tab_grid_move_tab_right (workspace->priv->tab_grid, tab);
+ }
+
+ gb_devhelp_tab_jump_to_keyword (GB_DEVHELP_TAB (tab), search_text);
+ gb_tab_grid_focus_tab (workspace->priv->tab_grid, tab);
+}
+
+static void
open_tab (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
@@ -348,6 +379,7 @@ gb_editor_workspace_init (GbEditorWorkspace *workspace)
{ "find", find_tab },
{ "reformat", reformat_tab },
{ "preview", preview_tab },
+ { "jump-to-doc", jump_to_doc_tab, "s" },
};
workspace->priv = gb_editor_workspace_get_instance_private (workspace);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]