[gnome-builder/wip/libide] libide: add IdeSourceView::clear-selection gsignalaction
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/libide] libide: add IdeSourceView::clear-selection gsignalaction
- Date: Wed, 4 Mar 2015 22:34:19 +0000 (UTC)
commit 35aa010e23730858ec8f505a4ba69fd83c42ef5d
Author: Christian Hergert <christian hergert me>
Date: Wed Mar 4 14:33:55 2015 -0800
libide: add IdeSourceView::clear-selection gsignalaction
This allows keybindings to clear the current selection.
libide/ide-source-view.c | 29 +++++++++++++++++++++++++++++
libide/ide-source-view.h | 1 +
2 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index b33d405..b05814e 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -103,6 +103,7 @@ enum {
enum {
ACTION,
+ CLEAR_SELECTION,
INSERT_AT_CURSOR_AND_INDENT,
JUMP,
MOVEMENT,
@@ -1452,6 +1453,23 @@ ide_source_view_real_action (IdeSourceView *self,
}
static void
+ide_source_view_real_clear_selection (IdeSourceView *self)
+{
+ GtkTextView *text_view = (GtkTextView *)self;
+ GtkTextBuffer *buffer;
+ GtkTextMark *insert;
+ GtkTextIter iter;
+
+ g_assert (GTK_IS_TEXT_VIEW (text_view));
+
+ buffer = gtk_text_view_get_buffer (text_view);
+ insert = gtk_text_buffer_get_insert (buffer);
+ gtk_text_buffer_get_iter_at_mark (buffer, &iter, insert);
+ gtk_text_buffer_select_range (buffer, &iter, &iter);
+ gtk_text_view_scroll_mark_onscreen (text_view, insert);
+}
+
+static void
ide_source_view_real_insert_at_cursor_and_indent (IdeSourceView *self,
const gchar *str)
{
@@ -1792,6 +1810,7 @@ ide_source_view_class_init (IdeSourceViewClass *klass)
widget_class->query_tooltip = ide_source_view_query_tooltip;
klass->action = ide_source_view_real_action;
+ klass->clear_selection = ide_source_view_real_clear_selection;
klass->insert_at_cursor_and_indent = ide_source_view_real_insert_at_cursor_and_indent;
klass->jump = ide_source_view_real_jump;
klass->movement = ide_source_view_real_movement;
@@ -1875,6 +1894,16 @@ ide_source_view_class_init (IdeSourceViewClass *klass)
G_TYPE_STRING,
G_TYPE_STRING);
+ gSignals [CLEAR_SELECTION] =
+ g_signal_new ("clear-selection",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (IdeSourceViewClass, clear_selection),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
gSignals [INSERT_AT_CURSOR_AND_INDENT] =
g_signal_new ("insert-at-cursor-and-indent",
G_TYPE_FROM_CLASS (klass),
diff --git a/libide/ide-source-view.h b/libide/ide-source-view.h
index 309b5fa..9637bc7 100644
--- a/libide/ide-source-view.h
+++ b/libide/ide-source-view.h
@@ -162,6 +162,7 @@ struct _IdeSourceViewClass
const gchar *prefix,
const gchar *action_name,
const gchar *param);
+ void (*clear_selection) (IdeSourceView *self);
void (*insert_at_cursor_and_indent) (IdeSourceView *self,
const gchar *str);
void (*movement) (IdeSourceView *self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]