[gnome-builder/editor-layout] wire up find command



commit 5dea826aacff6daa9dbfe36f5835477a0765402b
Author: Christian Hergert <christian hergert me>
Date:   Sun Nov 30 20:14:38 2014 -0800

    wire up find command

 src/editor/gb-editor-frame.c     |   13 +++++++++++++
 src/editor/gb-editor-frame.h     |    2 ++
 src/editor/gb-editor-tab.c       |   11 +++++++++++
 src/editor/gb-editor-tab.h       |    1 +
 src/editor/gb-editor-workspace.c |   14 ++++++++++++++
 5 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/src/editor/gb-editor-frame.c b/src/editor/gb-editor-frame.c
index 1e46958..9a51537 100644
--- a/src/editor/gb-editor-frame.c
+++ b/src/editor/gb-editor-frame.c
@@ -535,6 +535,19 @@ gb_editor_frame_on_begin_search (GbEditorFrame    *frame,
   EXIT;
 }
 
+void
+gb_editor_frame_find (GbEditorFrame *frame,
+                      const gchar   *search_text)
+{
+  g_return_if_fail (GB_IS_EDITOR_FRAME (frame));
+
+  if (!search_text)
+    search_text = "";
+
+  gb_editor_frame_on_begin_search (frame, GTK_DIR_DOWN, search_text,
+                                   frame->priv->source_view);
+}
+
 static gboolean
 gb_editor_frame_on_query_tooltip (GbEditorFrame *frame,
                                   gint           x,
diff --git a/src/editor/gb-editor-frame.h b/src/editor/gb-editor-frame.h
index 37ddaf1..2c006ba 100644
--- a/src/editor/gb-editor-frame.h
+++ b/src/editor/gb-editor-frame.h
@@ -57,6 +57,8 @@ void              gb_editor_frame_link         (GbEditorFrame    *src,
 GbEditorDocument *gb_editor_frame_get_document (GbEditorFrame    *frame);
 void              gb_editor_frame_set_document (GbEditorFrame    *frame,
                                                 GbEditorDocument *document);
+void              gb_editor_frame_find         (GbEditorFrame    *frame,
+                                                const gchar      *search_text);
 
 G_END_DECLS
 
diff --git a/src/editor/gb-editor-tab.c b/src/editor/gb-editor-tab.c
index 5dd68d3..d005bab 100644
--- a/src/editor/gb-editor-tab.c
+++ b/src/editor/gb-editor-tab.c
@@ -464,6 +464,17 @@ gb_editor_tab_on_modified_changed (GbEditorTab   *tab,
   g_object_notify (G_OBJECT (tab), "title");
 }
 
+void
+gb_editor_tab_find (GbEditorTab *tab)
+{
+  GbEditorFrame *frame;
+
+  g_return_if_fail (GB_IS_EDITOR_TAB (tab));
+
+  frame = gb_editor_tab_get_last_frame (tab);
+  gb_editor_frame_find (frame, NULL);
+}
+
 static void
 gb_editor_tab_constructed (GObject *object)
 {
diff --git a/src/editor/gb-editor-tab.h b/src/editor/gb-editor-tab.h
index 70d49ce..11b9c66 100644
--- a/src/editor/gb-editor-tab.h
+++ b/src/editor/gb-editor-tab.h
@@ -60,6 +60,7 @@ void         gb_editor_tab_open_file    (GbEditorTab *tab,
 void         gb_editor_tab_scroll_up    (GbEditorTab *tab);
 void         gb_editor_tab_scroll_down  (GbEditorTab *tab);
 void         gb_editor_tab_toggle_split (GbEditorTab *tab);
+void         gb_editor_tab_find         (GbEditorTab *tab);
 
 G_END_DECLS
 
diff --git a/src/editor/gb-editor-workspace.c b/src/editor/gb-editor-workspace.c
index 16f906e..e1b07e3 100644
--- a/src/editor/gb-editor-workspace.c
+++ b/src/editor/gb-editor-workspace.c
@@ -115,6 +115,19 @@ toggle_split_tab (GSimpleAction *action,
 }
 
 static void
+find_tab (GSimpleAction *action,
+          GVariant      *parameter,
+          gpointer       user_data)
+{
+  GbEditorWorkspace *workspace = user_data;
+  GbTab *tab;
+
+  tab = gb_tab_grid_get_active (workspace->priv->tab_grid);
+  if (GB_IS_EDITOR_TAB (tab))
+    gb_editor_tab_find (GB_EDITOR_TAB (tab));
+}
+
+static void
 close_tab (GSimpleAction *action,
            GVariant      *parameter,
            gpointer       user_data)
@@ -270,6 +283,7 @@ gb_editor_workspace_init (GbEditorWorkspace *workspace)
       { "scroll-up", scroll_up_tab },
       { "scroll-down", scroll_down_tab },
       { "toggle-split", toggle_split_tab },
+      { "find", find_tab },
     };
 
   workspace->priv = gb_editor_workspace_get_instance_private (workspace);


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