[gtksourceview/wip/search: 13/36] Split GtkSourceSearchFlags into three bool properties



commit 41a20a90d7b961ee7e1a34d5bbaaf720eb4853f4
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sun Jun 30 16:12:46 2013 +0200

    Split GtkSourceSearchFlags into three bool properties

 docs/reference/gtksourceview-3.0-sections.txt |   15 ++-
 gtksourceview/gtksourcebuffer.c               |  214 ++++++++++++++++++-------
 gtksourceview/gtksourcebuffer.h               |   46 ++----
 gtksourceview/gtksourcesearch.c               |  108 +++++++------
 gtksourceview/gtksourcesearch.h               |   28 +++-
 tests/test-search-ui.c                        |   81 ++--------
 6 files changed, 276 insertions(+), 216 deletions(-)
---
diff --git a/docs/reference/gtksourceview-3.0-sections.txt b/docs/reference/gtksourceview-3.0-sections.txt
index 47fc1d1..2d1a80e 100644
--- a/docs/reference/gtksourceview-3.0-sections.txt
+++ b/docs/reference/gtksourceview-3.0-sections.txt
@@ -5,7 +5,6 @@
 <TITLE>GtkSourceBuffer</TITLE>
 GtkSourceBuffer
 GtkSourceBracketMatchType
-GtkSourceSearchFlags
 gtk_source_buffer_new
 gtk_source_buffer_new_with_language
 gtk_source_buffer_set_highlight_syntax
@@ -39,9 +38,19 @@ gtk_source_buffer_get_undo_manager
 gtk_source_buffer_set_undo_manager
 gtk_source_buffer_set_search_text
 gtk_source_buffer_get_search_text
-gtk_source_buffer_set_search_flags
-gtk_source_buffer_get_search_flags
+gtk_source_buffer_set_case_sensitive_search
+gtk_source_buffer_get_case_sensitive_search
+gtk_source_buffer_set_search_at_word_boundaries
+gtk_source_buffer_get_search_at_word_boundaries
+gtk_source_buffer_set_search_wrap_around
+gtk_source_buffer_get_search_wrap_around
 gtk_source_buffer_get_search_occurrences_count
+gtk_source_buffer_forward_search
+gtk_source_buffer_forward_search_async
+gtk_source_buffer_forward_search_finish
+gtk_source_buffer_backward_search
+gtk_source_buffer_backward_search_async
+gtk_source_buffer_backward_search_finish
 <SUBSECTION Standard>
 GtkSourceBufferClass
 GTK_SOURCE_IS_BUFFER
diff --git a/gtksourceview/gtksourcebuffer.c b/gtksourceview/gtksourcebuffer.c
index 462aff6..7e951d9 100644
--- a/gtksourceview/gtksourcebuffer.c
+++ b/gtksourceview/gtksourcebuffer.c
@@ -30,10 +30,10 @@
 #include <string.h>
 #include <gtk/gtk.h>
 
+#include "gtksourcebuffer.h"
 #include "gtksourceview-i18n.h"
 #include "gtksourcelanguage.h"
 #include "gtksourcelanguage-private.h"
-#include "gtksourcebuffer.h"
 #include "gtksourceundomanager.h"
 #include "gtksourceview-marshal.h"
 #include "gtksourcestylescheme.h"
@@ -123,8 +123,10 @@ enum {
        PROP_STYLE_SCHEME,
        PROP_UNDO_MANAGER,
        PROP_SEARCH_TEXT,
-       PROP_SEARCH_FLAGS,
-       PROP_SEARCH_OCCURRENCES_COUNT
+       PROP_SEARCH_OCCURRENCES_COUNT,
+       PROP_CASE_SENSITIVE_SEARCH,
+       PROP_SEARCH_AT_WORD_BOUNDARIES,
+       PROP_SEARCH_WRAP_AROUND
 };
 
 struct _GtkSourceBufferPrivate
