[gnome-builder] source-view: add push-snippet and pop-snippet signals.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] source-view: add push-snippet and pop-snippet signals.
- Date: Mon, 8 Sep 2014 06:27:28 +0000 (UTC)
commit 823addbbbb72180981347f174bc4738af3b41f8c
Author: Christian Hergert <christian hergert me>
Date: Sun Sep 7 23:22:49 2014 -0700
source-view: add push-snippet and pop-snippet signals.
This will allow us to hook into the snippet context from the editor tab,
which is where things like filename should be owned.
src/editor/gb-source-view.c | 39 ++++++++++++++++++++++++++++++++++++++-
src/editor/gb-source-view.h | 7 +++++++
2 files changed, 45 insertions(+), 1 deletions(-)
---
diff --git a/src/editor/gb-source-view.c b/src/editor/gb-source-view.c
index b263d10..1cfdb9d 100644
--- a/src/editor/gb-source-view.c
+++ b/src/editor/gb-source-view.c
@@ -59,7 +59,14 @@ enum {
LAST_PROP
};
-static GParamSpec *gParamSpecs[LAST_PROP];
+enum {
+ PUSH_SNIPPET,
+ POP_SNIPPET,
+ LAST_SIGNAL
+};
+
+static GParamSpec *gParamSpecs [LAST_PROP];
+static guint gSignals [LAST_SIGNAL];
static void
on_search_highlighter_changed (GbSourceSearchHighlighter *highlighter,
@@ -288,6 +295,7 @@ gb_source_view_pop_snippet (GbSourceView *view)
if ((snippet = g_queue_pop_head (priv->snippets)))
{
gb_source_snippet_finish (snippet);
+ g_signal_emit (view, gSignals [POP_SNIPPET], 0, snippet);
g_object_unref (snippet);
}
@@ -443,6 +451,9 @@ gb_source_view_push_snippet (GbSourceView *view,
gb_source_snippet_context_set_line_prefix (context, line_prefix);
g_free (line_prefix);
+ g_signal_emit (view, gSignals [PUSH_SNIPPET], 0,
+ snippet, context, &iter);
+
gb_source_view_block_handlers (view);
has_more_tab_stops = gb_source_snippet_begin (snippet, buffer, &iter);
gb_source_view_scroll_to_insert (view);
@@ -1055,6 +1066,32 @@ gb_source_view_class_init (GbSourceViewClass *klass)
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_SEARCH_HIGHLIGHTER,
gParamSpecs[PROP_SEARCH_HIGHLIGHTER]);
+
+ gSignals [PUSH_SNIPPET] =
+ g_signal_new ("push-snippet",
+ GB_TYPE_SOURCE_VIEW,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GbSourceViewClass, push_snippet),
+ NULL,
+ NULL,
+ g_cclosure_marshal_generic,
+ G_TYPE_NONE,
+ 3,
+ GB_TYPE_SOURCE_SNIPPET,
+ GB_TYPE_SOURCE_SNIPPET_CONTEXT,
+ GTK_TYPE_TEXT_ITER);
+
+ gSignals [POP_SNIPPET] =
+ g_signal_new ("pop-snippet",
+ GB_TYPE_SOURCE_VIEW,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GbSourceViewClass, pop_snippet),
+ NULL,
+ NULL,
+ g_cclosure_marshal_generic,
+ G_TYPE_NONE,
+ 1,
+ GB_TYPE_SOURCE_SNIPPET);
}
static void
diff --git a/src/editor/gb-source-view.h b/src/editor/gb-source-view.h
index e7ab39d..301bb9f 100644
--- a/src/editor/gb-source-view.h
+++ b/src/editor/gb-source-view.h
@@ -48,6 +48,13 @@ struct _GbSourceView
struct _GbSourceViewClass
{
GtkSourceViewClass parent_class;
+
+ void (*push_snippet) (GbSourceView *view,
+ GbSourceSnippet *snippet,
+ GbSourceSnippetContext *context,
+ GtkTextIter *location);
+ void (*pop_snippet) (GbSourceView *view,
+ GbSourceSnippet *snippet);
};
GType gb_source_view_get_type (void) G_GNUC_CONST;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]