[goffice] GODoc: make "pristine" an object property.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Subject: [goffice] GODoc: make "pristine" an object property.
- Date: Mon, 11 May 2009 11:40:34 -0400 (EDT)
commit eeda2c48c70956d1657e9c8b1a95e2502d4e9cf0
Author: Morten Welinder <terra gnome org>
Date: Mon May 11 11:40:15 2009 -0400
GODoc: make "pristine" an object property.
---
ChangeLog | 6 +++++
NEWS | 3 ++
goffice/app/go-doc.c | 55 ++++++++++++++++++++++++++++++++++++++++----------
goffice/app/go-doc.h | 1 +
4 files changed, 54 insertions(+), 11 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c0a83ea..76f2bcc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-05-11 Morten Welinder <terra gnome org>
+
+ * goffice/app/go-doc.c (go_doc_set_pristine): New function.
+ (go_doc_get_property, go_doc_set_property, go_doc_class_init):
+ Make "pristine" an object property.
+
2009-05-07 Andreas J. Guelzow <aguelzow pyrshep ca>
* goffice/utils/go-format.c (cb_attrs_as_string): store the full
diff --git a/NEWS b/NEWS
index 21cd029..a42393e 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,9 @@ goffice 0.7.7:
Andreas:
* Modified serialization of pango markup to support all weights
+Morten:
+ * Add "pristine" as GODoc property.
+
--------------------------------------------------------------------------
goffice 0.7.6:
diff --git a/goffice/app/go-doc.c b/goffice/app/go-doc.c
index d53346e..aa87665 100644
--- a/goffice/app/go-doc.c
+++ b/goffice/app/go-doc.c
@@ -3,6 +3,7 @@
* go-doc.c : A GOffice Document
*
* Copyright (C) 2004-2006 Jody Goldberg (jody gnome org)
+ * Copyright (C) 2008-2009 Morten Welinder (terra gnome org)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
@@ -34,7 +35,8 @@
enum {
PROP_0,
PROP_URI,
- PROP_DIRTY
+ PROP_DIRTY,
+ PROP_PRISTINE
};
enum {
METADATA_CHANGED,
@@ -58,6 +60,11 @@ go_doc_get_property (GObject *obj, guint property_id,
case PROP_DIRTY:
g_value_set_boolean (value, go_doc_is_dirty (doc));
break;
+
+ case PROP_PRISTINE:
+ g_value_set_boolean (value, go_doc_is_pristine (doc));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec);
break;
@@ -74,9 +81,15 @@ go_doc_set_property (GObject *obj, guint property_id,
case PROP_URI:
go_doc_set_uri (doc, g_value_get_string (value));
break;
- case PROP_DIRTY:
+
+ case PROP_DIRTY:
go_doc_set_dirty (doc, g_value_get_boolean (value));
break;
+
+ case PROP_PRISTINE:
+ go_doc_set_pristine (doc, g_value_get_boolean (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec);
break;
@@ -126,10 +139,15 @@ go_doc_class_init (GObjectClass *object_class)
NULL, GSF_PARAM_STATIC | G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_DIRTY,
- g_param_spec_boolean ("dirty", _("Dirty"),
+ g_param_spec_boolean ("dirty", _("Dirty"),
_("Whether the document has been changed."),
FALSE, GSF_PARAM_STATIC | G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_PRISTINE,
+ g_param_spec_boolean ("pristine", _("Pristine"),
+ _("Whether the document is unchanged since it was created."),
+ FALSE, GSF_PARAM_STATIC | G_PARAM_READWRITE));
+
signals [METADATA_UPDATE] = g_signal_new ("metadata-update",
GO_TYPE_DOC, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GODocClass, meta_data.update),
@@ -201,7 +219,7 @@ go_doc_set_dirty (GODoc *doc, gboolean is_dirty)
return;
/* Dirtiness changed so no longer pristine. */
- doc->pristine = FALSE;
+ go_doc_set_pristine (doc, FALSE);
doc->modified = is_dirty;
g_object_notify (G_OBJECT (doc), "dirty");
@@ -222,6 +240,28 @@ go_doc_is_dirty (GODoc const *doc)
}
/**
+ * go_doc_set_pristine:
+ * @doc: #GODoc
+ * @pristine: a gboolean.
+ *
+ * Sets the indication of whether this document is unchanged since it was
+ * created. Note: if both "dirty" and "pristine" are being set, set
+ * "pristine" last.
+ **/
+void
+go_doc_set_pristine (GODoc *doc, gboolean pristine)
+{
+ g_return_if_fail (GO_IS_DOC (doc));
+
+ pristine = !!pristine;
+ if (pristine == doc->pristine)
+ return;
+
+ doc->pristine = pristine;
+ g_object_notify (G_OBJECT (doc), "pristine");
+}
+
+/**
* go_doc_is_pristine:
* @doc: #GODoc
*
@@ -234,13 +274,6 @@ gboolean
go_doc_is_pristine (GODoc const *doc)
{
g_return_val_if_fail (GO_IS_DOC (doc), FALSE);
-
-#if 0
- if (doc->names ||
- (doc->file_format_level > FILE_FL_NEW))
- return FALSE;
-#endif
-
return doc->pristine;
}
diff --git a/goffice/app/go-doc.h b/goffice/app/go-doc.h
index 8452dd5..4f28963 100644
--- a/goffice/app/go-doc.h
+++ b/goffice/app/go-doc.h
@@ -34,6 +34,7 @@ G_BEGIN_DECLS
GType go_doc_get_type (void);
+void go_doc_set_pristine (GODoc *doc, gboolean pristine);
gboolean go_doc_is_pristine (GODoc const *doc);
void go_doc_set_dirty (GODoc *doc, gboolean is_dirty);
gboolean go_doc_is_dirty (GODoc const *doc);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]