[gnome-builder] libide: add IdeSourceView::swap-selection-bounds
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide: add IdeSourceView::swap-selection-bounds
- Date: Tue, 24 Mar 2015 00:01:18 +0000 (UTC)
commit 692afa4b8c328626263604fd46707258c37750be
Author: Christian Hergert <christian hergert me>
Date: Thu Mar 5 16:33:38 2015 -0800
libide: add IdeSourceView::swap-selection-bounds
This can be handy if the keybinding knows it needs to swap the order of
the selection (so insert comes after selection, or vice-versa).
libide/ide-source-view.c | 28 +++++++++++++++++++++++++++-
libide/ide-source-view.h | 1 +
2 files changed, 28 insertions(+), 1 deletions(-)
---
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index d937019..ed8dd9a 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -124,6 +124,7 @@ enum {
SELECTION_THEATRIC,
SET_MODE,
SET_OVERWRITE,
+ SWAP_SELECTION_BOUNDS,
LAST_SIGNAL
};
@@ -1973,6 +1974,20 @@ ide_source_view_real_set_overwrite (IdeSourceView *self,
}
static void
+ide_source_view_real_swap_selection_bounds (IdeSourceView *self)
+{
+ GtkTextBuffer *buffer;
+ GtkTextIter insert;
+ GtkTextIter selection_bound;
+
+ g_assert (IDE_IS_SOURCE_VIEW (self));
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self));
+ gtk_text_buffer_get_selection_bounds (buffer, &insert, &selection_bound);
+ gtk_text_buffer_select_range (buffer, &selection_bound, &insert);
+}
+
+static void
ide_source_view_real_movement (IdeSourceView *self,
IdeSourceViewMovement movement,
gboolean extend_selection)
@@ -2291,6 +2306,7 @@ ide_source_view_class_init (IdeSourceViewClass *klass)
klass->selection_theatric = ide_source_view_real_selection_theatric;
klass->set_mode = ide_source_view_real_set_mode;
klass->set_overwrite = ide_source_view_real_set_overwrite;
+ klass->swap_selection_bounds = ide_source_view_real_swap_selection_bounds;
g_object_class_override_property (object_class, PROP_AUTO_INDENT, "auto-indent");
@@ -2552,10 +2568,20 @@ ide_source_view_class_init (IdeSourceViewClass *klass)
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (IdeSourceViewClass, set_overwrite),
NULL, NULL,
- g_cclosure_marshal_generic,
+ g_cclosure_marshal_VOID__BOOLEAN,
G_TYPE_NONE,
1,
G_TYPE_BOOLEAN);
+
+ gSignals [SWAP_SELECTION_BOUNDS] =
+ g_signal_new ("swap-selection-bounds",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (IdeSourceViewClass, swap_selection_bounds),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
}
static void
diff --git a/libide/ide-source-view.h b/libide/ide-source-view.h
index f1cadb4..8ca9397 100644
--- a/libide/ide-source-view.h
+++ b/libide/ide-source-view.h
@@ -215,6 +215,7 @@ struct _IdeSourceViewClass
IdeSourceViewModeType type);
void (*set_overwrite) (IdeSourceView *self,
gboolean overwrite);
+ void (*swap_selection_bounds) (IdeSourceView *self);
};
void ide_source_view_clear_snippets (IdeSourceView *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]