[gnome-builder] GbEditorDocument: implement GbDocument interface functions
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] GbEditorDocument: implement GbDocument interface functions
- Date: Sat, 13 Dec 2014 00:35:10 +0000 (UTC)
commit 61994ae9773f9e9f0963b2a610f6105c89cf3d88
Author: Christian Hergert <christian hergert me>
Date: Fri Dec 12 16:28:33 2014 -0800
GbEditorDocument: implement GbDocument interface functions
Adds helper functions for mtime, is_untitled, and get_read_only()
src/editor/gb-editor-document.c | 50 +++++++++++++++++++++++++++-----------
src/editor/gb-editor-document.h | 1 -
2 files changed, 35 insertions(+), 16 deletions(-)
---
diff --git a/src/editor/gb-editor-document.c b/src/editor/gb-editor-document.c
index e91dd0d..59a05a3 100644
--- a/src/editor/gb-editor-document.c
+++ b/src/editor/gb-editor-document.c
@@ -90,6 +90,14 @@ gb_editor_document_new (void)
return g_object_new (GB_TYPE_EDITOR_DOCUMENT, NULL);
}
+static gboolean
+gb_editor_document_is_untitled (GbDocument *document)
+{
+ g_return_val_if_fail (GB_IS_EDITOR_DOCUMENT (document), NULL);
+
+ return (GB_EDITOR_DOCUMENT (document)->priv->doc_seq_id > 0);
+}
+
/**
* gb_editor_document_get_error:
*
@@ -120,12 +128,12 @@ gb_editor_document_set_error (GbEditorDocument *document,
}
}
-gboolean
-gb_editor_document_get_read_only (GbEditorDocument *document)
+static gboolean
+gb_editor_document_get_read_only (GbDocument *document)
{
g_return_val_if_fail (GB_IS_EDITOR_DOCUMENT (document), FALSE);
- return document->priv->read_only;
+ return GB_EDITOR_DOCUMENT (document)->priv->read_only;
}
static void
@@ -139,8 +147,7 @@ gb_editor_document_set_read_only (GbEditorDocument *document,
if (document->priv->read_only != read_only)
{
document->priv->read_only = read_only;
- g_object_notify_by_pspec (G_OBJECT (document),
- gParamSpecs [PROP_READ_ONLY]);
+ g_object_notify (G_OBJECT (document), "read-only");
}
EXIT;
@@ -1125,6 +1132,23 @@ gb_editor_document_modified_changed (GtkTextBuffer *buffer)
}
gboolean
+gb_editor_document_get_mtime (GbDocument *document,
+ GTimeVal *mtime)
+{
+ GbEditorDocument *self = (GbEditorDocument *)document;
+
+ g_return_val_if_fail (GB_IS_EDITOR_DOCUMENT (self), FALSE);
+
+ if (self->priv->mtime_set)
+ {
+ memcpy (mtime, &self->priv->mtime, sizeof *mtime);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+gboolean
gb_editor_document_get_modified (GbDocument *document)
{
g_return_val_if_fail (GB_IS_EDITOR_DOCUMENT (document), FALSE);
@@ -1229,7 +1253,8 @@ gb_editor_document_get_property (GObject *object,
break;
case PROP_READ_ONLY:
- g_value_set_boolean (value, gb_editor_document_get_read_only (self));
+ g_value_set_boolean (value,
+ gb_editor_document_get_read_only (GB_DOCUMENT (self)));
break;
case PROP_PROGRESS:
@@ -1294,6 +1319,7 @@ gb_editor_document_class_init (GbEditorDocumentClass *klass)
text_buffer_class->modified_changed = gb_editor_document_modified_changed;
g_object_class_override_property (object_class, PROP_MODIFIED, "modified");
+ g_object_class_override_property (object_class, PROP_READ_ONLY, "read-only");
g_object_class_override_property (object_class, PROP_TITLE, "title");
gParamSpecs [PROP_CHANGE_MONITOR] =
@@ -1343,15 +1369,6 @@ gb_editor_document_class_init (GbEditorDocumentClass *klass)
g_object_class_install_property (object_class, PROP_PROGRESS,
gParamSpecs [PROP_PROGRESS]);
- gParamSpecs [PROP_READ_ONLY] =
- g_param_spec_boolean ("read-only",
- _("Read Only"),
- _("If the buffer is read only."),
- FALSE,
- (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (object_class, PROP_READ_ONLY,
- gParamSpecs [PROP_READ_ONLY]);
-
gParamSpecs [PROP_STYLE_SCHEME_NAME] =
g_param_spec_string ("style-scheme-name",
_("Style Scheme Name"),
@@ -1426,7 +1443,10 @@ static void
gb_editor_document_init_document (GbDocumentInterface *iface)
{
iface->get_modified = gb_editor_document_get_modified;
+ iface->get_mtime = gb_editor_document_get_mtime;
+ iface->get_read_only = gb_editor_document_get_read_only;
iface->get_title = gb_editor_document_get_title;
+ iface->is_untitled = gb_editor_document_is_untitled;
iface->create_view = gb_editor_document_create_view;
iface->save = gb_editor_document_save;
iface->save_as = gb_editor_document_save_as;
diff --git a/src/editor/gb-editor-document.h b/src/editor/gb-editor-document.h
index d2c1e44..f4b4571 100644
--- a/src/editor/gb-editor-document.h
+++ b/src/editor/gb-editor-document.h
@@ -63,7 +63,6 @@ void gb_editor_document_set_file (GbEditor
gdouble gb_editor_document_get_progress (GbEditorDocument *document);
GbSourceChangeMonitor *gb_editor_document_get_change_monitor (GbEditorDocument *document);
GbSourceCodeAssistant *gb_editor_document_get_code_assistant (GbEditorDocument *document);
-gboolean gb_editor_document_get_read_only (GbEditorDocument *document);
gboolean gb_editor_document_get_file_changed_on_volume (GbEditorDocument *document);
gboolean gb_editor_document_get_trim_trailing_whitespace (GbEditorDocument *document);
void gb_editor_document_set_trim_trailing_whitespace (GbEditorDocument *document,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]