diff options
| author | Patrick Storz <eduard.braun2@gmx.de> | 2019-09-01 19:49:18 +0000 |
|---|---|---|
| committer | Patrick Storz <eduard.braun2@gmx.de> | 2019-09-01 19:50:16 +0000 |
| commit | 5e8e0a6bdd15427faa16d6432b9fbd7bbe0d6335 (patch) | |
| tree | 37dfb161397255903dd32fe27302fb308e5b9d4a /src | |
| parent | Add 'vector-effect' to CSS and attribute lists. (diff) | |
| parent | Update internal extensions for latest .inx format changes (diff) | |
| download | inkscape-5e8e0a6bdd15427faa16d6432b9fbd7bbe0d6335.tar.gz inkscape-5e8e0a6bdd15427faa16d6432b9fbd7bbe0d6335.zip | |
Extension updates for 1.0 (!808)
Diffstat (limited to 'src')
137 files changed, 5166 insertions, 4723 deletions
diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index eaa9b4956..5708c2ee0 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -11,7 +11,6 @@ set(extension_SRC input.cpp output.cpp patheffect.cpp - prefdialog.cpp print.cpp system.cpp timer.cpp @@ -21,17 +20,6 @@ set(extension_SRC implementation/xslt.cpp implementation/script.cpp - param/bool.cpp - param/color.cpp - param/description.cpp - param/enum.cpp - param/float.cpp - param/int.cpp - param/notebook.cpp - param/parameter.cpp - param/radiobutton.cpp - param/string.cpp - internal/bluredge.cpp internal/cairo-ps-out.cpp internal/cairo-render-context.cpp @@ -64,6 +52,23 @@ set(extension_SRC internal/pdfinput/pdf-parser.cpp internal/pdfinput/svg-builder.cpp + prefdialog/prefdialog.cpp + prefdialog/parameter.cpp + prefdialog/parameter-bool.cpp + prefdialog/parameter-color.cpp + prefdialog/parameter-float.cpp + prefdialog/parameter-int.cpp + prefdialog/parameter-notebook.cpp + prefdialog/parameter-optiongroup.cpp + prefdialog/parameter-path.cpp + prefdialog/parameter-string.cpp + prefdialog/widget.cpp + prefdialog/widget-box.cpp + prefdialog/widget-image.cpp + prefdialog/widget-label.cpp + prefdialog/widget-separator.cpp + prefdialog/widget-spacer.cpp + # ------ # Header db.h @@ -75,18 +80,7 @@ set(extension_SRC init.h input.h output.h - param/bool.h - param/color.h - param/description.h - param/enum.h - param/float.h - param/int.h - param/notebook.h - param/parameter.h - param/radiobutton.h - param/string.h patheffect.h - prefdialog.h print.h system.h timer.h @@ -137,6 +131,23 @@ set(extension_SRC internal/text_reassemble.h internal/wmf-inout.h internal/wmf-print.h + + prefdialog/prefdialog.h + prefdialog/parameter.h + prefdialog/parameter-bool.h + prefdialog/parameter-color.h + prefdialog/parameter-float.h + prefdialog/parameter-int.h + prefdialog/parameter-notebook.h + prefdialog/parameter-optiongroup.h + prefdialog/parameter-path.h + prefdialog/parameter-string.h + prefdialog/widget.h + prefdialog/widget-box.h + prefdialog/widget-image.h + prefdialog/widget-label.h + prefdialog/widget-separator.h + prefdialog/widget-spacer.h ) if(WIN32) diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp index 265b6f61a..21a9c238b 100644 --- a/src/extension/dbus/document-interface.cpp +++ b/src/extension/dbus/document-interface.cpp @@ -1447,7 +1447,7 @@ document_interface_get_children (DocumentInterface *doc_interface, char *name, gchar* document_interface_get_parent (DocumentInterface *doc_interface, char *name, GError **error) { - SPItem* node=(SPItem* )get_object_by_name(doc_interface->target.getDocument(), name, error); + SPItem*node=(SPItem* )get_object_by_name(doc_interface->target.getDocument(), name, error); SPObject* parent=node->parent; diff --git a/src/extension/dependency.h b/src/extension/dependency.h index 6c360785b..3532eefcb 100644 --- a/src/extension/dependency.h +++ b/src/extension/dependency.h @@ -60,7 +60,6 @@ public: virtual ~Dependency (); bool check () const; const gchar* get_name(); - Glib::ustring &get_help () const; Glib::ustring &get_link () const; friend std::ostream & operator<< (std::ostream &out_file, const Dependency & in_dep); diff --git a/src/extension/effect.cpp b/src/extension/effect.cpp index 3c9940240..db00a77a9 100644 --- a/src/extension/effect.cpp +++ b/src/extension/effect.cpp @@ -9,16 +9,17 @@ * Released under GNU GPL v2+, read the file 'COPYING' for more information. */ -#include "prefdialog.h" -#include "inkscape.h" -#include "helper/action.h" -#include "ui/view/view.h" - -#include "implementation/implementation.h" #include "effect.h" + #include "execution-env.h" +#include "inkscape.h" #include "timer.h" +#include "helper/action.h" +#include "implementation/implementation.h" +#include "prefdialog/prefdialog.h" +#include "ui/view/view.h" + /* Inkscape::Extension::Effect */ @@ -33,14 +34,11 @@ Inkscape::XML::Node * Effect::_filters_list = nullptr; #define EFFECTS_LIST "effects-list" #define FILTERS_LIST "filters-list" -Effect::Effect (Inkscape::XML::Node * in_repr, Implementation::Implementation * in_imp) - : Extension(in_repr, in_imp), - _id_noprefs(Glib::ustring(get_id()) + ".noprefs"), - _name_noprefs(Glib::ustring(_(get_name())) + _(" (No preferences)")), - _verb(get_id(), get_name(), nullptr, nullptr, this, true), - _verb_nopref(_id_noprefs.c_str(), _name_noprefs.c_str(), nullptr, nullptr, this, false), - _menu_node(nullptr), _workingDialog(true), - _prefDialog(nullptr) +Effect::Effect (Inkscape::XML::Node *in_repr, Implementation::Implementation *in_imp, std::string *base_directory) + : Extension(in_repr, in_imp, base_directory) + , _verb(get_id(), get_name(), nullptr, nullptr, this, true) + , _menu_node(nullptr), _workingDialog(true) + , _prefDialog(nullptr) { Inkscape::XML::Node * local_effects_menu = nullptr; @@ -107,8 +105,8 @@ Effect::Effect (Inkscape::XML::Node * in_repr, Implementation::Implementation * if (!hidden) { if (_filters_list && - local_effects_menu && - local_effects_menu->attribute("name") && + local_effects_menu && + local_effects_menu->attribute("name") && !strcmp(local_effects_menu->attribute("name"), ("Filters"))) { merge_menu(_filters_list->parent(), _filters_list, local_effects_menu->firstChild(), _menu_node); } else if (_effects_list) { @@ -129,24 +127,25 @@ Effect::merge_menu (Inkscape::XML::Node * base, Inkscape::XML::Node * tomerge = nullptr; Inkscape::XML::Node * submenu = nullptr; - /* printf("Merge menu with '%s' '%s' '%s'\n", - base != NULL ? base->name() : "NULL", - pattern != NULL ? pattern->name() : "NULL", - merge != NULL ? merge->name() : "NULL"); */ - if (pattern == nullptr) { // Merge the verb name tomerge = merge; - mergename = _(this->get_name()); + mergename = get_translation(get_name()); } else { - gchar const * menuname = pattern->attribute("name"); + gchar const *menuname = pattern->attribute("name"); if (menuname == nullptr) menuname = pattern->attribute("_name"); if (menuname == nullptr) return; - + Inkscape::XML::Document *xml_doc; xml_doc = base->document(); tomerge = xml_doc->createElement("submenu"); - mergename = _(menuname); + if (_translation_enabled) { + mergename = get_translation(menuname); + } else { + // Even if the extension author requested the extension not to be translated, + // it still seems desirable to be able to put the extension into the existing (translated) submenus. + mergename = _(menuname); + } tomerge->setAttribute("name", mergename, false); } @@ -240,7 +239,7 @@ Effect::prefs (Inkscape::UI::View::View * doc) return true; } - if (param_visible_count() == 0) { + if (widget_visible_count() == 0) { effect(doc); return true; } @@ -249,7 +248,8 @@ Effect::prefs (Inkscape::UI::View::View * doc) set_state(Extension::STATE_LOADED); if (!loaded()) return false; - _prefDialog = new PrefDialog(this->get_name(), this->get_help(), nullptr, this); + Glib::ustring name = get_translation(this->get_name()); + _prefDialog = new PrefDialog(name, nullptr, this); _prefDialog->show(); return true; @@ -288,7 +288,7 @@ Effect::effect (Inkscape::UI::View::View * doc) /** \brief Sets which effect was called last \param in_effect The effect that has been called - + This function sets the static variable \c _last_effect and it ensures that the last effect verb is sensitive. diff --git a/src/extension/effect.h b/src/extension/effect.h index 1eb04cd15..39412dda5 100644 --- a/src/extension/effect.h +++ b/src/extension/effect.h @@ -68,17 +68,17 @@ class Effect : public Extension { Effect * effect, bool showPrefs) : Verb(id, _(name), _(tip), image, _("Extensions")), - _effect(effect), + _effect(effect), _showPrefs(showPrefs), _elip_name(nullptr) { /* No clue why, but this is required */ this->set_default_sensitive(true); - if (_showPrefs && effect != nullptr && effect->param_visible_count() != 0) { + if (_showPrefs && effect != nullptr && effect->widget_visible_count() != 0) { _elip_name = g_strdup_printf("%s...", _(name)); set_name(_elip_name); } } - + /** \brief Destructor */ ~EffectVerb() override { if (_elip_name != nullptr) { @@ -87,15 +87,8 @@ class Effect : public Extension { } }; - /** \brief ID used for the verb without preferences */ - Glib::ustring _id_noprefs; - /** \brief Name used for the verb without preferences */ - Glib::ustring _name_noprefs; - /** \brief The verb representing this effect. */ EffectVerb _verb; - /** \brief The verb representing this effect. Without preferences. */ - EffectVerb _verb_nopref; /** \brief Menu node created for this effect */ Inkscape::XML::Node * _menu_node; /** \brief Whether a working dialog should be shown */ @@ -104,10 +97,11 @@ class Effect : public Extension { /** \brief The preference dialog if it is shown */ PrefDialog * _prefDialog; public: - Effect (Inkscape::XML::Node * in_repr, - Implementation::Implementation * in_imp); - ~Effect () override; - bool check () override; + Effect(Inkscape::XML::Node *in_repr, Implementation::Implementation *in_imp, std::string *base_directory); + ~Effect () override; + + bool check() override; + bool prefs (Inkscape::UI::View::View * doc); void effect (Inkscape::UI::View::View * doc); /** \brief Accessor function for a pointer to the verb */ diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp index ca770e1f6..9293e5655 100644 --- a/src/extension/execution-env.cpp +++ b/src/extension/execution-env.cpp @@ -13,7 +13,7 @@ #include <gtkmm/messagedialog.h> #include "execution-env.h" -#include "prefdialog.h" +#include "prefdialog/prefdialog.h" #include "implementation/implementation.h" #include "selection.h" @@ -127,17 +127,15 @@ ExecutionEnv::createWorkingDialog () { _visibleDialog->signal_response().connect(sigc::mem_fun(this, &ExecutionEnv::workingCanceled)); g_free(dlgmessage); - if (!_effect->is_silent()){ - Gtk::Dialog *dlg = _effect->get_pref_dialog(); - if (dlg) { - _visibleDialog->set_transient_for(*dlg); - } else { - // ToDo: Do we need to make the window transient for the main window here? - // Currently imossible to test because of GUI freezing during save, - // see https://bugs.launchpad.net/inkscape/+bug/967416 - } - _visibleDialog->show_now(); + Gtk::Dialog *dlg = _effect->get_pref_dialog(); + if (dlg) { + _visibleDialog->set_transient_for(*dlg); + } else { + // ToDo: Do we need to make the window transient for the main window here? + // Currently imossible to test because of GUI freezing during save, + // see https://bugs.launchpad.net/inkscape/+bug/967416 } + _visibleDialog->show_now(); return; } diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp index 77a171487..b8c3242a5 100644 --- a/src/extension/extension.cpp +++ b/src/extension/extension.cpp @@ -16,22 +16,28 @@ * Released under GNU GPL v2+, read the file 'COPYING' for more information. */ +#include "extension.h" +#include "implementation/implementation.h" + +#include <glibmm/i18n.h> #include <gtkmm/box.h> -#include <gtkmm/label.h> #include <gtkmm/frame.h> #include <gtkmm/grid.h> - -#include <glibmm/i18n.h> -#include "inkscape.h" -#include "extension/implementation/implementation.h" -#include "extension.h" +#include <gtkmm/label.h> #include "db.h" #include "dependency.h" +#include "inkscape.h" #include "timer.h" -#include "param/parameter.h" + #include "io/resource.h" +#include "prefdialog/parameter.h" +#include "prefdialog/widget.h" + +#include "xml/repr.h" + + namespace Inkscape { namespace Extension { @@ -42,7 +48,8 @@ std::ofstream Extension::error_file; /** \return none \brief Constructs an Extension from a Inkscape::XML::Node - \param in_repr The repr that should be used to build it + \param in_repr The repr that should be used to build it + \param base_directory Base directory of extension that were loaded from a file (.inx file's location) This function is the basis of building an extension for Inkscape. It currently extracts the fields from the Repr that are used in the @@ -50,18 +57,13 @@ std::ofstream Extension::error_file; not related to the module directly. If the Repr does not include a name and an ID the module will be left in an errored state. */ -Extension::Extension (Inkscape::XML::Node * in_repr, Implementation::Implementation * in_imp) - : _help(nullptr) - , silent(false) - , _gui(true) +Extension::Extension(Inkscape::XML::Node *in_repr, Implementation::Implementation *in_imp, std::string *base_directory) + : _gui(true) , execution_env(nullptr) { + g_return_if_fail(in_repr); // should be ensured in system.cpp repr = in_repr; - Inkscape::GC::anchor(in_repr); - - id = nullptr; - name = nullptr; - _state = STATE_UNLOADED; + Inkscape::GC::anchor(repr); if (in_imp == nullptr) { imp = new Implementation::Implementation(); @@ -69,56 +71,76 @@ Extension::Extension (Inkscape::XML::Node * in_repr, Implementation::Implementat imp = in_imp; } - // printf("Extension Constructor: "); - if (repr != nullptr) { - Inkscape::XML::Node *child_repr = repr->firstChild(); - /* TODO: Handle what happens if we don't have these two */ - while (child_repr != nullptr) { - char const * chname = child_repr->name(); - if (!strncmp(chname, INKSCAPE_EXTENSION_NS_NC, strlen(INKSCAPE_EXTENSION_NS_NC))) { - chname += strlen(INKSCAPE_EXTENSION_NS); - } - if (chname[0] == '_') /* Allow _ for translation of tags */ - chname++; - if (!strcmp(chname, "id")) { - gchar const *val = child_repr->firstChild()->content(); - id = g_strdup (val); - } /* id */ - if (!strcmp(chname, "name")) { - name = g_strdup (child_repr->firstChild()->content()); - } /* name */ - if (!strcmp(chname, "help")) { - _help = g_strdup (child_repr->firstChild()->content()); - } /* name */ - if (!strcmp(chname, "param") || !strcmp(chname, "_param")) { - Parameter * param; - param = Parameter::make(child_repr, this); - if (param != nullptr) - parameters.push_back(param); - } /* param || _param */ - if (!strcmp(chname, "dependency")) { - _deps.push_back(new Dependency(child_repr)); - } /* dependency */ - if (!strcmp(chname, "script")) { - for (Inkscape::XML::Node *child = child_repr->firstChild(); child != nullptr ; child = child->next()) { - if (child->type() == Inkscape::XML::ELEMENT_NODE) { - _deps.push_back(new Dependency(child)); - break; - } /* skip non-element nodes (see LP #1372200) */ + if (base_directory) { + _base_directory = *base_directory; + } + + // get name of the translation catalog ("gettext textdomain") that the extension wants to use for translations + const char *translationdomain = repr->attribute("translationdomain"); + if (translationdomain) { + _translationdomain = g_strdup(translationdomain); + + // special keyword "none" means the extension author does not want translation of extension strings + if (!strcmp(translationdomain, "none")) { + _translation_enabled = false; + } + } + + // Read XML tree and parse extension + Inkscape::XML::Node *child_repr = repr->firstChild(); + while (child_repr) { + const char *chname = child_repr->name(); + if (!strncmp(chname, INKSCAPE_EXTENSION_NS_NC, strlen(INKSCAPE_EXTENSION_NS_NC))) { + chname += strlen(INKSCAPE_EXTENSION_NS); + } + if (chname[0] == '_') { // allow leading underscore in tag names for backwards-compatibility + chname++; + } + + if (!strcmp(chname, "id")) { + const char *id = child_repr->firstChild() ? child_repr->firstChild()->content() : nullptr; + if (id) { + _id = g_strdup(id); + } else { + throw extension_no_id(); + } + } else if (!strcmp(chname, "name")) { + const char *name = child_repr->firstChild() ? child_repr->firstChild()->content() : nullptr; + if (name) { + _name = g_strdup(name); + } else { + throw extension_no_name(); + } + } else if (InxWidget::is_valid_widget_name(chname)) { + InxWidget *widget = InxWidget::make(child_repr, this); + if (widget) { + _widgets.push_back(widget); + } + } else if (!strcmp(chname, "dependency")) { + _deps.push_back(new Dependency(child_repr)); + } else if (!strcmp(chname, "script")) { // check command as a dependency (see LP #505920) + for (Inkscape::XML::Node *child = child_repr->firstChild(); child != nullptr; child = child->next()) { + if (child->type() == Inkscape::XML::ELEMENT_NODE) { // skip non-element nodes (see LP #1372200) + _deps.push_back(new Dependency(child)); + break; } - } /* check command as a dependency (see LP #505920) */ - if (!strcmp(chname, "options")) { - silent = !strcmp( child_repr->attribute("silent"), "true" ); } - child_repr = child_repr->next(); + } else { + // We could do some sanity checking here. + // However, we don't really know which additional elements Extension subclasses might need... } - db.register_ext (this); + child_repr = child_repr->next(); } - // printf("%s\n", name); - timer = nullptr; - return; + // register extension if we have an id and a name + if (!_id) { + throw extension_no_id(); + } + if (!_name) { + throw extension_no_name(); + } + db.register_ext (this); } /** @@ -132,27 +154,26 @@ Extension::Extension (Inkscape::XML::Node * in_repr, Implementation::Implementat */ Extension::~Extension () { -// printf("Extension Destructor: %s\n", name); set_state(STATE_UNLOADED); + db.unregister_ext(this); + Inkscape::GC::release(repr); - g_free(id); - g_free(name); + + g_free(_id); + g_free(_name); + delete timer; timer = nullptr; - /** \todo Need to do parameters here */ - // delete parameters: - for (auto param:parameters) { - delete param; + for (auto widget : _widgets) { + delete widget; } for (auto & _dep : _deps) { delete _dep; } _deps.clear(); - - return; } /** @@ -250,9 +271,6 @@ Extension::check () { bool retval = true; - // static int i = 0; - // std::cout << "Checking module[" << i++ << "]: " << name << std::endl; - const char * inx_failure = _(" This is caused by an improper .inx file for this extension." " An improper .inx file could have been caused by a faulty installation of Inkscape."); @@ -261,20 +279,12 @@ Extension::check () #ifndef _WIN32 const char* win_ext[] = {"com.vaxxine.print.win32"}; std::vector<std::string> v (win_ext, win_ext + sizeof(win_ext)/sizeof(win_ext[0])); - std::string ext_id(id); + std::string ext_id(_id); if (std::find(v.begin(), v.end(), ext_id) != v.end()) { printFailure(Glib::ustring(_("the extension is designed for Windows only.")) + inx_failure); retval = false; } #endif - if (id == nullptr) { - printFailure(Glib::ustring(_("an ID was not defined for it.")) + inx_failure); - retval = false; - } - if (name == nullptr) { - printFailure(Glib::ustring(_("there was no name defined for it.")) + inx_failure); - retval = false; - } if (repr == nullptr) { printFailure(Glib::ustring(_("the XML description of it got lost.")) + inx_failure); retval = false; @@ -307,7 +317,7 @@ Extension::check () void Extension::printFailure (Glib::ustring reason) { - error_file << _("Extension \"") << name << _("\" failed to load because "); + error_file << _("Extension \"") << _name << _("\" failed to load because "); error_file << reason.raw(); error_file << std::endl; return; @@ -324,23 +334,13 @@ Extension::get_repr () } /** - \return bool - \brief Whether this extension should hide the "working, please wait" dialog -*/ -bool -Extension::is_silent () -{ - return silent; -} - -/** \return The textual id of this extension \brief Get the ID of this extension - not a copy don't delete! */ gchar * Extension::get_id () { - return id; + return _id; } /** @@ -350,7 +350,7 @@ Extension::get_id () gchar * Extension::get_name () { - return name; + return _name; } /** @@ -391,260 +391,296 @@ Extension::deactivated () return get_state() == STATE_DEACTIVATED; } -Parameter *Extension::get_param(gchar const *name) -{ - if (name == nullptr) { - throw Extension::param_not_exist(); +/** Gets a translation within the context of the current extension + * + * Query gettext for the translated version of the input string, + * handling the preferred translation domain of the extension internally. + * + * @param msgid String to translate + * @param msgctxt Context for the translation + * + * @return Translated string (or original string if extension is not supposed to be translated) + */ +const char *Extension::get_translation(const char *msgid, const char *msgctxt) { + if (!_translation_enabled) { + return msgid; } - if (this->parameters.empty()) { - throw Extension::param_not_exist(); + + // Note: _translationdomain might be NULL, which is fine. + // We will simply default to the domain set via textdomain() in this case (which should be 'inkscape') + if (msgctxt) { + return g_dpgettext2(_translationdomain, msgctxt, msgid); + } else { + return g_dgettext(_translationdomain, msgid); } +} - for( auto param:this->parameters) { - if (!strcmp(param->name(), name)) { - return param; - } else { - Parameter * subparam = param->get_param(name); - if (subparam) { - return subparam; +/** + \brief A function to get the parameters in a string form + \return An array with all the parameters in it. + +*/ +void +Extension::paramListString (std::list <std::string> &retlist) +{ + // first collect all widgets in the current extension + std::vector<InxWidget *> widget_list; + for (auto widget : _widgets) { + widget->get_widgets(widget_list); + } + + // then build a list of parameter strings from parameter names and values, as '--name=value' + for (auto widget : widget_list) { + InxParameter *parameter = dynamic_cast<InxParameter *>(widget); // filter InxParameters from InxWidgets + if (parameter) { + const char *name = parameter->name(); + std::string value = parameter->value_to_string(); + + if (name && !value.empty()) { // TODO: Shouldn't empty string values be allowed? + std::string parameter_string; + parameter_string += "--"; + parameter_string += name; + parameter_string += "="; + parameter_string += value; + retlist.push_back(parameter_string); } } } - // if execution reaches here, no parameter matching 'name' was found - throw Extension::param_not_exist(); + return; } -Parameter const *Extension::get_param(const gchar * name) const +InxParameter *Extension::get_param(const gchar *name) { - return const_cast<Extension *>(this)->get_param(name); -} + if (!name || _widgets.empty()) { + throw Extension::param_not_exist(); + } -gchar const *Extension::get_param_string(gchar const *name, SPDocument const *doc, Inkscape::XML::Node const *node) const -{ - Parameter const *param = get_param(name); - return param->get_string(doc, node); -} + // first collect all widgets in the current extension + std::vector<InxWidget *> widget_list; + for (auto widget : _widgets) { + widget->get_widgets(widget_list); + } -const gchar * -Extension::get_param_enum (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node) const -{ - Parameter const *param = get_param(name); - return param->get_enum(doc, node); -} + // then search for a parameter with a matching name + for (auto widget : widget_list) { + InxParameter *parameter = dynamic_cast<InxParameter *>(widget); // filter InxParameters from InxWidgets + if (parameter && !strcmp(parameter->name(), name)) { + return parameter; + } + } -/** - * This is useful to find out, if a given string \c value is selectable in a ComboBox named \cname. - * - * @param name The name of the enum parameter to get. - * @param doc The document to look in for document specific parameters. - * @param node The node to look in for a specific parameter. - * @return true if value exists, false if not - */ -bool -Extension::get_param_enum_contains(gchar const * name, gchar const * value, SPDocument * doc, Inkscape::XML::Node * node) const -{ - Parameter const *param = get_param(name); - return param->get_enum_contains(value, doc, node); + // if execution reaches here, no parameter matching 'name' was found + throw Extension::param_not_exist(); } -gchar const * -Extension::get_param_optiongroup( gchar const * name, SPDocument const * doc, Inkscape::XML::Node const * node) const +InxParameter const *Extension::get_param(const gchar *name) const { - Parameter const*param = get_param(name); - return param->get_optiongroup(doc, node); + return const_cast<Extension *>(this)->get_param(name); } /** \return The value of the parameter identified by the name - \brief Gets a parameter identified by name with the bool placed - in value. - \param name The name of the parameter to get - \param doc The document to look in for document specific parameters - \param node The node to look in for a specific parameter - - Look up in the parameters list, then execute the function on that - found parameter. + \brief Gets a parameter identified by name with the bool placed in value. + \param name The name of the parameter to get + + Look up in the parameters list, const then execute the function on that found parameter. */ bool -Extension::get_param_bool (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node) +Extension::get_param_bool(const gchar *name) const { - Parameter * param; + const InxParameter *param; param = get_param(name); - return param->get_bool(doc, node); + return param->get_bool(); } /** \return The integer value for the parameter specified - \brief Gets a parameter identified by name with the integer placed - in value. - \param name The name of the parameter to get - \param doc The document to look in for document specific parameters - \param node The node to look in for a specific parameter - - Look up in the parameters list, then execute the function on that - found parameter. + \brief Gets a parameter identified by name with the integer placed in value. + \param name The name of the parameter to get + + Look up in the parameters list, const then execute the function on that found parameter. */ int -Extension::get_param_int (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node) +Extension::get_param_int(const gchar *name) const { - Parameter * param; + const InxParameter *param; param = get_param(name); - return param->get_int(doc, node); + return param->get_int(); } /** \return The float value for the parameter specified - \brief Gets a parameter identified by name with the float placed - in value. - \param name The name of the parameter to get - \param doc The document to look in for document specific parameters - \param node The node to look in for a specific parameter - - Look up in the parameters list, then execute the function on that - found parameter. + \brief Gets a parameter identified by name with the float in value. + \param name The name of the parameter to get + + Look up in the parameters list, const then execute the function on that found parameter. */ float -Extension::get_param_float (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node) +Extension::get_param_float(const gchar *name) const { - Parameter * param; + const InxParameter *param; param = get_param(name); - return param->get_float(doc, node); + return param->get_float(); } /** \return The string value for the parameter specified - \brief Gets a parameter identified by name with the float placed - in value. - \param name The name of the parameter to get - \param doc The document to look in for document specific parameters - \param node The node to look in for a specific parameter - - Look up in the parameters list, then execute the function on that - found parameter. + \brief Gets a parameter identified by name with the string placed in value. + \param name The name of the parameter to get + + Look up in the parameters list, const then execute the function on that found parameter. +*/ +const char * +Extension::get_param_string(const gchar *name) const +{ + const InxParameter *param; + param = get_param(name); + return param->get_string(); +} + +/** + \return The string value for the parameter specified + \brief Gets a parameter identified by name with the string placed in value. + \param name The name of the parameter to get + + Look up in the parameters list, const then execute the function on that found parameter. +*/ +const char * +Extension::get_param_optiongroup(const gchar *name) const +{ + const InxParameter *param; + param = get_param(name); + return param->get_optiongroup(); +} + +/** + * This is useful to find out, if a given string \c value is selectable in a optiongroup named \cname. + * + * @param name The name of the optiongroup parameter to get. + * @return true if value exists, false if not + */ +bool +Extension::get_param_optiongroup_contains(const gchar *name, const char *value) const +{ + const InxParameter *param; + param = get_param(name); + return param->get_optiongroup_contains(value); +} + +/** + \return The unsigned integer RGBA value for the parameter specified + \brief Gets a parameter identified by name with the unsigned int placed in value. + \param name The name of the parameter to get + + Look up in the parameters list, const then execute the function on that found parameter. */ guint32 -Extension::get_param_color (const gchar * name, const SPDocument * doc, const Inkscape::XML::Node * node) const +Extension::get_param_color(const gchar *name) const { - Parameter const *param = get_param(name); - return param->get_color(doc, node); + const InxParameter *param; + param = get_param(name); + return param->get_color(); } /** \return The passed in value - \brief Sets a parameter identified by name with the boolean - in the parameter value. - \param name The name of the parameter to set - \param value The value to set the parameter to - \param doc The document to look in for document specific parameters - \param node The node to look in for a specific parameter - - Look up in the parameters list, then execute the function on that - found parameter. + \brief Sets a parameter identified by name with the boolean in the parameter value. + \param name The name of the parameter to set + \param value The value to set the parameter to + + Look up in the parameters list, const then execute the function on that found parameter. */ bool -Extension::set_param_bool (const gchar * name, bool value, SPDocument * doc, Inkscape::XML::Node * node) +Extension::set_param_bool(const gchar *name, const bool value) { - Parameter * param; + InxParameter *param; param = get_param(name); - return param->set_bool(value, doc, node); + return param->set_bool(value); } /** \return The passed in value - \brief Sets a parameter identified by name with the integer - in the parameter value. - \param name The name of the parameter to set - \param value The value to set the parameter to - \param doc The document to look in for document specific parameters - \param node The node to look in for a specific parameter - - Look up in the parameters list, then execute the function on that - found parameter. + \brief Sets a parameter identified by name with the integer in the parameter value. + \param name The name of the parameter to set + \param value The value to set the parameter to + + Look up in the parameters list, const then execute the function on that found parameter. */ int -Extension::set_param_int (const gchar * name, int value, SPDocument * doc, Inkscape::XML::Node * node) +Extension::set_param_int(const gchar *name, const int value) { - Parameter * param; + InxParameter *param; param = get_param(name); - return param->set_int(value, doc, node); + return param->set_int(value); } /** \return The passed in value - \brief Sets a parameter identified by name with the integer - in the parameter value. - \param name The name of the parameter to set - \param value The value to set the parameter to - \param doc The document to look in for document specific parameters - \param node The node to look in for a specific parameter - - Look up in the parameters list, then execute the function on that - found parameter. + \brief Sets a parameter identified by name with the float in the parameter value. + \param name The name of the parameter to set + \param value The value to set the parameter to + + Look up in the parameters list, const then execute the function on that found parameter. */ float -Extension::set_param_float (const gchar * name, float value, SPDocument * doc, Inkscape::XML::Node * node) +Extension::set_param_float(const gchar *name, const float value) { - Parameter * param; + InxParameter *param; param = get_param(name); - return param->set_float(value, doc, node); + return param->set_float(value); } /** \return The passed in value - \brief Sets a parameter identified by name with the string - in the parameter value. - \param name The name of the parameter to set - \param value The value to set the parameter to - \param doc The document to look in for document specific parameters - \param node The node to look in for a specific parameter - - Look up in the parameters list, then execute the function on that - found parameter. + \brief Sets a parameter identified by name with the string in the parameter value. + \param name The name of the parameter to set + \param value The value to set the parameter to + + Look up in the parameters list, const then execute the function on that found parameter. */ -const gchar * -Extension::set_param_string (const gchar * name, const gchar * value, SPDocument * doc, Inkscape::XML::Node * node) +const char * +Extension::set_param_string(const gchar *name, const char *value) { - Parameter * param; + InxParameter *param; param = get_param(name); - return param->set_string(value, doc, node); + return param->set_string(value); } -gchar const * -Extension::set_param_optiongroup(gchar const * name, gchar const * value, SPDocument * doc, Inkscape::XML::Node * node) -{ - Parameter * param = get_param(name); - return param->set_optiongroup(value, doc, node); -} +/** + \return The passed in value + \brief Sets a parameter identified by name with the string in the parameter value. + \param name The name of the parameter to set + \param value The value to set the parameter to -gchar const * -Extension::set_param_enum(gchar const * name, gchar const * value, SPDocument * doc, Inkscape::XML::Node * node) + Look up in the parameters list, const then execute the function on that found parameter. +*/ +const char * +Extension::set_param_optiongroup(const gchar *name, const char *value) { - Parameter * param = get_param(name); - return param->set_enum(value, doc, node); + InxParameter *param; + param = get_param(name); + return param->set_optiongroup(value); } - /** \return The passed in value - \brief Sets a parameter identified by name with the string - in the parameter value. - \param name The name of the parameter to set - \param value The value to set the parameter to - \param doc The document to look in for document specific parameters - \param node The node to look in for a specific parameter - - Look up in the parameters list, then execute the function on that - found parameter. + \brief Sets a parameter identified by name with the unsigned integer RGBA value in the parameter value. + \param name The name of the parameter to set + \param value The value to set the parameter to + +Look up in the parameters list, const then execute the function on that found parameter. */ guint32 -Extension::set_param_color (const gchar * name, guint32 color, SPDocument * doc, Inkscape::XML::Node * node) +Extension::set_param_color(const gchar *name, const guint32 color) { - Parameter* param = get_param(name); - return param->set_color(color, doc, node); + InxParameter *param; + param = get_param(name); + return param->set_color(color); } + /** \brief A function to open the error log file. */ void Extension::error_file_open () @@ -685,8 +721,9 @@ public: */ void addWidget(Gtk::Widget *widg, gchar const *tooltip, int indent) { if (widg) { - widg->set_margin_start(indent * Parameter::GUI_INDENTATION); - this->pack_start(*widg, false, false, 0); + widg->set_margin_start(indent * InxParameter::GUI_INDENTATION); + this->pack_start(*widg, false, true, 0); // fill=true does not have an effect here, but allows the + // child to choose to expand by setting hexpand/vexpand if (tooltip) { widg->set_tooltip_text(tooltip); } else { @@ -697,31 +734,35 @@ public: }; }; -/** \brief A function to automatically generate a GUI using the parameters +/** \brief A function to automatically generate a GUI from the extensions' widgets \return Generated widget - This function just goes through each parameter, and calls it's 'get_widget' - function to get each widget. Then, each of those is placed into - a Gtk::VBox, which is then returned to the calling function. + This function just goes through each widget, and calls it's 'get_widget'. + Then, each of those is placed into a Gtk::VBox, which is then returned to the calling function. If there are no visible parameters, this function just returns NULL. - If all parameters are gui_hidden = true NULL is returned as well. */ Gtk::Widget * -Extension::autogui (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) +Extension::autogui (SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<void> *changeSignal) { - if (!_gui || param_visible_count() == 0) return nullptr; + if (!_gui || widget_visible_count() == 0) { + return nullptr; + } AutoGUI * agui = Gtk::manage(new AutoGUI()); - agui->set_border_width(Parameter::GUI_BOX_MARGIN); - agui->set_spacing(Parameter::GUI_BOX_SPACING); - - //go through the list of parameters to see if there are any non-hidden ones - for (auto param:parameters) { - if (param->get_hidden()) continue; //Ignore hidden parameters - Gtk::Widget * widg = param->get_widget(doc, node, changeSignal); - gchar const * tip = param->get_tooltip(); - int indent = param->get_indent(); + agui->set_border_width(InxParameter::GUI_BOX_MARGIN); + agui->set_spacing(InxParameter::GUI_BOX_SPACING); + + // go through the list of widgets and add the all non-hidden ones + for (auto widget : _widgets) { + if (widget->get_hidden()) { + continue; + } + + Gtk::Widget *widg = widget->get_widget(changeSignal); + gchar const *tip = widget->get_tooltip(); + int indent = widget->get_indent(); + agui->addWidget(widg, tip, indent); } @@ -729,21 +770,6 @@ Extension::autogui (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<v return agui; }; -/** - \brief A function to get the parameters in a string form - \return An array with all the parameters in it. - -*/ -void -Extension::paramListString (std::list <std::string> &retlist) -{ - for(auto param:parameters) { - param->string(retlist); - } - - return; -} - /* Extension editor dialog stuff */ Gtk::VBox * @@ -762,8 +788,8 @@ Extension::get_info_widget() info->add(*table); int row = 0; - add_val(_("Name:"), _(name), table, &row); - add_val(_("ID:"), id, table, &row); + add_val(_("Name:"), get_translation(_name), table, &row); + add_val(_("ID:"), _id, table, &row); add_val(_("State:"), _state == STATE_LOADED ? _("Loaded") : _state == STATE_UNLOADED ? _("Unloaded") : _("Deactivated"), table, &row); retval->show_all(); @@ -789,29 +815,6 @@ void Extension::add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Gri } Gtk::VBox * -Extension::get_help_widget() -{ - Gtk::VBox * retval = Gtk::manage(new Gtk::VBox()); - retval->set_border_width(4); - - if (_help == nullptr) { - Gtk::Label * content = Gtk::manage(new Gtk::Label(_("Currently there is no help available for this Extension. Please look on the Inkscape website or ask on the mailing lists if you have questions regarding this extension."))); - content->set_xalign(0); - content->set_yalign(0); - retval->pack_start(*content, true, true, 4); - content->set_line_wrap(true); - content->show(); - } else { - - - - } - - retval->show(); - return retval; -} - -Gtk::VBox * Extension::get_params_widget() { Gtk::VBox * retval = Gtk::manage(new Gtk::VBox()); @@ -822,11 +825,13 @@ Extension::get_params_widget() return retval; } -unsigned int Extension::param_visible_count ( ) +unsigned int Extension::widget_visible_count ( ) { unsigned int _visible_count = 0; - for (auto param:parameters) { - if (!param->get_hidden()) _visible_count++; + for (auto widget : _widgets) { + if (!widget->get_hidden()) { + _visible_count++; + } } return _visible_count; } diff --git a/src/extension/extension.h b/src/extension/extension.h index 619cb588e..d28ba2efc 100644 --- a/src/extension/extension.h +++ b/src/extension/extension.h @@ -15,13 +15,17 @@ * Released under GNU GPL v2+, read the file 'COPYING' for more information. */ -#include <ostream> #include <fstream> +#include <ostream> #include <vector> -#include <glibmm/ustring.h> -#include "xml/repr.h" + +#include <glib.h> #include <sigc++/signal.h> +namespace Glib { + class ustring; +} + namespace Gtk { class Grid; class VBox; @@ -70,13 +74,19 @@ namespace Gtk { class SPDocument; namespace Inkscape { + +namespace XML { +class Node; +} + namespace Extension { class ExecutionEnv; class Dependency; class ExpirationTimer; class ExpirationTimer; -class Parameter; +class InxParameter; +class InxWidget; namespace Implementation { @@ -99,25 +109,28 @@ public: }; private: - gchar *id; /**< The unique identifier for the Extension */ - gchar *name; /**< A user friendly name for the Extension */ - gchar *_help; /**< A string that contains a help text for the user */ - state_t _state; /**< Which state the Extension is currently in */ - std::vector<Dependency *> _deps; /**< Dependencies for this extension */ - static std::ofstream error_file; /**< This is the place where errors get reported */ - bool silent; + gchar *_id = nullptr; /**< The unique identifier for the Extension */ + gchar *_name = nullptr; /**< A user friendly name for the Extension */ + state_t _state = STATE_UNLOADED; /**< Which state the Extension is currently in */ + std::vector<Dependency *> _deps; /**< Dependencies for this extension */ + static std::ofstream error_file; /**< This is the place where errors get reported */ bool _gui; protected: - Inkscape::XML::Node *repr; /**< The XML description of the Extension */ - Implementation::Implementation * imp; /**< An object that holds all the functions for making this work */ - ExecutionEnv * execution_env; /**< Execution environment of the extension (currently only used by Effects) */ - ExpirationTimer * timer; /**< Timeout to unload after a given time */ + Inkscape::XML::Node *repr; /**< The XML description of the Extension */ + Implementation::Implementation * imp; /**< An object that holds all the functions for making this work */ + ExecutionEnv * execution_env; /**< Execution environment of the extension + * (currently only used by Effects) */ + std::string _base_directory; /**< Directory containing the .inx file, + * relative paths in the extension should usually be relative to it */ + ExpirationTimer * timer = nullptr; /**< Timeout to unload after a given time */ + bool _translation_enabled = true; /**< Attempt translation of strings provided by the extension? */ + const char *_translationdomain = nullptr; /**< Domainname of gettext textdomain that should + * be used for translation of the extension's strings */ public: - Extension (Inkscape::XML::Node * in_repr, - Implementation::Implementation * in_imp); - virtual ~Extension (); + Extension(Inkscape::XML::Node *in_repr, Implementation::Implementation *in_imp, std::string *base_directory); + virtual ~Extension(); void set_state (state_t in_state); state_t get_state (); @@ -126,53 +139,36 @@ public: Inkscape::XML::Node * get_repr (); gchar * get_id (); gchar * get_name (); - /** \brief Gets the help string for this extension */ - gchar const * get_help () { return _help; } - bool is_silent (); void deactivate (); bool deactivated (); void printFailure (Glib::ustring reason); Implementation::Implementation * get_imp () { return imp; }; void set_execution_env (ExecutionEnv * env) { execution_env = env; }; ExecutionEnv *get_execution_env () { return execution_env; }; + std::string get_base_directory() { return _base_directory; }; + void set_base_directory(std::string base_directory) { _base_directory = base_directory; }; + const char *get_translation(const char* msgid, const char *msgctxt=nullptr); /* Parameter Stuff */ private: - std::vector<Parameter *> parameters; /**< A table to store the parameters for this extension. - This only gets created if there are parameters in this - extension */ + std::vector<InxWidget *> _widgets; /**< A list of widgets for this extension. */ public: - /** \brief A function to get the number of parameters that - the extension has. - \return The number of parameters. */ - unsigned int param_count ( ) { return parameters.size(); }; - /** \brief A function to get the number of parameters that - are visible to the user that the extension has. - \return The number of visible parameters. - - \note Currently this just calls param_count as visible isn't implemented - but in the future it'll do something different. Please call - the appropriate function in code so that it'll work in the - future. - */ - unsigned int param_visible_count ( ); + /** \brief A function to get the number of visible parameters of the extension. + \return The number of visible parameters. */ + unsigned int widget_visible_count ( ); public: - /** An error class for when a parameter is called on a type it is not */ - class param_wrong_type {}; - class param_not_color_param {}; - class param_not_enum_param {}; - class param_not_optiongroup_param {}; - class param_not_string_param {}; - class param_not_float_param {}; - class param_not_int_param {}; - class param_not_bool_param {}; - /** An error class for when a parameter is looked for that just * simply doesn't exist */ class param_not_exist {}; + /** no valid ID found while parsing XML representation */ + class extension_no_id{}; + + /** no valid name found while parsing XML representation */ + class extension_no_name{}; + /** An error class for when a filename already exists, but the user * doesn't want to overwrite it */ class no_overwrite {}; @@ -181,106 +177,38 @@ private: void make_param (Inkscape::XML::Node * paramrepr); /** - * This function looks through the linked list for a parameter - * structure with the name of the passed in name. + * Looks up the parameter with the specified name. * - * This is an inline function that is used by all the get_param and - * set_param functions to find a param_t in the linked list with - * the passed in name. + * Searches the list of parameters attached to this extension, + * looking for a parameter with a matching name. * * This function can throw a 'param_not_exist' exception if the * name is not found. * - * The first thing that this function checks is if the list is NULL. - * It could be NULL because there are no parameters for this extension - * or because all of them have been checked. If the list - * is NULL then the 'param_not_exist' exception is thrown. - * - * @param name The name to search for. - * @return Parameter structure with a name of 'name'. + * @param name Name of the parameter to search for. + * @return Parameter with matching name. */ - Parameter *get_param(const gchar * name); + InxParameter *get_param(const gchar *name); - Parameter const *get_param(const gchar * name) const; + InxParameter const *get_param(const gchar *name) const; public: - bool get_param_bool (const gchar * name, - const SPDocument * doc = nullptr, - const Inkscape::XML::Node * node = nullptr); + bool get_param_bool (const gchar *name) const; + int get_param_int (const gchar *name) const; + float get_param_float (const gchar *name) const; + const char *get_param_string (const gchar *name) const; + const char *get_param_optiongroup (const gchar *name) const; + guint32 get_param_color (const gchar *name) const; - int get_param_int (const gchar * name, - const SPDocument * doc = nullptr, - const Inkscape::XML::Node * node = nullptr); + bool get_param_optiongroup_contains (const gchar *name, const char *value) const; - float get_param_float (const gchar * name, - const SPDocument * doc = nullptr, - const Inkscape::XML::Node * node = nullptr); + bool set_param_bool (const gchar *name, const bool value); + int set_param_int (const gchar *name, const int value); + float set_param_float (const gchar *name, const float value); + const char *set_param_string (const gchar *name, const char *value); + const char *set_param_optiongroup (const gchar *name, const char *value); + guint32 set_param_color (const gchar *name, const guint32 color); - /** - * Gets a parameter identified by name with the string placed in value. - * It isn't duplicated into the value string. Look up in the parameters list, - * then execute the function on that found parameter. - * - * @param name The name of the parameter to get. - * @param doc The document to look in for document specific parameters. - * @param node The node to look in for a specific parameter. - * @return A constant pointer to the string held by the parameters. - */ - gchar const *get_param_string(gchar const *name, - SPDocument const *doc = nullptr, - Inkscape::XML::Node const *node = nullptr) const; - - guint32 get_param_color (const gchar * name, - const SPDocument * doc = nullptr, - const Inkscape::XML::Node * node = nullptr) const; - - const gchar * get_param_enum (const gchar * name, - const SPDocument * doc = nullptr, - const Inkscape::XML::Node * node = nullptr) const; - - gchar const *get_param_optiongroup( gchar const * name, - SPDocument const * doc = nullptr, - Inkscape::XML::Node const * node = nullptr) const; - - bool get_param_enum_contains(gchar const * name, - gchar const * value, - SPDocument * doc = nullptr, - Inkscape::XML::Node * node = nullptr) const; - - bool set_param_bool (const gchar * name, - bool value, - SPDocument * doc = nullptr, - Inkscape::XML::Node * node = nullptr); - - int set_param_int (const gchar * name, - int value, - SPDocument * doc = nullptr, - Inkscape::XML::Node * node = nullptr); - - float set_param_float (const gchar * name, - float value, - SPDocument * doc = nullptr, - Inkscape::XML::Node * node = nullptr); - - const gchar * set_param_string (const gchar * name, - const gchar * value, - SPDocument * doc = nullptr, - Inkscape::XML::Node * node = nullptr); - - gchar const * set_param_optiongroup(gchar const * name, - gchar const * value, - SPDocument * doc = nullptr, - Inkscape::XML::Node * node = nullptr); - - gchar const * set_param_enum (gchar const * name, - gchar const * value, - SPDocument * doc = nullptr, - Inkscape::XML::Node * node = nullptr); - - guint32 set_param_color (const gchar * name, - guint32 color, - SPDocument * doc = nullptr, - Inkscape::XML::Node * node = nullptr); /* Error file handling */ public: @@ -288,16 +216,15 @@ public: static void error_file_close (); public: - Gtk::Widget * autogui (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal = nullptr); - void paramListString (std::list <std::string> & retlist); + Gtk::Widget *autogui (SPDocument *doc, Inkscape::XML::Node *node, sigc::signal<void> *changeSignal = nullptr); + void paramListString(std::list <std::string> &retlist); void set_gui(bool s) { _gui = s; } bool get_gui() { return _gui; } /* Extension editor dialog stuff */ public: - Gtk::VBox * get_info_widget(); - Gtk::VBox * get_help_widget(); - Gtk::VBox * get_params_widget(); + Gtk::VBox *get_info_widget(); + Gtk::VBox *get_params_widget(); protected: inline static void add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Grid * table, int * row); }; diff --git a/src/extension/implementation/implementation.cpp b/src/extension/implementation/implementation.cpp index 949451293..36cd299b7 100644 --- a/src/extension/implementation/implementation.cpp +++ b/src/extension/implementation/implementation.cpp @@ -37,7 +37,7 @@ Implementation::prefs_output(Inkscape::Extension::Output *module) { Gtk::Widget *Implementation::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View * view, sigc::signal<void> * changeSignal, ImplementationDocumentCache * /*docCache*/) { - if (module->param_visible_count() == 0) { + if (module->widget_visible_count() == 0) { return nullptr; } diff --git a/src/extension/implementation/implementation.h b/src/extension/implementation/implementation.h index e4922a083..21569ad3c 100644 --- a/src/extension/implementation/implementation.h +++ b/src/extension/implementation/implementation.h @@ -30,12 +30,12 @@ namespace Inkscape { namespace UI { namespace View { class View; -} // namespace View -} // namespace UI +} +} namespace XML { class Node; -} // namespace XML +} namespace Extension { @@ -58,7 +58,7 @@ class ImplementationDocumentCache { Inkscape::UI::View::View * _view; public: ImplementationDocumentCache (Inkscape::UI::View::View * view) { return; }; - + virtual ~ImplementationDocumentCache ( ) { return; }; Inkscape::UI::View::View const * view ( ) { return _view; }; }; @@ -72,7 +72,7 @@ class Implementation { public: // ----- Constructor / destructor ----- Implementation() = default; - + virtual ~Implementation() = default; // ----- Basic functions for all Extension ----- diff --git a/src/extension/implementation/xslt.cpp b/src/extension/implementation/xslt.cpp index 8ea8e5a7a..69e876be4 100644 --- a/src/extension/implementation/xslt.cpp +++ b/src/extension/implementation/xslt.cpp @@ -13,21 +13,28 @@ * Released under GNU GPL v2+, read the file 'COPYING' for more information. */ -#include <glibmm/fileutils.h> -#include "file.h" #include "xslt.h" -#include "../extension.h" -#include "../output.h" -#include "extension/input.h" -#include "io/resource.h" #include <unistd.h> #include <cstring> -#include "document.h" +#include <glibmm/fileutils.h> #include <libxslt/transform.h> #include <libxslt/xsltutils.h> +#include "document.h" +#include "file.h" + +#include "extension/extension.h" +#include "extension/output.h" +#include "extension/input.h" + +#include "io/resource.h" + +#include "xml/node.h" +#include "xml/repr.h" + + Inkscape::XML::Document * sp_repr_do_read (xmlDocPtr doc, const gchar * default_ns); /* Namespaces */ diff --git a/src/extension/input.cpp b/src/extension/input.cpp index 708324de2..ef3a9a5b5 100644 --- a/src/extension/input.cpp +++ b/src/extension/input.cpp @@ -8,13 +8,16 @@ * Released under GNU GPL v2+, read the file 'COPYING' for more information. */ -#ifdef HAVE_CONFIG_H -#endif +#include "input.h" -#include "prefdialog.h" -#include "implementation/implementation.h" #include "timer.h" -#include "input.h" + +#include "implementation/implementation.h" + +#include "prefdialog/prefdialog.h" + +#include "xml/repr.h" + /* Inkscape::Extension::Input */ @@ -37,7 +40,8 @@ namespace Extension { Overall, there are many levels of indentation, just to handle the levels of indentation in the XML file. */ -Input::Input (Inkscape::XML::Node * in_repr, Implementation::Implementation * in_imp) : Extension(in_repr, in_imp) +Input::Input (Inkscape::XML::Node *in_repr, Implementation::Implementation *in_imp, std::string *base_directory) + : Extension(in_repr, in_imp, base_directory) { mimetype = nullptr; extension = nullptr; @@ -182,23 +186,35 @@ Input::get_extension() \return The name of the filetype supported \brief Get the name of the filetype supported */ -gchar * -Input::get_filetypename() +const char * +Input::get_filetypename(bool translated) { - if (filetypename != nullptr) - return filetypename; + const char *name; + + if (filetypename) + name = filetypename; else - return get_name(); + name = get_name(); + + if (name && translated) { + return get_translation(name); + } else { + return name; + } } /** \return Tooltip giving more information on the filetype \brief Get the tooltip for more information on the filetype */ -gchar * -Input::get_filetypetooltip() +const char * +Input::get_filetypetooltip(bool translated) { - return filetypetooltip; + if (filetypetooltip && translated) { + return get_translation(filetypetooltip); + } else { + return filetypetooltip; + } } /** @@ -224,7 +240,8 @@ Input::prefs (const gchar *uri) return true; } - PrefDialog * dialog = new PrefDialog(this->get_name(), this->get_help(), controls); + Glib::ustring name = get_translation(this->get_name()); + PrefDialog *dialog = new PrefDialog(name, controls); int response = dialog->run(); dialog->hide(); diff --git a/src/extension/input.h b/src/extension/input.h index 93b000388..5952c3c04 100644 --- a/src/extension/input.h +++ b/src/extension/input.h @@ -44,15 +44,16 @@ public: const char *what() const noexcept override { return "Open was cancelled"; } }; - Input (Inkscape::XML::Node * in_repr, - Implementation::Implementation * in_imp); - ~Input () override; - bool check () override; + Input(Inkscape::XML::Node *in_repr, Implementation::Implementation *in_imp, std::string *base_directory); + ~Input() override; + + bool check() override; + SPDocument * open (gchar const *uri); gchar * get_mimetype (); gchar * get_extension (); - gchar * get_filetypename (); - gchar * get_filetypetooltip (); + const char * get_filetypename (bool translated=false); + const char * get_filetypetooltip (bool translated=false); bool prefs (gchar const *uri); }; diff --git a/src/extension/internal/bitmap/adaptiveThreshold.cpp b/src/extension/internal/bitmap/adaptiveThreshold.cpp index 473bada4e..ce4d78a89 100644 --- a/src/extension/internal/bitmap/adaptiveThreshold.cpp +++ b/src/extension/internal/bitmap/adaptiveThreshold.cpp @@ -39,9 +39,9 @@ AdaptiveThreshold::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Adaptive Threshold") "</name>\n" "<id>org.inkscape.effect.bitmap.adaptiveThreshold</id>\n" - "<param name=\"width\" _gui-text=\"" N_("Width:") "\" type=\"int\" min=\"-100\" max=\"100\">5</param>\n" - "<param name=\"height\" _gui-text=\"" N_("Height:") "\" type=\"int\" min=\"-100\" max=\"100\">5</param>\n" - "<param name=\"offset\" _gui-text=\"" N_("Offset:") "\" type=\"int\" min=\"0\" max=\"100\">0</param>\n" + "<param name=\"width\" gui-text=\"" N_("Width:") "\" type=\"int\" min=\"-100\" max=\"100\">5</param>\n" + "<param name=\"height\" gui-text=\"" N_("Height:") "\" type=\"int\" min=\"-100\" max=\"100\">5</param>\n" + "<param name=\"offset\" gui-text=\"" N_("Offset:") "\" type=\"int\" min=\"0\" max=\"100\">0</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bitmap/addNoise.cpp b/src/extension/internal/bitmap/addNoise.cpp index 5981eed24..26b050fa8 100644 --- a/src/extension/internal/bitmap/addNoise.cpp +++ b/src/extension/internal/bitmap/addNoise.cpp @@ -33,7 +33,7 @@ AddNoise::applyEffect(Magick::Image *image) { void AddNoise::refreshParameters(Inkscape::Extension::Effect *module) { - _noiseTypeName = module->get_param_enum("noiseType"); + _noiseTypeName = module->get_param_optiongroup("noiseType"); } #include "../clear-n_.h" @@ -45,13 +45,13 @@ AddNoise::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Add Noise") "</name>\n" "<id>org.inkscape.effect.bitmap.addNoise</id>\n" - "<param name=\"noiseType\" _gui-text=\"" N_("Type:") "\" type=\"enum\" >\n" - "<_item value='Uniform Noise'>" N_("Uniform Noise") "</_item>\n" - "<_item value='Gaussian Noise'>" N_("Gaussian Noise") "</_item>\n" - "<_item value='Multiplicative Gaussian Noise'>" N_("Multiplicative Gaussian Noise") "</_item>\n" - "<_item value='Impulse Noise'>" N_("Impulse Noise") "</_item>\n" - "<_item value='Laplacian Noise'>" N_("Laplacian Noise") "</_item>\n" - "<_item value='Poisson Noise'>" N_("Poisson Noise") "</_item>\n" + "<param name=\"noiseType\" gui-text=\"" N_("Type:") "\" type=\"optiongroup\" appearance=\"combo\" >\n" + "<option value='Uniform Noise'>" N_("Uniform Noise") "</option>\n" + "<option value='Gaussian Noise'>" N_("Gaussian Noise") "</option>\n" + "<option value='Multiplicative Gaussian Noise'>" N_("Multiplicative Gaussian Noise") "</option>\n" + "<option value='Impulse Noise'>" N_("Impulse Noise") "</option>\n" + "<option value='Laplacian Noise'>" N_("Laplacian Noise") "</option>\n" + "<option value='Poisson Noise'>" N_("Poisson Noise") "</option>\n" "</param>\n" "<effect>\n" "<object-type>all</object-type>\n" diff --git a/src/extension/internal/bitmap/blur.cpp b/src/extension/internal/bitmap/blur.cpp index 57c3342a8..b50511c32 100644 --- a/src/extension/internal/bitmap/blur.cpp +++ b/src/extension/internal/bitmap/blur.cpp @@ -38,8 +38,8 @@ Blur::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Blur") "</name>\n" "<id>org.inkscape.effect.bitmap.blur</id>\n" - "<param name=\"radius\" _gui-text=\"" N_("Radius:") "\" type=\"float\" min=\"0\" max=\"100\">1</param>\n" - "<param name=\"sigma\" _gui-text=\"" N_("Sigma:") "\" type=\"float\" min=\"0\" max=\"100\">0.5</param>\n" + "<param name=\"radius\" gui-text=\"" N_("Radius:") "\" type=\"float\" min=\"0\" max=\"100\">1</param>\n" + "<param name=\"sigma\" gui-text=\"" N_("Sigma:") "\" type=\"float\" min=\"0\" max=\"100\">0.5</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bitmap/channel.cpp b/src/extension/internal/bitmap/channel.cpp index fb0dad635..f26a9f985 100644 --- a/src/extension/internal/bitmap/channel.cpp +++ b/src/extension/internal/bitmap/channel.cpp @@ -36,7 +36,7 @@ Channel::applyEffect(Magick::Image *image) { void Channel::refreshParameters(Inkscape::Extension::Effect *module) { - _layerName = module->get_param_enum("layer"); + _layerName = module->get_param_optiongroup("layer"); } #include "../clear-n_.h" @@ -48,16 +48,16 @@ Channel::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Channel") "</name>\n" "<id>org.inkscape.effect.bitmap.channel</id>\n" - "<param name=\"layer\" _gui-text=\"" N_("Layer:") "\" type=\"enum\" >\n" - "<_item value='Red Channel'>" N_("Red Channel") "</_item>\n" - "<_item value='Green Channel'>" N_("Green Channel") "</_item>\n" - "<_item value='Blue Channel'>" N_("Blue Channel") "</_item>\n" - "<_item value='Cyan Channel'>" N_("Cyan Channel") "</_item>\n" - "<_item value='Magenta Channel'>" N_("Magenta Channel") "</_item>\n" - "<_item value='Yellow Channel'>" N_("Yellow Channel") "</_item>\n" - "<_item value='Black Channel'>" N_("Black Channel") "</_item>\n" - "<_item value='Opacity Channel'>" N_("Opacity Channel") "</_item>\n" - "<_item value='Matte Channel'>" N_("Matte Channel") "</_item>\n" + "<param name=\"layer\" gui-text=\"" N_("Layer:") "\" type=\"optiongroup\" appearance=\"combo\" >\n" + "<option value='Red Channel'>" N_("Red Channel") "</option>\n" + "<option value='Green Channel'>" N_("Green Channel") "</option>\n" + "<option value='Blue Channel'>" N_("Blue Channel") "</option>\n" + "<option value='Cyan Channel'>" N_("Cyan Channel") "</option>\n" + "<option value='Magenta Channel'>" N_("Magenta Channel") "</option>\n" + "<option value='Yellow Channel'>" N_("Yellow Channel") "</option>\n" + "<option value='Black Channel'>" N_("Black Channel") "</option>\n" + "<option value='Opacity Channel'>" N_("Opacity Channel") "</option>\n" + "<option value='Matte Channel'>" N_("Matte Channel") "</option>\n" "</param>\n" "<effect>\n" "<object-type>all</object-type>\n" diff --git a/src/extension/internal/bitmap/charcoal.cpp b/src/extension/internal/bitmap/charcoal.cpp index 2c4894732..4da2cbac0 100644 --- a/src/extension/internal/bitmap/charcoal.cpp +++ b/src/extension/internal/bitmap/charcoal.cpp @@ -38,8 +38,8 @@ Charcoal::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Charcoal") "</name>\n" "<id>org.inkscape.effect.bitmap.charcoal</id>\n" - "<param name=\"radius\" _gui-text=\"" N_("Radius:") "\" type=\"float\" min=\"0\" max=\"100\">1</param>\n" - "<param name=\"sigma\" _gui-text=\"" N_("Sigma:") "\" type=\"float\" min=\"0\" max=\"100\">0.5</param>\n" + "<param name=\"radius\" gui-text=\"" N_("Radius:") "\" type=\"float\" min=\"0\" max=\"100\">1</param>\n" + "<param name=\"sigma\" gui-text=\"" N_("Sigma:") "\" type=\"float\" min=\"0\" max=\"100\">0.5</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bitmap/colorize.cpp b/src/extension/internal/bitmap/colorize.cpp index 01dfd1d7e..265090915 100644 --- a/src/extension/internal/bitmap/colorize.cpp +++ b/src/extension/internal/bitmap/colorize.cpp @@ -50,7 +50,7 @@ Colorize::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Colorize") "</name>\n" "<id>org.inkscape.effect.bitmap.colorize</id>\n" - "<param name=\"color\" _gui-text=\"" N_("Color") "\" type=\"color\">0</param>\n" + "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">0</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bitmap/contrast.cpp b/src/extension/internal/bitmap/contrast.cpp index bb01d8e85..64d21674e 100644 --- a/src/extension/internal/bitmap/contrast.cpp +++ b/src/extension/internal/bitmap/contrast.cpp @@ -40,7 +40,7 @@ Contrast::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Contrast") "</name>\n" "<id>org.inkscape.effect.bitmap.contrast</id>\n" - "<param name=\"sharpen\" _gui-text=\"" N_("Adjust:") "\" type=\"int\" min=\"0\" max=\"10\">0</param>\n" + "<param name=\"sharpen\" gui-text=\"" N_("Adjust:") "\" type=\"int\" min=\"0\" max=\"10\">0</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bitmap/crop.cpp b/src/extension/internal/bitmap/crop.cpp index 69e23c770..c69b4029b 100644 --- a/src/extension/internal/bitmap/crop.cpp +++ b/src/extension/internal/bitmap/crop.cpp @@ -67,10 +67,10 @@ Crop::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Crop") "</name>\n" "<id>org.inkscape.effect.bitmap.crop</id>\n" - "<param name=\"top\" _gui-text=\"" N_("Top (px):") "\" type=\"int\" min=\"0\" max=\"100000\">0</param>\n" - "<param name=\"bottom\" _gui-text=\"" N_("Bottom (px):") "\" type=\"int\" min=\"0\" max=\"100000\">0</param>\n" - "<param name=\"left\" _gui-text=\"" N_("Left (px):") "\" type=\"int\" min=\"0\" max=\"100000\">0</param>\n" - "<param name=\"right\" _gui-text=\"" N_("Right (px):") "\" type=\"int\" min=\"0\" max=\"100000\">0</param>\n" + "<param name=\"top\" gui-text=\"" N_("Top (px):") "\" type=\"int\" min=\"0\" max=\"100000\">0</param>\n" + "<param name=\"bottom\" gui-text=\"" N_("Bottom (px):") "\" type=\"int\" min=\"0\" max=\"100000\">0</param>\n" + "<param name=\"left\" gui-text=\"" N_("Left (px):") "\" type=\"int\" min=\"0\" max=\"100000\">0</param>\n" + "<param name=\"right\" gui-text=\"" N_("Right (px):") "\" type=\"int\" min=\"0\" max=\"100000\">0</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bitmap/cycleColormap.cpp b/src/extension/internal/bitmap/cycleColormap.cpp index d245294bc..04741f9f4 100644 --- a/src/extension/internal/bitmap/cycleColormap.cpp +++ b/src/extension/internal/bitmap/cycleColormap.cpp @@ -37,7 +37,7 @@ CycleColormap::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Cycle Colormap") "</name>\n" "<id>org.inkscape.effect.bitmap.cycleColormap</id>\n" - "<param name=\"amount\" _gui-text=\"" N_("Amount:") "\" type=\"int\" min=\"0\" max=\"360\">180</param>\n" + "<param name=\"amount\" gui-text=\"" N_("Amount:") "\" type=\"int\" min=\"0\" max=\"360\">180</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bitmap/edge.cpp b/src/extension/internal/bitmap/edge.cpp index d147001d6..58bceec46 100644 --- a/src/extension/internal/bitmap/edge.cpp +++ b/src/extension/internal/bitmap/edge.cpp @@ -37,7 +37,7 @@ Edge::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Edge") "</name>\n" "<id>org.inkscape.effect.bitmap.edge</id>\n" - "<param name=\"radius\" _gui-text=\"" N_("Radius:") "\" type=\"int\" min=\"0\" max=\"100\">0</param>\n" + "<param name=\"radius\" gui-text=\"" N_("Radius:") "\" type=\"int\" min=\"0\" max=\"100\">0</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bitmap/emboss.cpp b/src/extension/internal/bitmap/emboss.cpp index 8cb363ebd..b7f2235a2 100644 --- a/src/extension/internal/bitmap/emboss.cpp +++ b/src/extension/internal/bitmap/emboss.cpp @@ -38,8 +38,8 @@ Emboss::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Emboss") "</name>\n" "<id>org.inkscape.effect.bitmap.emboss</id>\n" - "<param name=\"radius\" _gui-text=\"" N_("Radius:") "\" type=\"float\" min=\"0\" max=\"100\">1.0</param>\n" - "<param name=\"sigma\" _gui-text=\"" N_("Sigma:") "\" type=\"float\" min=\"-50\" max=\"50\">0.5</param>\n" + "<param name=\"radius\" gui-text=\"" N_("Radius:") "\" type=\"float\" min=\"0\" max=\"100\">1.0</param>\n" + "<param name=\"sigma\" gui-text=\"" N_("Sigma:") "\" type=\"float\" min=\"-50\" max=\"50\">0.5</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bitmap/gaussianBlur.cpp b/src/extension/internal/bitmap/gaussianBlur.cpp index 78b77e23c..405ee66d5 100644 --- a/src/extension/internal/bitmap/gaussianBlur.cpp +++ b/src/extension/internal/bitmap/gaussianBlur.cpp @@ -38,8 +38,8 @@ GaussianBlur::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Gaussian Blur") "</name>\n" "<id>org.inkscape.effect.bitmap.gaussianBlur</id>\n" - "<param name=\"width\" _gui-text=\"" N_("Factor:") "\" type=\"float\" min=\"0\" max=\"100\">5.0</param>\n" - "<param name=\"sigma\" _gui-text=\"" N_("Sigma:") "\" type=\"float\" min=\"0\" max=\"100\">5.0</param>\n" + "<param name=\"width\" gui-text=\"" N_("Factor:") "\" type=\"float\" min=\"0\" max=\"100\">5.0</param>\n" + "<param name=\"sigma\" gui-text=\"" N_("Sigma:") "\" type=\"float\" min=\"0\" max=\"100\">5.0</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bitmap/implode.cpp b/src/extension/internal/bitmap/implode.cpp index 7bad3489f..c6c7a5f48 100644 --- a/src/extension/internal/bitmap/implode.cpp +++ b/src/extension/internal/bitmap/implode.cpp @@ -37,7 +37,7 @@ Implode::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Implode") "</name>\n" "<id>org.inkscape.effect.bitmap.implode</id>\n" - "<param name=\"factor\" _gui-text=\"" N_("Factor:") "\" type=\"float\" min=\"0\" max=\"100\">10</param>\n" + "<param name=\"factor\" gui-text=\"" N_("Factor:") "\" type=\"float\" min=\"0\" max=\"100\">10</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bitmap/level.cpp b/src/extension/internal/bitmap/level.cpp index 0b58ec8b9..aaf31682f 100644 --- a/src/extension/internal/bitmap/level.cpp +++ b/src/extension/internal/bitmap/level.cpp @@ -41,9 +41,9 @@ Level::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Level") "</name>\n" "<id>org.inkscape.effect.bitmap.level</id>\n" - "<param name=\"blackPoint\" _gui-text=\"" N_("Black Point:") "\" type=\"float\" min=\"0\" max=\"100\">0</param>\n" - "<param name=\"whitePoint\" _gui-text=\"" N_("White Point:") "\" type=\"float\" min=\"0\" max=\"100\">100</param>\n" - "<param name=\"midPoint\" _gui-text=\"" N_("Gamma Correction:") "\" type=\"float\" min=\"0\" max=\"10\">1</param>\n" + "<param name=\"blackPoint\" gui-text=\"" N_("Black Point:") "\" type=\"float\" min=\"0\" max=\"100\">0</param>\n" + "<param name=\"whitePoint\" gui-text=\"" N_("White Point:") "\" type=\"float\" min=\"0\" max=\"100\">100</param>\n" + "<param name=\"midPoint\" gui-text=\"" N_("Gamma Correction:") "\" type=\"float\" min=\"0\" max=\"10\">1</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bitmap/levelChannel.cpp b/src/extension/internal/bitmap/levelChannel.cpp index 714293d28..497d6ce8c 100644 --- a/src/extension/internal/bitmap/levelChannel.cpp +++ b/src/extension/internal/bitmap/levelChannel.cpp @@ -37,7 +37,7 @@ LevelChannel::applyEffect(Magick::Image* image) { void LevelChannel::refreshParameters(Inkscape::Extension::Effect* module) { - _channelName = module->get_param_enum("channel"); + _channelName = module->get_param_optiongroup("channel"); _black_point = module->get_param_float("blackPoint"); _white_point = module->get_param_float("whitePoint"); _mid_point = module->get_param_float("midPoint"); @@ -52,20 +52,20 @@ LevelChannel::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Level (with Channel)") "</name>\n" "<id>org.inkscape.effect.bitmap.levelChannel</id>\n" - "<param name=\"channel\" _gui-text=\"" N_("Channel:") "\" type=\"enum\" >\n" - "<_item value='Red Channel'>" N_("Red Channel") "</_item>\n" - "<_item value='Green Channel'>" N_("Green Channel") "</_item>\n" - "<_item value='Blue Channel'>" N_("Blue Channel") "</_item>\n" - "<_item value='Cyan Channel'>" N_("Cyan Channel") "</_item>\n" - "<_item value='Magenta Channel'>" N_("Magenta Channel") "</_item>\n" - "<_item value='Yellow Channel'>" N_("Yellow Channel") "</_item>\n" - "<_item value='Black Channel'>" N_("Black Channel") "</_item>\n" - "<_item value='Opacity Channel'>" N_("Opacity Channel") "</_item>\n" - "<_item value='Matte Channel'>" N_("Matte Channel") "</_item>\n" + "<param name=\"channel\" gui-text=\"" N_("Channel:") "\" type=\"optiongroup\" appearance=\"combo\" >\n" + "<option value='Red Channel'>" N_("Red Channel") "</option>\n" + "<option value='Green Channel'>" N_("Green Channel") "</option>\n" + "<option value='Blue Channel'>" N_("Blue Channel") "</option>\n" + "<option value='Cyan Channel'>" N_("Cyan Channel") "</option>\n" + "<option value='Magenta Channel'>" N_("Magenta Channel") "</option>\n" + "<option value='Yellow Channel'>" N_("Yellow Channel") "</option>\n" + "<option value='Black Channel'>" N_("Black Channel") "</option>\n" + "<option value='Opacity Channel'>" N_("Opacity Channel") "</option>\n" + "<option value='Matte Channel'>" N_("Matte Channel") "</option>\n" "</param>\n" - "<param name=\"blackPoint\" _gui-text=\"" N_("Black Point:") "\" type=\"float\" min=\"0.0\" max=\"100.0\">0.0</param>\n" - "<param name=\"whitePoint\" _gui-text=\"" N_("White Point:") "\" type=\"float\" min=\"0.0\" max=\"100.0\">100.0</param>\n" - "<param name=\"midPoint\" _gui-text=\"" N_("Gamma Correction:") "\" type=\"float\" min=\"0.0\" max=\"10.0\">1.0</param>\n" + "<param name=\"blackPoint\" gui-text=\"" N_("Black Point:") "\" type=\"float\" min=\"0.0\" max=\"100.0\">0.0</param>\n" + "<param name=\"whitePoint\" gui-text=\"" N_("White Point:") "\" type=\"float\" min=\"0.0\" max=\"100.0\">100.0</param>\n" + "<param name=\"midPoint\" gui-text=\"" N_("Gamma Correction:") "\" type=\"float\" min=\"0.0\" max=\"10.0\">1.0</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bitmap/medianFilter.cpp b/src/extension/internal/bitmap/medianFilter.cpp index 5a5e0311b..cc3dabd9f 100644 --- a/src/extension/internal/bitmap/medianFilter.cpp +++ b/src/extension/internal/bitmap/medianFilter.cpp @@ -37,7 +37,7 @@ MedianFilter::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Median") "</name>\n" "<id>org.inkscape.effect.bitmap.medianFilter</id>\n" - "<param name=\"radius\" _gui-text=\"" N_("Radius:") "\" type=\"float\" min=\"0\" max=\"100\">0</param>\n" + "<param name=\"radius\" gui-text=\"" N_("Radius:") "\" type=\"float\" min=\"0\" max=\"100\">0</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bitmap/modulate.cpp b/src/extension/internal/bitmap/modulate.cpp index 1a82707f2..5071a6031 100644 --- a/src/extension/internal/bitmap/modulate.cpp +++ b/src/extension/internal/bitmap/modulate.cpp @@ -40,9 +40,9 @@ Modulate::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("HSB Adjust") "</name>\n" "<id>org.inkscape.effect.bitmap.modulate</id>\n" - "<param name=\"hue\" _gui-text=\"" N_("Hue:") "\" type=\"float\" min=\"-360\" max=\"360\">0</param>\n" - "<param name=\"saturation\" _gui-text=\"" N_("Saturation:") "\" type=\"float\" min=\"-200\" max=\"200\">0</param>\n" - "<param name=\"brightness\" _gui-text=\"" N_("Brightness:") "\" type=\"float\" min=\"-200\" max=\"200\">0</param>\n" + "<param name=\"hue\" gui-text=\"" N_("Hue:") "\" type=\"float\" min=\"-360\" max=\"360\">0</param>\n" + "<param name=\"saturation\" gui-text=\"" N_("Saturation:") "\" type=\"float\" min=\"-200\" max=\"200\">0</param>\n" + "<param name=\"brightness\" gui-text=\"" N_("Brightness:") "\" type=\"float\" min=\"-200\" max=\"200\">0</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bitmap/oilPaint.cpp b/src/extension/internal/bitmap/oilPaint.cpp index a2ffce712..a5373eb22 100644 --- a/src/extension/internal/bitmap/oilPaint.cpp +++ b/src/extension/internal/bitmap/oilPaint.cpp @@ -37,7 +37,7 @@ OilPaint::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Oil Paint") "</name>\n" "<id>org.inkscape.effect.bitmap.oilPaint</id>\n" - "<param name=\"radius\" _gui-text=\"" N_("Radius:") "\" type=\"int\" min=\"0\" max=\"50\">3</param>\n" + "<param name=\"radius\" gui-text=\"" N_("Radius:") "\" type=\"int\" min=\"0\" max=\"50\">3</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bitmap/opacity.cpp b/src/extension/internal/bitmap/opacity.cpp index 3206d246d..cac8b65f7 100644 --- a/src/extension/internal/bitmap/opacity.cpp +++ b/src/extension/internal/bitmap/opacity.cpp @@ -38,7 +38,7 @@ Opacity::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Opacity") "</name>\n" "<id>org.inkscape.effect.bitmap.opacity</id>\n" - "<param name=\"opacity\" _gui-text=\"" N_("Opacity:") "\" type=\"float\" min=\"0.0\" max=\"100.0\">80.0</param>\n" + "<param name=\"opacity\" gui-text=\"" N_("Opacity:") "\" type=\"float\" min=\"0.0\" max=\"100.0\">80.0</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bitmap/raise.cpp b/src/extension/internal/bitmap/raise.cpp index b97455d4e..8b3598ae8 100644 --- a/src/extension/internal/bitmap/raise.cpp +++ b/src/extension/internal/bitmap/raise.cpp @@ -40,9 +40,9 @@ Raise::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Raise") "</name>\n" "<id>org.inkscape.effect.bitmap.raise</id>\n" - "<param name=\"width\" _gui-text=\"" N_("Width:") "\" type=\"int\" min=\"0\" max=\"800\">6</param>\n" - "<param name=\"height\" _gui-text=\"" N_("Height:") "\" type=\"int\" min=\"0\" max=\"800\">6</param>\n" - "<param name=\"raisedFlag\" _gui-text=\"" N_("Raised") "\" type=\"boolean\">0</param>\n" + "<param name=\"width\" gui-text=\"" N_("Width:") "\" type=\"int\" min=\"0\" max=\"800\">6</param>\n" + "<param name=\"height\" gui-text=\"" N_("Height:") "\" type=\"int\" min=\"0\" max=\"800\">6</param>\n" + "<param name=\"raisedFlag\" gui-text=\"" N_("Raised") "\" type=\"bool\">false</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bitmap/reduceNoise.cpp b/src/extension/internal/bitmap/reduceNoise.cpp index 1a4e124ac..809c69315 100644 --- a/src/extension/internal/bitmap/reduceNoise.cpp +++ b/src/extension/internal/bitmap/reduceNoise.cpp @@ -40,7 +40,7 @@ ReduceNoise::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Reduce Noise") "</name>\n" "<id>org.inkscape.effect.bitmap.reduceNoise</id>\n" - "<param name=\"order\" _gui-text=\"" N_("Order:") "\" type=\"int\" min=\"-1\" max=\"100\">-1</param>\n" + "<param name=\"order\" gui-text=\"" N_("Order:") "\" type=\"int\" min=\"-1\" max=\"100\">-1</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bitmap/sample.cpp b/src/extension/internal/bitmap/sample.cpp index e8bf32500..e59e1aff9 100644 --- a/src/extension/internal/bitmap/sample.cpp +++ b/src/extension/internal/bitmap/sample.cpp @@ -39,8 +39,8 @@ Sample::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Resample") "</name>\n" "<id>org.inkscape.effect.bitmap.sample</id>\n" - "<param name=\"width\" _gui-text=\"" N_("Width:") "\" type=\"int\" min=\"0\" max=\"6400\">100</param>\n" - "<param name=\"height\" _gui-text=\"" N_("Height:") "\" type=\"int\" min=\"0\" max=\"6400\">100</param>\n" + "<param name=\"width\" gui-text=\"" N_("Width:") "\" type=\"int\" min=\"0\" max=\"6400\">100</param>\n" + "<param name=\"height\" gui-text=\"" N_("Height:") "\" type=\"int\" min=\"0\" max=\"6400\">100</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bitmap/shade.cpp b/src/extension/internal/bitmap/shade.cpp index 5896072c4..f6b2f255b 100644 --- a/src/extension/internal/bitmap/shade.cpp +++ b/src/extension/internal/bitmap/shade.cpp @@ -40,9 +40,9 @@ Shade::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Shade") "</name>\n" "<id>org.inkscape.effect.bitmap.shade</id>\n" - "<param name=\"azimuth\" _gui-text=\"" N_("Azimuth:") "\" type=\"float\" min=\"-180\" max=\"180\">30</param>\n" - "<param name=\"elevation\" _gui-text=\"" N_("Elevation:") "\" type=\"float\" min=\"-180\" max=\"180\">30</param>\n" - "<param name=\"colorShading\" _gui-text=\"" N_("Colored Shading") "\" type=\"boolean\">false</param>\n" + "<param name=\"azimuth\" gui-text=\"" N_("Azimuth:") "\" type=\"float\" min=\"-180\" max=\"180\">30</param>\n" + "<param name=\"elevation\" gui-text=\"" N_("Elevation:") "\" type=\"float\" min=\"-180\" max=\"180\">30</param>\n" + "<param name=\"colorShading\" gui-text=\"" N_("Colored Shading") "\" type=\"bool\">false</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bitmap/sharpen.cpp b/src/extension/internal/bitmap/sharpen.cpp index 6ee05a900..aa24ac3ff 100644 --- a/src/extension/internal/bitmap/sharpen.cpp +++ b/src/extension/internal/bitmap/sharpen.cpp @@ -38,8 +38,8 @@ Sharpen::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Sharpen") "</name>\n" "<id>org.inkscape.effect.bitmap.sharpen</id>\n" - "<param name=\"radius\" _gui-text=\"" N_("Radius:") "\" type=\"float\" min=\"0\" max=\"50\">1.0</param>\n" - "<param name=\"sigma\" _gui-text=\"" N_("Sigma:") "\" type=\"float\" min=\"0\" max=\"10\">0.5</param>\n" + "<param name=\"radius\" gui-text=\"" N_("Radius:") "\" type=\"float\" min=\"0\" max=\"50\">1.0</param>\n" + "<param name=\"sigma\" gui-text=\"" N_("Sigma:") "\" type=\"float\" min=\"0\" max=\"10\">0.5</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bitmap/solarize.cpp b/src/extension/internal/bitmap/solarize.cpp index 489141d39..69a1e186b 100644 --- a/src/extension/internal/bitmap/solarize.cpp +++ b/src/extension/internal/bitmap/solarize.cpp @@ -39,7 +39,7 @@ Solarize::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Solarize") "</name>\n" "<id>org.inkscape.effect.bitmap.solarize</id>\n" - "<param name=\"factor\" _gui-text=\"" N_("Factor:") "\" type=\"float\" min=\"0\" max=\"100\">50</param>\n" + "<param name=\"factor\" gui-text=\"" N_("Factor:") "\" type=\"float\" min=\"0\" max=\"100\">50</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bitmap/spread.cpp b/src/extension/internal/bitmap/spread.cpp index e6f426591..86b4432bb 100644 --- a/src/extension/internal/bitmap/spread.cpp +++ b/src/extension/internal/bitmap/spread.cpp @@ -37,7 +37,7 @@ Spread::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Dither") "</name>\n" "<id>org.inkscape.effect.bitmap.spread</id>\n" - "<param name=\"amount\" _gui-text=\"" N_("Amount:") "\" type=\"int\" min=\"0\" max=\"100\">3</param>\n" + "<param name=\"amount\" gui-text=\"" N_("Amount:") "\" type=\"int\" min=\"0\" max=\"100\">3</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bitmap/swirl.cpp b/src/extension/internal/bitmap/swirl.cpp index 21df59502..a7681a34d 100644 --- a/src/extension/internal/bitmap/swirl.cpp +++ b/src/extension/internal/bitmap/swirl.cpp @@ -37,7 +37,7 @@ Swirl::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Swirl") "</name>\n" "<id>org.inkscape.effect.bitmap.swirl</id>\n" - "<param name=\"degrees\" _gui-text=\"" N_("Degrees:") "\" type=\"int\" min=\"-360\" max=\"360\">30</param>\n" + "<param name=\"degrees\" gui-text=\"" N_("Degrees:") "\" type=\"int\" min=\"-360\" max=\"360\">30</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bitmap/threshold.cpp b/src/extension/internal/bitmap/threshold.cpp index ddcc7ab1b..4f9dec57c 100644 --- a/src/extension/internal/bitmap/threshold.cpp +++ b/src/extension/internal/bitmap/threshold.cpp @@ -38,7 +38,7 @@ Threshold::init() // TRANSLATORS: see http://docs.gimp.org/en/gimp-tool-threshold.html "<name>" N_("Threshold") "</name>\n" "<id>org.inkscape.effect.bitmap.threshold</id>\n" - "<param name=\"threshold\" _gui-text=\"" N_("Threshold:") "\" type=\"float\" min=\"-100.0\" max=\"100.0\"></param>\n" + "<param name=\"threshold\" gui-text=\"" N_("Threshold:") "\" type=\"float\" min=\"-100.0\" max=\"100.0\"></param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bitmap/unsharpmask.cpp b/src/extension/internal/bitmap/unsharpmask.cpp index 2e807a39a..9240803e2 100644 --- a/src/extension/internal/bitmap/unsharpmask.cpp +++ b/src/extension/internal/bitmap/unsharpmask.cpp @@ -41,10 +41,10 @@ Unsharpmask::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Unsharp Mask") "</name>\n" "<id>org.inkscape.effect.bitmap.unsharpmask</id>\n" - "<param name=\"radius\" _gui-text=\"" N_("Radius:") "\" type=\"float\" min=\"0.0\" max=\"50.0\">5.0</param>\n" - "<param name=\"sigma\" _gui-text=\"" N_("Sigma:") "\" type=\"float\" min=\"0.0\" max=\"50.0\">5.0</param>\n" - "<param name=\"amount\" _gui-text=\"" N_("Amount:") "\" type=\"float\" min=\"0.0\" max=\"100.0\">50.0</param>\n" - "<param name=\"threshold\" _gui-text=\"" N_("Threshold:") "\" type=\"float\" min=\"0.0\" max=\"50.0\">5.0</param>\n" + "<param name=\"radius\" gui-text=\"" N_("Radius:") "\" type=\"float\" min=\"0.0\" max=\"50.0\">5.0</param>\n" + "<param name=\"sigma\" gui-text=\"" N_("Sigma:") "\" type=\"float\" min=\"0.0\" max=\"50.0\">5.0</param>\n" + "<param name=\"amount\" gui-text=\"" N_("Amount:") "\" type=\"float\" min=\"0.0\" max=\"100.0\">50.0</param>\n" + "<param name=\"threshold\" gui-text=\"" N_("Threshold:") "\" type=\"float\" min=\"0.0\" max=\"50.0\">5.0</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bitmap/wave.cpp b/src/extension/internal/bitmap/wave.cpp index 6a86ca3f7..5a67574a0 100644 --- a/src/extension/internal/bitmap/wave.cpp +++ b/src/extension/internal/bitmap/wave.cpp @@ -38,8 +38,8 @@ Wave::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Wave") "</name>\n" "<id>org.inkscape.effect.bitmap.wave</id>\n" - "<param name=\"amplitude\" _gui-text=\"" N_("Amplitude:") "\" type=\"float\" min=\"-720.0\" max=\"720.0\">25</param>\n" - "<param name=\"wavelength\" _gui-text=\"" N_("Wavelength:") "\" type=\"float\" min=\"-720.0\" max=\"720.0\">150</param>\n" + "<param name=\"amplitude\" gui-text=\"" N_("Amplitude:") "\" type=\"float\" min=\"-720.0\" max=\"720.0\">25</param>\n" + "<param name=\"wavelength\" gui-text=\"" N_("Wavelength:") "\" type=\"float\" min=\"-720.0\" max=\"720.0\">150</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/bluredge.cpp b/src/extension/internal/bluredge.cpp index 23a337ff7..80fa4f232 100644 --- a/src/extension/internal/bluredge.cpp +++ b/src/extension/internal/bluredge.cpp @@ -129,8 +129,8 @@ BlurEdge::init () "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Inset/Outset Halo") "</name>\n" "<id>org.inkscape.effect.bluredge</id>\n" - "<param name=\"blur-width\" _gui-text=\"" N_("Width:") "\" gui-description=\"" N_("Width in px of the halo") "\" type=\"float\" min=\"1.0\" max=\"50.0\">1.0</param>\n" - "<param name=\"num-steps\" _gui-text=\"" N_("Number of steps:") "\" gui-description=\"" N_("Number of inset/outset copies of the object to make") "\" type=\"int\" min=\"5\" max=\"100\">11</param>\n" + "<param name=\"blur-width\" gui-text=\"" N_("Width:") "\" gui-description=\"" N_("Width in px of the halo") "\" type=\"float\" min=\"1.0\" max=\"50.0\">1.0</param>\n" + "<param name=\"num-steps\" gui-text=\"" N_("Number of steps:") "\" gui-description=\"" N_("Number of inset/outset copies of the object to make") "\" type=\"int\" min=\"5\" max=\"100\">11</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/cairo-ps-out.cpp b/src/extension/internal/cairo-ps-out.cpp index 5dfbe051e..06d3ceb23 100644 --- a/src/extension/internal/cairo-ps-out.cpp +++ b/src/extension/internal/cairo-ps-out.cpp @@ -137,7 +137,7 @@ CairoPsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar con int level = CAIRO_PS_LEVEL_2; try { - const gchar *new_level = mod->get_param_enum("PSlevel"); + const gchar *new_level = mod->get_param_optiongroup("PSlevel"); if((new_level != nullptr) && (g_ascii_strcasecmp("PS3", new_level) == 0)) { level = CAIRO_PS_LEVEL_3; } @@ -226,7 +226,7 @@ CairoEpsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar co int level = CAIRO_PS_LEVEL_2; try { - const gchar *new_level = mod->get_param_enum("PSlevel"); + const gchar *new_level = mod->get_param_optiongroup("PSlevel"); if((new_level != nullptr) && (g_ascii_strcasecmp("PS3", new_level) == 0)) { level = CAIRO_PS_LEVEL_3; } @@ -325,23 +325,23 @@ CairoPsOutput::init () "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("PostScript") "</name>\n" "<id>" SP_MODULE_KEY_PRINT_CAIRO_PS "</id>\n" - "<param name=\"PSlevel\" _gui-text=\"" N_("Restrict to PS level:") "\" type=\"enum\" >\n" - "<_item value='PS3'>" N_("PostScript level 3") "</_item>\n" - "<_item value='PS2'>" N_("PostScript level 2") "</_item>\n" + "<param name=\"PSlevel\" gui-text=\"" N_("Restrict to PS level:") "\" type=\"optiongroup\" appearance=\"combo\" >\n" + "<option value='PS3'>" N_("PostScript level 3") "</option>\n" + "<option value='PS2'>" N_("PostScript level 2") "</option>\n" "</param>\n" - "<param name=\"textToPath\" _gui-text=\"" N_("Text output options:") "\" type=\"optiongroup\">\n" - "<_option value=\"embed\">" N_("Embed fonts") "</_option>\n" - "<_option value=\"paths\">" N_("Convert text to paths") "</_option>\n" - "<_option value=\"LaTeX\">" N_("Omit text in PDF and create LaTeX file") "</_option>\n" + "<param name=\"textToPath\" gui-text=\"" N_("Text output options:") "\" type=\"optiongroup\" appearance=\"radio\">\n" + "<option value=\"embed\">" N_("Embed fonts") "</option>\n" + "<option value=\"paths\">" N_("Convert text to paths") "</option>\n" + "<option value=\"LaTeX\">" N_("Omit text in PDF and create LaTeX file") "</option>\n" "</param>\n" - "<param name=\"blurToBitmap\" _gui-text=\"" N_("Rasterize filter effects") "\" type=\"boolean\">true</param>\n" - "<param name=\"resolution\" _gui-text=\"" N_("Resolution for rasterization (dpi):") "\" type=\"int\" min=\"1\" max=\"10000\">96</param>\n" - "<param name=\"area\" _gui-text=\"" N_("Output page size") "\" type=\"optiongroup\" >\n" - "<_option value=\"page\">" N_("Use document's page size") "</_option>" - "<_option value=\"drawing\">" N_("Use exported object's size") "</_option>" + "<param name=\"blurToBitmap\" gui-text=\"" N_("Rasterize filter effects") "\" type=\"bool\">true</param>\n" + "<param name=\"resolution\" gui-text=\"" N_("Resolution for rasterization (dpi):") "\" type=\"int\" min=\"1\" max=\"10000\">96</param>\n" + "<param name=\"area\" gui-text=\"" N_("Output page size") "\" type=\"optiongroup\" appearance=\"radio\" >\n" + "<option value=\"page\">" N_("Use document's page size") "</option>" + "<option value=\"drawing\">" N_("Use exported object's size") "</option>" "</param>" - "<param name=\"bleed\" _gui-text=\"" N_("Bleed/margin (mm):") "\" type=\"float\" min=\"-10000\" max=\"10000\">0</param>\n" - "<param name=\"exportId\" _gui-text=\"" N_("Limit export to the object with ID:") "\" type=\"string\"></param>\n" + "<param name=\"bleed\" gui-text=\"" N_("Bleed/margin (mm):") "\" type=\"float\" min=\"-10000\" max=\"10000\">0</param>\n" + "<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID:") "\" type=\"string\"></param>\n" "<output>\n" "<extension>.ps</extension>\n" "<mimetype>image/x-postscript</mimetype>\n" @@ -367,23 +367,23 @@ CairoEpsOutput::init () "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Encapsulated PostScript") "</name>\n" "<id>" SP_MODULE_KEY_PRINT_CAIRO_EPS "</id>\n" - "<param name=\"PSlevel\" _gui-text=\"" N_("Restrict to PS level:") "\" type=\"enum\" >\n" - "<_item value='PS3'>" N_("PostScript level 3") "</_item>\n" - "<_item value='PS2'>" N_("PostScript level 2") "</_item>\n" + "<param name=\"PSlevel\" gui-text=\"" N_("Restrict to PS level:") "\" type=\"optiongroup\" appearance=\"combo\" >\n" + "<option value='PS3'>" N_("PostScript level 3") "</option>\n" + "<option value='PS2'>" N_("PostScript level 2") "</option>\n" "</param>\n" - "<param name=\"textToPath\" _gui-text=\"" N_("Text output options:") "\" type=\"optiongroup\">\n" - "<_option value=\"embed\">" N_("Embed fonts") "</_option>\n" - "<_option value=\"paths\">" N_("Convert text to paths") "</_option>\n" - "<_option value=\"LaTeX\">" N_("Omit text in PDF and create LaTeX file") "</_option>\n" + "<param name=\"textToPath\" gui-text=\"" N_("Text output options:") "\" type=\"optiongroup\" appearance=\"radio\">\n" + "<option value=\"embed\">" N_("Embed fonts") "</option>\n" + "<option value=\"paths\">" N_("Convert text to paths") "</option>\n" + "<option value=\"LaTeX\">" N_("Omit text in PDF and create LaTeX file") "</option>\n" "</param>\n" - "<param name=\"blurToBitmap\" _gui-text=\"" N_("Rasterize filter effects") "\" type=\"boolean\">true</param>\n" - "<param name=\"resolution\" _gui-text=\"" N_("Resolution for rasterization (dpi):") "\" type=\"int\" min=\"1\" max=\"10000\">96</param>\n" - "<param name=\"area\" _gui-text=\"" N_("Output page size") "\" type=\"optiongroup\" >\n" - "<_option value=\"page\">" N_("Use document's page size") "</_option>" - "<_option value=\"drawing\">" N_("Use exported object's size") "</_option>" + "<param name=\"blurToBitmap\" gui-text=\"" N_("Rasterize filter effects") "\" type=\"bool\">true</param>\n" + "<param name=\"resolution\" gui-text=\"" N_("Resolution for rasterization (dpi):") "\" type=\"int\" min=\"1\" max=\"10000\">96</param>\n" + "<param name=\"area\" gui-text=\"" N_("Output page size") "\" type=\"optiongroup\" appearance=\"radio\" >\n" + "<option value=\"page\">" N_("Use document's page size") "</option>" + "<option value=\"drawing\">" N_("Use exported object's size") "</option>" "</param>" - "<param name=\"bleed\" _gui-text=\"" N_("Bleed/margin (mm)") "\" type=\"float\" min=\"-10000\" max=\"10000\">0</param>\n" - "<param name=\"exportId\" _gui-text=\"" N_("Limit export to the object with ID:") "\" type=\"string\"></param>\n" + "<param name=\"bleed\" gui-text=\"" N_("Bleed/margin (mm)") "\" type=\"float\" min=\"-10000\" max=\"10000\">0</param>\n" + "<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID:") "\" type=\"string\"></param>\n" "<output>\n" "<extension>.eps</extension>\n" "<mimetype>image/x-e-postscript</mimetype>\n" diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp index ecdea2005..cd46a66dd 100644 --- a/src/extension/internal/cairo-renderer-pdf-out.cpp +++ b/src/extension/internal/cairo-renderer-pdf-out.cpp @@ -139,7 +139,7 @@ CairoRendererPdfOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, int level = 0; try { - const gchar *new_level = mod->get_param_enum("PDFversion"); + const gchar *new_level = mod->get_param_optiongroup("PDFversion"); if((new_level != nullptr) && (g_ascii_strcasecmp("PDF-1.5", new_level) == 0)) { level = 1; } @@ -242,25 +242,25 @@ CairoRendererPdfOutput::init () "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>Portable Document Format</name>\n" "<id>org.inkscape.output.pdf.cairorenderer</id>\n" - "<param name=\"PDFversion\" _gui-text=\"" N_("Restrict to PDF version:") "\" type=\"enum\" >\n" + "<param name=\"PDFversion\" gui-text=\"" N_("Restrict to PDF version:") "\" type=\"optiongroup\" appearance=\"combo\" >\n" #if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0)) - "<_item value='PDF-1.5'>" N_("PDF 1.5") "</_item>\n" + "<option value='PDF-1.5'>" N_("PDF 1.5") "</option>\n" #endif - "<_item value='PDF-1.4'>" N_("PDF 1.4") "</_item>\n" + "<option value='PDF-1.4'>" N_("PDF 1.4") "</option>\n" "</param>\n" - "<param name=\"textToPath\" _gui-text=\"" N_("Text output options:") "\" type=\"optiongroup\">\n" - "<_option value=\"embed\">" N_("Embed fonts") "</_option>\n" - "<_option value=\"paths\">" N_("Convert text to paths") "</_option>\n" - "<_option value=\"LaTeX\">" N_("Omit text in PDF and create LaTeX file") "</_option>\n" + "<param name=\"textToPath\" gui-text=\"" N_("Text output options:") "\" type=\"optiongroup\" appearance=\"radio\">\n" + "<option value=\"embed\">" N_("Embed fonts") "</option>\n" + "<option value=\"paths\">" N_("Convert text to paths") "</option>\n" + "<option value=\"LaTeX\">" N_("Omit text in PDF and create LaTeX file") "</option>\n" "</param>\n" - "<param name=\"blurToBitmap\" _gui-text=\"" N_("Rasterize filter effects") "\" type=\"boolean\">true</param>\n" - "<param name=\"resolution\" _gui-text=\"" N_("Resolution for rasterization (dpi):") "\" type=\"int\" min=\"1\" max=\"10000\">96</param>\n" - "<param name=\"area\" _gui-text=\"" N_("Output page size:") "\" type=\"optiongroup\" >\n" - "<_option value=\"page\">" N_("Use document's page size") "</_option>" - "<_option value=\"drawing\">" N_("Use exported object's size") "</_option>" + "<param name=\"blurToBitmap\" gui-text=\"" N_("Rasterize filter effects") "\" type=\"bool\">true</param>\n" + "<param name=\"resolution\" gui-text=\"" N_("Resolution for rasterization (dpi):") "\" type=\"int\" min=\"1\" max=\"10000\">96</param>\n" + "<param name=\"area\" gui-text=\"" N_("Output page size:") "\" type=\"optiongroup\" appearance=\"radio\" >\n" + "<option value=\"page\">" N_("Use document's page size") "</option>" + "<option value=\"drawing\">" N_("Use exported object's size") "</option>" "</param>" - "<param name=\"bleed\" _gui-text=\"" N_("Bleed/margin (mm):") "\" type=\"float\" min=\"-10000\" max=\"10000\">0</param>\n" - "<param name=\"exportId\" _gui-text=\"" N_("Limit export to the object with ID:") "\" type=\"string\"></param>\n" + "<param name=\"bleed\" gui-text=\"" N_("Bleed/margin (mm):") "\" type=\"float\" min=\"-10000\" max=\"10000\">0</param>\n" + "<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID:") "\" type=\"string\"></param>\n" "<output>\n" "<extension>.pdf</extension>\n" "<mimetype>application/pdf</mimetype>\n" diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp index 30b98c462..4be021e9e 100644 --- a/src/extension/internal/emf-inout.cpp +++ b/src/extension/internal/emf-inout.cpp @@ -3647,17 +3647,17 @@ Emf::init () "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("EMF Output") "</name>\n" "<id>org.inkscape.output.emf</id>\n" - "<param name=\"textToPath\" _gui-text=\"" N_("Convert texts to paths") "\" type=\"boolean\">true</param>\n" - "<param name=\"TnrToSymbol\" _gui-text=\"" N_("Map Unicode to Symbol font") "\" type=\"boolean\">true</param>\n" - "<param name=\"TnrToWingdings\" _gui-text=\"" N_("Map Unicode to Wingdings") "\" type=\"boolean\">true</param>\n" - "<param name=\"TnrToZapfDingbats\" _gui-text=\"" N_("Map Unicode to Zapf Dingbats") "\" type=\"boolean\">true</param>\n" - "<param name=\"UsePUA\" _gui-text=\"" N_("Use MS Unicode PUA (0xF020-0xF0FF) for converted characters") "\" type=\"boolean\">false</param>\n" - "<param name=\"FixPPTCharPos\" _gui-text=\"" N_("Compensate for PPT font bug") "\" type=\"boolean\">false</param>\n" - "<param name=\"FixPPTDashLine\" _gui-text=\"" N_("Convert dashed/dotted lines to single lines") "\" type=\"boolean\">false</param>\n" - "<param name=\"FixPPTGrad2Polys\" _gui-text=\"" N_("Convert gradients to colored polygon series") "\" type=\"boolean\">false</param>\n" - "<param name=\"FixPPTLinGrad\" _gui-text=\"" N_("Use native rectangular linear gradients") "\" type=\"boolean\">false</param>\n" - "<param name=\"FixPPTPatternAsHatch\" _gui-text=\"" N_("Map all fill patterns to standard EMF hatches") "\" type=\"boolean\">false</param>\n" - "<param name=\"FixImageRot\" _gui-text=\"" N_("Ignore image rotations") "\" type=\"boolean\">false</param>\n" + "<param name=\"textToPath\" gui-text=\"" N_("Convert texts to paths") "\" type=\"bool\">true</param>\n" + "<param name=\"TnrToSymbol\" gui-text=\"" N_("Map Unicode to Symbol font") "\" type=\"bool\">true</param>\n" + "<param name=\"TnrToWingdings\" gui-text=\"" N_("Map Unicode to Wingdings") "\" type=\"bool\">true</param>\n" + "<param name=\"TnrToZapfDingbats\" gui-text=\"" N_("Map Unicode to Zapf Dingbats") "\" type=\"bool\">true</param>\n" + "<param name=\"UsePUA\" gui-text=\"" N_("Use MS Unicode PUA (0xF020-0xF0FF) for converted characters") "\" type=\"bool\">false</param>\n" + "<param name=\"FixPPTCharPos\" gui-text=\"" N_("Compensate for PPT font bug") "\" type=\"bool\">false</param>\n" + "<param name=\"FixPPTDashLine\" gui-text=\"" N_("Convert dashed/dotted lines to single lines") "\" type=\"bool\">false</param>\n" + "<param name=\"FixPPTGrad2Polys\" gui-text=\"" N_("Convert gradients to colored polygon series") "\" type=\"bool\">false</param>\n" + "<param name=\"FixPPTLinGrad\" gui-text=\"" N_("Use native rectangular linear gradients") "\" type=\"bool\">false</param>\n" + "<param name=\"FixPPTPatternAsHatch\" gui-text=\"" N_("Map all fill patterns to standard EMF hatches") "\" type=\"bool\">false</param>\n" + "<param name=\"FixImageRot\" gui-text=\"" N_("Ignore image rotations") "\" type=\"bool\">false</param>\n" "<output>\n" "<extension>.emf</extension>\n" "<mimetype>image/x-emf</mimetype>\n" diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp index 36f162ef9..ec85b9281 100644 --- a/src/extension/internal/emf-print.cpp +++ b/src/extension/internal/emf-print.cpp @@ -821,7 +821,7 @@ Geom::Path PrintEmf::pathv_to_simple_polygon(Geom::PathVector const &pathv, int v2 = unit_vector(P1_lead - P1 ); if(Geom::are_near(dot(v1,v2), 1.0, 1e-5)){ // P1 is within a straight line P1 = P1_lead; - continue; + continue; } // P1 is the center point of a turn of some angle if(!*vertices){ @@ -841,7 +841,7 @@ Geom::Path PrintEmf::pathv_to_simple_polygon(Geom::PathVector const &pathv, int } P1_trail = P1; P1 = P1_lead; - } + } return(output); } @@ -872,7 +872,7 @@ Geom::Path PrintEmf::pathv_to_rect(Geom::PathVector const &pathv, bool *is_rect, } if(cit == pR.end_open())break; } - + /* For increased numerical stability, snap the angle to the nearest 1/100th of a degree. */ double convert = 36000.0/ (2.0 * M_PI); *angle = round(*angle * convert)/convert; @@ -969,11 +969,11 @@ U_TRIVERTEX PrintEmf::make_trivertex(Geom::Point Pt, U_COLORREF uc){ U_TRIVERTEX tv; using Geom::X; using Geom::Y; - tv.x = (int32_t) round(Pt[X]); - tv.y = (int32_t) round(Pt[Y]); - tv.Red = uc.Red << 8; - tv.Green = uc.Green << 8; - tv.Blue = uc.Blue << 8; + tv.x = (int32_t) round(Pt[X]); + tv.y = (int32_t) round(Pt[Y]); + tv.Red = uc.Red << 8; + tv.Green = uc.Green << 8; + tv.Blue = uc.Blue << 8; tv.Alpha = uc.Reserved << 8; // EMF will ignore this return(tv); } @@ -997,7 +997,7 @@ void PrintEmf::do_clip_if_present(SPStyle const *style){ /* The current implementation converts only one level of clipping. If there were more clips further up the stack they should be combined with the pathvector using "and". Since this comes up rarely, and would involve a lot of searching (all the way up the stack for every - draw operation), it has not yet been implemented. + draw operation), it has not yet been implemented. Note, to debug this section of code use print statements on sp_svg_write_path(combined_pathvector). */ @@ -1010,7 +1010,7 @@ void PrintEmf::do_clip_if_present(SPStyle const *style){ item = SP_ITEM(item->parent); if(!item || SP_IS_ROOT(item))break; // this will never be a clipping path } - + if(scp != scpActive){ // change or remove the clipping if(scpActive){ // clear the existing clip rec = U_EMRRESTOREDC_set(-1); @@ -1044,10 +1044,10 @@ void PrintEmf::do_clip_if_present(SPStyle const *style){ if (SP_IS_GROUP(item)) { // not implemented // return sp_group_render(item); combined_pathvector = merge_PathVector_with_group(combined_pathvector, item, tfc); - } else if (SP_IS_SHAPE(item)) { + } else if (SP_IS_SHAPE(item)) { combined_pathvector = merge_PathVector_with_shape(combined_pathvector, item, tfc); - } else { // not implemented - } + } else { // not implemented + } } if (!combined_pathvector.empty()) { // if clipping path isn't empty, define EMF clipping record @@ -1086,10 +1086,10 @@ Geom::PathVector PrintEmf::merge_PathVector_with_group(Geom::PathVector const &c } if (SP_IS_GROUP(item)) { new_combined_pathvector = merge_PathVector_with_group(new_combined_pathvector, item, tfc); // could be endlessly recursive on a badly formed SVG - } else if (SP_IS_SHAPE(item)) { + } else if (SP_IS_SHAPE(item)) { new_combined_pathvector = merge_PathVector_with_shape(new_combined_pathvector, item, tfc); - } else { // not implemented - } + } else { // not implemented + } } return new_combined_pathvector; } @@ -1129,9 +1129,9 @@ unsigned int PrintEmf::fill( use_stroke = false; fill_transform = tf; - + int brush_stat = create_brush(style, nullptr); - + /* native linear gradients are only used if the object is a rectangle AND the gradient is parallel to the sides of the object */ bool is_Rect = false; double angle; @@ -1278,17 +1278,17 @@ unsigned int PrintEmf::fill( if (!rec || emf_append((PU_ENHMETARECORD)rec, et, U_REC_FREE)) { g_error("Fatal programming error in PrintEmf::image at EMRMODIFYWORLDTRANSFORM"); } - + for(;istop<nstops;istop++){ doff_range = tg->vector.stops[istop].offset; // next or last stop - if(rectDir == 1 || rectDir == 2){ - outUL = Geom::Point(doff_base *wRect, 0 ); - outLR = Geom::Point(doff_range*wRect, hRect); + if(rectDir == 1 || rectDir == 2){ + outUL = Geom::Point(doff_base *wRect, 0 ); + outLR = Geom::Point(doff_range*wRect, hRect); gMode = U_GRADIENT_FILL_RECT_H; } else { - outUL = Geom::Point(0, doff_base *hRect); - outLR = Geom::Point(wRect,doff_range*hRect); + outUL = Geom::Point(0, doff_base *hRect); + outLR = Geom::Point(wRect,doff_range*hRect); gMode = U_GRADIENT_FILL_RECT_V; } @@ -1810,7 +1810,7 @@ unsigned int PrintEmf::draw_pathv_to_EMF(Geom::PathVector const &pathv, const Ge /* inkscape to EMF scaling is done below, but NOT the rotation/translation transform, that is handled by the EMF MODIFYWORLDTRANSFORM record */ - + Geom::PathVector pv = pathv_to_linear_and_cubic_beziers(pathv * transform); rec = U_EMRBEGINPATH_set(); @@ -2185,15 +2185,15 @@ void PrintEmf::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>Enhanced Metafile Print</name>\n" "<id>org.inkscape.print.emf</id>\n" - "<param name=\"destination\" type=\"string\"></param>\n" - "<param name=\"textToPath\" type=\"boolean\">true</param>\n" - "<param name=\"pageBoundingBox\" type=\"boolean\">true</param>\n" - "<param name=\"FixPPTCharPos\" type=\"boolean\">false</param>\n" - "<param name=\"FixPPTDashLine\" type=\"boolean\">false</param>\n" - "<param name=\"FixPPTGrad2Polys\" type=\"boolean\">false</param>\n" - "<param name=\"FixPPTLinGrad\" type=\"boolean\">false</param>\n" - "<param name=\"FixPPTPatternAsHatch\" type=\"boolean\">false</param>\n" - "<param name=\"FixImageRot\" type=\"boolean\">false</param>\n" + "<param gui-hidden=\"true\" name=\"destination\" type=\"string\"></param>\n" + "<param gui-hidden=\"true\" name=\"textToPath\" type=\"bool\">true</param>\n" + "<param gui-hidden=\"true\" name=\"pageBoundingBox\" type=\"bool\">true</param>\n" + "<param gui-hidden=\"true\" name=\"FixPPTCharPos\" type=\"bool\">false</param>\n" + "<param gui-hidden=\"true\" name=\"FixPPTDashLine\" type=\"bool\">false</param>\n" + "<param gui-hidden=\"true\" name=\"FixPPTGrad2Polys\" type=\"bool\">false</param>\n" + "<param gui-hidden=\"true\" name=\"FixPPTLinGrad\" type=\"bool\">false</param>\n" + "<param gui-hidden=\"true\" name=\"FixPPTPatternAsHatch\" type=\"bool\">false</param>\n" + "<param gui-hidden=\"true\" name=\"FixImageRot\" type=\"bool\">false</param>\n" "<print/>\n" "</inkscape-extension>", new PrintEmf()); diff --git a/src/extension/internal/filter/bevels.h b/src/extension/internal/filter/bevels.h index 767e4e907..2fce96ca9 100644 --- a/src/extension/internal/filter/bevels.h +++ b/src/extension/internal/filter/bevels.h @@ -53,10 +53,10 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Diffuse Light") "</name>\n" "<id>org.inkscape.effect.filter.DiffuseLight</id>\n" - "<param name=\"smooth\" _gui-text=\"" N_("Smoothness") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"10\">6</param>\n" - "<param name=\"elevation\" _gui-text=\"" N_("Elevation (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">25</param>\n" - "<param name=\"azimuth\" _gui-text=\"" N_("Azimuth (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">235</param>\n" - "<param name=\"color\" _gui-text=\"" N_("Lighting color") "\" type=\"color\">-1</param>\n" + "<param name=\"smooth\" gui-text=\"" N_("Smoothness") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"10\">6</param>\n" + "<param name=\"elevation\" gui-text=\"" N_("Elevation (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">25</param>\n" + "<param name=\"azimuth\" gui-text=\"" N_("Azimuth (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">235</param>\n" + "<param name=\"color\" gui-text=\"" N_("Lighting color") "\" type=\"color\">-1</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -133,11 +133,11 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Matte Jelly") "</name>\n" "<id>org.inkscape.effect.filter.MatteJelly</id>\n" - "<param name=\"smooth\" _gui-text=\"" N_("Smoothness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"10.00\">7</param>\n" - "<param name=\"bright\" _gui-text=\"" N_("Brightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"5.00\">0.9</param>\n" - "<param name=\"elevation\" _gui-text=\"" N_("Elevation (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">60</param>\n" - "<param name=\"azimuth\" _gui-text=\"" N_("Azimuth (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">225</param>\n" - "<param name=\"color\" _gui-text=\"" N_("Lighting color") "\" type=\"color\">-1</param>\n" + "<param name=\"smooth\" gui-text=\"" N_("Smoothness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"10.00\">7</param>\n" + "<param name=\"bright\" gui-text=\"" N_("Brightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"5.00\">0.9</param>\n" + "<param name=\"elevation\" gui-text=\"" N_("Elevation (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">60</param>\n" + "<param name=\"azimuth\" gui-text=\"" N_("Azimuth (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">225</param>\n" + "<param name=\"color\" gui-text=\"" N_("Lighting color") "\" type=\"color\">-1</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -217,11 +217,11 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Specular Light") "</name>\n" "<id>org.inkscape.effect.filter.SpecularLight</id>\n" - "<param name=\"smooth\" _gui-text=\"" N_("Smoothness") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"10\">6</param>\n" - "<param name=\"bright\" _gui-text=\"" N_("Brightness") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"5\">1</param>\n" - "<param name=\"elevation\" _gui-text=\"" N_("Elevation (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">45</param>\n" - "<param name=\"azimuth\" _gui-text=\"" N_("Azimuth (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">235</param>\n" - "<param name=\"color\" _gui-text=\"" N_("Lighting color") "\" type=\"color\">-1</param>\n" + "<param name=\"smooth\" gui-text=\"" N_("Smoothness") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"10\">6</param>\n" + "<param name=\"bright\" gui-text=\"" N_("Brightness") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"5\">1</param>\n" + "<param name=\"elevation\" gui-text=\"" N_("Elevation (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">45</param>\n" + "<param name=\"azimuth\" gui-text=\"" N_("Azimuth (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">235</param>\n" + "<param name=\"color\" gui-text=\"" N_("Lighting color") "\" type=\"color\">-1</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/filter/blurs.h b/src/extension/internal/filter/blurs.h index 7db128b7c..15b9c49bb 100644 --- a/src/extension/internal/filter/blurs.h +++ b/src/extension/internal/filter/blurs.h @@ -54,9 +54,9 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Blur") "</name>\n" "<id>org.inkscape.effect.filter.Blur</id>\n" - "<param name=\"hblur\" _gui-text=\"" N_("Horizontal blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">2</param>\n" - "<param name=\"vblur\" _gui-text=\"" N_("Vertical blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">2</param>\n" - "<param name=\"content\" _gui-text=\"" N_("Blur content only") "\" type=\"boolean\">False</param>\n" + "<param name=\"hblur\" gui-text=\"" N_("Horizontal blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">2</param>\n" + "<param name=\"vblur\" gui-text=\"" N_("Vertical blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">2</param>\n" + "<param name=\"content\" gui-text=\"" N_("Blur content only") "\" type=\"bool\">false</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -125,7 +125,7 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Clean Edges") "</name>\n" "<id>org.inkscape.effect.filter.CleanEdges</id>\n" - "<param name=\"blur\" _gui-text=\"" N_("Strength") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"2.00\">0.4</param>\n" + "<param name=\"blur\" gui-text=\"" N_("Strength") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"2.00\">0.4</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -185,15 +185,15 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Cross Blur") "</name>\n" "<id>org.inkscape.effect.filter.CrossBlur</id>\n" - "<param name=\"bright\" _gui-text=\"" N_("Brightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"10.00\">0</param>\n" - "<param name=\"fade\" _gui-text=\"" N_("Fading") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.00\">0</param>\n" - "<param name=\"hblur\" _gui-text=\"" N_("Horizontal blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">5</param>\n" - "<param name=\"vblur\" _gui-text=\"" N_("Vertical blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">5</param>\n" - "<param name=\"blend\" _gui-text=\"" N_("Blend:") "\" type=\"enum\">\n" - "<_item value=\"darken\">" N_("Darken") "</_item>\n" - "<_item value=\"screen\">" N_("Screen") "</_item>\n" - "<_item value=\"multiply\">" N_("Multiply") "</_item>\n" - "<_item value=\"lighten\">" N_("Lighten") "</_item>\n" + "<param name=\"bright\" gui-text=\"" N_("Brightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"10.00\">0</param>\n" + "<param name=\"fade\" gui-text=\"" N_("Fading") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.00\">0</param>\n" + "<param name=\"hblur\" gui-text=\"" N_("Horizontal blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">5</param>\n" + "<param name=\"vblur\" gui-text=\"" N_("Vertical blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">5</param>\n" + "<param name=\"blend\" gui-text=\"" N_("Blend:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"darken\">" N_("Darken") "</option>\n" + "<option value=\"screen\">" N_("Screen") "</option>\n" + "<option value=\"multiply\">" N_("Multiply") "</option>\n" + "<option value=\"lighten\">" N_("Lighten") "</option>\n" "</param>\n" "<effect>\n" "<object-type>all</object-type>\n" @@ -224,7 +224,7 @@ CrossBlur::get_filter_text (Inkscape::Extension::Extension * ext) fade << ext->get_param_float("fade"); hblur << ext->get_param_float("hblur"); vblur << ext->get_param_float("vblur"); - blend << ext->get_param_enum("blend"); + blend << ext->get_param_optiongroup("blend"); _filter = g_strdup_printf( "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Cross Blur\">\n" @@ -260,7 +260,7 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Feather") "</name>\n" "<id>org.inkscape.effect.filter.Feather</id>\n" - "<param name=\"blur\" _gui-text=\"" N_("Strength") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">5</param>\n" + "<param name=\"blur\" gui-text=\"" N_("Strength") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">5</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -326,23 +326,23 @@ public: "<name>" N_("Out of Focus") "</name>\n" "<id>org.inkscape.effect.filter.ImageBlur</id>\n" "<param name=\"tab\" type=\"notebook\">\n" - "<page name=\"optionstab\" _gui-text=\"Options\">\n" - "<param name=\"hblur\" _gui-text=\"" N_("Horizontal blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"50.00\">3</param>\n" - "<param name=\"vblur\" _gui-text=\"" N_("Vertical blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"50.00\">3</param>\n" - "<param name=\"dilat\" _gui-text=\"" N_("Dilatation") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">6</param>\n" - "<param name=\"erosion\" _gui-text=\"" N_("Erosion") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">2</param>\n" - "<param name=\"opacity\" _gui-text=\"" N_("Opacity") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1\">1</param>\n" + "<page name=\"optionstab\" gui-text=\"Options\">\n" + "<param name=\"hblur\" gui-text=\"" N_("Horizontal blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"50.00\">3</param>\n" + "<param name=\"vblur\" gui-text=\"" N_("Vertical blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"50.00\">3</param>\n" + "<param name=\"dilat\" gui-text=\"" N_("Dilatation") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">6</param>\n" + "<param name=\"erosion\" gui-text=\"" N_("Erosion") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">2</param>\n" + "<param name=\"opacity\" gui-text=\"" N_("Opacity") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1\">1</param>\n" "</page>\n" - "<page name=\"backgroundtab\" _gui-text=\"Background\">\n" - "<param name=\"color\" _gui-text=\"" N_("Background color") "\" type=\"color\">-1</param>\n" - "<param name=\"blend\" _gui-text=\"" N_("Blend type:") "\" type=\"enum\">\n" - "<_item value=\"normal\">" N_("Normal") "</_item>\n" - "<_item value=\"darken\">" N_("Darken") "</_item>\n" - "<_item value=\"screen\">" N_("Screen") "</_item>\n" - "<_item value=\"multiply\">" N_("Multiply") "</_item>\n" - "<_item value=\"lighten\">" N_("Lighten") "</_item>\n" + "<page name=\"backgroundtab\" gui-text=\"Background\">\n" + "<param name=\"color\" gui-text=\"" N_("Background color") "\" type=\"color\">-1</param>\n" + "<param name=\"blend\" gui-text=\"" N_("Blend type:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"normal\">" N_("Normal") "</option>\n" + "<option value=\"darken\">" N_("Darken") "</option>\n" + "<option value=\"screen\">" N_("Screen") "</option>\n" + "<option value=\"multiply\">" N_("Multiply") "</option>\n" + "<option value=\"lighten\">" N_("Lighten") "</option>\n" "</param>\n" - "<param name=\"background\" _gui-text=\"" N_("Blend to background") "\" type=\"boolean\" >false</param>\n" + "<param name=\"background\" gui-text=\"" N_("Blend to background") "\" type=\"bool\" >false</param>\n" "</page>\n" "</param>\n" "<effect>\n" @@ -387,7 +387,7 @@ ImageBlur::get_filter_text (Inkscape::Extension::Extension * ext) g << ((color >> 16) & 0xff); b << ((color >> 8) & 0xff); a << (color & 0xff) / 255.0F; - blend << ext->get_param_enum("blend"); + blend << ext->get_param_optiongroup("blend"); if (ext->get_param_bool("background")) { background << "BackgroundImage" ; diff --git a/src/extension/internal/filter/bumps.h b/src/extension/internal/filter/bumps.h index bcde76542..21328f45d 100644 --- a/src/extension/internal/filter/bumps.h +++ b/src/extension/internal/filter/bumps.h @@ -81,58 +81,58 @@ public: "<name>" N_("Bump") "</name>\n" "<id>org.inkscape.effect.filter.Bump</id>\n" "<param name=\"tab\" type=\"notebook\">\n" - "<page name=\"optionstab\" _gui-text=\"Options\">\n" - "<param name=\"simplifyImage\" _gui-text=\"" N_("Image simplification") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">0.01</param>\n" - "<param name=\"simplifyBump\" _gui-text=\"" N_("Bump simplification") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">0.01</param>\n" - "<param name=\"crop\" _gui-text=\"" N_("Crop") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">0</param>\n" - "<_param name=\"sourceHeader\" type=\"description\" appearance=\"header\">" N_("Bump source") "</_param>\n" - "<param name=\"red\" _gui-text=\"" N_("Red") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">0</param>\n" - "<param name=\"green\" _gui-text=\"" N_("Green") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">0</param>\n" - "<param name=\"blue\" _gui-text=\"" N_("Blue") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">0</param>\n" - "<param name=\"background\" _gui-text=\"" N_("Bump from background") "\" indent=\"1\" type=\"boolean\">false</param>\n" + "<page name=\"optionstab\" gui-text=\"Options\">\n" + "<param name=\"simplifyImage\" gui-text=\"" N_("Image simplification") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">0.01</param>\n" + "<param name=\"simplifyBump\" gui-text=\"" N_("Bump simplification") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">0.01</param>\n" + "<param name=\"crop\" gui-text=\"" N_("Crop") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">0</param>\n" + "<label appearance=\"header\">" N_("Bump source") "</label>\n" + "<param name=\"red\" gui-text=\"" N_("Red") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">0</param>\n" + "<param name=\"green\" gui-text=\"" N_("Green") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">0</param>\n" + "<param name=\"blue\" gui-text=\"" N_("Blue") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">0</param>\n" + "<param name=\"background\" gui-text=\"" N_("Bump from background") "\" indent=\"1\" type=\"bool\">false</param>\n" "</page>\n" - "<page name=\"lightingtab\" _gui-text=\"Lighting\">\n" - "<param name=\"lightType\" _gui-text=\"" N_("Lighting type:") "\" type=\"enum\">\n" - "<_item value=\"specular\">" N_("Specular") "</_item>\n" - "<_item value=\"diffuse\">" N_("Diffuse") "</_item>\n" + "<page name=\"lightingtab\" gui-text=\"Lighting\">\n" + "<param name=\"lightType\" gui-text=\"" N_("Lighting type:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"specular\">" N_("Specular") "</option>\n" + "<option value=\"diffuse\">" N_("Diffuse") "</option>\n" "</param>\n" - "<param name=\"height\" _gui-text=\"" N_("Height") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"50.\">5</param>\n" - "<param name=\"lightness\" _gui-text=\"" N_("Lightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"5.\">1</param>\n" - "<param name=\"precision\" _gui-text=\"" N_("Precision") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"128\">15</param>\n" - "<param name=\"lightingColor\" _gui-text=\"" N_("Color") "\" type=\"color\">-1</param>\n" + "<param name=\"height\" gui-text=\"" N_("Height") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"50.\">5</param>\n" + "<param name=\"lightness\" gui-text=\"" N_("Lightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"5.\">1</param>\n" + "<param name=\"precision\" gui-text=\"" N_("Precision") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"128\">15</param>\n" + "<param name=\"lightingColor\" gui-text=\"" N_("Color") "\" type=\"color\">-1</param>\n" "</page>\n" - "<page name=\"lightsourcetab\" _gui-text=\"" N_("Light source") "\">\n" - "<param name=\"lightSource\" _gui-text=\"" N_("Light source:") "\" type=\"enum\">\n" - "<_item value=\"distant\">" N_("Distant") "</_item>\n" - "<_item value=\"point\">" N_("Point") "</_item>\n" - "<_item value=\"spot\">" N_("Spot") "</_item>\n" + "<page name=\"lightsourcetab\" gui-text=\"" N_("Light source") "\">\n" + "<param name=\"lightSource\" gui-text=\"" N_("Light source:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"distant\">" N_("Distant") "</option>\n" + "<option value=\"point\">" N_("Point") "</option>\n" + "<option value=\"spot\">" N_("Spot") "</option>\n" "</param>\n" - "<_param name=\"distantHeader\" type=\"description\" appearance=\"header\">" N_("Distant light options") "</_param>\n" - "<param name=\"distantAzimuth\" _gui-text=\"" N_("Azimuth") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"360\">225</param>\n" - "<param name=\"distantElevation\" _gui-text=\"" N_("Elevation") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"180\">45</param>\n" - "<_param name=\"pointHeader\" type=\"description\" appearance=\"header\">" N_("Point light options") "</_param>\n" - "<param name=\"pointX\" _gui-text=\"" N_("X location") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">526</param>\n" - "<param name=\"pointY\" _gui-text=\"" N_("Y location") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">372</param>\n" - "<param name=\"pointZ\" _gui-text=\"" N_("Z location") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"5000\">150</param>\n" - "<_param name=\"spotHeader\" type=\"description\" appearance=\"header\">" N_("Spot light options") "</_param>\n" - "<param name=\"spotX\" _gui-text=\"" N_("X location") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">526</param>\n" - "<param name=\"spotY\" _gui-text=\"" N_("Y location") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">372</param>\n" - "<param name=\"spotZ\" _gui-text=\"" N_("Z location") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">150</param>\n" - "<param name=\"spotAtX\" _gui-text=\"" N_("X target") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">0</param>\n" - "<param name=\"spotAtY\" _gui-text=\"" N_("Y target") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">0</param>\n" - "<param name=\"spotAtZ\" _gui-text=\"" N_("Z target") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"0\">-1000</param>\n" - "<param name=\"spotExponent\" _gui-text=\"" N_("Specular exponent") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"1\" max=\"100\">1</param>\n" - "<param name=\"spotConeAngle\" _gui-text=\"" N_("Cone angle") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"100\">50</param>\n" + "<label appearance=\"header\">" N_("Distant light options") "</label>\n" + "<param name=\"distantAzimuth\" gui-text=\"" N_("Azimuth") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"360\">225</param>\n" + "<param name=\"distantElevation\" gui-text=\"" N_("Elevation") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"180\">45</param>\n" + "<label appearance=\"header\">" N_("Point light options") "</label>\n" + "<param name=\"pointX\" gui-text=\"" N_("X location") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">526</param>\n" + "<param name=\"pointY\" gui-text=\"" N_("Y location") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">372</param>\n" + "<param name=\"pointZ\" gui-text=\"" N_("Z location") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"5000\">150</param>\n" + "<label appearance=\"header\">" N_("Spot light options") "</label>\n" + "<param name=\"spotX\" gui-text=\"" N_("X location") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">526</param>\n" + "<param name=\"spotY\" gui-text=\"" N_("Y location") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">372</param>\n" + "<param name=\"spotZ\" gui-text=\"" N_("Z location") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">150</param>\n" + "<param name=\"spotAtX\" gui-text=\"" N_("X target") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">0</param>\n" + "<param name=\"spotAtY\" gui-text=\"" N_("Y target") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"5000\">0</param>\n" + "<param name=\"spotAtZ\" gui-text=\"" N_("Z target") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"-5000\" max=\"0\">-1000</param>\n" + "<param name=\"spotExponent\" gui-text=\"" N_("Specular exponent") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"1\" max=\"100\">1</param>\n" + "<param name=\"spotConeAngle\" gui-text=\"" N_("Cone angle") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"100\">50</param>\n" "</page>\n" - "<page name=\"colortab\" _gui-text=\"Color bump\">\n" - "<param name=\"imageColor\" _gui-text=\"" N_("Image color") "\" type=\"color\">-987158017</param>\n" - "<param name=\"colorize\" _gui-text=\"" N_("Color bump") "\" type=\"boolean\" >false</param>\n" - "<param name=\"blend\" _gui-text=\"" N_("Blend type:") "\" type=\"enum\">\n" - "<_item value=\"normal\">" N_("Normal") "</_item>\n" - "<_item value=\"darken\">" N_("Darken") "</_item>\n" - "<_item value=\"screen\">" N_("Screen") "</_item>\n" - "<_item value=\"multiply\">" N_("Multiply") "</_item>\n" - "<_item value=\"lighten\">" N_("Lighten") "</_item>\n" + "<page name=\"colortab\" gui-text=\"Color bump\">\n" + "<param name=\"imageColor\" gui-text=\"" N_("Image color") "\" type=\"color\">-987158017</param>\n" + "<param name=\"colorize\" gui-text=\"" N_("Color bump") "\" type=\"bool\" >false</param>\n" + "<param name=\"blend\" gui-text=\"" N_("Blend type:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"normal\">" N_("Normal") "</option>\n" + "<option value=\"darken\">" N_("Darken") "</option>\n" + "<option value=\"screen\">" N_("Screen") "</option>\n" + "<option value=\"multiply\">" N_("Multiply") "</option>\n" + "<option value=\"lighten\">" N_("Lighten") "</option>\n" "</param>\n" "</page>\n" "</param>\n" @@ -181,7 +181,7 @@ Bump::get_filter_text (Inkscape::Extension::Extension * ext) green << ext->get_param_float("green"); blue << ext->get_param_float("blue"); crop << ext->get_param_float("crop"); - blend << ext->get_param_enum("blend"); + blend << ext->get_param_optiongroup("blend"); guint32 lightingColor = ext->get_param_color("lightingColor"); guint32 imageColor = ext->get_param_color("imageColor"); @@ -192,7 +192,7 @@ Bump::get_filter_text (Inkscape::Extension::Extension * ext) bumpSource << "blur1" ; } - const gchar *lightType = ext->get_param_enum("lightType"); + const gchar *lightType = ext->get_param_optiongroup("lightType"); if ((g_ascii_strcasecmp("specular", lightType) == 0)) { // Specular lightStart << "<feSpecularLighting lighting-color=\"rgb(" << ((lightingColor >> 24) & 0xff) << "," @@ -209,7 +209,7 @@ Bump::get_filter_text (Inkscape::Extension::Extension * ext) lightEnd << "</feDiffuseLighting>"; } - const gchar *lightSource = ext->get_param_enum("lightSource"); + const gchar *lightSource = ext->get_param_optiongroup("lightSource"); if ((g_ascii_strcasecmp("distant", lightSource) == 0)) { // Distant lightOptions << "<feDistantLight azimuth=\"" << ext->get_param_int("distantAzimuth") << "\" elevation=\"" @@ -310,49 +310,49 @@ public: "<name>" N_("Wax Bump") "</name>\n" "<id>org.inkscape.effect.filter.WaxBump</id>\n" "<param name=\"tab\" type=\"notebook\">\n" - "<page name=\"optionstab\" _gui-text=\"Options\">\n" - "<param name=\"simplifyImage\" _gui-text=\"" N_("Image simplification") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">1.5</param>\n" - "<param name=\"simplifyBump\" _gui-text=\"" N_("Bump simplification") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">1</param>\n" - "<param name=\"crop\" _gui-text=\"" N_("Crop") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">1</param>\n" - "<_param name=\"sourceHeader\" type=\"description\" appearance=\"header\">" N_("Bump source") "</_param>\n" - "<param name=\"red\" _gui-text=\"" N_("Red") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0</param>\n" - "<param name=\"green\" _gui-text=\"" N_("Green") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0</param>\n" - "<param name=\"blue\" _gui-text=\"" N_("Blue") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0</param>\n" - "<param name=\"background\" _gui-text=\"" N_("Background:") "\" type=\"enum\">\n" - "<_item value=\"flood1\">" N_("Color") "</_item>\n" - "<_item value=\"SourceGraphic\">" N_("Image") "</_item>\n" - "<_item value=\"blur1\">" N_("Blurred image") "</_item>\n" + "<page name=\"optionstab\" gui-text=\"Options\">\n" + "<param name=\"simplifyImage\" gui-text=\"" N_("Image simplification") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">1.5</param>\n" + "<param name=\"simplifyBump\" gui-text=\"" N_("Bump simplification") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">1</param>\n" + "<param name=\"crop\" gui-text=\"" N_("Crop") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">1</param>\n" + "<label appearance=\"header\">" N_("Bump source") "</label>\n" + "<param name=\"red\" gui-text=\"" N_("Red") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0</param>\n" + "<param name=\"green\" gui-text=\"" N_("Green") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0</param>\n" + "<param name=\"blue\" gui-text=\"" N_("Blue") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0</param>\n" + "<param name=\"background\" gui-text=\"" N_("Background:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"flood1\">" N_("Color") "</option>\n" + "<option value=\"SourceGraphic\">" N_("Image") "</option>\n" + "<option value=\"blur1\">" N_("Blurred image") "</option>\n" "</param>\n" - "<param name=\"bgopacity\" _gui-text=\"" N_("Background opacity") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.\">0</param>\n" + "<param name=\"bgopacity\" gui-text=\"" N_("Background opacity") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.\">0</param>\n" "</page>\n" - "<page name=\"lightingtab\" _gui-text=\"" N_("Lighting") "\">\n" - "<param name=\"lightingColor\" _gui-text=\"" N_("Color") "\" type=\"color\">-1</param>\n" - "<param name=\"height\" _gui-text=\"" N_("Height") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">5</param>\n" - "<param name=\"lightness\" _gui-text=\"" N_("Lightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"10.\">1.4</param>\n" - "<param name=\"precision\" _gui-text=\"" N_("Precision") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"50\">35</param>\n" - "<param name=\"distantAzimuth\" _gui-text=\"" N_("Azimuth") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"360\">225</param>\n" - "<param name=\"distantElevation\" _gui-text=\"" N_("Elevation") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"180\">60</param>\n" - "<param name=\"lightingblend\" _gui-text=\"" N_("Lighting blend:") "\" type=\"enum\">\n" - "<_item value=\"screen\">" N_("Screen") "</_item>\n" - "<_item value=\"normal\">" N_("Normal") "</_item>\n" - "<_item value=\"darken\">" N_("Darken") "</_item>\n" - "<_item value=\"multiply\">" N_("Multiply") "</_item>\n" - "<_item value=\"lighten\">" N_("Lighten") "</_item>\n" + "<page name=\"lightingtab\" gui-text=\"" N_("Lighting") "\">\n" + "<param name=\"lightingColor\" gui-text=\"" N_("Color") "\" type=\"color\">-1</param>\n" + "<param name=\"height\" gui-text=\"" N_("Height") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-50.\" max=\"50.\">5</param>\n" + "<param name=\"lightness\" gui-text=\"" N_("Lightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"10.\">1.4</param>\n" + "<param name=\"precision\" gui-text=\"" N_("Precision") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"50\">35</param>\n" + "<param name=\"distantAzimuth\" gui-text=\"" N_("Azimuth") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"360\">225</param>\n" + "<param name=\"distantElevation\" gui-text=\"" N_("Elevation") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"180\">60</param>\n" + "<param name=\"lightingblend\" gui-text=\"" N_("Lighting blend:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"screen\">" N_("Screen") "</option>\n" + "<option value=\"normal\">" N_("Normal") "</option>\n" + "<option value=\"darken\">" N_("Darken") "</option>\n" + "<option value=\"multiply\">" N_("Multiply") "</option>\n" + "<option value=\"lighten\">" N_("Lighten") "</option>\n" "</param>\n" - "<param name=\"highlightblend\" _gui-text=\"" N_("Highlight blend:") "\" type=\"enum\">\n" - "<_item value=\"screen\">" N_("Screen") "</_item>\n" - "<_item value=\"normal\">" N_("Normal") "</_item>\n" - "<_item value=\"darken\">" N_("Darken") "</_item>\n" - "<_item value=\"multiply\">" N_("Multiply") "</_item>\n" - "<_item value=\"lighten\">" N_("Lighten") "</_item>\n" + "<param name=\"highlightblend\" gui-text=\"" N_("Highlight blend:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"screen\">" N_("Screen") "</option>\n" + "<option value=\"normal\">" N_("Normal") "</option>\n" + "<option value=\"darken\">" N_("Darken") "</option>\n" + "<option value=\"multiply\">" N_("Multiply") "</option>\n" + "<option value=\"lighten\">" N_("Lighten") "</option>\n" "</param>\n" "</page>\n" - "<page name=\"colortab\" _gui-text=\"Bump\">\n" - "<param name=\"imageColor\" _gui-text=\"" N_("Bump color") "\" type=\"color\">-520083713</param>\n" - "<param name=\"revert\" _gui-text=\"" N_("Revert bump") "\" type=\"boolean\" >false</param>\n" - "<param name=\"transparency\" _gui-text=\"" N_("Transparency type:") "\" type=\"enum\">\n" - "<_item value=\"atop\">" N_("Atop") "</_item>\n" - "<_item value=\"in\">" N_("In") "</_item>\n" + "<page name=\"colortab\" gui-text=\"Bump\">\n" + "<param name=\"imageColor\" gui-text=\"" N_("Bump color") "\" type=\"color\">-520083713</param>\n" + "<param name=\"revert\" gui-text=\"" N_("Revert bump") "\" type=\"bool\" >false</param>\n" + "<param name=\"transparency\" gui-text=\"" N_("Transparency type:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"atop\">" N_("Atop") "</option>\n" + "<option value=\"in\">" N_("In") "</option>\n" "</param>\n" "</page>\n" "</param>\n" @@ -414,7 +414,7 @@ WaxBump::get_filter_text (Inkscape::Extension::Extension * ext) green << ext->get_param_float("green") - 0.72; blue << ext->get_param_float("blue") - 0.07; - background << ext->get_param_enum("background"); + background << ext->get_param_optiongroup("background"); bgopacity << ext->get_param_float("bgopacity"); height << ext->get_param_float("height"); @@ -440,9 +440,9 @@ WaxBump::get_filter_text (Inkscape::Extension::Extension * ext) revert << "out" ; } - lightingblend << ext->get_param_enum("lightingblend"); - highlightblend << ext->get_param_enum("highlightblend"); - transparency << ext->get_param_enum("transparency"); + lightingblend << ext->get_param_optiongroup("lightingblend"); + highlightblend << ext->get_param_optiongroup("highlightblend"); + transparency << ext->get_param_optiongroup("transparency"); _filter = g_strdup_printf( "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Wax Bump\">\n" diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index a98311e38..1b0b9e28e 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -74,10 +74,10 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Brilliance") "</name>\n" "<id>org.inkscape.effect.filter.Brilliance</id>\n" - "<param name=\"brightness\" _gui-text=\"" N_("Brightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"10.00\">2</param>\n" - "<param name=\"sat\" _gui-text=\"" N_("Over-saturation") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.0\" max=\"10.00\">0.5</param>\n" - "<param name=\"lightness\" _gui-text=\"" N_("Lightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0</param>\n" - "<param name=\"invert\" _gui-text=\"" N_("Inverted") "\" type=\"boolean\">false</param>\n" + "<param name=\"brightness\" gui-text=\"" N_("Brightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"10.00\">2</param>\n" + "<param name=\"sat\" gui-text=\"" N_("Over-saturation") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.0\" max=\"10.00\">0.5</param>\n" + "<param name=\"lightness\" gui-text=\"" N_("Lightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0</param>\n" + "<param name=\"invert\" gui-text=\"" N_("Inverted") "\" type=\"bool\">false</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -155,16 +155,16 @@ public: "<name>" N_("Channel Painting") "</name>\n" "<id>org.inkscape.effect.filter.ChannelPaint</id>\n" "<param name=\"tab\" type=\"notebook\">\n" - "<page name=\"optionstab\" _gui-text=\"Options\">\n" - "<param name=\"saturation\" _gui-text=\"" N_("Saturation") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.\">1</param>\n" - "<param name=\"red\" _gui-text=\"" N_("Red") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">-1</param>\n" - "<param name=\"green\" _gui-text=\"" N_("Green") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0.5</param>\n" - "<param name=\"blue\" _gui-text=\"" N_("Blue") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0.5</param>\n" - "<param name=\"alpha\" _gui-text=\"" N_("Alpha") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">1</param>\n" - "<param name=\"invert\" _gui-text=\"" N_("Inverted") "\" type=\"boolean\">false</param>\n" + "<page name=\"optionstab\" gui-text=\"Options\">\n" + "<param name=\"saturation\" gui-text=\"" N_("Saturation") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.\">1</param>\n" + "<param name=\"red\" gui-text=\"" N_("Red") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">-1</param>\n" + "<param name=\"green\" gui-text=\"" N_("Green") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0.5</param>\n" + "<param name=\"blue\" gui-text=\"" N_("Blue") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0.5</param>\n" + "<param name=\"alpha\" gui-text=\"" N_("Alpha") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">1</param>\n" + "<param name=\"invert\" gui-text=\"" N_("Inverted") "\" type=\"bool\">false</param>\n" "</page>\n" - "<page name=\"colortab\" _gui-text=\"Color\">\n" - "<param name=\"color\" _gui-text=\"" N_("Color") "\" type=\"color\">16777215</param>\n" + "<page name=\"colortab\" gui-text=\"Color\">\n" + "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">16777215</param>\n" "</page>\n" "</param>\n" "<effect>\n" @@ -256,26 +256,26 @@ public: "<name>" N_("Color Blindness") "</name>\n" "<id>org.inkscape.effect.filter.ColorBlindness</id>\n" "<param name=\"tab\" type=\"notebook\">\n" - "<page name=\"optionstab\" _gui-text=\"Options\">\n" - "<param name=\"type\" _gui-text=\"" N_("Blindness type:") "\" type=\"enum\">\n" - "<_item value=\"0.618 0.32 0.062 0 0 0.163 0.775 0.062 0 0 0.163 0.32 0.516 0 0 0 0 0 1 0 \">" N_("Rod monochromacy (atypical achromatopsia)") "</_item>\n" - "<_item value=\"0.299 0.587 0.114 0 0 0.299 0.587 0.114 0 0 0.299 0.587 0.114 0 0 0 0 0 1 0 \">" N_("Cone monochromacy (typical achromatopsia)") "</_item>\n" - "<_item value=\"0.8 0.2 0 0 0 0.2583 0.74167 0 0 0 0 0.14167 0.85833 0 0 0 0 0 1 0 \">" N_("Green weak (deuteranomaly)") "</_item>\n" - "<_item value=\"0.625 0.375 0 0 0 0.7 0.3 0 0 0 0 0.3 0.7 0 0 0 0 0 1 0 \">" N_("Green blind (deuteranopia)") "</_item>\n" - "<_item value=\"0.8166 0.1833 0 0 0 0.333 0.666 0 0 0 0 0.125 0.875 0 0 0 0 0 1 0 \">" N_("Red weak (protanomaly)") "</_item>\n" - "<_item value=\"0.566 0.43333 0 0 0 0.55833 0.4416 0 0 0 0 0.24167 0.75833 0 0 0 0 0 1 0 \">" N_("Red blind (protanopia)") "</_item>\n" - "<_item value=\"0.966 0.033 0 0 0 0 0.733 0.266 0 0 0 0.1833 0.816 0 0 0 0 0 1 0 \">" N_("Blue weak (tritanomaly)") "</_item>\n" - "<_item value=\"0.95 0.05 0 0 0 0.2583 0.4333 0.5667 0 0 0 0.475 0.525 0 0 0 0 0 1 0 \">" N_("Blue blind (tritanopia)") "</_item>\n" + "<page name=\"optionstab\" gui-text=\"Options\">\n" + "<param name=\"type\" gui-text=\"" N_("Blindness type:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"0.618 0.32 0.062 0 0 0.163 0.775 0.062 0 0 0.163 0.32 0.516 0 0 0 0 0 1 0 \">" N_("Rod monochromacy (atypical achromatopsia)") "</option>\n" + "<option value=\"0.299 0.587 0.114 0 0 0.299 0.587 0.114 0 0 0.299 0.587 0.114 0 0 0 0 0 1 0 \">" N_("Cone monochromacy (typical achromatopsia)") "</option>\n" + "<option value=\"0.8 0.2 0 0 0 0.2583 0.74167 0 0 0 0 0.14167 0.85833 0 0 0 0 0 1 0 \">" N_("Green weak (deuteranomaly)") "</option>\n" + "<option value=\"0.625 0.375 0 0 0 0.7 0.3 0 0 0 0 0.3 0.7 0 0 0 0 0 1 0 \">" N_("Green blind (deuteranopia)") "</option>\n" + "<option value=\"0.8166 0.1833 0 0 0 0.333 0.666 0 0 0 0 0.125 0.875 0 0 0 0 0 1 0 \">" N_("Red weak (protanomaly)") "</option>\n" + "<option value=\"0.566 0.43333 0 0 0 0.55833 0.4416 0 0 0 0 0.24167 0.75833 0 0 0 0 0 1 0 \">" N_("Red blind (protanopia)") "</option>\n" + "<option value=\"0.966 0.033 0 0 0 0 0.733 0.266 0 0 0 0.1833 0.816 0 0 0 0 0 1 0 \">" N_("Blue weak (tritanomaly)") "</option>\n" + "<option value=\"0.95 0.05 0 0 0 0.2583 0.4333 0.5667 0 0 0 0.475 0.525 0 0 0 0 0 1 0 \">" N_("Blue blind (tritanopia)") "</option>\n" "</param>\n" "</page>\n" - "<page name=\"helptab\" _gui-text=\"Help\">\n" - "<param name=\"help\" xml:space=\"preserve\" type=\"description\">\n" + "<page name=\"helptab\" gui-text=\"Help\">\n" + "<label xml:space=\"preserve\">\n" "Filters based on https://openclipart.org/detail/22299/Color%20Blindness%20filters\n" "\n" "These filters don't correctly reflect actual color blindness for two main reasons:\n" " * Everyone is different, and is not affected exactly the same way.\n" " * The filters are in the RGB color space, and ignore confusion lines.\n" - "</param>\n" + "</label>\n" "</page>\n" "</param>\n" "<effect>\n" @@ -297,7 +297,7 @@ ColorBlindness::get_filter_text (Inkscape::Extension::Extension * ext) if (_filter != nullptr) g_free((void *)_filter); std::ostringstream type; - type << ext->get_param_enum("type"); + type << ext->get_param_optiongroup("type"); _filter = g_strdup_printf( "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Color Blindness\">\n" @@ -330,8 +330,8 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Color Shift") "</name>\n" "<id>org.inkscape.effect.filter.ColorShift</id>\n" - "<param name=\"shift\" _gui-text=\"" N_("Shift (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">330</param>\n" - "<param name=\"sat\" _gui-text=\"" N_("Saturation") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1\">0.6</param>\n" + "<param name=\"shift\" gui-text=\"" N_("Shift (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">330</param>\n" + "<param name=\"sat\" gui-text=\"" N_("Saturation") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1\">0.6</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -394,27 +394,27 @@ public: "<name>" N_("Colorize") "</name>\n" "<id>org.inkscape.effect.filter.Colorize</id>\n" "<param name=\"tab\" type=\"notebook\">\n" - "<page name=\"optionstab\" _gui-text=\"Options\">\n" - "<param name=\"hlight\" _gui-text=\"" N_("Harsh light") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"10\">0</param>\n" - "<param name=\"nlight\" _gui-text=\"" N_("Normal light") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"10\">1</param>\n" - "<param name=\"duotone\" _gui-text=\"" N_("Duotone") "\" type=\"boolean\" >false</param>\n" - "<param name=\"blend1\" _gui-text=\"" N_("Blend 1:") "\" type=\"enum\">\n" - "<_item value=\"multiply\">" N_("Multiply") "</_item>\n" - "<_item value=\"normal\">" N_("Normal") "</_item>\n" - "<_item value=\"screen\">" N_("Screen") "</_item>\n" - "<_item value=\"lighten\">" N_("Lighten") "</_item>\n" - "<_item value=\"darken\">" N_("Darken") "</_item>\n" + "<page name=\"optionstab\" gui-text=\"Options\">\n" + "<param name=\"hlight\" gui-text=\"" N_("Harsh light") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"10\">0</param>\n" + "<param name=\"nlight\" gui-text=\"" N_("Normal light") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"10\">1</param>\n" + "<param name=\"duotone\" gui-text=\"" N_("Duotone") "\" type=\"bool\" >false</param>\n" + "<param name=\"blend1\" gui-text=\"" N_("Blend 1:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"multiply\">" N_("Multiply") "</option>\n" + "<option value=\"normal\">" N_("Normal") "</option>\n" + "<option value=\"screen\">" N_("Screen") "</option>\n" + "<option value=\"lighten\">" N_("Lighten") "</option>\n" + "<option value=\"darken\">" N_("Darken") "</option>\n" "</param>\n" - "<param name=\"blend2\" _gui-text=\"" N_("Blend 2:") "\" type=\"enum\">\n" - "<_item value=\"screen\">" N_("Screen") "</_item>\n" - "<_item value=\"multiply\">" N_("Multiply") "</_item>\n" - "<_item value=\"normal\">" N_("Normal") "</_item>\n" - "<_item value=\"lighten\">" N_("Lighten") "</_item>\n" - "<_item value=\"darken\">" N_("Darken") "</_item>\n" + "<param name=\"blend2\" gui-text=\"" N_("Blend 2:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"screen\">" N_("Screen") "</option>\n" + "<option value=\"multiply\">" N_("Multiply") "</option>\n" + "<option value=\"normal\">" N_("Normal") "</option>\n" + "<option value=\"lighten\">" N_("Lighten") "</option>\n" + "<option value=\"darken\">" N_("Darken") "</option>\n" "</param>\n" "</page>\n" - "<page name=\"colortab\" _gui-text=\"Color\">\n" - "<param name=\"color\" _gui-text=\"" N_("Color") "\" type=\"color\">-1639776001</param>\n" + "<page name=\"colortab\" gui-text=\"Color\">\n" + "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">-1639776001</param>\n" "</page>\n" "</param>\n" "<effect>\n" @@ -454,8 +454,8 @@ Colorize::get_filter_text (Inkscape::Extension::Extension * ext) hlight << ext->get_param_float("hlight"); nlight << ext->get_param_float("nlight"); - blend1 << ext->get_param_enum("blend1"); - blend2 << ext->get_param_enum("blend2"); + blend1 << ext->get_param_optiongroup("blend1"); + blend2 << ext->get_param_optiongroup("blend2"); if (ext->get_param_bool("duotone")) { duotone << "0"; } else { @@ -500,12 +500,12 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Component Transfer") "</name>\n" "<id>org.inkscape.effect.filter.ComponentTransfer</id>\n" - "<param name=\"type\" _gui-text=\"" N_("Type:") "\" type=\"enum\">\n" - "<_item value=\"identity\">" N_("Identity") "</_item>\n" - "<_item value=\"table\">" N_("Table") "</_item>\n" - "<_item value=\"discrete\">" N_("Discrete") "</_item>\n" - "<_item value=\"linear\">" N_("Linear") "</_item>\n" - "<_item value=\"gamma\">" N_("Gamma") "</_item>\n" + "<param name=\"type\" gui-text=\"" N_("Type:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"identity\">" N_("Identity") "</option>\n" + "<option value=\"table\">" N_("Table") "</option>\n" + "<option value=\"discrete\">" N_("Discrete") "</option>\n" + "<option value=\"linear\">" N_("Linear") "</option>\n" + "<option value=\"gamma\">" N_("Gamma") "</option>\n" "</param>\n" "<effect>\n" "<object-type>all</object-type>\n" @@ -526,7 +526,7 @@ ComponentTransfer::get_filter_text (Inkscape::Extension::Extension * ext) if (_filter != nullptr) g_free((void *)_filter); std::ostringstream CTfunction; - const gchar *type = ext->get_param_enum("type"); + const gchar *type = ext->get_param_optiongroup("type"); if ((g_ascii_strcasecmp("identity", type) == 0)) { CTfunction << "<feFuncR type=\"identity\" tableValues=\"1 0\" />\n" @@ -586,20 +586,20 @@ public: "<name>" N_("Duochrome") "</name>\n" "<id>org.inkscape.effect.filter.Duochrome</id>\n" "<param name=\"tab\" type=\"notebook\">\n" - "<page name=\"optionstab\" _gui-text=\"Options\">\n" - "<param name=\"fluo\" _gui-text=\"" N_("Fluorescence level") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"2\">0</param>\n" - "<param name=\"swap\" _gui-text=\"" N_("Swap:") "\" type=\"enum\">\n" - "<_item value=\"none\">" N_("No swap") "</_item>\n" - "<_item value=\"full\">" N_("Color and alpha") "</_item>\n" - "<_item value=\"color\">" N_("Color only") "</_item>\n" - "<_item value=\"alpha\">" N_("Alpha only") "</_item>\n" + "<page name=\"optionstab\" gui-text=\"Options\">\n" + "<param name=\"fluo\" gui-text=\"" N_("Fluorescence level") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"2\">0</param>\n" + "<param name=\"swap\" gui-text=\"" N_("Swap:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"none\">" N_("No swap") "</option>\n" + "<option value=\"full\">" N_("Color and alpha") "</option>\n" + "<option value=\"color\">" N_("Color only") "</option>\n" + "<option value=\"alpha\">" N_("Alpha only") "</option>\n" "</param>\n" "</page>\n" - "<page name=\"co11tab\" _gui-text=\"Color 1\">\n" - "<param name=\"color1\" _gui-text=\"" N_("Color 1") "\" type=\"color\">1364325887</param>\n" + "<page name=\"co11tab\" gui-text=\"Color 1\">\n" + "<param name=\"color1\" gui-text=\"" N_("Color 1") "\" type=\"color\">1364325887</param>\n" "</page>\n" - "<page name=\"co12tab\" _gui-text=\"Color 2\">\n" - "<param name=\"color2\" _gui-text=\"" N_("Color 2") "\" type=\"color\">-65281</param>\n" + "<page name=\"co12tab\" gui-text=\"Color 2\">\n" + "<param name=\"color2\" gui-text=\"" N_("Color 2") "\" type=\"color\">-65281</param>\n" "</page>\n" "</param>\n" "<effect>\n" @@ -635,7 +635,7 @@ Duochrome::get_filter_text (Inkscape::Extension::Extension * ext) guint32 color1 = ext->get_param_color("color1"); guint32 color2 = ext->get_param_color("color2"); float fluorescence = ext->get_param_float("fluo"); - const gchar *swaptype = ext->get_param_enum("swap"); + const gchar *swaptype = ext->get_param_optiongroup("swap"); r1 << ((color1 >> 24) & 0xff); g1 << ((color1 >> 16) & 0xff); @@ -710,20 +710,20 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Extract Channel") "</name>\n" "<id>org.inkscape.effect.filter.ExtractChannel</id>\n" - "<param name=\"source\" _gui-text=\"" N_("Channel:") "\" type=\"enum\">\n" - "<_item value=\"r\">" N_("Red") "</_item>\n" - "<_item value=\"g\">" N_("Green") "</_item>\n" - "<_item value=\"b\">" N_("Blue") "</_item>\n" - "<_item value=\"c\">" N_("Cyan") "</_item>\n" - "<_item value=\"m\">" N_("Magenta") "</_item>\n" - "<_item value=\"y\">" N_("Yellow") "</_item>\n" + "<param name=\"source\" gui-text=\"" N_("Channel:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"r\">" N_("Red") "</option>\n" + "<option value=\"g\">" N_("Green") "</option>\n" + "<option value=\"b\">" N_("Blue") "</option>\n" + "<option value=\"c\">" N_("Cyan") "</option>\n" + "<option value=\"m\">" N_("Magenta") "</option>\n" + "<option value=\"y\">" N_("Yellow") "</option>\n" "</param>\n" - "<param name=\"blend\" _gui-text=\"" N_("Background blend mode:") "\" type=\"enum\">\n" - "<_item value=\"multiply\">" N_("Multiply") "</_item>\n" - "<_item value=\"normal\">" N_("Normal") "</_item>\n" - "<_item value=\"screen\">" N_("Screen") "</_item>\n" + "<param name=\"blend\" gui-text=\"" N_("Background blend mode:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"multiply\">" N_("Multiply") "</option>\n" + "<option value=\"normal\">" N_("Normal") "</option>\n" + "<option value=\"screen\">" N_("Screen") "</option>\n" "</param>\n" - "<param name=\"alpha\" _gui-text=\"" N_("Channel to alpha") "\" type=\"boolean\">false</param>\n" + "<param name=\"alpha\" gui-text=\"" N_("Channel to alpha") "\" type=\"bool\">false</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -745,9 +745,9 @@ ExtractChannel::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream blend; std::ostringstream colors; - blend << ext->get_param_enum("blend"); + blend << ext->get_param_optiongroup("blend"); - const gchar *channel = ext->get_param_enum("source"); + const gchar *channel = ext->get_param_optiongroup("source"); if (ext->get_param_bool("alpha")) { if ((g_ascii_strcasecmp("r", channel) == 0)) { colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0"; @@ -816,10 +816,10 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Fade to Black or White") "</name>\n" "<id>org.inkscape.effect.filter.FadeToBW</id>\n" - "<param name=\"level\" _gui-text=\"" N_("Level") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1\">1</param>\n" - "<param name=\"fadeto\" _gui-text=\"" N_("Fade to:") "\" type=\"enum\">\n" - "<_item value=\"black\">" N_("Black") "</_item>\n" - "<_item value=\"white\">" N_("White") "</_item>\n" + "<param name=\"level\" gui-text=\"" N_("Level") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1\">1</param>\n" + "<param name=\"fadeto\" gui-text=\"" N_("Fade to:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"black\">" N_("Black") "</option>\n" + "<option value=\"white\">" N_("White") "</option>\n" "</param>\n" "<effect>\n" "<object-type>all</object-type>\n" @@ -844,7 +844,7 @@ FadeToBW::get_filter_text (Inkscape::Extension::Extension * ext) level << ext->get_param_float("level"); - const gchar *fadeto = ext->get_param_enum("fadeto"); + const gchar *fadeto = ext->get_param_optiongroup("fadeto"); if ((g_ascii_strcasecmp("white", fadeto) == 0)) { // White wlevel << (1 - ext->get_param_float("level")); @@ -895,11 +895,11 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Greyscale") "</name>\n" "<id>org.inkscape.effect.filter.Greyscale</id>\n" - "<param name=\"red\" _gui-text=\"" N_("Red") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0.21</param>\n" - "<param name=\"green\" _gui-text=\"" N_("Green") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0.72</param>\n" - "<param name=\"blue\" _gui-text=\"" N_("Blue") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0.072</param>\n" - "<param name=\"strength\" _gui-text=\"" N_("Lightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0</param>\n" - "<param name=\"transparent\" _gui-text=\"" N_("Transparent") "\" type=\"boolean\" >false</param>\n" + "<param name=\"red\" gui-text=\"" N_("Red") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0.21</param>\n" + "<param name=\"green\" gui-text=\"" N_("Green") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0.72</param>\n" + "<param name=\"blue\" gui-text=\"" N_("Blue") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0.072</param>\n" + "<param name=\"strength\" gui-text=\"" N_("Lightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.00\" max=\"10.00\">0</param>\n" + "<param name=\"transparent\" gui-text=\"" N_("Transparent") "\" type=\"bool\" >false</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -981,16 +981,16 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Invert") "</name>\n" "<id>org.inkscape.effect.filter.Invert</id>\n" - "<param name=\"channels\" _gui-text=\"" N_("Invert channels:") "\" type=\"enum\">\n" - "<_item value=\"0\">" N_("No inversion") "</_item>\n" - "<_item value=\"1\">" N_("Red and blue") "</_item>\n" - "<_item value=\"2\">" N_("Red and green") "</_item>\n" - "<_item value=\"3\">" N_("Green and blue") "</_item>\n" + "<param name=\"channels\" gui-text=\"" N_("Invert channels:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"0\">" N_("No inversion") "</option>\n" + "<option value=\"1\">" N_("Red and blue") "</option>\n" + "<option value=\"2\">" N_("Red and green") "</option>\n" + "<option value=\"3\">" N_("Green and blue") "</option>\n" "</param>\n" - "<param name=\"opacify\" _gui-text=\"" N_("Light transparency") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1\">0</param>\n" - "<param name=\"hue\" _gui-text=\"" N_("Invert hue") "\" type=\"boolean\" >false</param>\n" - "<param name=\"lightness\" _gui-text=\"" N_("Invert lightness") "\" type=\"boolean\" >false</param>\n" - "<param name=\"transparency\" _gui-text=\"" N_("Invert transparency") "\" type=\"boolean\" >false</param>\n" + "<param name=\"opacify\" gui-text=\"" N_("Light transparency") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1\">0</param>\n" + "<param name=\"hue\" gui-text=\"" N_("Invert hue") "\" type=\"bool\" >false</param>\n" + "<param name=\"lightness\" gui-text=\"" N_("Invert lightness") "\" type=\"bool\" >false</param>\n" + "<param name=\"transparency\" gui-text=\"" N_("Invert transparency") "\" type=\"bool\" >false</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -1031,7 +1031,7 @@ Invert::get_filter_text (Inkscape::Extension::Extension * ext) } if (ext->get_param_bool("lightness")) { - switch (atoi(ext->get_param_enum("channels"))) { + switch (atoi(ext->get_param_optiongroup("channels"))) { case 1: line1 << "0 0 -1"; line2 << "0 -1 0"; @@ -1055,7 +1055,7 @@ Invert::get_filter_text (Inkscape::Extension::Extension * ext) } col5 << "1"; } else { - switch (atoi(ext->get_param_enum("channels"))) { + switch (atoi(ext->get_param_optiongroup("channels"))) { case 1: line1 << "0 0 1"; line2 << "0 1 0"; @@ -1116,9 +1116,9 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Lighting") "</name>\n" "<id>org.inkscape.effect.filter.Lighting</id>\n" - "<param name=\"amplitude\" _gui-text=\"" N_("Lights") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"20.00\">1</param>\n" - "<param name=\"exponent\" _gui-text=\"" N_("Shadows") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"20.00\">1</param>\n" - "<param name=\"offset\" _gui-text=\"" N_("Offset") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-1.00\" max=\"1.00\">0</param>\n" + "<param name=\"amplitude\" gui-text=\"" N_("Lights") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"20.00\">1</param>\n" + "<param name=\"exponent\" gui-text=\"" N_("Shadows") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"20.00\">1</param>\n" + "<param name=\"offset\" gui-text=\"" N_("Offset") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-1.00\" max=\"1.00\">0</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -1187,8 +1187,8 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Lightness-Contrast") "</name>\n" "<id>org.inkscape.effect.filter.LightnessContrast</id>\n" - "<param name=\"lightness\" _gui-text=\"" N_("Lightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-100\" max=\"100\">0</param>\n" - "<param name=\"contrast\" _gui-text=\"" N_("Contrast") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-100\" max=\"100\">0</param>\n" + "<param name=\"lightness\" gui-text=\"" N_("Lightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-100\" max=\"100\">0</param>\n" + "<param name=\"contrast\" gui-text=\"" N_("Contrast") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-100\" max=\"100\">0</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -1267,19 +1267,19 @@ public: "<name>" N_("Nudge RGB") "</name>\n" "<id>org.inkscape.effect.filter.NudgeRGB</id>\n" "<param name=\"tab\" type=\"notebook\">\n" - "<page name=\"offsettab\" _gui-text=\"Offset\">\n" - "<_param name=\"redOffset\" type=\"description\" appearance=\"header\">" N_("Red offset") "</_param>\n" - "<param name=\"rx\" _gui-text=\"" N_("X") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n" - "<param name=\"ry\" _gui-text=\"" N_("Y") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n" - "<_param name=\"greenOffset\" type=\"description\" appearance=\"header\">" N_("Green offset") "</_param>\n" - "<param name=\"gx\" _gui-text=\"" N_("X") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">6</param>\n" - "<param name=\"gy\" _gui-text=\"" N_("Y") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">7</param>\n" - "<_param name=\"redOffset\" type=\"description\" appearance=\"header\">" N_("Blue offset") "</_param>\n" - "<param name=\"bx\" _gui-text=\"" N_("X") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">1</param>\n" - "<param name=\"by\" _gui-text=\"" N_("Y") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-16</param>\n" + "<page name=\"offsettab\" gui-text=\"Offset\">\n" + "<label appearance=\"header\">" N_("Red offset") "</label>\n" + "<param name=\"rx\" gui-text=\"" N_("X") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n" + "<param name=\"ry\" gui-text=\"" N_("Y") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n" + "<label appearance=\"header\">" N_("Green offset") "</label>\n" + "<param name=\"gx\" gui-text=\"" N_("X") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">6</param>\n" + "<param name=\"gy\" gui-text=\"" N_("Y") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">7</param>\n" + "<label appearance=\"header\">" N_("Blue offset") "</label>\n" + "<param name=\"bx\" gui-text=\"" N_("X") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">1</param>\n" + "<param name=\"by\" gui-text=\"" N_("Y") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-16</param>\n" "</page>\n" - "<page name=\"coltab\" _gui-text=\"Color\">\n" - "<param name=\"color\" _gui-text=\"" N_("Background color") "\" type=\"color\">255</param>\n" + "<page name=\"coltab\" gui-text=\"Color\">\n" + "<param name=\"color\" gui-text=\"" N_("Background color") "\" type=\"color\">255</param>\n" "</page>\n" "</param>\n" "<effect>\n" @@ -1379,19 +1379,19 @@ public: "<name>" N_("Nudge CMY") "</name>\n" "<id>org.inkscape.effect.filter.NudgeCMY</id>\n" "<param name=\"tab\" type=\"notebook\">\n" - "<page name=\"offsettab\" _gui-text=\"Offset\">\n" - "<_param name=\"cyanOffset\" type=\"description\" appearance=\"header\">" N_("Cyan offset") "</_param>\n" - "<param name=\"cx\" _gui-text=\"" N_("X") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n" - "<param name=\"cy\" _gui-text=\"" N_("Y") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n" - "<_param name=\"magentaOffset\" type=\"description\" appearance=\"header\">" N_("Magenta offset") "</_param>\n" - "<param name=\"mx\" _gui-text=\"" N_("X") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">6</param>\n" - "<param name=\"my\" _gui-text=\"" N_("Y") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">7</param>\n" - "<_param name=\"yellowOffset\" type=\"description\" appearance=\"header\">" N_("Yellow offset") "</_param>\n" - "<param name=\"yx\" _gui-text=\"" N_("X") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">1</param>\n" - "<param name=\"yy\" _gui-text=\"" N_("Y") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-16</param>\n" + "<page name=\"offsettab\" gui-text=\"Offset\">\n" + "<label appearance=\"header\">" N_("Cyan offset") "</label>\n" + "<param name=\"cx\" gui-text=\"" N_("X") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n" + "<param name=\"cy\" gui-text=\"" N_("Y") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n" + "<label appearance=\"header\">" N_("Magenta offset") "</label>\n" + "<param name=\"mx\" gui-text=\"" N_("X") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">6</param>\n" + "<param name=\"my\" gui-text=\"" N_("Y") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">7</param>\n" + "<label appearance=\"header\">" N_("Yellow offset") "</label>\n" + "<param name=\"yx\" gui-text=\"" N_("X") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">1</param>\n" + "<param name=\"yy\" gui-text=\"" N_("Y") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-16</param>\n" "</page>\n" - "<page name=\"coltab\" _gui-text=\"Color\">\n" - "<param name=\"color\" _gui-text=\"" N_("Background color") "\" type=\"color\">-1</param>\n" + "<page name=\"coltab\" gui-text=\"Color\">\n" + "<param name=\"color\" gui-text=\"" N_("Background color") "\" type=\"color\">-1</param>\n" "</page>\n" "</param>\n" "<effect>\n" @@ -1484,20 +1484,20 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Quadritone Fantasy") "</name>\n" "<id>org.inkscape.effect.filter.Quadritone</id>\n" - "<param name=\"dist\" _gui-text=\"" N_("Hue distribution (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">280</param>\n" - "<param name=\"colors\" _gui-text=\"" N_("Colors") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">100</param>\n" - "<param name=\"blend1\" _gui-text=\"" N_("Blend 1:") "\" type=\"enum\">\n" - "<_item value=\"normal\">" N_("Normal") "</_item>\n" - "<_item value=\"multiply\">" N_("Multiply") "</_item>\n" - "<_item value=\"screen\">" N_("Screen") "</_item>\n" + "<param name=\"dist\" gui-text=\"" N_("Hue distribution (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">280</param>\n" + "<param name=\"colors\" gui-text=\"" N_("Colors") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">100</param>\n" + "<param name=\"blend1\" gui-text=\"" N_("Blend 1:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"normal\">" N_("Normal") "</option>\n" + "<option value=\"multiply\">" N_("Multiply") "</option>\n" + "<option value=\"screen\">" N_("Screen") "</option>\n" "</param>\n" - "<param name=\"sat\" _gui-text=\"" N_("Over-saturation") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"1.00\">0</param>\n" - "<param name=\"blend2\" _gui-text=\"" N_("Blend 2:") "\" type=\"enum\">\n" - "<_item value=\"normal\">" N_("Normal") "</_item>\n" - "<_item value=\"screen\">" N_("Screen") "</_item>\n" - "<_item value=\"multiply\">" N_("Multiply") "</_item>\n" - "<_item value=\"lighten\">" N_("Lighten") "</_item>\n" - "<_item value=\"darken\">" N_("Darken") "</_item>\n" + "<param name=\"sat\" gui-text=\"" N_("Over-saturation") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"1.00\">0</param>\n" + "<param name=\"blend2\" gui-text=\"" N_("Blend 2:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"normal\">" N_("Normal") "</option>\n" + "<option value=\"screen\">" N_("Screen") "</option>\n" + "<option value=\"multiply\">" N_("Multiply") "</option>\n" + "<option value=\"lighten\">" N_("Lighten") "</option>\n" + "<option value=\"darken\">" N_("Darken") "</option>\n" "</param>\n" "<effect>\n" "<object-type>all</object-type>\n" @@ -1526,9 +1526,9 @@ Quadritone::get_filter_text (Inkscape::Extension::Extension * ext) dist << ext->get_param_int("dist"); colors << ext->get_param_int("colors"); - blend1 << ext->get_param_enum("blend1"); + blend1 << ext->get_param_optiongroup("blend1"); sat << ext->get_param_float("sat"); - blend2 << ext->get_param_enum("blend2"); + blend2 << ext->get_param_optiongroup("blend2"); _filter = g_strdup_printf( "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Quadritone fantasy\">\n" @@ -1567,23 +1567,23 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Simple blend") "</name>\n" "<id>org.inkscape.effect.filter.SimpleBlend</id>\n" - "<param name=\"color\" _gui-text=\"" N_("Color") "\" type=\"color\">16777215</param>\n" - "<param name=\"blendmode\" _gui-text=\"" N_("Blend mode:") "\" type=\"enum\">\n" - "<_item value=\"normal\">" N_("Normal") "</_item>\n" - "<_item value=\"multiply\">" N_("Multiply") "</_item>\n" - "<_item value=\"screen\">" N_("Screen") "</_item>\n" - "<_item value=\"saturation\">" N_("Saturation") "</_item>\n" - "<_item value=\"darken\">" N_("Darken") "</_item>\n" - "<_item value=\"difference\">" N_("Difference") "</_item>\n" - "<_item value=\"lighten\">" N_("Lighten") "</_item>\n" - "<_item value=\"luminosity\">" N_("Luminosity") "</_item>\n" - "<_item value=\"overlay\">" N_("Overlay") "</_item>\n" - "<_item value=\"color-dodge\">" N_("Color Dodge") "</_item>\n" - "<_item value=\"color-burn\">" N_("Color Burn") "</_item>\n" - "<_item value=\"color\">" N_("Color") "</_item>\n" - "<_item value=\"hard-light\">" N_("Hard Light") "</_item>\n" - "<_item value=\"hue\">" N_("Hue") "</_item>\n" - "<_item value=\"exclusion\">" N_("Exclusion") "</_item>\n" + "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">16777215</param>\n" + "<param name=\"blendmode\" gui-text=\"" N_("Blend mode:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"normal\">" N_("Normal") "</option>\n" + "<option value=\"multiply\">" N_("Multiply") "</option>\n" + "<option value=\"screen\">" N_("Screen") "</option>\n" + "<option value=\"saturation\">" N_("Saturation") "</option>\n" + "<option value=\"darken\">" N_("Darken") "</option>\n" + "<option value=\"difference\">" N_("Difference") "</option>\n" + "<option value=\"lighten\">" N_("Lighten") "</option>\n" + "<option value=\"luminosity\">" N_("Luminosity") "</option>\n" + "<option value=\"overlay\">" N_("Overlay") "</option>\n" + "<option value=\"color-dodge\">" N_("Color Dodge") "</option>\n" + "<option value=\"color-burn\">" N_("Color Burn") "</option>\n" + "<option value=\"color\">" N_("Color") "</option>\n" + "<option value=\"hard-light\">" N_("Hard Light") "</option>\n" + "<option value=\"hue\">" N_("Hue") "</option>\n" + "<option value=\"exclusion\">" N_("Exclusion") "</option>\n" "</param>\n" "<effect>\n" "<object-type>all</object-type>\n" @@ -1614,7 +1614,7 @@ SimpleBlend::get_filter_text (Inkscape::Extension::Extension * ext) g << ((color >> 16) & 0xff); b << ((color >> 8) & 0xff); a << (color & 0xff) / 255.0F; - blend << ext->get_param_enum("blendmode"); + blend << ext->get_param_optiongroup("blendmode"); _filter = g_strdup_printf( "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Simple blend\">\n" @@ -1653,10 +1653,10 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Solarize") "</name>\n" "<id>org.inkscape.effect.filter.Solarize</id>\n" - "<param name=\"rotate\" _gui-text=\"" N_("Hue rotation (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">0</param>\n" - "<param name=\"type\" _gui-text=\"" N_("Type:") "\" type=\"enum\">\n" - "<_item value=\"solarize\">" N_("Solarize") "</_item>\n" - "<_item value=\"moonarize\">" N_("Moonarize") "</_item>\n" + "<param name=\"rotate\" gui-text=\"" N_("Hue rotation (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">0</param>\n" + "<param name=\"type\" gui-text=\"" N_("Type:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"solarize\">" N_("Solarize") "</option>\n" + "<option value=\"moonarize\">" N_("Moonarize") "</option>\n" "</param>\n" "<effect>\n" "<object-type>all</object-type>\n" @@ -1682,7 +1682,7 @@ Solarize::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream blend2; rotate << ext->get_param_int("rotate"); - const gchar *type = ext->get_param_enum("type"); + const gchar *type = ext->get_param_optiongroup("type"); if ((g_ascii_strcasecmp("solarize", type) == 0)) { // Solarize blend1 << "darken"; @@ -1741,32 +1741,32 @@ public: "<name>" N_("Tritone") "</name>\n" "<id>org.inkscape.effect.filter.Tritone</id>\n" "<param name=\"tab\" type=\"notebook\">\n" - "<page name=\"optionstab\" _gui-text=\"Options\">\n" - "<param name=\"type\" _gui-text=\"" N_("Type:") "\" type=\"enum\">\n" - "<_item value=\"normal\">" N_("Normal") "</_item>\n" - "<_item value=\"enhue\">" N_("Enhance hue") "</_item>\n" - "<_item value=\"phospho\">" N_("Phosphorescence") "</_item>\n" - "<_item value=\"phosphoB\">" N_("Colored nights") "</_item>\n" - "<_item value=\"htb\">" N_("Hue to background") "</_item>\n" + "<page name=\"optionstab\" gui-text=\"Options\">\n" + "<param name=\"type\" gui-text=\"" N_("Type:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"normal\">" N_("Normal") "</option>\n" + "<option value=\"enhue\">" N_("Enhance hue") "</option>\n" + "<option value=\"phospho\">" N_("Phosphorescence") "</option>\n" + "<option value=\"phosphoB\">" N_("Colored nights") "</option>\n" + "<option value=\"htb\">" N_("Hue to background") "</option>\n" "</param>\n" - "<param name=\"globalblend\" _gui-text=\"" N_("Global blend:") "\" type=\"enum\">\n" - "<_item value=\"lighten\">" N_("Lighten") "</_item>\n" - "<_item value=\"screen\">" N_("Screen") "</_item>\n" - "<_item value=\"multiply\">" N_("Multiply") "</_item>\n" - "<_item value=\"darken\">" N_("Darken") "</_item>\n" + "<param name=\"globalblend\" gui-text=\"" N_("Global blend:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"lighten\">" N_("Lighten") "</option>\n" + "<option value=\"screen\">" N_("Screen") "</option>\n" + "<option value=\"multiply\">" N_("Multiply") "</option>\n" + "<option value=\"darken\">" N_("Darken") "</option>\n" "</param>\n" - "<param name=\"glow\" _gui-text=\"" N_("Glow") "\" type=\"float\" appearance=\"full\" min=\"0.01\" max=\"10\">0.01</param>\n" - "<param name=\"glowblend\" _gui-text=\"" N_("Glow blend:") "\" type=\"enum\">\n" - "<_item value=\"normal\">" N_("Normal") "</_item>\n" - "<_item value=\"multiply\">" N_("Multiply") "</_item>\n" - "<_item value=\"darken\">" N_("Darken") "</_item>\n" + "<param name=\"glow\" gui-text=\"" N_("Glow") "\" type=\"float\" appearance=\"full\" min=\"0.01\" max=\"10\">0.01</param>\n" + "<param name=\"glowblend\" gui-text=\"" N_("Glow blend:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"normal\">" N_("Normal") "</option>\n" + "<option value=\"multiply\">" N_("Multiply") "</option>\n" + "<option value=\"darken\">" N_("Darken") "</option>\n" "</param>\n" - "<param name=\"llight\" _gui-text=\"" N_("Local light") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"10\">0</param>\n" - "<param name=\"glight\" _gui-text=\"" N_("Global light") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"10\">1</param>\n" + "<param name=\"llight\" gui-text=\"" N_("Local light") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"10\">0</param>\n" + "<param name=\"glight\" gui-text=\"" N_("Global light") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"10\">1</param>\n" "</page>\n" - "<page name=\"co1tab\" _gui-text=\"Color\">\n" - "<param name=\"dist\" _gui-text=\"" N_("Hue distribution (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">0</param>\n" - "<param name=\"color\" _gui-text=\"" N_("Color") "\" type=\"color\">-73203457</param>\n" + "<page name=\"co1tab\" gui-text=\"Color\">\n" + "<param name=\"dist\" gui-text=\"" N_("Hue distribution (°):") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">0</param>\n" + "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">-73203457</param>\n" "</page>\n" "</param>\n" "<effect>\n" @@ -1808,14 +1808,14 @@ Tritone::get_filter_text (Inkscape::Extension::Extension * ext) g << ((color >> 16) & 0xff); b << ((color >> 8) & 0xff); a << (color & 0xff) / 255.0F; - globalblend << ext->get_param_enum("globalblend"); + globalblend << ext->get_param_optiongroup("globalblend"); dist << ext->get_param_int("dist"); glow << ext->get_param_float("glow"); - glowblend << ext->get_param_enum("glowblend"); + glowblend << ext->get_param_optiongroup("glowblend"); llight << ext->get_param_float("llight"); glight << ext->get_param_float("glight"); - const gchar *type = ext->get_param_enum("type"); + const gchar *type = ext->get_param_optiongroup("type"); if ((g_ascii_strcasecmp("enhue", type) == 0)) { // Enhance hue c1in2 << "flood"; diff --git a/src/extension/internal/filter/distort.h b/src/extension/internal/filter/distort.h index fffa3fbec..b8f66b63f 100644 --- a/src/extension/internal/filter/distort.h +++ b/src/extension/internal/filter/distort.h @@ -67,29 +67,29 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Felt Feather") "</name>\n" "<id>org.inkscape.effect.filter.FeltFeather</id>\n" - "<param name=\"type\" _gui-text=\"" N_("Type:") "\" type=\"enum\">\n" - "<_item value=\"in\">" N_("In") "</_item>\n" - "<_item value=\"out\">" N_("Out") "</_item>\n" + "<param name=\"type\" gui-text=\"" N_("Type:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"in\">" N_("In") "</option>\n" + "<option value=\"out\">" N_("Out") "</option>\n" "</param>\n" - "<param name=\"hblur\" _gui-text=\"" N_("Horizontal blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"30.00\">15</param>\n" - "<param name=\"vblur\" _gui-text=\"" N_("Vertical blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"30.00\">15</param>\n" - "<param name=\"dilat\" _gui-text=\"" N_("Dilatation") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">1</param>\n" - "<param name=\"erosion\" _gui-text=\"" N_("Erosion") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">0</param>\n" - "<param name=\"stroke\" _gui-text=\"" N_("Stroke:") "\" type=\"enum\">\n" - "<_item value=\"atop\">" N_("Normal") "</_item>\n" - "<_item value=\"over\">" N_("Wide") "</_item>\n" - "<_item value=\"in\">" N_("Narrow") "</_item>\n" - "<_item value=\"xor\">" N_("No fill") "</_item>\n" + "<param name=\"hblur\" gui-text=\"" N_("Horizontal blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"30.00\">15</param>\n" + "<param name=\"vblur\" gui-text=\"" N_("Vertical blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"30.00\">15</param>\n" + "<param name=\"dilat\" gui-text=\"" N_("Dilatation") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">1</param>\n" + "<param name=\"erosion\" gui-text=\"" N_("Erosion") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">0</param>\n" + "<param name=\"stroke\" gui-text=\"" N_("Stroke:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"atop\">" N_("Normal") "</option>\n" + "<option value=\"over\">" N_("Wide") "</option>\n" + "<option value=\"in\">" N_("Narrow") "</option>\n" + "<option value=\"xor\">" N_("No fill") "</option>\n" "</param>\n" - "<param name=\"turbulence\" indent=\"1\" _gui-text=\"" N_("Turbulence:") "\" type=\"enum\">\n" - "<_item value=\"fractalNoise\">" N_("Fractal noise") "</_item>\n" - "<_item value=\"turbulence\">" N_("Turbulence") "</_item>\n" + "<param name=\"turbulence\" indent=\"1\" gui-text=\"" N_("Turbulence:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"fractalNoise\">" N_("Fractal noise") "</option>\n" + "<option value=\"turbulence\">" N_("Turbulence") "</option>\n" "</param>\n" - "<param name=\"hfreq\" _gui-text=\"" N_("Horizontal frequency") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.\">5</param>\n" - "<param name=\"vfreq\" _gui-text=\"" N_("Vertical frequency") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.\">5</param>\n" - "<param name=\"complexity\" _gui-text=\"" N_("Complexity") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">3</param>\n" - "<param name=\"variation\" _gui-text=\"" N_("Variation") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"100\">0</param>\n" - "<param name=\"intensity\" _gui-text=\"" N_("Intensity") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"100\">30</param>\n" + "<param name=\"hfreq\" gui-text=\"" N_("Horizontal frequency") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.\">5</param>\n" + "<param name=\"vfreq\" gui-text=\"" N_("Vertical frequency") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.\">5</param>\n" + "<param name=\"complexity\" gui-text=\"" N_("Complexity") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">3</param>\n" + "<param name=\"variation\" gui-text=\"" N_("Variation") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"100\">0</param>\n" + "<param name=\"intensity\" gui-text=\"" N_("Intensity") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"100\">30</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -130,16 +130,16 @@ FeltFeather::get_filter_text (Inkscape::Extension::Extension * ext) dilat << ext->get_param_float("dilat"); erosion << -ext->get_param_float("erosion"); - turbulence << ext->get_param_enum("turbulence"); + turbulence << ext->get_param_optiongroup("turbulence"); hfreq << ext->get_param_float("hfreq") / 100; vfreq << ext->get_param_float("vfreq") / 100; complexity << ext->get_param_int("complexity"); variation << ext->get_param_int("variation"); intensity << ext->get_param_float("intensity"); - stroke << ext->get_param_enum("stroke"); + stroke << ext->get_param_optiongroup("stroke"); - const gchar *maptype = ext->get_param_enum("type"); + const gchar *maptype = ext->get_param_optiongroup("type"); if (g_ascii_strcasecmp("in", maptype) == 0) { map << "composite3"; } else { @@ -190,15 +190,15 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Roughen") "</name>\n" "<id>org.inkscape.effect.filter.Roughen</id>\n" - "<param name=\"type\" _gui-text=\"" N_("Turbulence type:") "\" type=\"enum\">\n" - "<_item value=\"fractalNoise\">" N_("Fractal noise") "</_item>\n" - "<_item value=\"turbulence\">" N_("Turbulence") "</_item>\n" + "<param name=\"type\" gui-text=\"" N_("Turbulence type:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"fractalNoise\">" N_("Fractal noise") "</option>\n" + "<option value=\"turbulence\">" N_("Turbulence") "</option>\n" "</param>\n" - "<param name=\"hfreq\" _gui-text=\"" N_("Horizontal frequency") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.1\" max=\"1000.00\">1.3</param>\n" - "<param name=\"vfreq\" _gui-text=\"" N_("Vertical frequency") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.1\" max=\"1000.00\">1.3</param>\n" - "<param name=\"complexity\" _gui-text=\"" N_("Complexity") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">5</param>\n" - "<param name=\"variation\" _gui-text=\"" N_("Variation") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"360\">0</param>\n" - "<param name=\"intensity\" _gui-text=\"" N_("Intensity") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"50\">6.6</param>\n" + "<param name=\"hfreq\" gui-text=\"" N_("Horizontal frequency") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.1\" max=\"1000.00\">1.3</param>\n" + "<param name=\"vfreq\" gui-text=\"" N_("Vertical frequency") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.1\" max=\"1000.00\">1.3</param>\n" + "<param name=\"complexity\" gui-text=\"" N_("Complexity") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">5</param>\n" + "<param name=\"variation\" gui-text=\"" N_("Variation") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"360\">0</param>\n" + "<param name=\"intensity\" gui-text=\"" N_("Intensity") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"50\">6.6</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -225,7 +225,7 @@ Roughen::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream variation; std::ostringstream intensity; - type << ext->get_param_enum("type"); + type << ext->get_param_optiongroup("type"); hfreq << ext->get_param_float("hfreq") / 100; vfreq << ext->get_param_float("vfreq") / 100; complexity << ext->get_param_int("complexity"); diff --git a/src/extension/internal/filter/filter-file.cpp b/src/extension/internal/filter/filter-file.cpp index f6d9a58f5..afa979fd5 100644 --- a/src/extension/internal/filter/filter-file.cpp +++ b/src/extension/internal/filter/filter-file.cpp @@ -91,7 +91,7 @@ void mywriter::put (char ch) { _str += ch; } void -Filter::filters_load_node (Inkscape::XML::Node * node, gchar * menuname) +Filter::filters_load_node (Inkscape::XML::Node *node, gchar * menuname) { gchar const * label = node->attribute("inkscape:label"); gchar const * menu = node->attribute("inkscape:menu"); diff --git a/src/extension/internal/filter/filter.cpp b/src/extension/internal/filter/filter.cpp index 98c0e8ce6..45f2d0af8 100644 --- a/src/extension/internal/filter/filter.cpp +++ b/src/extension/internal/filter/filter.cpp @@ -131,7 +131,7 @@ void Filter::effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::Vie Inkscape::XML::Node * defsrepr = document->doc()->getDefs()->getRepr(); for(auto spitem : items) { - Inkscape::XML::Node * node = spitem->getRepr(); + Inkscape::XML::Node *node = spitem->getRepr(); SPCSSAttr * css = sp_repr_css_attr(node, "style"); gchar const * filter = sp_repr_css_property(css, "filter", nullptr); diff --git a/src/extension/internal/filter/filter.h b/src/extension/internal/filter/filter.h index 35a73900c..cb3ed363b 100644 --- a/src/extension/internal/filter/filter.h +++ b/src/extension/internal/filter/filter.h @@ -50,7 +50,7 @@ public: /* File loader related */ static void filters_all_files(); - static void filters_load_node(Inkscape::XML::Node * node, gchar * menuname); + static void filters_load_node(Inkscape::XML::Node *node, gchar * menuname); }; diff --git a/src/extension/internal/filter/image.h b/src/extension/internal/filter/image.h index e9dcb1d8e..2a0e3346e 100644 --- a/src/extension/internal/filter/image.h +++ b/src/extension/internal/filter/image.h @@ -49,13 +49,13 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Edge Detect") "</name>\n" "<id>org.inkscape.effect.filter.EdgeDetect</id>\n" - "<param name=\"type\" _gui-text=\"" N_("Detect:") "\" type=\"enum\" >\n" - "<_item value=\"all\">" N_("All") "</_item>\n" - "<_item value=\"vertical\">" N_("Vertical lines") "</_item>\n" - "<_item value=\"horizontal\">" N_("Horizontal lines") "</_item>\n" + "<param name=\"type\" gui-text=\"" N_("Detect:") "\" type=\"optiongroup\" appearance=\"combo\" >\n" + "<option value=\"all\">" N_("All") "</option>\n" + "<option value=\"vertical\">" N_("Vertical lines") "</option>\n" + "<option value=\"horizontal\">" N_("Horizontal lines") "</option>\n" "</param>\n" - "<param name=\"level\" _gui-text=\"" N_("Level") "\" type=\"float\" appearance=\"full\" min=\"0.1\" max=\"100.0\">1.0</param>\n" - "<param name=\"inverted\" _gui-text=\"" N_("Invert colors") "\" type=\"boolean\" >false</param>\n" + "<param name=\"level\" gui-text=\"" N_("Level") "\" type=\"float\" appearance=\"full\" min=\"0.1\" max=\"100.0\">1.0</param>\n" + "<param name=\"inverted\" gui-text=\"" N_("Invert colors") "\" type=\"bool\" >false</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -79,7 +79,7 @@ EdgeDetect::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream inverted; std::ostringstream level; - const gchar *type = ext->get_param_enum("type"); + const gchar *type = ext->get_param_optiongroup("type"); level << 1 / ext->get_param_float("level"); diff --git a/src/extension/internal/filter/morphology.h b/src/extension/internal/filter/morphology.h index fc71b6ea2..9c2915302 100644 --- a/src/extension/internal/filter/morphology.h +++ b/src/extension/internal/filter/morphology.h @@ -58,17 +58,17 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Cross-smooth") "</name>\n" "<id>org.inkscape.effect.filter.crosssmooth</id>\n" - "<param name=\"type\" _gui-text=\"" N_("Type:") "\" type=\"enum\">\n" - "<_item value=\"in\">" N_("Inner") "</_item>\n" - "<_item value=\"over\">" N_("Outer") "</_item>\n" - "<_item value=\"xor\">" N_("Open") "</_item>\n" + "<param name=\"type\" gui-text=\"" N_("Type:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"in\">" N_("Inner") "</option>\n" + "<option value=\"over\">" N_("Outer") "</option>\n" + "<option value=\"xor\">" N_("Open") "</option>\n" "</param>\n" - "<param name=\"width\" _gui-text=\"" N_("Width") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"30.\">10</param>\n" - "<param name=\"level\" _gui-text=\"" N_("Level") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.2\" max=\"2\">1</param>\n" - "<param name=\"dilat\" _gui-text=\"" N_("Dilatation") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"100\">10</param>\n" - "<param name=\"erosion\" _gui-text=\"" N_("Erosion") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"100\">1</param>\n" - "<param name=\"antialias\" _gui-text=\"" N_("Antialiasing") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"1\">1</param>\n" - "<param name=\"content\" _gui-text=\"" N_("Blur content") "\" type=\"boolean\" >false</param>\n" + "<param name=\"width\" gui-text=\"" N_("Width") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"30.\">10</param>\n" + "<param name=\"level\" gui-text=\"" N_("Level") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.2\" max=\"2\">1</param>\n" + "<param name=\"dilat\" gui-text=\"" N_("Dilatation") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"100\">10</param>\n" + "<param name=\"erosion\" gui-text=\"" N_("Erosion") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"100\">1</param>\n" + "<param name=\"antialias\" gui-text=\"" N_("Antialiasing") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"1\">1</param>\n" + "<param name=\"content\" gui-text=\"" N_("Blur content") "\" type=\"bool\" >false</param>\n" "<effect>\n" "<object-type>all</object-type>\n" @@ -97,7 +97,7 @@ Crosssmooth::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream antialias; std::ostringstream content; - type << ext->get_param_enum("type"); + type << ext->get_param_optiongroup("type"); width << ext->get_param_float("width"); level << ext->get_param_float("level"); dilat << ext->get_param_float("dilat"); @@ -167,34 +167,34 @@ public: "<name>" N_("Outline") "</name>\n" "<id>org.inkscape.effect.filter.Outline</id>\n" "<param name=\"tab\" type=\"notebook\">\n" - "<page name=\"optionstab\" _gui-text=\"Options\">\n" - "<param name=\"fill\" _gui-text=\"" N_("Fill image") "\" type=\"boolean\" >false</param>\n" - "<param name=\"outline\" _gui-text=\"" N_("Hide image") "\" type=\"boolean\" >false</param>\n" - "<param name=\"type\" _gui-text=\"" N_("Composite type:") "\" type=\"enum\">\n" - "<_item value=\"over\">" N_("Over") "</_item>\n" - "<_item value=\"in\">" N_("In") "</_item>\n" - "<_item value=\"out\">" N_("Out") "</_item>\n" - "<_item value=\"atop\">" N_("Atop") "</_item>\n" - "<_item value=\"xor\">" N_("XOR") "</_item>\n" + "<page name=\"optionstab\" gui-text=\"Options\">\n" + "<param name=\"fill\" gui-text=\"" N_("Fill image") "\" type=\"bool\" >false</param>\n" + "<param name=\"outline\" gui-text=\"" N_("Hide image") "\" type=\"bool\" >false</param>\n" + "<param name=\"type\" gui-text=\"" N_("Composite type:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"over\">" N_("Over") "</option>\n" + "<option value=\"in\">" N_("In") "</option>\n" + "<option value=\"out\">" N_("Out") "</option>\n" + "<option value=\"atop\">" N_("Atop") "</option>\n" + "<option value=\"xor\">" N_("XOR") "</option>\n" "</param>\n" - "<param name=\"position\" _gui-text=\"" N_("Position:") "\" type=\"enum\">\n" - "<_item value=\"inside\">" N_("Inside") "</_item>\n" - "<_item value=\"outside\">" N_("Outside") "</_item>\n" - "<_item value=\"overlayed\">" N_("Overlayed") "</_item>\n" + "<param name=\"position\" gui-text=\"" N_("Position:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"inside\">" N_("Inside") "</option>\n" + "<option value=\"outside\">" N_("Outside") "</option>\n" + "<option value=\"overlayed\">" N_("Overlayed") "</option>\n" "</param>\n" - "<param name=\"width1\" _gui-text=\"" N_("Width 1") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">4</param>\n" - "<param name=\"dilat1\" _gui-text=\"" N_("Dilatation 1") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"100\">100</param>\n" - "<param name=\"erosion1\" _gui-text=\"" N_("Erosion 1") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">1</param>\n" - "<param name=\"width2\" _gui-text=\"" N_("Width 2") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">0.5</param>\n" - "<param name=\"dilat2\" _gui-text=\"" N_("Dilatation 2") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"100\">50</param>\n" - "<param name=\"erosion2\" _gui-text=\"" N_("Erosion 2") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">5</param>\n" - "<param name=\"antialias\" _gui-text=\"" N_("Antialiasing") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"1\">1</param>\n" - "<param name=\"smooth\" _gui-text=\"" N_("Smooth") "\" type=\"boolean\" >false</param>\n" + "<param name=\"width1\" gui-text=\"" N_("Width 1") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">4</param>\n" + "<param name=\"dilat1\" gui-text=\"" N_("Dilatation 1") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"100\">100</param>\n" + "<param name=\"erosion1\" gui-text=\"" N_("Erosion 1") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">1</param>\n" + "<param name=\"width2\" gui-text=\"" N_("Width 2") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">0.5</param>\n" + "<param name=\"dilat2\" gui-text=\"" N_("Dilatation 2") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"100\">50</param>\n" + "<param name=\"erosion2\" gui-text=\"" N_("Erosion 2") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"100\">5</param>\n" + "<param name=\"antialias\" gui-text=\"" N_("Antialiasing") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"1\">1</param>\n" + "<param name=\"smooth\" gui-text=\"" N_("Smooth") "\" type=\"bool\" >false</param>\n" "</page>\n" - "<page name=\"co11tab\" _gui-text=\"Color\">\n" - "<param name=\"color\" _gui-text=\"" N_("Color") "\" type=\"color\">255</param>\n" - "<param name=\"fopacity\" _gui-text=\"" N_("Fill opacity:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1\">1</param>\n" - "<param name=\"sopacity\" _gui-text=\"" N_("Stroke opacity:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1\">1</param>\n" + "<page name=\"co11tab\" gui-text=\"Color\">\n" + "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">255</param>\n" + "<param name=\"fopacity\" gui-text=\"" N_("Fill opacity:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1\">1</param>\n" + "<param name=\"sopacity\" gui-text=\"" N_("Stroke opacity:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1\">1</param>\n" "</page>\n" "</param>\n" "<effect>\n" @@ -255,7 +255,7 @@ Outline::get_filter_text (Inkscape::Extension::Extension * ext) fopacity << ext->get_param_float("fopacity"); sopacity << ext->get_param_float("sopacity"); - const gchar *position = ext->get_param_enum("position"); + const gchar *position = ext->get_param_optiongroup("position"); if((g_ascii_strcasecmp("inside", position) == 0)) { // Indide c1in << "SourceGraphic"; @@ -279,7 +279,7 @@ Outline::get_filter_text (Inkscape::Extension::Extension * ext) c2in << "blur2"; } - c2op << ext->get_param_enum("type"); + c2op << ext->get_param_optiongroup("type"); if (ext->get_param_bool("outline")) { c4in << "composite3"; diff --git a/src/extension/internal/filter/overlays.h b/src/extension/internal/filter/overlays.h index 0dbf79db8..fd8846002 100644 --- a/src/extension/internal/filter/overlays.h +++ b/src/extension/internal/filter/overlays.h @@ -57,21 +57,21 @@ public: "<name>" N_("Noise Fill") "</name>\n" "<id>org.inkscape.effect.filter.NoiseFill</id>\n" "<param name=\"tab\" type=\"notebook\">\n" - "<page name=\"optionstab\" _gui-text=\"" N_("Options") "\">\n" - "<param name=\"type\" _gui-text=\"" N_("Turbulence type:") "\" type=\"enum\">\n" - "<_item value=\"fractalNoise\">" N_("Fractal noise") "</_item>\n" - "<_item value=\"turbulence\">" N_("Turbulence") "</_item>\n" + "<page name=\"optionstab\" gui-text=\"" N_("Options") "\">\n" + "<param name=\"type\" gui-text=\"" N_("Turbulence type:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"fractalNoise\">" N_("Fractal noise") "</option>\n" + "<option value=\"turbulence\">" N_("Turbulence") "</option>\n" "</param>\n" - "<param name=\"hfreq\" _gui-text=\"" N_("Horizontal frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10000.00\">20</param>\n" - "<param name=\"vfreq\" _gui-text=\"" N_("Vertical frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10000.00\">40</param>\n" - "<param name=\"complexity\" _gui-text=\"" N_("Complexity:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">5</param>\n" - "<param name=\"variation\" _gui-text=\"" N_("Variation:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"360\">0</param>\n" - "<param name=\"dilat\" _gui-text=\"" N_("Dilatation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"50\">3</param>\n" - "<param name=\"erosion\" _gui-text=\"" N_("Erosion:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"50\">1</param>\n" - "<param name=\"inverted\" _gui-text=\"" N_("Inverted") "\" type=\"boolean\" >false</param>\n" + "<param name=\"hfreq\" gui-text=\"" N_("Horizontal frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10000.00\">20</param>\n" + "<param name=\"vfreq\" gui-text=\"" N_("Vertical frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10000.00\">40</param>\n" + "<param name=\"complexity\" gui-text=\"" N_("Complexity:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">5</param>\n" + "<param name=\"variation\" gui-text=\"" N_("Variation:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"360\">0</param>\n" + "<param name=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"50\">3</param>\n" + "<param name=\"erosion\" gui-text=\"" N_("Erosion:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"50\">1</param>\n" + "<param name=\"inverted\" gui-text=\"" N_("Inverted") "\" type=\"bool\" >false</param>\n" "</page>\n" - "<page name=\"co11tab\" _gui-text=\"" N_("Noise color") "\">\n" - "<param name=\"color\" _gui-text=\"" N_("Color") "\" type=\"color\">354957823</param>\n" + "<page name=\"co11tab\" gui-text=\"" N_("Noise color") "\">\n" + "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">354957823</param>\n" "</page>\n" "</param>\n" "<effect>\n" @@ -106,7 +106,7 @@ NoiseFill::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream a; std::ostringstream inverted; - type << ext->get_param_enum("type"); + type << ext->get_param_optiongroup("type"); hfreq << (ext->get_param_float("hfreq") / 1000); vfreq << (ext->get_param_float("vfreq") / 1000); complexity << ext->get_param_int("complexity"); diff --git a/src/extension/internal/filter/paint.h b/src/extension/internal/filter/paint.h index 69da5fd2c..162d15099 100644 --- a/src/extension/internal/filter/paint.h +++ b/src/extension/internal/filter/paint.h @@ -72,38 +72,38 @@ public: "<name>" N_("Chromolitho") "</name>\n" "<id>org.inkscape.effect.filter.Chromolitho</id>\n" "<param name=\"tab\" type=\"notebook\">\n" - "<page name=\"optionstab\" _gui-text=\"Options\">\n" - "<param name=\"drawing\" _gui-text=\"" N_("Drawing mode") "\" type=\"boolean\" >true</param>\n" - "<param name=\"dblend\" _gui-text=\"" N_("Drawing blend:") "\" type=\"enum\">\n" - "<_item value=\"darken\">Darken</_item>\n" - "<_item value=\"normal\">Normal</_item>\n" - "<_item value=\"multiply\">Multiply</_item>\n" - "<_item value=\"screen\">Screen</_item>\n" - "<_item value=\"lighten\">Lighten</_item>\n" + "<page name=\"optionstab\" gui-text=\"Options\">\n" + "<param name=\"drawing\" gui-text=\"" N_("Drawing mode") "\" type=\"bool\" >true</param>\n" + "<param name=\"dblend\" gui-text=\"" N_("Drawing blend:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"darken\">Darken</option>\n" + "<option value=\"normal\">Normal</option>\n" + "<option value=\"multiply\">Multiply</option>\n" + "<option value=\"screen\">Screen</option>\n" + "<option value=\"lighten\">Lighten</option>\n" "</param>\n" - "<param name=\"transparent\" _gui-text=\"" N_("Transparent") "\" type=\"boolean\" >false</param>\n" - "<param name=\"dented\" _gui-text=\"" N_("Dented") "\" type=\"boolean\" >false</param>\n" - "<param name=\"inverted\" _gui-text=\"" N_("Inverted") "\" type=\"boolean\" >false</param>\n" - "<param name=\"light\" _gui-text=\"" N_("Lightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"10\">0</param>\n" - "<param name=\"saturation\" _gui-text=\"" N_("Saturation") "\" type=\"float\" precision=\"2\" appearance=\"full\" min=\"0\" max=\"1\">1</param>\n" - "<param name=\"noise\" _gui-text=\"" N_("Noise reduction") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"1000\">10</param>\n" - "<param name=\"smooth\" _gui-text=\"" N_("Smoothness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">1</param>\n" + "<param name=\"transparent\" gui-text=\"" N_("Transparent") "\" type=\"bool\" >false</param>\n" + "<param name=\"dented\" gui-text=\"" N_("Dented") "\" type=\"bool\" >false</param>\n" + "<param name=\"inverted\" gui-text=\"" N_("Inverted") "\" type=\"bool\" >false</param>\n" + "<param name=\"light\" gui-text=\"" N_("Lightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"10\">0</param>\n" + "<param name=\"saturation\" gui-text=\"" N_("Saturation") "\" type=\"float\" precision=\"2\" appearance=\"full\" min=\"0\" max=\"1\">1</param>\n" + "<param name=\"noise\" gui-text=\"" N_("Noise reduction") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"1000\">10</param>\n" + "<param name=\"smooth\" gui-text=\"" N_("Smoothness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">1</param>\n" "</page>\n" - "<page name=\"graintab\" _gui-text=\"" N_("Grain") "\">\n" - "<param name=\"grain\" _gui-text=\"" N_("Grain mode") "\" type=\"boolean\" >true</param>\n" - "<param name=\"grainxf\" _gui-text=\"" N_("Horizontal frequency") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1000\">1000</param>\n" - "<param name=\"grainyf\" _gui-text=\"" N_("Vertical frequency") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1000\">1000</param>\n" - "<param name=\"grainc\" _gui-text=\"" N_("Complexity") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">1</param>\n" - "<param name=\"grainv\" _gui-text=\"" N_("Variation") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"1000\">0</param>\n" - "<param name=\"grainexp\" _gui-text=\"" N_("Expansion") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"50\">1</param>\n" - "<param name=\"grainero\" _gui-text=\"" N_("Erosion") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"40\">0</param>\n" - "<param name=\"graincol\" _gui-text=\"" N_("Color") "\" type=\"boolean\" >true</param>\n" - "<param name=\"gblend\" _gui-text=\"" N_("Grain blend:") "\" type=\"enum\">\n" - "<_item value=\"normal\">Normal</_item>\n" - "<_item value=\"multiply\">Multiply</_item>\n" - "<_item value=\"screen\">Screen</_item>\n" - "<_item value=\"lighten\">Lighten</_item>\n" - "<_item value=\"darken\">Darken</_item>\n" + "<page name=\"graintab\" gui-text=\"" N_("Grain") "\">\n" + "<param name=\"grain\" gui-text=\"" N_("Grain mode") "\" type=\"bool\" >true</param>\n" + "<param name=\"grainxf\" gui-text=\"" N_("Horizontal frequency") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1000\">1000</param>\n" + "<param name=\"grainyf\" gui-text=\"" N_("Vertical frequency") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1000\">1000</param>\n" + "<param name=\"grainc\" gui-text=\"" N_("Complexity") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">1</param>\n" + "<param name=\"grainv\" gui-text=\"" N_("Variation") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"1000\">0</param>\n" + "<param name=\"grainexp\" gui-text=\"" N_("Expansion") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"50\">1</param>\n" + "<param name=\"grainero\" gui-text=\"" N_("Erosion") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"40\">0</param>\n" + "<param name=\"graincol\" gui-text=\"" N_("Color") "\" type=\"bool\" >true</param>\n" + "<param name=\"gblend\" gui-text=\"" N_("Grain blend:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"normal\">Normal</option>\n" + "<option value=\"multiply\">Multiply</option>\n" + "<option value=\"screen\">Screen</option>\n" + "<option value=\"lighten\">Lighten</option>\n" + "<option value=\"darken\">Darken</option>\n" "</param>\n" "</page>\n" "</param>\n" @@ -155,7 +155,7 @@ Chromolitho::get_filter_text (Inkscape::Extension::Extension * ext) light << ext->get_param_float("light"); saturation << ext->get_param_float("saturation"); noise << (-1000 - ext->get_param_int("noise")); - dblend << ext->get_param_enum("dblend"); + dblend << ext->get_param_optiongroup("dblend"); smooth << ext->get_param_float("smooth"); if (ext->get_param_bool("dented")) { @@ -174,7 +174,7 @@ Chromolitho::get_filter_text (Inkscape::Extension::Extension * ext) grainyf << (ext->get_param_float("grainyf") / 1000); grainc << ext->get_param_int("grainc"); grainv << ext->get_param_int("grainv"); - gblend << ext->get_param_enum("gblend"); + gblend << ext->get_param_optiongroup("gblend"); grainexp << ext->get_param_float("grainexp"); grainero << (-ext->get_param_float("grainero")); if (ext->get_param_bool("graincol")) @@ -232,12 +232,12 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Cross Engraving") "</name>\n" "<id>org.inkscape.effect.filter.CrossEngraving</id>\n" - "<param name=\"clean\" _gui-text=\"" N_("Clean-up") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"500\">30</param>\n" - "<param name=\"dilat\" _gui-text=\"" N_("Dilatation") "\" type=\"float\" appearance=\"full\" min=\"1\" max=\"50\">1</param>\n" - "<param name=\"erosion\" _gui-text=\"" N_("Erosion") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"50\">0</param>\n" - "<param name=\"strength\" _gui-text=\"" N_("Strength") "\" type=\"float\" appearance=\"full\" min=\"0.1\" max=\"10\">0.5</param>\n" - "<param name=\"length\" _gui-text=\"" N_("Length") "\" type=\"float\" appearance=\"full\" min=\"0.5\" max=\"20\">4</param>\n" - "<param name=\"trans\" _gui-text=\"" N_("Transparent") "\" type=\"boolean\" >false</param>\n" + "<param name=\"clean\" gui-text=\"" N_("Clean-up") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"500\">30</param>\n" + "<param name=\"dilat\" gui-text=\"" N_("Dilatation") "\" type=\"float\" appearance=\"full\" min=\"1\" max=\"50\">1</param>\n" + "<param name=\"erosion\" gui-text=\"" N_("Erosion") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"50\">0</param>\n" + "<param name=\"strength\" gui-text=\"" N_("Strength") "\" type=\"float\" appearance=\"full\" min=\"0.1\" max=\"10\">0.5</param>\n" + "<param name=\"length\" gui-text=\"" N_("Length") "\" type=\"float\" appearance=\"full\" min=\"0.5\" max=\"20\">4</param>\n" + "<param name=\"trans\" gui-text=\"" N_("Transparent") "\" type=\"bool\" >false</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -332,29 +332,29 @@ public: "<name>" N_("Drawing") "</name>\n" "<id>org.inkscape.effect.filter.Drawing</id>\n" "<param name=\"tab\" type=\"notebook\">\n" - "<page name=\"optionstab\" _gui-text=\"Options\">\n" - "<_param name=\"simplifyheader\" type=\"description\" appearance=\"header\">" N_("Simplify") "</_param>\n" - "<param name=\"simply\" _gui-text=\"" N_("Strength") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">0.6</param>\n" - "<param name=\"clean\" _gui-text=\"" N_("Clean-up") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"1\" max=\"500\">10</param>\n" - "<param name=\"erase\" _gui-text=\"" N_("Erase") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"60\">0</param>\n" - "<param name=\"translucent\" _gui-text=\"" N_("Translucent") "\" indent=\"1\" type=\"boolean\" >false</param>\n" - "<_param name=\"smoothheader\" type=\"description\" appearance=\"header\">" N_("Smoothness") "</_param>\n" - "<param name=\"smooth\" _gui-text=\"" N_("Strength") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">0.6</param>\n" - "<param name=\"dilat\" _gui-text=\"" N_("Dilatation") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"1\" max=\"50\">6</param>\n" - "<param name=\"erosion\" _gui-text=\"" N_("Erosion") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"50\">2</param>\n" - "<_param name=\"meltheader\" type=\"description\" appearance=\"header\">" N_("Melt") "</_param>\n" - "<param name=\"blur\" _gui-text=\"" N_("Level") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">1</param>\n" - "<param name=\"bdilat\" _gui-text=\"" N_("Dilatation") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"1\" max=\"50\">6</param>\n" - "<param name=\"berosion\" _gui-text=\"" N_("Erosion") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"50\">2</param>\n" + "<page name=\"optionstab\" gui-text=\"Options\">\n" + "<label appearance=\"header\">" N_("Simplify") "</label>\n" + "<param name=\"simply\" gui-text=\"" N_("Strength") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">0.6</param>\n" + "<param name=\"clean\" gui-text=\"" N_("Clean-up") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"1\" max=\"500\">10</param>\n" + "<param name=\"erase\" gui-text=\"" N_("Erase") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"60\">0</param>\n" + "<param name=\"translucent\" gui-text=\"" N_("Translucent") "\" indent=\"1\" type=\"bool\" >false</param>\n" + "<label appearance=\"header\">" N_("Smoothness") "</label>\n" + "<param name=\"smooth\" gui-text=\"" N_("Strength") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">0.6</param>\n" + "<param name=\"dilat\" gui-text=\"" N_("Dilatation") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"1\" max=\"50\">6</param>\n" + "<param name=\"erosion\" gui-text=\"" N_("Erosion") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"50\">2</param>\n" + "<label appearance=\"header\">" N_("Melt") "</label>\n" + "<param name=\"blur\" gui-text=\"" N_("Level") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">1</param>\n" + "<param name=\"bdilat\" gui-text=\"" N_("Dilatation") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"1\" max=\"50\">6</param>\n" + "<param name=\"berosion\" gui-text=\"" N_("Erosion") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"50\">2</param>\n" "</page>\n" - "<page name=\"co11tab\" _gui-text=\"Fill color\">\n" - "<param name=\"fcolor\" _gui-text=\"" N_("Fill color") "\" type=\"color\">-1515870721</param>\n" - "<param name=\"iof\" _gui-text=\"" N_("Image on fill") "\" type=\"boolean\" >false</param>\n" + "<page name=\"co11tab\" gui-text=\"Fill color\">\n" + "<param name=\"fcolor\" gui-text=\"" N_("Fill color") "\" type=\"color\">-1515870721</param>\n" + "<param name=\"iof\" gui-text=\"" N_("Image on fill") "\" type=\"bool\" >false</param>\n" "</page>\n" - "<page name=\"co12tab\" _gui-text=\"Stroke color\">\n" - "<param name=\"scolor\" _gui-text=\"" N_("Stroke color") "\" type=\"color\">589505535</param>\n" - "<param name=\"ios\" _gui-text=\"" N_("Image on stroke") "\" type=\"boolean\" >false</param>\n" - "<param name=\"offset\" _gui-text=\"" N_("Offset") "\" type=\"int\" appearance=\"full\" min=\"-100\" max=\"100\">0</param>\n" + "<page name=\"co12tab\" gui-text=\"Stroke color\">\n" + "<param name=\"scolor\" gui-text=\"" N_("Stroke color") "\" type=\"color\">589505535</param>\n" + "<param name=\"ios\" gui-text=\"" N_("Image on stroke") "\" type=\"bool\" >false</param>\n" + "<param name=\"offset\" gui-text=\"" N_("Offset") "\" type=\"int\" appearance=\"full\" min=\"-100\" max=\"100\">0</param>\n" "</page>\n" "</param>\n" "<effect>\n" @@ -494,13 +494,13 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Electrize") "</name>\n" "<id>org.inkscape.effect.filter.Electrize</id>\n" - "<param name=\"blur\" _gui-text=\"" N_("Simplify") "\" type=\"float\" appearance=\"full\" min=\"0.01\" max=\"10.0\">2.0</param>\n" - "<param name=\"type\" _gui-text=\"" N_("Effect type:") "\" type=\"enum\">\n" - "<_item value=\"table\">" N_("Table") "</_item>\n" - "<_item value=\"discrete\">" N_("Discrete") "</_item>\n" + "<param name=\"blur\" gui-text=\"" N_("Simplify") "\" type=\"float\" appearance=\"full\" min=\"0.01\" max=\"10.0\">2.0</param>\n" + "<param name=\"type\" gui-text=\"" N_("Effect type:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"table\">" N_("Table") "</option>\n" + "<option value=\"discrete\">" N_("Discrete") "</option>\n" "</param>\n" - "<param name=\"levels\" _gui-text=\"" N_("Levels") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"10\">3</param>\n" - "<param name=\"invert\" _gui-text=\"" N_("Inverted") "\" type=\"boolean\">false</param>\n" + "<param name=\"levels\" gui-text=\"" N_("Levels") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"10\">3</param>\n" + "<param name=\"invert\" gui-text=\"" N_("Inverted") "\" type=\"bool\">false</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -524,7 +524,7 @@ Electrize::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream values; blur << ext->get_param_float("blur"); - type << ext->get_param_enum("type"); + type << ext->get_param_optiongroup("type"); // TransfertComponent table values are calculated based on the effect level and inverted parameters. int val = 0; @@ -584,17 +584,17 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Neon Draw") "</name>\n" "<id>org.inkscape.effect.filter.NeonDraw</id>\n" - "<param name=\"type\" _gui-text=\"" N_("Line type:") "\" type=\"enum\">\n" - "<_item value=\"table\">" N_("Smoothed") "</_item>\n" - "<_item value=\"discrete\">" N_("Contrasted") "</_item>\n" + "<param name=\"type\" gui-text=\"" N_("Line type:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"table\">" N_("Smoothed") "</option>\n" + "<option value=\"discrete\">" N_("Contrasted") "</option>\n" "</param>\n" - "<param name=\"simply\" _gui-text=\"" N_("Simplify") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">3</param>\n" - "<param name=\"width\" _gui-text=\"" N_("Line width") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">3</param>\n" - "<param name=\"lightness\" _gui-text=\"" N_("Lightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"10.00\">1</param>\n" - "<param name=\"blend\" _gui-text=\"" N_("Blend mode:") "\" type=\"enum\">\n" - "<_item value=\"normal\">Normal</_item>\n" - "<_item value=\"multiply\">Multiply</_item>\n" - "<_item value=\"screen\">Screen</_item>\n" + "<param name=\"simply\" gui-text=\"" N_("Simplify") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">3</param>\n" + "<param name=\"width\" gui-text=\"" N_("Line width") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">3</param>\n" + "<param name=\"lightness\" gui-text=\"" N_("Lightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"10.00\">1</param>\n" + "<param name=\"blend\" gui-text=\"" N_("Blend mode:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"normal\">Normal</option>\n" + "<option value=\"multiply\">Multiply</option>\n" + "<option value=\"screen\">Screen</option>\n" "</param>\n" "<effect>\n" "<object-type>all</object-type>\n" @@ -620,8 +620,8 @@ NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream lightness; std::ostringstream type; - type << ext->get_param_enum("type"); - blend << ext->get_param_enum("blend"); + type << ext->get_param_optiongroup("type"); + blend << ext->get_param_optiongroup("blend"); simply << ext->get_param_float("simply"); width << ext->get_param_float("width"); lightness << ext->get_param_float("lightness"); @@ -688,35 +688,35 @@ public: "<name>" N_("Point Engraving") "</name>\n" "<id>org.inkscape.effect.filter.PointEngraving</id>\n" "<param name=\"tab\" type=\"notebook\">\n" - "<page name=\"optionstab\" _gui-text=\"" N_("Options") "\">\n" - "<param name=\"type\" _gui-text=\"" N_("Turbulence type:") "\" type=\"enum\">\n" - "<_item value=\"fractalNoise\">" N_("Fractal noise") "</_item>\n" - "<_item value=\"turbulence\">" N_("Turbulence") "</_item>\n" + "<page name=\"optionstab\" gui-text=\"" N_("Options") "\">\n" + "<param name=\"type\" gui-text=\"" N_("Turbulence type:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"fractalNoise\">" N_("Fractal noise") "</option>\n" + "<option value=\"turbulence\">" N_("Turbulence") "</option>\n" "</param>\n" - "<param name=\"hfreq\" _gui-text=\"" N_("Horizontal frequency") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.1\" max=\"100.00\">100</param>\n" - "<param name=\"vfreq\" _gui-text=\"" N_("Vertical frequency") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.1\" max=\"100.00\">100</param>\n" - "<param name=\"complexity\" _gui-text=\"" N_("Complexity") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">1</param>\n" - "<param name=\"variation\" _gui-text=\"" N_("Variation") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"100\">0</param>\n" - "<param name=\"reduction\" _gui-text=\"" N_("Noise reduction") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"500\">45</param>\n" - "<param name=\"blend\" _gui-text=\"" N_("Noise blend:") "\" type=\"enum\">\n" - "<_item value=\"multiply\">" N_("Multiply") "</_item>\n" - "<_item value=\"normal\">" N_("Normal") "</_item>\n" - "<_item value=\"screen\">" N_("Screen") "</_item>\n" - "<_item value=\"lighten\">" N_("Lighten") "</_item>\n" - "<_item value=\"darken\">" N_("Darken") "</_item>\n" + "<param name=\"hfreq\" gui-text=\"" N_("Horizontal frequency") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.1\" max=\"100.00\">100</param>\n" + "<param name=\"vfreq\" gui-text=\"" N_("Vertical frequency") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.1\" max=\"100.00\">100</param>\n" + "<param name=\"complexity\" gui-text=\"" N_("Complexity") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">1</param>\n" + "<param name=\"variation\" gui-text=\"" N_("Variation") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"100\">0</param>\n" + "<param name=\"reduction\" gui-text=\"" N_("Noise reduction") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"500\">45</param>\n" + "<param name=\"blend\" gui-text=\"" N_("Noise blend:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"multiply\">" N_("Multiply") "</option>\n" + "<option value=\"normal\">" N_("Normal") "</option>\n" + "<option value=\"screen\">" N_("Screen") "</option>\n" + "<option value=\"lighten\">" N_("Lighten") "</option>\n" + "<option value=\"darken\">" N_("Darken") "</option>\n" "</param>\n" - "<param name=\"lightness\" _gui-text=\"" N_("Lightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"10\">2.5</param>\n" - "<param name=\"grain\" _gui-text=\"" N_("Grain lightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"10\">1.3</param>\n" - "<param name=\"erase\" _gui-text=\"" N_("Erase") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1\">0</param>\n" - "<param name=\"blur\" _gui-text=\"" N_("Blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"2\">0.5</param>\n" + "<param name=\"lightness\" gui-text=\"" N_("Lightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"10\">2.5</param>\n" + "<param name=\"grain\" gui-text=\"" N_("Grain lightness") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"10\">1.3</param>\n" + "<param name=\"erase\" gui-text=\"" N_("Erase") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1\">0</param>\n" + "<param name=\"blur\" gui-text=\"" N_("Blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"2\">0.5</param>\n" "</page>\n" - "<page name=\"fcolortab\" _gui-text=\"" N_("Fill color") "\">\n" - "<param name=\"fcolor\" _gui-text=\"" N_("Color") "\" type=\"color\">-1</param>\n" - "<param name=\"iof\" _gui-text=\"" N_("Image on fill") "\" type=\"boolean\" >false</param>\n" + "<page name=\"fcolortab\" gui-text=\"" N_("Fill color") "\">\n" + "<param name=\"fcolor\" gui-text=\"" N_("Color") "\" type=\"color\">-1</param>\n" + "<param name=\"iof\" gui-text=\"" N_("Image on fill") "\" type=\"bool\" >false</param>\n" "</page>\n" - "<page name=\"pcolortab\" _gui-text=\"" N_("Points color") "\">\n" - "<param name=\"pcolor\" _gui-text=\"" N_("Color") "\" type=\"color\">1666789119</param>\n" - "<param name=\"iop\" _gui-text=\"" N_("Image on points") "\" type=\"boolean\" >false</param>\n" + "<page name=\"pcolortab\" gui-text=\"" N_("Points color") "\">\n" + "<param name=\"pcolor\" gui-text=\"" N_("Color") "\" type=\"color\">1666789119</param>\n" + "<param name=\"iop\" gui-text=\"" N_("Image on points") "\" type=\"bool\" >false</param>\n" "</page>\n" "</param>\n" "<effect>\n" @@ -760,13 +760,13 @@ PointEngraving::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream iof; std::ostringstream iop; - type << ext->get_param_enum("type"); + type << ext->get_param_optiongroup("type"); hfreq << ext->get_param_float("hfreq") / 100; vfreq << ext->get_param_float("vfreq") / 100; complexity << ext->get_param_int("complexity"); variation << ext->get_param_int("variation"); reduction << (-1000 - ext->get_param_int("reduction")); - blend << ext->get_param_enum("blend"); + blend << ext->get_param_optiongroup("blend"); lightness << ext->get_param_float("lightness"); grain << ext->get_param_float("grain"); erase << ext->get_param_float("erase"); @@ -850,27 +850,27 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Poster Paint") "</name>\n" "<id>org.inkscape.effect.filter.Posterize</id>\n" - "<param name=\"type\" _gui-text=\"" N_("Effect type:") "\" type=\"enum\">\n" - "<_item value=\"normal\">Normal</_item>\n" - "<_item value=\"dented\">Dented</_item>\n" + "<param name=\"type\" gui-text=\"" N_("Effect type:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"normal\">Normal</option>\n" + "<option value=\"dented\">Dented</option>\n" "</param>\n" - "<param name=\"table\" _gui-text=\"" N_("Transfer type:") "\" type=\"enum\">\n" - "<_item value=\"discrete\">" N_("Poster") "</_item>\n" - "<_item value=\"table\">" N_("Painting") "</_item>\n" + "<param name=\"table\" gui-text=\"" N_("Transfer type:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"discrete\">" N_("Poster") "</option>\n" + "<option value=\"table\">" N_("Painting") "</option>\n" "</param>\n" - "<param name=\"levels\" _gui-text=\"" N_("Levels") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"15\">5</param>\n" - "<param name=\"blend\" _gui-text=\"" N_("Blend mode:") "\" type=\"enum\">\n" - "<_item value=\"lighten\">Lighten</_item>\n" - "<_item value=\"normal\">Normal</_item>\n" - "<_item value=\"darken\">Darken</_item>\n" - "<_item value=\"multiply\">Multiply</_item>\n" - "<_item value=\"screen\">Screen</_item>\n" + "<param name=\"levels\" gui-text=\"" N_("Levels") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"15\">5</param>\n" + "<param name=\"blend\" gui-text=\"" N_("Blend mode:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"lighten\">Lighten</option>\n" + "<option value=\"normal\">Normal</option>\n" + "<option value=\"darken\">Darken</option>\n" + "<option value=\"multiply\">Multiply</option>\n" + "<option value=\"screen\">Screen</option>\n" "</param>\n" - "<param name=\"blur1\" _gui-text=\"" N_("Simplify (primary)") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">4.0</param>\n" - "<param name=\"blur2\" _gui-text=\"" N_("Simplify (secondary)") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">0.5</param>\n" - "<param name=\"presaturation\" _gui-text=\"" N_("Pre-saturation") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"1.00\">1.00</param>\n" - "<param name=\"postsaturation\" _gui-text=\"" N_("Post-saturation") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"1.00\">1.00</param>\n" - "<param name=\"antialiasing\" _gui-text=\"" N_("Simulate antialiasing") "\" type=\"boolean\">false</param>\n" + "<param name=\"blur1\" gui-text=\"" N_("Simplify (primary)") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">4.0</param>\n" + "<param name=\"blur2\" gui-text=\"" N_("Simplify (secondary)") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">0.5</param>\n" + "<param name=\"presaturation\" gui-text=\"" N_("Pre-saturation") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"1.00\">1.00</param>\n" + "<param name=\"postsaturation\" gui-text=\"" N_("Post-saturation") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"1.00\">1.00</param>\n" + "<param name=\"antialiasing\" gui-text=\"" N_("Simulate antialiasing") "\" type=\"bool\">false</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -898,8 +898,8 @@ Posterize::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream transf; std::ostringstream antialias; - table << ext->get_param_enum("table"); - blendmode << ext->get_param_enum("blend"); + table << ext->get_param_optiongroup("table"); + blendmode << ext->get_param_optiongroup("blend"); blur1 << ext->get_param_float("blur1"); blur2 << ext->get_param_float("blur2"); presat << ext->get_param_float("presaturation"); @@ -908,7 +908,7 @@ Posterize::get_filter_text (Inkscape::Extension::Extension * ext) // TransfertComponent table values are calculated based on the poster type. transf << "0"; int levels = ext->get_param_int("levels") + 1; - const gchar *effecttype = ext->get_param_enum("type"); + const gchar *effecttype = ext->get_param_optiongroup("type"); if (levels == 1) { if ((g_ascii_strcasecmp("dented", effecttype) == 0)) { transf << " 1 0 1"; @@ -973,8 +973,8 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Posterize Basic") "</name>\n" "<id>org.inkscape.effect.filter.PosterizeBasic</id>\n" - "<param name=\"levels\" _gui-text=\"" N_("Levels") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"20\">5</param>\n" - "<param name=\"blur\" _gui-text=\"" N_("Simplify") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">4.0</param>\n" + "<param name=\"levels\" gui-text=\"" N_("Levels") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"20\">5</param>\n" + "<param name=\"blur\" gui-text=\"" N_("Simplify") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">4.0</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/filter/protrusions.h b/src/extension/internal/filter/protrusions.h index 1934f93f3..590608d58 100644 --- a/src/extension/internal/filter/protrusions.h +++ b/src/extension/internal/filter/protrusions.h @@ -48,7 +48,7 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Snow Crest") "</name>\n" "<id>org.inkscape.effect.filter.snow</id>\n" - "<param name=\"drift\" _gui-text=\"" N_("Drift Size") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"20.0\">3.5</param>\n" + "<param name=\"drift\" gui-text=\"" N_("Drift Size") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"20.0\">3.5</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/filter/shadows.h b/src/extension/internal/filter/shadows.h index 79e6e8712..d8aa69e33 100644 --- a/src/extension/internal/filter/shadows.h +++ b/src/extension/internal/filter/shadows.h @@ -58,21 +58,21 @@ public: "<name>" N_("Drop Shadow") "</name>\n" "<id>org.inkscape.effect.filter.ColorDropShadow</id>\n" "<param name=\"tab\" type=\"notebook\">\n" - "<page name=\"optionstab\" _gui-text=\"" N_("Options") "\">\n" - "<param name=\"blur\" _gui-text=\"" N_("Blur radius (px)") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"200.0\">3.0</param>\n" - "<param name=\"xoffset\" _gui-text=\"" N_("Horizontal offset (px)") "\" type=\"float\" appearance=\"full\" min=\"-50.0\" max=\"50.0\">6.0</param>\n" - "<param name=\"yoffset\" _gui-text=\"" N_("Vertical offset (px)") "\" type=\"float\" appearance=\"full\" min=\"-50.0\" max=\"50.0\">6.0</param>\n" - "<param name=\"type\" _gui-text=\"" N_("Shadow type:") "\" type=\"enum\" >\n" - "<_item value=\"outer\">" N_("Outer") "</_item>\n" - "<_item value=\"inner\">" N_("Inner") "</_item>\n" - "<_item value=\"outercut\">" N_("Outer cutout") "</_item>\n" - "<_item value=\"innercut\">" N_("Inner cutout") "</_item>\n" - "<_item value=\"shadow\">" N_("Shadow only") "</_item>\n" + "<page name=\"optionstab\" gui-text=\"" N_("Options") "\">\n" + "<param name=\"blur\" gui-text=\"" N_("Blur radius (px)") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"200.0\">3.0</param>\n" + "<param name=\"xoffset\" gui-text=\"" N_("Horizontal offset (px)") "\" type=\"float\" appearance=\"full\" min=\"-50.0\" max=\"50.0\">6.0</param>\n" + "<param name=\"yoffset\" gui-text=\"" N_("Vertical offset (px)") "\" type=\"float\" appearance=\"full\" min=\"-50.0\" max=\"50.0\">6.0</param>\n" + "<param name=\"type\" gui-text=\"" N_("Shadow type:") "\" type=\"optiongroup\" appearance=\"combo\" >\n" + "<option value=\"outer\">" N_("Outer") "</option>\n" + "<option value=\"inner\">" N_("Inner") "</option>\n" + "<option value=\"outercut\">" N_("Outer cutout") "</option>\n" + "<option value=\"innercut\">" N_("Inner cutout") "</option>\n" + "<option value=\"shadow\">" N_("Shadow only") "</option>\n" "</param>\n" "</page>\n" - "<page name=\"coltab\" _gui-text=\"" N_("Blur color") "\">\n" - "<param name=\"color\" _gui-text=\"" N_("Color") "\" type=\"color\">127</param>\n" - "<param name=\"objcolor\" _gui-text=\"" N_("Use object's color") "\" type=\"boolean\" >false</param>\n" + "<page name=\"coltab\" gui-text=\"" N_("Blur color") "\">\n" + "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">127</param>\n" + "<param name=\"objcolor\" gui-text=\"" N_("Use object's color") "\" type=\"bool\" >false</param>\n" "</page>\n" "</param>\n" "<effect>\n" @@ -108,7 +108,7 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream comp2in2; std::ostringstream comp2op; - const gchar *type = ext->get_param_enum("type"); + const gchar *type = ext->get_param_optiongroup("type"); guint32 color = ext->get_param_color("color"); blur << ext->get_param_float("blur"); diff --git a/src/extension/internal/filter/textures.h b/src/extension/internal/filter/textures.h index 31e76df6c..45a78a3db 100644 --- a/src/extension/internal/filter/textures.h +++ b/src/extension/internal/filter/textures.h @@ -62,29 +62,29 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Ink Blot") "</name>\n" "<id>org.inkscape.effect.filter.InkBlot</id>\n" - "<param name=\"type\" _gui-text=\"" N_("Turbulence type:") "\" type=\"enum\">\n" - "<_item value=\"fractalNoise\">Fractal noise</_item>\n" - "<_item value=\"turbulence\">Turbulence</_item>\n" + "<param name=\"type\" gui-text=\"" N_("Turbulence type:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"fractalNoise\">Fractal noise</option>\n" + "<option value=\"turbulence\">Turbulence</option>\n" "</param>\n" - "<param name=\"freq\" _gui-text=\"" N_("Frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">4</param>\n" - "<param name=\"complexity\" _gui-text=\"" N_("Complexity:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">3</param>\n" - "<param name=\"variation\" _gui-text=\"" N_("Variation:") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"100\">0</param>\n" - "<param name=\"hblur\" _gui-text=\"" N_("Horizontal inlay:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"30.00\">10</param>\n" - "<param name=\"vblur\" _gui-text=\"" N_("Vertical inlay:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"30.00\">10</param>\n" - "<param name=\"displacement\" _gui-text=\"" N_("Displacement:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"100.00\">50</param>\n" - "<param name=\"blend\" _gui-text=\"" N_("Blend:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"30.00\">5</param>\n" - "<param name=\"stroke\" _gui-text=\"" N_("Stroke:") "\" type=\"enum\">\n" - "<_item value=\"over\">" N_("Wide") "</_item>\n" - "<_item value=\"atop\">" N_("Normal") "</_item>\n" - "<_item value=\"in\">" N_("Narrow") "</_item>\n" - "<_item value=\"xor\">" N_("Overlapping") "</_item>\n" - "<_item value=\"out\">" N_("External") "</_item>\n" - "<_item value=\"arithmetic\">" N_("Custom") "</_item>\n" + "<param name=\"freq\" gui-text=\"" N_("Frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">4</param>\n" + "<param name=\"complexity\" gui-text=\"" N_("Complexity:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">3</param>\n" + "<param name=\"variation\" gui-text=\"" N_("Variation:") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"100\">0</param>\n" + "<param name=\"hblur\" gui-text=\"" N_("Horizontal inlay:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"30.00\">10</param>\n" + "<param name=\"vblur\" gui-text=\"" N_("Vertical inlay:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"30.00\">10</param>\n" + "<param name=\"displacement\" gui-text=\"" N_("Displacement:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"100.00\">50</param>\n" + "<param name=\"blend\" gui-text=\"" N_("Blend:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"30.00\">5</param>\n" + "<param name=\"stroke\" gui-text=\"" N_("Stroke:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"over\">" N_("Wide") "</option>\n" + "<option value=\"atop\">" N_("Normal") "</option>\n" + "<option value=\"in\">" N_("Narrow") "</option>\n" + "<option value=\"xor\">" N_("Overlapping") "</option>\n" + "<option value=\"out\">" N_("External") "</option>\n" + "<option value=\"arithmetic\">" N_("Custom") "</option>\n" "</param>\n" - "<_param name=\"customHeader\" type=\"description\" appearance=\"header\">" N_("Custom stroke options") "</_param>\n" - "<param name=\"k1\" _gui-text=\"" N_("k1:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">1.5</param>\n" - "<param name=\"k2\" _gui-text=\"" N_("k2:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">-0.25</param>\n" - "<param name=\"k3\" _gui-text=\"" N_("k3:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0.5</param>\n" + "<label appearance=\"header\">" N_("Custom stroke options") "</label>\n" + "<param name=\"k1\" gui-text=\"" N_("k1:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">1.5</param>\n" + "<param name=\"k2\" gui-text=\"" N_("k2:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">-0.25</param>\n" + "<param name=\"k3\" gui-text=\"" N_("k3:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0.5</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -115,7 +115,7 @@ InkBlot::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream stroke; std::ostringstream custom; - type << ext->get_param_enum("type"); + type << ext->get_param_optiongroup("type"); freq << ext->get_param_float("freq") / 100; complexity << ext->get_param_int("complexity"); variation << ext->get_param_int("variation"); @@ -124,14 +124,14 @@ InkBlot::get_filter_text (Inkscape::Extension::Extension * ext) displacement << ext->get_param_float("displacement"); blend << ext->get_param_float("blend"); - const gchar *ope = ext->get_param_enum("stroke"); + const gchar *ope = ext->get_param_optiongroup("stroke"); if (g_ascii_strcasecmp("arithmetic", ope) == 0) { custom << "k1=\"" << ext->get_param_float("k1") << "\" k2=\"" << ext->get_param_float("k2") << "\" k3=\"" << ext->get_param_float("k3") << "\""; } else { custom << ""; } - stroke << ext->get_param_enum("stroke"); + stroke << ext->get_param_optiongroup("stroke"); _filter = g_strdup_printf( "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" x=\"-0.15\" width=\"1.3\" y=\"-0.15\" height=\"1.3\" inkscape:label=\"Ink Blot\" >\n" diff --git a/src/extension/internal/filter/transparency.h b/src/extension/internal/filter/transparency.h index 2fb02a01a..87a4c886e 100644 --- a/src/extension/internal/filter/transparency.h +++ b/src/extension/internal/filter/transparency.h @@ -53,16 +53,16 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Blend") "</name>\n" "<id>org.inkscape.effect.filter.Blend</id>\n" - "<param name=\"source\" _gui-text=\"" N_("Source:") "\" type=\"enum\">\n" - "<_item value=\"BackgroundImage\">" N_("Background") "</_item>\n" - "<_item value=\"SourceGraphic\">" N_("Image") "</_item>\n" + "<param name=\"source\" gui-text=\"" N_("Source:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"BackgroundImage\">" N_("Background") "</option>\n" + "<option value=\"SourceGraphic\">" N_("Image") "</option>\n" "</param>\n" - "<param name=\"mode\" _gui-text=\"" N_("Mode:") "\" type=\"enum\">\n" - "<_item value=\"multiply\">" N_("Multiply") "</_item>\n" - "<_item value=\"normal\">" N_("Normal") "</_item>\n" - "<_item value=\"screen\">" N_("Screen") "</_item>\n" - "<_item value=\"darken\">" N_("Darken") "</_item>\n" - "<_item value=\"lighten\">" N_("Lighten") "</_item>\n" + "<param name=\"mode\" gui-text=\"" N_("Mode:") "\" type=\"optiongroup\" appearance=\"combo\">\n" + "<option value=\"multiply\">" N_("Multiply") "</option>\n" + "<option value=\"normal\">" N_("Normal") "</option>\n" + "<option value=\"screen\">" N_("Screen") "</option>\n" + "<option value=\"darken\">" N_("Darken") "</option>\n" + "<option value=\"lighten\">" N_("Lighten") "</option>\n" "</param>\n" "<effect>\n" "<object-type>all</object-type>\n" @@ -86,8 +86,8 @@ Blend::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream source; std::ostringstream mode; - source << ext->get_param_enum("source"); - mode << ext->get_param_enum("mode"); + source << ext->get_param_optiongroup("source"); + mode << ext->get_param_optiongroup("mode"); _filter = g_strdup_printf( "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Blend\">\n" @@ -130,11 +130,11 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Channel Transparency") "</name>\n" "<id>org.inkscape.effect.filter.ChannelTransparency</id>\n" - "<param name=\"red\" _gui-text=\"" N_("Red") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">-1</param>\n" - "<param name=\"green\" _gui-text=\"" N_("Green") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0.5</param>\n" - "<param name=\"blue\" _gui-text=\"" N_("Blue") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0.5</param>\n" - "<param name=\"alpha\" _gui-text=\"" N_("Alpha") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">1</param>\n" - "<param name=\"invert\" _gui-text=\"" N_("Inverted") "\" type=\"boolean\">false</param>\n" + "<param name=\"red\" gui-text=\"" N_("Red") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">-1</param>\n" + "<param name=\"green\" gui-text=\"" N_("Green") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0.5</param>\n" + "<param name=\"blue\" gui-text=\"" N_("Blue") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">0.5</param>\n" + "<param name=\"alpha\" gui-text=\"" N_("Alpha") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"-10.\" max=\"10.\">1</param>\n" + "<param name=\"invert\" gui-text=\"" N_("Inverted") "\" type=\"bool\">false</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -205,10 +205,10 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Light Eraser") "</name>\n" "<id>org.inkscape.effect.filter.LightEraser</id>\n" - "<param name=\"expand\" _gui-text=\"" N_("Expansion") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"1000\">50</param>\n" - "<param name=\"erode\" _gui-text=\"" N_("Erosion") "\" type=\"float\" appearance=\"full\" min=\"1\" max=\"1000\">100</param>\n" - "<param name=\"opacity\" _gui-text=\"" N_("Global opacity") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.\">1</param>\n" - "<param name=\"invert\" _gui-text=\"" N_("Inverted") "\" type=\"boolean\">false</param>\n" + "<param name=\"expand\" gui-text=\"" N_("Expansion") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"1000\">50</param>\n" + "<param name=\"erode\" gui-text=\"" N_("Erosion") "\" type=\"float\" appearance=\"full\" min=\"1\" max=\"1000\">100</param>\n" + "<param name=\"opacity\" gui-text=\"" N_("Global opacity") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.\">1</param>\n" + "<param name=\"invert\" gui-text=\"" N_("Inverted") "\" type=\"bool\">false</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -279,9 +279,9 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Opacity") "</name>\n" "<id>org.inkscape.effect.filter.Opacity</id>\n" - "<param name=\"expand\" _gui-text=\"" N_("Expansion") "\" type=\"float\" appearance=\"full\" min=\"1\" max=\"1000\">5</param>\n" - "<param name=\"erode\" _gui-text=\"" N_("Erosion") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"1000\">1</param>\n" - "<param name=\"opacity\" _gui-text=\"" N_("Global opacity") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.\">1</param>\n" + "<param name=\"expand\" gui-text=\"" N_("Expansion") "\" type=\"float\" appearance=\"full\" min=\"1\" max=\"1000\">5</param>\n" + "<param name=\"erode\" gui-text=\"" N_("Erosion") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"1000\">1</param>\n" + "<param name=\"opacity\" gui-text=\"" N_("Global opacity") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.\" max=\"1.\">1</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" @@ -341,9 +341,9 @@ public: "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Silhouette") "</name>\n" "<id>org.inkscape.effect.filter.Silhouette</id>\n" - "<param name=\"blur\" _gui-text=\"" N_("Blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"50.00\">0.01</param>\n" - "<param name=\"cutout\" _gui-text=\"" N_("Cutout") "\" type=\"boolean\">false</param>\n" - "<param name=\"color\" _gui-text=\"" N_("Color") "\" type=\"color\">255</param>\n" + "<param name=\"blur\" gui-text=\"" N_("Blur") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"50.00\">0.01</param>\n" + "<param name=\"cutout\" gui-text=\"" N_("Cutout") "\" type=\"bool\">false</param>\n" + "<param name=\"color\" gui-text=\"" N_("Color") "\" type=\"color\">255</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/gdkpixbuf-input.cpp b/src/extension/internal/gdkpixbuf-input.cpp index 9a1ed40e7..08555fbfc 100644 --- a/src/extension/internal/gdkpixbuf-input.cpp +++ b/src/extension/internal/gdkpixbuf-input.cpp @@ -195,23 +195,23 @@ GdkpixbufInput::init() "<name>%s</name>\n" "<id>org.inkscape.input.gdkpixbuf.%s</id>\n" - "<param name='link' type='optiongroup' appearance='full' _gui-text='" N_("Image Import Type:") "' _gui-description='" N_("Embed results in stand-alone, larger SVG files. Link references a file outside this SVG document and all files must be moved together.") "' >\n" - "<_option value='embed' >" N_("Embed") "</_option>\n" - "<_option value='link' >" N_("Link") "</_option>\n" + "<param name='link' type='optiongroup' gui-text='" N_("Image Import Type:") "' gui-description='" N_("Embed results in stand-alone, larger SVG files. Link references a file outside this SVG document and all files must be moved together.") "' >\n" + "<option value='embed' >" N_("Embed") "</option>\n" + "<option value='link' >" N_("Link") "</option>\n" "</param>\n" - "<param name='dpi' type='optiongroup' appearance='full' _gui-text='" N_("Image DPI:") "' _gui-description='" N_("Take information from file or use default bitmap import resolution as defined in the preferences.") "' >\n" - "<_option value='from_file' >" N_("From file") "</_option>\n" - "<_option value='from_default' >" N_("Default import resolution") "</_option>\n" + "<param name='dpi' type='optiongroup' gui-text='" N_("Image DPI:") "' gui-description='" N_("Take information from file or use default bitmap import resolution as defined in the preferences.") "' >\n" + "<option value='from_file' >" N_("From file") "</option>\n" + "<option value='from_default' >" N_("Default import resolution") "</option>\n" "</param>\n" - "<param name='scale' type='optiongroup' appearance='full' _gui-text='" N_("Image Rendering Mode:") "' _gui-description='" N_("When an image is upscaled, apply smoothing or keep blocky (pixelated). (Will not work in all browsers.)") "' >\n" - "<_option value='auto' >" N_("None (auto)") "</_option>\n" - "<_option value='optimizeQuality' >" N_("Smooth (optimizeQuality)") "</_option>\n" - "<_option value='optimizeSpeed' >" N_("Blocky (optimizeSpeed)") "</_option>\n" + "<param name='scale' type='optiongroup' gui-text='" N_("Image Rendering Mode:") "' gui-description='" N_("When an image is upscaled, apply smoothing or keep blocky (pixelated). (Will not work in all browsers.)") "' >\n" + "<option value='auto' >" N_("None (auto)") "</option>\n" + "<option value='optimizeQuality' >" N_("Smooth (optimizeQuality)") "</option>\n" + "<option value='optimizeSpeed' >" N_("Blocky (optimizeSpeed)") "</option>\n" "</param>\n" - "<param name=\"do_not_ask\" _gui-description='" N_("Hide the dialog next time and always apply the same actions.") "' _gui-text=\"" N_("Don't ask again") "\" type=\"boolean\" >false</param>\n" + "<param name=\"do_not_ask\" gui-description='" N_("Hide the dialog next time and always apply the same actions.") "' gui-text=\"" N_("Don't ask again") "\" type=\"bool\" >false</param>\n" "<input>\n" "<extension>.%s</extension>\n" "<mimetype>%s</mimetype>\n" diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index 89881fa0b..180f45814 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -192,11 +192,11 @@ Grid::init () "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Grid") "</name>\n" "<id>org.inkscape.effect.grid</id>\n" - "<param name=\"lineWidth\" _gui-text=\"" N_("Line Width:") "\" type=\"float\">1.0</param>\n" - "<param name=\"xspacing\" _gui-text=\"" N_("Horizontal Spacing:") "\" type=\"float\" min=\"0.1\" max=\"1000\">10.0</param>\n" - "<param name=\"yspacing\" _gui-text=\"" N_("Vertical Spacing:") "\" type=\"float\" min=\"0.1\" max=\"1000\">10.0</param>\n" - "<param name=\"xoffset\" _gui-text=\"" N_("Horizontal Offset:") "\" type=\"float\" min=\"0.0\" max=\"1000\">0.0</param>\n" - "<param name=\"yoffset\" _gui-text=\"" N_("Vertical Offset:") "\" type=\"float\" min=\"0.0\" max=\"1000\">0.0</param>\n" + "<param name=\"lineWidth\" gui-text=\"" N_("Line Width:") "\" type=\"float\">1.0</param>\n" + "<param name=\"xspacing\" gui-text=\"" N_("Horizontal Spacing:") "\" type=\"float\" min=\"0.1\" max=\"1000\">10.0</param>\n" + "<param name=\"yspacing\" gui-text=\"" N_("Vertical Spacing:") "\" type=\"float\" min=\"0.1\" max=\"1000\">10.0</param>\n" + "<param name=\"xoffset\" gui-text=\"" N_("Horizontal Offset:") "\" type=\"float\" min=\"0.0\" max=\"1000\">0.0</param>\n" + "<param name=\"yoffset\" gui-text=\"" N_("Vertical Offset:") "\" type=\"float\" min=\"0.0\" max=\"1000\">0.0</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/latex-pstricks.cpp b/src/extension/internal/latex-pstricks.cpp index 519e0a893..0fcc6f71c 100644 --- a/src/extension/internal/latex-pstricks.cpp +++ b/src/extension/internal/latex-pstricks.cpp @@ -122,7 +122,7 @@ unsigned int PrintLatex::begin (Inkscape::Extension::Print *mod, SPDocument *doc os << "\\psset{xunit=.5pt,yunit=.5pt,runit=.5pt}\n"; // from now on we can output px, but they will be treated as pt - + os << "\\begin{pspicture}(" << doc->getWidth().value("px") << "," << doc->getHeight().value("px") << ")\n"; } @@ -203,7 +203,7 @@ unsigned int PrintLatex::fill(Inkscape::Extension::Print * /*mod*/, os << "}\n}\n"; fprintf(_stream, "%s", os.str().c_str()); - } + } return 0; } @@ -229,7 +229,7 @@ unsigned int PrintLatex::stroke(Inkscape::Extension::Print * /*mod*/, os << "{\n\\newrgbcolor{curcolor}{" << rgb[0] << " " << rgb[1] << " " << rgb[2] << "}\n"; os << "\\pscustom[linewidth=" << style->stroke_width.computed*scale<< ",linecolor=curcolor"; - + if (stroke_opacity!=1.0) { os<<",strokeopacity="<<stroke_opacity; } @@ -299,7 +299,7 @@ PrintLatex::print_2geomcurve(SVGOStringStream &os, Geom::Curve const &c) os << "\\curveto(" << points[1][X] << "," << points[1][Y] << ")(" << points[2][X] << "," << points[2][Y] << ")(" << points[3][X] << "," << points[3][Y] << ")\n"; - } + } else { //this case handles sbasis as well as all other curve types Geom::Path sbasis_path = Geom::cubicbezierpath_from_sbasis(c.toSBasis(), 0.1); @@ -325,8 +325,8 @@ void PrintLatex::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("LaTeX Print") "</name>\n" "<id>" SP_MODULE_KEY_PRINT_LATEX "</id>\n" - "<param name=\"destination\" type=\"string\"></param>\n" - "<param name=\"textToPath\" type=\"boolean\">true</param>\n" + "<param gui-hidden=\"true\" name=\"destination\" type=\"string\"></param>\n" + "<param gui-hidden=\"true\" name=\"textToPath\" type=\"bool\">true</param>\n" "<print/>\n" "</inkscape-extension>", new PrintLatex()); } diff --git a/src/extension/internal/svg.cpp b/src/extension/internal/svg.cpp index 172a85a7f..c367bcaa1 100644 --- a/src/extension/internal/svg.cpp +++ b/src/extension/internal/svg.cpp @@ -674,19 +674,19 @@ Svg::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("SVG Input") "</name>\n" "<id>" SP_MODULE_KEY_INPUT_SVG "</id>\n" - "<param name='import_mode_svg' type='optiongroup' appearance='full' _gui-text='" N_("SVG Image Import Type:") "' >\n" - "<_option value='include' >" N_("Include SVG image as editable object(s) in the current file") "</_option>\n" - "<_option value='embed' >" N_("Embed the SVG file in a image tag (not editable in this document)") "</_option>\n" - "<_option value='link' >" N_("Link the SVG file in a image tag (not editable in this document).") "</_option>\n" + "<param name='import_mode_svg' type='optiongroup' gui-text='" N_("SVG Image Import Type:") "' >\n" + "<option value='include' >" N_("Include SVG image as editable object(s) in the current file") "</option>\n" + "<option value='embed' >" N_("Embed the SVG file in a image tag (not editable in this document)") "</option>\n" + "<option value='link' >" N_("Link the SVG file in a image tag (not editable in this document).") "</option>\n" "</param>\n" "<param name='svgdpi' type='float' precision='2' min='1' max='999999' gui-text='DPI for rendered SVG'>96.00</param>\n" - "<param name='scale' appearance='minimal' type='optiongroup' _gui-text='" N_("Image Rendering Mode:") "' _gui-description='" N_("When an image is upscaled, apply smoothing or keep blocky (pixelated). (Will not work in all browsers.)") "' >\n" - "<_option value='auto' >" N_("None (auto)") "</_option>\n" - "<_option value='optimizeQuality' >" N_("Smooth (optimizeQuality)") "</_option>\n" - "<_option value='optimizeSpeed' >" N_("Blocky (optimizeSpeed)") "</_option>\n" + "<param name='scale' appearance='combo' type='optiongroup' gui-text='" N_("Image Rendering Mode:") "' gui-description='" N_("When an image is upscaled, apply smoothing or keep blocky (pixelated). (Will not work in all browsers.)") "' >\n" + "<option value='auto' >" N_("None (auto)") "</option>\n" + "<option value='optimizeQuality' >" N_("Smooth (optimizeQuality)") "</option>\n" + "<option value='optimizeSpeed' >" N_("Blocky (optimizeSpeed)") "</option>\n" "</param>\n" - "<param name=\"do_not_ask\" _gui-description='" N_("Hide the dialog next time and always apply the same actions.") "' _gui-text=\"" N_("Don't ask again") "\" type=\"boolean\" >%s</param>\n" + "<param name=\"do_not_ask\" gui-description='" N_("Hide the dialog next time and always apply the same actions.") "' gui-text=\"" N_("Don't ask again") "\" type=\"bool\" >false</param>\n" "<input>\n" "<extension>.svg</extension>\n" "<mimetype>image/svg+xml</mimetype>\n" diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp index 2c68076dc..f62c41d44 100644 --- a/src/extension/internal/wmf-inout.cpp +++ b/src/extension/internal/wmf-inout.cpp @@ -3226,15 +3226,15 @@ Wmf::init () "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("WMF Output") "</name>\n" "<id>org.inkscape.output.wmf</id>\n" - "<param name=\"textToPath\" _gui-text=\"" N_("Convert texts to paths") "\" type=\"boolean\">true</param>\n" - "<param name=\"TnrToSymbol\" _gui-text=\"" N_("Map Unicode to Symbol font") "\" type=\"boolean\">true</param>\n" - "<param name=\"TnrToWingdings\" _gui-text=\"" N_("Map Unicode to Wingdings") "\" type=\"boolean\">true</param>\n" - "<param name=\"TnrToZapfDingbats\" _gui-text=\"" N_("Map Unicode to Zapf Dingbats") "\" type=\"boolean\">true</param>\n" - "<param name=\"UsePUA\" _gui-text=\"" N_("Use MS Unicode PUA (0xF020-0xF0FF) for converted characters") "\" type=\"boolean\">false</param>\n" - "<param name=\"FixPPTCharPos\" _gui-text=\"" N_("Compensate for PPT font bug") "\" type=\"boolean\">false</param>\n" - "<param name=\"FixPPTDashLine\" _gui-text=\"" N_("Convert dashed/dotted lines to single lines") "\" type=\"boolean\">false</param>\n" - "<param name=\"FixPPTGrad2Polys\" _gui-text=\"" N_("Convert gradients to colored polygon series") "\" type=\"boolean\">false</param>\n" - "<param name=\"FixPPTPatternAsHatch\" _gui-text=\"" N_("Map all fill patterns to standard WMF hatches") "\" type=\"boolean\">false</param>\n" + "<param name=\"textToPath\" gui-text=\"" N_("Convert texts to paths") "\" type=\"bool\">true</param>\n" + "<param name=\"TnrToSymbol\" gui-text=\"" N_("Map Unicode to Symbol font") "\" type=\"bool\">true</param>\n" + "<param name=\"TnrToWingdings\" gui-text=\"" N_("Map Unicode to Wingdings") "\" type=\"bool\">true</param>\n" + "<param name=\"TnrToZapfDingbats\" gui-text=\"" N_("Map Unicode to Zapf Dingbats") "\" type=\"bool\">true</param>\n" + "<param name=\"UsePUA\" gui-text=\"" N_("Use MS Unicode PUA (0xF020-0xF0FF) for converted characters") "\" type=\"bool\">false</param>\n" + "<param name=\"FixPPTCharPos\" gui-text=\"" N_("Compensate for PPT font bug") "\" type=\"bool\">false</param>\n" + "<param name=\"FixPPTDashLine\" gui-text=\"" N_("Convert dashed/dotted lines to single lines") "\" type=\"bool\">false</param>\n" + "<param name=\"FixPPTGrad2Polys\" gui-text=\"" N_("Convert gradients to colored polygon series") "\" type=\"bool\">false</param>\n" + "<param name=\"FixPPTPatternAsHatch\" gui-text=\"" N_("Map all fill patterns to standard WMF hatches") "\" type=\"bool\">false</param>\n" "<output>\n" "<extension>.wmf</extension>\n" "<mimetype>image/x-wmf</mimetype>\n" diff --git a/src/extension/internal/wmf-print.cpp b/src/extension/internal/wmf-print.cpp index 79de51925..6f3485fe5 100644 --- a/src/extension/internal/wmf-print.cpp +++ b/src/extension/internal/wmf-print.cpp @@ -622,7 +622,7 @@ int PrintWmf::create_pen(SPStyle const *style, const Geom::Affine &transform) if(mark_long == mark_short){ // only one mark size penstyle = U_PS_DOT; } - else if (n_dash==2) { + else if (n_dash==2) { penstyle = U_PS_DASH; } else if (n_dash==4) { @@ -1581,13 +1581,13 @@ void PrintWmf::init() "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>Windows Metafile Print</name>\n" "<id>org.inkscape.print.wmf</id>\n" - "<param name=\"destination\" type=\"string\"></param>\n" - "<param name=\"textToPath\" type=\"boolean\">true</param>\n" - "<param name=\"pageBoundingBox\" type=\"boolean\">true</param>\n" - "<param name=\"FixPPTCharPos\" type=\"boolean\">false</param>\n" - "<param name=\"FixPPTDashLine\" type=\"boolean\">false</param>\n" - "<param name=\"FixPPTGrad2Polys\" type=\"boolean\">false</param>\n" - "<param name=\"FixPPTPatternAsHatch\" type=\"boolean\">false</param>\n" + "<param gui-hidden=\"true\" name=\"destination\" type=\"string\"></param>\n" + "<param gui-hidden=\"true\" name=\"textToPath\" type=\"bool\">true</param>\n" + "<param gui-hidden=\"true\" name=\"pageBoundingBox\" type=\"bool\">true</param>\n" + "<param gui-hidden=\"true\" name=\"FixPPTCharPos\" type=\"bool\">false</param>\n" + "<param gui-hidden=\"true\" name=\"FixPPTDashLine\" type=\"bool\">false</param>\n" + "<param gui-hidden=\"true\" name=\"FixPPTGrad2Polys\" type=\"bool\">false</param>\n" + "<param gui-hidden=\"true\" name=\"FixPPTPatternAsHatch\" type=\"bool\">false</param>\n" "<print/>\n" "</inkscape-extension>", new PrintWmf()); diff --git a/src/extension/loader.h b/src/extension/loader.h index 65e5885f6..c6adbe2ec 100644 --- a/src/extension/loader.h +++ b/src/extension/loader.h @@ -18,6 +18,11 @@ namespace Inkscape { + +namespace XML { +class Document; +} + namespace Extension { /** This class contains the mechanism to load c++ plugins dynamically. @@ -27,7 +32,7 @@ class Loader { public: /** * Sets a base directory where to look for the actual plugin to load. - * + * * @param dir is the path where the plugin should be loaded from. */ void set_base_directory(std::string dir) { @@ -36,14 +41,14 @@ public: /** * Loads plugin dependencies which are needed for the plugin to load. - * + * * @param dep */ bool load_dependency(Dependency *dep); /** * Load the actual implementation of a plugin supplied by the plugin. - * + * * @param doc The xml representation of the INX extension configuration. * @return The implementation of the extension loaded from the plugin. */ diff --git a/src/extension/output.cpp b/src/extension/output.cpp index c6cf399b8..07c1120e7 100644 --- a/src/extension/output.cpp +++ b/src/extension/output.cpp @@ -9,10 +9,15 @@ * Released under GNU GPL v2+, read the file 'COPYING' for more information. */ -#include "prefdialog.h" +#include "output.h" + #include "document.h" + #include "implementation/implementation.h" -#include "output.h" + +#include "prefdialog/prefdialog.h" + +#include "xml/repr.h" /* Inkscape::Extension::Output */ @@ -36,7 +41,8 @@ namespace Extension { Overall, there are many levels of indentation, just to handle the levels of indentation in the XML file. */ -Output::Output (Inkscape::XML::Node * in_repr, Implementation::Implementation * in_imp) : Extension(in_repr, in_imp) +Output::Output (Inkscape::XML::Node *in_repr, Implementation::Implementation *in_imp, std::string *base_directory) + : Extension(in_repr, in_imp, base_directory) { mimetype = nullptr; extension = nullptr; @@ -148,23 +154,35 @@ Output::get_extension() \return The name of the filetype supported \brief Get the name of the filetype supported */ -gchar * -Output::get_filetypename() +const char * +Output::get_filetypename(bool translated) { - if (filetypename != nullptr) - return filetypename; + const char *name; + + if (filetypename) + name = filetypename; else - return get_name(); + name = get_name(); + + if (name && translated) { + return get_translation(name); + } else { + return name; + } } /** \return Tooltip giving more information on the filetype \brief Get the tooltip for more information on the filetype */ -gchar * -Output::get_filetypetooltip() +const char * +Output::get_filetypetooltip(bool translated) { - return filetypetooltip; + if (filetypetooltip && translated) { + return get_translation(filetypetooltip); + } else { + return filetypetooltip; + } } /** @@ -187,7 +205,8 @@ Output::prefs () return true; } - PrefDialog * dialog = new PrefDialog(this->get_name(), this->get_help(), controls); + Glib::ustring title = get_translation(this->get_name()); + PrefDialog *dialog = new PrefDialog(title, controls); int response = dialog->run(); dialog->hide(); diff --git a/src/extension/output.h b/src/extension/output.h index 5ce27a265..8210858ea 100644 --- a/src/extension/output.h +++ b/src/extension/output.h @@ -38,18 +38,19 @@ public: export_id_not_found(const gchar * const id = nullptr) : id{id} {}; }; - Output (Inkscape::XML::Node * in_repr, - Implementation::Implementation * in_imp); - ~Output () override; - bool check () override; + Output(Inkscape::XML::Node *in_repr, Implementation::Implementation *in_imp, std::string *base_directory); + ~Output () override; + + bool check() override; + void save (SPDocument *doc, gchar const *filename, bool detachbase = false); bool prefs (); gchar * get_mimetype(); gchar * get_extension(); - gchar * get_filetypename(); - gchar * get_filetypetooltip(); + const char * get_filetypename(bool translated=false); + const char * get_filetypetooltip(bool translated=false); bool causes_dataloss() { return dataloss; }; }; diff --git a/src/extension/param/color.cpp b/src/extension/param/color.cpp deleted file mode 100644 index f71670cb2..000000000 --- a/src/extension/param/color.cpp +++ /dev/null @@ -1,119 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * Copyright (C) 2005-2007 Authors: - * Ted Gould <ted@gould.cx> - * Johan Engelen <johan@shouraizou.nl> - * Christopher Brown <audiere@gmail.com> - * Jon A. Cruz <jon@joncruz.org> - * Released under GNU GPL v2+, read the file 'COPYING' for more information. - */ - -#include <iostream> -#include <sstream> - -#include <gtkmm/adjustment.h> -#include <gtkmm/box.h> -#include <gtkmm/spinbutton.h> - -#include <xml/node.h> - -#include "../extension.h" -#include "color.h" - -#include <color.h> -#include "ui/widget/color-notebook.h" -#include "preferences.h" - -namespace Inkscape { -namespace Extension { - -ParamColor::~ParamColor() -{ - _color_changed.disconnect(); -} - -guint32 ParamColor::set( guint32 in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/ ) -{ - _color_changed.block(true); - _color.setValue(in); - _color_changed.block(false); - - gchar * prefname = this->pref_name(); - std::string value; - string(value); - - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setString(extension_pref_root + prefname, value); - g_free(prefname); - - return in; -} - -ParamColor::ParamColor(const gchar * name, - const gchar * text, - const gchar * description, - bool hidden, - int indent, - Inkscape::Extension::Extension * ext, - Inkscape::XML::Node * xml) - : Parameter(name, text, description, hidden, indent, ext) - , _changeSignal(nullptr) -{ - const char * defaulthex = nullptr; - if (xml->firstChild() != nullptr) - defaulthex = xml->firstChild()->content(); - - gchar * pref_name = this->pref_name(); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - Glib::ustring paramval = prefs->getString(extension_pref_root + pref_name); - g_free(pref_name); - - if (!paramval.empty()) - defaulthex = paramval.data(); - - if (defaulthex) { - _color.setValue(atoi(defaulthex)); - } - _color_changed = _color.signal_changed.connect(sigc::mem_fun(this, &ParamColor::_onColorChanged)); - -} - -void ParamColor::string(std::string &string) const -{ - char str[16]; - snprintf(str, 16, "%i", _color.value()); - string += str; -} - -Gtk::Widget *ParamColor::get_widget( SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * changeSignal ) -{ - using Inkscape::UI::Widget::ColorNotebook; - - if (_hidden) return nullptr; - - if (changeSignal) { - _changeSignal = new sigc::signal<void>(*changeSignal); - } - - if (_color.value() < 1) { - _color_changed.block(true); - _color.setValue(0xFF000000); - _color_changed.block(false); - } - - Gtk::HBox *hbox = Gtk::manage(new Gtk::HBox(false, Parameter::GUI_PARAM_WIDGETS_SPACING)); - Gtk::Widget *selector = Gtk::manage(new ColorNotebook(_color)); - hbox->pack_start(*selector, true, true, 0); - selector->show(); - hbox->show(); - return hbox; -} - -void ParamColor::_onColorChanged() -{ - if (_changeSignal) - _changeSignal->emit(); -} - -}; /* namespace Extension */ -}; /* namespace Inkscape */ diff --git a/src/extension/param/description.h b/src/extension/param/description.h deleted file mode 100644 index 822370b82..000000000 --- a/src/extension/param/description.h +++ /dev/null @@ -1,63 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -#ifndef __INK_EXTENSION_PARAMDESCRIPTION_H__ -#define __INK_EXTENSION_PARAMDESCRIPTION_H__ - -/* - * Copyright (C) 2005-2007 Authors: - * Ted Gould <ted@gould.cx> - * Johan Engelen <johan@shouraizou.nl> * - * Released under GNU GPL v2+, read the file 'COPYING' for more information. - */ - -#include "parameter.h" - -class SPDocument; - -namespace Gtk { - class Widget; -} - -namespace Inkscape { -namespace Xml { - class Node; -} - -namespace Extension { - -/** \brief A description parameter */ -class ParamDescription : public Parameter { -public: - enum AppearanceMode { - DESCRIPTION, HEADER, URL - }; - ParamDescription(const gchar * name, - const gchar * text, - const gchar * description, - bool hidden, - int indent, - Inkscape::Extension::Extension * ext, - Inkscape::XML::Node * xml, - AppearanceMode mode); - - Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) override; -private: - /** \brief Internal value. */ - gchar * _value; - AppearanceMode _mode; -}; - -} /* namespace Extension */ -} /* namespace Inkscape */ - -#endif /* __INK_EXTENSION_PARAMDESCRIPTION_H__ */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp deleted file mode 100644 index 5ba3e5772..000000000 --- a/src/extension/param/enum.cpp +++ /dev/null @@ -1,268 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/** \file - * extension parameter for enumerations. - * - * It uses a Gtk:ComboBoxText widget in the extension UI. - */ - -/* - * Author: - * Johan Engelen <johan@shouraizou.nl> - * Jon A. Cruz <jon@joncruz.org> - * - * Copyright (C) 2006-2007 Johan Engelen - * - * Released under GNU GPL v2+, read the file 'COPYING' for more information. - */ - -#include <gtkmm/box.h> -#include <gtkmm/comboboxtext.h> -#include <glibmm/i18n.h> - -#include "xml/node.h" -#include "extension/extension.h" -#include "enum.h" -#include "preferences.h" - -namespace Inkscape { -namespace Extension { - -ParamComboBox::ParamComboBox(const gchar * name, - const gchar * text, - const gchar * description, - bool hidden, - int indent, - Inkscape::Extension::Extension * ext, - Inkscape::XML::Node * xml) - : Parameter(name, text, description, hidden, indent, ext) - , _value(nullptr) -{ - const char *xmlval = nullptr; // the value stored in XML - - if (xml != nullptr) { - // Read XML tree to add enumeration items: - for (Inkscape::XML::Node *node = xml->firstChild(); node; node = node->next()) { - char const * chname = node->name(); - if (!strcmp(chname, INKSCAPE_EXTENSION_NS "item") || !strcmp(chname, INKSCAPE_EXTENSION_NS "_item")) { - Glib::ustring newtext, newvalue; - const char * contents = nullptr; - if (node->firstChild()) { - contents = node->firstChild()->content(); - } - if (contents != nullptr) { - // don't translate when 'item' but do translate when '_item' - // NOTE: internal extensions use build_from_mem and don't need _item but - // still need to include if are to be localized - if (!strcmp(chname, INKSCAPE_EXTENSION_NS "_item")) { - if (node->attribute("msgctxt") != nullptr) { - newtext = g_dpgettext2(nullptr, node->attribute("msgctxt"), contents); - } else { - newtext = _(contents); - } - } else { - newtext = contents; - } - } else - continue; - - const char * val = node->attribute("value"); - if (val != nullptr) { - newvalue = val; - } else { - newvalue = contents; - } - - if ( (!newtext.empty()) && (!newvalue.empty()) ) { // logical error if this is not true here - choices.push_back(new enumentry(newvalue, newtext) ); - } - } - } - - // Initialize _value with the default value from xml - // for simplicity : default to the contents of the first xml-child - if (xml->firstChild() && xml->firstChild()->firstChild()) { - xmlval = xml->firstChild()->attribute("value"); - } - } - - gchar * pref_name = this->pref_name(); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - Glib::ustring paramval = prefs ? prefs->getString(extension_pref_root + pref_name) : ""; - g_free(pref_name); - - if (!paramval.empty()) { - _value = g_strdup(paramval.data()); - } else if (xmlval) { - _value = g_strdup(xmlval); - } -} - -ParamComboBox::~ParamComboBox () -{ - //destroy choice strings - for (auto i:choices) { - delete i; - } - g_free(_value); -} - - -/** - * A function to set the \c _value. - * - * This function sets ONLY the internal value, but it also sets the value - * in the preferences structure. To put it in the right place, \c PREF_DIR - * and \c pref_name() are used. - * - * To copy the data into _value the old memory must be free'd first. - * It is important to note that \c g_free handles \c NULL just fine. Then - * the passed in value is duplicated using \c g_strdup(). - * - * @param in The value to set. - * @param doc A document that should be used to set the value. - * @param node The node where the value may be placed. - */ -const gchar *ParamComboBox::set(const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) -{ - if (in == nullptr) { - return nullptr; /* Can't have NULL string */ - } - - Glib::ustring settext; - for (auto entr:choices) { - if ( !entr->text.compare(in) ) { - settext = entr->value; - break; // break out of for loop - } - } - if (!settext.empty()) { - if (_value != nullptr) { - g_free(_value); - } - _value = g_strdup(settext.data()); - gchar * prefname = this->pref_name(); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setString(extension_pref_root + prefname, _value); - g_free(prefname); - } - - return _value; -} - -/** - * function to test if \c text is selectable - */ -bool ParamComboBox::contains(const gchar * text, SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/) const -{ - if (text == nullptr) { - return false; /* Can't have NULL string */ - } - - for (auto entr:choices) { - if ( !entr->text.compare(text) ) - return true; - } - // if we did not find the text in this ParamComboBox: - return false; -} - -void -ParamComboBox::changed () { - -} - -void ParamComboBox::string(std::string &string) const -{ - string += _value; -} - - - - -/** A special category of Gtk::Entry to handle string parameteres. */ -class ParamComboBoxEntry : public Gtk::ComboBoxText { -private: - ParamComboBox * _pref; - SPDocument * _doc; - Inkscape::XML::Node * _node; - sigc::signal<void> * _changeSignal; -public: - /** - * Build a string preference for the given parameter. - * @param pref Where to get the string from, and where to put it - * when it changes. - */ - ParamComboBoxEntry (ParamComboBox * pref, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) : - Gtk::ComboBoxText(), _pref(pref), _doc(doc), _node(node), _changeSignal(changeSignal) { - this->signal_changed().connect(sigc::mem_fun(this, &ParamComboBoxEntry::changed)); - }; - void changed (); -}; - -/** - * Respond to the text box changing. - * - * This function responds to the box changing by grabbing the value - * from the text box and putting it in the parameter. - */ -void -ParamComboBoxEntry::changed () -{ - Glib::ustring data = this->get_active_text(); - _pref->set(data.c_str(), _doc, _node); - if (_changeSignal != nullptr) { - _changeSignal->emit(); - } -} - -/** - * Creates a combobox widget for an enumeration parameter. - */ -Gtk::Widget *ParamComboBox::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) -{ - if (_hidden) { - return nullptr; - } - - Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, Parameter::GUI_PARAM_WIDGETS_SPACING)); - Gtk::Label * label = Gtk::manage(new Gtk::Label(_text, Gtk::ALIGN_START)); - label->show(); - hbox->pack_start(*label, false, false); - - ParamComboBoxEntry * combo = Gtk::manage(new ParamComboBoxEntry(this, doc, node, changeSignal)); - // add choice strings: - Glib::ustring settext; - for (auto entr:choices) { - Glib::ustring text = entr->text; - combo->append(text); - - if ( _value && !entr->value.compare(_value) ) { - settext = entr->text; - } - } - if (!settext.empty()) { - combo->set_active_text(settext); - } - - combo->show(); - hbox->pack_start(*combo, true, true); - - hbox->show(); - - return dynamic_cast<Gtk::Widget *>(hbox); -} - - -} // namespace Extension -} // namespace Inkscape - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/extension/param/enum.h b/src/extension/param/enum.h deleted file mode 100644 index 329bb26f9..000000000 --- a/src/extension/param/enum.h +++ /dev/null @@ -1,106 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -#ifndef INK_EXTENSION_PARAMENUM_H_SEEN -#define INK_EXTENSION_PARAMENUM_H_SEEN - -/** \file - * Enumeration parameter for extensions. - */ - -/* - * Authors: - * Johan Engelen <johan@shouraizou.nl> - * Jon A. Cruz <jon@joncruz.org> - * - * Copyright (C) 2006-2007 Johan Engelen - * - * Released under GNU GPL v2+, read the file 'COPYING' for more information. - */ - -#include <vector> - -#include "parameter.h" -#include "document.h" - -namespace Gtk { -class Widget; -} - -namespace Inkscape { -namespace Extension { - -class Extension; - - -// \brief A class to represent a notebookparameter of an extension -class ParamComboBox : public Parameter { -private: - /** \brief Internal value. This should point to a string that has - been allocated in memory. And should be free'd. - It is the value of the current selected string */ - gchar * _value; - - /* For internal use only. - * Note that value and text MUST be non-NULL. - * This is ensured by newing only at one location in the code where non-NULL checks are made. - */ - class enumentry { - public: - enumentry (Glib::ustring &val, Glib::ustring &text) : - value(val), - text(text) - {} - - Glib::ustring value; - Glib::ustring text; - }; - - std::vector<enumentry *> choices; /**< A table to store the choice strings */ - -public: - ParamComboBox(const gchar * name, - const gchar * text, - const gchar * description, - bool hidden, - int indent, - Inkscape::Extension::Extension * ext, - Inkscape::XML::Node * xml); - ~ParamComboBox() override; - - Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) override; - - // Explicitly call superclass version to avoid method being hidden. - void string(std::list <std::string> &list) const override { return Parameter::string(list); } - - void string(std::string &string) const override; - - gchar const *get(SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/) const { return _value; } - - const gchar * set (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node); - - /** - * @returns true if text is part of this enum - */ - bool contains(const gchar * text, SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/) const; - - void changed (); -}; /* class ParamComboBox */ - - - - - -} /* namespace Extension */ -} /* namespace Inkscape */ - -#endif /* INK_EXTENSION_PARAMENUM_H_SEEN */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp deleted file mode 100644 index 661c533ca..000000000 --- a/src/extension/param/float.cpp +++ /dev/null @@ -1,205 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * Copyright (C) 2005-2007 Authors: - * Ted Gould <ted@gould.cx> - * Johan Engelen <johan@shouraizou.nl> * - * Jon A. Cruz <jon@joncruz.org> - * Released under GNU GPL v2+, read the file 'COPYING' for more information. - */ - -#include <gtkmm/adjustment.h> -#include <gtkmm/box.h> -#include <gtkmm/scale.h> -#include "ui/widget/spinbutton.h" -#include "ui/widget/spin-scale.h" - -#include "xml/node.h" -#include "extension/extension.h" -#include "preferences.h" -#include "./float.h" - -namespace Inkscape { -namespace Extension { - - -/** Use the superclass' allocator and set the \c _value. */ -ParamFloat::ParamFloat(const gchar * name, - const gchar * text, - const gchar * description, - bool hidden, - int indent, - Inkscape::Extension::Extension * ext, - Inkscape::XML::Node * xml, - AppearanceMode mode) - : Parameter(name, text, description, hidden, indent, ext) - , _value(0.0) - , _mode(mode) - , _min(0.0) - , _max(10.0) -{ - const gchar * defaultval = nullptr; - if (xml->firstChild() != nullptr) { - defaultval = xml->firstChild()->content(); - } - if (defaultval != nullptr) { - _value = g_ascii_strtod (defaultval,nullptr); - } - - const char * maxval = xml->attribute("max"); - if (maxval != nullptr) { - _max = g_ascii_strtod (maxval,nullptr); - } - - const char * minval = xml->attribute("min"); - if (minval != nullptr) { - _min = g_ascii_strtod (minval,nullptr); - } - - _precision = 1; - const char * precision = xml->attribute("precision"); - if (precision != nullptr) { - _precision = atoi(precision); - } - - /* We're handling this by just killing both values */ - if (_max < _min) { - _max = 10.0; - _min = 0.0; - } - - gchar * pref_name = this->pref_name(); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - _value = prefs->getDouble(extension_pref_root + pref_name, _value); - g_free(pref_name); - - // std::cout << "New Float:: value: " << _value << " max: " << _max << " min: " << _min << std::endl; - - if (_value > _max) { - _value = _max; - } - if (_value < _min) { - _value = _min; - } - - return; -} - -/** - * A function to set the \c _value. - * - * This function sets the internal value, but it also sets the value - * in the preferences structure. To put it in the right place, \c PREF_DIR - * and \c pref_name() are used. - * - * @param in The value to set to. - * @param doc A document that should be used to set the value. - * @param node The node where the value may be placed. - */ -float ParamFloat::set(float in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) -{ - _value = in; - if (_value > _max) { - _value = _max; - } - if (_value < _min) { - _value = _min; - } - - gchar * prefname = this->pref_name(); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setDouble(extension_pref_root + prefname, _value); - g_free(prefname); - - return _value; -} - -void ParamFloat::string(std::string &string) const -{ - char startstring[G_ASCII_DTOSTR_BUF_SIZE]; - g_ascii_dtostr(startstring, G_ASCII_DTOSTR_BUF_SIZE, _value); - string += startstring; - return; -} - -/** A class to make an adjustment that uses Extension params. */ -class ParamFloatAdjustment : public Gtk::Adjustment { - /** The parameter to adjust. */ - ParamFloat * _pref; - SPDocument * _doc; - Inkscape::XML::Node * _node; - sigc::signal<void> * _changeSignal; -public: - /** Make the adjustment using an extension and the string - describing the parameter. */ - ParamFloatAdjustment (ParamFloat * param, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) : - Gtk::Adjustment(0.0, param->min(), param->max(), 0.1, 1.0, 0), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) { - this->set_value(_pref->get(nullptr, nullptr) /* \todo fix */); - this->signal_value_changed().connect(sigc::mem_fun(this, &ParamFloatAdjustment::val_changed)); - return; - }; - - void val_changed (); -}; /* class ParamFloatAdjustment */ - -/** - * A function to respond to the value_changed signal from the adjustment. - * - * This function just grabs the value from the adjustment and writes - * it to the parameter. Very simple, but yet beautiful. - */ -void ParamFloatAdjustment::val_changed() -{ - //std::cout << "Value Changed to: " << this->get_value() << std::endl; - _pref->set(this->get_value(), _doc, _node); - if (_changeSignal != nullptr) { - _changeSignal->emit(); - } - return; -} - -/** - * Creates a Float Adjustment for a float parameter. - * - * Builds a hbox with a label and a float adjustment in it. - */ -Gtk::Widget * ParamFloat::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) -{ - if (_hidden) { - return nullptr; - } - - Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, Parameter::GUI_PARAM_WIDGETS_SPACING)); - - auto pfa = new ParamFloatAdjustment(this, doc, node, changeSignal); - Glib::RefPtr<Gtk::Adjustment> fadjust(pfa); - - if (_mode == FULL) { - - Glib::ustring text; - if (_text != nullptr) - text = _text; - UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(text, fadjust, _precision); - scale->set_size_request(400, -1); - scale->show(); - hbox->pack_start(*scale, true, true); - - } - else if (_mode == MINIMAL) { - - Gtk::Label * label = Gtk::manage(new Gtk::Label(_text, Gtk::ALIGN_START)); - label->show(); - hbox->pack_start(*label, true, true); - - auto spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(fadjust, 0.1, _precision)); - spin->show(); - hbox->pack_start(*spin, false, false); - } - - hbox->show(); - - return dynamic_cast<Gtk::Widget *>(hbox); -} - - -} /* namespace Extension */ -} /* namespace Inkscape */ diff --git a/src/extension/param/int.cpp b/src/extension/param/int.cpp deleted file mode 100644 index 1c41c0834..000000000 --- a/src/extension/param/int.cpp +++ /dev/null @@ -1,201 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * Copyright (C) 2005-2007 Authors: - * Ted Gould <ted@gould.cx> - * Johan Engelen <johan@shouraizou.nl> * - * Jon A. Cruz <jon@joncruz.org> - * Released under GNU GPL v2+, read the file 'COPYING' for more information. - */ - -#include <gtkmm/adjustment.h> -#include <gtkmm/box.h> -#include <gtkmm/scale.h> -#include "ui/widget/spinbutton.h" -#include "ui/widget/spin-scale.h" - -#include "xml/node.h" -#include "extension/extension.h" -#include "preferences.h" -#include "int.h" - -namespace Inkscape { -namespace Extension { - - -/** Use the superclass' allocator and set the \c _value. */ -ParamInt::ParamInt(const gchar * name, - const gchar * text, - const gchar * description, - bool hidden, - int indent, - Inkscape::Extension::Extension * ext, - Inkscape::XML::Node * xml, - AppearanceMode mode) - : Parameter(name, text, description, hidden, indent, ext) - , _value(0) - , _mode(mode) - , _min(0) - , _max(10) -{ - const char * defaultval = nullptr; - if (xml->firstChild() != nullptr) { - defaultval = xml->firstChild()->content(); - } - if (defaultval != nullptr) { - _value = atoi(defaultval); - } - - const char * maxval = xml->attribute("max"); - if (maxval != nullptr) { - _max = atoi(maxval); - } - - const char * minval = xml->attribute("min"); - if (minval != nullptr) { - _min = atoi(minval); - } - /* We're handling this by just killing both values */ - if (_max < _min) { - _max = 10; - _min = 0; - } - - gchar *pref_name = this->pref_name(); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - _value = prefs->getInt(extension_pref_root + pref_name, _value); - g_free(pref_name); - - // std::cout << "New Int:: value: " << _value << " max: " << _max << " min: " << _min << std::endl; - - if (_value > _max) { - _value = _max; - } - if (_value < _min) { - _value = _min; - } -} - -/** - * A function to set the \c _value. - * This function sets the internal value, but it also sets the value - * in the preferences structure. To put it in the right place, \c PREF_DIR - * and \c pref_name() are used. - * - * @param in The value to set to. - * @param doc A document that should be used to set the value. - * @param node The node where the value may be placed. - */ -int ParamInt::set(int in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) -{ - _value = in; - if (_value > _max) { - _value = _max; - } - if (_value < _min) { - _value = _min; - } - - gchar * prefname = this->pref_name(); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setInt(extension_pref_root + prefname, _value); - g_free(prefname); - - return _value; -} - -/** A class to make an adjustment that uses Extension params. */ -class ParamIntAdjustment : public Gtk::Adjustment { - /** The parameter to adjust. */ - ParamInt * _pref; - SPDocument * _doc; - Inkscape::XML::Node * _node; - sigc::signal<void> * _changeSignal; -public: - /** Make the adjustment using an extension and the string - describing the parameter. */ - ParamIntAdjustment (ParamInt * param, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) : - Gtk::Adjustment(0.0, param->min(), param->max(), 1.0, 10.0, 0), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) { - this->set_value(_pref->get(nullptr, nullptr) /* \todo fix */); - this->signal_value_changed().connect(sigc::mem_fun(this, &ParamIntAdjustment::val_changed)); - }; - - void val_changed (); -}; /* class ParamIntAdjustment */ - -/** - * A function to respond to the value_changed signal from the adjustment. - * - * This function just grabs the value from the adjustment and writes - * it to the parameter. Very simple, but yet beautiful. - */ -void ParamIntAdjustment::val_changed() -{ - //std::cout << "Value Changed to: " << this->get_value() << std::endl; - _pref->set((int)this->get_value(), _doc, _node); - if (_changeSignal != nullptr) { - _changeSignal->emit(); - } -} - -/** - * Creates a Int Adjustment for a int parameter. - * - * Builds a hbox with a label and a int adjustment in it. - */ -Gtk::Widget * -ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) -{ - if (_hidden) { - return nullptr; - } - - Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, Parameter::GUI_PARAM_WIDGETS_SPACING)); - - auto pia = new ParamIntAdjustment(this, doc, node, changeSignal); - Glib::RefPtr<Gtk::Adjustment> fadjust(pia); - - if (_mode == FULL) { - - Glib::ustring text; - if (_text != nullptr) - text = _text; - UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(text, fadjust, 0); - scale->set_size_request(400, -1); - scale->show(); - hbox->pack_start(*scale, true, true); - } - else if (_mode == MINIMAL) { - Gtk::Label * label = Gtk::manage(new Gtk::Label(_text, Gtk::ALIGN_START)); - label->show(); - hbox->pack_start(*label, true, true); - - auto spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(fadjust, 1.0, 0)); - spin->show(); - hbox->pack_start(*spin, false, false); - } - - hbox->show(); - - return dynamic_cast<Gtk::Widget *>(hbox); -} - -void ParamInt::string(std::string &string) const -{ - char startstring[32]; - sprintf(startstring, "%d", _value); - string += startstring; -} - -} // namespace Extension -} // namespace Inkscape - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/extension/param/notebook.cpp b/src/extension/param/notebook.cpp deleted file mode 100644 index 838c09d5b..000000000 --- a/src/extension/param/notebook.cpp +++ /dev/null @@ -1,413 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/** \file - * Notebook and NotebookPage parameters for extensions. - */ - -/* - * Authors: - * Johan Engelen <johan@shouraizou.nl> - * Jon A. Cruz <jon@joncruz.org> - * - * Copyright (C) 2006 Author - * - * Released under GNU GPL v2+, read the file 'COPYING' for more information. - */ - -#include <gtkmm/adjustment.h> -#include <gtkmm/box.h> -#include <gtkmm/spinbutton.h> -#include <gtkmm/notebook.h> - -#include <glibmm/i18n.h> - -#include <xml/node.h> - -#include <extension/extension.h> -#include "preferences.h" - -#include "notebook.h" - -/** - * The root directory in the preferences database for extension - * related parameters. - */ -#define PREF_DIR "extensions" - -namespace Inkscape { -namespace Extension { - - -ParamNotebook::ParamNotebookPage::ParamNotebookPage(const gchar * name, - const gchar * text, - const gchar * description, - bool hidden, - Inkscape::Extension::Extension * ext, - Inkscape::XML::Node * xml) - : Parameter(name, text, description, hidden, /*indent*/ 0, ext) -{ - - // Read XML to build page - if (xml != nullptr) { - Inkscape::XML::Node *child_repr = xml->firstChild(); - while (child_repr != nullptr) { - char const * chname = child_repr->name(); - if (!strncmp(chname, INKSCAPE_EXTENSION_NS_NC, strlen(INKSCAPE_EXTENSION_NS_NC))) { - chname += strlen(INKSCAPE_EXTENSION_NS); - } - if (chname[0] == '_') // Allow _ for translation of tags - chname++; - if (!strcmp(chname, "param") || !strcmp(chname, "_param")) { - Parameter * param; - param = Parameter::make(child_repr, ext); - if (param != nullptr) parameters.push_back(param); - } - child_repr = child_repr->next(); - } - } -} - -ParamNotebook::ParamNotebookPage::~ParamNotebookPage () -{ - //destroy parameters - for (auto param:parameters) { - delete param; - } -} - -/** Return the value as a string. */ -void ParamNotebook::ParamNotebookPage::paramString(std::list <std::string> &list) -{ - for (auto param:parameters) { - param->string(list); - } -} - - -/** - \return None - \brief This function creates a page that can be used later. This - is typically done in the creation of the notebook and defined - in the XML file describing the extension (it's private so people - have to use the system) :) - \param in_repr The XML describing the page - \todo the 'gui-hidden' attribute is read but not used! - - This function first grabs all of the data out of the Repr and puts - it into local variables. Actually, these are just pointers, and the - data is not duplicated so we need to be careful with it. If there - isn't a name in the XML, then no page is created as - the function just returns. - - From this point on, we're pretty committed as we've allocated an - object and we're starting to fill it. The name is set first, and - is created with a strdup to actually allocate memory for it. Then - there is a case statement (roughly because strcmp requires 'ifs') - based on what type of parameter this is. Depending which type it - is, the value is interpreted differently, but they are relatively - straight forward. In all cases the value is set to the default - value from the XML and the type is set to the interpreted type. -*/ -ParamNotebook::ParamNotebookPage * -ParamNotebook::ParamNotebookPage::makepage (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * in_ext) -{ - const char * name; - const char * text; - const char * description; - bool hidden = false; - const char * hide; - - name = in_repr->attribute("name"); - text = in_repr->attribute("gui-text"); - if (text == nullptr) - text = in_repr->attribute("_gui-text"); - description = in_repr->attribute("gui-description"); - if (description == nullptr) - description = in_repr->attribute("_gui-description"); - hide = in_repr->attribute("gui-hidden"); - if (hide != nullptr) { - if (strcmp(hide, "1") == 0 || - strcmp(hide, "true") == 0) { - hidden = true; - } - /* else stays false */ - } - - /* In this case we just don't have enough information */ - if (name == nullptr) { - return nullptr; - } - - ParamNotebookPage * page = new ParamNotebookPage(name, text, description, hidden, in_ext, in_repr); - - /* Note: page could equal NULL */ - return page; -} - - - -/** - * Creates a notebookpage widget for a notebook. - * - * Builds a notebook page (a vbox) and puts parameters on it. - */ -Gtk::Widget * ParamNotebook::ParamNotebookPage::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) -{ - if (_hidden) { - return nullptr; - } - - Gtk::VBox * vbox = Gtk::manage(new Gtk::VBox); - vbox->set_border_width(Parameter::GUI_BOX_MARGIN); - vbox->set_spacing(Parameter::GUI_BOX_SPACING); - - // add parameters onto page (if any) - for (auto param:parameters) { - Gtk::Widget * widg = param->get_widget(doc, node, changeSignal); - if (widg) { - int indent = param->get_indent(); - widg->set_margin_start(indent * Parameter::GUI_INDENTATION); - vbox->pack_start(*widg, false, false, 0); - - gchar const * tip = param->get_tooltip(); - if (tip) { - widg->set_tooltip_text(tip); - } else { - widg->set_tooltip_text(""); - widg->set_has_tooltip(false); - } - } - } - - vbox->show(); - - return dynamic_cast<Gtk::Widget *>(vbox); -} - -/** Search the parameter's name in the page content. */ -Parameter *ParamNotebook::ParamNotebookPage::get_param(const gchar * name) -{ - if (name == nullptr) { - throw Extension::param_not_exist(); - } - if (this->parameters.empty()) { - // the list of parameters is empty - throw Extension::param_not_exist(); - } - - for (auto param:parameters) { - if (!strcmp(param->name(), name)) { - return param; - } - } - - return nullptr; -} - -/** End ParamNotebookPage **/ -/** ParamNotebook **/ - -ParamNotebook::ParamNotebook(const gchar * name, - const gchar * text, - const gchar * description, - bool hidden, - int indent, - Inkscape::Extension::Extension * ext, - Inkscape::XML::Node * xml) - : Parameter(name, text, description, hidden, indent, ext) -{ - // Read XML tree to add pages: - if (xml != nullptr) { - Inkscape::XML::Node *child_repr = xml->firstChild(); - while (child_repr != nullptr) { - char const * chname = child_repr->name(); - if (!strncmp(chname, INKSCAPE_EXTENSION_NS_NC, strlen(INKSCAPE_EXTENSION_NS_NC))) { - chname += strlen(INKSCAPE_EXTENSION_NS); - } - if (chname[0] == '_') // Allow _ for translation of tags - chname++; - if (!strcmp(chname, "page")) { - ParamNotebookPage * page; - page = ParamNotebookPage::makepage(child_repr, ext); - if (page != nullptr) pages.push_back(page); - } - child_repr = child_repr->next(); - } - } - - // Initialize _value with the current page - const char * defaultval = nullptr; - // set first page as default - if (!pages.empty()) { - defaultval = pages[0]->name(); - } - - gchar * pref_name = this->pref_name(); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - Glib::ustring paramval = prefs->getString(extension_pref_root + pref_name); - g_free(pref_name); - - if (!paramval.empty()) - defaultval = paramval.data(); - if (defaultval != nullptr) - _value = g_strdup(defaultval); // allocate space for _value -} - -ParamNotebook::~ParamNotebook () -{ - //destroy pages - for (auto page:pages) { - delete page; - } - g_free(_value); -} - - -/** - * A function to set the \c _value. - * - * This function sets the internal value, but it also sets the value - * in the preferences structure. To put it in the right place, \c PREF_DIR - * and \c pref_name() are used. - * - * To copy the data into _value the old memory must be free'd first. - * It is important to note that \c g_free handles \c NULL just fine. Then - * the passed in value is duplicated using \c g_strdup(). - * - * @param in The number of the page which value must be set. - * @param doc A document that should be used to set the value. - * @param node The node where the value may be placed. - */ -const gchar *ParamNotebook::set(const int in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) -{ - int i = in < pages.size() ? in : pages.size()-1; - ParamNotebookPage * page = pages[i]; - - if (page == nullptr) return _value; - - if (_value != nullptr) g_free(_value); - _value = g_strdup(page->name()); - - gchar * prefname = this->pref_name(); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setString(extension_pref_root + prefname, _value); - g_free(prefname); - - return _value; -} - -void ParamNotebook::string(std::list <std::string> &list) const -{ - std::string param_string; - param_string += "--"; - param_string += name(); - param_string += "="; - - param_string += "\""; - param_string += _value; // the name of the current page - param_string += "\""; - list.insert(list.end(), param_string); - - for (auto page:pages) { - page->paramString(list); - } -} - -/** A special category of Gtk::Notebook to handle notebook parameters. */ -class ParamNotebookWdg : public Gtk::Notebook { -private: - ParamNotebook * _pref; - SPDocument * _doc; - Inkscape::XML::Node * _node; -public: - /** - * Build a notebookpage preference for the given parameter. - * @param pref Where to get the string (pagename) from, and where to put it - * when it changes. - */ - ParamNotebookWdg (ParamNotebook * pref, SPDocument * doc, Inkscape::XML::Node * node) : - Gtk::Notebook(), _pref(pref), _doc(doc), _node(node), activated(false) { - // don't have to set the correct page: this is done in ParamNotebook::get_widget. - // hook function - this->signal_switch_page().connect(sigc::mem_fun(this, &ParamNotebookWdg::changed_page)); - }; - void changed_page(Gtk::Widget *page, guint pagenum); - bool activated; -}; - -/** - * Respond to the selected page of notebook changing. - * This function responds to the changing by reporting it to - * ParamNotebook. The change is only reported when the notebook - * is actually visible. This to exclude 'fake' changes when the - * notebookpages are added or removed. - */ -void ParamNotebookWdg::changed_page(Gtk::Widget * /*page*/, guint pagenum) -{ - if (get_visible()) { - _pref->set((int)pagenum, _doc, _node); - } -} - -/** Search the parameter's name in the notebook content. */ -Parameter *ParamNotebook::get_param(const gchar * name) -{ - if (name == nullptr) { - throw Extension::param_not_exist(); - } - for (auto page:pages) { - Parameter * subparam = page->get_param(name); - if (subparam) { - return subparam; - } - } - - return nullptr; -} - - -/** - * Creates a Notebook widget for a notebook parameter. - * - * Builds a notebook and puts pages in it. - */ -Gtk::Widget * ParamNotebook::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) -{ - if (_hidden) { - return nullptr; - } - - ParamNotebookWdg * nb = Gtk::manage(new ParamNotebookWdg(this, doc, node)); - - // add pages (if any) - int i = -1; - int pagenr = i; - for (auto page:pages) { - i++; - Gtk::Widget * widg = page->get_widget(doc, node, changeSignal); - nb->append_page(*widg, _(page->get_text())); - if (!strcmp(_value, page->name())) { - pagenr = i; // this is the page to be displayed? - } - } - - nb->show(); - - if (pagenr >= 0) nb->set_current_page(pagenr); - - return dynamic_cast<Gtk::Widget *>(nb); -} - - -} // namespace Extension -} // namespace Inkscape - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/extension/param/notebook.h b/src/extension/param/notebook.h deleted file mode 100644 index dd7154f06..000000000 --- a/src/extension/param/notebook.h +++ /dev/null @@ -1,117 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -#ifndef INK_EXTENSION_PARAMNOTEBOOK_H_SEEN -#define INK_EXTENSION_PARAMNOTEBOOK_H_SEEN - -/** \file - * Notebook parameter for extensions. - */ - -/* - * Author: - * Johan Engelen <johan@shouraizou.nl> - * Jon A. Cruz <jon@joncruz.org> - * - * Copyright (C) 2006 Author - * - * Released under GNU GPL v2+, read the file 'COPYING' for more information. - */ - -#include "parameter.h" - -namespace Gtk { -class Widget; -} - -namespace Inkscape { -namespace Extension { - -class Extension; - - -/** A class to represent a notebookparameter of an extension. */ -class ParamNotebook : public Parameter { -private: - /** - * Internal value. This should point to a string that has - * been allocated in memory. And should be free'd. - * It is the name of the current page. - */ - gchar * _value; - - /** - * A class to represent the pages of a notebookparameter of an extension. - */ - class ParamNotebookPage : public Parameter { - private: - std::vector<Parameter *> parameters; /**< A table to store the parameters for this page. - This only gets created if there are parameters on this - page */ - - public: - static ParamNotebookPage * makepage (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * in_ext); - - ParamNotebookPage(const gchar * name, - const gchar * text, - const gchar * description, - bool hidden, - Inkscape::Extension::Extension * ext, - Inkscape::XML::Node * xml); - ~ParamNotebookPage() override; - - Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) override; - void paramString (std::list <std::string> &list); - gchar * get_text () {return _text;}; - Parameter * get_param (const gchar * name) override; - }; /* class ParamNotebookPage */ - - - std::vector<ParamNotebookPage*> pages; /**< A table to store the pages with parameters for this notebook. - This only gets created if there are pages in this - notebook */ -public: - ParamNotebook(const gchar * name, - const gchar * text, - const gchar * description, - bool hidden, - int indent, - Inkscape::Extension::Extension * ext, - Inkscape::XML::Node * xml); - ~ParamNotebook() override; - - Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) override; - - /** - * A function to get the currentpage and the parameters in a string form. - * @return A string with the 'value' and all the parameters on all pages as command line arguments. - */ - void string (std::list <std::string> &list) const override; - - // Explicitly call superclass version to avoid method being hidden. - void string(std::string &string) const override {return Parameter::string(string);} - - - Parameter * get_param (const gchar * name) override; - - const gchar * get (const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) { return _value; } - const gchar * set (const int in, SPDocument * doc, Inkscape::XML::Node * node); -}; /* class ParamNotebook */ - - - - - -} // namespace Extension -} // namespace Inkscape - -#endif /* INK_EXTENSION_PARAMNOTEBOOK_H_SEEN */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp deleted file mode 100644 index 1a60ef32e..000000000 --- a/src/extension/param/parameter.cpp +++ /dev/null @@ -1,461 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/** @file - * Parameters for extensions. - */ -/* Author: - * Ted Gould <ted@gould.cx> - * Johan Engelen <johan@shouraizou.nl> - * Jon A. Cruz <jon@joncruz.org> - * - * Copyright (C) 2005-2007 Authors - * - * Released under GNU GPL v2+, read the file 'COPYING' for more information. - */ - -#ifdef linux // does the dollar sign need escaping when passed as string parameter? -# define ESCAPE_DOLLAR_COMMANDLINE -#endif - -#include <cstring> -#include <list> - -#include <glibmm/i18n.h> -#include <sigc++/sigc++.h> - -#include "bool.h" -#include "color.h" -#include "description.h" -#include "enum.h" -#include "./float.h" -#include "int.h" -#include "notebook.h" -#include "parameter.h" -#include "radiobutton.h" -#include "./string.h" - -#include "extension/extension.h" - -#include "object/sp-defs.h" - -#include "ui/widget/color-notebook.h" - -#include "xml/node.h" - - -namespace Inkscape { -namespace Extension { - -Parameter *Parameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Extension *in_ext) -{ - const char *name = in_repr->attribute("name"); - const char *type = in_repr->attribute("type"); - - // we can't create a parameter without type - if (!type) { - return nullptr; - } - // also require name unless it's a pure UI element that does not store its value - if (!name) { - static std::vector<std::string> ui_elements = {"description"}; - if (std::find(ui_elements.begin(), ui_elements.end(), type) == ui_elements.end()) { - return nullptr; - } - } - - const char *text = in_repr->attribute("gui-text"); - if (text == nullptr) { - text = in_repr->attribute("_gui-text"); - if (text == nullptr) { - // text = ""; // probably better to require devs to explicitly set an empty gui-text if this is what they want - } else { - const char *context = in_repr->attribute("msgctxt"); - if (context != nullptr) { - text = g_dpgettext2(nullptr, context, text); - } else { - text = _(text); - } - } - } - const char *description = in_repr->attribute("gui-description"); - if (description == nullptr) { - description = in_repr->attribute("_gui-description"); - if (description != nullptr) { - const char *context = in_repr->attribute("msgctxt"); - if (context != nullptr) { - description = g_dpgettext2(nullptr, context, description); - } else { - description = _(description); - } - } - } - bool hidden = false; - { - const char *gui_hide = in_repr->attribute("gui-hidden"); - if (gui_hide != nullptr) { - if (strcmp(gui_hide, "1") == 0 || - strcmp(gui_hide, "true") == 0) { - hidden = true; - } - /* else stays false */ - } - } - int indent = 0; - { - const char *indent_attr = in_repr->attribute("indent"); - if (indent_attr != nullptr) { - if (strcmp(indent_attr, "true") == 0) { - indent = 1; - } else { - indent = atoi(indent_attr); - } - } - } - const gchar* appearance = in_repr->attribute("appearance"); - - Parameter * param = nullptr; - if (!strcmp(type, "boolean")) { - param = new ParamBool(name, text, description, hidden, indent, in_ext, in_repr); - } else if (!strcmp(type, "int")) { - if (appearance && !strcmp(appearance, "full")) { - param = new ParamInt(name, text, description, hidden, indent, in_ext, in_repr, ParamInt::FULL); - } else { - param = new ParamInt(name, text, description, hidden, indent, in_ext, in_repr, ParamInt::MINIMAL); - } - } else if (!strcmp(type, "float")) { - if (appearance && !strcmp(appearance, "full")) { - param = new ParamFloat(name, text, description, hidden, indent, in_ext, in_repr, ParamFloat::FULL); - } else { - param = new ParamFloat(name, text, description, hidden, indent, in_ext, in_repr, ParamFloat::MINIMAL); - } - } else if (!strcmp(type, "string")) { - param = new ParamString(name, text, description, hidden, indent, in_ext, in_repr); - gchar const * max_length = in_repr->attribute("max_length"); - if (max_length != nullptr) { - ParamString * ps = dynamic_cast<ParamString *>(param); - ps->setMaxLength(atoi(max_length)); - } - } else if (!strcmp(type, "description")) { - ParamDescription::AppearanceMode appearance_mode = ParamDescription::DESCRIPTION; - if (appearance) { - if (!strcmp(appearance, "header")) { - appearance_mode = ParamDescription::HEADER; - } else if (!strcmp(appearance, "url")) { - appearance_mode = ParamDescription::URL; - } - } - param = new ParamDescription(name, text, description, hidden, indent, in_ext, in_repr, appearance_mode); - } else if (!strcmp(type, "enum")) { - param = new ParamComboBox(name, text, description, hidden, indent, in_ext, in_repr); - } else if (!strcmp(type, "notebook")) { - param = new ParamNotebook(name, text, description, hidden, indent, in_ext, in_repr); - } else if (!strcmp(type, "optiongroup")) { - if (appearance && !strcmp(appearance, "minimal")) { - param = new ParamRadioButton(name, text, description, hidden, indent, in_ext, in_repr, ParamRadioButton::MINIMAL); - } else { - param = new ParamRadioButton(name, text, description, hidden, indent, in_ext, in_repr, ParamRadioButton::FULL); - } - } else if (!strcmp(type, "color")) { - param = new ParamColor(name, text, description, hidden, indent, in_ext, in_repr); - } - - // Note: param could equal NULL - return param; -} - -bool Parameter::get_bool(SPDocument const *doc, Inkscape::XML::Node const *node) const -{ - ParamBool const *boolpntr = dynamic_cast<ParamBool const *>(this); - if (!boolpntr) { - throw Extension::param_not_bool_param(); - } - return boolpntr->get(doc, node); -} - -int Parameter::get_int(SPDocument const *doc, Inkscape::XML::Node const *node) const -{ - ParamInt const *intpntr = dynamic_cast<ParamInt const *>(this); - if (!intpntr) { - throw Extension::param_not_int_param(); - } - return intpntr->get(doc, node); -} - -float Parameter::get_float(SPDocument const *doc, Inkscape::XML::Node const *node) const -{ - ParamFloat const *floatpntr = dynamic_cast<ParamFloat const *>(this); - if (!floatpntr) { - throw Extension::param_not_float_param(); - } - return floatpntr->get(doc, node); -} - -gchar const *Parameter::get_string(SPDocument const *doc, Inkscape::XML::Node const *node) const -{ - ParamString const *stringpntr = dynamic_cast<ParamString const *>(this); - if (!stringpntr) { - throw Extension::param_not_string_param(); - } - return stringpntr->get(doc, node); -} - -gchar const *Parameter::get_enum(SPDocument const *doc, Inkscape::XML::Node const *node) const -{ - ParamComboBox const *param = dynamic_cast<ParamComboBox const *>(this); - if (!param) { - throw Extension::param_not_enum_param(); - } - return param->get(doc, node); -} - -bool Parameter::get_enum_contains(gchar const * value, SPDocument const *doc, Inkscape::XML::Node const *node) const -{ - ParamComboBox const *param = dynamic_cast<ParamComboBox const *>(this); - if (!param) { - throw Extension::param_not_enum_param(); - } - return param->contains(value, doc, node); -} - -gchar const *Parameter::get_optiongroup(SPDocument const *doc, Inkscape::XML::Node const * node) const -{ - ParamRadioButton const *param = dynamic_cast<ParamRadioButton const *>(this); - if (!param) { - throw Extension::param_not_optiongroup_param(); - } - return param->get(doc, node); -} - -guint32 Parameter::get_color(const SPDocument* doc, Inkscape::XML::Node const *node) const -{ - ParamColor const *param = dynamic_cast<ParamColor const *>(this); - if (!param) { - throw Extension::param_not_color_param(); - } - return param->get(doc, node); -} - -bool Parameter::set_bool(bool in, SPDocument * doc, Inkscape::XML::Node * node) -{ - ParamBool * boolpntr = dynamic_cast<ParamBool *>(this); - if (boolpntr == nullptr) - throw Extension::param_not_bool_param(); - return boolpntr->set(in, doc, node); -} - -int Parameter::set_int(int in, SPDocument * doc, Inkscape::XML::Node * node) -{ - ParamInt * intpntr = dynamic_cast<ParamInt *>(this); - if (intpntr == nullptr) - throw Extension::param_not_int_param(); - return intpntr->set(in, doc, node); -} - -/** Wrapper to cast to the object and use it's function. */ -float -Parameter::set_float (float in, SPDocument * doc, Inkscape::XML::Node * node) -{ - ParamFloat * floatpntr; - floatpntr = dynamic_cast<ParamFloat *>(this); - if (floatpntr == nullptr) - throw Extension::param_not_float_param(); - return floatpntr->set(in, doc, node); -} - -/** Wrapper to cast to the object and use it's function. */ -gchar const * -Parameter::set_string (gchar const * in, SPDocument * doc, Inkscape::XML::Node * node) -{ - ParamString * stringpntr = dynamic_cast<ParamString *>(this); - if (stringpntr == nullptr) - throw Extension::param_not_string_param(); - return stringpntr->set(in, doc, node); -} - -gchar const * Parameter::set_optiongroup( gchar const * in, SPDocument * doc, Inkscape::XML::Node * node ) -{ - ParamRadioButton *param = dynamic_cast<ParamRadioButton *>(this); - if (!param) { - throw Extension::param_not_optiongroup_param(); - } - return param->set(in, doc, node); -} - -gchar const *Parameter::set_enum( gchar const * in, SPDocument * doc, Inkscape::XML::Node * node ) -{ - ParamComboBox *param = dynamic_cast<ParamComboBox *>(this); - if (!param) { - throw Extension::param_not_enum_param(); - } - return param->set(in, doc, node); -} - - -/** Wrapper to cast to the object and use it's function. */ -guint32 -Parameter::set_color (guint32 in, SPDocument * doc, Inkscape::XML::Node * node) -{ - ParamColor* param = dynamic_cast<ParamColor *>(this); - if (param == nullptr) - throw Extension::param_not_color_param(); - return param->set(in, doc, node); -} - - -/** Oop, now that we need a parameter, we need it's name. */ -Parameter::Parameter(gchar const * name, gchar const * text, gchar const * description, bool hidden, int indent, Inkscape::Extension::Extension * ext) : - _description(nullptr), - _text(nullptr), - _hidden(hidden), - _indent(indent), - _extension(ext), - _name(nullptr) -{ - if (name != nullptr) { - _name = g_strdup(name); - } - - if (description != nullptr) { - _description = g_strdup(description); - } - - if (text != nullptr) { - _text = g_strdup(text); - } else { - _text = g_strdup(name); - } - - return; -} - -/** Oop, now that we need a parameter, we need it's name. */ -Parameter::Parameter (gchar const * name, gchar const * text, Inkscape::Extension::Extension * ext) : - _description(nullptr), - _text(nullptr), - _hidden(false), - _indent(0), - _extension(ext), - _name(nullptr) -{ - if (name != nullptr) { - _name = g_strdup(name); - } - if (text != nullptr) { - _text = g_strdup(text); - } else { - _text = g_strdup(name); - } - - return; -} - -Parameter::~Parameter() -{ - g_free(_name); - _name = nullptr; - - g_free(_text); - _text = nullptr; - - g_free(_description); - _description = nullptr; -} - -gchar *Parameter::pref_name() const -{ - return g_strdup_printf("%s.%s", _extension->get_id(), _name); -} - -Inkscape::XML::Node * -Parameter::find_child (Inkscape::XML::Node * adult) -{ - return sp_repr_lookup_child(adult, "name", _name); -} - -Inkscape::XML::Node * -Parameter::new_child (Inkscape::XML::Node * parent) -{ - Inkscape::XML::Node * retval; - retval = parent->document()->createElement("inkscape:extension-param"); - retval->setAttribute("name", _name); - - parent->appendChild(retval); - Inkscape::GC::release(retval); - return retval; -} - -Inkscape::XML::Node *Parameter::document_param_node(SPDocument * doc) -{ - Inkscape::XML::Document *xml_doc = doc->getReprDoc(); - Inkscape::XML::Node * defs = doc->getDefs()->getRepr(); - Inkscape::XML::Node * params = nullptr; - - GQuark const name_quark = g_quark_from_string("inkscape:extension-params"); - - for (Inkscape::XML::Node * child = defs->firstChild(); - child != nullptr; - child = child->next()) { - if ((GQuark)child->code() == name_quark && - !strcmp(child->attribute("extension"), _extension->get_id())) { - params = child; - break; - } - } - - if (params == nullptr) { - params = xml_doc->createElement("inkscape:extension-param"); - params->setAttribute("extension", _extension->get_id()); - defs->appendChild(params); - Inkscape::GC::release(params); - } - - return params; -} - -/** Basically, if there is no widget pass a NULL. */ -Gtk::Widget * -Parameter::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * /*changeSignal*/) -{ - return nullptr; -} - -/** If I'm not sure which it is, just don't return a value. */ -void Parameter::string(std::string &/*string*/) const -{ - // TODO investigate clearing the target string. -} - -void Parameter::string(std::list <std::string> &list) const -{ - std::string value; - string(value); - if (!value.empty()) { - std::string final; - final += "--"; - final += name(); - final += "="; - final += value; - - list.insert(list.end(), final); - } -} - -Parameter *Parameter::get_param(gchar const * /*name*/) -{ - return nullptr; -} - -Glib::ustring const extension_pref_root = "/extensions/"; - -} // namespace Extension -} // namespace Inkscape - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/extension/param/parameter.h b/src/extension/param/parameter.h deleted file mode 100644 index c37d1539a..000000000 --- a/src/extension/param/parameter.h +++ /dev/null @@ -1,219 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/** @file - * Parameters for extensions. - */ -/* Authors: - * Ted Gould <ted@gould.cx> - * Jon A. Cruz <jon@joncruz.org> - * - * Copyright (C) 2005-2006 Authors - * - * Released under GNU GPL v2+, read the file 'COPYING' for more information. - */ - -#ifndef SEEN_INK_EXTENSION_PARAM_H__ -#define SEEN_INK_EXTENSION_PARAM_H__ - -#include <string> - -#include <glibmm/ustring.h> - -class SPDocument; - -namespace Gtk { -class Widget; -} - -namespace Inkscape { -namespace XML { -class Node; -} - -namespace Extension { - -class Extension; - - -/** - * The root directory in the preferences database for extension-related parameters. - * - * The directory path has both a leading and a trailing slash, so that extension_pref_root + pref_name works - * without having to append a separator. - */ -extern Glib::ustring const extension_pref_root; - -/** - * A class to represent the parameter of an extension. - * - * This is really a super class that allows them to abstract all - * the different types of parameters into some that can be passed - * around. There is also a few functions that are used by all the - * different parameters. - */ -class Parameter { - -public: - Parameter(gchar const *name, - gchar const *text, - gchar const *description, - bool hidden, - int indent, - Inkscape::Extension::Extension * ext); - - Parameter(gchar const *name, - gchar const *text, - Inkscape::Extension::Extension * ext); - - virtual ~Parameter(); - - /** Wrapper to cast to the object and use its function. */ - bool get_bool(SPDocument const *doc, Inkscape::XML::Node const *node) const; - - /** Wrapper to cast to the object and use it's function. */ - int get_int(SPDocument const *doc, Inkscape::XML::Node const *node) const; - - /** Wrapper to cast to the object and use it's function. */ - float get_float(SPDocument const *doc, Inkscape::XML::Node const *node) const; - - /** Wrapper to cast to the object and use it's function. */ - gchar const *get_string(SPDocument const *doc, Inkscape::XML::Node const *node) const; - - guint32 get_color(SPDocument const *doc, Inkscape::XML::Node const *node) const; - - /** Wrapper to cast to the object and use it's function. */ - gchar const *get_enum(SPDocument const *doc, Inkscape::XML::Node const *node) const; - - /** Wrapper to cast to the object and use it's function. */ - bool get_enum_contains(gchar const * value, SPDocument const *doc, Inkscape::XML::Node const *node) const; - - /** Wrapper to cast to the object and use it's function. */ - gchar const *get_optiongroup(SPDocument const * doc, Inkscape::XML::Node const *node) const; - - /** Wrapper to cast to the object and use it's function. */ - bool set_bool(bool in, SPDocument * doc, Inkscape::XML::Node * node); - - /** Wrapper to cast to the object and use it's function. */ - int set_int(int in, SPDocument * doc, Inkscape::XML::Node * node); - - float set_float(float in, SPDocument * doc, Inkscape::XML::Node * node); - - gchar const *set_optiongroup(gchar const *in, SPDocument * doc, Inkscape::XML::Node *node); - - gchar const *set_enum(gchar const * in, SPDocument * doc, Inkscape::XML::Node *node); - - gchar const *set_string(gchar const * in, SPDocument * doc, Inkscape::XML::Node * node); - - guint32 set_color(guint32 in, SPDocument * doc, Inkscape::XML::Node * node); - - gchar const * name() const {return _name;} - - /** - * This function creates a parameter that can be used later. This - * is typically done in the creation of the extension and defined - * in the XML file describing the extension (it's private so people - * have to use the system) :) - * - * This function first grabs all of the data out of the Repr and puts - * it into local variables. Actually, these are just pointers, and the - * data is not duplicated so we need to be careful with it. If there - * isn't a name or a type in the XML, then no parameter is created as - * the function just returns. - * - * From this point on, we're pretty committed as we've allocated an - * object and we're starting to fill it. The name is set first, and - * is created with a strdup to actually allocate memory for it. Then - * there is a case statement (roughly because strcmp requires 'ifs') - * based on what type of parameter this is. Depending which type it - * is, the value is interpreted differently, but they are relatively - * straight forward. In all cases the value is set to the default - * value from the XML and the type is set to the interpreted type. - * - * @param in_repr The XML describing the parameter. - * @return a pointer to a new Parameter if applicable, null otherwise.. - */ - static Parameter *make(Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * in_ext); - - virtual Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal); - - gchar const * get_tooltip() const { return _description; } - - /** Indicates if the GUI for this parameter is hidden or not */ - bool get_hidden() const { return _hidden; } - - /** Indentation level of the parameter */ - int get_indent() const { return _indent; } - - virtual void string(std::list <std::string> &list) const; - - /** - * Gets the current value of the parameter in a string form. - * @return A string with the 'value'. - */ - virtual void string(std::string &string) const; - - /** All the code in Notebook::get_param to get the notebook content. */ - virtual Parameter *get_param(gchar const *name); - - - /** Recommended margin of boxes containing multiple Parameters (in px) */ - const static int GUI_BOX_MARGIN = 10; - /** Recommended spacing between multiple Parameters packed into a box (in px) */ - const static int GUI_BOX_SPACING = 4; - /** Recommended spacing between the widgets making up a single Parameter (e.g. label and input) (in px) */ - const static int GUI_PARAM_WIDGETS_SPACING = 4; - /** Recommended indentation width of parameters (in px) */ - const static int GUI_INDENTATION = 12; - /** Recommended maximum line length for wrapping textual parameters (in chars) */ - const static int GUI_MAX_LINE_LENGTH = 60; - - -protected: - /** Parameter text to show as the GUI label. */ - gchar * _text; - - /** Extended description of the parameter (crrently shown as tooltip on hover). */ - gchar * _description; - - /** Whether the parameter is visible. */ - bool _hidden; - - /** Indentation level of the parameter. */ - int _indent; - - - /* **** funcs **** */ - - /** - * Build the name to write the parameter from the extension's ID and the name of this parameter. - */ - gchar *pref_name() const; - - Inkscape::XML::Node * find_child (Inkscape::XML::Node * adult); - - Inkscape::XML::Node * document_param_node (SPDocument * doc); - - Inkscape::XML::Node * new_child (Inkscape::XML::Node * parent); - -private: - /** Which extension is this parameter attached to. */ - Inkscape::Extension::Extension *_extension; - - /** The name of this parameter. */ - gchar *_name; -}; - -} // namespace Extension -} // namespace Inkscape - -#endif // SEEN_INK_EXTENSION_PARAM_H__ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/extension/param/radiobutton.cpp b/src/extension/param/radiobutton.cpp deleted file mode 100644 index 8c1d6a5f7..000000000 --- a/src/extension/param/radiobutton.cpp +++ /dev/null @@ -1,349 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/** \file - * extension parameter for radiobuttons. - * - * It uses a Gtk:ComboBoxText widget in the extension UI. - */ - -/* - * Author: - * Johan Engelen <johan@shouraizou.nl> - * - * Copyright (C) 2006-2007 Johan Engelen - * Copyright (C) 2008 Jon A. Cruz - * - * Released under GNU GPL v2+, read the file 'COPYING' for more information. - */ - -#include <gtkmm/box.h> -#include <gtkmm/comboboxtext.h> -#include <gtkmm/radiobutton.h> -#include <glibmm/i18n.h> - -#include "xml/node.h" -#include "extension/extension.h" -#include "preferences.h" - -#include "radiobutton.h" - -/** - * The root directory in the preferences database for extension - * related parameters. - */ -#define PREF_DIR "extensions" - -namespace Inkscape { -namespace Extension { - -/* For internal use only. - Note that value and text MUST be non-NULL. This is ensured by newing only at one location in the code where non-NULL checks are made. */ - -ParamRadioButton::ParamRadioButton(const gchar * name, - const gchar * text, - const gchar * description, - bool hidden, - int indent, - Inkscape::Extension::Extension * ext, - Inkscape::XML::Node * xml, - AppearanceMode mode) - : Parameter(name, text, description, hidden, indent, ext) - , _value(nullptr) - , _mode(mode) -{ - // Read XML tree to add enumeration items: - // printf("Extension Constructor: "); - if (xml != nullptr) { - Inkscape::XML::Node *child_repr = xml->firstChild(); - while (child_repr != nullptr) { - char const * chname = child_repr->name(); - if (!strcmp(chname, INKSCAPE_EXTENSION_NS "option") || !strcmp(chname, INKSCAPE_EXTENSION_NS "_option")) { - Glib::ustring * newtext = nullptr; - Glib::ustring * newvalue = nullptr; - const char * contents = child_repr->firstChild()->content(); - - if (contents != nullptr) { - // don't translate when 'item' but do translate when '_option' - if (!strcmp(chname, INKSCAPE_EXTENSION_NS "_option")) { - if (child_repr->attribute("msgctxt") != nullptr) { - newtext = new Glib::ustring(g_dpgettext2(nullptr, child_repr->attribute("msgctxt"), contents)); - } else { - newtext = new Glib::ustring(_(contents)); - } - } else { - newtext = new Glib::ustring(contents); - } - } else { - continue; - } - - - const char * val = child_repr->attribute("value"); - if (val != nullptr) { - newvalue = new Glib::ustring(val); - } else { - newvalue = new Glib::ustring(contents); - } - - if ( (newtext) && (newvalue) ) { // logical error if this is not true here - choices.push_back(new optionentry(newvalue, newtext)); - } - } - child_repr = child_repr->next(); - } - } - - // Initialize _value with the default value from xml - // for simplicity : default to the contents of the first xml-child - const char * defaultval = nullptr; - if (!choices.empty()) { - defaultval = (static_cast<optionentry*> (choices[0]))->value->c_str(); - } - - gchar * pref_name = this->pref_name(); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - Glib::ustring paramval = prefs->getString(extension_pref_root + pref_name); - g_free(pref_name); - - if (!paramval.empty()) { - defaultval = paramval.data(); - } - if (defaultval != nullptr) { - _value = g_strdup(defaultval); // allocate space for _value - } -} - -ParamRadioButton::~ParamRadioButton () -{ - //destroy choice strings - for(auto i:choices) { - delete i; - } - g_free(_value); -} - - -/** - * A function to set the \c _value. - * - * This function sets ONLY the internal value, but it also sets the value - * in the preferences structure. To put it in the right place, \c PREF_DIR - * and \c pref_name() are used. - * - * To copy the data into _value the old memory must be free'd first. - * It is important to note that \c g_free handles \c NULL just fine. Then - * the passed in value is duplicated using \c g_strdup(). - * - * @param in The value to set. - * @param doc A document that should be used to set the value. - * @param node The node where the value may be placed. - */ -const gchar *ParamRadioButton::set(const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) -{ - if (in == nullptr) { - return nullptr; /* Can't have NULL string */ - } - - Glib::ustring * settext = nullptr; - for (auto entr:choices) { - if ( !entr->value->compare(in) ) { - settext = entr->value; - break; // break out of for loop - } - } - if (settext) { - if (_value != nullptr) { - g_free(_value); - } - _value = g_strdup(settext->c_str()); - gchar * prefname = this->pref_name(); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setString(extension_pref_root + prefname, _value); - g_free(prefname); - } else { - g_warning("Couldn't set ParamRadioButton %s", in); - } - - return _value; -} - -void ParamRadioButton::string(std::string &string) const -{ - string += _value; -} - -/** A special radiobutton class to use in ParamRadioButton. */ -class ParamRadioButtonWdg : public Gtk::RadioButton { -private: - ParamRadioButton * _pref; - SPDocument * _doc; - Inkscape::XML::Node * _node; - sigc::signal<void> * _changeSignal; -public: - /** - * Build a string preference for the given parameter. - * @param pref Where to put the radiobutton's string when it is selected. - */ - ParamRadioButtonWdg ( Gtk::RadioButtonGroup& group, const Glib::ustring& label, - ParamRadioButton * pref, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal ) : - Gtk::RadioButton(group, label), _pref(pref), _doc(doc), _node(node), _changeSignal(changeSignal) { - add_changesignal(); - }; - ParamRadioButtonWdg ( const Glib::ustring& label, - ParamRadioButton * pref, SPDocument * doc, Inkscape::XML::Node * node , sigc::signal<void> * changeSignal) : - Gtk::RadioButton(label), _pref(pref), _doc(doc), _node(node), _changeSignal(changeSignal) { - add_changesignal(); - }; - void add_changesignal() { - this->signal_toggled().connect(sigc::mem_fun(this, &ParamRadioButtonWdg::changed)); - }; - void changed (); -}; - -/** - * Respond to the selected radiobutton changing. - * - * This function responds to the radiobutton selection changing by grabbing the value - * from the text box and putting it in the parameter. - */ -void ParamRadioButtonWdg::changed() -{ - if (this->get_active()) { - Glib::ustring value = _pref->value_from_label(this->get_label()); - _pref->set(value.c_str(), _doc, _node); - } - if (_changeSignal != nullptr) { - _changeSignal->emit(); - } -} - - -class ComboWdg : public Gtk::ComboBoxText { -private: - ParamRadioButton* _base; - SPDocument* _doc; - Inkscape::XML::Node* _node; - sigc::signal<void> * _changeSignal; - -public: - ComboWdg(ParamRadioButton* base, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) : - _base(base), - _doc(doc), - _node(node), - _changeSignal(changeSignal) - { - this->signal_changed().connect(sigc::mem_fun(this, &ComboWdg::changed)); - } - ~ComboWdg() override = default; - void changed (); -}; - -void ComboWdg::changed() -{ - if ( _base ) { - Glib::ustring value = _base->value_from_label(get_active_text()); - _base->set(value.c_str(), _doc, _node); - } - if (_changeSignal != nullptr) { - _changeSignal->emit(); - } -} - -/** - * Returns the value for the options label parameter - */ -Glib::ustring ParamRadioButton::value_from_label(const Glib::ustring label) -{ - Glib::ustring value = ""; - - for ( auto entr:choices) { - if ( !entr->text->compare(label) ) { - value = *(entr->value); - break; - } - } - - return value; - -} - -/** - * Creates a combobox widget for an enumeration parameter. - */ -Gtk::Widget * ParamRadioButton::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) -{ - if (_hidden) { - return nullptr; - } - - auto hbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, Parameter::GUI_PARAM_WIDGETS_SPACING)); - hbox->set_homogeneous(false); - auto vbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL, 0)); - vbox->set_homogeneous(false); - - Gtk::Label * label = Gtk::manage(new Gtk::Label(_text, Gtk::ALIGN_START, Gtk::ALIGN_START)); - label->show(); - hbox->pack_start(*label, false, false); - - Gtk::ComboBoxText* cbt = nullptr; - bool comboSet = false; - if (_mode == MINIMAL) { - cbt = Gtk::manage(new ComboWdg(this, doc, node, changeSignal)); - cbt->show(); - vbox->pack_start(*cbt, false, false); - } - - // add choice strings as radiobuttons - // and select last selected option (_value) - Gtk::RadioButtonGroup group; - for (auto entr:choices) { - Glib::ustring * text = entr->text; - switch ( _mode ) { - case MINIMAL: - { - cbt->append(*text); - if (!entr->value->compare(_value)) { - cbt->set_active_text(*text); - comboSet = true; - } - } - break; - case COMPACT: - case FULL: - { - ParamRadioButtonWdg * radio = Gtk::manage(new ParamRadioButtonWdg(group, *text, this, doc, node, changeSignal)); - radio->show(); - vbox->pack_start(*radio, true, true); - if (!entr->value->compare(_value)) { - radio->set_active(); - } - } - break; - } - } - - if ( (_mode == MINIMAL) && !comboSet) { - cbt->set_active(0); - } - - vbox->show(); - hbox->pack_end(*vbox, false, false); - hbox->show(); - - - return dynamic_cast<Gtk::Widget *>(hbox); -} - - -} /* namespace Extension */ -} /* namespace Inkscape */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/extension/param/radiobutton.h b/src/extension/param/radiobutton.h deleted file mode 100644 index 48d470a01..000000000 --- a/src/extension/param/radiobutton.h +++ /dev/null @@ -1,107 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -#ifndef INK_EXTENSION_PARAMRADIOBUTTON_H_SEEN -#define INK_EXTENSION_PARAMRADIOBUTTON_H_SEEN - -/** \file - * Radiobutton parameter for extensions. - */ - -/* - * Authors: - * Johan Engelen <johan@shouraizou.nl> - * Jon A. Cruz <jon@joncruz.org> - * - * Copyright (C) 2006-2007 Johan Engelen - * - * Released under GNU GPL v2+, read the file 'COPYING' for more information. - */ - -#include "parameter.h" - -namespace Gtk { -class Widget; -} - -namespace Inkscape { -namespace Extension { - -class Extension; - - - -// \brief A class to represent a radiobutton parameter of an extension -class ParamRadioButton : public Parameter { -public: - enum AppearanceMode { - FULL, COMPACT, MINIMAL - }; - - ParamRadioButton(const gchar * name, - const gchar * text, - const gchar * description, - bool hidden, - int indent, - Inkscape::Extension::Extension * ext, - Inkscape::XML::Node * xml, - AppearanceMode mode); - ~ParamRadioButton() override; - - Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) override; - - // Explicitly call superclass version to avoid method being hidden. - void string(std::list <std::string> &list) const override { return Parameter::string(list); } - - void string(std::string &string) const override; - - Glib::ustring value_from_label(const Glib::ustring label); - - const gchar *get(const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) const { return _value; } - - const gchar *set(const gchar *in, SPDocument *doc, Inkscape::XML::Node *node); - -private: - /** \brief Internal value. This should point to a string that has - been allocated in memory. And should be free'd. - It is the value of the current selected string */ - gchar * _value; - AppearanceMode _mode; - - /* For internal use only. - Note that value and text MUST be non-NULL. This is ensured by newing only at one location in the code where non-NULL checks are made. */ - class optionentry { - public: - optionentry (Glib::ustring * val, Glib::ustring * txt) { - value = val; - text = txt; - } - ~optionentry() { - delete value; - delete text; - } - Glib::ustring * value; - Glib::ustring * text; - }; - - std::vector<optionentry*> choices; /**< A table to store the choice strings */ - -}; /* class ParamRadioButton */ - - - - - -} /* namespace Extension */ -} /* namespace Inkscape */ - -#endif /* INK_EXTENSION_PARAMRADIOBUTTON_H_SEEN */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/extension/param/string.cpp b/src/extension/param/string.cpp deleted file mode 100644 index c1986cf92..000000000 --- a/src/extension/param/string.cpp +++ /dev/null @@ -1,181 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * Copyright (C) 2005-2007 Authors: - * Ted Gould <ted@gould.cx> - * Johan Engelen <johan@shouraizou.nl> * - * Jon A. Cruz <jon@joncruz.org> - * Released under GNU GPL v2+, read the file 'COPYING' for more information. - */ - -#include <gtkmm/adjustment.h> -#include <gtkmm/box.h> -#include <gtkmm/spinbutton.h> - -#include <glibmm/value.h> - -#include "xml/node.h" -#include "extension/extension.h" -#include "./string.h" -#include "preferences.h" -#include <glibmm/i18n.h> - -namespace Inkscape { -namespace Extension { - - -/** Free the allocated data. */ -ParamString::~ParamString() -{ - g_free(_value); - _value = nullptr; -} - -/** - * A function to set the \c _value. - * - * This function sets the internal value, but it also sets the value - * in the preferences structure. To put it in the right place, \c PREF_DIR - * and \c pref_name() are used. - * - * To copy the data into _value the old memory must be free'd first. - * It is important to note that \c g_free handles \c NULL just fine. Then - * the passed in value is duplicated using \c g_strdup(). - * - * @param in The value to set to. - * @param doc A document that should be used to set the value. - * @param node The node where the value may be placed. - */ -const gchar * ParamString::set(const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) -{ - if (in == nullptr) { - return nullptr; /* Can't have NULL string */ - } - - if (_value != nullptr) { - g_free(_value); - } - - _value = g_strdup(in); - - gchar * prefname = this->pref_name(); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setString(extension_pref_root + prefname, _value); - g_free(prefname); - - return _value; -} - -void ParamString::string(std::string &string) const -{ - if (_value) { - string += _value; - } -} - -/** Initialize the object, to do that, copy the data. */ -ParamString::ParamString(const gchar * name, - const gchar * text, - const gchar * description, - bool hidden, - int indent, - Inkscape::Extension::Extension * ext, - Inkscape::XML::Node * xml) - : Parameter(name, text, description, hidden, indent, ext) - , _value(nullptr) -{ - const char * defaultval = nullptr; - if (xml->firstChild() != nullptr) { - defaultval = xml->firstChild()->content(); - } - - gchar * pref_name = this->pref_name(); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - Glib::ustring paramval = prefs->getString(extension_pref_root + pref_name); - g_free(pref_name); - - if (!paramval.empty()) { - defaultval = paramval.data(); - } - if (defaultval != nullptr) { - char const * chname = xml->name(); - if (!strcmp(chname, INKSCAPE_EXTENSION_NS "_param")) { - if (xml->attribute("msgctxt") != nullptr) { - _value = g_strdup(g_dpgettext2(nullptr, xml->attribute("msgctxt"), defaultval)); - } else { - _value = g_strdup(_(defaultval)); - } - } else { - _value = g_strdup(defaultval); - } - } - - _max_length = 0; -} - -/** A special type of Gtk::Entry to handle string parameteres. */ -class ParamStringEntry : public Gtk::Entry { -private: - ParamString * _pref; - SPDocument * _doc; - Inkscape::XML::Node * _node; - sigc::signal<void> * _changeSignal; -public: - /** - * Build a string preference for the given parameter. - * @param pref Where to get the string from, and where to put it - * when it changes. - */ - ParamStringEntry (ParamString * pref, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) : - Gtk::Entry(), _pref(pref), _doc(doc), _node(node), _changeSignal(changeSignal) { - if (_pref->get(nullptr, nullptr) != nullptr) { - this->set_text(Glib::ustring(_pref->get(nullptr, nullptr))); - } - this->set_max_length(_pref->getMaxLength()); //Set the max length - default zero means no maximum - this->signal_changed().connect(sigc::mem_fun(this, &ParamStringEntry::changed_text)); - }; - void changed_text (); -}; - - -/** - * Respond to the text box changing. - * - * This function responds to the box changing by grabbing the value - * from the text box and putting it in the parameter. - */ -void ParamStringEntry::changed_text() -{ - Glib::ustring data = this->get_text(); - _pref->set(data.c_str(), _doc, _node); - if (_changeSignal != nullptr) { - _changeSignal->emit(); - } -} - -/** - * Creates a text box for the string parameter. - * - * Builds a hbox with a label and a text box in it. - */ -Gtk::Widget * ParamString::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) -{ - if (_hidden) { - return nullptr; - } - - Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, Parameter::GUI_PARAM_WIDGETS_SPACING)); - Gtk::Label * label = Gtk::manage(new Gtk::Label(_text, Gtk::ALIGN_START)); - label->show(); - hbox->pack_start(*label, false, false); - - ParamStringEntry * textbox = new ParamStringEntry(this, doc, node, changeSignal); - textbox->show(); - hbox->pack_start(*textbox, true, true); - - hbox->show(); - - return dynamic_cast<Gtk::Widget *>(hbox); -} - -} /* namespace Extension */ -} /* namespace Inkscape */ diff --git a/src/extension/param/string.h b/src/extension/param/string.h deleted file mode 100644 index 7c094d394..000000000 --- a/src/extension/param/string.h +++ /dev/null @@ -1,67 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -#ifndef INK_EXTENSION_PARAMSTRING_H_SEEN -#define INK_EXTENSION_PARAMSTRING_H_SEEN - -/* - * Copyright (C) 2005-2007 Authors: - * Ted Gould <ted@gould.cx> - * Johan Engelen <johan@shouraizou.nl> * - * Jon A. Cruz <jon@joncruz.org> - * Released under GNU GPL v2+, read the file 'COPYING' for more information. - */ - -#include "parameter.h" - -namespace Inkscape { -namespace Extension { - -class ParamString : public Parameter { -private: - /** \brief Internal value. This should point to a string that has - been allocated in memory. And should be free'd. */ - gchar * _value; - /** \brief Internal value. This indicates the maximum length of the string. Zero meaning unlimited. - */ - gint _max_length; -public: - ParamString(const gchar * name, - const gchar * text, - const gchar * description, - bool hidden, - int indent, - Inkscape::Extension::Extension * ext, - Inkscape::XML::Node * xml); - ~ParamString() override; - - /** \brief Returns \c _value, with a \i const to protect it. */ - const gchar *get(SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/) const { return _value; } - - const gchar * set (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node); - - Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) override; - - // Explicitly call superclass version to avoid method being hidden. - void string(std::list <std::string> &list) const override { return Parameter::string(list); } - - void string(std::string &string) const override; - - void setMaxLength(int maxLength) { _max_length = maxLength; } - int getMaxLength() { return _max_length; } -}; - - -} // namespace Extension -} // namespace Inkscape - -#endif /* INK_EXTENSION_PARAMSTRING_H_SEEN */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/extension/patheffect.cpp b/src/extension/patheffect.cpp index 89925f73b..3ed53e74e 100644 --- a/src/extension/patheffect.cpp +++ b/src/extension/patheffect.cpp @@ -10,15 +10,19 @@ #include "patheffect.h" + #include "db.h" #include "object/sp-defs.h" +#include "xml/repr.h" + + namespace Inkscape { namespace Extension { -PathEffect::PathEffect (Inkscape::XML::Node * in_repr, Implementation::Implementation * in_imp) - : Extension(in_repr, in_imp) +PathEffect::PathEffect (Inkscape::XML::Node *in_repr, Implementation::Implementation *in_imp, std::string *base_directory) + : Extension(in_repr, in_imp, base_directory) { } diff --git a/src/extension/patheffect.h b/src/extension/patheffect.h index 734f0c58a..b2dd7a029 100644 --- a/src/extension/patheffect.h +++ b/src/extension/patheffect.h @@ -20,9 +20,9 @@ namespace Extension { class PathEffect : public Extension { public: - PathEffect (Inkscape::XML::Node * in_repr, - Implementation::Implementation * in_imp); - ~PathEffect () override; + PathEffect(Inkscape::XML::Node *in_repr, Implementation::Implementation *in_imp, std::string *base_directory); + ~PathEffect() override; + void processPath (SPDocument * doc, Inkscape::XML::Node * path, Inkscape::XML::Node * def); diff --git a/src/extension/param/bool.cpp b/src/extension/prefdialog/parameter-bool.cpp index 10121f7ab..609e72774 100644 --- a/src/extension/param/bool.cpp +++ b/src/extension/prefdialog/parameter-bool.cpp @@ -7,61 +7,51 @@ * Released under GNU GPL v2+, read the file 'COPYING' for more information. */ -#include <gtkmm/adjustment.h> +#include "parameter-bool.h" + #include <gtkmm/box.h> -#include <gtkmm/spinbutton.h> #include <gtkmm/checkbutton.h> #include "xml/node.h" -#include "../extension.h" -#include "bool.h" +#include "extension/extension.h" #include "preferences.h" namespace Inkscape { namespace Extension { -ParamBool::ParamBool(const gchar * name, - const gchar * text, - const gchar * description, - bool hidden, - int indent, - Inkscape::Extension::Extension * ext, - Inkscape::XML::Node * xml) - : Parameter(name, text, description, hidden, indent, ext) - , _value(false) +ParamBool::ParamBool(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext) + : InxParameter(xml, ext) { - const char * defaultval = nullptr; - if (xml->firstChild() != nullptr) { - defaultval = xml->firstChild()->content(); - } - - if (defaultval != nullptr && (!strcmp(defaultval, "true") || !strcmp(defaultval, "1"))) { - _value = true; - } else { - _value = false; + // get value + if (xml->firstChild()) { + const char *value = xml->firstChild()->content(); + if (value) { + if (!strcmp(value, "true")) { + _value = true; + } else if (!strcmp(value, "false")) { + _value = false; + } else { + g_warning("Invalid default value ('%s') for parameter '%s' in extension '%s'", + value, _name, _extension->get_id()); + } + } } - gchar * pref_name = this->pref_name(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - _value = prefs->getBool(extension_pref_root + pref_name, _value); - g_free(pref_name); - - return; + _value = prefs->getBool(pref_name(), _value); } -bool ParamBool::set( bool in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/ ) +bool ParamBool::set(bool in) { _value = in; - gchar * prefname = this->pref_name(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setBool(extension_pref_root + prefname, _value); - g_free(prefname); + prefs->setBool(pref_name(), _value); return _value; } -bool ParamBool::get(const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) const +bool ParamBool::get() const { return _value; } @@ -80,9 +70,11 @@ public: * * @param param Which parameter to adjust on changing the check button */ - ParamBoolCheckButton (ParamBool * param, gchar * label, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) : - Gtk::CheckButton(label), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) { - this->set_active(_pref->get(nullptr, nullptr) /**\todo fix */); + ParamBoolCheckButton(ParamBool *param, char *label, sigc::signal<void> *changeSignal) + : Gtk::CheckButton(label) + , _pref(param) + , _changeSignal(changeSignal) { + this->set_active(_pref->get()); this->signal_toggled().connect(sigc::mem_fun(this, &ParamBoolCheckButton::on_toggle)); return; } @@ -95,42 +87,37 @@ public: private: /** Param to change. */ - ParamBool * _pref; - SPDocument * _doc; - Inkscape::XML::Node * _node; - sigc::signal<void> * _changeSignal; + ParamBool *_pref; + sigc::signal<void> *_changeSignal; }; void ParamBoolCheckButton::on_toggle() { - _pref->set(this->get_active(), nullptr /**\todo fix this */, nullptr); + _pref->set(this->get_active()); if (_changeSignal != nullptr) { _changeSignal->emit(); } return; } -void ParamBool::string(std::string &string) const +std::string ParamBool::value_to_string() const { if (_value) { - string += "true"; - } else { - string += "false"; + return "true"; } - - return; + return "false"; } -Gtk::Widget *ParamBool::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) +Gtk::Widget *ParamBool::get_widget(sigc::signal<void> *changeSignal) { if (_hidden) { return nullptr; } - auto hbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, Parameter::GUI_PARAM_WIDGETS_SPACING)); + auto hbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, GUI_PARAM_WIDGETS_SPACING)); hbox->set_homogeneous(false); - ParamBoolCheckButton * checkbox = Gtk::manage(new ParamBoolCheckButton(this, _text, doc, node, changeSignal)); + ParamBoolCheckButton * checkbox = Gtk::manage(new ParamBoolCheckButton(this, _text, changeSignal)); checkbox->show(); hbox->pack_start(*checkbox, false, false); diff --git a/src/extension/param/bool.h b/src/extension/prefdialog/parameter-bool.h index 9864cac38..52fe06a73 100644 --- a/src/extension/param/bool.h +++ b/src/extension/prefdialog/parameter-bool.h @@ -11,8 +11,6 @@ #include "parameter.h" -class SPDocument; - namespace Gtk { class Widget; } @@ -27,55 +25,39 @@ namespace Extension { /** * A boolean parameter. */ -class ParamBool : public Parameter { +class ParamBool : public InxParameter { public: - - /** - * Use the superclass' allocator and set the \c _value. - */ - ParamBool(const gchar * name, - const gchar * text, - const gchar * description, - bool hidden, - int indent, - Inkscape::Extension::Extension * ext, - Inkscape::XML::Node * xml); + ParamBool(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext); /** * Returns the current state/value. */ - bool get(const SPDocument *doc, const Inkscape::XML::Node *node) const; + bool get() const; /** * A function to set the state/value. * This function sets the internal value, but it also sets the value - * in the preferences structure. To put it in the right place, \c PREF_DIR - * and \c pref_name() are used. + * in the preferences structure. To put it in the right place pref_name() is used. * * @param in The value to set to - * @param doc A document that should be used to set the value. - * @param node The node where the value may be placed */ - bool set(bool in, SPDocument * doc, Inkscape::XML::Node * node); + bool set(bool in); /** * Creates a bool check button for a bool parameter. * Builds a hbox with a label and a check button in it. */ - Gtk::Widget *get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) override; - - // Explicitly call superclass version to avoid method being hidden. - void string(std::list <std::string> &list) const override { return Parameter::string(list); } + Gtk::Widget *get_widget(sigc::signal<void> *changeSignal) override; /** * Appends 'true' or 'false'. * @todo investigate. Returning a value that can then be appended would probably work better/safer. */ - void string(std::string &string) const override; + std::string value_to_string() const override; private: /** Internal value. */ - bool _value; + bool _value = true; }; } // namespace Extension diff --git a/src/extension/prefdialog/parameter-color.cpp b/src/extension/prefdialog/parameter-color.cpp new file mode 100644 index 000000000..a17ca1bbd --- /dev/null +++ b/src/extension/prefdialog/parameter-color.cpp @@ -0,0 +1,146 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2005-2007 Authors: + * Ted Gould <ted@gould.cx> + * Johan Engelen <johan@shouraizou.nl> + * Christopher Brown <audiere@gmail.com> + * Jon A. Cruz <jon@joncruz.org> + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#include "parameter-color.h" + +#include <iostream> +#include <sstream> + +#include <gtkmm/box.h> +#include <gtkmm/colorbutton.h> +#include <gtkmm/label.h> + +#include "color.h" +#include "preferences.h" + +#include "extension/extension.h" + +#include "ui/widget/color-notebook.h" + +#include "xml/node.h" + + +namespace Inkscape { +namespace Extension { + +ParamColor::ParamColor(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext) + : InxParameter(xml, ext) +{ + // get value + unsigned int _value = 0x000000ff; // default to black + if (xml->firstChild()) { + const char *value = xml->firstChild()->content(); + if (value) { + _value = strtoul(value, nullptr, 0); + } + } + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + _value = prefs->getUInt(pref_name(), _value); + + _color.setValue(_value); + + _color_changed = _color.signal_changed.connect(sigc::mem_fun(this, &ParamColor::_onColorChanged)); + // TODO: SelectedColor does not properly emit signal_changed after dragging, so we also need the following + _color_released = _color.signal_released.connect(sigc::mem_fun(this, &ParamColor::_onColorChanged)); + + // parse appearance + if (_appearance) { + if (!strcmp(_appearance, "colorbutton")) { + _mode = COLOR_BUTTON; + } else { + g_warning("Invalid value ('%s') for appearance of parameter '%s' in extension '%s'", + _appearance, _name, _extension->get_id()); + } + } +} + +ParamColor::~ParamColor() +{ + _color_changed.disconnect(); + _color_released.disconnect(); +} + +unsigned int ParamColor::set(unsigned int in) +{ + _color.setValue(in); + + return in; +} + +Gtk::Widget *ParamColor::get_widget(sigc::signal<void> *changeSignal) +{ + if (_hidden) { + return nullptr; + } + + if (changeSignal) { + _changeSignal = new sigc::signal<void>(*changeSignal); + } + + Gtk::HBox *hbox = Gtk::manage(new Gtk::HBox(false, GUI_PARAM_WIDGETS_SPACING)); + if (_mode == COLOR_BUTTON) { + Gtk::Label *label = Gtk::manage(new Gtk::Label(_text, Gtk::ALIGN_START)); + label->show(); + hbox->pack_start(*label, true, true); + + Gdk::RGBA rgba; + rgba.set_red_u (((_color.value() >> 24) & 255) << 8); + rgba.set_green_u(((_color.value() >> 16) & 255) << 8); + rgba.set_blue_u (((_color.value() >> 8) & 255) << 8); + rgba.set_alpha_u(((_color.value() >> 0) & 255) << 8); + + // TODO: It would be nicer to have a custom Gtk::ColorButton() implementation here, + // that wraps an Inkscape::UI::Widget::ColorNotebook into a new dialog + _color_button = Gtk::manage(new Gtk::ColorButton(rgba)); + _color_button->set_title(_text); + _color_button->set_use_alpha(); + _color_button->show(); + hbox->pack_end(*_color_button, false, false); + + _color_button->signal_color_set().connect(sigc::mem_fun(this, &ParamColor::_onColorButtonChanged)); + } else { + Gtk::Widget *selector = Gtk::manage(new Inkscape::UI::Widget::ColorNotebook(_color)); + hbox->pack_start(*selector, true, true, 0); + selector->show(); + } + hbox->show(); + return hbox; + +} + +void ParamColor::_onColorChanged() +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setUInt(pref_name(), _color.value()); + + if (_changeSignal) + _changeSignal->emit(); +} + +void ParamColor::_onColorButtonChanged() +{ + Gdk::RGBA rgba = _color_button->get_rgba(); + unsigned int value = ((rgba.get_red_u() >> 8) << 24) + + ((rgba.get_green_u() >> 8) << 16) + + ((rgba.get_blue_u() >> 8) << 8) + + ((rgba.get_alpha_u() >> 8) << 0); + set(value); +} + +std::string ParamColor::value_to_string() const +{ + char value_string[16]; + snprintf(value_string, 16, "%u", _color.value()); + return value_string; +} + +}; /* namespace Extension */ +}; /* namespace Inkscape */ diff --git a/src/extension/param/color.h b/src/extension/prefdialog/parameter-color.h index c2d3c2ccb..4fef4b66b 100644 --- a/src/extension/param/color.h +++ b/src/extension/prefdialog/parameter-color.h @@ -12,10 +12,9 @@ #include "parameter.h" #include "ui/selected-color.h" -class SPDocument; - namespace Gtk { class Widget; +class ColorButton; } namespace Inkscape { @@ -25,36 +24,40 @@ class Node; namespace Extension { -class ParamColor : public Parameter { -private: - void _onColorChanged(); - - Inkscape::UI::SelectedColor _color; - sigc::connection _color_changed; +class ParamColor : public InxParameter { public: - ParamColor(const gchar * name, - const gchar * text, - const gchar * description, - bool hidden, - int indent, - Inkscape::Extension::Extension * ext, - Inkscape::XML::Node * xml); + enum AppearanceMode { + DEFAULT, COLOR_BUTTON + }; + + ParamColor(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext); ~ParamColor() override; /** Returns \c _value, with a \i const to protect it. */ - guint32 get( SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/ ) const { return _color.value(); } + unsigned int get() const { return _color.value(); } - guint32 set (guint32 in, SPDocument * doc, Inkscape::XML::Node * node); + unsigned int set(unsigned int in); - Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) override; + Gtk::Widget *get_widget(sigc::signal<void> *changeSignal) override; - // Explicitly call superclass version to avoid method being hidden. - void string(std::list <std::string> &list) const override { return Parameter::string(list); } + std::string value_to_string() const override; - void string (std::string &string) const override; + sigc::signal<void> *_changeSignal; + +private: + void _onColorChanged(); + void _onColorButtonChanged(); + + /** Internal value of this parameter */ + Inkscape::UI::SelectedColor _color; + + sigc::connection _color_changed; + sigc::connection _color_released; - sigc::signal<void> * _changeSignal; + Gtk::ColorButton *_color_button; + /** appearance mode **/ + AppearanceMode _mode = DEFAULT; }; // class ParamColor } // namespace Extension diff --git a/src/extension/prefdialog/parameter-float.cpp b/src/extension/prefdialog/parameter-float.cpp new file mode 100644 index 000000000..f6abd5c63 --- /dev/null +++ b/src/extension/prefdialog/parameter-float.cpp @@ -0,0 +1,193 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2005-2007 Authors: + * Ted Gould <ted@gould.cx> + * Johan Engelen <johan@shouraizou.nl> * + * Jon A. Cruz <jon@joncruz.org> + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#include "parameter-float.h" + +#include <gtkmm/adjustment.h> +#include <gtkmm/box.h> + +#include "preferences.h" + +#include "extension/extension.h" + +#include "ui/widget/spin-scale.h" +#include "ui/widget/spinbutton.h" + +#include "xml/node.h" + + +namespace Inkscape { +namespace Extension { + +ParamFloat::ParamFloat(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext) + : InxParameter(xml, ext) +{ + // get value + if (xml->firstChild()) { + const char *value = xml->firstChild()->content(); + if (value) { + _value = g_ascii_strtod(value, nullptr); + } + } + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + _value = prefs->getDouble(pref_name(), _value); + + // parse and apply limits + const char *min = xml->attribute("min"); + if (min) { + _min = g_ascii_strtod(min, nullptr); + } + + const char *max = xml->attribute("max"); + if (max) { + _max = g_ascii_strtod(max, nullptr); + } + + if (_value < _min) { + _value = _min; + } + + if (_value > _max) { + _value = _max; + } + + // parse precision + const char *precision = xml->attribute("precision"); + if (precision != nullptr) { + _precision = strtol(precision, nullptr, 0); + } + + + // parse appearance + if (_appearance) { + if (!strcmp(_appearance, "full")) { + _mode = FULL; + } else { + g_warning("Invalid value ('%s') for appearance of parameter '%s' in extension '%s'", + _appearance, _name, _extension->get_id()); + } + } +} + +/** + * A function to set the \c _value. + * + * This function sets the internal value, but it also sets the value + * in the preferences structure. To put it in the right place \c pref_name() is used. + * + * @param in The value to set to. + */ +float ParamFloat::set(float in) +{ + _value = in; + if (_value > _max) { + _value = _max; + } + if (_value < _min) { + _value = _min; + } + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setDouble(pref_name(), _value); + + return _value; +} + +std::string ParamFloat::value_to_string() const +{ + char value_string[G_ASCII_DTOSTR_BUF_SIZE]; + // TODO: Some strange rounding is going on here, resulting in parameter values quite different + // from the original string value. Needs some investigation to make it less bad. + // See also https://gitlab.gnome.org/GNOME/glib/issues/964 + g_ascii_dtostr(value_string, G_ASCII_DTOSTR_BUF_SIZE, _value); + return value_string; +} + +/** A class to make an adjustment that uses Extension params. */ +class ParamFloatAdjustment : public Gtk::Adjustment { + /** The parameter to adjust. */ + ParamFloat *_pref; + sigc::signal<void> *_changeSignal; +public: + /** Make the adjustment using an extension and the string + describing the parameter. */ + ParamFloatAdjustment(ParamFloat *param, sigc::signal<void> *changeSignal) + : Gtk::Adjustment(0.0, param->min(), param->max(), 0.1, 1.0, 0) + , _pref(param) + , _changeSignal(changeSignal) { + this->set_value(_pref->get()); + this->signal_value_changed().connect(sigc::mem_fun(this, &ParamFloatAdjustment::val_changed)); + return; + }; + + void val_changed (); +}; /* class ParamFloatAdjustment */ + +/** + * A function to respond to the value_changed signal from the adjustment. + * + * This function just grabs the value from the adjustment and writes + * it to the parameter. Very simple, but yet beautiful. + */ +void ParamFloatAdjustment::val_changed() +{ + _pref->set(this->get_value()); + if (_changeSignal != nullptr) { + _changeSignal->emit(); + } + return; +} + +/** + * Creates a Float Adjustment for a float parameter. + * + * Builds a hbox with a label and a float adjustment in it. + */ +Gtk::Widget *ParamFloat::get_widget(sigc::signal<void> *changeSignal) +{ + if (_hidden) { + return nullptr; + } + + Gtk::HBox *hbox = Gtk::manage(new Gtk::HBox(false, GUI_PARAM_WIDGETS_SPACING)); + + auto pfa = new ParamFloatAdjustment(this, changeSignal); + Glib::RefPtr<Gtk::Adjustment> fadjust(pfa); + + if (_mode == FULL) { + + Glib::ustring text; + if (_text != nullptr) + text = _text; + UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(text, fadjust, _precision); + scale->set_size_request(400, -1); + scale->show(); + hbox->pack_start(*scale, true, true); + + } + else if (_mode == DEFAULT) { + + Gtk::Label *label = Gtk::manage(new Gtk::Label(_text, Gtk::ALIGN_START)); + label->show(); + hbox->pack_start(*label, true, true); + + auto spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(fadjust, 0.1, _precision)); + spin->show(); + hbox->pack_start(*spin, false, false); + } + + hbox->show(); + + return dynamic_cast<Gtk::Widget *>(hbox); +} + + +} /* namespace Extension */ +} /* namespace Inkscape */ diff --git a/src/extension/param/float.h b/src/extension/prefdialog/parameter-float.h index c1d0f0f79..4c28cb54e 100644 --- a/src/extension/param/float.h +++ b/src/extension/prefdialog/parameter-float.h @@ -12,8 +12,6 @@ #include "parameter.h" -class SPDocument; - namespace Gtk { class Widget; } @@ -25,24 +23,18 @@ class Node; namespace Extension { -class ParamFloat : public Parameter { +class ParamFloat : public InxParameter { public: enum AppearanceMode { - FULL, MINIMAL + DEFAULT, FULL }; - ParamFloat(const gchar * name, - const gchar * text, - const gchar * description, - bool hidden, - int indent, - Inkscape::Extension::Extension * ext, - Inkscape::XML::Node * xml, - AppearanceMode mode); + + ParamFloat(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext); /** Returns \c _value. */ - float get(const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) const { return _value; } + float get() const { return _value; } - float set (float in, SPDocument * doc, Inkscape::XML::Node * node); + float set(float in); float max () { return _max; } @@ -50,20 +42,24 @@ public: float precision () { return _precision; } - Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) override; - - // Explicitly call superclass version to avoid method being hidden. - void string(std::list <std::string> &list) const override { return Parameter::string(list); } + Gtk::Widget *get_widget(sigc::signal<void> *changeSignal) override; - void string(std::string &string) const override; + std::string value_to_string() const override; private: /** Internal value. */ - float _value; - AppearanceMode _mode; - float _min; - float _max; - int _precision; + float _value = 0; + + /** limits */ + // TODO: do these defaults make sense or should we be unbounded by default? + float _min = 0; + float _max = 10; + + /** numeric precision (i.e. number of digits) */ + int _precision = 1; + + /** appearance mode **/ + AppearanceMode _mode = DEFAULT; }; } /* namespace Extension */ diff --git a/src/extension/prefdialog/parameter-int.cpp b/src/extension/prefdialog/parameter-int.cpp new file mode 100644 index 000000000..e18e1bddc --- /dev/null +++ b/src/extension/prefdialog/parameter-int.cpp @@ -0,0 +1,189 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2005-2007 Authors: + * Ted Gould <ted@gould.cx> + * Johan Engelen <johan@shouraizou.nl> * + * Jon A. Cruz <jon@joncruz.org> + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#include "parameter-int.h" + +#include <gtkmm/adjustment.h> +#include <gtkmm/box.h> + +#include "preferences.h" + +#include "extension/extension.h" + +#include "ui/widget/spinbutton.h" +#include "ui/widget/spin-scale.h" + +#include "xml/node.h" + + +namespace Inkscape { +namespace Extension { + + +ParamInt::ParamInt(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext) + : InxParameter(xml, ext) +{ + // get value + if (xml->firstChild()) { + const char *value = xml->firstChild()->content(); + if (value) { + _value = strtol(value, nullptr, 0); + } + } + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + _value = prefs->getInt(pref_name(), _value); + + // parse and apply limits + const char *min = xml->attribute("min"); + if (min) { + _min = strtol(min, nullptr, 0); + } + + const char *max = xml->attribute("max"); + if (max) { + _max = strtol(max, nullptr, 0); + } + + if (_value < _min) { + _value = _min; + } + + if (_value > _max) { + _value = _max; + } + + // parse appearance + if (_appearance) { + if (!strcmp(_appearance, "full")) { + _mode = FULL; + } else { + g_warning("Invalid value ('%s') for appearance of parameter '%s' in extension '%s'", + _appearance, _name, _extension->get_id()); + } + } +} + +/** + * A function to set the \c _value. + * This function sets the internal value, but it also sets the value + * in the preferences structure. To put it in the right place \c pref_name() is used. + * + * @param in The value to set to. + */ +int ParamInt::set(int in) +{ + _value = in; + if (_value > _max) { + _value = _max; + } + if (_value < _min) { + _value = _min; + } + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setInt(pref_name(), _value); + + return _value; +} + +/** A class to make an adjustment that uses Extension params. */ +class ParamIntAdjustment : public Gtk::Adjustment { + /** The parameter to adjust. */ + ParamInt *_pref; + sigc::signal<void> *_changeSignal; +public: + /** Make the adjustment using an extension and the string describing the parameter. */ + ParamIntAdjustment(ParamInt *param, sigc::signal<void> *changeSignal) + : Gtk::Adjustment(0.0, param->min(), param->max(), 1.0, 10.0, 0) + , _pref(param) + , _changeSignal(changeSignal) + { + this->set_value(_pref->get()); + this->signal_value_changed().connect(sigc::mem_fun(this, &ParamIntAdjustment::val_changed)); + }; + + void val_changed (); +}; /* class ParamIntAdjustment */ + +/** + * A function to respond to the value_changed signal from the adjustment. + * + * This function just grabs the value from the adjustment and writes + * it to the parameter. Very simple, but yet beautiful. + */ +void ParamIntAdjustment::val_changed() +{ + _pref->set((int)this->get_value()); + if (_changeSignal != nullptr) { + _changeSignal->emit(); + } +} + +/** + * Creates a Int Adjustment for a int parameter. + * + * Builds a hbox with a label and a int adjustment in it. + */ +Gtk::Widget * +ParamInt::get_widget(sigc::signal<void> *changeSignal) +{ + if (_hidden) { + return nullptr; + } + + Gtk::HBox *hbox = Gtk::manage(new Gtk::HBox(false, GUI_PARAM_WIDGETS_SPACING)); + + auto pia = new ParamIntAdjustment(this, changeSignal); + Glib::RefPtr<Gtk::Adjustment> fadjust(pia); + + if (_mode == FULL) { + + Glib::ustring text; + if (_text != nullptr) + text = _text; + UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(text, fadjust, 0); + scale->set_size_request(400, -1); + scale->show(); + hbox->pack_start(*scale, true, true); + } else if (_mode == DEFAULT) { + Gtk::Label *label = Gtk::manage(new Gtk::Label(_text, Gtk::ALIGN_START)); + label->show(); + hbox->pack_start(*label, true, true); + + auto spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(fadjust, 1.0, 0)); + spin->show(); + hbox->pack_start(*spin, false, false); + } + + hbox->show(); + + return dynamic_cast<Gtk::Widget *>(hbox); +} + +std::string ParamInt::value_to_string() const +{ + char value_string[32]; + snprintf(value_string, 32, "%d", _value); + return value_string; +} + +} // namespace Extension +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/extension/param/int.h b/src/extension/prefdialog/parameter-int.h index fac481267..da43eb75f 100644 --- a/src/extension/param/int.h +++ b/src/extension/prefdialog/parameter-int.h @@ -12,8 +12,6 @@ #include "parameter.h" -class SPDocument; - namespace Gtk { class Widget; } @@ -25,42 +23,38 @@ class Node; namespace Extension { -class ParamInt : public Parameter { +class ParamInt : public InxParameter { public: enum AppearanceMode { - FULL, MINIMAL + DEFAULT, FULL }; - ParamInt(const gchar * name, - const gchar * text, - const gchar * description, - bool hidden, - int indent, - Inkscape::Extension::Extension * ext, - Inkscape::XML::Node * xml, - AppearanceMode mode); + + ParamInt(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext); /** Returns \c _value. */ - int get(const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) const { return _value; } + int get() const { return _value; } - int set (int in, SPDocument * doc, Inkscape::XML::Node * node); + int set(int in); int max () { return _max; } int min () { return _min; } - Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) override; - - // Explicitly call superclass version to avoid method being hidden. - void string(std::list <std::string> &list) const override { return Parameter::string(list); } + Gtk::Widget *get_widget(sigc::signal<void> *changeSignal) override; - void string(std::string &string) const override; + std::string value_to_string() const override; private: /** Internal value. */ - int _value; - AppearanceMode _mode; - int _min; - int _max; + int _value = 0; + + /** limits */ + // TODO: do these defaults make sense or should we be unbounded by default? + int _min = 0; + int _max = 10; + + /** appearance mode **/ + AppearanceMode _mode = DEFAULT; }; } /* namespace Extension */ diff --git a/src/extension/prefdialog/parameter-notebook.cpp b/src/extension/prefdialog/parameter-notebook.cpp new file mode 100644 index 000000000..a90935ca1 --- /dev/null +++ b/src/extension/prefdialog/parameter-notebook.cpp @@ -0,0 +1,272 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** \file + * Notebook and NotebookPage parameters for extensions. + */ + +/* + * Authors: + * Johan Engelen <johan@shouraizou.nl> + * Jon A. Cruz <jon@joncruz.org> + * + * Copyright (C) 2006 Author + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#include "parameter-notebook.h" + +#include <gtkmm/box.h> +#include <gtkmm/notebook.h> + +#include "preferences.h" + +#include "extension/extension.h" + +#include "xml/node.h" + +namespace Inkscape { +namespace Extension { + + +ParamNotebook::ParamNotebookPage::ParamNotebookPage(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext) + : InxParameter(xml, ext) +{ + // Read XML tree of page and parse parameters + if (xml) { + Inkscape::XML::Node *child_repr = xml->firstChild(); + while (child_repr) { + const char *chname = child_repr->name(); + if (!strncmp(chname, INKSCAPE_EXTENSION_NS_NC, strlen(INKSCAPE_EXTENSION_NS_NC))) { + chname += strlen(INKSCAPE_EXTENSION_NS); + } + if (chname[0] == '_') { // allow leading underscore in tag names for backwards-compatibility + chname++; + } + + if (InxWidget::is_valid_widget_name(chname)) { + InxWidget *widget = InxWidget::make(child_repr, _extension); + if (widget) { + _children.push_back(widget); + } + } else if (child_repr->type() == XML::ELEMENT_NODE) { + g_warning("Invalid child element ('%s') in notebook page in extension '%s'.", + chname, _extension->get_id()); + } else if (child_repr->type() != XML::COMMENT_NODE){ + g_warning("Invalid child element found in notebook page in extension '%s'.", _extension->get_id()); + } + + child_repr = child_repr->next(); + } + } +} + + +/** + * Creates a notebookpage widget for a notebook. + * + * Builds a notebook page (a vbox) and puts parameters on it. + */ +Gtk::Widget *ParamNotebook::ParamNotebookPage::get_widget(sigc::signal<void> *changeSignal) +{ + if (_hidden) { + return nullptr; + } + + Gtk::VBox * vbox = Gtk::manage(new Gtk::VBox); + vbox->set_border_width(GUI_BOX_MARGIN); + vbox->set_spacing(GUI_BOX_SPACING); + + // add parameters onto page (if any) + for (auto child : _children) { + Gtk::Widget *child_widget = child->get_widget(changeSignal); + if (child_widget) { + int indent = child->get_indent(); + child_widget->set_margin_start(indent *GUI_INDENTATION); + vbox->pack_start(*child_widget, false, true, 0); // fill=true does not have an effect here, but allows the + // child to choose to expand by setting hexpand/vexpand + + const char *tooltip = child->get_tooltip(); + if (tooltip) { + child_widget->set_tooltip_text(tooltip); + } + } + } + + vbox->show(); + + return dynamic_cast<Gtk::Widget *>(vbox); +} + +/** End ParamNotebookPage **/ + + + +/** ParamNotebook **/ + +ParamNotebook::ParamNotebook(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext) + : InxParameter(xml, ext) +{ + // Read XML tree to add pages (allow _page for backwards compatibility) + if (xml) { + Inkscape::XML::Node *child_repr = xml->firstChild(); + while (child_repr) { + const char *chname = child_repr->name(); + if (chname && (!strcmp(chname, INKSCAPE_EXTENSION_NS "page") || + !strcmp(chname, INKSCAPE_EXTENSION_NS "_page") )) { + ParamNotebookPage *page; + page = new ParamNotebookPage(child_repr, ext); + + if (page) { + _children.push_back(page); + } + } else if (child_repr->type() == XML::ELEMENT_NODE) { + g_warning("Invalid child element ('%s') for parameter '%s' in extension '%s'. Expected 'page'.", + chname, _name, _extension->get_id()); + } else if (child_repr->type() != XML::COMMENT_NODE){ + g_warning("Invalid child element found in parameter '%s' in extension '%s'. Expected 'page'.", + _name, _extension->get_id()); + } + child_repr = child_repr->next(); + } + } + if (_children.empty()) { + g_warning("No (valid) pages for parameter '%s' in extension '%s'", _name, _extension->get_id()); + } + + // get value (initialize with value of first page if pref is empty) + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + _value = prefs->getString(pref_name()); + + if (_value.empty()) { + if (!_children.empty()) { + ParamNotebookPage *first_page = dynamic_cast<ParamNotebookPage *>(_children[0]); + _value = first_page->_name; + } + } +} + + +/** + * A function to set the \c _value. + * + * This function sets the internal value, but it also sets the value + * in the preferences structure. To put it in the right place \c pref_name() is used. + * + * @param in The number of the page to set as new value. + */ +const Glib::ustring& ParamNotebook::set(const int in) +{ + int i = in < _children.size() ? in : _children.size()-1; + ParamNotebookPage *page = dynamic_cast<ParamNotebookPage *>(_children[i]); + + if (page) { + _value = page->_name; + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setString(pref_name(), _value); + } + + return _value; +} + +std::string ParamNotebook::value_to_string() const +{ + return _value; +} + + +/** A special category of Gtk::Notebook to handle notebook parameters. */ +class NotebookWidget : public Gtk::Notebook { +private: + ParamNotebook *_pref; +public: + /** + * Build a notebookpage preference for the given parameter. + * @param pref Where to get the string (pagename) from, and where to put it when it changes. + */ + NotebookWidget(ParamNotebook *pref) + : Gtk::Notebook() + , _pref(pref) + , activated(false) + { + // don't have to set the correct page: this is done in ParamNotebook::get_widget hook function + this->signal_switch_page().connect(sigc::mem_fun(this, &NotebookWidget::changed_page)); + } + + void changed_page(Gtk::Widget *page, guint pagenum); + + bool activated; +}; + +/** + * Respond to the selected page of notebook changing. + * This function responds to the changing by reporting it to + * ParamNotebook. The change is only reported when the notebook + * is actually visible. This to exclude 'fake' changes when the + * notebookpages are added or removed. + */ +void NotebookWidget::changed_page(Gtk::Widget * /*page*/, guint pagenum) +{ + if (get_visible()) { + _pref->set((int)pagenum); + } +} + +/** + * Creates a Notebook widget for a notebook parameter. + * + * Builds a notebook and puts pages in it. + */ +Gtk::Widget *ParamNotebook::get_widget(sigc::signal<void> *changeSignal) +{ + if (_hidden) { + return nullptr; + } + + NotebookWidget *notebook = Gtk::manage(new NotebookWidget(this)); + + // add pages (if any) and switch to previously selected page + int current_page = -1; + int selected_page = -1; + for (auto child : _children) { + ParamNotebookPage *page = dynamic_cast<ParamNotebookPage *>(child); + g_assert(child); // A ParamNotebook has only children of type ParamNotebookPage. + // If we receive a non-page child here something is very wrong! + current_page++; + + Gtk::Widget *page_widget = page->get_widget(changeSignal); + + Glib::ustring page_text = page->_text; + if (page->_translatable != NO) { // translate unless explicitly marked untranslatable + page_text = page->get_translation(page_text.c_str()); + } + + notebook->append_page(*page_widget, page_text); + + if (_value == page->_name) { + selected_page = current_page; + } + } + if (selected_page >= 0) { + notebook->set_current_page(selected_page); + } + + notebook->show(); + + return static_cast<Gtk::Widget *>(notebook); +} + + +} // namespace Extension +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/extension/prefdialog/parameter-notebook.h b/src/extension/prefdialog/parameter-notebook.h new file mode 100644 index 000000000..f5a313b49 --- /dev/null +++ b/src/extension/prefdialog/parameter-notebook.h @@ -0,0 +1,90 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#ifndef INK_EXTENSION_PARAMNOTEBOOK_H_SEEN +#define INK_EXTENSION_PARAMNOTEBOOK_H_SEEN + +/** \file + * Notebook parameter for extensions. + */ + +/* + * Author: + * Johan Engelen <johan@shouraizou.nl> + * Jon A. Cruz <jon@joncruz.org> + * + * Copyright (C) 2006 Author + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#include "parameter.h" + +#include <vector> + +#include <glibmm/ustring.h> + + +namespace Gtk { +class Widget; +} + + +namespace Inkscape { +namespace Extension { + +class Extension; + + +/** A class to represent a notebook parameter of an extension. */ +class ParamNotebook : public InxParameter { +private: + /** Internal value. */ + Glib::ustring _value; + + /** + * A class to represent the pages of a notebook parameter of an extension. + */ + class ParamNotebookPage : public InxParameter { + friend class ParamNotebook; + public: + ParamNotebookPage(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext); + + Gtk::Widget *get_widget(sigc::signal<void> *changeSignal) override; + + // ParamNotebookPage is not a real parameter (it has no value), so make sure it does not return one + std::string value_to_string() const override { return ""; }; + }; /* class ParamNotebookPage */ + + /** A table to store the pages with parameters for this notebook. + * This only gets created if there are pages in this notebook */ + std::vector<ParamNotebookPage*> _pages; + +public: + ParamNotebook(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext); + + Gtk::Widget *get_widget(sigc::signal<void> *changeSignal) override; + + std::string value_to_string() const override; + + const Glib::ustring& get() { return _value; } + const Glib::ustring& set(const int in); +}; /* class ParamNotebook */ + + + + + +} // namespace Extension +} // namespace Inkscape + +#endif /* INK_EXTENSION_PARAMNOTEBOOK_H_SEEN */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/extension/prefdialog/parameter-optiongroup.cpp b/src/extension/prefdialog/parameter-optiongroup.cpp new file mode 100644 index 000000000..e3f655dde --- /dev/null +++ b/src/extension/prefdialog/parameter-optiongroup.cpp @@ -0,0 +1,324 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** \file + *extension parameter for options with multiple predefined value choices + * + * Currently implemented as either Gtk::RadioButton or Gtk::ComboBoxText + */ + +/* + * Author: + * Johan Engelen <johan@shouraizou.nl> + * + * Copyright (C) 2006-2007 Johan Engelen + * Copyright (C) 2008 Jon A. Cruz + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#include "parameter-optiongroup.h" + +#include <gtkmm/box.h> +#include <gtkmm/comboboxtext.h> +#include <gtkmm/radiobutton.h> + +#include "xml/node.h" +#include "extension/extension.h" +#include "preferences.h" + + +namespace Inkscape { +namespace Extension { + +ParamOptionGroup::ParamOptionGroup(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext) + : InxParameter(xml, ext) +{ + // Read valid optiongroup choices from XML tree, i,e. + // - <option> elements + // - <item> elements (for backwards-compatibility with params of type enum) + // - underscored variants of both (for backwards-compatibility) + if (xml) { + Inkscape::XML::Node *child_repr = xml->firstChild(); + while (child_repr) { + const char *chname = child_repr->name(); + if (chname && (!strcmp(chname, INKSCAPE_EXTENSION_NS "option") || + !strcmp(chname, INKSCAPE_EXTENSION_NS "_option") || + !strcmp(chname, INKSCAPE_EXTENSION_NS "item") || + !strcmp(chname, INKSCAPE_EXTENSION_NS "_item")) ) { + child_repr->setAttribute("name", "option"); // TODO: hack to allow options to be parameters + child_repr->setAttribute("gui-text", "option"); // TODO: hack to allow options to be parameters + ParamOptionGroupOption *param = new ParamOptionGroupOption(child_repr, ext, this); + choices.push_back(param); + } else if (child_repr->type() == XML::ELEMENT_NODE) { + g_warning("Invalid child element ('%s') for parameter '%s' in extension '%s'. Expected 'option'.", + chname, _name, _extension->get_id()); + } else if (child_repr->type() != XML::COMMENT_NODE){ + g_warning("Invalid child element found in parameter '%s' in extension '%s'. Expected 'option'.", + _name, _extension->get_id()); + } + child_repr = child_repr->next(); + } + } + if (choices.empty()) { + g_warning("No (valid) choices for parameter '%s' in extension '%s'", _name, _extension->get_id()); + } + + // get value (initialize with value of first choice if pref is empty) + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + _value = prefs->getString(pref_name()); + + if (_value.empty()) { + if (!choices.empty()) { + _value = choices[0]->_value; + } + } + + // parse appearance + // (we support "combo" and "radio"; "minimal" is for backwards-compatibility) + if (_appearance) { + if (!strcmp(_appearance, "combo") || !strcmp(_appearance, "minimal")) { + _mode = COMBOBOX; + } else if (!strcmp(_appearance, "radio")) { + _mode = RADIOBUTTON; + } else { + g_warning("Invalid value ('%s') for appearance of parameter '%s' in extension '%s'", + _appearance, _name, _extension->get_id()); + } + } +} + +ParamOptionGroup::~ParamOptionGroup () +{ + // destroy choice strings + for (auto choice : choices) { + delete choice; + } +} + + +/** + * A function to set the \c _value. + * + * This function sets ONLY the internal value, but it also sets the value + * in the preferences structure. To put it in the right place \c pref_name() is used. + * + * @param in The value to set. + */ +const Glib::ustring& ParamOptionGroup::set(Glib::ustring in) +{ + if (contains(in)) { + _value = in; + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setString(pref_name(), _value.c_str()); + } else { + g_warning("Could not set value ('%s') for parameter '%s' in extension '%s'. Not a valid choice.", + in.c_str(), _name, _extension->get_id()); + } + + return _value; +} + +bool ParamOptionGroup::contains(const Glib::ustring text) const +{ + for (auto choice : choices) { + if (choice->_value == text) { + return true; + } + } + + return false; +} + +std::string ParamOptionGroup::value_to_string() const +{ + return _value; +} + +/** + * Returns the value for the options label parameter + */ +Glib::ustring ParamOptionGroup::value_from_label(const Glib::ustring label) +{ + Glib::ustring value; + + for (auto choice : choices) { + if (choice->_text == label) { + value = choice->_value; + break; + } + } + + return value; +} + + + +/** A special RadioButton class to use in ParamOptionGroup. */ +class RadioWidget : public Gtk::RadioButton { +private: + ParamOptionGroup *_pref; + sigc::signal<void> *_changeSignal; +public: + RadioWidget(Gtk::RadioButtonGroup& group, const Glib::ustring& label, + ParamOptionGroup *pref, sigc::signal<void> *changeSignal) + : Gtk::RadioButton(group, label) + , _pref(pref) + , _changeSignal(changeSignal) + { + add_changesignal(); + }; + + void add_changesignal() { + this->signal_toggled().connect(sigc::mem_fun(this, &RadioWidget::changed)); + }; + + void changed(); +}; + +/** + * Respond to the selected radiobutton changing. + * + * This function responds to the radiobutton selection changing by grabbing the value + * from the text box and putting it in the parameter. + */ +void RadioWidget::changed() +{ + if (this->get_active()) { + Glib::ustring value = _pref->value_from_label(this->get_label()); + _pref->set(value.c_str()); + } + + if (_changeSignal) { + _changeSignal->emit(); + } +} + + +/** A special ComboBoxText class to use in ParamOptionGroup. */ +class ComboWidget : public Gtk::ComboBoxText { +private: + ParamOptionGroup *_pref; + sigc::signal<void> *_changeSignal; + +public: + ComboWidget(ParamOptionGroup *pref, sigc::signal<void> *changeSignal) + : _pref(pref) + , _changeSignal(changeSignal) + { + this->signal_changed().connect(sigc::mem_fun(this, &ComboWidget::changed)); + } + + ~ComboWidget() override = default; + + void changed(); +}; + +void ComboWidget::changed() +{ + if (_pref) { + Glib::ustring value = _pref->value_from_label(get_active_text()); + _pref->set(value.c_str()); + } + + if (_changeSignal) { + _changeSignal->emit(); + } +} + + + +/** + * Creates the widget for the optiongroup parameter. + */ +Gtk::Widget *ParamOptionGroup::get_widget(sigc::signal<void> *changeSignal) +{ + if (_hidden) { + return nullptr; + } + + auto hbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, GUI_PARAM_WIDGETS_SPACING)); + + Gtk::Label *label = Gtk::manage(new Gtk::Label(_text, Gtk::ALIGN_START)); + hbox->pack_start(*label, false, false); + + if (_mode == COMBOBOX) { + ComboWidget *combo = Gtk::manage(new ComboWidget(this, changeSignal)); + + for (auto choice : choices) { + combo->append(choice->_text); + if (choice->_value == _value) { + combo->set_active_text(choice->_text); + } + } + + if (combo->get_active_row_number() == -1) { + combo->set_active(0); + } + + hbox->pack_end(*combo, false, false); + } else if (_mode == RADIOBUTTON) { + label->set_valign(Gtk::ALIGN_START); // align label and first radio + + Gtk::Box *radios = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL, 0)); + Gtk::RadioButtonGroup group; + + for (auto choice : choices) { + RadioWidget *radio = Gtk::manage(new RadioWidget(group, choice->_text, this, changeSignal)); + radios->pack_start(*radio, true, true); + if (choice->_value == _value) { + radio->set_active(); + } + } + + hbox->pack_end(*radios, false, false); + } + + hbox->show_all(); + return static_cast<Gtk::Widget *>(hbox); +} + + +ParamOptionGroup::ParamOptionGroupOption::ParamOptionGroupOption(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext, + const Inkscape::Extension::ParamOptionGroup *parent) + : InxParameter(xml, ext) +{ + // get content (=label) of option and translate it + const char *text = nullptr; + if (xml->firstChild()) { + text = xml->firstChild()->content(); + } + if (text) { + if (_translatable != NO) { // translate unless explicitly marked untranslatable + _text = get_translation(text); + } else { + _text = text; + } + } else { + g_warning("Missing content in option of parameter '%s' in extension '%s'.", + parent->_name, _extension->get_id()); + } + + // get string value of option + const char *value = xml->attribute("value"); + if (value) { + _value = value; + } else { + g_warning("Missing value for option '%s' of parameter '%s' in extension '%s'.", + _text.c_str(), parent->_name, _extension->get_id()); + } +} + + + +} /* namespace Extension */ +} /* namespace Inkscape */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/extension/prefdialog/parameter-optiongroup.h b/src/extension/prefdialog/parameter-optiongroup.h new file mode 100644 index 000000000..533b13170 --- /dev/null +++ b/src/extension/prefdialog/parameter-optiongroup.h @@ -0,0 +1,103 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#ifndef INK_EXTENSION_PARAMOPTIONGROUP_H_SEEN +#define INK_EXTENSION_PARAMOPTIONGROUP_H_SEEN + +/** \file + * extension parameter for options with multiple predefined value choices + * + * Currently implemented as either Gtk::RadioButton or Gtk::ComboBoxText + */ + +/* + * Authors: + * Johan Engelen <johan@shouraizou.nl> + * Jon A. Cruz <jon@joncruz.org> + * + * Copyright (C) 2006-2007 Johan Engelen + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#include "parameter.h" + +#include <vector> + +#include <glibmm/ustring.h> + +namespace Gtk { +class Widget; +} + +namespace Inkscape { +namespace Extension { + +class Extension; + + + +// \brief A class to represent an optiongroup (option with multiple predefined value choices) parameter of an extension +class ParamOptionGroup : public InxParameter { +public: + enum AppearanceMode { + RADIOBUTTON, COMBOBOX + }; + + ParamOptionGroup(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext); + ~ParamOptionGroup() override; + + Gtk::Widget *get_widget(sigc::signal<void> *changeSignal) override; + + std::string value_to_string() const override; + + Glib::ustring value_from_label(const Glib::ustring label); + + const Glib::ustring& get() const { return _value; } + + const Glib::ustring& set(const Glib::ustring in); + + /** + * @returns true if text is a valid choice for this option group + * @param text string value to check (this is an actual option value, not the user-visible option name!) + */ + bool contains(const Glib::ustring text) const; + +private: + /** \brief Internal value. */ + Glib::ustring _value; + + /** appearance mode **/ + AppearanceMode _mode = RADIOBUTTON; + + /* For internal use only. */ + class ParamOptionGroupOption : public InxParameter { + friend class ParamOptionGroup; + public: + ParamOptionGroupOption(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext, + const Inkscape::Extension::ParamOptionGroup *parent); + private: + Glib::ustring _value; + Glib::ustring _text; + }; + + std::vector<ParamOptionGroupOption *> choices; /**< List of available options for the option group */ +}; /* class ParamOptionGroup */ + + + + + +} /* namespace Extension */ +} /* namespace Inkscape */ + +#endif /*INK_EXTENSION_PARAMOPTIONGROUP_H_SEEN */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/extension/prefdialog/parameter-path.cpp b/src/extension/prefdialog/parameter-path.cpp new file mode 100644 index 000000000..76774eb46 --- /dev/null +++ b/src/extension/prefdialog/parameter-path.cpp @@ -0,0 +1,282 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * Path parameter for extensions + *//* + * Authors: + * Patrick Storz <eduard.braun2@gmx.de> + * + * Copyright (C) 2019 Authors + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#include "parameter-path.h" + +#include <boost/algorithm/string/case_conv.hpp> +#include <boost/algorithm/string/join.hpp> + +#include <glibmm/i18n.h> +#include <glibmm/fileutils.h> +#include <glibmm/miscutils.h> +#include <glibmm/regex.h> + +#include <gtkmm/box.h> +#include <gtkmm/button.h> +#include <gtkmm/dialog.h> +#include <gtkmm/entry.h> + +#include "include/gtkmm_version.h" +#if GTKMM_CHECK_VERSION(3,24,0) // unfortunately GtkFileChooserNative (since gtk 3.20) was not wrapped until gtkmm 3.24 +# include <gtkmm/filechoosernative.h> +#else +# include <gtkmm/filechooserdialog.h> +#endif + +#include "xml/node.h" +#include "extension/extension.h" +#include "preferences.h" + +namespace Inkscape { +namespace Extension { + +ParamPath::ParamPath(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext) + : InxParameter(xml, ext) +{ + // get value + const char *value = nullptr; + if (xml->firstChild()) { + value = xml->firstChild()->content(); + } + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + _value = prefs->getString(pref_name()); + + if (_value.empty() && value) { + _value = value; + } + + // parse selection mode + const char *mode = xml->attribute("mode"); + if (mode) { + if (!strcmp(mode, "file")) { + // this is the default + } else if (!strcmp(mode, "files")) { + _select_multiple = true; + } else if (!strcmp(mode, "folder")) { + _mode = FOLDER; + } else if (!strcmp(mode, "folders")) { + _mode = FOLDER; + _select_multiple = true; + } else if (!strcmp(mode, "file_new")) { + _mode = FILE_NEW; + } else if (!strcmp(mode, "folder_new")) { + _mode = FOLDER_NEW; + } else { + g_warning("Invalid value ('%s') for mode of parameter '%s' in extension '%s'", + mode, _name, _extension->get_id()); + } + } + + // parse filetypes + const char *filetypes = xml->attribute("filetypes"); + if (filetypes) { + _filetypes = Glib::Regex::split_simple("," , filetypes); + } +} + +/** + * A function to set the \c _value. + * + * This function sets the internal value, but it also sets the value + * in the preferences structure. To put it in the right place \c pref_name() is used. + * + * @param in The value to set to. + */ +const std::string& ParamPath::set(const std::string in) +{ + _value = in; + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setString(pref_name(), _value); + + return _value; +} + +std::string ParamPath::value_to_string() const +{ + if (!Glib::path_is_absolute(_value)) { + return Glib::build_filename(_extension->get_base_directory(), _value); + } else { + return _value; + } +} + + +/** A special type of Gtk::Entry to handle path parameters. */ +class ParamPathEntry : public Gtk::Entry { +private: + ParamPath *_pref; + sigc::signal<void> *_changeSignal; +public: + /** + * Build a string preference for the given parameter. + * @param pref Where to get the string from, and where to put it + * when it changes. + */ + ParamPathEntry(ParamPath *pref, sigc::signal<void> *changeSignal) + : Gtk::Entry() + , _pref(pref) + , _changeSignal(changeSignal) + { + this->set_text(_pref->get()); + this->signal_changed().connect(sigc::mem_fun(this, &ParamPathEntry::changed_text)); + }; + void changed_text(); +}; + + +/** + * Respond to the text box changing. + * + * This function responds to the box changing by grabbing the value + * from the text box and putting it in the parameter. + */ +void ParamPathEntry::changed_text() +{ + std::string data = this->get_text(); + _pref->set(data.c_str()); + if (_changeSignal != nullptr) { + _changeSignal->emit(); + } +} + +/** + * Creates a text box for the string parameter. + * + * Builds a hbox with a label and a text box in it. + */ +Gtk::Widget *ParamPath::get_widget(sigc::signal<void> *changeSignal) +{ + if (_hidden) { + return nullptr; + } + + Gtk::HBox *hbox = Gtk::manage(new Gtk::HBox(false, GUI_PARAM_WIDGETS_SPACING)); + Gtk::Label *label = Gtk::manage(new Gtk::Label(_text, Gtk::ALIGN_START)); + label->show(); + hbox->pack_start(*label, false, false); + + ParamPathEntry *textbox = new ParamPathEntry(this, changeSignal); + textbox->show(); + hbox->pack_start(*textbox, true, true); + _entry = textbox; + + Gtk::Button *button = Gtk::manage(new Gtk::Button("…")); + button->show(); + hbox->pack_end(*button, false, false); + button->signal_clicked().connect(sigc::mem_fun(*this, &ParamPath::on_button_clicked)); + + hbox->show(); + + return dynamic_cast<Gtk::Widget *>(hbox); +} + +/** + * Create and show the file chooser dialog when the "…" button is clicked + * Then set the value of the ParamPathEntry holding the current value accordingly + */ +void ParamPath::on_button_clicked() +{ + // set-up action and dialog title according to 'mode' + Gtk::FileChooserAction action; + std::string dialog_title; + if (_mode == FILE) { + // pick the "save" variants here - otherwise the dialog will only accept existing files + action = Gtk::FILE_CHOOSER_ACTION_OPEN; + if (_select_multiple) { + dialog_title = _("Select existing files"); + } else { + dialog_title = _("Select existing file"); + } + } else if (_mode == FOLDER) { + // pick the "create" variant here - otherwise the dialog will only accept existing folders + action = Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER; + if (_select_multiple) { + dialog_title = _("Select existing folders"); + } else { + dialog_title = _("Select existing folder"); + } + } else if (_mode == FILE_NEW) { + action = Gtk::FILE_CHOOSER_ACTION_SAVE; + dialog_title = _("Choose file name"); + } else if (_mode == FOLDER_NEW) { + action = Gtk::FILE_CHOOSER_ACTION_CREATE_FOLDER; + dialog_title = _("Choose folder name"); + } else { + g_assert_not_reached(); + } + + // create file chooser dialog +#if GTKMM_CHECK_VERSION(3,24,0) // unfortunately GtkFileChooserNative (since gtk 3.20) was not wrapped until gtkmm 3.24 + Glib::RefPtr<Gtk::FileChooserNative> file_chooser = + Gtk::FileChooserNative::create(dialog_title + "…", action, _("Select")); +#else + Gtk::FileChooserDialog file_chooser_instance(dialog_title + "…", action); + Gtk::FileChooserDialog *file_chooser = &file_chooser_instance; + file_chooser->add_button(_("Select"), Gtk::RESPONSE_ACCEPT); + file_chooser->add_button(_("Cancel"), Gtk::RESPONSE_CANCEL); +#endif + file_chooser->set_select_multiple(_select_multiple); + file_chooser->set_do_overwrite_confirmation(true); + file_chooser->set_create_folders(true); + + // set FileFilter according to 'filetype' attribute + if (!_filetypes.empty() && _mode != FOLDER && _mode != FOLDER_NEW) { + Glib::RefPtr<Gtk::FileFilter> file_filter = Gtk::FileFilter::create(); + + for (auto filetype : _filetypes) { + file_filter->add_pattern(Glib::ustring::compose("*.%1", filetype)); + } + + std::string filter_name = boost::algorithm::join(_filetypes, "+"); + boost::algorithm::to_upper(filter_name); + file_filter->set_name(filter_name); + + file_chooser->add_filter(file_filter); + } + + // set current file/folder suitable for current value + // (use basepath of first filename; relative paths are considered relative to .inx file's location) + if (!_value.empty()) { + std::string first_filename = _value.substr(0, _value.find("|")); + + if (!Glib::path_is_absolute(first_filename)) { + first_filename = Glib::build_filename(_extension->get_base_directory(), first_filename); + } + + std::string dirname = Glib::path_get_dirname(first_filename); + if (Glib::file_test(dirname, Glib::FILE_TEST_IS_DIR)) { + file_chooser->set_current_folder(dirname); + } + + if(_mode == FILE_NEW || _mode == FOLDER_NEW) { + file_chooser->set_current_name(Glib::path_get_basename(first_filename)); + } else { + if (Glib::file_test(first_filename, Glib::FILE_TEST_EXISTS)) { + // TODO: This does not seem to work (at least on Windows) + // file_chooser->set_filename(first_filename); + } + } + } + + // show dialog and parse result + int res = file_chooser->run(); + if (res == Gtk::ResponseType::RESPONSE_ACCEPT) { + std::vector<std::string> filenames = file_chooser->get_filenames(); + std::string filenames_joined = boost::algorithm::join(filenames, "|"); + _entry->set_text(filenames_joined); // let the ParamPathEntry handle the rest (including setting the preference) + } +} + +} /* namespace Extension */ +} /* namespace Inkscape */ diff --git a/src/extension/prefdialog/parameter-path.h b/src/extension/prefdialog/parameter-path.h new file mode 100644 index 000000000..2de231190 --- /dev/null +++ b/src/extension/prefdialog/parameter-path.h @@ -0,0 +1,75 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * Path parameter for extensions + *//* + * Authors: + * Patrick Storz <eduard.braun2@gmx.de> + * + * Copyright (C) 2019 Authors + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#ifndef INK_EXTENSION_PARAM_PATH_H_SEEN +#define INK_EXTENSION_PARAM_PATH_H_SEEN + +#include "parameter.h" + + +namespace Inkscape { +namespace Extension { + +class ParamPathEntry; + +class ParamPath : public InxParameter { +public: + ParamPath(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext); + + /** \brief Returns \c _value, with a \i const to protect it. */ + const std::string& get() const { return _value; } + const std::string& set(const std::string in); + + Gtk::Widget *get_widget(sigc::signal<void> *changeSignal) override; + + std::string value_to_string() const override; + +private: + enum Mode { + FILE, FOLDER, FILE_NEW, FOLDER_NEW + }; + + /** \brief Internal value. */ + std::string _value; + + /** selection mode for the file chooser: files or folders? */ + Mode _mode = FILE; + + /** selection mode for the file chooser: multiple items? */ + bool _select_multiple = false; + + /** filetypes that should be selectable in file chooser */ + std::vector<std::string> _filetypes; + + /** pointer to the parameters text entry + * keep this around, so we can update the value accordingly in \a on_button_clicked() */ + ParamPathEntry *_entry; + + void on_button_clicked(); +}; + + +} // namespace Extension +} // namespace Inkscape + +#endif /* INK_EXTENSION_PARAM_PATH_H_SEEN */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/extension/prefdialog/parameter-string.cpp b/src/extension/prefdialog/parameter-string.cpp new file mode 100644 index 000000000..6cf57c20e --- /dev/null +++ b/src/extension/prefdialog/parameter-string.cpp @@ -0,0 +1,228 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2005-2007 Authors: + * Ted Gould <ted@gould.cx> + * Johan Engelen <johan@shouraizou.nl> * + * Jon A. Cruz <jon@joncruz.org> + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#include "parameter-string.h" + +#include <gtkmm/box.h> +#include <gtkmm/entry.h> +#include <gtkmm/scrolledwindow.h> +#include <gtkmm/textview.h> +#include <glibmm/regex.h> + +#include "xml/node.h" +#include "extension/extension.h" +#include "preferences.h" + +namespace Inkscape { +namespace Extension { + +ParamString::ParamString(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext) + : InxParameter(xml, ext) +{ + // get value + const char *value = nullptr; + if (xml->firstChild()) { + value = xml->firstChild()->content(); + } + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + _value = prefs->getString(pref_name()); + + if (_value.empty() && value) { + _value = value; + } + + // translate value + if (!_value.empty()) { + if (_translatable == YES) { // translate only if explicitly marked translatable + _value = get_translation(_value.c_str()); + } + } + + // max-length + const char *max_length = xml->attribute("max-length"); + if (!max_length) { + max_length = xml->attribute("max_length"); // backwards-compatibility with old name (underscore) + } + if (max_length) { + _max_length = strtoul(max_length, nullptr, 0); + } + + // parse appearance + if (_appearance) { + if (!strcmp(_appearance, "multiline")) { + _mode = MULTILINE; + } else { + g_warning("Invalid value ('%s') for appearance of parameter '%s' in extension '%s'", + _appearance, _name, _extension->get_id()); + } + } +} + +/** + * A function to set the \c _value. + * + * This function sets the internal value, but it also sets the value + * in the preferences structure. To put it in the right place \c pref_name() is used. + * + * To copy the data into _value the old memory must be free'd first. + * It is important to note that \c g_free handles \c NULL just fine. Then + * the passed in value is duplicated using \c g_strdup(). + * + * @param in The value to set to. + */ +const Glib::ustring& ParamString::set(const Glib::ustring in) +{ + _value = in; + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setString(pref_name(), _value); + + return _value; +} + +std::string ParamString::value_to_string() const +{ + return _value; +} + + + +/** A special type of Gtk::Entry to handle string parameters. */ +class ParamStringEntry : public Gtk::Entry { +private: + ParamString *_pref; + sigc::signal<void> *_changeSignal; +public: + /** + * Build a string preference for the given parameter. + * @param pref Where to get the string from, and where to put it + * when it changes. + */ + ParamStringEntry(ParamString *pref, sigc::signal<void> *changeSignal) + : Gtk::Entry() + , _pref(pref) + , _changeSignal(changeSignal) + { + this->set_text(_pref->get()); + this->set_max_length(_pref->getMaxLength()); //Set the max length - default zero means no maximum + this->signal_changed().connect(sigc::mem_fun(this, &ParamStringEntry::changed_text)); + }; + void changed_text(); +}; + + +/** + * Respond to the text box changing. + * + * This function responds to the box changing by grabbing the value + * from the text box and putting it in the parameter. + */ +void ParamStringEntry::changed_text() +{ + Glib::ustring data = this->get_text(); + _pref->set(data.c_str()); + if (_changeSignal != nullptr) { + _changeSignal->emit(); + } +} + + + +/** A special type of Gtk::TextView to handle multiline string parameters. */ +class ParamMultilineStringEntry : public Gtk::TextView { +private: + ParamString *_pref; + sigc::signal<void> *_changeSignal; +public: + /** + * Build a string preference for the given parameter. + * @param pref Where to get the string from, and where to put it + * when it changes. + */ + ParamMultilineStringEntry(ParamString *pref, sigc::signal<void> *changeSignal) + : Gtk::TextView() + , _pref(pref) + , _changeSignal(changeSignal) + { + // replace literal '\n' with actual newlines for multiline strings + Glib::ustring value = Glib::Regex::create("\\\\n")->replace_literal(_pref->get(), 0, "\n", (Glib::RegexMatchFlags)0); + + this->get_buffer()->set_text(value); + this->get_buffer()->signal_changed().connect(sigc::mem_fun(this, &ParamMultilineStringEntry::changed_text)); + }; + void changed_text(); +}; + +/** + * Respond to the text box changing. + * + * This function responds to the box changing by grabbing the value + * from the text box and putting it in the parameter. + */ +void ParamMultilineStringEntry::changed_text() +{ + Glib::ustring data = this->get_buffer()->get_text(); + + // always store newlines as literal '\n' + data = Glib::Regex::create("\n")->replace_literal(data, 0, "\\n", (Glib::RegexMatchFlags)0); + + _pref->set(data.c_str()); + if (_changeSignal != nullptr) { + _changeSignal->emit(); + } +} + + + +/** + * Creates a text box for the string parameter. + * + * Builds a hbox with a label and a text box in it. + */ +Gtk::Widget *ParamString::get_widget(sigc::signal<void> *changeSignal) +{ + if (_hidden) { + return nullptr; + } + + Gtk::Box *box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, GUI_PARAM_WIDGETS_SPACING)); + + Gtk::Label *label = Gtk::manage(new Gtk::Label(_text, Gtk::ALIGN_START)); + label->show(); + box->pack_start(*label, false, false); + + if (_mode == MULTILINE) { + box->set_orientation(Gtk::ORIENTATION_VERTICAL); + + Gtk::ScrolledWindow *textarea = new Gtk::ScrolledWindow(); + textarea->set_vexpand(); + textarea->set_shadow_type(Gtk::SHADOW_IN); + + ParamMultilineStringEntry *entry = new ParamMultilineStringEntry(this, changeSignal); + entry->show(); + + textarea->add(*entry); + textarea->show(); + + box->pack_start(*textarea, true, true); + } else { + Gtk::Widget *entry = new ParamStringEntry(this, changeSignal); + entry->show(); + + box->pack_start(*entry, true, true); + } + + box->show(); + + return dynamic_cast<Gtk::Widget *>(box); +} + +} /* namespace Extension */ +} /* namespace Inkscape */ diff --git a/src/extension/prefdialog/parameter-string.h b/src/extension/prefdialog/parameter-string.h new file mode 100644 index 000000000..3af83111d --- /dev/null +++ b/src/extension/prefdialog/parameter-string.h @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#ifndef INK_EXTENSION_PARAMSTRING_H_SEEN +#define INK_EXTENSION_PARAMSTRING_H_SEEN + +/* + * Copyright (C) 2005-2007 Authors: + * Ted Gould <ted@gould.cx> + * Johan Engelen <johan@shouraizou.nl> * + * Jon A. Cruz <jon@joncruz.org> + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#include "parameter.h" + +#include <glibmm/ustring.h> + + +namespace Inkscape { +namespace Extension { + +class ParamString : public InxParameter { +public: + enum AppearanceMode { + DEFAULT, MULTILINE + }; + + ParamString(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext); + + /** \brief Returns \c _value, with a \i const to protect it. */ + const Glib::ustring& get() const { return _value; } + const Glib::ustring& set(const Glib::ustring in); + + Gtk::Widget *get_widget(sigc::signal<void> *changeSignal) override; + + std::string value_to_string() const override; + + void setMaxLength(int maxLength) { _max_length = maxLength; } + int getMaxLength() { return _max_length; } + +private: + /** \brief Internal value. */ + Glib::ustring _value; + + /** appearance mode **/ + AppearanceMode _mode = DEFAULT; + + /** \brief Maximum length of the string in characters (zero meaning unlimited). */ + int _max_length = 0; +}; + + +} // namespace Extension +} // namespace Inkscape + +#endif /* INK_EXTENSION_PARAMSTRING_H_SEEN */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/extension/prefdialog/parameter.cpp b/src/extension/prefdialog/parameter.cpp new file mode 100644 index 000000000..65072f6a8 --- /dev/null +++ b/src/extension/prefdialog/parameter.cpp @@ -0,0 +1,302 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * Parameters for extensions. + */ +/* Author: + * Ted Gould <ted@gould.cx> + * Johan Engelen <johan@shouraizou.nl> + * Jon A. Cruz <jon@joncruz.org> + * + * Copyright (C) 2005-2007 Authors + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#include <cstring> +#include <list> + +#include <glibmm/i18n.h> +#include <sigc++/sigc++.h> + +#include "parameter.h" +#include "parameter-bool.h" +#include "parameter-color.h" +#include "parameter-float.h" +#include "parameter-int.h" +#include "parameter-notebook.h" +#include "parameter-optiongroup.h" +#include "parameter-path.h" +#include "parameter-string.h" +#include "widget.h" +#include "widget-label.h" + +#include "extension/extension.h" + +#include "object/sp-defs.h" + +#include "ui/widget/color-notebook.h" + +#include "xml/node.h" + + +namespace Inkscape { +namespace Extension { + + +// Re-implement ParamDescription for backwards-compatibility, deriving from both, WidgetLabel and InxParameter. +// TODO: Should go away eventually... +class ParamDescription : public virtual WidgetLabel, public virtual InxParameter { +public: + ParamDescription(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext) + : WidgetLabel(xml, ext) + , InxParameter(xml, ext) + {} + + Gtk::Widget *get_widget(sigc::signal<void> *changeSignal) override + { + return this->WidgetLabel::get_widget(changeSignal); + } + + // Well, no, I don't have a value! That's why I should not be an InxParameter! + std::string value_to_string() const override { return ""; } +}; + + + +InxParameter *InxParameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Extension *in_ext) +{ + InxParameter *param = nullptr; + + try { + const char *type = in_repr->attribute("type"); + if (!type) { + // we can't create a parameter without type + g_warning("Parameter without type in extension '%s'.", in_ext->get_id()); + } else if(!strcmp(type, "bool") || !strcmp(type, "boolean")) { // support "boolean" for backwards-compatibility + param = new ParamBool(in_repr, in_ext); + } else if (!strcmp(type, "int")) { + param = new ParamInt(in_repr, in_ext); + } else if (!strcmp(type, "float")) { + param = new ParamFloat(in_repr, in_ext); + } else if (!strcmp(type, "string")) { + param = new ParamString(in_repr, in_ext); + } else if (!strcmp(type, "path")) { + param = new ParamPath(in_repr, in_ext); + } else if (!strcmp(type, "description")) { + // support deprecated "description" for backwards-compatibility + in_repr->setAttribute("gui-text", "description"); // TODO: hack to allow descriptions to be parameters + param = new ParamDescription(in_repr, in_ext); + } else if (!strcmp(type, "notebook")) { + in_repr->setAttribute("gui-text", "notebook"); // notebooks have no 'gui-text' (but Parameters need one) + param = new ParamNotebook(in_repr, in_ext); + } else if (!strcmp(type, "optiongroup")) { + param = new ParamOptionGroup(in_repr, in_ext); + } else if (!strcmp(type, "enum")) { // support deprecated "enum" for backwards-compatibility + in_repr->setAttribute("appearance", "combo"); + param = new ParamOptionGroup(in_repr, in_ext); + } else if (!strcmp(type, "color")) { + param = new ParamColor(in_repr, in_ext); + } else { + g_warning("Unknown parameter type ('%s') in extension '%s'", type, in_ext->get_id()); + } + } catch (const param_no_name&) { + } catch (const param_no_text&) { + } + + // Note: param could equal nullptr + return param; +} + +bool InxParameter::get_bool() const +{ + ParamBool const *boolpntr = dynamic_cast<ParamBool const *>(this); + if (!boolpntr) { + throw param_not_bool_param(); + } + return boolpntr->get(); +} + +int InxParameter::get_int() const +{ + ParamInt const *intpntr = dynamic_cast<ParamInt const *>(this); + if (!intpntr) { + throw param_not_int_param(); + } + return intpntr->get(); +} + +float InxParameter::get_float() const +{ + ParamFloat const *floatpntr = dynamic_cast<ParamFloat const *>(this); + if (!floatpntr) { + throw param_not_float_param(); + } + return floatpntr->get(); +} + +const char *InxParameter::get_string() const +{ + ParamString const *stringpntr = dynamic_cast<ParamString const *>(this); + if (!stringpntr) { + throw param_not_string_param(); + } + return stringpntr->get().c_str(); +} + +const char *InxParameter::get_optiongroup() const +{ + ParamOptionGroup const *param = dynamic_cast<ParamOptionGroup const *>(this); + if (!param) { + throw param_not_optiongroup_param(); + } + return param->get().c_str(); +} + +bool InxParameter::get_optiongroup_contains(const char *value) const +{ + ParamOptionGroup const *param = dynamic_cast<ParamOptionGroup const *>(this); + if (!param) { + throw param_not_optiongroup_param(); + } + return param->contains(value); +} + +unsigned int InxParameter::get_color() const +{ + ParamColor const *param = dynamic_cast<ParamColor const *>(this); + if (!param) { + throw param_not_color_param(); + } + return param->get(); +} + +bool InxParameter::set_bool(bool in) +{ + ParamBool * boolpntr = dynamic_cast<ParamBool *>(this); + if (boolpntr == nullptr) + throw param_not_bool_param(); + return boolpntr->set(in); +} + +int InxParameter::set_int(int in) +{ + ParamInt *intpntr = dynamic_cast<ParamInt *>(this); + if (intpntr == nullptr) + throw param_not_int_param(); + return intpntr->set(in); +} + +float InxParameter::set_float(float in) +{ + ParamFloat * floatpntr; + floatpntr = dynamic_cast<ParamFloat *>(this); + if (floatpntr == nullptr) + throw param_not_float_param(); + return floatpntr->set(in); +} + +const char *InxParameter::set_string(const char *in) +{ + ParamString * stringpntr = dynamic_cast<ParamString *>(this); + if (stringpntr == nullptr) + throw param_not_string_param(); + return stringpntr->set(in).c_str(); +} + +const char *InxParameter::set_optiongroup(const char *in) +{ + ParamOptionGroup *param = dynamic_cast<ParamOptionGroup *>(this); + if (!param) { + throw param_not_optiongroup_param(); + } + return param->set(in).c_str(); +} + +unsigned int InxParameter::set_color(unsigned int in) +{ + ParamColor*param = dynamic_cast<ParamColor *>(this); + if (param == nullptr) + throw param_not_color_param(); + return param->set(in); +} + + +InxParameter::InxParameter(Inkscape::XML::Node *in_repr, Inkscape::Extension::Extension *ext) + : InxWidget(in_repr, ext) +{ + // name (mandatory for all paramters) + const char *name = in_repr->attribute("name"); + if (!name) { + g_warning("Parameter without name in extension '%s'.", _extension->get_id()); + throw param_no_name(); + } + _name = g_strdup(name); + + // gui-text + const char *gui_text = in_repr->attribute("gui-text"); + if (!gui_text) { + gui_text = in_repr->attribute("_gui-text"); // backwards-compatibility with underscored variants + } + if (gui_text) { + if (_translatable != NO) { // translate unless explicitly marked untranslatable + gui_text = get_translation(gui_text); + } + _text = g_strdup(gui_text); + } + if (!_text && !_hidden) { + g_warning("Parameter '%s' in extension '%s' is visible but does not have a 'gui-text'.", + _name, _extension->get_id()); + throw param_no_text(); + } + + // gui-description (optional) + const char *gui_description = in_repr->attribute("gui-description"); + if (!gui_description) { + gui_description = in_repr->attribute("_gui-description"); // backwards-compatibility with underscored variants + } + if (gui_description) { + if (_translatable != NO) { // translate unless explicitly marked untranslatable + gui_description = get_translation(gui_description); + } + _description = g_strdup(gui_description); + } +} + +InxParameter::~InxParameter() +{ + g_free(_name); + _name = nullptr; + + g_free(_text); + _text = nullptr; + + g_free(_description); + _description = nullptr; +} + +Glib::ustring InxParameter::pref_name() const +{ + return Glib::ustring::compose("/extensions/%1.%2", _extension->get_id(), _name); +} + +std::string InxParameter::value_to_string() const +{ + // if we end up here we're missing a definition of ::string() in one of the subclasses + g_critical("InxParameter::value_to_string called from parameter '%s' in extension '%s'", _name, _extension->get_id()); + g_assert_not_reached(); + return ""; +} + +} // namespace Extension +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/extension/prefdialog/parameter.h b/src/extension/prefdialog/parameter.h new file mode 100644 index 000000000..7776851dc --- /dev/null +++ b/src/extension/prefdialog/parameter.h @@ -0,0 +1,162 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * Parameters for extensions. + */ +/* Authors: + * Ted Gould <ted@gould.cx> + * Jon A. Cruz <jon@joncruz.org> + * + * Copyright (C) 2005-2006 Authors + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#ifndef SEEN_INK_EXTENSION_PARAM_H__ +#define SEEN_INK_EXTENSION_PARAM_H__ + +#include "widget.h" + + +namespace Glib { +class ustring; +} + + +namespace Inkscape { +namespace Extension { + +/** + * A class to represent the parameter of an extension. + * + * This is really a super class that allows them to abstract all + * the different types of parameters into some that can be passed + * around. There is also a few functions that are used by all the + * different parameters. + */ +class InxParameter : public InxWidget { +public: + InxParameter(Inkscape::XML::Node *in_repr, + Inkscape::Extension::Extension *ext); + + ~InxParameter() override; + + /** Wrapper to cast to the object and use its function. */ + bool get_bool() const; + + /** Wrapper to cast to the object and use it's function. */ + int get_int() const; + + /** Wrapper to cast to the object and use it's function. */ + float get_float() const; + + /** Wrapper to cast to the object and use it's function. */ + const char *get_string() const; + + /** Wrapper to cast to the object and use it's function. */ + const char *get_optiongroup() const; + bool get_optiongroup_contains(const char *value) const; + + /** Wrapper to cast to the object and use it's function. */ + unsigned int get_color() const; + + /** Wrapper to cast to the object and use it's function. */ + bool set_bool(bool in); + + /** Wrapper to cast to the object and use it's function. */ + int set_int(int in); + + /** Wrapper to cast to the object and use it's function. */ + float set_float(float in); + + /** Wrapper to cast to the object and use it's function. */ + const char *set_string(const char *in); + + /** Wrapper to cast to the object and use it's function. */ + const char *set_optiongroup(const char *in); + + /** Wrapper to cast to the object and use it's function. */ + unsigned int set_color(unsigned int in); + + char const *name() const { return _name; } + + /** + * Creates a new extension parameter for usage in a prefdialog. + * + * The type of widget created is parsed from the XML representation passed in, + * and the suitable subclass constructor is called. + * + * Called from base-class method of the same name. + * + * @param in_repr The XML representation describing the widget. + * @param in_ext The extension the widget belongs to. + * @return a pointer to a new Widget if applicable, null otherwise.. + */ + static InxParameter *make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Extension *in_ext); + + const char *get_tooltip() const override { return _description; } + + /** + * Gets the current value of the parameter in a string form. + * + * @return String representation of the parameter's value. + * + * \internal Must be implemented by all derived classes. + * Unfortunately it seems we can't make this a pure virtual function, + * as InxParameter is not supposed to be abstract. + */ + virtual std::string value_to_string() const; + + /** Recommended spacing between the widgets making up a single Parameter (e.g. label and input) (in px) */ + const static int GUI_PARAM_WIDGETS_SPACING = 4; + + + /** An error class for when a parameter is called on a type it is not */ + class param_no_name {}; + class param_no_text {}; + class param_not_bool_param {}; + class param_not_color_param {}; + class param_not_float_param {}; + class param_not_int_param {}; + class param_not_optiongroup_param {}; + class param_not_string_param {}; + + +protected: + /** The name of this parameter. */ + char *_name = nullptr; + + /** Parameter text to show as the GUI label. */ + char *_text = nullptr; + + /** Extended description of the parameter (currently shown as tooltip on hover). */ + char *_description = nullptr; + + + /* **** member functions **** */ + + /** + * Build preference name for the current parameter. + * + * Returns a preference name that can be used with setters and getters from Inkscape::Preferences. + * The name is assembled from a fixed root ("/extensions/"), extension ID and parameter name. + * + * @return: Preference name + */ + Glib::ustring pref_name() const; +}; + +} // namespace Extension +} // namespace Inkscape + +#endif // SEEN_INK_EXTENSION_PARAM_H__ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/extension/prefdialog.cpp b/src/extension/prefdialog/prefdialog.cpp index de58545fb..3bb9be811 100644 --- a/src/extension/prefdialog.cpp +++ b/src/extension/prefdialog/prefdialog.cpp @@ -9,6 +9,7 @@ */ #include "prefdialog.h" + #include <gtkmm/checkbutton.h> #include <gtkmm/separator.h> #include <glibmm/i18n.h> @@ -22,11 +23,11 @@ #include "document.h" #include "document-undo.h" -#include "effect.h" -#include "implementation/implementation.h" +#include "extension/effect.h" +#include "extension/execution-env.h" +#include "extension/implementation/implementation.h" -#include "execution-env.h" -#include "param/parameter.h" +#include "parameter.h" namespace Inkscape { @@ -34,17 +35,15 @@ namespace Extension { /** \brief Creates a new preference dialog for extension preferences - \param name Name of the Extension whose dialog this is - \param help The help string for the extension (NULL if none) + \param name Name of the Extension whose dialog this is (should already be translated) \param controls The extension specific widgets in the dialog This function initializes the dialog with the name of the extension in the title. It adds a few buttons and sets up handlers for them. It also places the passed-in widgets into the dialog. */ -PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * controls, Effect * effect) : - Gtk::Dialog(_(name.c_str()), true), - _help(help), +PrefDialog::PrefDialog (Glib::ustring name, Gtk::Widget * controls, Effect * effect) : + Gtk::Dialog(name, true), _name(name), _button_ok(nullptr), _button_cancel(nullptr), @@ -55,7 +54,7 @@ PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * co { this->set_default_size(0,0); // we want the window to be as small as possible instead of clobbering up space - Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox()); + Gtk::HBox *hbox = Gtk::manage(new Gtk::HBox()); if (controls == nullptr) { if (_effect == nullptr) { std::cout << "AH!!! No controls and no effect!!!" << std::endl; @@ -70,11 +69,6 @@ PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * co this->get_content_area()->pack_start(*hbox, true, true, 0); - /* - Gtk::Button * help_button = add_button(Gtk::Stock::HELP, Gtk::RESPONSE_HELP); - if (_help == NULL) - help_button->set_sensitive(false); - */ _button_cancel = add_button(_effect == nullptr ? _("_Cancel") : _("_Close"), Gtk::RESPONSE_CANCEL); _button_ok = add_button(_effect == nullptr ? _("_OK") : _("_Apply"), Gtk::RESPONSE_OK); set_default_response(Gtk::RESPONSE_OK); @@ -87,24 +81,24 @@ PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * co std::cout << "Error encountered loading live parameter XML !!!" << std::endl; return; } - _param_preview = Parameter::make(doc->root(), _effect); + _param_preview = InxParameter::make(doc->root(), _effect); } auto sep = Gtk::manage(new Gtk::Separator()); sep->show(); - this->get_content_area()->pack_start(*sep, false, false, Parameter::GUI_BOX_SPACING); + this->get_content_area()->pack_start(*sep, false, false, InxWidget::GUI_BOX_SPACING); hbox = Gtk::manage(new Gtk::HBox()); - hbox->set_border_width(Parameter::GUI_BOX_MARGIN); - _button_preview = _param_preview->get_widget(nullptr, nullptr, &_signal_preview); + hbox->set_border_width(InxWidget::GUI_BOX_MARGIN); + _button_preview = _param_preview->get_widget(&_signal_preview); _button_preview->show(); hbox->pack_start(*_button_preview, true, true, 0); hbox->show(); this->get_content_area()->pack_start(*hbox, false, false, 0); - Gtk::Box * hbox = dynamic_cast<Gtk::Box *>(_button_preview); + Gtk::Box *hbox = dynamic_cast<Gtk::Box *>(_button_preview); if (hbox != nullptr) { _checkbox_preview = dynamic_cast<Gtk::CheckButton *>(hbox->get_children().front()); } @@ -145,39 +139,12 @@ PrefDialog::~PrefDialog ( ) return; } -#if 0 -/** \brief Runs the dialog - \return The response to the dialog - - This function overrides the run function in the GTKmm dialog - class, but basically it only calls it. This function only - handles the \c Gtk::RESPONSE_HELP return, and in that case it - brings up the help window. All other return values are returned - to the calling function. -*/ -int -PrefDialog::run (void) { - int resp = Gtk::RESPONSE_HELP; - while (resp == Gtk::RESPONSE_HELP) { - resp = Gtk::Dialog::run(); - if (resp == Gtk::RESPONSE_HELP) { - /* - if (_helpDialog == NULL) { - _helpDialog = new HelpDialog(_help); - } - */ - } - } - return resp; -} -#endif - void PrefDialog::preview_toggle () { SPDesktop *desktop = SP_ACTIVE_DESKTOP; SPDocument *document = SP_ACTIVE_DOCUMENT; bool modified = document->isModifiedSinceSave(); - if(_param_preview->get_bool(nullptr, nullptr)) { + if(_param_preview->get_bool()) { if (_exEnv == nullptr) { set_modal(true); _exEnv = new ExecutionEnv(_effect, SP_ACTIVE_DESKTOP, nullptr, false, false); @@ -258,9 +225,9 @@ PrefDialog::on_response (int signal) { return; } -#include "internal/clear-n_.h" +#include "extension/internal/clear-n_.h" -const char * PrefDialog::live_param_xml = "<param name=\"__live_effect__\" type=\"boolean\" _gui-text=\"" N_("Live preview") "\" gui-description=\"" N_("Is the effect previewed live on canvas?") "\">false</param>"; +const char * PrefDialog::live_param_xml = "<param name=\"__live_effect__\" type=\"bool\" gui-text=\"" N_("Live preview") "\" gui-description=\"" N_("Is the effect previewed live on canvas?") "\">false</param>"; }; }; /* namespace Inkscape, Extension */ diff --git a/src/extension/prefdialog.h b/src/extension/prefdialog/prefdialog.h index 087900fbe..9fe8acda8 100644 --- a/src/extension/prefdialog.h +++ b/src/extension/prefdialog/prefdialog.h @@ -23,27 +23,25 @@ namespace Inkscape { namespace Extension { class Effect; class ExecutionEnv; -class Parameter; +class InxParameter; /** \brief A class to represent the preferences for an extension */ class PrefDialog : public Gtk::Dialog { - /** \brief Help string if it exists */ - gchar const * _help; /** \brief Name of the extension */ Glib::ustring _name; /** \brief A pointer to the OK button */ - Gtk::Button * _button_ok; + Gtk::Button *_button_ok; /** \brief A pointer to the CANCEL button */ - Gtk::Button * _button_cancel; + Gtk::Button *_button_cancel; /** \brief Button to control live preview */ - Gtk::Widget * _button_preview; + Gtk::Widget *_button_preview; /** \brief Checkbox for the preview */ - Gtk::CheckButton * _checkbox_preview; + Gtk::CheckButton *_checkbox_preview; /** \brief Parameter to control live preview */ - Parameter * _param_preview; + InxParameter *_param_preview; /** \brief XML to define the live effects parameter on the dialog */ static const char * live_param_xml; @@ -55,10 +53,10 @@ class PrefDialog : public Gtk::Dialog { /** \brief If this is the preferences for an effect, the effect that we're working with. */ - Effect * _effect; + Effect *_effect; /** \brief If we're executing in preview mode here is the execution environment for the effect. */ - ExecutionEnv * _exEnv; + ExecutionEnv *_exEnv; /** \brief The timer used to make it so that parameters don't respond directly and allows for changes. */ @@ -71,7 +69,6 @@ class PrefDialog : public Gtk::Dialog { public: PrefDialog (Glib::ustring name, - gchar const * help, Gtk::Widget * controls = nullptr, Effect * effect = nullptr); ~PrefDialog () override; diff --git a/src/extension/prefdialog/widget-box.cpp b/src/extension/prefdialog/widget-box.cpp new file mode 100644 index 000000000..9fd75e19a --- /dev/null +++ b/src/extension/prefdialog/widget-box.cpp @@ -0,0 +1,115 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * Box widget for extensions + *//* + * Authors: + * Patrick Storz <eduard.braun2@gmx.de> + * + * Copyright (C) 2019 Authors + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#include "widget-box.h" + +#include <gtkmm/box.h> + +#include "xml/node.h" +#include "extension/extension.h" + +namespace Inkscape { +namespace Extension { + + +WidgetBox::WidgetBox(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext) + : InxWidget(xml, ext) +{ + // Decide orientation based on tagname (hbox vs. vbox) + const char *tagname = xml->name(); + if (!strncmp(tagname, INKSCAPE_EXTENSION_NS_NC, strlen(INKSCAPE_EXTENSION_NS_NC))) { + tagname += strlen(INKSCAPE_EXTENSION_NS); + } + if (!strcmp(tagname, "hbox")) { + _orientation = HORIZONTAL; + } else if (!strcmp(tagname, "vbox")) { + _orientation = VERTICAL; + } else { + g_assert_not_reached(); + } + + // Read XML tree of box and parse child widgets + if (xml) { + Inkscape::XML::Node *child_repr = xml->firstChild(); + while (child_repr) { + const char *chname = child_repr->name(); + if (!strncmp(chname, INKSCAPE_EXTENSION_NS_NC, strlen(INKSCAPE_EXTENSION_NS_NC))) { + chname += strlen(INKSCAPE_EXTENSION_NS); + } + if (chname[0] == '_') { // allow leading underscore in tag names for backwards-compatibility + chname++; + } + + if (InxWidget::is_valid_widget_name(chname)) { + InxWidget *widget = InxWidget::make(child_repr, _extension); + if (widget) { + _children.push_back(widget); + } + } else if (child_repr->type() == XML::ELEMENT_NODE) { + g_warning("Invalid child element ('%s') in box widget in extension '%s'.", + chname, _extension->get_id()); + } else if (child_repr->type() != XML::COMMENT_NODE){ + g_warning("Invalid child element found in box widget in extension '%s'.", _extension->get_id()); + } + + child_repr = child_repr->next(); + } + } +} + +Gtk::Widget *WidgetBox::get_widget(sigc::signal<void> *changeSignal) +{ + if (_hidden) { + return nullptr; + } + + Gtk::Orientation orientation; + if (_orientation == HORIZONTAL) { + orientation = Gtk::ORIENTATION_HORIZONTAL; + } else { + orientation = Gtk::ORIENTATION_VERTICAL; + } + + Gtk::Box *box = Gtk::manage(new Gtk::Box(orientation)); + // box->set_border_width(GUI_BOX_MARGIN); // leave at zero for now, so box is purely for layouting (not grouping) + // revisit this later, possibly implementing GtkFrame or similar + box->set_spacing(GUI_BOX_SPACING); + + if (_orientation == HORIZONTAL) { + box->set_vexpand(false); + } else { + box->set_hexpand(false); + } + + // add child widgets onto page (if any) + for (auto child : _children) { + Gtk::Widget *child_widget = child->get_widget(changeSignal); + if (child_widget) { + int indent = child->get_indent(); + child_widget->set_margin_start(indent * GUI_INDENTATION); + box->pack_start(*child_widget, false, true, 0); // fill=true does not have an effect here, but allows the + // child to choose to expand by setting hexpand/vexpand + + const char *tooltip = child->get_tooltip(); + if (tooltip) { + child_widget->set_tooltip_text(tooltip); + } + } + } + + box->show(); + + return dynamic_cast<Gtk::Widget *>(box); +} + +} /* namespace Extension */ +} /* namespace Inkscape */ diff --git a/src/extension/prefdialog/widget-box.h b/src/extension/prefdialog/widget-box.h new file mode 100644 index 000000000..6fd7b900c --- /dev/null +++ b/src/extension/prefdialog/widget-box.h @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * Box widget for extensions + *//* + * Authors: + * Patrick Storz <eduard.braun2@gmx.de> + * + * Copyright (C) 2019 Authors + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#ifndef SEEN_INK_EXTENSION_WIDGET_BOX_H +#define SEEN_INK_EXTENSION_WIDGET_BOX_H + +#include "widget.h" + +#include <glibmm/ustring.h> + +namespace Gtk { + class Widget; +} + +namespace Inkscape { +namespace Xml { + class Node; +} + +namespace Extension { + +/** \brief A box widget */ +class WidgetBox : public InxWidget { +public: + WidgetBox(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext); + + Gtk::Widget *get_widget(sigc::signal<void> *changeSignal) override; +private: + enum Orientation { + HORIZONTAL, VERTICAL + }; + + /** Layout orientation of the box (default is vertical) **/ + Orientation _orientation = VERTICAL; +}; + +} /* namespace Extension */ +} /* namespace Inkscape */ + +#endif /* SEEN_INK_EXTENSION_WIDGET_BOX_H */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/extension/prefdialog/widget-image.cpp b/src/extension/prefdialog/widget-image.cpp new file mode 100644 index 000000000..4f5e11dec --- /dev/null +++ b/src/extension/prefdialog/widget-image.cpp @@ -0,0 +1,87 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * Image widget for extensions + *//* + * Authors: + * Patrick Storz <eduard.braun2@gmx.de> + * + * Copyright (C) 2019 Authors + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#include "widget-image.h" + +#include <glibmm/fileutils.h> +#include <glibmm/miscutils.h> +#include <gtkmm/image.h> + +#include "xml/node.h" +#include "extension/extension.h" + +namespace Inkscape { +namespace Extension { + + +WidgetImage::WidgetImage(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext) + : InxWidget(xml, ext) +{ + std::string image_path; + + // get path to image + const char *content = nullptr; + if (xml->firstChild()) { + content = xml->firstChild()->content(); + } + if (content) { + image_path = content; + } else { + g_warning("Missing path for image widget in extension '%s'.", _extension->get_id()); + return; + } + + // make sure path is absolute (relative paths are relative to .inx file's location) + if (!Glib::path_is_absolute(image_path)) { + image_path = Glib::build_filename(_extension->get_base_directory(), image_path); + } + + // check if image exists + if (Glib::file_test(image_path, Glib::FILE_TEST_IS_REGULAR)) { + _image_path = image_path; + } else { + g_warning("Image file ('%s') not found for image widget in extension '%s'.", + image_path.c_str(), _extension->get_id()); + } + + // parse width/height attributes + const char *width = xml->attribute("width"); + const char *height = xml->attribute("height"); + if (width && height) { + _width = strtoul(width, nullptr, 0); + _height = strtoul(height, nullptr, 0); + } +} + +/** \brief Create a label for the description */ +Gtk::Widget *WidgetImage::get_widget(sigc::signal<void> * /*changeSignal*/) +{ + if (_hidden || _image_path.empty()) { + return nullptr; + } + + Gtk::Image *image = Gtk::manage(new Gtk::Image(_image_path)); + + // resize if requested + if (_width && _height) { + Glib::RefPtr<Gdk::Pixbuf> pixbuf = image->get_pixbuf(); + pixbuf = pixbuf->scale_simple(_width, _height, Gdk::INTERP_BILINEAR); + image->set(pixbuf); + } + + image->show(); + + return dynamic_cast<Gtk::Widget *>(image); +} + +} /* namespace Extension */ +} /* namespace Inkscape */ diff --git a/src/extension/prefdialog/widget-image.h b/src/extension/prefdialog/widget-image.h new file mode 100644 index 000000000..95dd4d5d1 --- /dev/null +++ b/src/extension/prefdialog/widget-image.h @@ -0,0 +1,61 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * Image widget for extensions + *//* + * Authors: + * Patrick Storz <eduard.braun2@gmx.de> + * + * Copyright (C) 2019 Authors + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#ifndef SEEN_INK_EXTENSION_WIDGET_IMAGE_H +#define SEEN_INK_EXTENSION_WIDGET_IMAGE_H + +#include "widget.h" + +#include <string> + +namespace Gtk { + class Widget; +} + +namespace Inkscape { +namespace Xml { + class Node; +} + +namespace Extension { + +/** \brief A label widget */ +class WidgetImage : public InxWidget { +public: + WidgetImage(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext); + + Gtk::Widget *get_widget(sigc::signal<void> *changeSignal) override; +private: + /** \brief Path to image file (relative paths are relative to the .inx file location). */ + std::string _image_path; + + /** desired width of image when rendered on screen (in px) */ + unsigned int _width = 0; + /** desired height of image when rendered on screen (in px) */ + unsigned int _height = 0; +}; + +} /* namespace Extension */ +} /* namespace Inkscape */ + +#endif /* SEEN_INK_EXTENSION_WIDGET_IMAGE_H */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/extension/param/description.cpp b/src/extension/prefdialog/widget-label.cpp index 60e2d02c8..ec4f558af 100644 --- a/src/extension/param/description.cpp +++ b/src/extension/prefdialog/widget-label.cpp @@ -1,102 +1,89 @@ // SPDX-License-Identifier: GPL-2.0-or-later -/* - * Copyright (C) 2005-2007 Authors: +/** @file + * Description widget for extensions + *//* + * Authors: * Ted Gould <ted@gould.cx> * Johan Engelen <johan@shouraizou.nl> * + * Patrick Storz <eduard.braun2@gmx.de> + * + * Copyright (C) 2005-2019 Authors + * * Released under GNU GPL v2+, read the file 'COPYING' for more information. */ -#ifdef linux // does the dollar sign need escaping when passed as string parameter? -# define ESCAPE_DOLLAR_COMMANDLINE -#endif +#include "widget-label.h" #include <gtkmm/box.h> #include <gtkmm/label.h> -#include <glibmm/i18n.h> #include <glibmm/markup.h> #include <glibmm/regex.h> #include "xml/node.h" #include "extension/extension.h" -#include "description.h" namespace Inkscape { namespace Extension { -/** \brief Initialize the object, to do that, copy the data. */ -ParamDescription::ParamDescription(const gchar * name, - const gchar * text, - const gchar * description, - bool hidden, - int indent, - Inkscape::Extension::Extension * ext, - Inkscape::XML::Node * xml, - AppearanceMode mode) - : Parameter(name, text, description, hidden, indent, ext) - , _value(nullptr) - , _mode(mode) +WidgetLabel::WidgetLabel(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext) + : InxWidget(xml, ext) { // construct the text content by concatenating all (non-empty) text nodes, // removing all other nodes (e.g. comment nodes) and replacing <extension:br> elements with "<br/>" - Glib::ustring value; Inkscape::XML::Node * cur_child = xml->firstChild(); while (cur_child != nullptr) { if (cur_child->type() == XML::TEXT_NODE && cur_child->content() != nullptr) { - value += cur_child->content(); + _value += cur_child->content(); } else if (cur_child->type() == XML::ELEMENT_NODE && !g_strcmp0(cur_child->name(), "extension:br")) { - value += "<br/>"; + _value += "<br/>"; } cur_child = cur_child->next(); } - // if there is no text content we can return immediately (the description will be invisible) - if (value == Glib::ustring("")) { - return; - } - // do replacements in the source string to account for the attribute xml:space="preserve" // (those should match replacements potentially performed by xgettext to allow for proper translation) if (g_strcmp0(xml->attribute("xml:space"), "preserve") == 0) { // xgettext copies the source string verbatim in this case, so no changes needed } else { // remove all whitespace from start/end of string and replace intermediate whitespace with a single space - value = Glib::Regex::create("^\\s+|\\s+$")->replace_literal(value, 0, "", (Glib::RegexMatchFlags)0); - value = Glib::Regex::create("\\s+")->replace_literal(value, 0, " ", (Glib::RegexMatchFlags)0); + _value = Glib::Regex::create("^\\s+|\\s+$")->replace_literal(_value, 0, "", (Glib::RegexMatchFlags)0); + _value = Glib::Regex::create("\\s+")->replace_literal(_value, 0, " ", (Glib::RegexMatchFlags)0); } - // translate if underscored version (_param) was used - if (g_str_has_prefix(xml->name(), "extension:_")) { - const gchar * context = xml->attribute("msgctxt"); - if (context != nullptr) { - value = g_dpgettext2(nullptr, context, value.c_str()); - } else { - value = _(value.c_str()); + // translate value + if (!_value.empty()) { + if (_translatable != NO) { // translate unless explicitly marked untranslatable + _value = get_translation(_value.c_str()); } } // finally replace all remaining <br/> with a real newline character - value = Glib::Regex::create("<br/>")->replace_literal(value, 0, "\n", (Glib::RegexMatchFlags)0); - - _value = g_strdup(value.c_str()); - - return; + _value = Glib::Regex::create("<br/>")->replace_literal(_value, 0, "\n", (Glib::RegexMatchFlags)0); + + // parse appearance + if (_appearance) { + if (!strcmp(_appearance, "header")) { + _mode = HEADER; + } else if (!strcmp(_appearance, "url")) { + _mode = URL; + } else { + g_warning("Invalid value ('%s') for appearance of label widget in extension '%s'", + _appearance, _extension->get_id()); + } + } } /** \brief Create a label for the description */ -Gtk::Widget * -ParamDescription::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * /*changeSignal*/) +Gtk::Widget *WidgetLabel::get_widget(sigc::signal<void> * /*changeSignal*/) { if (_hidden) { return nullptr; } - if (_value == nullptr) { - return nullptr; - } Glib::ustring newtext = _value; - Gtk::Label * label = Gtk::manage(new Gtk::Label()); + Gtk::Label *label = Gtk::manage(new Gtk::Label()); if (_mode == HEADER) { label->set_markup(Glib::ustring("<b>") + Glib::Markup::escape_text(newtext) + Glib::ustring("</b>")); label->set_margin_top(5); @@ -112,18 +99,18 @@ ParamDescription::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node // TODO: Ugly "fix" for gtk3 width/height calculation of labels. // - If not applying any limits long labels will make the window grow horizontally until it uses up - // most of the available space (i.e. most of the screen area) which is ridicously wide + // most of the available space (i.e. most of the screen area) which is ridiculously wide. // - By using "set_default_size(0,0)" in prefidalog.cpp we tell the window to shrink as much as possible, - // however this can result in a much to narrow dialog instead and much unnecessary wrapping - // - Here we set a lower limit of GUI_MAX_LINE_LENGTH characters per line that long texts will always use + // however this can result in a much too narrow dialog instead and a lot of unnecessary wrapping. + // - Here we set a lower limit of GUI_MAX_LINE_LENGTH characters per line that long texts will always use. // This means texts can not shrink anymore (they can still grow, though) and it's also necessary // to prevent https://bugzilla.gnome.org/show_bug.cgi?id=773572 int len = newtext.length(); - label->set_width_chars(len > Parameter::GUI_MAX_LINE_LENGTH ? Parameter::GUI_MAX_LINE_LENGTH : len); + label->set_width_chars(len > GUI_MAX_LINE_LENGTH ? GUI_MAX_LINE_LENGTH : len); label->show(); - Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox()); + Gtk::HBox *hbox = Gtk::manage(new Gtk::HBox()); hbox->pack_start(*label, true, true); hbox->show(); diff --git a/src/extension/prefdialog/widget-label.h b/src/extension/prefdialog/widget-label.h new file mode 100644 index 000000000..1c1655006 --- /dev/null +++ b/src/extension/prefdialog/widget-label.h @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * Description widget for extensions + *//* + * Authors: + * Ted Gould <ted@gould.cx> + * Johan Engelen <johan@shouraizou.nl> * + * Patrick Storz <eduard.braun2@gmx.de> + * + * Copyright (C) 2005-2019 Authors + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#ifndef SEEN_INK_EXTENSION_WIDGET_LABEL_H +#define SEEN_INK_EXTENSION_WIDGET_LABEL_H + +#include "widget.h" + +#include <glibmm/ustring.h> + +namespace Gtk { + class Widget; +} + +namespace Inkscape { +namespace Xml { + class Node; +} + +namespace Extension { + +/** \brief A label widget */ +class WidgetLabel : public InxWidget { +public: + enum AppearanceMode { + DEFAULT, HEADER, URL + }; + + WidgetLabel(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext); + + Gtk::Widget *get_widget(sigc::signal<void> *changeSignal) override; +private: + /** \brief Internal value. */ + Glib::ustring _value; + + /** appearance mode **/ + AppearanceMode _mode = DEFAULT; +}; + +} /* namespace Extension */ +} /* namespace Inkscape */ + +#endif /* SEEN_INK_EXTENSION_WIDGET_LABEL_H */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/extension/prefdialog/widget-separator.cpp b/src/extension/prefdialog/widget-separator.cpp new file mode 100644 index 000000000..d78894b62 --- /dev/null +++ b/src/extension/prefdialog/widget-separator.cpp @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * Separator widget for extensions + *//* + * Authors: + * Patrick Storz <eduard.braun2@gmx.de> + * + * Copyright (C) 2019 Authors + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#include "widget-separator.h" + +#include <gtkmm/separator.h> + +#include "xml/node.h" +#include "extension/extension.h" + +namespace Inkscape { +namespace Extension { + + +WidgetSeparator::WidgetSeparator(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext) + : InxWidget(xml, ext) +{ +} + +/** \brief Create a label for the description */ +Gtk::Widget *WidgetSeparator::get_widget(sigc::signal<void> *changeSignal) +{ + if (_hidden) { + return nullptr; + } + + Gtk::Separator *separator = Gtk::manage(new Gtk::Separator()); + separator->show(); + + return dynamic_cast<Gtk::Widget *>(separator); +} + +} /* namespace Extension */ +} /* namespace Inkscape */ diff --git a/src/extension/prefdialog/widget-separator.h b/src/extension/prefdialog/widget-separator.h new file mode 100644 index 000000000..9533aba61 --- /dev/null +++ b/src/extension/prefdialog/widget-separator.h @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * Separator widget for extensions + *//* + * Authors: + * Patrick Storz <eduard.braun2@gmx.de> + * + * Copyright (C) 2019 Authors + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#ifndef SEEN_INK_EXTENSION_WIDGET_SEPARATOR_H +#define SEEN_INK_EXTENSION_WIDGET_SEPARATOR_H + +#include "widget.h" + +#include <glibmm/ustring.h> + +namespace Gtk { + class Widget; +} + +namespace Inkscape { +namespace Xml { + class Node; +} + +namespace Extension { + +/** \brief A separator widget */ +class WidgetSeparator : public InxWidget { +public: + WidgetSeparator(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext); + + Gtk::Widget *get_widget(sigc::signal<void> *changeSignal) override; +}; + +} /* namespace Extension */ +} /* namespace Inkscape */ + +#endif /* SEEN_INK_EXTENSION_WIDGET_SEPARATOR_H */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/extension/prefdialog/widget-spacer.cpp b/src/extension/prefdialog/widget-spacer.cpp new file mode 100644 index 000000000..350aeb4f2 --- /dev/null +++ b/src/extension/prefdialog/widget-spacer.cpp @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * Spacer widget for extensions + *//* + * Authors: + * Patrick Storz <eduard.braun2@gmx.de> + * + * Copyright (C) 2019 Authors + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#include "widget-spacer.h" + +#include <gtkmm/box.h> + +#include "xml/node.h" +#include "extension/extension.h" + +namespace Inkscape { +namespace Extension { + + +WidgetSpacer::WidgetSpacer(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext) + : InxWidget(xml, ext) +{ + // get size + const char *size = xml->attribute("size"); + if (size) { + _size = strtol(size, nullptr, 0); + if (_size == 0) { + if (!strcmp(size, "expand")) { + _expand = true; + } else { + g_warning("Invalid value ('%s') for size spacer in extension '%s'", size, _extension->get_id()); + } + } + } +} + +/** \brief Create a label for the description */ +Gtk::Widget *WidgetSpacer::get_widget(sigc::signal<void> *changeSignal) +{ + if (_hidden) { + return nullptr; + } + + Gtk::Box *spacer = Gtk::manage(new Gtk::Box()); + spacer->set_border_width(_size/2); + + if (_expand) { + spacer->set_hexpand(); + spacer->set_vexpand(); + } else { + spacer->set_margin_start(_size); + spacer->set_margin_top(_size); + } + + spacer->show(); + + return dynamic_cast<Gtk::Widget *>(spacer); +} + +} /* namespace Extension */ +} /* namespace Inkscape */ diff --git a/src/extension/prefdialog/widget-spacer.h b/src/extension/prefdialog/widget-spacer.h new file mode 100644 index 000000000..467b5f95b --- /dev/null +++ b/src/extension/prefdialog/widget-spacer.h @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * Spacer widget for extensions + *//* + * Authors: + * Patrick Storz <eduard.braun2@gmx.de> + * + * Copyright (C) 2019 Authors + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#ifndef SEEN_INK_EXTENSION_WIDGET_SPACER_H +#define SEEN_INK_EXTENSION_WIDGET_SPACER_H + +#include "widget.h" + +#include <glibmm/ustring.h> + +namespace Gtk { + class Widget; +} + +namespace Inkscape { +namespace Xml { + class Node; +} + +namespace Extension { + +/** \brief A separator widget */ +class WidgetSpacer : public InxWidget { +public: + WidgetSpacer(Inkscape::XML::Node *xml, Inkscape::Extension::Extension *ext); + + Gtk::Widget *get_widget(sigc::signal<void> *changeSignal) override; + +private: + /** size of the spacer in px */ + int _size = GUI_BOX_MARGIN; + + /** should the spacer be flexible and expand? */ + bool _expand = false; +}; + +} /* namespace Extension */ +} /* namespace Inkscape */ + +#endif /* SEEN_INK_EXTENSION_WIDGET_SPACER_H */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/extension/prefdialog/widget.cpp b/src/extension/prefdialog/widget.cpp new file mode 100644 index 000000000..d4f33f7af --- /dev/null +++ b/src/extension/prefdialog/widget.cpp @@ -0,0 +1,177 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * Parameters for extensions. + *//* + * Author: + * Patrick Storz <eduard.braun2@gmx.de> + * + * Copyright (C) 2019 Authors + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#include "parameter.h" +#include "widget.h" +#include "widget-box.h" +#include "widget-image.h" +#include "widget-label.h" +#include "widget-separator.h" +#include "widget-spacer.h" + +#include <algorithm> + +#include <sigc++/sigc++.h> + +#include "extension/extension.h" + +#include "xml/node.h" + + +namespace Inkscape { +namespace Extension { + +InxWidget *InxWidget::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Extension *in_ext) +{ + InxWidget *widget = nullptr; + + const char *name = in_repr->name(); + if (!strncmp(name, INKSCAPE_EXTENSION_NS_NC, strlen(INKSCAPE_EXTENSION_NS_NC))) { + name += strlen(INKSCAPE_EXTENSION_NS); + } + if (name[0] == '_') { // allow leading underscore in tag names for backwards-compatibility + name++; + } + + // decide on widget type based on tag name + // keep in sync with list of names supported in InxWidget::is_valid_widget_name() below + if (!name) { + // we can't create a widget without name + g_warning("InxWidget without name in extension '%s'.", in_ext->get_id()); + } else if (!strcmp(name, "hbox") || !strcmp(name, "vbox")) { + widget = new WidgetBox(in_repr, in_ext); + } else if (!strcmp(name, "image")) { + widget = new WidgetImage(in_repr, in_ext); + } else if (!strcmp(name, "label")) { + widget = new WidgetLabel(in_repr, in_ext); + } else if (!strcmp(name, "separator")) { + widget = new WidgetSeparator(in_repr, in_ext); + } else if (!strcmp(name, "spacer")) { + widget = new WidgetSpacer(in_repr, in_ext); + } else if (!strcmp(name, "param")) { + widget = InxParameter::make(in_repr, in_ext); + } else { + g_warning("Unknown widget name ('%s') in extension '%s'", name, in_ext->get_id()); + } + + // Note: widget could equal nullptr + return widget; +} + +bool InxWidget::is_valid_widget_name(const char *name) +{ + // keep in sync with names supported in InxWidget::make() above + static const std::vector<std::string> valid_names = + {"hbox", "vbox", "image", "label", "separator", "spacer", "param"}; + + if (std::find(valid_names.begin(), valid_names.end(), name) != valid_names.end()) { + return true; + } else { + return false; + } +} + + +InxWidget::InxWidget(Inkscape::XML::Node *in_repr, Inkscape::Extension::Extension *ext) + : _extension(ext) +{ + // translatable (optional) + const char *translatable = in_repr->attribute("translatable"); + if (translatable) { + if (!strcmp(translatable, "yes")) { + _translatable = YES; + } else if (!strcmp(translatable, "no")) { + _translatable = NO; + } else { + g_warning("Invalid value ('%s') for translatable attribute of widget '%s' in extension '%s'", + translatable, in_repr->name(), _extension->get_id()); + } + } + + // context (optional) + const char *context = in_repr->attribute("context"); + if (!context) { + context = in_repr->attribute("msgctxt"); // backwards-compatibility with previous name + } + if (context) { + _context = g_strdup(context); + } + + // gui-hidden (optional) + const char *gui_hidden = in_repr->attribute("gui-hidden"); + if (gui_hidden != nullptr) { + if (strcmp(gui_hidden, "true") == 0) { + _hidden = true; + } + } + + // indent (optional) + const char *indent = in_repr->attribute("indent"); + if (indent != nullptr) { + _indent = strtol(indent, nullptr, 0); + } + + // appearance (optional, does not apply to all parameters) + const char *appearance = in_repr->attribute("appearance"); + if (appearance) { + _appearance = g_strdup(appearance); + } +} + +InxWidget::~InxWidget() +{ + for (auto child : _children) { + delete child; + } + + g_free(_context); + _context = nullptr; + + g_free(_appearance); + _appearance = nullptr; +} + +Gtk::Widget * +InxWidget::get_widget(sigc::signal<void> * /*changeSignal*/) +{ + // if we end up here we're missing a definition of ::get_widget() in one of the subclasses + g_critical("InxWidget::get_widget called from widget of type '%s' in extension '%s'", + typeid(this).name(), _extension->get_id()); + g_assert_not_reached(); + return nullptr; +} + +const char *InxWidget::get_translation(const char* msgid) { + return _extension->get_translation(msgid, _context); +} + +void InxWidget::get_widgets(std::vector<InxWidget *> &list) +{ + list.push_back(this); + for (auto child : _children) { + child->get_widgets(list); + } +} + +} // namespace Extension +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/extension/prefdialog/widget.h b/src/extension/prefdialog/widget.h new file mode 100644 index 000000000..843655c6e --- /dev/null +++ b/src/extension/prefdialog/widget.h @@ -0,0 +1,149 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/** @file + * Base class for extension widgets. + *//* + * Authors: + * Patrick Storz <eduard.braun2@gmx.de> + * + * Copyright (C) 2019 Authors + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#ifndef SEEN_INK_EXTENSION_WIDGET_H +#define SEEN_INK_EXTENSION_WIDGET_H + +#include <string> +#include <vector> + +#include <sigc++/sigc++.h> + +namespace Gtk { +class Widget; +} + +namespace Inkscape { +namespace XML { +class Node; +} + +namespace Extension { + +class Extension; + + +/** + * Base class to represent all widgets of an extension (including parameters) + */ +class InxWidget { +public: + InxWidget(Inkscape::XML::Node *in_repr, Inkscape::Extension::Extension *in_ext); + + virtual ~InxWidget(); + + /** + * Creates a new extension widget for usage in a prefdialog. + * + * The type of widget created is parsed from the XML representation passed in, + * and the suitable subclass constructor is called. + * + * For specialized widget types (like parameters) we defer to the subclass function of the same name. + * + * @param in_repr The XML representation describing the widget. + * @param in_ext The extension the widget belongs to. + * @return a pointer to a new Widget if applicable, null otherwise.. + */ + static InxWidget *make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Extension *in_ext); + + /** Checks if name is a valid widget name, i.e. a widget can be constructed from it using make() */ + static bool is_valid_widget_name(const char *name); + + /** Return the instance's GTK::Widget representation for usage in a GUI + * + * @param changeSignal Can be used to subscribe to parameter changes. + * Will be emitted whenever a parameter value changes. + * + * @teturn A Gtk::Widget for the \a InxWidget. \c nullptr if the widget is hidden. + */ + virtual Gtk::Widget *get_widget(sigc::signal<void> *changeSignal); + + virtual const char *get_tooltip() const { return nullptr; } // tool-tips are exclusive to InxParameters for now + + /** Indicates if the widget is hidden or not */ + bool get_hidden() const { return _hidden; } + + /** Indentation level of the widget */ + int get_indent() const { return _indent; } + + + /** + * Recursively construct a list containing the current widget and all of it's child widgets (if it has any) + * + * @param list Reference to a vector of pointers to \a InxWidget that will be appended with the new \a InxWidgets + */ + virtual void get_widgets(std::vector<InxWidget *> &list); + + + /** Recommended margin of boxes containing multiple widgets (in px) */ + const static int GUI_BOX_MARGIN = 10; + /** Recommended spacing between multiple widgets packed into a box (in px) */ + const static int GUI_BOX_SPACING = 4; + /** Recommended indentation width of widgets(in px) */ + const static int GUI_INDENTATION = 12; + /** Recommended maximum line length for wrapping textual wdgets (in chars) */ + const static int GUI_MAX_LINE_LENGTH = 60; + +protected: + enum Translatable { + UNSET, YES, NO + }; + + /** Which extension is this Widget attached to. */ + Inkscape::Extension::Extension *_extension = nullptr; + + /** Child widgets of this widget (might be empty if there are none) */ + std::vector<InxWidget *> _children; + + /** Whether the widget is visible. */ + bool _hidden = false; + + /** Indentation level of the widget. */ + int _indent = 0; + + /** Appearance of the widget (not used by all widgets). */ + char *_appearance = nullptr; + + /** Is widget translatable? */ + Translatable _translatable = UNSET; + + /** context for translation of translatable strings. */ + char *_context = nullptr; + + + /* **** member functions **** */ + + /** gets the gettext translation for msgid + * + * Handles translation domain of the extension and message context of the widget internally + * + * @param msgid String to translate + * @return Translated string + */ + const char *get_translation(const char* msgid); +}; + +} // namespace Extension +} // namespace Inkscape + +#endif // SEEN_INK_EXTENSION_WIDGET_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/extension/print.cpp b/src/extension/print.cpp index 32fb5ea2c..d9f7406ae 100644 --- a/src/extension/print.cpp +++ b/src/extension/print.cpp @@ -16,8 +16,8 @@ namespace Inkscape { namespace Extension { -Print::Print (Inkscape::XML::Node *in_repr, Implementation::Implementation *in_imp) - : Extension(in_repr, in_imp) +Print::Print (Inkscape::XML::Node *in_repr, Implementation::Implementation *in_imp, std::string *base_directory) + : Extension(in_repr, in_imp, base_directory) , base(nullptr) , drawing(nullptr) , root(nullptr) diff --git a/src/extension/print.h b/src/extension/print.h index aaad3cf4e..56ec36700 100644 --- a/src/extension/print.h +++ b/src/extension/print.h @@ -33,10 +33,10 @@ public: /* TODO: These are public for the short term, but this should be fixed * unsigned int dkey; public: - Print (Inkscape::XML::Node * in_repr, - Implementation::Implementation * in_imp); - ~Print () override; - bool check () override; + Print(Inkscape::XML::Node *in_repr, Implementation::Implementation *in_imp, std::string *base_directory); + ~Print() override; + + bool check() override; /* FALSE means user hit cancel */ unsigned int setup (); diff --git a/src/extension/system.cpp b/src/extension/system.cpp index 05a62884c..e81a7f973 100644 --- a/src/extension/system.cpp +++ b/src/extension/system.cpp @@ -508,31 +508,38 @@ build_from_reprdoc(Inkscape::XML::Document *doc, Implementation::Implementation } Extension *module = nullptr; - switch (module_functional_type) { - case MODULE_INPUT: { - module = new Input(repr, imp); - break; - } - case MODULE_OUTPUT: { - module = new Output(repr, imp); - break; - } - case MODULE_FILTER: { - module = new Effect(repr, imp); - break; - } - case MODULE_PRINT: { - module = new Print(repr, imp); - break; - } - case MODULE_PATH_EFFECT: { - module = new PathEffect(repr, imp); - break; - } - default: { - module = new Extension(repr, imp); - break; + try { + switch (module_functional_type) { + case MODULE_INPUT: { + module = new Input(repr, imp, baseDir); + break; + } + case MODULE_OUTPUT: { + module = new Output(repr, imp, baseDir); + break; + } + case MODULE_FILTER: { + module = new Effect(repr, imp, baseDir); + break; + } + case MODULE_PRINT: { + module = new Print(repr, imp, baseDir); + break; + } + case MODULE_PATH_EFFECT: { + module = new PathEffect(repr, imp, baseDir); + break; + } + default: { + g_warning("Extension of unknown type!"); // TODO: Should not happen! Is this even useful? + module = new Extension(repr, imp, baseDir); + break; + } } + } catch (const Extension::extension_no_id& e) { + g_warning("Building extension failed. Extension does not have a valid ID"); + } catch (const Extension::extension_no_name& e) { + g_warning("Building extension failed. Extension does not have a valid name"); } return module; @@ -552,10 +559,10 @@ build_from_file(gchar const *filename) Inkscape::XML::Document *doc = sp_repr_read_file(filename, INKSCAPE_EXTENSION_URI); std::string dir = Glib::path_get_dirname(filename); Extension *ext = build_from_reprdoc(doc, nullptr, &dir); - if (ext != nullptr) - Inkscape::GC::release(doc); - else + Inkscape::GC::release(doc); + if (!ext) { g_warning("Unable to create extension from definition file %s.\n", filename); + } return ext; } @@ -646,7 +653,7 @@ get_file_save_path (SPDocument *doc, FileSaveMethod method) { } break; case FILE_SAVE_METHOD_EXPORT: - /// \todo no default path set for Export? + /// \todo no default path set for Export? // defaults to g_get_home_dir() break; } diff --git a/src/file.cpp b/src/file.cpp index 6b8e52c45..a8ff49cb6 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -827,10 +827,10 @@ sp_file_save_template(Gtk::Window &parentWindow, Glib::ustring name, auto root = document->getReprRoot(); auto xml_doc = document->getReprDoc(); - auto templateinfo_node = xml_doc->createElement("inkscape:_templateinfo"); + auto templateinfo_node = xml_doc->createElement("inkscape:templateinfo"); Inkscape::GC::release(templateinfo_node); - auto element_node = xml_doc->createElement("inkscape:_name"); + auto element_node = xml_doc->createElement("inkscape:name"); Inkscape::GC::release(element_node); element_node->appendChild(xml_doc->createTextNode(name.c_str())); @@ -847,7 +847,7 @@ sp_file_save_template(Gtk::Window &parentWindow, Glib::ustring name, if (description.length() != 0) { - element_node = xml_doc->createElement("inkscape:_shortdesc"); + element_node = xml_doc->createElement("inkscape:shortdesc"); Inkscape::GC::release(element_node); element_node->appendChild(xml_doc->createTextNode(description.c_str())); @@ -864,7 +864,7 @@ sp_file_save_template(Gtk::Window &parentWindow, Glib::ustring name, if (keywords.length() != 0) { - element_node = xml_doc->createElement("inkscape:_keywords"); + element_node = xml_doc->createElement("inkscape:keywords"); Inkscape::GC::release(element_node); element_node->appendChild(xml_doc->createTextNode(keywords.c_str())); @@ -888,7 +888,7 @@ sp_file_save_template(Gtk::Window &parentWindow, Glib::ustring name, Inkscape::Extension::FILE_SAVE_METHOD_INKSCAPE_SVG); if (isDefault) { - // save as "default.svg" by default (so it works intependent of UI language)unless + // save as "default.svg" by default (so it works independently of UI language), unless // a localized template like "default.de.svg" is already present (which overrides "default.svg") Glib::ustring default_svg_localized = Glib::ustring("default.") + _("en") + ".svg"; filename = Inkscape::IO::Resource::get_path_ustring(USER, TEMPLATES, default_svg_localized.c_str()); diff --git a/src/io/file-export-cmd.cpp b/src/io/file-export-cmd.cpp index 9af2d61ac..bf1d72a75 100644 --- a/src/io/file-export-cmd.cpp +++ b/src/io/file-export-cmd.cpp @@ -611,12 +611,12 @@ InkFileExportCmd::do_export_ps_pdf(SPDocument* doc, std::string filename_in, std const gchar *pdfver_param_name = "PDFversion"; if (!export_pdf_level.empty()) { // combine "PDF " and the given command line - std::string version_gui_string = std::string("PDF ") + export_pdf_level; - try{ + std::string version_gui_string = std::string("PDF-") + export_pdf_level; + try { // first, check if the given pdf version is selectable in the ComboBox - if((*i)->get_param_enum_contains("PDFversion", version_gui_string.c_str())) { - (*i)->set_param_enum(pdfver_param_name, version_gui_string.c_str()); - set_export_pdf_version_fail=false; + if ((*i)->get_param_optiongroup_contains("PDFversion", version_gui_string.c_str())) { + (*i)->set_param_optiongroup(pdfver_param_name, version_gui_string.c_str()); + set_export_pdf_version_fail = false; } else { g_warning("Desired PDF export version \"%s\" not supported! Hint: input one of the versions found in the pdf export dialog e.g. \"1.4\".", export_pdf_level.c_str()); @@ -631,7 +631,7 @@ InkFileExportCmd::do_export_ps_pdf(SPDocument* doc, std::string filename_in, std // set default pdf export version to 1.4, also if something went wrong if(set_export_pdf_version_fail) { - (*i)->set_param_enum(pdfver_param_name, "PDF 1.4"); + (*i)->set_param_optiongroup(pdfver_param_name, "PDF-1.4"); } } @@ -642,8 +642,7 @@ InkFileExportCmd::do_export_ps_pdf(SPDocument* doc, std::string filename_in, std export_ps_level = 2; } - (*i)->set_param_enum("PSlevel", (export_ps_level == 3) - ? "PostScript level 3" : "PostScript level 2"); + (*i)->set_param_optiongroup("PSlevel", (export_ps_level == 3) ? "PS3" : "PS2"); } diff --git a/src/io/file.cpp b/src/io/file.cpp index a87453d47..6317622bb 100644 --- a/src/io/file.cpp +++ b/src/io/file.cpp @@ -8,11 +8,11 @@ * */ +#include "file.h" + #include <iostream> #include <gtkmm.h> -#include "file.h" - #include "document.h" #include "document-undo.h" @@ -24,6 +24,9 @@ #include "object/sp-root.h" +#include "xml/repr.h" + + /** * Create a blank document, remove any template data. * Input: Empty string or template file name. @@ -36,7 +39,15 @@ ink_file_new(const std::string &Template) if (doc) { // Remove all the template info from xml tree Inkscape::XML::Node *myRoot = doc->getReprRoot(); - Inkscape::XML::Node *nodeToRemove = sp_repr_lookup_name(myRoot, "inkscape:_templateinfo"); + Inkscape::XML::Node *nodeToRemove; + + nodeToRemove = sp_repr_lookup_name(myRoot, "inkscape:templateinfo"); + if (nodeToRemove != nullptr) { + Inkscape::DocumentUndo::ScopedInsensitive no_undo(doc); + sp_repr_unparent(nodeToRemove); + delete nodeToRemove; + } + nodeToRemove = sp_repr_lookup_name(myRoot, "inkscape:_templateinfo"); // backwards-compatibility if (nodeToRemove != nullptr) { Inkscape::DocumentUndo::ScopedInsensitive no_undo(doc); sp_repr_unparent(nodeToRemove); diff --git a/src/io/file.h b/src/io/file.h index 3b53bce4f..1767de2a0 100644 --- a/src/io/file.h +++ b/src/io/file.h @@ -11,6 +11,19 @@ #ifndef INK_FILE_IO_H #define INK_FILE_IO_H +#include <string> + +namespace Gio { +class File; +} + +namespace Glib { +class ustring; + +template <class T> +class RefPtr; +} + class SPDocument; SPDocument* ink_file_new(const std::string &Template = nullptr); diff --git a/src/object/sp-factory.cpp b/src/object/sp-factory.cpp index cc635752e..e773354f2 100644 --- a/src/object/sp-factory.cpp +++ b/src/object/sp-factory.cpp @@ -315,7 +315,7 @@ SPObject *SPFactory::createObject(std::string const& id) {} else if (id == "inkscape:clipboard") // SP node not necessary {} - else if (id == "inkscape:_templateinfo") // ? + else if (id == "inkscape:templateinfo" || id == "inkscape:_templateinfo") // metadata for templates {} else if (id.empty()) // comments {} diff --git a/src/ui/dialog/extension-editor.cpp b/src/ui/dialog/extension-editor.cpp index e324afcc7..1852010a0 100644 --- a/src/ui/dialog/extension-editor.cpp +++ b/src/ui/dialog/extension-editor.cpp @@ -41,7 +41,6 @@ ExtensionEditor::ExtensionEditor() : UI::Widget::Panel("/dialogs/extensioneditor", SP_VERB_DIALOG_EXTENSIONEDITOR) { _notebook_info.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); - _notebook_help.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); _notebook_params.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); //Main HBox @@ -73,7 +72,6 @@ ExtensionEditor::ExtensionEditor() hbox_list_page->pack_start(*vbox_page, true, true, 0); Gtk::Notebook * notebook = Gtk::manage(new Gtk::Notebook()); notebook->append_page(_notebook_info, *Gtk::manage(new Gtk::Label(_("Information")))); - notebook->append_page(_notebook_help, *Gtk::manage(new Gtk::Label(_("Help")))); notebook->append_page(_notebook_params, *Gtk::manage(new Gtk::Label(_("Parameters")))); vbox_page->pack_start(*notebook, true, true, 0); @@ -140,19 +138,16 @@ void ExtensionEditor::on_pagelist_selection_changed() /* Clear the notbook pages */ _notebook_info.remove(); - _notebook_help.remove(); _notebook_params.remove(); Inkscape::Extension::Extension * ext = Inkscape::Extension::db.get(id.c_str()); /* Make sure we have all the widgets */ Gtk::Widget * info = nullptr; - Gtk::Widget * help = nullptr; Gtk::Widget * params = nullptr; if (ext != nullptr) { info = ext->get_info_widget(); - help = ext->get_help_widget(); params = ext->get_params_widget(); } @@ -160,9 +155,6 @@ void ExtensionEditor::on_pagelist_selection_changed() if (info != nullptr) { _notebook_info.add(*info); } - if (help != nullptr) { - _notebook_help.add(*help); - } if (params != nullptr) { _notebook_params.add(*params); } diff --git a/src/ui/dialog/extension-editor.h b/src/ui/dialog/extension-editor.h index e9c45e209..403ee1fb5 100644 --- a/src/ui/dialog/extension-editor.h +++ b/src/ui/dialog/extension-editor.h @@ -33,8 +33,6 @@ public: static ExtensionEditor &getInstance() { return *new ExtensionEditor(); } - static void show_help (gchar const * extension_id); - protected: /** \brief The view of the list of extensions on the left of the dialog */ Gtk::TreeView _page_list; @@ -42,8 +40,6 @@ protected: Glib::RefPtr<Gtk::TreeStore> _page_list_model; /** \brief The notebook page that contains information */ Gtk::ScrolledWindow _notebook_info; - /** \brief The notebook page that contains help info */ - Gtk::ScrolledWindow _notebook_help; /** \brief The notebook page that holds all the parameters */ Gtk::ScrolledWindow _notebook_params; @@ -68,8 +64,8 @@ private: an item in the extension list */ Glib::ustring _selection_search; - ExtensionEditor(ExtensionEditor const &d); - ExtensionEditor& operator=(ExtensionEditor const &d); + ExtensionEditor(ExtensionEditor const &d) = delete; + ExtensionEditor& operator=(ExtensionEditor const &d) = delete; void on_pagelist_selection_changed(); static void dbfunc (Inkscape::Extension::Extension * in_plug, gpointer in_data); diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index de6b18489..5874cac19 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -330,7 +330,7 @@ void FileOpenDialogImplGtk::createFilterMenu() Glib::ustring extension = imod->get_extension(); fileDialogExtensionToPattern(upattern, extension); - Glib::ustring uname(_(imod->get_filetypename())); + Glib::ustring uname(imod->get_filetypename(true)); auto filter = Gtk::FileFilter::create(); filter->set_name(uname); @@ -624,10 +624,10 @@ void FileSaveDialogImplGtk::fileTypeChangedCallback() auto filter = Gtk::FileFilter::create(); filter->add_pattern(type.pattern); set_filter(filter); - + if (fromCB) { //do not update if called from a name change - fromCB = false; + fromCB = false; return; } @@ -642,7 +642,7 @@ void FileSaveDialogImplGtk::fileNameChanged() { if (extension && Glib::ustring(dynamic_cast<Inkscape::Extension::Output *>(extension)->get_extension()).casefold() == ext ) return; if (knownExtensions.find(ext) == knownExtensions.end()) return; fromCB = true; - fileTypeComboBox.set_active_text(_(knownExtensions[ext]->get_filetypename())); + fileTypeComboBox.set_active_text(knownExtensions[ext]->get_filetypename(true)); } void FileSaveDialogImplGtk::addFileType(Glib::ustring name, Glib::ustring pattern) @@ -672,7 +672,7 @@ void FileSaveDialogImplGtk::createFileTypeMenu() continue; FileType type; - type.name = (_(omod->get_filetypename())); + type.name = omod->get_filetypename(true); type.pattern = "*"; Glib::ustring extension = omod->get_extension(); knownExtensions.insert(std::pair<Glib::ustring, Inkscape::Extension::Output*>(extension.casefold(), omod)); diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index 3964091cc..bd66b2d40 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -247,7 +247,7 @@ void FileOpenDialogImplWin32::createFilterMenu() int extension_index = 0; int filter_length = 1; - + if (dialogType == CUSTOM_TYPE) { return; } @@ -281,13 +281,11 @@ void FileOpenDialogImplWin32::createFilterMenu() if (imod->deactivated()) continue; // Type - filter.name = g_utf8_to_utf16(_(imod->get_filetypename()), - -1, NULL, &filter.name_length, NULL); + filter.name = g_utf8_to_utf16(imod->get_filetypename(true), -1, NULL, &filter.name_length, NULL); // Extension const gchar *file_extension_name = imod->get_extension(); - filter.filter = g_utf8_to_utf16(file_extension_name, - -1, NULL, &filter.filter_length, NULL); + filter.filter = g_utf8_to_utf16(file_extension_name, -1, NULL, &filter.filter_length, NULL); filter.mod = imod; filter_list.push_back(filter); @@ -309,7 +307,7 @@ void FileOpenDialogImplWin32::createFilterMenu() // I don't know of any other way to define "bitmap" formats other than by listing them // if you change it here, do the same change in filedialogimpl-gtkmm - if ( + if ( strncmp("image/png", imod->get_mimetype(), 9)==0 || strncmp("image/jpeg", imod->get_mimetype(), 10)==0 || strncmp("image/gif", imod->get_mimetype(), 9)==0 || @@ -322,7 +320,7 @@ void FileOpenDialogImplWin32::createFilterMenu() strncmp("image/tiff", imod->get_mimetype(), 10)==0 || strncmp("image/x-xbitmap", imod->get_mimetype(), 15)==0 || strncmp("image/x-tga", imod->get_mimetype(), 11)==0 || - strncmp("image/x-pcx", imod->get_mimetype(), 11)==0 + strncmp("image/x-pcx", imod->get_mimetype(), 11)==0 ) { if(all_bitmaps_filter.length() > 0) all_bitmaps_filter += ";*"; @@ -396,12 +394,12 @@ void FileOpenDialogImplWin32::createFilterMenu() const gchar *all_files_filter_name = _("All Files"); const gchar *all_exe_files_filter_name = _("All Executable Files"); - + // Calculate the amount of memory required int filter_count = 2; // 2 - All Files and All Executable Files - + _extension_map = new Inkscape::Extension::Extension*[filter_count]; - + // Filter Executable Files all_exe_files.name = g_utf8_to_utf16(all_exe_files_filter_name, -1, NULL, &all_exe_files.name_length, NULL); @@ -417,14 +415,14 @@ void FileOpenDialogImplWin32::createFilterMenu() all_files.filter_length = 0; all_files.mod = NULL; filter_list.push_front(all_files); - + filter_length += all_files.name_length + 3 + all_exe_files.filter_length + all_exe_files.name_length + 3 + 1; // Add 3 for 2*2 \0s and a *, and 1 for a trailing \0 } - + _filter = new wchar_t[filter_length]; wchar_t *filterptr = _filter; @@ -546,11 +544,11 @@ UINT_PTR CALLBACK FileOpenDialogImplWin32::GetOpenFileName_hookproc( SetWindowLongPtr(hdlg, GWLP_USERDATA, ofn->lCustData); SetWindowLongPtr(hParentWnd, GWLP_USERDATA, ofn->lCustData); pImpl = reinterpret_cast<FileOpenDialogImplWin32*>(ofn->lCustData); - + // Make the window a bit wider RECT rcRect; GetWindowRect(hParentWnd, &rcRect); - + // Don't show the preview when opening executable files if ( pImpl->dialogType == EXE_TYPES) { MoveWindow(hParentWnd, rcRect.left, rcRect.top, @@ -577,7 +575,7 @@ UINT_PTR CALLBACK FileOpenDialogImplWin32::GetOpenFileName_hookproc( TBADDBITMAP tbAddBitmap = {NULL, reinterpret_cast<UINT_PTR>(pImpl->_show_preview_button_bitmap)}; const int iBitmapIndex = SendMessage(pImpl->_toolbar_wnd, TB_ADDBITMAP, 1, (LPARAM)&tbAddBitmap); - + TBBUTTON tbButton; memset(&tbButton, 0, sizeof(TBBUTTON)); @@ -604,7 +602,7 @@ UINT_PTR CALLBACK FileOpenDialogImplWin32::GetOpenFileName_hookproc( 0, 0, 100, 100, hParentWnd, NULL, hInstance, NULL); SetWindowLongPtr(pImpl->_preview_wnd, GWLP_USERDATA, ofn->lCustData); } - + pImpl->_mutex->unlock(); pImpl->layout_dialog(); @@ -727,7 +725,7 @@ LRESULT CALLBACK FileOpenDialogImplWin32::preview_wnd_proc(HWND hwnd, UINT uMsg, WCHAR* noFileText=(WCHAR*)g_utf8_to_utf16(_("No file selected"), -1, NULL, NULL, NULL); FillRect(dc, &rcClient, reinterpret_cast<HBRUSH>(COLOR_3DFACE + 1)); - DrawTextW(dc, noFileText, -1, &rcClient, + DrawTextW(dc, noFileText, -1, &rcClient, DT_CENTER | DT_VCENTER | DT_NOPREFIX); g_free(noFileText); } @@ -1592,7 +1590,7 @@ FileSaveDialogImplWin32::FileSaveDialogImplWin32(Gtk::Window &parent, size_t last_slash_index = udir.find_last_of( '\\' ); size_t last_period_index = udir.find_last_of( '.' ); if (last_period_index > last_slash_index) { - myFilename = udir.substr(0, last_period_index ); + myFilename = udir.substr(0, last_period_index ); } } @@ -1638,8 +1636,7 @@ void FileSaveDialogImplWin32::createFilterMenu() knownExtensions.insert(std::pair<Glib::ustring, Inkscape::Extension::Output*>(Glib::ustring(filter_extension).casefold(), omod)); // Type - filter.name = g_utf8_to_utf16( - _(omod->get_filetypename()), -1, NULL, &filter.name_length, NULL); + filter.name = g_utf8_to_utf16(omod->get_filetypename(true), -1, NULL, &filter.name_length, NULL); filter.mod = omod; @@ -1705,7 +1702,7 @@ void FileSaveDialogImplWin32::addFileType(Glib::ustring name, Glib::ustring patt -1, NULL, &all_exe_files.filter_length, NULL); all_exe_files.mod = NULL; filter_list.push_front(all_exe_files); - + filter_length = all_exe_files.name_length + all_exe_files.filter_length + 3; // Add 3 for two \0s and a * knownExtensions.insert(std::pair<Glib::ustring, Inkscape::Extension::Output*>(Glib::ustring(all_exe_files_filter).casefold(), NULL)); @@ -1883,7 +1880,7 @@ UINT_PTR CALLBACK FileSaveDialogImplWin32::GetSaveFileName_hookproc( CW_USEDEFAULT, CW_USEDEFAULT, rCB1.left-rST.left, rST.bottom-rST.top, hParentWnd, NULL, hInstance, NULL); g_free(title_label_str); - + if(pImpl->_title_label) { if(dlgFont) SendMessage(pImpl->_title_label, WM_SETFONT, (WPARAM)dlgFont, MAKELPARAM(FALSE, 0)); SetWindowPos(pImpl->_title_label, NULL, rST.left-rROOT.left, rST.top+ydelta-rROOT.top, diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 6c17a9a96..f290dcab7 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -19,6 +19,7 @@ #include <gtkmm/scrolledwindow.h> #include <iostream> +#include "extension/extension.h" #include "extension/db.h" #include "inkscape.h" #include "file.h" @@ -170,8 +171,7 @@ void TemplateLoadTab::_refreshTemplatesList() if (it.second.keywords.count(_current_keyword.lowercase()) != 0 || it.second.display_name.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos || it.second.author.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos || - it.second.short_description.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos || - it.second.long_description.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos ) + it.second.short_description.lowercase().find(_current_keyword.lowercase()) != Glib::ustring::npos) { Gtk::TreeModel::iterator iter = _tlist_store->append(); Gtk::TreeModel::Row row = *iter; @@ -236,16 +236,19 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const std::s Inkscape::XML::Document *rdoc = sp_repr_read_file(path.data(), SP_SVG_NS_URI); if (rdoc){ - Inkscape::XML::Node *myRoot = rdoc->root(); - if (strcmp(myRoot->name(), "svg:svg") != 0){ // Wrong file format + Inkscape::XML::Node *root = rdoc->root(); + if (strcmp(root->name(), "svg:svg") != 0){ // Wrong file format return result; } - myRoot = sp_repr_lookup_name(myRoot, "inkscape:_templateinfo"); + Inkscape::XML::Node *templateinfo = sp_repr_lookup_name(root, "inkscape:templateinfo"); + if (!templateinfo) { + templateinfo = sp_repr_lookup_name(root, "inkscape:_templateinfo"); // backwards-compatibility + } - if (myRoot == nullptr) // No template info + if (templateinfo == nullptr) // No template info return result; - _getDataFromNode(myRoot, result); + _getDataFromNode(templateinfo, result); } return result; @@ -258,43 +261,61 @@ void TemplateLoadTab::_getProceduralTemplates() std::list<Inkscape::Extension::Effect *>::iterator it = effects.begin(); while (it != effects.end()){ - Inkscape::XML::Node *myRoot; - myRoot = (*it)->get_repr(); - myRoot = sp_repr_lookup_name(myRoot, "inkscape:_templateinfo"); + Inkscape::XML::Node *repr = (*it)->get_repr(); + Inkscape::XML::Node *templateinfo = sp_repr_lookup_name(repr, "inkscape:templateinfo"); + if (!templateinfo) { + templateinfo = sp_repr_lookup_name(repr, "inkscape:_templateinfo"); // backwards-compatibility + } - if (myRoot){ + if (templateinfo){ TemplateData result; result.display_name = (*it)->get_name(); result.is_procedural = true; result.path = ""; result.tpl_effect = *it; - _getDataFromNode(myRoot, result); + _getDataFromNode(templateinfo, result, *it); _tdata[result.display_name] = result; } ++it; } } +// if the template data comes from a procedural template (aka Effect extension), +// attempt to translate within the extension's context (which might use a different gettext textdomain) +const char *_translate(const char* msgid, Extension::Extension *extension) +{ + if (extension) { + return extension->get_translation(msgid); + } else { + return _(msgid); + } +} -void TemplateLoadTab::_getDataFromNode(Inkscape::XML::Node *dataNode, TemplateData &data) +void TemplateLoadTab::_getDataFromNode(Inkscape::XML::Node *dataNode, TemplateData &data, Extension::Extension *extension) { Inkscape::XML::Node *currentData; - if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_name")) != nullptr) - data.display_name = _(currentData->firstChild()->content()); + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:name")) != nullptr) + data.display_name = _translate(currentData->firstChild()->content(), extension); + else if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_name")) != nullptr) // backwards-compatibility + data.display_name = _translate(currentData->firstChild()->content(), extension); + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:author")) != nullptr) data.author = currentData->firstChild()->content(); - if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_shortdesc")) != nullptr) - data.short_description = _( currentData->firstChild()->content()); - if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_long") )!= nullptr) - data.long_description = _(currentData->firstChild()->content()); + + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:shortdesc")) != nullptr) + data.short_description = _translate(currentData->firstChild()->content(), extension); + else if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_shortdesc")) != nullptr) // backwards-compatibility + data.short_description = _translate(currentData->firstChild()->content(), extension); + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:preview")) != nullptr) data.preview_name = currentData->firstChild()->content(); + if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:date")) != nullptr) data.creation_date = currentData->firstChild()->content(); if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_keywords")) != nullptr){ - Glib::ustring tplKeywords = _(currentData->firstChild()->content()); + Glib::ustring tplKeywords = _translate(currentData->firstChild()->content(), extension); while (!tplKeywords.empty()){ std::size_t pos = tplKeywords.find_first_of(" "); if (pos == Glib::ustring::npos) diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h index 037d7782c..2b8f98f12 100644 --- a/src/ui/dialog/template-load-tab.h +++ b/src/ui/dialog/template-load-tab.h @@ -27,11 +27,16 @@ namespace Inkscape { + +namespace Extension { +class Extension; +} + namespace UI { class TemplateWidget; class NewFromTemplate; - + class TemplateLoadTab : public Gtk::HBox { @@ -43,18 +48,18 @@ public: Glib::ustring display_name; Glib::ustring author; Glib::ustring short_description; - Glib::ustring long_description; + Glib::ustring long_description; // unused Glib::ustring preview_name; Glib::ustring creation_date; std::set<Glib::ustring> keywords; Inkscape::Extension::Effect *tpl_effect; }; - + TemplateLoadTab(NewFromTemplate* parent); ~TemplateLoadTab() override; virtual void createTemplate(); -protected: +protected: class StringModelColumns : public Gtk::TreeModelColumnRecord { public: @@ -62,32 +67,32 @@ protected: { add(textValue); } - + Gtk::TreeModelColumn<Glib::ustring> textValue; }; - + Glib::ustring _current_keyword; Glib::ustring _current_template; std::map<Glib::ustring, TemplateData> _tdata; std::set<Glib::ustring> _keywords; - - + + virtual void _displayTemplateInfo(); virtual void _initKeywordsList(); virtual void _refreshTemplatesList(); void _loadTemplates(); void _initLists(); - + Gtk::VBox _tlist_box; Gtk::HBox _search_box; TemplateWidget *_info_widget; - + Gtk::ComboBoxText _keywords_combo; - + Gtk::TreeView _tlist_view; Glib::RefPtr<Gtk::ListStore> _tlist_store; - StringModelColumns _columns; - + StringModelColumns _columns; + private: enum SearchType { @@ -95,16 +100,16 @@ private: USER_SPECIFIED, ALL }; - + SearchType _current_search_type; NewFromTemplate* _parent_widget; - - void _getDataFromNode(Inkscape::XML::Node *, TemplateData &); + + void _getDataFromNode(Inkscape::XML::Node *, TemplateData &, Extension::Extension *extension=nullptr); void _getProceduralTemplates(); void _getTemplatesFromDomain(Inkscape::IO::Resource::Domain domain); - void _keywordSelected(); + void _keywordSelected(); TemplateData _processTemplateFile(const std::string &); - + void _onRowActivated(const Gtk::TreeModel::Path &, Gtk::TreeViewColumn*); }; diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index be94b79c0..e5adaf9e1 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -26,7 +26,7 @@ namespace Inkscape { namespace UI { - + TemplateWidget::TemplateWidget() : _more_info_button(_("More info")) @@ -36,18 +36,18 @@ TemplateWidget::TemplateWidget() { pack_start(_template_name_label, Gtk::PACK_SHRINK, 10); pack_start(_preview_box, Gtk::PACK_SHRINK, 0); - + _preview_box.pack_start(_preview_image, Gtk::PACK_EXPAND_PADDING, 15); _preview_box.pack_start(_preview_render, Gtk::PACK_EXPAND_PADDING, 10); - + _short_description_label.set_line_wrap(true); _more_info_button.set_halign(Gtk::ALIGN_END); _more_info_button.set_valign(Gtk::ALIGN_CENTER); pack_end(_more_info_button, Gtk::PACK_SHRINK); - + pack_end(_short_description_label, Gtk::PACK_SHRINK, 5); - + _more_info_button.signal_clicked().connect( sigc::mem_fun(*this, &TemplateWidget::_displayTemplateDetails)); _more_info_button.set_sensitive(false); @@ -58,7 +58,7 @@ void TemplateWidget::create() { if (_current_template.display_name == "") return; - + if (_current_template.is_procedural){ SPDesktop *desktop = SP_ACTIVE_DESKTOP; SPDesktop *desc = sp_file_new_default(); @@ -98,7 +98,7 @@ void TemplateWidget::display(TemplateLoadTab::TemplateData data) } if (data.is_procedural){ - _effect_prefs = data.tpl_effect->get_imp()->prefs_effect(data.tpl_effect, SP_ACTIVE_DESKTOP, nullptr, nullptr); + _effect_prefs = data.tpl_effect->get_imp()->prefs_effect(data.tpl_effect, SP_ACTIVE_DESKTOP, nullptr, nullptr); pack_start(*_effect_prefs); } _more_info_button.set_sensitive(true); @@ -118,24 +118,32 @@ void TemplateWidget::clear() } void TemplateWidget::_displayTemplateDetails() -{ +{ Glib::ustring message = _current_template.display_name + "\n\n"; - - if (_current_template.path != "") - message += _("Path: ") + _current_template.path + "\n\n"; - - if (_current_template.long_description != "") - message += _("Description: ") + _current_template.long_description + "\n\n"; + + if (!_current_template.author.empty()) { + message += _("Author"); + message += ": "; + message += _current_template.author + " " + _current_template.creation_date + "\n\n"; + } + if (!_current_template.keywords.empty()){ - message += _("Keywords: "); - for (const auto & keyword : _current_template.keywords) - message += keyword + " "; + message += _("Keywords"); + message += ":"; + for (const auto & keyword : _current_template.keywords) { + message += " "; + message += keyword; + } message += "\n\n"; } - - if (_current_template.author != "") - message += _("By: ") + _current_template.author + " " + _current_template.creation_date + "\n\n"; - + + if (!_current_template.path.empty()) { + message += _("Path"); + message += ": "; + message += _current_template.path; + message += "\n\n"; + } + Gtk::MessageDialog dl(message, false, Gtk::MESSAGE_OTHER); dl.run(); } diff --git a/src/ui/selected-color.h b/src/ui/selected-color.h index 6bb426b7f..1a00fc5cf 100644 --- a/src/ui/selected-color.h +++ b/src/ui/selected-color.h @@ -14,7 +14,9 @@ #ifndef SEEN_SELECTED_COLOR #define SEEN_SELECTED_COLOR +#include <glib.h> #include <sigc++/signal.h> + #include "color.h" namespace Gtk |
