From d9da2a4f178e71f5b33ea158c0631e86220f2e5d Mon Sep 17 00:00:00 2001 From: John Smith Date: Thu, 12 Jul 2012 17:19:58 +0900 Subject: Fix for 612221 : Add metadata default configuration in the preferences (bzr r11544) --- src/ui/widget/entity-entry.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/ui/widget/entity-entry.cpp') diff --git a/src/ui/widget/entity-entry.cpp b/src/ui/widget/entity-entry.cpp index 2a6e2bcd0..c622796b2 100644 --- a/src/ui/widget/entity-entry.cpp +++ b/src/ui/widget/entity-entry.cpp @@ -27,6 +27,7 @@ #include "sp-root.h" #include "document-undo.h" #include "document-private.h" +#include "preferences.h" #include "verbs.h" #include "entity-entry.h" @@ -72,6 +73,13 @@ EntityEntry::~EntityEntry() _changed_connection.disconnect(); } +void EntityEntry::save_to_preferences(SPDocument *doc) +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + const gchar *text = rdf_get_work_entity (doc, _entity); + prefs->setString(PREFS_METADATA + Glib::ustring(_entity->name), Glib::ustring(text ? text : "")); +} + EntityLineEntry::EntityLineEntry (rdf_work_entity_t* ent, Registry& wr) : EntityEntry (ent, wr) { @@ -97,6 +105,16 @@ void EntityLineEntry::update(SPDocument *doc) static_cast(_packable)->set_text (text ? text : ""); } + +void EntityLineEntry::load_from_preferences() +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring text = prefs->getString(PREFS_METADATA + Glib::ustring(_entity->name)); + if (text.length() > 0) { + static_cast(_packable)->set_text (text.c_str()); + } +} + void EntityLineEntry::on_changed() { @@ -146,6 +164,19 @@ void EntityMultiLineEntry::update(SPDocument *doc) tv->get_buffer()->set_text (text ? text : ""); } + +void EntityMultiLineEntry::load_from_preferences() +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Glib::ustring text = prefs->getString(PREFS_METADATA + Glib::ustring(_entity->name)); + if (text.length() > 0) { + Gtk::ScrolledWindow *s = static_cast(_packable); + Gtk::TextView *tv = static_cast(s->get_child()); + tv->get_buffer()->set_text (text.c_str()); + } +} + + void EntityMultiLineEntry::on_changed() { -- cgit v1.2.3