[gtksourceview/wip/regex-search] SearchContext: add highlight property



commit 539deb9a023fe2bcf0ec6727433e5db6a0aa90b9
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Thu Aug 1 12:50:53 2013 +0200

    SearchContext: add highlight property

 docs/reference/gtksourceview-3.0-sections.txt |    2 +
 gtksourceview/gtksourcesearchcontext.c        |   69 ++++++++++++++++++++++++-
 gtksourceview/gtksourcesearchcontext.h        |    5 ++
 3 files changed, 74 insertions(+), 2 deletions(-)
---
diff --git a/docs/reference/gtksourceview-3.0-sections.txt b/docs/reference/gtksourceview-3.0-sections.txt
index f7a9f97..cde933e 100644
--- a/docs/reference/gtksourceview-3.0-sections.txt
+++ b/docs/reference/gtksourceview-3.0-sections.txt
@@ -477,6 +477,8 @@ gtk_source_search_context_new
 gtk_source_search_context_get_buffer
 gtk_source_search_context_get_settings
 gtk_source_search_context_set_settings
+gtk_source_search_context_get_highlight
+gtk_source_search_context_set_highlight
 gtk_source_search_context_get_occurrences_count
 gtk_source_search_context_get_occurrence_position
 gtk_source_search_context_forward
diff --git a/gtksourceview/gtksourcesearchcontext.c b/gtksourceview/gtksourcesearchcontext.c
index c0e68b3..b715548 100644
--- a/gtksourceview/gtksourcesearchcontext.c
+++ b/gtksourceview/gtksourcesearchcontext.c
@@ -222,6 +222,7 @@ enum
        PROP_0,
        PROP_BUFFER,
        PROP_SETTINGS,
+       PROP_HIGHLIGHT,
        PROP_OCCURRENCES_COUNT,
        PROP_REGEX_ERROR
 };
@@ -260,6 +261,8 @@ struct _GtkSourceSearchContextPrivate
 
        gint occurrences_count;
        gulong idle_scan_id;
+
+       guint highlight : 1;
 };
 
 /* Data for the asynchronous forward and backward search tasks. */
@@ -307,13 +310,11 @@ sync_found_tag (GtkSourceSearchContext *search)
                return;
        }
 
-       /*
        if (!search->priv->highlight)
        {
                _gtk_source_style_apply (NULL, search->priv->found_tag);
                return;
        }
-       */
 
        style_scheme = gtk_source_buffer_get_style_scheme (GTK_SOURCE_BUFFER (search->priv->buffer));
 
@@ -2565,6 +2566,10 @@ gtk_source_search_context_get_property (GObject    *object,
                        g_value_set_object (value, get_settings (search));
                        break;
 
+               case PROP_HIGHLIGHT:
+                       g_value_set_boolean (value, search->priv->highlight);
+                       break;
+
                case PROP_OCCURRENCES_COUNT:
                        g_value_set_int (value, gtk_source_search_context_get_occurrences_count (search));
                        break;
@@ -2601,6 +2606,10 @@ gtk_source_search_context_set_property (GObject      *object,
                        gtk_source_search_context_set_settings (search, g_value_get_object (value));
                        break;
 
+               case PROP_HIGHLIGHT:
+                       gtk_source_search_context_set_highlight (search, g_value_get_boolean (value));
+                       break;
+
                default:
                        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
                        break;
@@ -2648,6 +2657,21 @@ gtk_source_search_context_class_init (GtkSourceSearchContextClass *klass)
                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 
        /**
+        * GtkSourceSearchContext:highlight:
+        *
+        * Highlight the search occurrences.
+        *
+        * Since: 3.10
+        */
+       g_object_class_install_property (object_class,
+                                        PROP_HIGHLIGHT,
+                                        g_param_spec_boolean ("highlight",
+                                                              _("Highlight"),
+                                                              _("Highlight search occurrences"),
+                                                              TRUE,
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+       /**
         * GtkSourceSearchContext:occurrences-count:
         *
         * The total number of search occurrences. If the search is disabled,
@@ -2789,6 +2813,47 @@ gtk_source_search_context_set_settings (GtkSourceSearchContext  *search,
 }
 
 /**
+ * gtk_source_search_context_get_highlight:
+ * @search: a #GtkSourceSearchContext.
+ *
+ * Returns: whether to highlight the search occurrences.
+ * Since: 3.10
+ */
+gboolean
+gtk_source_search_context_get_highlight (GtkSourceSearchContext *search)
+{
+       g_return_val_if_fail (GTK_SOURCE_IS_SEARCH_CONTEXT (search), FALSE);
+
+       return search->priv->highlight;
+}
+
+/**
+ * gtk_source_search_context_set_highlight:
+ * @search: a #GtkSourceSearchContext.
+ * @highlight: the setting.
+ *
+ * Enables or disables the search occurrences highlighting.
+ *
+ * Since: 3.10
+ */
+void
+gtk_source_search_context_set_highlight (GtkSourceSearchContext *search,
+                                        gboolean                highlight)
+{
+       g_return_if_fail (GTK_SOURCE_IS_SEARCH_CONTEXT (search));
+
+       highlight = highlight != FALSE;
+
+       if (search->priv->highlight != highlight)
+       {
+               search->priv->highlight = highlight;
+               sync_found_tag (search);
+
+               g_object_notify (G_OBJECT (search), "highlight");
+       }
+}
+
+/**
  * gtk_source_search_context_get_regex_error:
  * @search: a #GtkSourceSearchContext.
  *
diff --git a/gtksourceview/gtksourcesearchcontext.h b/gtksourceview/gtksourcesearchcontext.h
index 6ad38ae..35989ad 100644
--- a/gtksourceview/gtksourcesearchcontext.h
+++ b/gtksourceview/gtksourcesearchcontext.h
@@ -61,6 +61,11 @@ GtkSourceSearchSettings      *gtk_source_search_context_get_settings                 
(GtkSourceSear
 void                    gtk_source_search_context_set_settings                 (GtkSourceSearchContext  
*search,
                                                                                 GtkSourceSearchSettings 
*settings);
 
+gboolean                gtk_source_search_context_get_highlight                (GtkSourceSearchContext  
*search);
+
+void                    gtk_source_search_context_set_highlight                (GtkSourceSearchContext  
*search,
+                                                                                gboolean                 
highlight);
+
 GError                 *gtk_source_search_context_get_regex_error              (GtkSourceSearchContext  
*search);
 
 gint                    gtk_source_search_context_get_occurrences_count        (GtkSourceSearchContext  
*search);


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