[gnome-builder/wip/vim] editor: make beginning search a GbSourceView signal.



commit 850ce9eb3ff390cbf25386af169b2e78d283ab9b
Author: Christian Hergert <christian hergert me>
Date:   Mon Sep 29 16:26:30 2014 -0700

    editor: make beginning search a GbSourceView signal.
    
    This allows the VIM engine to initiate a search as well as the <Control>F
    accelerator.

 src/editor/gb-editor-commands.c |   11 +----------
 src/editor/gb-editor-tab.c      |   20 ++++++++++++++++++++
 src/editor/gb-source-view.c     |   20 ++++++++++++++++++++
 src/editor/gb-source-view.h     |    2 ++
 4 files changed, 43 insertions(+), 10 deletions(-)
---
diff --git a/src/editor/gb-editor-commands.c b/src/editor/gb-editor-commands.c
index e12881e..d4d7cda 100644
--- a/src/editor/gb-editor-commands.c
+++ b/src/editor/gb-editor-commands.c
@@ -216,18 +216,9 @@ void
 gb_editor_commands_find (GbEditorWorkspace *workspace,
                          GbEditorTab       *tab)
 {
-  GbEditorTabPrivate *priv;
-
   ENTRY;
-
   g_return_if_fail (GB_IS_EDITOR_TAB (tab));
-
-  priv = tab->priv;
-
-  gtk_revealer_set_reveal_child (priv->revealer, TRUE);
-  gtk_source_search_context_set_highlight (priv->search_context, TRUE);
-  gtk_widget_grab_focus (GTK_WIDGET (priv->search_entry));
-
+  gb_source_view_begin_search (tab->priv->source_view);
   EXIT;
 }
 
diff --git a/src/editor/gb-editor-tab.c b/src/editor/gb-editor-tab.c
index 84f3213..3bea8a2 100644
--- a/src/editor/gb-editor-tab.c
+++ b/src/editor/gb-editor-tab.c
@@ -884,6 +884,22 @@ on_source_view_push_snippet (GbSourceView           *source_view,
     }
 }
 
+static void
+on_source_view_begin_search (GbSourceView *source_view,
+                             GbEditorTab  *tab)
+{
+  GbEditorTabPrivate *priv;
+
+  g_return_if_fail (GB_IS_EDITOR_TAB (tab));
+  g_return_if_fail (GB_IS_SOURCE_VIEW (source_view));
+
+  priv = tab->priv;
+
+  gtk_revealer_set_reveal_child (priv->revealer, TRUE);
+  gtk_source_search_context_set_highlight (priv->search_context, TRUE);
+  gtk_widget_grab_focus (GTK_WIDGET (priv->search_entry));
+}
+
 void
 gb_editor_tab_scroll_to_line (GbEditorTab *tab,
                               guint        line,
@@ -1007,6 +1023,10 @@ gb_editor_tab_constructed (GObject *object)
                     "push-snippet",
                     G_CALLBACK (on_source_view_push_snippet),
                     tab);
+  g_signal_connect (priv->source_view,
+                    "begin-search",
+                    G_CALLBACK (on_source_view_begin_search),
+                    tab);
 
   g_signal_connect_swapped (priv->go_down_button,
                             "clicked",
diff --git a/src/editor/gb-source-view.c b/src/editor/gb-source-view.c
index 12e8d4a..c692993 100644
--- a/src/editor/gb-source-view.c
+++ b/src/editor/gb-source-view.c
@@ -67,12 +67,21 @@ enum {
 enum {
   PUSH_SNIPPET,
   POP_SNIPPET,
+  BEGIN_SEARCH,
   LAST_SIGNAL
 };
 
 static GParamSpec *gParamSpecs [LAST_PROP];
 static guint       gSignals [LAST_SIGNAL];
 
+void
+gb_source_view_begin_search (GbSourceView *view)
+{
+  g_return_if_fail (GB_IS_SOURCE_VIEW (view));
+
+  g_signal_emit (view, gSignals [BEGIN_SEARCH], 0);
+}
+
 static void
 on_search_highlighter_changed (GbSourceSearchHighlighter *highlighter,
                                GbSourceView              *view)
@@ -1461,6 +1470,17 @@ gb_source_view_class_init (GbSourceViewClass *klass)
                   G_TYPE_NONE,
                   1,
                   GB_TYPE_SOURCE_SNIPPET);
+
+  gSignals [BEGIN_SEARCH] =
+    g_signal_new ("begin-search",
+                  GB_TYPE_SOURCE_VIEW,
+                  G_SIGNAL_RUN_LAST,
+                  G_STRUCT_OFFSET (GbSourceViewClass, begin_search),
+                  NULL,
+                  NULL,
+                  g_cclosure_marshal_VOID__VOID,
+                  G_TYPE_NONE,
+                  0);
 }
 
 static void
diff --git a/src/editor/gb-source-view.h b/src/editor/gb-source-view.h
index f27e218..7d82cbe 100644
--- a/src/editor/gb-source-view.h
+++ b/src/editor/gb-source-view.h
@@ -56,6 +56,7 @@ struct _GbSourceViewClass
                         GtkTextIter            *location);
   void (*pop_snippet)  (GbSourceView           *view,
                         GbSourceSnippet        *snippet);
+  void (*begin_search) (GbSourceView           *view);
 };
 
 GType                 gb_source_view_get_type          (void) G_GNUC_CONST;
@@ -68,6 +69,7 @@ void                  gb_source_view_set_show_shadow   (GbSourceView         *vi
 GbSourceAutoIndenter *gb_source_view_get_auto_indenter (GbSourceView         *view);
 void                  gb_source_view_set_auto_indenter (GbSourceView         *view,
                                                         GbSourceAutoIndenter *auto_indenter);
+void                  gb_source_view_begin_search      (GbSourceView         *view);
 
 G_END_DECLS
 


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