[gnome-builder] history: push cursor location upon buffer load
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] history: push cursor location upon buffer load
- Date: Mon, 17 Sep 2018 18:54:38 +0000 (UTC)
commit 19c9581135c4243026dd269a4d12849361ed8d7d
Author: Christian Hergert <chergert redhat com>
Date: Mon Sep 17 11:51:34 2018 -0700
history: push cursor location upon buffer load
.../history/gbp-history-editor-view-addin.c | 35 ++++++++++++++++++++++
1 file changed, 35 insertions(+)
---
diff --git a/src/plugins/history/gbp-history-editor-view-addin.c
b/src/plugins/history/gbp-history-editor-view-addin.c
index aa8195bed..655d7b80c 100644
--- a/src/plugins/history/gbp-history-editor-view-addin.c
+++ b/src/plugins/history/gbp-history-editor-view-addin.c
@@ -205,6 +205,32 @@ gbp_history_editor_view_addin_delete_range (GbpHistoryEditorViewAddin *self,
gbp_history_editor_view_addin_queue (self, gtk_text_iter_get_line (begin));
}
+static void
+gbp_history_editor_view_addin_buffer_loaded (GbpHistoryEditorViewAddin *self,
+ IdeBuffer *buffer)
+{
+ IdeSourceView *source_view;
+
+ g_assert (GBP_IS_HISTORY_EDITOR_VIEW_ADDIN (self));
+ g_assert (IDE_IS_EDITOR_VIEW (self->editor));
+ g_assert (IDE_IS_BUFFER (buffer));
+
+ /*
+ * The cursor should have settled here, push it's location onto the
+ * history stack so that ctrl+i works after jumping backwards.
+ */
+
+ source_view = ide_editor_view_get_view (self->editor);
+
+ if (gtk_widget_has_focus (GTK_WIDGET (source_view)))
+ {
+ GtkTextIter iter;
+
+ ide_buffer_get_selection_bounds (buffer, &iter, NULL);
+ gbp_history_editor_view_addin_queue (self, gtk_text_iter_get_line (&iter));
+ }
+}
+
static void
gbp_history_editor_view_addin_load (IdeEditorViewAddin *addin,
IdeEditorView *view)
@@ -237,6 +263,11 @@ gbp_history_editor_view_addin_load (IdeEditorViewAddin *addin,
"delete-range",
G_CALLBACK (gbp_history_editor_view_addin_delete_range),
self);
+
+ g_signal_connect_swapped (buffer,
+ "loaded",
+ G_CALLBACK (gbp_history_editor_view_addin_buffer_loaded),
+ self);
}
static void
@@ -267,6 +298,10 @@ gbp_history_editor_view_addin_unload (IdeEditorViewAddin *addin,
G_CALLBACK (gbp_history_editor_view_addin_delete_range),
self);
+ g_signal_handlers_disconnect_by_func (buffer,
+ G_CALLBACK (gbp_history_editor_view_addin_buffer_loaded),
+ self);
+
g_clear_weak_pointer (&self->stack_addin);
self->editor = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]