[gtksourceview/wip/regex-search: 9/10] SearchContext: set_settings(): allow NULL to create a new settings



commit e46ef177e9946cbac798afe6b419027b69afa85d
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Thu Aug 1 16:23:23 2013 +0200

    SearchContext: set_settings(): allow NULL to create a new settings
    
    gtk_source_search_context_new() already allows a NULL SearchSettings.

 gtksourceview/gtksourcesearchcontext.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/gtksourceview/gtksourcesearchcontext.c b/gtksourceview/gtksourcesearchcontext.c
index 6ec7259..17104e4 100644
--- a/gtksourceview/gtksourcesearchcontext.c
+++ b/gtksourceview/gtksourcesearchcontext.c
@@ -2789,9 +2789,10 @@ gtk_source_search_context_get_settings (GtkSourceSearchContext *search)
 /**
  * gtk_source_search_context_set_settings:
  * @search: a #GtkSourceSearchContext.
- * @settings: the new #GtkSourceSearchSettings.
+ * @settings: (allow-none): the new #GtkSourceSearchSettings, or %NULL.
  *
- * Associate a #GtkSourceSearchSettings with the search context.
+ * Associate a #GtkSourceSearchSettings with the search context. If @settings is
+ * %NULL, a new one will be created.
  *
  * The search context holds a reference to @settings.
  *
@@ -2802,7 +2803,7 @@ gtk_source_search_context_set_settings (GtkSourceSearchContext  *search,
                                        GtkSourceSearchSettings *settings)
 {
        g_return_if_fail (GTK_SOURCE_IS_SEARCH_CONTEXT (search));
-       g_return_if_fail (GTK_SOURCE_IS_SEARCH_SETTINGS (settings));
+       g_return_if_fail (settings == NULL || GTK_SOURCE_IS_SEARCH_SETTINGS (settings));
 
        if (search->priv->settings != NULL)
        {
@@ -2813,9 +2814,16 @@ gtk_source_search_context_set_settings (GtkSourceSearchContext  *search,
                g_object_unref (search->priv->settings);
        }
 
-       search->priv->settings = g_object_ref (settings);
+       if (settings != NULL)
+       {
+               search->priv->settings = g_object_ref (settings);
+       }
+       else
+       {
+               search->priv->settings = gtk_source_search_settings_new ();
+       }
 
-       g_signal_connect_object (settings,
+       g_signal_connect_object (search->priv->settings,
                                 "notify",
                                 G_CALLBACK (settings_notify_cb),
                                 search,


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