[gtksourceview/wip/search-start-signal] Add private search-start signal



commit c8e6a04afb73e6699adcc37e9889ee973b588fbf
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Wed Aug 10 12:57:11 2016 +0200

    Add private search-start signal
    
    https://bugzilla.gnome.org/show_bug.cgi?id=742550

 docs/reference/Makefile.am              |    1 +
 gtksourceview/Makefile.am               |    2 +
 gtksourceview/gtksourcebufferinternal.c |  117 +++++++++++++++++++++++++++++++
 gtksourceview/gtksourcebufferinternal.h |   48 +++++++++++++
 gtksourceview/gtksourcetypes-private.h  |    1 +
 po/POTFILES.in                          |    1 +
 6 files changed, 170 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am
index 1e85a23..7da1e9e 100644
--- a/docs/reference/Makefile.am
+++ b/docs/reference/Makefile.am
@@ -34,6 +34,7 @@ IGNORE_HFILES =                                       \
        gtksource.h                             \
        gtksourcebuffer-private.h               \
        gtksourcebufferinputstream.h            \
+       gtksourcebufferinternal.h               \
        gtksourcebufferoutputstream.h           \
        gtksourcecompletioncontainer.h          \
        gtksourcecompletionmodel.h              \
diff --git a/gtksourceview/Makefile.am b/gtksourceview/Makefile.am
index e304301..b86eccf 100644
--- a/gtksourceview/Makefile.am
+++ b/gtksourceview/Makefile.am
@@ -99,6 +99,7 @@ libgtksourceview_private_headers =            \
        gconstructor.h                          \
        gtksourcebuffer-private.h               \
        gtksourcebufferinputstream.h            \
+       gtksourcebufferinternal.h               \
        gtksourcebufferoutputstream.h           \
        gtksourcecompletioncontainer.h          \
        gtksourcecompletionmodel.h              \
@@ -124,6 +125,7 @@ libgtksourceview_private_headers =          \
 
 libgtksourceview_private_c_files =     \
        gtksourcebufferinputstream.c    \
+       gtksourcebufferinternal.c       \
        gtksourcebufferoutputstream.c   \
        gtksourcecompletioncontainer.c  \
        gtksourcecompletionmodel.c      \
