[gtksourceview/wip/regex-search: 2/2] SearchContext: "buffer" and "settings" properties



commit bf4e8b3f02f7076053a1a97f7785a288161117bf
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Mon Jul 29 23:58:21 2013 +0200

    SearchContext: "buffer" and "settings" properties

 gtksourceview/gtksourcesearchcontext.c |   98 +++++++++++++------------
 gtksourceview/gtksourcesearchcontext.h |  125 ++++++++++++++++----------------
 2 files changed, 115 insertions(+), 108 deletions(-)
---
diff --git a/gtksourceview/gtksourcesearchcontext.c b/gtksourceview/gtksourcesearchcontext.c
index cc42659..1b6e053 100644
--- a/gtksourceview/gtksourcesearchcontext.c
+++ b/gtksourceview/gtksourcesearchcontext.c
@@ -20,6 +20,7 @@
  */
 
 #include "gtksourcesearchcontext.h"
+#include "gtksourcesearchsettings.h"
 #include "gtksourcebuffer.h"
 #include "gtksourcestylescheme.h"
 #include "gtksourcestyle-private.h"
@@ -186,6 +187,8 @@
 enum
 {
        PROP_0,
+       PROP_BUFFER,
+       PROP_SETTINGS,
        PROP_OCCURRENCES_COUNT,
        PROP_REGEX_ERROR
 };