@@ -357,22 +359,6 @@ gtk_source_buffer_class_init (GtkSourceBufferClass *klass)
                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 
        /**
-        * GtkSourceBuffer:search-flags:
-        *
-        * Flags affecting how the search is done.
-        *
-        * Since: 3.10
-        */
-       g_object_class_install_property (object_class,
-                                        PROP_SEARCH_FLAGS,
-                                        g_param_spec_flags ("search-flags",
-                                                            _("Search flags"),
-                                                            _("Search flags"),
-                                                            GTK_SOURCE_TYPE_SEARCH_FLAGS,
-                                                            0,
-                                                            G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       /**
         * GtkSourceBuffer:search-occurrences-count:
         *
         * The total number of search occurrences. If the search is disabled,
@@ -390,6 +376,54 @@ gtk_source_buffer_class_init (GtkSourceBufferClass *klass)
                                                            0,
                                                            G_PARAM_READABLE));
 
+       /**
+        * GtkSourceBuffer:case-sensitive-search:
+        *
+        * Whether the search is case sensitive.
+        *
+        * Since: 3.10
+        */
+       g_object_class_install_property (object_class,
+                                        PROP_CASE_SENSITIVE_SEARCH,
+                                        g_param_spec_boolean ("case-sensitive-search",
+                                                              _("Case sensitive search"),
+                                                              _("Case sensitive search"),
+                                                              FALSE,
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+       /**
+        * GtkSourceBuffer:search-at-word-boundaries:
+        *
+        * If %TRUE, a search match must start and end a word. The match can
+        * span multiple words.
+        *
+        * Since: 3.10
+        */
+       g_object_class_install_property (object_class,
+                                        PROP_SEARCH_AT_WORD_BOUNDARIES,
+                                        g_param_spec_boolean ("search-at-word-boundaries",
+                                                              _("Search at word boundaries"),
+                                                              _("Search at word boundaries"),
+                                                              FALSE,
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+       /**
+        * GtkSourceBuffer:search-wrap-around:
+        *
+        * For a forward search, continue at the beginning of the buffer if no
+        * search occurrence is found. For a backward search, continue at the
+        * end of the buffer.
+        *
+        * Since: 3.10
+        */
+       g_object_class_install_property (object_class,
+                                        PROP_SEARCH_WRAP_AROUND,
+                                        g_param_spec_boolean ("search-wrap-around",
+                                                              _("Search: wrap around"),
+                                                              _("Search: wrap around"),
+                                                              TRUE,
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
        param_types[0] = GTK_TYPE_TEXT_ITER | G_SIGNAL_TYPE_STATIC_SCOPE;
        param_types[1] = GTK_TYPE_TEXT_ITER | G_SIGNAL_TYPE_STATIC_SCOPE;
 
@@ -629,9 +663,19 @@ gtk_source_buffer_set_property (GObject      *object,
                                                     g_value_get_string (value));
                        break;
 
-               case PROP_SEARCH_FLAGS:
-                       _gtk_source_search_set_flags (source_buffer->priv->search,
-                                                     g_value_get_flags (value));
+               case PROP_CASE_SENSITIVE_SEARCH:
+                       _gtk_source_search_set_case_sensitive (source_buffer->priv->search,
+                                                              g_value_get_boolean (value));
+                       break;
+
+               case PROP_SEARCH_AT_WORD_BOUNDARIES:
+                       _gtk_source_search_set_at_word_boundaries (source_buffer->priv->search,
+                                                                  g_value_get_boolean (value));
+                       break;
+
+               case PROP_SEARCH_WRAP_AROUND:
+                       _gtk_source_search_set_wrap_around (source_buffer->priv->search,
+                                                           g_value_get_boolean (value));
                        break;
 
                default:
@@ -693,14 +737,22 @@ gtk_source_buffer_get_property (GObject    *object,
                        g_value_set_string (value, _gtk_source_search_get_text (source_buffer->priv->search));
                        break;
 
-               case PROP_SEARCH_FLAGS:
-                       g_value_set_flags (value, _gtk_source_search_get_flags (source_buffer->priv->search));
-                       break;
-
                case PROP_SEARCH_OCCURRENCES_COUNT:
                        g_value_set_uint (value, _gtk_source_search_get_occurrences_count 
(source_buffer->priv->search));
                        break;
 
+               case PROP_CASE_SENSITIVE_SEARCH:
+                       g_value_set_boolean (value, _gtk_source_search_get_case_sensitive 
(source_buffer->priv->search));
+                       break;
+
+               case PROP_SEARCH_AT_WORD_BOUNDARIES:
+                       g_value_set_boolean (value, _gtk_source_search_get_at_word_boundaries 
(source_buffer->priv->search));
+                       break;
+
+               case PROP_SEARCH_WRAP_AROUND:
+                       g_value_set_boolean (value, _gtk_source_search_get_wrap_around 
(source_buffer->priv->search));
+                       break;
+
                default:
                        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
                        break;
@@ -2621,63 +2673,101 @@ gtk_source_buffer_get_search_text (GtkSourceBuffer *buffer)
 }
 
 /**
- * gtk_source_buffer_set_search_flags:
+ * gtk_source_buffer_get_search_occurrences_count:
  * @buffer: a #GtkSourceBuffer.
- * @flags: flags affecting how the search is done.
  *
- * Modifies how the search is done.
+ * Gets the total number of search occurrences.
  *
+ * Returns: the total number of search occurrences.
  * Since: 3.10
  */
+guint
+gtk_source_buffer_get_search_occurrences_count (GtkSourceBuffer *buffer)
+{
+       g_return_val_if_fail (GTK_SOURCE_IS_BUFFER (buffer), 0);
+
+       return _gtk_source_search_get_occurrences_count (buffer->priv->search);
+}
+
 void
-gtk_source_buffer_set_search_flags (GtkSourceBuffer      *buffer,
-                                   GtkSourceSearchFlags  flags)
+gtk_source_buffer_set_case_sensitive_search (GtkSourceBuffer *buffer,
+                                            gboolean         case_sensitive)
 {
-       GtkSourceSearchFlags cur_flags;
+       gboolean cur_val;
 
        g_return_if_fail (GTK_SOURCE_IS_BUFFER (buffer));
 
-       cur_flags = _gtk_source_search_get_flags (buffer->priv->search);
+       cur_val = _gtk_source_search_get_case_sensitive (buffer->priv->search);
 
-       if (cur_flags != flags)
+       if (cur_val != case_sensitive)
        {
-               _gtk_source_search_set_flags (buffer->priv->search, flags);
-               g_object_notify (G_OBJECT (buffer), "search-flags");
+               _gtk_source_search_set_case_sensitive (buffer->priv->search,
+                                                      case_sensitive);
+
+               g_object_notify (G_OBJECT (buffer), "case-sensitive-search");
        }
 }
 
-/**
- * gtk_source_buffer_get_search_flags:
- * @buffer: a #GtkSourceBuffer.
- *
- * Gets the search flags.
- *
- * Returns: the flags affecting how the search is done.
- * Since: 3.10
- */
-GtkSourceSearchFlags
-gtk_source_buffer_get_search_flags (GtkSourceBuffer *buffer)
+gboolean
+gtk_source_buffer_get_case_sensitive_search (GtkSourceBuffer *buffer)
 {
-       g_return_val_if_fail (GTK_SOURCE_IS_BUFFER (buffer), 0);
+       g_return_val_if_fail (GTK_SOURCE_IS_BUFFER (buffer), FALSE);
 
-       return _gtk_source_search_get_flags (buffer->priv->search);
+       return _gtk_source_search_get_case_sensitive (buffer->priv->search);
 }
 
-/**
- * gtk_source_buffer_get_search_occurrences_count:
- * @buffer: a #GtkSourceBuffer.
- *
- * Gets the total number of search occurrences.
- *
- * Returns: the total number of search occurrences.
- * Since: 3.10
- */
-guint
-gtk_source_buffer_get_search_occurrences_count (GtkSourceBuffer *buffer)
+void
+gtk_source_buffer_set_search_at_word_boundaries (GtkSourceBuffer *buffer,
+                                                gboolean         at_word_boundaries)
 {
-       g_return_val_if_fail (GTK_SOURCE_IS_BUFFER (buffer), 0);
+       gboolean cur_val;
 
-       return _gtk_source_search_get_occurrences_count (buffer->priv->search);
+       g_return_if_fail (GTK_SOURCE_IS_BUFFER (buffer));
+
+       cur_val = _gtk_source_search_get_at_word_boundaries (buffer->priv->search);
+
+       if (cur_val != at_word_boundaries)
+       {
+               _gtk_source_search_set_at_word_boundaries (buffer->priv->search,
+                                                          at_word_boundaries);
+
+               g_object_notify (G_OBJECT (buffer), "search-at-word-boundaries");
+       }
+}
+
+gboolean
+gtk_source_buffer_get_search_at_word_boundaries (GtkSourceBuffer *buffer)
+{
+       g_return_val_if_fail (GTK_SOURCE_IS_BUFFER (buffer), FALSE);
+
+       return _gtk_source_search_get_at_word_boundaries (buffer->priv->search);
+}
+
+void
+gtk_source_buffer_set_search_wrap_around (GtkSourceBuffer *buffer,
+                                         gboolean         wrap_around)
+{
+       gboolean cur_val;
+
+       g_return_if_fail (GTK_SOURCE_IS_BUFFER (buffer));
+
+       cur_val = _gtk_source_search_get_wrap_around (buffer->priv->search);
+
+       if (cur_val != wrap_around)
+       {
+               _gtk_source_search_set_wrap_around (buffer->priv->search,
+                                                   wrap_around);
+
+               g_object_notify (G_OBJECT (buffer), "search-wrap-around");
+       }
+}
+
+gboolean
+gtk_source_buffer_get_search_wrap_around (GtkSourceBuffer *buffer)
+{
+       g_return_val_if_fail (GTK_SOURCE_IS_BUFFER (buffer), FALSE);
+
+       return _gtk_source_search_get_wrap_around (buffer->priv->search);
 }
 
 /**
diff --git a/gtksourceview/gtksourcebuffer.h b/gtksourceview/gtksourcebuffer.h
index 41b2579..1589d38 100644
--- a/gtksourceview/gtksourcebuffer.h
+++ b/gtksourceview/gtksourcebuffer.h
@@ -56,27 +56,6 @@ typedef enum
        GTK_SOURCE_BRACKET_MATCH_FOUND
 } GtkSourceBracketMatchType;
 
-/**
- * GtkSourceSearchFlags:
- * @GTK_SOURCE_SEARCH_CASE_SENSITIVE: Case sensitive search.
- * @GTK_SOURCE_SEARCH_AT_WORD_BOUNDARIES: A search match must start and end a
- * word. The match can span multiple words.
- * @GTK_SOURCE_SEARCH_WRAP_AROUND: For a forward search, continue at the
- * beginning of the buffer if no search occurrence is found at the end of the
- * buffer. For a backward search, continue at the end of the buffer.
- *
- * Flags affecting how the search is done. Internally, GtkSourceView always
- * enables #GTK_TEXT_SEARCH_VISIBLE_ONLY and #GTK_TEXT_SEARCH_TEXT_ONLY.
- *
- * Since: 3.10
- */
-typedef enum
-{
-       GTK_SOURCE_SEARCH_CASE_SENSITIVE        = 1 << 0,
-       GTK_SOURCE_SEARCH_AT_WORD_BOUNDARIES    = 1 << 1,
-       GTK_SOURCE_SEARCH_WRAP_AROUND           = 1 << 2
-} GtkSourceSearchFlags;
-
 struct _GtkSourceBuffer
 {
        GtkTextBuffer parent_instance;
@@ -196,18 +175,27 @@ GtkSourceUndoManager      *gtk_source_buffer_get_undo_manager     (GtkSourceBuffer      
  *buffe
 void                    gtk_source_buffer_set_undo_manager     (GtkSourceBuffer        *buffer,
                                                                 GtkSourceUndoManager   *manager);
 
-void                    gtk_source_buffer_set_search_text      (GtkSourceBuffer        *buffer,
-                                                                const gchar            *text);
+void                    gtk_source_buffer_set_search_text                      (GtkSourceBuffer        
*buffer,
+                                                                                const gchar            
*text);
+
+const gchar            *gtk_source_buffer_get_search_text                      (GtkSourceBuffer        
*buffer);
+
+guint                   gtk_source_buffer_get_search_occurrences_count         (GtkSourceBuffer        
*buffer);
+
+void                    gtk_source_buffer_set_case_sensitive_search            (GtkSourceBuffer        
*buffer,
+                                                                                gboolean                
case_sensitive);
+
+gboolean                gtk_source_buffer_get_case_sensitive_search            (GtkSourceBuffer        
*buffer);
 
-const gchar            *gtk_source_buffer_get_search_text      (GtkSourceBuffer        *buffer);
+void                    gtk_source_buffer_set_search_at_word_boundaries        (GtkSourceBuffer        
*buffer,
+                                                                                gboolean                
at_word_boundaries);
 
-void                    gtk_source_buffer_set_search_flags     (GtkSourceBuffer        *buffer,
-                                                                GtkSourceSearchFlags    flags);
+gboolean                gtk_source_buffer_get_search_at_word_boundaries        (GtkSourceBuffer        
*buffer);
 
-GtkSourceSearchFlags    gtk_source_buffer_get_search_flags     (GtkSourceBuffer        *buffer);
+void                    gtk_source_buffer_set_search_wrap_around               (GtkSourceBuffer        
*buffer,
+                                                                                gboolean                
wrap_around);
 
-guint                   gtk_source_buffer_get_search_occurrences_count
-                                                               (GtkSourceBuffer        *buffer);
+gboolean                gtk_source_buffer_get_search_wrap_around               (GtkSourceBuffer        
*buffer);
 
 gboolean                gtk_source_buffer_forward_search       (GtkSourceBuffer        *buffer,
                                                                 const GtkTextIter      *iter,
diff --git a/gtksourceview/gtksourcesearch.c b/gtksourceview/gtksourcesearch.c
index 43b2aa7..6c2d683 100644
--- a/gtksourceview/gtksourcesearch.c
+++ b/gtksourceview/gtksourcesearch.c
@@ -1581,52 +1581,6 @@ _gtk_source_search_get_text (GtkSourceSearch *search)
 }
 
 void
-_gtk_source_search_set_flags (GtkSourceSearch      *search,
-                             GtkSourceSearchFlags  flags)
-{
-       g_return_if_fail (GTK_SOURCE_IS_SEARCH (search));
-
-       if (flags & GTK_SOURCE_SEARCH_CASE_SENSITIVE)
-       {
-               search->priv->flags &= ~GTK_TEXT_SEARCH_CASE_INSENSITIVE;
-       }
-       else
-       {
-               search->priv->flags |= GTK_TEXT_SEARCH_CASE_INSENSITIVE;
-       }
-
-       search->priv->at_word_boundaries = (flags & GTK_SOURCE_SEARCH_AT_WORD_BOUNDARIES) != 0;
-       search->priv->wrap_around = (flags & GTK_SOURCE_SEARCH_WRAP_AROUND) != 0;
-
-       update (search);
-}
-
-GtkSourceSearchFlags
-_gtk_source_search_get_flags (GtkSourceSearch *search)
-{
-       GtkSourceSearchFlags source_flags = 0;
-
-       g_return_val_if_fail (GTK_SOURCE_IS_SEARCH (search), 0);
-
-       if ((search->priv->flags & GTK_TEXT_SEARCH_CASE_INSENSITIVE) == 0)
-       {
-               source_flags |= GTK_SOURCE_SEARCH_CASE_SENSITIVE;
-       }
-
-       if (search->priv->at_word_boundaries)
-       {
-               source_flags |= GTK_SOURCE_SEARCH_AT_WORD_BOUNDARIES;
-       }
-
-       if (search->priv->wrap_around)
-       {
-               source_flags |= GTK_SOURCE_SEARCH_WRAP_AROUND;
-       }
-
-       return source_flags;
-}
-
-void
 _gtk_source_search_update_highlight (GtkSourceSearch   *search,
                                     const GtkTextIter *start,
                                     const GtkTextIter *end,
@@ -1688,6 +1642,68 @@ _gtk_source_search_get_occurrences_count (GtkSourceSearch *search)
        return search->priv->occurrences_count;
 }
 
+void
+_gtk_source_search_set_case_sensitive (GtkSourceSearch *search,
+                                      gboolean         case_sensitive)
+{
+       g_return_if_fail (GTK_SOURCE_IS_SEARCH (search));
+
+       if (case_sensitive)
+       {
+               search->priv->flags &= ~GTK_TEXT_SEARCH_CASE_INSENSITIVE;
+       }
+       else
+       {
+               search->priv->flags |= GTK_TEXT_SEARCH_CASE_INSENSITIVE;
+       }
+
+       update (search);
+}
+
+gboolean
+_gtk_source_search_get_case_sensitive (GtkSourceSearch *search)
+{
+       g_return_val_if_fail (GTK_SOURCE_IS_SEARCH (search), FALSE);
+
+       return (search->priv->flags & GTK_TEXT_SEARCH_CASE_INSENSITIVE) == 0;
+}
+
+void
+_gtk_source_search_set_at_word_boundaries (GtkSourceSearch *search,
+                                          gboolean         at_word_boundaries)
+{
+       g_return_if_fail (GTK_SOURCE_IS_SEARCH (search));
+
+       search->priv->at_word_boundaries = at_word_boundaries;
+       update (search);
+}
+
+gboolean
+_gtk_source_search_get_at_word_boundaries (GtkSourceSearch *search)
+{
+       g_return_val_if_fail (GTK_SOURCE_IS_SEARCH (search), FALSE);
+
+       return search->priv->at_word_boundaries;
+}
+
+void
+_gtk_source_search_set_wrap_around (GtkSourceSearch *search,
+                                   gboolean         wrap_around)
+{
+       g_return_if_fail (GTK_SOURCE_IS_SEARCH (search));
+
+       search->priv->wrap_around = wrap_around;
+       update (search);
+}
+
+gboolean
+_gtk_source_search_get_wrap_around (GtkSourceSearch *search)
+{
+       g_return_val_if_fail (GTK_SOURCE_IS_SEARCH (search), FALSE);
+
+       return search->priv->wrap_around;
+}
+
 gboolean
 _gtk_source_search_forward (GtkSourceSearch   *search,
                            const GtkTextIter *iter,
diff --git a/gtksourceview/gtksourcesearch.h b/gtksourceview/gtksourcesearch.h
index f55a3e6..c23bc68 100644
--- a/gtksourceview/gtksourcesearch.h
+++ b/gtksourceview/gtksourcesearch.h
@@ -65,13 +65,6 @@ G_GNUC_INTERNAL
 const gchar *          _gtk_source_search_get_text                     (GtkSourceSearch        *search);
 
 G_GNUC_INTERNAL
-void                   _gtk_source_search_set_flags                    (GtkSourceSearch        *search,
-                                                                        GtkSourceSearchFlags    flags);
-
-G_GNUC_INTERNAL
-GtkSourceSearchFlags   _gtk_source_search_get_flags                    (GtkSourceSearch        *search);
-
-G_GNUC_INTERNAL
 void                   _gtk_source_search_update_highlight             (GtkSourceSearch        *search,
                                                                         const GtkTextIter      *start,
                                                                         const GtkTextIter      *end,
@@ -81,6 +74,27 @@ G_GNUC_INTERNAL
 guint                  _gtk_source_search_get_occurrences_count        (GtkSourceSearch        *search);
 
 G_GNUC_INTERNAL
+void                   _gtk_source_search_set_case_sensitive           (GtkSourceSearch        *search,
+                                                                        gboolean                
case_sensitive);
+
+G_GNUC_INTERNAL
+gboolean               _gtk_source_search_get_case_sensitive           (GtkSourceSearch        *search);
+
+G_GNUC_INTERNAL
+void                   _gtk_source_search_set_at_word_boundaries       (GtkSourceSearch        *search,
+                                                                        gboolean                
at_word_boundaries);
+
+G_GNUC_INTERNAL
+gboolean               _gtk_source_search_get_at_word_boundaries       (GtkSourceSearch        *search);
+
+G_GNUC_INTERNAL
+void                   _gtk_source_search_set_wrap_around              (GtkSourceSearch        *search,
+                                                                        gboolean                wrap_around);
+
+G_GNUC_INTERNAL
+gboolean               _gtk_source_search_get_wrap_around              (GtkSourceSearch        *search);
+
+G_GNUC_INTERNAL
 gboolean               _gtk_source_search_forward                      (GtkSourceSearch        *search,
                                                                         const GtkTextIter      *iter,
                                                                         GtkTextIter            *match_start,
diff --git a/tests/test-search-ui.c b/tests/test-search-ui.c
index d005fc1..7c4de4f 100644
--- a/tests/test-search-ui.c
+++ b/tests/test-search-ui.c
@@ -74,60 +74,6 @@ on_search_entry_text_notify_cb (GtkEntry        *entry,
 }
 
 static void
-on_match_case_toggled_cb (GtkToggleButton *button,
-                         GtkSourceBuffer *buffer)
-{
-       GtkSourceSearchFlags flags = gtk_source_buffer_get_search_flags (buffer);
-
-       if (gtk_toggle_button_get_active (button))
-       {
-               flags |= GTK_SOURCE_SEARCH_CASE_SENSITIVE;
-       }
-       else
-       {
-               flags &= ~GTK_SOURCE_SEARCH_CASE_SENSITIVE;
-       }
-
-       gtk_source_buffer_set_search_flags (buffer, flags);
-}
-
-static void
-on_at_word_boundaries_toggled_cb (GtkToggleButton *button,
-                                 GtkSourceBuffer *buffer)
-{
-       GtkSourceSearchFlags flags = gtk_source_buffer_get_search_flags (buffer);
-
-       if (gtk_toggle_button_get_active (button))
-       {
-               flags |= GTK_SOURCE_SEARCH_AT_WORD_BOUNDARIES;
-       }
-       else
-       {
-               flags &= ~GTK_SOURCE_SEARCH_AT_WORD_BOUNDARIES;
-       }
-
-       gtk_source_buffer_set_search_flags (buffer, flags);
-}
-
-static void
-on_wrap_around_toggled_cb (GtkToggleButton *button,
-                          GtkSourceBuffer *buffer)
-{
-       GtkSourceSearchFlags flags = gtk_source_buffer_get_search_flags (buffer);
-
-       if (gtk_toggle_button_get_active (button))
-       {
-               flags |= GTK_SOURCE_SEARCH_WRAP_AROUND;
-       }
-       else
-       {
-               flags &= ~GTK_SOURCE_SEARCH_WRAP_AROUND;
-       }
-
-       gtk_source_buffer_set_search_flags (buffer, flags);
-}
-
-static void
 select_search_occurrence (GtkTextView       *view,
                          const GtkTextIter *match_start,
                          const GtkTextIter *match_end)
@@ -278,21 +224,6 @@ create_window (void)
                          G_CALLBACK (on_occurrences_count_notify_cb),
                          label_occurrences_count);
 
-       g_signal_connect (match_case,
-                         "toggled",
-                         G_CALLBACK (on_match_case_toggled_cb),
-                         source_buffer);
-
-       g_signal_connect (at_word_boundaries,
-                         "toggled",
-                         G_CALLBACK (on_at_word_boundaries_toggled_cb),
-                         source_buffer);
-
-       g_signal_connect (wrap_around,
-                         "toggled",
-                         G_CALLBACK (on_wrap_around_toggled_cb),
-                         source_buffer);
-
        g_signal_connect (button_previous,
                          "clicked",
                          G_CALLBACK (on_button_previous_clicked_cb),
@@ -303,6 +234,18 @@ create_window (void)
                          G_CALLBACK (on_button_next_clicked_cb),
                          source_view);
 
+       g_object_bind_property (match_case, "active",
+                               source_buffer, "case-sensitive-search",
+                               G_BINDING_SYNC_CREATE);
+
+       g_object_bind_property (at_word_boundaries, "active",
+                               source_buffer, "search-at-word-boundaries",
+                               G_BINDING_SYNC_CREATE);
+
+       g_object_bind_property (wrap_around, "active",
+                               source_buffer, "search-wrap-around",
+                               G_BINDING_SYNC_CREATE);
+
        g_object_unref (builder);
 }
 



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