[gtksourceview/wip/search-has-wrapped-around] SearchContext: add forward_finish2() and deprecate forward_finish()



commit e6eb00af4444d8b9e625cb5a0ba2fe0952933c41
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Jun 11 14:15:37 2016 +0200

    SearchContext: add forward_finish2() and deprecate forward_finish()
    
    https://bugzilla.gnome.org/show_bug.cgi?id=724420

 docs/reference/gtksourceview-3.0-sections.txt |    1 +
 gtksourceview/gtksourcesearchcontext.c        |   67 ++++++++++++++++++++++---
 gtksourceview/gtksourcesearchcontext.h        |   12 ++++-
 tests/test-search.c                           |   11 ++--
 testsuite/test-search-context.c               |   11 ++--
 5 files changed, 82 insertions(+), 20 deletions(-)
---
diff --git a/docs/reference/gtksourceview-3.0-sections.txt b/docs/reference/gtksourceview-3.0-sections.txt
index e406972..dac2912 100644
--- a/docs/reference/gtksourceview-3.0-sections.txt
+++ b/docs/reference/gtksourceview-3.0-sections.txt
@@ -664,6 +664,7 @@ gtk_source_search_context_forward
 gtk_source_search_context_forward2
 gtk_source_search_context_forward_async
 gtk_source_search_context_forward_finish
+gtk_source_search_context_forward_finish2
 gtk_source_search_context_backward
 gtk_source_search_context_backward2
 gtk_source_search_context_backward_async
