[gtksourceview] move-lines: deprecate copy parameter



commit e64db4ac3424f52d2fb77fd6a06db41799fd2726
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Thu Mar 30 19:18:39 2017 +0200

    move-lines: deprecate copy parameter
    
    The name of the signal is *move*-lines. Not copy. Anyway, how it is
    implemented it doesn't make sense, that's a very strange operation to do
    with a keyboard shortcut. See the removed unit test. It's better to do
    only one thing but do it well. copy=true was anyway buggy when several
    lines were selected (but it should now be fixed with the previous
    commit).
    
    Print also a warning if 'count' is different than 1 or -1.

 gtksourceview/gtksourceview.c |   21 ++++++++++++++++--
 testsuite/test-view.c         |   46 -----------------------------------------
 2 files changed, 18 insertions(+), 49 deletions(-)
---
diff --git a/gtksourceview/gtksourceview.c b/gtksourceview/gtksourceview.c
index 2482433..0108795 100644
--- a/gtksourceview/gtksourceview.c
+++ b/gtksourceview/gtksourceview.c
@@ -747,9 +747,11 @@ gtk_source_view_class_init (GtkSourceViewClass *klass)
        /**
         * GtkSourceView::move-lines:
         * @view: the #GtkSourceView which received the signal
-        * @copy: %TRUE if the line should be copied,
-        *        %FALSE if it should be moved
-        * @count: the number of lines to move over.
+        * @copy: %TRUE if the line should be copied, %FALSE if it should be
+        *   moved. This parameter is deprecated and will be removed in a later
+        *   version, it should be always %FALSE.
+        * @count: the number of lines to move over. Only 1 and -1 are
+        *   supported.
         *
         * The ::move-lines signal is a keybinding which gets emitted
         * when the user initiates moving a line. The default binding key
@@ -757,6 +759,9 @@ gtk_source_view_class_init (GtkSourceViewClass *klass)
         * or the current line by @count. For the moment, only
         * @count of -1 or 1 is valid.
         *
+        * The @copy parameter is deprecated, it has never been used by
+        * GtkSourceView (the value is always %FALSE) and was buggy.
+        *
         * Since: 2.10
         */
        signals[MOVE_LINES] =
@@ -3753,6 +3758,16 @@ gtk_source_view_move_lines (GtkSourceView *view,
        gboolean initially_contains_trailing_newline;
        gboolean down;
 
+       if (copy)
+       {
+               g_warning ("The 'copy' parameter of GtkSourceView::move-lines is deprecated.");
+       }
+
+       if (step != 1 && step != -1)
+       {
+               g_warning ("The 'count' parameter of GtkSourceView::move-lines should be either 1 or -1.");
+       }
+
        buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
 
        if (step == 0 || !gtk_text_view_get_editable (GTK_TEXT_VIEW (view)))
diff --git a/testsuite/test-view.c b/testsuite/test-view.c
index 34a199b..ee36d27 100644
--- a/testsuite/test-view.c
+++ b/testsuite/test-view.c
@@ -288,51 +288,6 @@ test_move_lines__move_single_line (void)
        g_object_unref (view);
 }
 
-static void
-test_move_lines__copy_single_line (void)
-{
-       GtkSourceView *view;
-       GtkTextBuffer *buffer;
-       GtkTextIter iter;
-       gchar *text;
-
-       view = GTK_SOURCE_VIEW (gtk_source_view_new ());
-       g_object_ref_sink (view);
-
-       buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
-
-       gtk_text_buffer_set_text (buffer,
-                                 "line1\n"
-                                 "line2\n"
-                                 "line3",
-                                 -1);
-
-       gtk_text_buffer_get_start_iter (buffer, &iter);
-       gtk_text_buffer_place_cursor (buffer, &iter);
-
-       /* Strange operation. A more useful operation would result to:
-        * line1\n
-        * line1\n
-        * line2\n
-        * line3
-        *
-        * The copy parameter has been added in
-        * commit 5ac5099a2fe28cc8d7851ba8dcc6c8126dae0f28, but it seems that it
-        * has never been used, at least not by GtkSourceView itself (there are
-        * no move-lines keybindings with copy=TRUE).
-        */
-       g_signal_emit_by_name (view, "move-lines", TRUE, 1);
-       text = get_text (buffer);
-       g_assert_cmpstr (text, ==,
-                        "line1\n"
-                        "line2\n"
-                        "line1\n"
-                        "line3");
-       g_free (text);
-
-       g_object_unref (view);
-}
-
 #define N_CASES_INITIAL_SELECTION_FOR_SEVERAL_LINES (3)
 
 static void
@@ -588,7 +543,6 @@ main (int argc, char **argv)
        gtk_test_init (&argc, &argv);
 
        g_test_add_func ("/view/move-lines/move-single-line", test_move_lines__move_single_line);
-       g_test_add_func ("/view/move-lines/copy-single-line", test_move_lines__copy_single_line);
        g_test_add_func ("/view/move-lines/move-several-lines", test_move_lines__move_several_lines);
 
        return g_test_run();


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