[gnome-builder] command-bar: activate command-bar in vim mode upon colon



commit ec3cad3299b6689c7fb0142cf550ba9991991cdb
Author: Christian Hergert <chergert redhat com>
Date:   Mon Oct 12 21:09:28 2015 -0700

    command-bar: activate command-bar in vim mode upon colon
    
    If nothing in the workbench handled :, then we should display the
    command bar if in vim mode.
    
    We still need to improve our vim plumbing to work without an active
    source view, however. Especially for things like 'edit'.

 plugins/command-bar/Makefile.am      |    1 +
 plugins/command-bar/gb-command-bar.c |   27 +++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/plugins/command-bar/Makefile.am b/plugins/command-bar/Makefile.am
index 7d7bc39..1b3850e 100644
--- a/plugins/command-bar/Makefile.am
+++ b/plugins/command-bar/Makefile.am
@@ -36,6 +36,7 @@ libcommand_bar_la_SOURCES = \
 
 libcommand_bar_la_CFLAGS = \
        -I$(top_srcdir)/libide \
+       -I$(top_srcdir)/src/app \
        -I$(top_srcdir)/src/workspace \
        -I$(top_srcdir)/src/workbench \
        -I$(top_srcdir)/src/views \
diff --git a/plugins/command-bar/gb-command-bar.c b/plugins/command-bar/gb-command-bar.c
index 81928f0..791caed 100644
--- a/plugins/command-bar/gb-command-bar.c
+++ b/plugins/command-bar/gb-command-bar.c
@@ -20,6 +20,7 @@
 #include <ide.h>
 #include <libpeas/peas.h>
 
+#include "gb-application.h"
 #include "gb-command.h"
 #include "gb-command-bar-resources.h"
 #include "gb-command-bar.h"
@@ -76,6 +77,26 @@ enum {
 
 static guint gSignals [LAST_SIGNAL];
 
+static gboolean
+key_press_event_cb (GbWorkbench  *workbench,
+                    GdkEventKey  *event,
+                    GbCommandBar *self)
+{
+  if (event->keyval == GDK_KEY_colon)
+    {
+      GbApplication *application = GB_APPLICATION (g_application_get_default ());
+      const gchar *mode = gb_application_get_keybindings_mode (application);
+
+      if (g_strcmp0 ("vim", mode) == 0)
+        {
+          g_action_activate (G_ACTION (self->show_action), NULL);
+          return GDK_EVENT_STOP;
+        }
+    }
+
+  return GDK_EVENT_PROPAGATE;
+}
+
 static void
 gb_command_bar_load (GbWorkbenchAddin *addin,
                      GbWorkbench      *workbench)
@@ -107,6 +128,12 @@ gb_command_bar_load (GbWorkbenchAddin *addin,
 
   g_action_map_add_action (G_ACTION_MAP (self->workbench), G_ACTION (self->show_action));
 
+  g_signal_connect_object (workbench,
+                           "key-press-event",
+                           G_CALLBACK (key_press_event_cb),
+                           self,
+                           G_CONNECT_AFTER);
+
   gtk_widget_show (GTK_WIDGET (self));
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]