[gtksourceview] Add an empty GtkSourceTag class
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] Add an empty GtkSourceTag class
- Date: Sun, 11 Oct 2015 09:52:57 +0000 (UTC)
commit 3df7913722497bfeed4ab8bbc3a39d89c8523e4b
Author: Sébastien Wilmet <sebastien wilmet uclouvain be>
Date: Tue Sep 8 13:29:48 2015 +0200
Add an empty GtkSourceTag class
GtkSourceTag is a subclass of GtkTextTag. It'll be useful to add
properties to it.
gtk_source_buffer_create_tag() is also implemented, for convenience and
consistency with how GtkTextTags are usually created.
https://bugzilla.gnome.org/show_bug.cgi?id=744179
docs/reference/gtksourceview-3.0-sections.txt | 11 ++++
docs/reference/gtksourceview-docs.xml | 1 +
gtksourceview/Makefile.am | 2 +
gtksourceview/gtksource.h | 1 +
gtksourceview/gtksourcebuffer.c | 60 ++++++++++++++++++++
gtksourceview/gtksourcebuffer.h | 5 ++
gtksourceview/gtksourcetag.c | 73 +++++++++++++++++++++++++
gtksourceview/gtksourcetag.h | 48 ++++++++++++++++
gtksourceview/gtksourcetypes.h | 1 +
po/POTFILES.in | 1 +
10 files changed, 203 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gtksourceview-3.0-sections.txt b/docs/reference/gtksourceview-3.0-sections.txt
index 5d88b23..94d8255 100644
--- a/docs/reference/gtksourceview-3.0-sections.txt
+++ b/docs/reference/gtksourceview-3.0-sections.txt
@@ -9,6 +9,7 @@ GtkSourceChangeCaseType
GtkSourceSortFlags
gtk_source_buffer_new
gtk_source_buffer_new_with_language
+gtk_source_buffer_create_tag
<SUBSECTION Syntax Highlighting>
gtk_source_buffer_set_highlight_syntax
gtk_source_buffer_get_highlight_syntax
@@ -798,6 +799,16 @@ GtkSourceStyleSchemeManagerPrivate
</SECTION>
<SECTION>
+<FILE>tag</FILE>
+<TITLE>GtkSourceTag</TITLE>
+GtkSourceTag
+gtk_source_tag_new
+<SUBSECTION Standard>
+GTK_SOURCE_TYPE_TAG
+GtkSourceTagClass
+</SECTION>
+
+<SECTION>
<FILE>undomanager</FILE>
<TITLE>GtkSourceUndoManager</TITLE>
GtkSourceUndoManager
diff --git a/docs/reference/gtksourceview-docs.xml b/docs/reference/gtksourceview-docs.xml
index 054e932..8afc0a5 100644
--- a/docs/reference/gtksourceview-docs.xml
+++ b/docs/reference/gtksourceview-docs.xml
@@ -76,6 +76,7 @@
<chapter>
<title>Others</title>
<xi:include href="xml/map.xml"/>
+ <xi:include href="xml/tag.xml"/>
<xi:include href="xml/undomanager.xml"/>
<xi:include href="xml/utils.xml"/>
</chapter>
diff --git a/gtksourceview/Makefile.am b/gtksourceview/Makefile.am
index 4f06408..bd2fffb 100644
--- a/gtksourceview/Makefile.am
+++ b/gtksourceview/Makefile.am
@@ -51,6 +51,7 @@ libgtksourceview_public_headers = \
gtksourcestyleschemechooserbutton.h \
gtksourcestyleschemechooserwidget.h \
gtksourcestyleschememanager.h \
+ gtksourcetag.h \
gtksourcetypes.h \
gtksourceundomanager.h \
gtksourceutils.h \
@@ -86,6 +87,7 @@ libgtksourceview_public_c_files = \
gtksourcestyleschemechooserbutton.c \
gtksourcestyleschemechooserwidget.c \
gtksourcestyleschememanager.c \
+ gtksourcetag.c \
gtksourceundomanager.c \
gtksourceutils.c \
gtksourceview.c
diff --git a/gtksourceview/gtksource.h b/gtksourceview/gtksource.h
index 51975ad..f832274 100644
--- a/gtksourceview/gtksource.h
+++ b/gtksourceview/gtksource.h
@@ -50,6 +50,7 @@
#include <gtksourceview/gtksourcestyleschemechooserbutton.h>
#include <gtksourceview/gtksourcestyleschemechooserwidget.h>
#include <gtksourceview/gtksourcestyleschememanager.h>
+#include <gtksourceview/gtksourcetag.h>
#include <gtksourceview/gtksourceundomanager.h>
#include <gtksourceview/gtksourceutils.h>
#include <gtksourceview/gtksourceview.h>
diff --git a/gtksourceview/gtksourcebuffer.c b/gtksourceview/gtksourcebuffer.c
index 2a5cc49..bebd916 100644
--- a/gtksourceview/gtksourcebuffer.c
+++ b/gtksourceview/gtksourcebuffer.c
@@ -44,6 +44,7 @@
#include "gtksourcemark.h"
#include "gtksourcemarkssequence.h"
#include "gtksourcesearchcontext.h"
+#include "gtksourcetag.h"
#include "gtksourceview-i18n.h"
#include "gtksourceview-typebuiltins.h"
@@ -3094,3 +3095,62 @@ gtk_source_buffer_get_implicit_trailing_newline (GtkSourceBuffer *buffer)
return buffer->priv->implicit_trailing_newline;
}
+
+/**
+ * gtk_source_buffer_create_tag:
+ * @buffer: a #GtkSourceBuffer
+ * @tag_name: (nullable): name of the new tag, or %NULL
+ * @first_property_name: (nullable): name of first property to set, or %NULL
+ * @...: %NULL-terminated list of property names and values
+ *
+ * In short, this is the same function as gtk_text_buffer_create_tag(), but
+ * instead of creating a #GtkTextTag, this function creates a #GtkSourceTag.
+ *
+ * This function creates a #GtkSourceTag and adds it to the tag table for
+ * @buffer. Equivalent to calling gtk_text_tag_new() and then adding the tag to
+ * the buffer’s tag table. The returned tag is owned by the buffer’s tag table,
+ * so the ref count will be equal to one.
+ *
+ * If @tag_name is %NULL, the tag is anonymous.
+ *
+ * If @tag_name is non-%NULL, a tag called @tag_name must not already
+ * exist in the tag table for this buffer.
+ *
+ * The @first_property_name argument and subsequent arguments are a list
+ * of properties to set on the tag, as with g_object_set().
+ *
+ * Returns: (transfer none): a new #GtkSourceTag.
+ * Since: 3.20
+ */
+GtkTextTag *
+gtk_source_buffer_create_tag (GtkSourceBuffer *buffer,
+ const gchar *tag_name,
+ const gchar *first_property_name,
+ ...)
+{
+ GtkTextTag *tag;
+ GtkTextTagTable *table;
+ va_list list;
+
+ g_return_val_if_fail (GTK_SOURCE_IS_BUFFER (buffer), NULL);
+
+ tag = gtk_source_tag_new (tag_name);
+
+ table = gtk_text_buffer_get_tag_table (GTK_TEXT_BUFFER (buffer));
+ if (!gtk_text_tag_table_add (table, tag))
+ {
+ g_object_unref (tag);
+ return NULL;
+ }
+
+ if (first_property_name != NULL)
+ {
+ va_start (list, first_property_name);
+ g_object_set_valist (G_OBJECT (tag), first_property_name, list);
+ va_end (list);
+ }
+
+ g_object_unref (tag);
+
+ return tag;
+}
diff --git a/gtksourceview/gtksourcebuffer.h b/gtksourceview/gtksourcebuffer.h
index 373b304..aaf1e3d 100644
--- a/gtksourceview/gtksourcebuffer.h
+++ b/gtksourceview/gtksourcebuffer.h
@@ -231,6 +231,11 @@ void gtk_source_buffer_set_implicit_trailing_newline
(GtkSourceBuffer
gboolean gtk_source_buffer_get_implicit_trailing_newline (GtkSourceBuffer
*buffer);
+GtkTextTag *gtk_source_buffer_create_tag (GtkSourceBuffer
*buffer,
+ const gchar
*tag_name,
+ const gchar
*first_property_name,
+ ...);
+
G_END_DECLS
#endif /* __GTK_SOURCE_BUFFER_H__ */
diff --git a/gtksourceview/gtksourcetag.c b/gtksourceview/gtksourcetag.c
new file mode 100644
index 0000000..d09bb9e
--- /dev/null
+++ b/gtksourceview/gtksourcetag.c
@@ -0,0 +1,73 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; coding: utf-8 -*- */
+/* gtksourcetag.c
+ * This file is part of GtkSourceView
+ *
+ * Copyright (C) 2015 - Université Catholique de Louvain
+ *
+ * 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
+ *
+ * Author: Sébastien Wilmet
+ */
+
+#include "gtksourcetag.h"
+
+/**
+ * SECTION:tag
+ * @Short_description: A tag that can be applied to text in a GtkSourceBuffer
+ * @Title: GtkSourceTag
+ * @See_also: #GtkSourceBuffer
+ *
+ * #GtkSourceTag is a subclass of #GtkTextTag that adds properties useful for
+ * the GtkSourceView library.
+ */
+
+typedef struct _GtkSourceTagPrivate GtkSourceTagPrivate;
+
+struct _GtkSourceTagPrivate
+{
+ gint something;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (GtkSourceTag, gtk_source_tag, GTK_TYPE_TEXT_TAG)
+
+static void
+gtk_source_tag_class_init (GtkSourceTagClass *klass)
+{
+ /*GObjectClass *object_class = G_OBJECT_CLASS (klass);*/
+}
+
+static void
+gtk_source_tag_init (GtkSourceTag *tag)
+{
+}
+
+/**
+ * gtk_source_tag_new:
+ * @name: (nullable): tag name, or %NULL.
+ *
+ * Creates a #GtkSourceTag. Configure the tag using object arguments,
+ * i.e. using g_object_set().
+ *
+ * For usual cases, gtk_source_buffer_create_tag() is more convenient to use.
+ *
+ * Returns: a new #GtkSourceTag.
+ */
+GtkTextTag *
+gtk_source_tag_new (const gchar *name)
+{
+ return g_object_new (GTK_SOURCE_TYPE_TAG,
+ "name", name,
+ NULL);
+}
diff --git a/gtksourceview/gtksourcetag.h b/gtksourceview/gtksourcetag.h
new file mode 100644
index 0000000..f03a84f
--- /dev/null
+++ b/gtksourceview/gtksourcetag.h
@@ -0,0 +1,48 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; coding: utf-8 -*- */
+/* gtksourcetag.h
+ * This file is part of GtkSourceView
+ *
+ * Copyright (C) 2015 - Université Catholique de Louvain
+ *
+ * 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
+ *
+ * Author: Sébastien Wilmet
+ */
+
+#ifndef __GTK_SOURCE_TAG_H__
+#define __GTK_SOURCE_TAG_H__
+
+#include <gtk/gtk.h>
+#include <gtksourceview/gtksourcetypes.h>
+
+G_BEGIN_DECLS
+
+#define GTK_SOURCE_TYPE_TAG (gtk_source_tag_get_type ())
+G_DECLARE_DERIVABLE_TYPE (GtkSourceTag, gtk_source_tag,
+ GTK_SOURCE, TAG,
+ GtkTextTag)
+
+struct _GtkSourceTagClass
+{
+ GtkTextTagClass parent_class;
+
+ gpointer padding[10];
+};
+
+GtkTextTag * gtk_source_tag_new (const gchar *name);
+
+G_END_DECLS
+
+#endif /* __GTK_SOURCE_TAG_H__ */
diff --git a/gtksourceview/gtksourcetypes.h b/gtksourceview/gtksourcetypes.h
index 6d60a65..a851fe8 100644
--- a/gtksourceview/gtksourcetypes.h
+++ b/gtksourceview/gtksourcetypes.h
@@ -51,6 +51,7 @@ typedef struct _GtkSourceSearchSettings GtkSourceSearchSettings;
typedef struct _GtkSourceStyle GtkSourceStyle;
typedef struct _GtkSourceStyleScheme GtkSourceStyleScheme;
typedef struct _GtkSourceStyleSchemeManager GtkSourceStyleSchemeManager;
+typedef struct _GtkSourceTag GtkSourceTag;
typedef struct _GtkSourceUndoManager GtkSourceUndoManager;
typedef struct _GtkSourceView GtkSourceView;
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 37edc97..418f661 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -161,6 +161,7 @@ gtksourceview/gtksourcestyle.c
gtksourceview/gtksourcestylescheme.c
gtksourceview/gtksourcestyleschemechooserbutton.c
gtksourceview/gtksourcestyleschememanager.c
+gtksourceview/gtksourcetag.c
gtksourceview/gtksourceundomanagerdefault.c
gtksourceview/gtksourceutils.c
gtksourceview/gtksourceview.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]