@@ -2423,28 +2426,16 @@ gtk_source_search_context_get_property (GObject    *object,
                        g_value_set_boolean (value, gtk_source_search_context_get_highlight 
(source_buffer->priv->search));
                        break;
 
-               case PROP_SEARCH_TEXT:
-                       g_value_set_string (value, gtk_source_search_context_get_text 
(source_buffer->priv->search));
+               case PROP_BUFFER:
+                       g_value_set_object (value, search->priv->buffer);
                        break;
 
-               case PROP_OCCURRENCES_COUNT:
-                       g_value_set_int (value, gtk_source_search_context_get_occurrences_count 
(source_buffer->priv->search));
+               case PROP_SETTINGS:
+                       g_value_set_object (value, search->priv->settings);
                        break;
 
-               case PROP_CASE_SENSITIVE:
-                       g_value_set_boolean (value, gtk_source_search_context_get_case_sensitive 
(source_buffer->priv->search));
-                       break;
-
-               case PROP_AT_WORD_BOUNDARIES:
-                       g_value_set_boolean (value, gtk_source_search_context_get_at_word_boundaries 
(source_buffer->priv->search));
-                       break;
-
-               case PROP_WRAP_AROUND:
-                       g_value_set_boolean (value, gtk_source_search_context_get_wrap_around 
(source_buffer->priv->search));
-                       break;
-
-               case PROP_REGEX_ENABLED:
-                       g_value_set_boolean (value, gtk_source_search_context_get_regex_enabled 
(source_buffer->priv->search));
+               case PROP_OCCURRENCES_COUNT:
+                       g_value_set_int (value, gtk_source_search_context_get_occurrences_count 
(source_buffer->priv->search));
                        break;
 
                case PROP_REGEX_ERROR:
@@ -2476,29 +2467,14 @@ gtk_source_search_context_set_property (GObject      *object,
                                                                 g_value_get_boolean (value));
                        break;
 
-               case PROP_SEARCH_TEXT:
-                       gtk_source_search_context_set_text (source_buffer->priv->search,
-                                                           g_value_get_string (value));
-                       break;
-
-               case PROP_CASE_SENSITIVE:
-                       gtk_source_search_context_set_case_sensitive (source_buffer->priv->search,
-                                                                     g_value_get_boolean (value));
-                       break;
-
-               case PROP_AT_WORD_BOUNDARIES:
-                       gtk_source_search_context_set_at_word_boundaries (source_buffer->priv->search,
-                                                                         g_value_get_boolean (value));
-                       break;
-
-               case PROP_WRAP_AROUND:
-                       gtk_source_search_context_set_wrap_around (source_buffer->priv->search,
-                                                                  g_value_get_boolean (value));
+               case PROP_BUFFER:
+                       set_buffer (search, g_value_get_object (value));
                        break;
 
-               case PROP_REGEX_ENABLED:
-                       gtk_source_search_context_set_regex_enabled (source_buffer->priv->search,
-                                                                    g_value_get_boolean (value));
+               case PROP_SETTINGS:
+                       g_clear_object (&search->priv->settings);
+                       search->priv->settings = g_value_get_object (value);
+                       g_object_ref (search->priv->settings);
                        break;
 
                default:
@@ -2533,6 +2509,36 @@ gtk_source_search_context_class_init (GtkSourceSearchContextClass *klass)
                                                               G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 
        /**
+        * GtkSourceSearchContext:buffer:
+        *
+        * The #GtkSourceBuffer associated to the search context.
+        *
+        * Since: 3.10
+        */
+       g_object_class_install_property (object_class,
+                                        PROP_BUFFER,
+                                        g_param_spec_object ("buffer",
+                                                             _("Buffer"),
+                                                             _("The associated GtkSourceBuffer"),
+                                                             GTK_SOURCE_TYPE_BUFFER,
+                                                             G_PARAM_READABLE | G_PARAM_CONSTRUCT_ONLY));
+
+       /**
+        * GtkSourceSearchContext:settings:
+        *
+        * The #GtkSourceSearchSettings associated to the search context.
+        *
+        * Since: 3.10
+        */
+       g_object_class_install_property (object_class,
+                                        PROP_SETTINGS,
+                                        g_param_spec_object ("settings",
+                                                             _("Settings"),
+                                                             _("The associated GtkSourceSearchSettings"),
+                                                             GTK_SOURCE_TYPE_SEARCH_SETTINGS,
+                                                             G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+       /**
         * GtkSourceSearchContext:occurrences-count:
         *
         * The total number of search occurrences. If the search is disabled,
@@ -2576,16 +2582,16 @@ gtk_source_search_context_init (GtkSourceSearchContext *search)
 }
 
 GtkSourceSearchContext *
-gtk_source_search_context_new (GtkSourceBuffer *buffer)
+gtk_source_search_context_new (GtkSourceBuffer         *buffer,
+                              GtkSourceSearchSettings *settings)
 {
-       GtkSourceSearchContext *search;
-
        g_return_val_if_fail (GTK_SOURCE_IS_BUFFER (buffer), NULL);
+       g_return_val_if_fail (settings == NULL || GTK_SOURCE_IS_SEARCH_SETTINGS (settings), NULL);
 
-       search = g_object_new (GTK_SOURCE_TYPE_SEARCH_CONTEXT, NULL);
-       set_buffer (search, buffer);
-
-       return search;
+       return g_object_new (GTK_SOURCE_TYPE_SEARCH_CONTEXT,
+                            "buffer", buffer,
+                            "settings", settings,
+                            NULL);
 }
 
 static gint
diff --git a/gtksourceview/gtksourcesearchcontext.h b/gtksourceview/gtksourcesearchcontext.h
index ddb74c2..9267094 100644
--- a/gtksourceview/gtksourcesearchcontext.h
+++ b/gtksourceview/gtksourcesearchcontext.h
@@ -51,70 +51,71 @@ struct _GtkSourceSearchContextClass
 
 GType                  gtk_source_search_context_get_type                      (void) G_GNUC_CONST;
 
-GtkSourceSearchContext *gtk_source_search_context_new                          (GtkSourceBuffer        
*buffer);
-
-GError *               gtk_source_search_context_get_regex_error               (GtkSourceSearchContext 
*search);
-
-void                   gtk_source_search_context_set_highlight                 (GtkSourceSearchContext 
*search,
-                                                                                gboolean                
highlight);
-
-gboolean               gtk_source_search_context_get_highlight                 (GtkSourceSearchContext 
*search);
-
-gint                   gtk_source_search_context_get_occurrences_count         (GtkSourceSearchContext 
*search);
-
-gint                   gtk_source_search_context_get_occurrence_position       (GtkSourceSearchContext 
*search,
-                                                                                const GtkTextIter      
*match_start,
-                                                                                const GtkTextIter      
*match_end);
-
-gboolean               gtk_source_search_context_forward                       (GtkSourceSearchContext 
*search,
-                                                                                const GtkTextIter      *iter,
-                                                                                GtkTextIter            
*match_start,
-                                                                                GtkTextIter            
*match_end);
-
-void                   gtk_source_search_context_forward_async                 (GtkSourceSearchContext 
*search,
-                                                                                const GtkTextIter      *iter,
-                                                                                GCancellable           
*cancellable,
-                                                                                GAsyncReadyCallback     
callback,
-                                                                                gpointer                
user_data);
-
-gboolean               gtk_source_search_context_forward_finish                (GtkSourceSearchContext 
*search,
-                                                                                GAsyncResult           
*result,
-                                                                                GtkTextIter            
*match_start,
-                                                                                GtkTextIter            
*match_end,
-                                                                                GError                
**error);
-
-gboolean               gtk_source_search_context_backward                      (GtkSourceSearchContext 
*search,
-                                                                                const GtkTextIter      *iter,
-                                                                                GtkTextIter            
*match_start,
-                                                                                GtkTextIter            
*match_end);
-
-void                   gtk_source_search_context_backward_async                (GtkSourceSearchContext 
*search,
-                                                                                const GtkTextIter      *iter,
-                                                                                GCancellable           
*cancellable,
-                                                                                GAsyncReadyCallback     
callback,
-                                                                                gpointer                
user_data);
-
-gboolean               gtk_source_search_context_backward_finish               (GtkSourceSearchContext 
*search,
-                                                                                GAsyncResult           
*result,
-                                                                                GtkTextIter            
*match_start,
-                                                                                GtkTextIter            
*match_end,
-                                                                                GError                
**error);
-
-gboolean               gtk_source_search_context_replace                       (GtkSourceSearchContext 
*search,
-                                                                                const GtkTextIter      
*match_start,
-                                                                                const GtkTextIter      
*match_end,
-                                                                                const gchar            
*replace,
-                                                                                gint                    
replace_length);
-
-guint                  gtk_source_search_context_replace_all                   (GtkSourceSearchContext 
*search,
-                                                                                const gchar            
*replace,
-                                                                                gint                    
replace_length);
+GtkSourceSearchContext *gtk_source_search_context_new                          (GtkSourceBuffer         
*buffer,
+                                                                                GtkSourceSearchSettings 
*settings);
+
+GError *               gtk_source_search_context_get_regex_error               (GtkSourceSearchContext  
*search);
+
+void                   gtk_source_search_context_set_highlight                 (GtkSourceSearchContext  
*search,
+                                                                                gboolean                 
highlight);
+
+gboolean               gtk_source_search_context_get_highlight                 (GtkSourceSearchContext  
*search);
+
+gint                   gtk_source_search_context_get_occurrences_count         (GtkSourceSearchContext  
*search);
+
+gint                   gtk_source_search_context_get_occurrence_position       (GtkSourceSearchContext  
*search,
+                                                                                const GtkTextIter       
*match_start,
+                                                                                const GtkTextIter       
*match_end);
+
+gboolean               gtk_source_search_context_forward                       (GtkSourceSearchContext  
*search,
+                                                                                const GtkTextIter       
*iter,
+                                                                                GtkTextIter             
*match_start,
+                                                                                GtkTextIter             
*match_end);
+
+void                   gtk_source_search_context_forward_async                 (GtkSourceSearchContext  
*search,
+                                                                                const GtkTextIter       
*iter,
+                                                                                GCancellable            
*cancellable,
+                                                                                GAsyncReadyCallback      
callback,
+                                                                                gpointer                 
user_data);
+
+gboolean               gtk_source_search_context_forward_finish                (GtkSourceSearchContext  
*search,
+                                                                                GAsyncResult            
*result,
+                                                                                GtkTextIter             
*match_start,
+                                                                                GtkTextIter             
*match_end,
+                                                                                GError                 
**error);
+
+gboolean               gtk_source_search_context_backward                      (GtkSourceSearchContext  
*search,
+                                                                                const GtkTextIter       
*iter,
+                                                                                GtkTextIter             
*match_start,
+                                                                                GtkTextIter             
*match_end);
+
+void                   gtk_source_search_context_backward_async                (GtkSourceSearchContext  
*search,
+                                                                                const GtkTextIter       
*iter,
+                                                                                GCancellable            
*cancellable,
+                                                                                GAsyncReadyCallback      
callback,
+                                                                                gpointer                 
user_data);
+
+gboolean               gtk_source_search_context_backward_finish               (GtkSourceSearchContext  
*search,
+                                                                                GAsyncResult            
*result,
+                                                                                GtkTextIter             
*match_start,
+                                                                                GtkTextIter             
*match_end,
+                                                                                GError                 
**error);
+
+gboolean               gtk_source_search_context_replace                       (GtkSourceSearchContext  
*search,
+                                                                                const GtkTextIter       
*match_start,
+                                                                                const GtkTextIter       
*match_end,
+                                                                                const gchar             
*replace,
+                                                                                gint                     
replace_length);
+
+guint                  gtk_source_search_context_replace_all                   (GtkSourceSearchContext  
*search,
+                                                                                const gchar             
*replace,
+                                                                                gint                     
replace_length);
 
 G_GNUC_INTERNAL
-void                   _gtk_source_search_context_update_highlight             (GtkSourceSearchContext 
*search,
-                                                                                const GtkTextIter      
*start,
-                                                                                const GtkTextIter      *end,
-                                                                                gboolean                
synchronous);
+void                   _gtk_source_search_context_update_highlight             (GtkSourceSearchContext  
*search,
+                                                                                const GtkTextIter       
*start,
+                                                                                const GtkTextIter       *end,
+                                                                                gboolean                 
synchronous);
 
 G_END_DECLS
 


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