[gnome-builder] implement GbView:modified for editor view
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] implement GbView:modified for editor view
- Date: Tue, 24 Mar 2015 00:32:45 +0000 (UTC)
commit cbe0e3cf49377175c03b0e6b9e4eaf321a3d700c
Author: Christian Hergert <christian hergert me>
Date: Sat Mar 21 15:09:22 2015 -0700
implement GbView:modified for editor view
src/editor/gb-editor-view.c | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/src/editor/gb-editor-view.c b/src/editor/gb-editor-view.c
index e02a596..694d8e9 100644
--- a/src/editor/gb-editor-view.c
+++ b/src/editor/gb-editor-view.c
@@ -98,6 +98,26 @@ language_to_string (GBinding *binding,
return TRUE;
}
+static gboolean
+gb_editor_view_get_modified (GbView *view)
+{
+ GbEditorView *self = (GbEditorView *)view;
+
+ g_assert (GB_IS_EDITOR_VIEW (self));
+
+ return gtk_text_buffer_get_modified (GTK_TEXT_BUFFER (self->document));
+}
+
+static void
+gb_editor_view__buffer_modified_changed (GbEditorView *self,
+ GParamSpec *pspec,
+ GtkTextBuffer *buffer)
+{
+ g_assert (GB_IS_EDITOR_VIEW (self));
+
+ g_object_notify (G_OBJECT (self), "modified");
+}
+
static void
gb_editor_view_set_document (GbEditorView *self,
GbEditorDocument *document)
@@ -124,6 +144,12 @@ gb_editor_view_set_document (GbEditorView *self,
"label", G_BINDING_SYNC_CREATE,
language_to_string, NULL, NULL, NULL);
+ g_signal_connect_object (document,
+ "modified-changed",
+ G_CALLBACK (gb_editor_view__buffer_modified_changed),
+ self,
+ G_CONNECT_SWAPPED);
+
g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_DOCUMENT]);
gb_editor_view_actions_update (self);
@@ -272,6 +298,7 @@ gb_editor_view_class_init (GbEditorViewClass *klass)
view_class->create_split = gb_editor_view_create_split;
view_class->get_document = gb_editor_view_get_document;
+ view_class->get_modified = gb_editor_view_get_modified;
view_class->set_split_view = gb_editor_view_set_split_view;
view_class->set_back_forward_list = gb_editor_view_set_back_forward_list;
view_class->navigate_to = gb_editor_view_navigate_to;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]