[gnome-builder] vim: add "execute-command" signal to GbSourceVim



commit fd940f1acec9fcd4f23bf47f5cb48e7309d265c0
Author: Christian Hergert <christian hergert me>
Date:   Mon Jan 12 19:24:01 2015 -0800

    vim: add "execute-command" signal to GbSourceVim
    
    This allows for command execution to be hooked and signal emission to
    be blocked by returning TRUE.

 src/vim/gb-source-vim.c |   35 ++++++++++++++++++++++++++++++++---
 src/vim/gb-source-vim.h |   14 ++++++++------
 2 files changed, 40 insertions(+), 9 deletions(-)
---
diff --git a/src/vim/gb-source-vim.c b/src/vim/gb-source-vim.c
index 318682b..f56e4e5 100644
--- a/src/vim/gb-source-vim.c
+++ b/src/vim/gb-source-vim.c
@@ -196,6 +196,7 @@ enum
 {
   BEGIN_SEARCH,
   COMMAND_VISIBILITY_TOGGLED,
+  EXECUTE_COMMAND,
   JUMP_TO_DOC,
   LAST_SIGNAL
 };
@@ -4099,9 +4100,9 @@ gb_source_vim_is_command (const gchar *command_text)
   return FALSE;
 }
 
-gboolean
-gb_source_vim_execute_command (GbSourceVim *vim,
-                               const gchar *command)
+static gboolean
+gb_source_vim_real_execute_command (GbSourceVim *vim,
+                                    const gchar *command)
 {
   GbSourceVimOperation func;
   GtkTextBuffer *buffer;
@@ -4130,6 +4131,20 @@ gb_source_vim_execute_command (GbSourceVim *vim,
   return ret;
 }
 
+gboolean
+gb_source_vim_execute_command (GbSourceVim *vim,
+                               const gchar *command)
+{
+  gboolean ret = FALSE;
+
+  g_return_val_if_fail (GB_IS_SOURCE_VIM (vim), FALSE);
+  g_return_val_if_fail (command, FALSE);
+
+  g_signal_emit (vim, gSignals [EXECUTE_COMMAND], 0, command, &ret);
+
+  return ret;
+}
+
 static void
 gb_source_vim_finalize (GObject *object)
 {
@@ -5140,6 +5155,8 @@ gb_source_vim_class_init (GbSourceVimClass *klass)
   object_class->get_property = gb_source_vim_get_property;
   object_class->set_property = gb_source_vim_set_property;
 
+  klass->execute_command = gb_source_vim_real_execute_command;
+
   gParamSpecs [PROP_ENABLED] =
     g_param_spec_boolean ("enabled",
                           _("Enabled"),
@@ -5223,6 +5240,18 @@ gb_source_vim_class_init (GbSourceVimClass *klass)
                   1,
                   G_TYPE_BOOLEAN);
 
+  gSignals [EXECUTE_COMMAND] =
+    g_signal_new ("execute-command",
+                  GB_TYPE_SOURCE_VIM,
+                  G_SIGNAL_RUN_LAST,
+                  G_STRUCT_OFFSET (GbSourceVimClass, execute_command),
+                  g_signal_accumulator_true_handled,
+                  NULL,
+                  g_cclosure_marshal_VOID__STRING,
+                  G_TYPE_BOOLEAN,
+                  1,
+                  G_TYPE_STRING);
+
   /**
    * GbSourceVim::jump-to-doc:
    * @search_text: keyword to search for.
diff --git a/src/vim/gb-source-vim.h b/src/vim/gb-source-vim.h
index 552eba0..560fbe3 100644
--- a/src/vim/gb-source-vim.h
+++ b/src/vim/gb-source-vim.h
@@ -55,12 +55,14 @@ struct _GbSourceVimClass
 {
   GObjectClass parent_class;
 
-  void (*begin_search)               (GbSourceVim *vim,
-                                      const gchar *search_text);
-  void (*command_visibility_toggled) (GbSourceVim *vim,
-                                      gboolean     visibility);
-  void (*jump_to_doc)                (GbSourceVim *vim,
-                                      const gchar *search_text);
+  void     (*begin_search)               (GbSourceVim *vim,
+                                          const gchar *search_text);
+  void     (*command_visibility_toggled) (GbSourceVim *vim,
+                                          gboolean     visibility);
+  gboolean (*execute_command)            (GbSourceVim *vim,
+                                          const gchar *command);
+  void     (*jump_to_doc)                (GbSourceVim *vim,
+                                          const gchar *search_text);
 
   gpointer _padding1;
   gpointer _padding2;


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