diff --git a/gtksourceview/gtksourcesearchcontext.c b/gtksourceview/gtksourcesearchcontext.c
index d86b3b4..7db152b 100644
--- a/gtksourceview/gtksourcesearchcontext.c
+++ b/gtksourceview/gtksourcesearchcontext.c
@@ -2,7 +2,7 @@
 /* gtksourcesearchcontext.c
  * This file is part of GtkSourceView
  *
- * Copyright (C) 2013 - Sébastien Wilmet <swilmet gnome org>
+ * Copyright (C) 2013-2016 - Sébastien Wilmet <swilmet gnome org>
  *
  * GtkSourceView is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -3271,8 +3271,12 @@ gtk_source_search_context_forward2 (GtkSourceSearchContext *search,
  * @callback: a #GAsyncReadyCallback to call when the operation is finished.
  * @user_data: the data to pass to the @callback function.
  *
- * Asynchronous forward search. See the #GAsyncResult documentation to know
- * how to use this function.
+ * The asynchronous version of gtk_source_search_context_forward2().
+ *
+ * See the documentation of gtk_source_search_context_forward2() for more
+ * details.
+ *
+ * See the #GAsyncResult documentation to know how to use this function.
  *
  * If the operation is cancelled, the @callback will only be called if
  * @cancellable was not %NULL. gtk_source_search_context_forward_async() takes
@@ -3314,6 +3318,7 @@ gtk_source_search_context_forward_async (GtkSourceSearchContext *search,
  *
  * Returns: whether a match was found.
  * Since: 3.10
+ * Deprecated: 3.22: Use gtk_source_search_context_forward_finish2() instead.
  */
 gboolean
 gtk_source_search_context_forward_finish (GtkSourceSearchContext  *search,
@@ -3322,11 +3327,51 @@ gtk_source_search_context_forward_finish (GtkSourceSearchContext  *search,
                                          GtkTextIter             *match_end,
                                          GError                 **error)
 {
+       return gtk_source_search_context_forward_finish2 (search,
+                                                         result,
+                                                         match_start,
+                                                         match_end,
+                                                         NULL,
+                                                         error);
+}
+
+/**
+ * gtk_source_search_context_forward_finish2:
+ * @search: a #GtkSourceSearchContext.
+ * @result: a #GAsyncResult.
+ * @match_start: (out) (optional): return location for start of match, or %NULL.
+ * @match_end: (out) (optional): return location for end of match, or %NULL.
+ * @has_wrapped_around: (out) (optional): return location to know whether the
+ *   search has wrapped around, or %NULL.
+ * @error: a #GError, or %NULL.
+ *
+ * Finishes a forward search started with
+ * gtk_source_search_context_forward_async().
+ *
+ * See the documentation of gtk_source_search_context_forward2() for more
+ * details.
+ *
+ * Returns: whether a match was found.
+ * Since: 3.22
+ */
+gboolean
+gtk_source_search_context_forward_finish2 (GtkSourceSearchContext  *search,
+                                          GAsyncResult            *result,
+                                          GtkTextIter             *match_start,
+                                          GtkTextIter             *match_end,
+                                          gboolean                *has_wrapped_around,
+                                          GError                 **error)
+{
        ForwardBackwardData *data;
        gboolean found;
 
        g_return_val_if_fail (GTK_SOURCE_IS_SEARCH_CONTEXT (search), FALSE);
 
+       if (has_wrapped_around != NULL)
+       {
+               *has_wrapped_around = FALSE;
+       }
+
        if (search->priv->buffer == NULL)
        {
                return FALSE;
@@ -3356,6 +3401,11 @@ gtk_source_search_context_forward_finish (GtkSourceSearchContext  *search,
                }
        }
 
+       if (has_wrapped_around != NULL)
+       {
+               *has_wrapped_around = data->wrapped_around;
+       }
+
        forward_backward_data_free (data);
        return found;
 }
@@ -3526,11 +3576,12 @@ gtk_source_search_context_backward_finish (GtkSourceSearchContext  *search,
                                           GtkTextIter             *match_end,
                                           GError                 **error)
 {
-       return gtk_source_search_context_forward_finish (search,
-                                                        result,
-                                                        match_start,
-                                                        match_end,
-                                                        error);
+       return gtk_source_search_context_forward_finish2 (search,
+                                                         result,
+                                                         match_start,
+                                                         match_end,
+                                                         NULL,
+                                                         error);
 }
 
 /* If correctly replaced, returns %TRUE and @match_end is updated to point to
diff --git a/gtksourceview/gtksourcesearchcontext.h b/gtksourceview/gtksourcesearchcontext.h
index 582a15d..4e4e504 100644
--- a/gtksourceview/gtksourcesearchcontext.h
+++ b/gtksourceview/gtksourcesearchcontext.h
@@ -2,7 +2,7 @@
  * gtksourcesearchcontext.h
  * This file is part of GtkSourceView
  *
- * Copyright (C) 2013 - Sébastien Wilmet <swilmet gnome org>
+ * Copyright (C) 2013, 2016 - Sébastien Wilmet <swilmet gnome org>
  *
  * GtkSourceView is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -113,13 +113,21 @@ void                       gtk_source_search_context_forward_async                
(GtkSourceSearchContext  *searc
                                                                                 GAsyncReadyCallback      
callback,
                                                                                 gpointer                 
user_data);
 
-GTK_SOURCE_AVAILABLE_IN_3_10
+GTK_SOURCE_DEPRECATED_IN_3_22_FOR (gtk_source_search_context_forward_finish2)
 gboolean                gtk_source_search_context_forward_finish               (GtkSourceSearchContext  
*search,
                                                                                 GAsyncResult            
*result,
                                                                                 GtkTextIter             
*match_start,
                                                                                 GtkTextIter             
*match_end,
                                                                                 GError                 
**error);
 
+GTK_SOURCE_AVAILABLE_IN_3_22
+gboolean                gtk_source_search_context_forward_finish2              (GtkSourceSearchContext  
*search,
+                                                                                GAsyncResult            
*result,
+                                                                                GtkTextIter             
*match_start,
+                                                                                GtkTextIter             
*match_end,
+                                                                                gboolean                
*has_wrapped_around,
+                                                                                GError                 
**error);
+
 GTK_SOURCE_DEPRECATED_IN_3_22_FOR (gtk_source_search_context_backward2)
 gboolean                gtk_source_search_context_backward                     (GtkSourceSearchContext  
*search,
                                                                                 const GtkTextIter       
*iter,
diff --git a/tests/test-search.c b/tests/test-search.c
index 2de3cfc..fc07614 100644
--- a/tests/test-search.c
+++ b/tests/test-search.c
@@ -222,11 +222,12 @@ forward_search_finished (GtkSourceSearchContext *search_context,
        GtkTextIter match_start;
        GtkTextIter match_end;
 
-       if (gtk_source_search_context_forward_finish (search_context,
-                                                     result,
-                                                     &match_start,
-                                                     &match_end,
-                                                     NULL))
+       if (gtk_source_search_context_forward_finish2 (search_context,
+                                                      result,
+                                                      &match_start,
+                                                      &match_end,
+                                                      NULL,
+                                                      NULL))
        {
                select_search_occurrence (search, &match_start, &match_end);
        }
diff --git a/testsuite/test-search-context.c b/testsuite/test-search-context.c
index b94e3f4..69afa0e 100644
--- a/testsuite/test-search-context.c
+++ b/testsuite/test-search-context.c
@@ -456,11 +456,12 @@ finish_check_result (GtkSourceSearchContext *context,
 
        if (data->forward)
        {
-               found = gtk_source_search_context_forward_finish (context,
-                                                                 result,
-                                                                 &match_start,
-                                                                 &match_end,
-                                                                 NULL);
+               found = gtk_source_search_context_forward_finish2 (context,
+                                                                  result,
+                                                                  &match_start,
+                                                                  &match_end,
+                                                                  NULL,
+                                                                  NULL);
        }
        else
        {


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