Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save chergert/6278446 to your computer and use it in GitHub Desktop.

Select an option

Save chergert/6278446 to your computer and use it in GitHub Desktop.
found tag for gtksourcesearchcontext
From d48632fcd7b541c181d6c9104b623d15cb021e53 Mon Sep 17 00:00:00 2001
From: Christian Hergert <[email protected]>
Date: Mon, 19 Aug 2013 21:47:23 -0700
Subject: [PATCH] searchcontext: add GtkSourceSearchContext:found-tag
property.
Includes a getter to fetch the read-only property.
This is useful for consumers that want to access the text-tag.
---
gtksourceview/gtksourcesearchcontext.c | 36 ++++++++++++++++++++++++++++++++
gtksourceview/gtksourcesearchcontext.h | 2 ++
2 files changed, 38 insertions(+)
diff --git a/gtksourceview/gtksourcesearchcontext.c b/gtksourceview/gtksourcesearchcontext.c
index deed7d8..8d3127b 100644
--- a/gtksourceview/gtksourcesearchcontext.c
+++ b/gtksourceview/gtksourcesearchcontext.c
@@ -270,6 +270,7 @@ enum
{
PROP_0,
PROP_BUFFER,
+ PROP_FOUND_TAG,
PROP_SETTINGS,
PROP_HIGHLIGHT,
PROP_OCCURRENCES_COUNT,
@@ -2664,6 +2665,10 @@ gtk_source_search_context_get_property (GObject *object,
g_value_set_object (value, search->priv->buffer);
break;
+ case PROP_FOUND_TAG:
+ g_value_set_object (value, search->priv->found_tag);
+ break;
+
case PROP_SETTINGS:
g_value_set_object (value, search->priv->settings);
break;
@@ -2748,6 +2753,22 @@ gtk_source_search_context_class_init (GtkSourceSearchContextClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
/**
+ * GtkSourceSearchContext:found-tag:
+ *
+ * The #GtkTextTag used for highlighting searches.
+ *
+ * Since: 3.10
+ */
+ g_object_class_install_property (object_class,
+ PROP_FOUND_TAG,
+ g_param_spec_object ("found-tag",
+ _("Found Tag"),
+ _("The tag used for highlighting."),
+ GTK_TYPE_TEXT_TAG,
+ G_PARAM_READABLE));
+
+
+ /**
* GtkSourceSearchContext:settings:
*
* The #GtkSourceSearchSettings associated to the search context.
@@ -2944,6 +2965,21 @@ gtk_source_search_context_set_settings (GtkSourceSearchContext *search,
}
/**
+ * gtk_source_search_context_get_found_tag:
+ * @search: a GtkSourceSearchContext.
+ *
+ * Gets the #GtkTextTag used for highlighting search matches.
+ *
+ * Returns: (transfer none): A #GtkTextTag.
+ */
+GtkTextTag *
+gtk_source_search_context_get_found_tag (GtkSourceSearchContext *search)
+{
+ g_return_val_if_fail (GTK_SOURCE_IS_SEARCH_CONTEXT (search), FALSE);
+ return search->priv->found_tag;
+}
+
+/**
* gtk_source_search_context_get_highlight:
* @search: a #GtkSourceSearchContext.
*
diff --git a/gtksourceview/gtksourcesearchcontext.h b/gtksourceview/gtksourcesearchcontext.h
index b57311d..224fcc2 100644
--- a/gtksourceview/gtksourcesearchcontext.h
+++ b/gtksourceview/gtksourcesearchcontext.h
@@ -78,6 +78,8 @@ GtkSourceSearchContext *gtk_source_search_context_new (GtkSourceBuffer *buff
GtkSourceBuffer *gtk_source_search_context_get_buffer (GtkSourceSearchContext *search);
+GtkTextTag *gtk_source_search_context_get_found_tag (GtkSourceSearchContext *search);
+
GtkSourceSearchSettings *gtk_source_search_context_get_settings (GtkSourceSearchContext *search);
void gtk_source_search_context_set_settings (GtkSourceSearchContext *search,
--
1.7.10.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment