[gnome-builder] GbEditorFrame: invalidate textview contents after saving document.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] GbEditorFrame: invalidate textview contents after saving document.
- Date: Fri, 19 Dec 2014 02:39:14 +0000 (UTC)
commit c1cb31985862cf7c9092b8ee7321fbd5098a8e26
Author: Christian Hergert <christian hergert me>
Date: Thu Dec 18 18:28:34 2014 -0800
GbEditorFrame: invalidate textview contents after saving document.
src/editor/gb-editor-document.c | 13 +++++++++++++
src/editor/gb-editor-document.h | 1 +
src/editor/gb-editor-frame.c | 25 +++++++++++++++++++++++++
3 files changed, 39 insertions(+), 0 deletions(-)
---
diff --git a/src/editor/gb-editor-document.c b/src/editor/gb-editor-document.c
index ab49101..2257bbc 100644
--- a/src/editor/gb-editor-document.c
+++ b/src/editor/gb-editor-document.c
@@ -68,6 +68,7 @@ enum {
enum {
CURSOR_MOVED,
FILE_MARK_SET,
+ SAVED,
LAST_SIGNAL
};
@@ -870,6 +871,8 @@ gb_editor_document_save_cb (GObject *object,
g_task_return_boolean (task, TRUE);
+ g_signal_emit (document, gSignals [SAVED], 0);
+
cleanup:
g_object_unref (task);
@@ -1512,6 +1515,16 @@ gb_editor_document_class_init (GbEditorDocumentClass *klass)
G_TYPE_NONE,
1,
GTK_TYPE_TEXT_ITER);
+
+ gSignals [SAVED] =
+ g_signal_new ("saved",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GbEditorDocumentClass, saved),
+ NULL, NULL,
+ g_cclosure_marshal_generic,
+ G_TYPE_NONE,
+ 0);
}
static void
diff --git a/src/editor/gb-editor-document.h b/src/editor/gb-editor-document.h
index dd3eccf..2833fe4 100644
--- a/src/editor/gb-editor-document.h
+++ b/src/editor/gb-editor-document.h
@@ -53,6 +53,7 @@ struct _GbEditorDocumentClass
void (*cursor_moved) (GbEditorDocument *document);
void (*file_mark_set) (GbEditorDocument *document,
GtkTextIter *location);
+ void (*saved) (GbEditorDocument *document);
};
GbEditorDocument *gb_editor_document_new (void);
diff --git a/src/editor/gb-editor-frame.c b/src/editor/gb-editor-frame.c
index 4e8bb07..dbc56c4 100644
--- a/src/editor/gb-editor-frame.c
+++ b/src/editor/gb-editor-frame.c
@@ -418,6 +418,20 @@ gb_editor_frame_on_file_mark_set (GbEditorFrame *frame,
location, 0.0, TRUE, 0.5, 0.5);
}
+static void
+gb_editor_frame_document_saved (GbEditorFrame *frame,
+ GbEditorDocument *document)
+{
+ GdkWindow *window;
+
+ g_return_if_fail (GB_IS_EDITOR_FRAME (frame));
+ g_return_if_fail (GB_IS_EDITOR_DOCUMENT (document));
+
+ window = gtk_text_view_get_window (GTK_TEXT_VIEW (frame->priv->source_view),
+ GTK_TEXT_WINDOW_WIDGET);
+ gdk_window_invalidate_rect (window, NULL, TRUE);
+}
+
/**
* gb_editor_frame_connect:
*
@@ -450,6 +464,17 @@ gb_editor_frame_connect (GbEditorFrame *frame,
GTK_TEXT_BUFFER (priv->document));
/*
+ * Look the saved signal so that we can invalidate the window afterwards.
+ * This could happen since gutter content could change (like if it is a
+ * new file in a git repo).
+ */
+ g_signal_connect_object (priv->document,
+ "saved",
+ G_CALLBACK (gb_editor_frame_document_saved),
+ frame,
+ G_CONNECT_SWAPPED);
+
+ /*
* Connect change monitor to gutter.
*/
monitor = gb_editor_document_get_change_monitor (document);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]