[gnome-builder/editor-layout] wire up vim command bar
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/editor-layout] wire up vim command bar
- Date: Sun, 30 Nov 2014 13:20:33 +0000 (UTC)
commit 0f1349b4624ae276d0742c190b28b4fa667dbb61
Author: Christian Hergert <christian hergert me>
Date: Sun Nov 30 03:07:03 2014 -0800
wire up vim command bar
src/commands/gb-command-vim-provider.c | 5 +---
src/commands/gb-command-vim.c | 8 +++---
src/editor/gb-editor-frame.c | 39 ++++++++++++++++++++++++++++++++
3 files changed, 44 insertions(+), 8 deletions(-)
---
diff --git a/src/commands/gb-command-vim-provider.c b/src/commands/gb-command-vim-provider.c
index 88ec37f..bb052df 100644
--- a/src/commands/gb-command-vim-provider.c
+++ b/src/commands/gb-command-vim-provider.c
@@ -20,6 +20,7 @@
#include "gb-command-vim.h"
#include "gb-command-vim-provider.h"
+#include "gb-editor-tab.h"
#include "gb-source-vim.h"
G_DEFINE_TYPE (GbCommandVimProvider, gb_command_vim_provider,
@@ -58,14 +59,10 @@ gb_command_vim_provider_lookup (GbCommandProvider *provider,
if (!GB_IS_WORKBENCH (workbench))
return NULL;
-#if 0
/* Make sure we have an editor tab last focused */
active_tab = gb_command_provider_get_active_tab (provider);
if (!GB_IS_EDITOR_TAB (active_tab))
return NULL;
-#else
- return NULL;
-#endif
/* See if GbEditorVim recognizes this command */
if (gb_source_vim_is_command (command_text))
diff --git a/src/commands/gb-command-vim.c b/src/commands/gb-command-vim.c
index 53d1fff..f96520e 100644
--- a/src/commands/gb-command-vim.c
+++ b/src/commands/gb-command-vim.c
@@ -16,11 +16,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#if 0
-
#include <glib/gi18n.h>
#include "gb-command-vim.h"
+#include "gb-editor-frame-private.h"
#include "gb-editor-tab.h"
#include "gb-editor-tab-private.h"
#include "gb-source-vim.h"
@@ -111,8 +110,10 @@ gb_command_vim_execute (GbCommand *command)
if (self->priv->tab && self->priv->command_text)
{
GbSourceVim *vim;
+ GbEditorFrame *frame;
- vim = gb_source_view_get_vim (self->priv->tab->priv->source_view);
+ frame = gb_editor_tab_get_last_frame (self->priv->tab);
+ vim = gb_source_view_get_vim (frame->priv->source_view);
gb_source_vim_execute_command (vim, self->priv->command_text);
}
@@ -214,4 +215,3 @@ gb_command_vim_init (GbCommandVim *self)
{
self->priv = gb_command_vim_get_instance_private (self);
}
-#endif
diff --git a/src/editor/gb-editor-frame.c b/src/editor/gb-editor-frame.c
index c602685..1e46958 100644
--- a/src/editor/gb-editor-frame.c
+++ b/src/editor/gb-editor-frame.c
@@ -23,6 +23,8 @@
#include "gb-editor-frame.h"
#include "gb-editor-frame-private.h"
#include "gb-log.h"
+#include "gb-widget.h"
+#include "gb-workbench.h"
G_DEFINE_TYPE_WITH_PRIVATE (GbEditorFrame, gb_editor_frame, GTK_TYPE_OVERLAY)
@@ -600,6 +602,35 @@ cleanup:
}
static void
+gb_editor_frame_on_command_toggled (GbEditorFrame *frame,
+ gboolean visible,
+ GbSourceVim *vim)
+{
+ GbWorkbench *workbench;
+ GAction *action;
+ GVariant *params;
+
+ 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)
+ return;
+
+ action = g_action_map_lookup_action (G_ACTION_MAP (workbench),
+ "toggle-command-bar");
+ if (!action)
+ return;
+
+ params = g_variant_new_boolean (visible);
+ g_action_activate (action, params);
+
+ EXIT;
+}
+
+static void
gb_editor_frame_grab_focus (GtkWidget *widget)
{
GbEditorFrame *frame = (GbEditorFrame *)widget;
@@ -631,6 +662,7 @@ gb_editor_frame_constructed (GObject *object)
GbEditorFramePrivate *priv = GB_EDITOR_FRAME (object)->priv;
GtkSourceGutter *gutter;
GbEditorFrame *frame = GB_EDITOR_FRAME (object);
+ GbSourceVim *vim;
G_OBJECT_CLASS (gb_editor_frame_parent_class)->constructed (object);
@@ -679,6 +711,13 @@ gb_editor_frame_constructed (GObject *object)
priv->source_view, "show-shadow",
G_BINDING_SYNC_CREATE);
+ vim = gb_source_view_get_vim (priv->source_view);
+ g_signal_connect_object (vim,
+ "command-visibility-toggled",
+ G_CALLBACK (gb_editor_frame_on_command_toggled),
+ frame,
+ G_CONNECT_SWAPPED);
+
g_signal_connect_object (priv->source_view,
"focus-in-event",
G_CALLBACK (gb_editor_frame_on_focus_in_event),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]