[glom] Fix document loading, and make distcheck.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Fix document loading, and make distcheck.
- Date: Tue, 24 Jan 2012 09:34:14 +0000 (UTC)
commit 9731c8f52727abf854f95ef915f36f275f0dde52
Author: Murray Cumming <murrayc murrayc com>
Date: Tue Jan 24 10:33:53 2012 +0100
Fix document loading, and make distcheck.
* glom/glom_document.dtd: Mention that the database_title
attribute is replaced by title.
* glom/libglom/document/document.cc: load_after(): Deprecate the
database_title attribute, but do load it if it is present and
if title is not.
get_latest_known_document_format_version(): Increase the version
because the deprecated attribute will not be saved.
ChangeLog | 12 ++++++++++++
glom/glom_document.dtd | 6 ++++--
glom/libglom/document/document.cc | 18 ++++++++++++------
3 files changed, 28 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 605e894..189ea05 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2012-01-24 Murray Cumming <murrayc murrayc com>
+
+ Fix document loading, and make distcheck.
+
+ * glom/glom_document.dtd: Mention that the database_title
+ attribute is replaced by title.
+ * glom/libglom/document/document.cc: load_after(): Deprecate the
+ database_title attribute, but do load it if it is present and
+ if title is not.
+ get_latest_known_document_format_version(): Increase the version
+ because the deprecated attribute will not be saved.
+
2012-01-23 Murray Cumming <murrayc murrayc com>
libglom: Replace more std::lists with std::vector.
diff --git a/glom/glom_document.dtd b/glom/glom_document.dtd
index c9201ca..a84851f 100644
--- a/glom/glom_document.dtd
+++ b/glom/glom_document.dtd
@@ -9,14 +9,16 @@ TODO: Should we specify the presence of child text nodes in the ELEMENT somehow?
<!-- This is the main node of the glom document. It describes the format of the
databases (tables) and permissions (groups), as well as connections and any
libraries.
- database_title: The human-readable title of the database.
+ title: The human-readable title of the database.
+ database_title: Deprecated in favour of title.
translation_original_locale: What locale is considered to have been used for the human-readable titles in this document.
format_version: The version of this document's format. Older versions of Glom cannot open documents saved in newer versions of the document format.
is_example: Whether this is an example document. Opening an example document causes a new database (and document) to be created.
-->
- <!ELEMENT glom_document (connection?, startup_script?, table*, groups?, library_modules?) >
+ <!ELEMENT glom_document (connection?, trans_set?, startup_script?, table*, groups?, library_modules?) >
<!ATTLIST glom_document
xmlns CDATA #IMPLIED
+ title CDATA #IMPLIED
database_title CDATA #IMPLIED
translation_original_locale CDATA #IMPLIED
format_version CDATA #IMPLIED
diff --git a/glom/libglom/document/document.cc b/glom/libglom/document/document.cc
index 3b64374..8fd2ac4 100644
--- a/glom/libglom/document/document.cc
+++ b/glom/libglom/document/document.cc
@@ -149,7 +149,7 @@ static const char GLOM_ATTRIBUTE_PRIV_DELETE[] = "priv_delete";
static const char GLOM_ATTRIBUTE_FORMAT_VERSION[] = "format_version";
static const char GLOM_ATTRIBUTE_IS_EXAMPLE[] = "is_example";
static const char GLOM_ATTRIBUTE_IS_BACKUP[] = "is_backup";
-static const char GLOM_ATTRIBUTE_CONNECTION_DATABASE_TITLE[] = "database_title";
+static const char GLOM_DEPRECATED_ATTRIBUTE_CONNECTION_DATABASE_TITLE[] = "database_title"; //deprecated in favour of GLOM_ATTRIBUTE_TITLE.
static const char GLOM_NODE_STARTUP_SCRIPT[] = "startup_script";
static const char GLOM_ATTRIBUTE_TRANSLATION_ORIGINAL_LOCALE[] = "translation_original_locale";
static const char GLOM_ATTRIBUTE_NAME[] = "name";
@@ -2669,10 +2669,17 @@ bool Document::load_after(int& failure_code)
m_is_example = get_node_attribute_value_as_bool(nodeRoot, GLOM_ATTRIBUTE_IS_EXAMPLE);
m_is_backup = get_node_attribute_value_as_bool(nodeRoot, GLOM_ATTRIBUTE_IS_BACKUP);
- m_database_title->set_title_original(
- get_node_attribute_value(nodeRoot, GLOM_ATTRIBUTE_CONNECTION_DATABASE_TITLE) );
+
load_after_translations(nodeRoot, m_database_title);
+ //"database_title" is deprecated in favour of "title", loaded in
+ //load_after_translations(), but load this from old documents if
+ //if it is present, and the only thing present:
+ const Glib::ustring database_title_deprecated =
+ get_node_attribute_value(nodeRoot, GLOM_DEPRECATED_ATTRIBUTE_CONNECTION_DATABASE_TITLE);
+ if(!database_title_deprecated.empty() && get_database_title_original().empty())
+ m_database_title->set_title_original(database_title_deprecated);
+
m_startup_script = get_child_text_node(nodeRoot, GLOM_NODE_STARTUP_SCRIPT);
m_translation_original_locale = get_node_attribute_value(nodeRoot, GLOM_ATTRIBUTE_TRANSLATION_ORIGINAL_LOCALE);
@@ -3724,8 +3731,6 @@ bool Document::save_before()
set_node_attribute_value_as_bool(nodeRoot, GLOM_ATTRIBUTE_IS_EXAMPLE, m_is_example);
set_node_attribute_value_as_bool(nodeRoot, GLOM_ATTRIBUTE_IS_BACKUP, m_is_backup);
- set_node_attribute_value(nodeRoot, GLOM_ATTRIBUTE_CONNECTION_DATABASE_TITLE,
- m_database_title->get_title_original());
save_before_translations(nodeRoot, m_database_title);
set_child_text_node(nodeRoot, GLOM_NODE_STARTUP_SCRIPT, m_startup_script);
@@ -4673,8 +4678,9 @@ guint Document::get_latest_known_document_format_version()
// Version 5: (Glom 1.14). Extra layout item formatting options were added, plus a startup script.
// Version 6: (Glom 1.16). Extra show_all option for choices that show related records. Extra related choice fields are now a layout group instead of just a second field name.
// Version 7: (Glom 1.20). New print layout details. Related records: Number of rows can be specified. All colors can now be in CSS3 string format (via GdkRGBA)
+ // Version 8: (Glom 1.22). The database_title attribute is replaced by the title attribute.
- return 7;
+ return 8;
}
std::vector<Glib::ustring> Document::get_library_module_names() const
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]