diff --git a/gtksourceview/gtksourcebufferinternal.c b/gtksourceview/gtksourcebufferinternal.c
new file mode 100644
index 0000000..989f5f6
--- /dev/null
+++ b/gtksourceview/gtksourcebufferinternal.c
@@ -0,0 +1,117 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; coding: utf-8 -*- */
+/* gtksourcebufferinternal.c
+ * This file is part of GtkSourceView
+ *
+ * Copyright (C) 2016 - Sébastien Wilmet <swilmet gnome org>
+ *
+ * GtkSourceView is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * GtkSourceView is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "gtksourcebufferinternal.h"
+#include "gtksourcebuffer.h"
+#include "gtksourcesearchcontext.h"
+
+/* A private extension of GtkSourceBuffer, to add private signals and
+ * properties.
+ */
+
+struct _GtkSourceBufferInternal
+{
+       GObject parent_instance;
+};
+
+enum
+{
+       SIGNAL_SEARCH_START,
+       N_SIGNALS
+};
+
+#define GTK_SOURCE_BUFFER_INTERNAL_KEY "gtk-source-buffer-internal-key"
+
+static guint signals[N_SIGNALS];
+
+G_DEFINE_TYPE (GtkSourceBufferInternal, _gtk_source_buffer_internal, G_TYPE_OBJECT)
+
+static void
+_gtk_source_buffer_internal_class_init (GtkSourceBufferInternalClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+       /*
+        * GtkSourceBufferInternal::search-start:
+        * @buffer_internal: the object that received the signal.
+        * @search_context: the #GtkSourceSearchContext.
+        *
+        * The ::search-start signal is emitted when a search is starting.
+        */
+       signals[SIGNAL_SEARCH_START] =
+               g_signal_new ("search-start",
+                             G_OBJECT_CLASS_TYPE (object_class),
+                             G_SIGNAL_RUN_LAST,
+                             0,
+                             NULL, NULL, NULL,
+                             G_TYPE_NONE,
+                             1, GTK_SOURCE_TYPE_SEARCH_CONTEXT);
+}
+
+static void
+_gtk_source_buffer_internal_init (GtkSourceBufferInternal *buffer_internal)
+{
+}
+
+/*
+ * _gtk_source_buffer_internal_get_from_buffer:
+ * @buffer: a #GtkSourceBuffer.
+ *
+ * Returns the #GtkSourceBufferInternal object of @buffer. The returned object
+ * is guaranteed to be the same for the lifetime of @buffer.
+ *
+ * Returns: (transfer none): the #GtkSourceBufferInternal object of @buffer.
+ */
+GtkSourceBufferInternal *
+_gtk_source_buffer_internal_get_from_buffer (GtkSourceBuffer *buffer)
+{
+       GtkSourceBufferInternal *buffer_internal;
+
+       g_return_val_if_fail (GTK_SOURCE_IS_BUFFER (buffer), NULL);
+
+       buffer_internal = g_object_get_data (G_OBJECT (buffer), GTK_SOURCE_BUFFER_INTERNAL_KEY);
+
+       if (buffer_internal == NULL)
+       {
+               buffer_internal = g_object_new (GTK_SOURCE_TYPE_BUFFER_INTERNAL, NULL);
+
+               g_object_set_data_full (G_OBJECT (buffer),
+                                       GTK_SOURCE_BUFFER_INTERNAL_KEY,
+                                       buffer_internal,
+                                       g_object_unref);
+       }
+
+       g_return_val_if_fail (GTK_SOURCE_IS_BUFFER_INTERNAL (buffer_internal), NULL);
+       return buffer_internal;
+}
+
+void
+_gtk_source_buffer_internal_emit_search_start (GtkSourceBufferInternal *buffer_internal,
+                                              GtkSourceSearchContext  *search_context)
+{
+       g_return_if_fail (GTK_SOURCE_IS_BUFFER_INTERNAL (buffer_internal));
+       g_return_if_fail (GTK_SOURCE_IS_SEARCH_CONTEXT (search_context));
+
+       g_signal_emit (buffer_internal,
+                      signals[SIGNAL_SEARCH_START],
+                      0,
+                      search_context);
+}
diff --git a/gtksourceview/gtksourcebufferinternal.h b/gtksourceview/gtksourcebufferinternal.h
new file mode 100644
index 0000000..e6b0dbc
--- /dev/null
+++ b/gtksourceview/gtksourcebufferinternal.h
@@ -0,0 +1,48 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; coding: utf-8 -*- */
+/* gtksourcebufferinternal.h
+ * This file is part of GtkSourceView
+ *
+ * Copyright (C) 2016 - Sébastien Wilmet <swilmet gnome org>
+ *
+ * GtkSourceView is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * GtkSourceView is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef GTK_SOURCE_BUFFER_INTERNAL_H
+#define GTK_SOURCE_BUFFER_INTERNAL_H
+
+#include <glib-object.h>
+#include "gtksourcetypes.h"
+#include "gtksourcetypes-private.h"
+
+G_BEGIN_DECLS
+
+#define GTK_SOURCE_TYPE_BUFFER_INTERNAL (_gtk_source_buffer_internal_get_type ())
+
+G_GNUC_INTERNAL
+G_DECLARE_FINAL_TYPE (GtkSourceBufferInternal, _gtk_source_buffer_internal,
+                     GTK_SOURCE, BUFFER_INTERNAL,
+                     GObject)
+
+G_GNUC_INTERNAL
+GtkSourceBufferInternal *
+               _gtk_source_buffer_internal_get_from_buffer             (GtkSourceBuffer *buffer);
+
+G_GNUC_INTERNAL
+void           _gtk_source_buffer_internal_emit_search_start           (GtkSourceBufferInternal 
*buffer_internal,
+                                                                        GtkSourceSearchContext  
*search_context);
+
+G_END_DECLS
+
+#endif /* GTK_SOURCE_BUFFER_INTERNAL_H */
diff --git a/gtksourceview/gtksourcetypes-private.h b/gtksourceview/gtksourcetypes-private.h
index 857a4b2..f613625 100644
--- a/gtksourceview/gtksourcetypes-private.h
+++ b/gtksourceview/gtksourcetypes-private.h
@@ -27,6 +27,7 @@
 G_BEGIN_DECLS
 
 typedef struct _GtkSourceBufferInputStream     GtkSourceBufferInputStream;
+typedef struct _GtkSourceBufferInternal                GtkSourceBufferInternal;
 typedef struct _GtkSourceBufferOutputStream    GtkSourceBufferOutputStream;
 typedef struct _GtkSourceCompletionContainer   GtkSourceCompletionContainer;
 typedef struct _GtkSourceCompletionModel       GtkSourceCompletionModel;
diff --git a/po/POTFILES.in b/po/POTFILES.in
index ad05598..aa0c00e 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -4,6 +4,7 @@ data/styles/styles.pot
 gtksourceview/completion-providers/words/gtksourcecompletionwords.c
 gtksourceview/gtksourcebuffer.c
 gtksourceview/gtksourcebufferinputstream.c
+gtksourceview/gtksourcebufferinternal.c
 gtksourceview/gtksourcebufferoutputstream.c
 gtksourceview/gtksourcecompletion.c
 gtksourceview/gtksourcecompletioncontainer.c


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