diff options
| author | John Smith <john.smith7545@yahoo.com> | 2012-07-12 08:19:58 +0000 |
|---|---|---|
| committer | John Smith <john.smith7545@yahoo.com> | 2012-07-12 08:19:58 +0000 |
| commit | d9da2a4f178e71f5b33ea158c0631e86220f2e5d (patch) | |
| tree | 5502c8d1addd8f0b270877102185604c103936e8 /src/ui/widget | |
| parent | Fix for 1023655 : IMprovments to Embedded script UI (diff) | |
| download | inkscape-d9da2a4f178e71f5b33ea158c0631e86220f2e5d.tar.gz inkscape-d9da2a4f178e71f5b33ea158c0631e86220f2e5d.zip | |
Fix for 612221 : Add metadata default configuration in the preferences
(bzr r11544)
Diffstat (limited to 'src/ui/widget')
| -rw-r--r-- | src/ui/widget/entity-entry.cpp | 31 | ||||
| -rw-r--r-- | src/ui/widget/entity-entry.h | 4 |
2 files changed, 35 insertions, 0 deletions
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<Gtk::Entry*>(_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<Gtk::Entry*>(_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<Gtk::ScrolledWindow*>(_packable); + Gtk::TextView *tv = static_cast<Gtk::TextView*>(s->get_child()); + tv->get_buffer()->set_text (text.c_str()); + } +} + + void EntityMultiLineEntry::on_changed() { diff --git a/src/ui/widget/entity-entry.h b/src/ui/widget/entity-entry.h index 0e031bb0a..09289496d 100644 --- a/src/ui/widget/entity-entry.h +++ b/src/ui/widget/entity-entry.h @@ -31,6 +31,8 @@ public: virtual ~EntityEntry() = 0; virtual void update (SPDocument *doc) = 0; virtual void on_changed() = 0; + virtual void load_from_preferences() = 0; + void save_to_preferences(SPDocument *doc); Gtk::Label _label; Gtk::Widget *_packable; @@ -46,6 +48,7 @@ public: EntityLineEntry (rdf_work_entity_t* ent, Registry& wr); ~EntityLineEntry(); void update (SPDocument *doc); + void load_from_preferences(); protected: virtual void on_changed(); @@ -56,6 +59,7 @@ public: EntityMultiLineEntry (rdf_work_entity_t* ent, Registry& wr); ~EntityMultiLineEntry(); void update (SPDocument *doc); + void load_from_preferences(); protected: virtual void on_changed(); |
