From a65a0a21e5452ced77123a8b846ff10cc1bc74b0 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 12 Feb 2017 15:59:14 +0100 Subject: Extensions: Make "indent" attribute a common attribute for all parameters that behaves more consistent and predictable than before. - Every "Parameter" now has an "_indent" member variable (specifying the indentation level; set in "Parameter::make()", see parameter.cpp) - Indentation is achieved by using "set_margin_left()" on the parameter's widget. This fixes bug #1662035 (comment #4 contains some more details about this patch). - Specifying "indent" on a parameter will now work consistently for all parameters. Previously the "indent" attribute often had no effect at all, e.g. for notebooks but also for parameters with 'appearance="full"' which was reasonable in most cases but made the outcome of using this attribute often unpredictable and is unnecessarily restrictive. - Most visible change: "description"s always used an indentation level of at least one (even if no indentation was specified). For the sake of consistency this discrepancy was dropped. Previous appearance can easily be restored by setting 'indent="1"'. Fixed bugs: - https://launchpad.net/bugs/1662035 (bzr r15508) --- src/extension/param/parameter.cpp | 43 +++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 15 deletions(-) (limited to 'src/extension/param/parameter.cpp') diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index a5632a39a..c8b30863b 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -78,6 +78,17 @@ Parameter *Parameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex /* else stays false */ } } + int indent = 0; + { + const char *indent_attr = in_repr->attribute("indent"); + if (indent_attr != NULL) { + if (strcmp(indent_attr, "true") == 0) { + indent = 1; + } else { + indent = atoi(indent_attr); + } + } + } const gchar* appearance = in_repr->attribute("appearance"); Parameter::_scope_t scope = Parameter::SCOPE_USER; @@ -96,21 +107,21 @@ Parameter *Parameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex Parameter * param = NULL; if (!strcmp(type, "boolean")) { - param = new ParamBool(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); + param = new ParamBool(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr); } else if (!strcmp(type, "int")) { if (appearance && !strcmp(appearance, "full")) { - param = new ParamInt(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamInt::FULL); + param = new ParamInt(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr, ParamInt::FULL); } else { - param = new ParamInt(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamInt::MINIMAL); + param = new ParamInt(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr, ParamInt::MINIMAL); } } else if (!strcmp(type, "float")) { if (appearance && !strcmp(appearance, "full")) { - param = new ParamFloat(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamFloat::FULL); + param = new ParamFloat(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr, ParamFloat::FULL); } else { - param = new ParamFloat(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamFloat::MINIMAL); + param = new ParamFloat(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr, ParamFloat::MINIMAL); } } else if (!strcmp(type, "string")) { - param = new ParamString(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); + param = new ParamString(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr); gchar const * max_length = in_repr->attribute("max_length"); if (max_length != NULL) { ParamString * ps = dynamic_cast(param); @@ -118,22 +129,22 @@ Parameter *Parameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex } } else if (!strcmp(type, "description")) { if (appearance && !strcmp(appearance, "header")) { - param = new ParamDescription(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamDescription::HEADER); + param = new ParamDescription(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr, ParamDescription::HEADER); } else { - param = new ParamDescription(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamDescription::DESC); - } + param = new ParamDescription(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr, ParamDescription::DESC); + } } else if (!strcmp(type, "enum")) { - param = new ParamComboBox(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); + param = new ParamComboBox(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr); } else if (!strcmp(type, "notebook")) { - param = new ParamNotebook(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); + param = new ParamNotebook(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr); } else if (!strcmp(type, "optiongroup")) { if (appearance && !strcmp(appearance, "minimal")) { - param = new ParamRadioButton(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamRadioButton::MINIMAL); + param = new ParamRadioButton(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr, ParamRadioButton::MINIMAL); } else { - param = new ParamRadioButton(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamRadioButton::FULL); + param = new ParamRadioButton(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr, ParamRadioButton::FULL); } } else if (!strcmp(type, "color")) { - param = new ParamColor(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); + param = new ParamColor(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr); } // Note: param could equal NULL @@ -280,12 +291,13 @@ Parameter::set_color (guint32 in, SPDocument * doc, Inkscape::XML::Node * node) /** Oop, now that we need a parameter, we need it's name. */ -Parameter::Parameter(gchar const * name, gchar const * guitext, gchar const * desc, const Parameter::_scope_t scope, bool gui_hidden, gchar const * gui_tip, Inkscape::Extension::Extension * ext) : +Parameter::Parameter(gchar const * name, gchar const * guitext, gchar const * desc, const Parameter::_scope_t scope, bool gui_hidden, gchar const * gui_tip, int indent, Inkscape::Extension::Extension * ext) : _desc(0), _scope(scope), _text(0), _gui_hidden(gui_hidden), _gui_tip(0), + _indent(indent), extension(ext), _name(0) { @@ -316,6 +328,7 @@ Parameter::Parameter (gchar const * name, gchar const * guitext, Inkscape::Exten _text(0), _gui_hidden(false), _gui_tip(0), + _indent(0), extension(ext), _name(0) { -- cgit v1.2.3 From 435717a3469ebb96ce8b8d30fc50d6151f9cbfbb Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Mon, 13 Feb 2017 22:35:48 +0100 Subject: Extensions: Do not require name for pure UI elements (i.e. parameters that do not store a value and therefore do not need to have a name) (bzr r15515) --- src/extension/param/parameter.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/extension/param/parameter.cpp') diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index c8b30863b..9fbe662f7 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -50,10 +50,17 @@ Parameter *Parameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex const char *name = in_repr->attribute("name"); const char *type = in_repr->attribute("type"); - // In this case we just don't have enough information - if (!name || !type) { + // we can't create a parameter without type + if (!type) { return NULL; } + // also require name unless it's a pure UI element that does not store its value + if (!name) { + static std::vector ui_elements = {"description"}; + if (std::find(ui_elements.begin(), ui_elements.end(), type) == ui_elements.end()) { + return NULL; + } + } const char *guitext = in_repr->attribute("gui-text"); if (guitext == NULL) { -- cgit v1.2.3 From 24d66b5173963dcb69545614449de91da5397db6 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Tue, 14 Feb 2017 00:42:11 +0100 Subject: Extensions: Add 'appearance="url"' to desccription parameters. It allows to create and add a clickable plain text link to extensions The description parameter's text is escaped and converted to a URL as-is preventing potential security issues The Scour extension shows a first example implementation (bzr r15519) --- src/extension/param/parameter.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/extension/param/parameter.cpp') diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index 9fbe662f7..0eb491078 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -135,11 +135,15 @@ Parameter *Parameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex ps->setMaxLength(atoi(max_length)); } } else if (!strcmp(type, "description")) { - if (appearance && !strcmp(appearance, "header")) { - param = new ParamDescription(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr, ParamDescription::HEADER); - } else { - param = new ParamDescription(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr, ParamDescription::DESC); + ParamDescription::AppearanceMode appearance_mode = ParamDescription::DESC; + if (appearance) { + if (!strcmp(appearance, "header")) { + appearance_mode = ParamDescription::HEADER; + } else if (!strcmp(appearance, "url")) { + appearance_mode = ParamDescription::URL; + } } + param = new ParamDescription(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr, appearance_mode); } else if (!strcmp(type, "enum")) { param = new ParamComboBox(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr); } else if (!strcmp(type, "notebook")) { -- cgit v1.2.3 From bab6dfe02bd9556c931973a272e154251764e88e Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Mon, 24 Apr 2017 20:59:06 +0200 Subject: Restore r14955 which was reverted in r15047 due to messed up merge http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/revision/14955 http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/revision/15047 Fixed bugs: - https://launchpad.net/bugs/1669951 (bzr r15633) --- src/extension/param/parameter.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/extension/param/parameter.cpp') diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index 0eb491078..2c72c61df 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -20,6 +20,7 @@ #endif #include +#include #include "ui/widget/color-notebook.h" #include @@ -65,6 +66,16 @@ Parameter *Parameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex const char *guitext = in_repr->attribute("gui-text"); if (guitext == NULL) { guitext = in_repr->attribute("_gui-text"); + if (guitext == NULL) { + // guitext = ""; // propably 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 != NULL) { + guitext = g_dpgettext2(NULL, context, guitext); + } else { + guitext = _(guitext); + } + } } const char *gui_tip = in_repr->attribute("gui-tip"); if (gui_tip == NULL) { -- cgit v1.2.3 From 34a1f9ad048c2aec2149e0bdaca5e66fca8de442 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 9 Apr 2017 15:20:24 +0200 Subject: Remove unused field "gui_tip" ("gui_description" does now what "gui_tip" was supposed to do) (bzr r15633.1.1) --- src/extension/param/parameter.cpp | 40 ++++++++++++++------------------------- 1 file changed, 14 insertions(+), 26 deletions(-) (limited to 'src/extension/param/parameter.cpp') diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index 2c72c61df..a0488142e 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -77,10 +77,6 @@ Parameter *Parameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex } } } - const char *gui_tip = in_repr->attribute("gui-tip"); - if (gui_tip == NULL) { - gui_tip = in_repr->attribute("_gui-tip"); - } const char *desc = in_repr->attribute("gui-description"); if (desc == NULL) { desc = in_repr->attribute("_gui-description"); @@ -125,21 +121,21 @@ Parameter *Parameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex Parameter * param = NULL; if (!strcmp(type, "boolean")) { - param = new ParamBool(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr); + param = new ParamBool(name, guitext, desc, scope, gui_hidden, indent, in_ext, in_repr); } else if (!strcmp(type, "int")) { if (appearance && !strcmp(appearance, "full")) { - param = new ParamInt(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr, ParamInt::FULL); + param = new ParamInt(name, guitext, desc, scope, gui_hidden, indent, in_ext, in_repr, ParamInt::FULL); } else { - param = new ParamInt(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr, ParamInt::MINIMAL); + param = new ParamInt(name, guitext, desc, scope, gui_hidden, indent, in_ext, in_repr, ParamInt::MINIMAL); } } else if (!strcmp(type, "float")) { if (appearance && !strcmp(appearance, "full")) { - param = new ParamFloat(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr, ParamFloat::FULL); + param = new ParamFloat(name, guitext, desc, scope, gui_hidden, indent, in_ext, in_repr, ParamFloat::FULL); } else { - param = new ParamFloat(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr, ParamFloat::MINIMAL); + param = new ParamFloat(name, guitext, desc, scope, gui_hidden, indent, in_ext, in_repr, ParamFloat::MINIMAL); } } else if (!strcmp(type, "string")) { - param = new ParamString(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr); + param = new ParamString(name, guitext, desc, scope, gui_hidden, indent, in_ext, in_repr); gchar const * max_length = in_repr->attribute("max_length"); if (max_length != NULL) { ParamString * ps = dynamic_cast(param); @@ -154,19 +150,19 @@ Parameter *Parameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex appearance_mode = ParamDescription::URL; } } - param = new ParamDescription(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr, appearance_mode); + param = new ParamDescription(name, guitext, desc, scope, gui_hidden, indent, in_ext, in_repr, appearance_mode); } else if (!strcmp(type, "enum")) { - param = new ParamComboBox(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr); + param = new ParamComboBox(name, guitext, desc, scope, gui_hidden, indent, in_ext, in_repr); } else if (!strcmp(type, "notebook")) { - param = new ParamNotebook(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr); + param = new ParamNotebook(name, guitext, desc, scope, gui_hidden, indent, in_ext, in_repr); } else if (!strcmp(type, "optiongroup")) { if (appearance && !strcmp(appearance, "minimal")) { - param = new ParamRadioButton(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr, ParamRadioButton::MINIMAL); + param = new ParamRadioButton(name, guitext, desc, scope, gui_hidden, indent, in_ext, in_repr, ParamRadioButton::MINIMAL); } else { - param = new ParamRadioButton(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr, ParamRadioButton::FULL); + param = new ParamRadioButton(name, guitext, desc, scope, gui_hidden, indent, in_ext, in_repr, ParamRadioButton::FULL); } } else if (!strcmp(type, "color")) { - param = new ParamColor(name, guitext, desc, scope, gui_hidden, gui_tip, indent, in_ext, in_repr); + param = new ParamColor(name, guitext, desc, scope, gui_hidden, indent, in_ext, in_repr); } // Note: param could equal NULL @@ -313,12 +309,11 @@ Parameter::set_color (guint32 in, SPDocument * doc, Inkscape::XML::Node * node) /** Oop, now that we need a parameter, we need it's name. */ -Parameter::Parameter(gchar const * name, gchar const * guitext, gchar const * desc, const Parameter::_scope_t scope, bool gui_hidden, gchar const * gui_tip, int indent, Inkscape::Extension::Extension * ext) : +Parameter::Parameter(gchar const * name, gchar const * guitext, gchar const * desc, const Parameter::_scope_t scope, bool gui_hidden, int indent, Inkscape::Extension::Extension * ext) : _desc(0), _scope(scope), _text(0), _gui_hidden(gui_hidden), - _gui_tip(0), _indent(indent), extension(ext), _name(0) @@ -326,12 +321,9 @@ Parameter::Parameter(gchar const * name, gchar const * guitext, gchar const * de if (name != NULL) { _name = g_strdup(name); } + if (desc != NULL) { _desc = g_strdup(desc); -// printf("Adding description: '%s' on '%s'\n", _desc, _name); - } - if (gui_tip != NULL) { - _gui_tip = g_strdup(gui_tip); } if (guitext != NULL) { @@ -349,7 +341,6 @@ Parameter::Parameter (gchar const * name, gchar const * guitext, Inkscape::Exten _scope(Parameter::SCOPE_USER), _text(0), _gui_hidden(false), - _gui_tip(0), _indent(0), extension(ext), _name(0) @@ -374,9 +365,6 @@ Parameter::~Parameter(void) g_free(_text); _text = 0; - g_free(_gui_tip); - _gui_tip = 0; - g_free(_desc); _desc = 0; } -- cgit v1.2.3 From f0ad38f6fd0d18f48d92df4b55ff8352747e6b2c Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 9 Apr 2017 15:39:40 +0200 Subject: Remove unused field "scope" (bzr r15633.1.2) --- src/extension/param/parameter.cpp | 42 ++++++++++++--------------------------- 1 file changed, 13 insertions(+), 29 deletions(-) (limited to 'src/extension/param/parameter.cpp') diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index a0488142e..8d77830c4 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -105,37 +105,23 @@ Parameter *Parameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex } const gchar* appearance = in_repr->attribute("appearance"); - Parameter::_scope_t scope = Parameter::SCOPE_USER; - { - const char *scope_str = in_repr->attribute("scope"); - if (scope_str != NULL) { - if (!strcmp(scope_str, "user")) { - scope = Parameter::SCOPE_USER; - } else if (!strcmp(scope_str, "document")) { - scope = Parameter::SCOPE_DOCUMENT; - } else if (!strcmp(scope_str, "node")) { - scope = Parameter::SCOPE_NODE; - } - } - } - Parameter * param = NULL; if (!strcmp(type, "boolean")) { - param = new ParamBool(name, guitext, desc, scope, gui_hidden, indent, in_ext, in_repr); + param = new ParamBool(name, guitext, desc, gui_hidden, indent, in_ext, in_repr); } else if (!strcmp(type, "int")) { if (appearance && !strcmp(appearance, "full")) { - param = new ParamInt(name, guitext, desc, scope, gui_hidden, indent, in_ext, in_repr, ParamInt::FULL); + param = new ParamInt(name, guitext, desc, gui_hidden, indent, in_ext, in_repr, ParamInt::FULL); } else { - param = new ParamInt(name, guitext, desc, scope, gui_hidden, indent, in_ext, in_repr, ParamInt::MINIMAL); + param = new ParamInt(name, guitext, desc, gui_hidden, indent, in_ext, in_repr, ParamInt::MINIMAL); } } else if (!strcmp(type, "float")) { if (appearance && !strcmp(appearance, "full")) { - param = new ParamFloat(name, guitext, desc, scope, gui_hidden, indent, in_ext, in_repr, ParamFloat::FULL); + param = new ParamFloat(name, guitext, desc, gui_hidden, indent, in_ext, in_repr, ParamFloat::FULL); } else { - param = new ParamFloat(name, guitext, desc, scope, gui_hidden, indent, in_ext, in_repr, ParamFloat::MINIMAL); + param = new ParamFloat(name, guitext, desc, gui_hidden, indent, in_ext, in_repr, ParamFloat::MINIMAL); } } else if (!strcmp(type, "string")) { - param = new ParamString(name, guitext, desc, scope, gui_hidden, indent, in_ext, in_repr); + param = new ParamString(name, guitext, desc, gui_hidden, indent, in_ext, in_repr); gchar const * max_length = in_repr->attribute("max_length"); if (max_length != NULL) { ParamString * ps = dynamic_cast(param); @@ -150,19 +136,19 @@ Parameter *Parameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex appearance_mode = ParamDescription::URL; } } - param = new ParamDescription(name, guitext, desc, scope, gui_hidden, indent, in_ext, in_repr, appearance_mode); + param = new ParamDescription(name, guitext, desc, gui_hidden, indent, in_ext, in_repr, appearance_mode); } else if (!strcmp(type, "enum")) { - param = new ParamComboBox(name, guitext, desc, scope, gui_hidden, indent, in_ext, in_repr); + param = new ParamComboBox(name, guitext, desc, gui_hidden, indent, in_ext, in_repr); } else if (!strcmp(type, "notebook")) { - param = new ParamNotebook(name, guitext, desc, scope, gui_hidden, indent, in_ext, in_repr); + param = new ParamNotebook(name, guitext, desc, gui_hidden, indent, in_ext, in_repr); } else if (!strcmp(type, "optiongroup")) { if (appearance && !strcmp(appearance, "minimal")) { - param = new ParamRadioButton(name, guitext, desc, scope, gui_hidden, indent, in_ext, in_repr, ParamRadioButton::MINIMAL); + param = new ParamRadioButton(name, guitext, desc, gui_hidden, indent, in_ext, in_repr, ParamRadioButton::MINIMAL); } else { - param = new ParamRadioButton(name, guitext, desc, scope, gui_hidden, indent, in_ext, in_repr, ParamRadioButton::FULL); + param = new ParamRadioButton(name, guitext, desc, gui_hidden, indent, in_ext, in_repr, ParamRadioButton::FULL); } } else if (!strcmp(type, "color")) { - param = new ParamColor(name, guitext, desc, scope, gui_hidden, indent, in_ext, in_repr); + param = new ParamColor(name, guitext, desc, gui_hidden, indent, in_ext, in_repr); } // Note: param could equal NULL @@ -309,9 +295,8 @@ Parameter::set_color (guint32 in, SPDocument * doc, Inkscape::XML::Node * node) /** Oop, now that we need a parameter, we need it's name. */ -Parameter::Parameter(gchar const * name, gchar const * guitext, gchar const * desc, const Parameter::_scope_t scope, bool gui_hidden, int indent, Inkscape::Extension::Extension * ext) : +Parameter::Parameter(gchar const * name, gchar const * guitext, gchar const * desc, bool gui_hidden, int indent, Inkscape::Extension::Extension * ext) : _desc(0), - _scope(scope), _text(0), _gui_hidden(gui_hidden), _indent(indent), @@ -338,7 +323,6 @@ Parameter::Parameter(gchar const * name, gchar const * guitext, gchar const * de /** Oop, now that we need a parameter, we need it's name. */ Parameter::Parameter (gchar const * name, gchar const * guitext, Inkscape::Extension::Extension * ext) : _desc(0), - _scope(Parameter::SCOPE_USER), _text(0), _gui_hidden(false), _indent(0), -- cgit v1.2.3 From bc1ecf9dd11d0b3bb6939114ce6aec229fc86548 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 9 Apr 2017 16:46:33 +0200 Subject: Some code refactoring for consistency (notably "gui_hidden" -> hidden", "guitext" -> "text", "desc" -> "description") (bzr r15633.1.3) --- src/extension/param/parameter.cpp | 88 +++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 44 deletions(-) (limited to 'src/extension/param/parameter.cpp') diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index 8d77830c4..eeffbecf2 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -63,31 +63,31 @@ Parameter *Parameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex } } - const char *guitext = in_repr->attribute("gui-text"); - if (guitext == NULL) { - guitext = in_repr->attribute("_gui-text"); - if (guitext == NULL) { - // guitext = ""; // propably better to require devs to explicitly set an empty gui-text if this is what they want + const char *text = in_repr->attribute("gui-text"); + if (text == NULL) { + text = in_repr->attribute("_gui-text"); + if (text == NULL) { + // text = ""; // propably 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 != NULL) { - guitext = g_dpgettext2(NULL, context, guitext); + text = g_dpgettext2(NULL, context, text); } else { - guitext = _(guitext); + text = _(text); } } } - const char *desc = in_repr->attribute("gui-description"); - if (desc == NULL) { - desc = in_repr->attribute("_gui-description"); + const char *description = in_repr->attribute("gui-description"); + if (description == NULL) { + description = in_repr->attribute("_gui-description"); } - bool gui_hidden = false; + bool hidden = false; { const char *gui_hide = in_repr->attribute("gui-hidden"); if (gui_hide != NULL) { if (strcmp(gui_hide, "1") == 0 || strcmp(gui_hide, "true") == 0) { - gui_hidden = true; + hidden = true; } /* else stays false */ } @@ -107,28 +107,28 @@ Parameter *Parameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex Parameter * param = NULL; if (!strcmp(type, "boolean")) { - param = new ParamBool(name, guitext, desc, gui_hidden, indent, in_ext, in_repr); + 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, guitext, desc, gui_hidden, indent, in_ext, in_repr, ParamInt::FULL); + param = new ParamInt(name, text, description, hidden, indent, in_ext, in_repr, ParamInt::FULL); } else { - param = new ParamInt(name, guitext, desc, gui_hidden, indent, in_ext, in_repr, ParamInt::MINIMAL); + 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, guitext, desc, gui_hidden, indent, in_ext, in_repr, ParamFloat::FULL); + param = new ParamFloat(name, text, description, hidden, indent, in_ext, in_repr, ParamFloat::FULL); } else { - param = new ParamFloat(name, guitext, desc, gui_hidden, indent, in_ext, in_repr, ParamFloat::MINIMAL); + param = new ParamFloat(name, text, description, hidden, indent, in_ext, in_repr, ParamFloat::MINIMAL); } } else if (!strcmp(type, "string")) { - param = new ParamString(name, guitext, desc, gui_hidden, indent, in_ext, in_repr); + param = new ParamString(name, text, description, hidden, indent, in_ext, in_repr); gchar const * max_length = in_repr->attribute("max_length"); if (max_length != NULL) { ParamString * ps = dynamic_cast(param); ps->setMaxLength(atoi(max_length)); } } else if (!strcmp(type, "description")) { - ParamDescription::AppearanceMode appearance_mode = ParamDescription::DESC; + ParamDescription::AppearanceMode appearance_mode = ParamDescription::DESCRIPTION; if (appearance) { if (!strcmp(appearance, "header")) { appearance_mode = ParamDescription::HEADER; @@ -136,19 +136,19 @@ Parameter *Parameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex appearance_mode = ParamDescription::URL; } } - param = new ParamDescription(name, guitext, desc, gui_hidden, indent, in_ext, in_repr, appearance_mode); + param = new ParamDescription(name, text, description, hidden, indent, in_ext, in_repr, appearance_mode); } else if (!strcmp(type, "enum")) { - param = new ParamComboBox(name, guitext, desc, gui_hidden, indent, in_ext, in_repr); + param = new ParamComboBox(name, text, description, hidden, indent, in_ext, in_repr); } else if (!strcmp(type, "notebook")) { - param = new ParamNotebook(name, guitext, desc, gui_hidden, indent, in_ext, in_repr); + 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, guitext, desc, gui_hidden, indent, in_ext, in_repr, ParamRadioButton::MINIMAL); + param = new ParamRadioButton(name, text, description, hidden, indent, in_ext, in_repr, ParamRadioButton::MINIMAL); } else { - param = new ParamRadioButton(name, guitext, desc, gui_hidden, indent, in_ext, in_repr, ParamRadioButton::FULL); + param = new ParamRadioButton(name, text, description, hidden, indent, in_ext, in_repr, ParamRadioButton::FULL); } } else if (!strcmp(type, "color")) { - param = new ParamColor(name, guitext, desc, gui_hidden, indent, in_ext, in_repr); + param = new ParamColor(name, text, description, hidden, indent, in_ext, in_repr); } // Note: param could equal NULL @@ -295,24 +295,24 @@ Parameter::set_color (guint32 in, SPDocument * doc, Inkscape::XML::Node * node) /** Oop, now that we need a parameter, we need it's name. */ -Parameter::Parameter(gchar const * name, gchar const * guitext, gchar const * desc, bool gui_hidden, int indent, Inkscape::Extension::Extension * ext) : - _desc(0), +Parameter::Parameter(gchar const * name, gchar const * text, gchar const * description, bool hidden, int indent, Inkscape::Extension::Extension * ext) : + _description(0), _text(0), - _gui_hidden(gui_hidden), + _hidden(hidden), _indent(indent), - extension(ext), + _extension(ext), _name(0) { if (name != NULL) { _name = g_strdup(name); } - if (desc != NULL) { - _desc = g_strdup(desc); + if (description != NULL) { + _description = g_strdup(description); } - if (guitext != NULL) { - _text = g_strdup(guitext); + if (text != NULL) { + _text = g_strdup(text); } else { _text = g_strdup(name); } @@ -321,19 +321,19 @@ Parameter::Parameter(gchar const * name, gchar const * guitext, gchar const * de } /** Oop, now that we need a parameter, we need it's name. */ -Parameter::Parameter (gchar const * name, gchar const * guitext, Inkscape::Extension::Extension * ext) : - _desc(0), +Parameter::Parameter (gchar const * name, gchar const * text, Inkscape::Extension::Extension * ext) : + _description(0), _text(0), - _gui_hidden(false), + _hidden(false), _indent(0), - extension(ext), + _extension(ext), _name(0) { if (name != NULL) { _name = g_strdup(name); } - if (guitext != NULL) { - _text = g_strdup(guitext); + if (text != NULL) { + _text = g_strdup(text); } else { _text = g_strdup(name); } @@ -349,13 +349,13 @@ Parameter::~Parameter(void) g_free(_text); _text = 0; - g_free(_desc); - _desc = 0; + g_free(_description); + _description = 0; } gchar *Parameter::pref_name(void) const { - return g_strdup_printf("%s.%s", extension->get_id(), _name); + return g_strdup_printf("%s.%s", _extension->get_id(), _name); } Inkscape::XML::Node * @@ -388,7 +388,7 @@ Inkscape::XML::Node *Parameter::document_param_node(SPDocument * doc) child != NULL; child = child->next()) { if ((GQuark)child->code() == name_quark && - !strcmp(child->attribute("extension"), extension->get_id())) { + !strcmp(child->attribute("extension"), _extension->get_id())) { params = child; break; } @@ -396,7 +396,7 @@ Inkscape::XML::Node *Parameter::document_param_node(SPDocument * doc) if (params == NULL) { params = xml_doc->createElement("inkscape:extension-param"); - params->setAttribute("extension", extension->get_id()); + params->setAttribute("extension", _extension->get_id()); defs->appendChild(params); Inkscape::GC::release(params); } -- cgit v1.2.3 From bcd53f13e2f8547266a915dac0fc4c0012bfcf87 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Mon, 24 Apr 2017 21:43:24 +0200 Subject: Extensions: Fixes and improvements for "gui-description" parameter attribute along the lines of r14955 - "gui-description" was always translated (as opposed to only "_gui-description") - Added possibility to specify "msgctxt" for "_gui-description" (bzr r15635) --- src/extension/param/parameter.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/extension/param/parameter.cpp') diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index eeffbecf2..e2093158d 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -80,6 +80,14 @@ Parameter *Parameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex const char *description = in_repr->attribute("gui-description"); if (description == NULL) { description = in_repr->attribute("_gui-description"); + if (description != NULL) { + const char *context = in_repr->attribute("msgctxt"); + if (context != NULL) { + description = g_dpgettext2(NULL, context, description); + } else { + description = _(description); + } + } } bool hidden = false; { -- cgit v1.2.3 From c091b4dad5c911f23eb657130ba260a2b664e944 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Mon, 24 Apr 2017 23:37:16 +0200 Subject: Restore r14978 which was reverted in r15047 due to messed up merge http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/revision/14978 http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/revision/15047 (bzr r15638) --- src/extension/param/parameter.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/extension/param/parameter.cpp') diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index e2093158d..5c4fe591f 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -20,7 +20,6 @@ #endif #include -#include #include "ui/widget/color-notebook.h" #include -- cgit v1.2.3