diff options
Diffstat (limited to 'src/ui/widget/licensor.cpp')
| -rw-r--r-- | src/ui/widget/licensor.cpp | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/src/ui/widget/licensor.cpp b/src/ui/widget/licensor.cpp index d31d4b759..c729354cb 100644 --- a/src/ui/widget/licensor.cpp +++ b/src/ui/widget/licensor.cpp @@ -25,6 +25,7 @@ #include "rdf.h" #include "inkscape.h" #include "document-undo.h" +#include "document-private.h" #include "verbs.h" #include <gtkmm/radiobutton.h> @@ -43,7 +44,7 @@ const struct rdf_license_t _other_license = class LicenseItem : public Gtk::RadioButton { public: - LicenseItem (struct rdf_license_t const* license, EntityEntry* entity, Registry &wr); + LicenseItem (struct rdf_license_t const* license, EntityEntry* entity, Registry &wr, Gtk::RadioButtonGroup *group); protected: void on_toggled(); struct rdf_license_t const *_lic; @@ -51,13 +52,12 @@ protected: Registry &_wr; }; -LicenseItem::LicenseItem (struct rdf_license_t const* license, EntityEntry* entity, Registry &wr) +LicenseItem::LicenseItem (struct rdf_license_t const* license, EntityEntry* entity, Registry &wr, Gtk::RadioButtonGroup *group) : Gtk::RadioButton(_(license->name)), _lic(license), _eep(entity), _wr(wr) { - static Gtk::RadioButtonGroup group = get_group(); - static bool first = true; - if (first) first = false; - else set_group (group); + if (group) { + set_group (*group); + } } /// \pre it is assumed that the license URI entry is a Gtk::Entry @@ -66,9 +66,11 @@ void LicenseItem::on_toggled() if (_wr.isUpdating()) return; _wr.setUpdating (true); - rdf_set_license (SP_ACTIVE_DOCUMENT, _lic->details ? _lic : 0); - DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_NONE, - /* TODO: annotate */ "licensor.cpp:65"); + SPDocument *doc = SP_ACTIVE_DOCUMENT; + rdf_set_license (doc, _lic->details ? _lic : 0); + if (doc->priv->sensitive) { + DocumentUndo::done(doc, SP_VERB_NONE, "Document license updated"); + } _wr.setUpdating (false); static_cast<Gtk::Entry*>(_eep->_packable)->set_text (_lic->uri); _eep->on_changed(); @@ -77,7 +79,8 @@ void LicenseItem::on_toggled() //--------------------------------------------------- Licensor::Licensor() -: Gtk::VBox(false,4) +: Gtk::VBox(false,4), + _eentry (NULL) { } @@ -94,18 +97,19 @@ void Licensor::init (Registry& wr) LicenseItem *i; wr.setUpdating (true); - i = manage (new LicenseItem (&_proprietary_license, _eentry, wr)); + i = manage (new LicenseItem (&_proprietary_license, _eentry, wr, NULL)); + Gtk::RadioButtonGroup group = i->get_group(); add (*i); LicenseItem *pd = i; for (struct rdf_license_t * license = rdf_licenses; license && license->name; license++) { - i = manage (new LicenseItem (license, _eentry, wr)); + i = manage (new LicenseItem (license, _eentry, wr, &group)); add(*i); } // add Other at the end before the URI field for the confused ppl. - LicenseItem *io = manage (new LicenseItem (&_other_license, _eentry, wr)); + LicenseItem *io = manage (new LicenseItem (&_other_license, _eentry, wr, &group)); add (*io); pd->set_active(); @@ -130,10 +134,18 @@ void Licensor::update (SPDocument *doc) for (i=0; rdf_licenses[i].name; i++) if (license == &rdf_licenses[i]) break; +#if WITH_GTKMM_3_0 + static_cast<LicenseItem*>(get_children()[i+1])->set_active(); +#else static_cast<LicenseItem*>(children()[i+1].get_widget())->set_active(); +#endif } else { +#if WITH_GTKMM_3_0 + static_cast<LicenseItem*>(get_children()[0])->set_active(); +#else static_cast<LicenseItem*>(children()[0].get_widget())->set_active(); +#endif } /* update the URI */ |
