[gtksourceview] Add a join-lines action signal



commit 75de09991504dc7dd7bec964a3ba12b8650ecfb1
Author: Paolo Borelli <pborelli gnome org>
Date:   Thu Mar 5 15:00:51 2015 +0100

    Add a join-lines action signal

 gtksourceview/gtksourceview.c |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/gtksourceview/gtksourceview.c b/gtksourceview/gtksourceview.c
index 00eea89..1e10b73 100644
--- a/gtksourceview/gtksourceview.c
+++ b/gtksourceview/gtksourceview.c
@@ -136,6 +136,7 @@ enum
        MOVE_TO_MATCHING_BRACKET,
        CHANGE_NUMBER,
        CHANGE_CASE,
+       JOIN_LINES,
        LAST_SIGNAL
 };
 
@@ -422,6 +423,22 @@ gtk_source_view_change_case (GtkSourceView           *view,
 }
 
 static void
+gtk_source_view_join_lines (GtkSourceView *view)
+{
+       GtkSourceBuffer *buffer;
+       GtkTextIter start;
+       GtkTextIter end;
+
+       buffer = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
+
+       gtk_text_view_reset_im_context (GTK_TEXT_VIEW (view));
+
+       gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (buffer), &start, &end);
+
+       gtk_source_buffer_join_lines (buffer, &start, &end);
+}
+
+static void
 gtk_source_view_class_init (GtkSourceViewClass *klass)
 {
        GObjectClass *object_class;
@@ -825,6 +842,23 @@ gtk_source_view_class_init (GtkSourceViewClass *klass)
                                            1,
                                            GTK_SOURCE_TYPE_CHANGE_CASE_TYPE);
 
+       /**
+        * GtkSourceView::join-lines:
+        * @view: the #GtkSourceView
+        *
+        * Keybinding signal to join the lines currently selected.
+        *
+        * Since: 3.16
+        */
+       signals[JOIN_LINES] =
+               g_signal_new_class_handler ("join-lines",
+                                           G_TYPE_FROM_CLASS (klass),
+                                           G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+                                           G_CALLBACK (gtk_source_view_join_lines),
+                                           NULL, NULL, NULL,
+                                           G_TYPE_NONE,
+                                           0);
+
        binding_set = gtk_binding_set_by_class (klass);
 
        gtk_binding_entry_add_signal (binding_set,


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