summaryrefslogtreecommitdiffstats
path: root/src/extension
diff options
context:
space:
mode:
authorEduard Braun <eduard.braun2@gmx.de>2017-02-12 14:59:14 +0000
committerEduard Braun <eduard.braun2@gmx.de>2017-02-12 14:59:14 +0000
commita65a0a21e5452ced77123a8b846ff10cc1bc74b0 (patch)
tree9a263d66a1fafaaf5243a57c420197274a626e35 /src/extension
parentFix and improve window sizing and positioning behavior when opening new docum... (diff)
downloadinkscape-a65a0a21e5452ced77123a8b846ff10cc1bc74b0.tar.gz
inkscape-a65a0a21e5452ced77123a8b846ff10cc1bc74b0.zip
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)
Diffstat (limited to 'src/extension')
-rw-r--r--src/extension/extension.cpp32
-rw-r--r--src/extension/extension.h2
-rw-r--r--src/extension/param/bool.cpp23
-rw-r--r--src/extension/param/bool.h11
-rw-r--r--src/extension/param/color.cpp16
-rw-r--r--src/extension/param/color.h11
-rw-r--r--src/extension/param/description.cpp39
-rw-r--r--src/extension/param/description.h5
-rw-r--r--src/extension/param/enum.cpp24
-rw-r--r--src/extension/param/enum.h12
-rw-r--r--src/extension/param/float.cpp35
-rw-r--r--src/extension/param/float.h21
-rw-r--r--src/extension/param/int.cpp35
-rw-r--r--src/extension/param/int.h20
-rw-r--r--src/extension/param/notebook.cpp39
-rw-r--r--src/extension/param/notebook.h11
-rw-r--r--src/extension/param/parameter.cpp43
-rw-r--r--src/extension/param/parameter.h9
-rw-r--r--src/extension/param/radiobutton.cpp32
-rw-r--r--src/extension/param/radiobutton.h3
-rw-r--r--src/extension/param/string.cpp23
-rw-r--r--src/extension/param/string.h13
22 files changed, 276 insertions, 183 deletions
diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp
index c6dee1b70..2d020aa0e 100644
--- a/src/extension/extension.cpp
+++ b/src/extension/extension.cpp
@@ -1,6 +1,6 @@
/** \file
*
- * Inkscape::Extension::Extension:
+ * Inkscape::Extension::Extension:
* the ability to have features that are more modular so that they
* can be added and removed easily. This is the basis for defining
* those actions.
@@ -144,15 +144,15 @@ Extension::~Extension (void)
delete timer;
timer = NULL;
/** \todo Need to do parameters here */
-
- // delete parameters:
+
+ // delete parameters:
for (GSList * list = parameters; list != NULL; list = g_slist_next(list)) {
Parameter * param = reinterpret_cast<Parameter *>(list->data);
delete param;
}
g_slist_free(parameters);
-
-
+
+
for (unsigned int i = 0 ; i < _deps.size(); i++) {
delete _deps[i];
}
@@ -330,7 +330,7 @@ Extension::get_repr (void)
}
/**
- \return bool
+ \return bool
\brief Whether this extension should hide the "working, please wait" dialog
*/
bool
@@ -444,7 +444,7 @@ Extension::get_param_enum (const gchar * name, const SPDocument * doc, const Ink
/**
* 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.
@@ -692,8 +692,9 @@ public:
* @param widg Widget to add.
* @param tooltip Tooltip for the widget.
*/
- void addWidget(Gtk::Widget *widg, gchar const *tooltip) {
+ void addWidget(Gtk::Widget *widg, gchar const *tooltip, int indent) {
if (widg) {
+ widg->set_margin_left(indent*12);
this->pack_start(*widg, false, false, 2);
if (tooltip) {
widg->set_tooltip_text(_(tooltip));
@@ -713,7 +714,7 @@ public:
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_visible = false NULL is returned as well.
+ If all parameters are gui_visible = false NULL is returned as well.
*/
Gtk::Widget *
Extension::autogui (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal)
@@ -728,9 +729,10 @@ Extension::autogui (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<v
if (param->get_gui_hidden()) continue; //Ignore hidden parameters
Gtk::Widget * widg = param->get_widget(doc, node, changeSignal);
gchar const * tip = param->get_tooltip();
- agui->addWidget(widg, tip);
- }
-
+ int indent = param->get_indent();
+ agui->addWidget(widg, tip, indent);
+ }
+
agui->show();
return agui;
};
@@ -780,7 +782,7 @@ void Extension::add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Gri
Gtk::Label * label;
Gtk::Label * value;
- (*row)++;
+ (*row)++;
label = Gtk::manage(new Gtk::Label(labelstr));
value = Gtk::manage(new Gtk::Label(valuestr));
@@ -824,13 +826,13 @@ Extension::get_params_widget(void)
return retval;
}
-unsigned int Extension::param_visible_count ( )
+unsigned int Extension::param_visible_count ( )
{
unsigned int _visible_count = 0;
for (GSList * list = parameters; list != NULL; list = g_slist_next(list)) {
Parameter * param = reinterpret_cast<Parameter *>(list->data);
if (!param->get_gui_hidden()) _visible_count++;
- }
+ }
return _visible_count;
}
diff --git a/src/extension/extension.h b/src/extension/extension.h
index cd29e1636..bbd6d068b 100644
--- a/src/extension/extension.h
+++ b/src/extension/extension.h
@@ -176,7 +176,7 @@ public:
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.
diff --git a/src/extension/param/bool.cpp b/src/extension/param/bool.cpp
index ca61d8c51..833215546 100644
--- a/src/extension/param/bool.cpp
+++ b/src/extension/param/bool.cpp
@@ -24,9 +24,17 @@
namespace Inkscape {
namespace Extension {
-ParamBool::ParamBool(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
- Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext),
- _value(false), _indent(0)
+ParamBool::ParamBool(const gchar * name,
+ const gchar * guitext,
+ const gchar * desc,
+ const Parameter::_scope_t scope,
+ bool gui_hidden,
+ const gchar * gui_tip,
+ int indent,
+ Inkscape::Extension::Extension * ext,
+ Inkscape::XML::Node * xml)
+ : Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, indent, ext)
+ , _value(false)
{
const char * defaultval = NULL;
if (xml->firstChild() != NULL) {
@@ -39,11 +47,6 @@ ParamBool::ParamBool(const gchar * name, const gchar * guitext, const gchar * de
_value = false;
}
- const char * indent = xml->attribute("indent");
- if (indent != NULL) {
- _indent = atoi(indent) * 12;
- }
-
gchar * pref_name = this->pref_name();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
_value = prefs->getBool(extension_pref_root + pref_name, _value);
@@ -66,7 +69,7 @@ bool ParamBool::set( bool in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node
bool ParamBool::get(const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) const
{
- return _value;
+ return _value;
}
/**
@@ -139,7 +142,7 @@ Gtk::Widget *ParamBool::get_widget(SPDocument * doc, Inkscape::XML::Node * node,
ParamBoolCheckButton * checkbox = Gtk::manage(new ParamBoolCheckButton(this, doc, node, changeSignal));
checkbox->show();
- hbox->pack_start(*checkbox, false, false, _indent);
+ hbox->pack_start(*checkbox, false, false);
hbox->show();
diff --git a/src/extension/param/bool.h b/src/extension/param/bool.h
index 5d190b9d3..0af12b105 100644
--- a/src/extension/param/bool.h
+++ b/src/extension/param/bool.h
@@ -32,7 +32,15 @@ public:
/**
* Use the superclass' allocator and set the \c _value.
*/
- ParamBool(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
+ ParamBool(const gchar * name,
+ const gchar * guitext,
+ const gchar * desc,
+ const Parameter::_scope_t scope,
+ bool gui_hidden,
+ const gchar * gui_tip,
+ int indent,
+ Inkscape::Extension::Extension * ext,
+ Inkscape::XML::Node * xml);
/**
* Returns the current state/value.
@@ -69,7 +77,6 @@ public:
private:
/** Internal value. */
bool _value;
- int _indent;
};
} // namespace Extension
diff --git a/src/extension/param/color.cpp b/src/extension/param/color.cpp
index 0b58c5011..041cd5509 100644
--- a/src/extension/param/color.cpp
+++ b/src/extension/param/color.cpp
@@ -52,9 +52,17 @@ guint32 ParamColor::set( guint32 in, SPDocument * /*doc*/, Inkscape::XML::Node *
return in;
}
-ParamColor::ParamColor (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
- Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext),
- _changeSignal(0)
+ParamColor::ParamColor(const gchar * name,
+ const gchar * guitext,
+ const gchar * desc,
+ const Parameter::_scope_t scope,
+ bool gui_hidden,
+ const gchar * gui_tip,
+ int indent,
+ Inkscape::Extension::Extension * ext,
+ Inkscape::XML::Node * xml)
+ : Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, indent, ext)
+ , _changeSignal(0)
{
const char * defaulthex = NULL;
if (xml->firstChild() != NULL)
@@ -86,7 +94,7 @@ Gtk::Widget *ParamColor::get_widget( SPDocument * /*doc*/, Inkscape::XML::Node *
{
using Inkscape::UI::Widget::ColorNotebook;
- if (_gui_hidden) return NULL;
+ if (_gui_hidden) return NULL;
if (changeSignal) {
_changeSignal = new sigc::signal<void>(*changeSignal);
diff --git a/src/extension/param/color.h b/src/extension/param/color.h
index ed2e57ceb..d6e9d1fbe 100644
--- a/src/extension/param/color.h
+++ b/src/extension/param/color.h
@@ -31,8 +31,15 @@ private:
Inkscape::UI::SelectedColor _color;
sigc::connection _color_changed;
public:
- ParamColor(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
-
+ ParamColor(const gchar * name,
+ const gchar * guitext,
+ const gchar * desc,
+ const Parameter::_scope_t scope,
+ bool gui_hidden,
+ const gchar * gui_tip,
+ int indent,
+ Inkscape::Extension::Extension * ext,
+ Inkscape::XML::Node * xml);
virtual ~ParamColor(void);
/** Returns \c _value, with a \i const to protect it. */
diff --git a/src/extension/param/description.cpp b/src/extension/param/description.cpp
index 07aaa07cc..7f7d2d976 100644
--- a/src/extension/param/description.cpp
+++ b/src/extension/param/description.cpp
@@ -26,17 +26,19 @@ namespace Extension {
/** \brief Initialize the object, to do that, copy the data. */
-ParamDescription::ParamDescription (const gchar * name,
- const gchar * guitext,
- const gchar * desc,
- const Parameter::_scope_t scope,
- bool gui_hidden,
- const gchar * gui_tip,
- Inkscape::Extension::Extension * ext,
- Inkscape::XML::Node * xml,
- AppearanceMode mode) :
- Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext),
- _value(NULL), _mode(mode), _indent(0)
+ParamDescription::ParamDescription(const gchar * name,
+ const gchar * guitext,
+ const gchar * desc,
+ const Parameter::_scope_t scope,
+ bool gui_hidden,
+ const gchar * gui_tip,
+ int indent,
+ Inkscape::Extension::Extension * ext,
+ Inkscape::XML::Node * xml,
+ AppearanceMode mode)
+ : Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, indent, ext)
+ , _value(NULL)
+ , _mode(mode)
{
// printf("Building Description\n");
const char * defaultval = NULL;
@@ -50,11 +52,6 @@ ParamDescription::ParamDescription (const gchar * name,
_context = xml->attribute("msgctxt");
- const char * indent = xml->attribute("indent");
- if (indent != NULL) {
- _indent = atoi(indent) * 12;
- }
-
return;
}
@@ -76,15 +73,13 @@ ParamDescription::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node
} else {
newguitext = _(_value);
}
-
+
Gtk::Label * label;
- int padding = 12 + _indent;
if (_mode == HEADER) {
label = Gtk::manage(new Gtk::Label(Glib::ustring("<b>") +newguitext + Glib::ustring("</b>"), Gtk::ALIGN_START));
- label->set_margin_top(5);
- label->set_margin_bottom(5);
+ label->set_margin_top(5);
+ label->set_margin_bottom(5);
label->set_use_markup(true);
- padding = _indent;
} else {
label = Gtk::manage(new Gtk::Label(newguitext, Gtk::ALIGN_START));
}
@@ -92,7 +87,7 @@ ParamDescription::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node
label->show();
Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
- hbox->pack_start(*label, true, true, padding);
+ hbox->pack_start(*label, true, true);
hbox->show();
return hbox;
diff --git a/src/extension/param/description.h b/src/extension/param/description.h
index 3a72c4112..aa3c3a798 100644
--- a/src/extension/param/description.h
+++ b/src/extension/param/description.h
@@ -34,16 +34,17 @@ public:
const gchar * desc,
const Parameter::_scope_t scope,
bool gui_hidden,
- const gchar * gui_tip,
+ const gchar * gui_tip,
+ 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);
private:
/** \brief Internal value. */
gchar * _value;
AppearanceMode _mode;
- int _indent;
const gchar* _context;
};
diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp
index 8bc0fbda7..9f254041a 100644
--- a/src/extension/param/enum.cpp
+++ b/src/extension/param/enum.cpp
@@ -46,12 +46,17 @@ public:
};
-ParamComboBox::ParamComboBox(const gchar *name, const gchar *guitext, const gchar *desc,
- const Parameter::_scope_t scope, bool gui_hidden, const gchar *gui_tip,
- Inkscape::Extension::Extension *ext, Inkscape::XML::Node *xml)
- : Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext)
+ParamComboBox::ParamComboBox(const gchar * name,
+ const gchar * guitext,
+ const gchar * desc,
+ const Parameter::_scope_t scope,
+ bool gui_hidden,
+ const gchar * gui_tip,
+ int indent,
+ Inkscape::Extension::Extension * ext,
+ Inkscape::XML::Node * xml)
+ : Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, indent, ext)
, _value(NULL)
- , _indent(0)
, choices(NULL)
{
const char *xmlval = NULL; // the value stored in XML
@@ -94,17 +99,12 @@ ParamComboBox::ParamComboBox(const gchar *name, const gchar *guitext, const gcha
}
}
}
-
+
// 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");
}
-
- const char *indent = xml->attribute("indent");
- if (indent != NULL) {
- _indent = atoi(indent) * 12;
- }
}
gchar * pref_name = this->pref_name();
@@ -253,7 +253,7 @@ Gtk::Widget *ParamComboBox::get_widget(SPDocument * doc, Inkscape::XML::Node * n
Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START));
label->show();
- hbox->pack_start(*label, false, false, _indent);
+ hbox->pack_start(*label, false, false);
ParamComboBoxEntry * combo = Gtk::manage(new ParamComboBoxEntry(this, doc, node, changeSignal));
// add choice strings:
diff --git a/src/extension/param/enum.h b/src/extension/param/enum.h
index 52e018469..f9d3d75f7 100644
--- a/src/extension/param/enum.h
+++ b/src/extension/param/enum.h
@@ -34,12 +34,20 @@ private:
been allocated in memory. And should be free'd.
It is the value of the current selected string */
gchar * _value;
- int _indent;
GSList * choices; /**< A table to store the choice strings */
public:
- ParamComboBox(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
+ ParamComboBox(const gchar * name,
+ const gchar * guitext,
+ const gchar * desc,
+ const Parameter::_scope_t scope,
+ bool gui_hidden,
+ const gchar * gui_tip,
+ int indent,
+ Inkscape::Extension::Extension * ext,
+ Inkscape::XML::Node * xml);
virtual ~ParamComboBox(void);
+
Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
// Explicitly call superclass version to avoid method being hidden.
diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp
index 23a03ea8f..fd82ab312 100644
--- a/src/extension/param/float.cpp
+++ b/src/extension/param/float.cpp
@@ -27,17 +27,21 @@ namespace Extension {
/** Use the superclass' allocator and set the \c _value. */
-ParamFloat::ParamFloat (const gchar * name,
- const gchar * guitext,
- const gchar * desc,
- const Parameter::_scope_t scope,
- bool gui_hidden,
- const gchar * gui_tip,
- Inkscape::Extension::Extension * ext,
- Inkscape::XML::Node * xml,
- AppearanceMode mode) :
- Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext),
- _value(0.0), _mode(mode), _indent(0), _min(0.0), _max(10.0)
+ParamFloat::ParamFloat(const gchar * name,
+ const gchar * guitext,
+ const gchar * desc,
+ const Parameter::_scope_t scope,
+ bool gui_hidden,
+ const gchar * gui_tip,
+ int indent,
+ Inkscape::Extension::Extension * ext,
+ Inkscape::XML::Node * xml,
+ AppearanceMode mode)
+ : Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, indent, ext)
+ , _value(0.0)
+ , _mode(mode)
+ , _min(0.0)
+ , _max(10.0)
{
const gchar * defaultval = NULL;
if (xml->firstChild() != NULL) {
@@ -69,11 +73,6 @@ ParamFloat::ParamFloat (const gchar * name,
_min = 0.0;
}
- const char * indent = xml->attribute("indent");
- if (indent != NULL) {
- _indent = atoi(indent) * 12;
- }
-
gchar * pref_name = this->pref_name();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
_value = prefs->getDouble(extension_pref_root + pref_name, _value);
@@ -179,7 +178,7 @@ Gtk::Widget * ParamFloat::get_widget(SPDocument * doc, Inkscape::XML::Node * nod
auto pfa = new ParamFloatAdjustment(this, doc, node, changeSignal);
Glib::RefPtr<Gtk::Adjustment> fadjust(pfa);
-
+
if (_mode == FULL) {
UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(_(_text), fadjust, _precision);
@@ -192,7 +191,7 @@ Gtk::Widget * ParamFloat::get_widget(SPDocument * doc, Inkscape::XML::Node * nod
Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START));
label->show();
- hbox->pack_start(*label, true, true, _indent);
+ hbox->pack_start(*label, true, true);
auto spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(fadjust, 0.1, _precision));
spin->show();
diff --git a/src/extension/param/float.h b/src/extension/param/float.h
index 42b1698b1..7fd86cea7 100644
--- a/src/extension/param/float.h
+++ b/src/extension/param/float.h
@@ -29,15 +29,17 @@ public:
enum AppearanceMode {
FULL, MINIMAL
};
- ParamFloat (const gchar * name,
- const gchar * guitext,
- const gchar * desc,
- const Parameter::_scope_t scope,
- bool gui_hidden,
- const gchar * gui_tip,
- Inkscape::Extension::Extension * ext,
- Inkscape::XML::Node * xml,
- AppearanceMode mode);
+ ParamFloat(const gchar * name,
+ const gchar * guitext,
+ const gchar * desc,
+ const Parameter::_scope_t scope,
+ bool gui_hidden,
+ const gchar * gui_tip,
+ int indent,
+ Inkscape::Extension::Extension * ext,
+ Inkscape::XML::Node * xml,
+ AppearanceMode mode);
+
/** Returns \c _value. */
float get(const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) const { return _value; }
@@ -60,7 +62,6 @@ private:
/** Internal value. */
float _value;
AppearanceMode _mode;
- int _indent;
float _min;
float _max;
int _precision;
diff --git a/src/extension/param/int.cpp b/src/extension/param/int.cpp
index 222d4f243..24b1390d1 100644
--- a/src/extension/param/int.cpp
+++ b/src/extension/param/int.cpp
@@ -27,17 +27,21 @@ namespace Extension {
/** Use the superclass' allocator and set the \c _value. */
-ParamInt::ParamInt (const gchar * name,
- const gchar * guitext,
- const gchar * desc,
- const Parameter::_scope_t scope,
- bool gui_hidden,
- const gchar * gui_tip,
- Inkscape::Extension::Extension * ext,
- Inkscape::XML::Node * xml,
- AppearanceMode mode) :
- Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext),
- _value(0), _mode(mode), _indent(0), _min(0), _max(10)
+ParamInt::ParamInt(const gchar * name,
+ const gchar * guitext,
+ const gchar * desc,
+ const Parameter::_scope_t scope,
+ bool gui_hidden,
+ const gchar * gui_tip,
+ int indent,
+ Inkscape::Extension::Extension * ext,
+ Inkscape::XML::Node * xml,
+ AppearanceMode mode)
+ : Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, indent, ext)
+ , _value(0)
+ , _mode(mode)
+ , _min(0)
+ , _max(10)
{
const char * defaultval = NULL;
if (xml->firstChild() != NULL) {
@@ -62,11 +66,6 @@ ParamInt::ParamInt (const gchar * name,
_min = 0;
}
- const char * indent = xml->attribute("indent");
- if (indent != NULL) {
- _indent = atoi(indent) * 12;
- }
-
gchar *pref_name = this->pref_name();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
_value = prefs->getInt(extension_pref_root + pref_name, _value);
@@ -169,10 +168,10 @@ ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal
hbox->pack_start(*scale, false, false);
}
else if (_mode == MINIMAL) {
-
+
Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START));
label->show();
- hbox->pack_start(*label, true, true, _indent);
+ hbox->pack_start(*label, true, true);
auto spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(fadjust, 1.0, 0));
spin->show();
diff --git a/src/extension/param/int.h b/src/extension/param/int.h
index 3fd6cea9b..40c0395ec 100644
--- a/src/extension/param/int.h
+++ b/src/extension/param/int.h
@@ -29,15 +29,16 @@ public:
enum AppearanceMode {
FULL, MINIMAL
};
- ParamInt (const gchar * name,
- const gchar * guitext,
- const gchar * desc,
- const Parameter::_scope_t scope,
- bool gui_hidden,
- const gchar * gui_tip,
- Inkscape::Extension::Extension * ext,
- Inkscape::XML::Node * xml,
- AppearanceMode mode);
+ ParamInt(const gchar * name,
+ const gchar * guitext,
+ const gchar * desc,
+ const Parameter::_scope_t scope,
+ bool gui_hidden,
+ const gchar * gui_tip,
+ int indent,
+ Inkscape::Extension::Extension * ext,
+ Inkscape::XML::Node * xml,
+ AppearanceMode mode);
/** Returns \c _value. */
int get(const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) const { return _value; }
@@ -59,7 +60,6 @@ private:
/** Internal value. */
int _value;
AppearanceMode _mode;
- int _indent;
int _min;
int _max;
};
diff --git a/src/extension/param/notebook.cpp b/src/extension/param/notebook.cpp
index 957d12d06..bfdff885a 100644
--- a/src/extension/param/notebook.cpp
+++ b/src/extension/param/notebook.cpp
@@ -54,8 +54,16 @@ private:
public:
static ParamNotebookPage * makepage (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * in_ext);
- ParamNotebookPage(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
+ ParamNotebookPage(const gchar * name,
+ const gchar * guitext,
+ const gchar * desc,
+ const Parameter::_scope_t scope,
+ bool gui_hidden,
+ const gchar * gui_tip,
+ Inkscape::Extension::Extension * ext,
+ Inkscape::XML::Node * xml);
~ParamNotebookPage(void);
+
Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
void paramString (std::list <std::string> &list);
gchar * get_guitext (void) {return _text;};
@@ -63,8 +71,15 @@ public:
}; /* class ParamNotebookPage */
-ParamNotebookPage::ParamNotebookPage (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
- Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext)
+ParamNotebookPage::ParamNotebookPage(const gchar * name,
+ const gchar * guitext,
+ const gchar * desc,
+ const Parameter::_scope_t scope,
+ bool gui_hidden,
+ const gchar * gui_tip,
+ Inkscape::Extension::Extension * ext,
+ Inkscape::XML::Node * xml)
+ : Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, /*indent*/ 0, ext)
{
parameters = NULL;
@@ -206,9 +221,11 @@ Gtk::Widget * ParamNotebookPage::get_widget(SPDocument * doc, Inkscape::XML::Nod
Parameter * param = reinterpret_cast<Parameter *>(list->data);
Gtk::Widget * widg = param->get_widget(doc, node, changeSignal);
if (widg) {
- gchar const * tip = param->get_tooltip();
- // printf("Tip: '%s'\n", tip);
+ int indent = param->get_indent();
+ widg->set_margin_left(indent*12);
vbox->pack_start(*widg, false, false, 2);
+
+ gchar const * tip = param->get_tooltip();
if (tip) {
widg->set_tooltip_text(_(tip));
} else {
@@ -224,8 +241,16 @@ Gtk::Widget * ParamNotebookPage::get_widget(SPDocument * doc, Inkscape::XML::Nod
}
-ParamNotebook::ParamNotebook (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
- Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext)
+ParamNotebook::ParamNotebook(const gchar * name,
+ const gchar * guitext,
+ const gchar * desc,
+ const Parameter::_scope_t scope,
+ bool gui_hidden,
+ const gchar * gui_tip,
+ int indent,
+ Inkscape::Extension::Extension * ext,
+ Inkscape::XML::Node * xml)
+ : Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, indent, ext)
{
pages = NULL;
diff --git a/src/extension/param/notebook.h b/src/extension/param/notebook.h
index 3c90964fd..278c4de12 100644
--- a/src/extension/param/notebook.h
+++ b/src/extension/param/notebook.h
@@ -41,8 +41,17 @@ private:
This only gets created if there are pages in this
notebook */
public:
- ParamNotebook(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
+ ParamNotebook(const gchar * name,
+ const gchar * guitext,
+ const gchar * desc,
+ const Parameter::_scope_t scope,
+ bool gui_hidden,
+ const gchar * gui_tip,
+ int indent,
+ Inkscape::Extension::Extension * ext,
+ Inkscape::XML::Node * xml);
virtual ~ParamNotebook(void);
+
Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
/**
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<ParamString *>(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)
{
diff --git a/src/extension/param/parameter.h b/src/extension/param/parameter.h
index 5e1e3897f..c787a7c97 100644
--- a/src/extension/param/parameter.h
+++ b/src/extension/param/parameter.h
@@ -37,7 +37,7 @@ class Extension;
*/
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
@@ -62,6 +62,7 @@ public:
const Parameter::_scope_t scope,
bool gui_hidden,
gchar const *gui_tip,
+ int indent,
Inkscape::Extension::Extension * ext);
Parameter(gchar const *name,
@@ -144,6 +145,9 @@ public:
/** Indicates if the GUI for this parameter is hidden or not */
bool get_gui_hidden() const { return _gui_hidden; }
+ /** Indentation level of the parameter */
+ int get_indent() const { return _indent; }
+
virtual void string(std::list <std::string> &list) const;
/**
@@ -171,6 +175,9 @@ protected:
/** A tip for the GUI if there is one. */
gchar * _gui_tip;
+ /** Indentation level of the parameter. */
+ int _indent;
+
/* **** funcs **** */
diff --git a/src/extension/param/radiobutton.cpp b/src/extension/param/radiobutton.cpp
index c54cc0ec3..fd1b6e04e 100644
--- a/src/extension/param/radiobutton.cpp
+++ b/src/extension/param/radiobutton.cpp
@@ -57,17 +57,20 @@ public:
Glib::ustring * guitext;
};
-ParamRadioButton::ParamRadioButton (const gchar * name,
- const gchar * guitext,
- const gchar * desc,
- const Parameter::_scope_t scope,
- bool gui_hidden,
- const gchar * gui_tip,
- Inkscape::Extension::Extension * ext,
- Inkscape::XML::Node * xml,
- AppearanceMode mode) :
- Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext),
- _value(0), _mode(mode), _indent(0), choices(0)
+ParamRadioButton::ParamRadioButton(const gchar * name,
+ const gchar * guitext,
+ const gchar * desc,
+ const Parameter::_scope_t scope,
+ bool gui_hidden,
+ const gchar * gui_tip,
+ int indent,
+ Inkscape::Extension::Extension * ext,
+ Inkscape::XML::Node * xml,
+ AppearanceMode mode)
+ : Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, indent, ext)
+ , _value(0)
+ , _mode(mode)
+ , choices(0)
{
// Read XML tree to add enumeration items:
// printf("Extension Constructor: ");
@@ -118,11 +121,6 @@ ParamRadioButton::ParamRadioButton (const gchar * name,
defaultval = (static_cast<optionentry*> (choices->data))->value->c_str();
}
- const char *indent = xml ? xml->attribute("indent") : NULL;
- if (indent != NULL) {
- _indent = atoi(indent) * 12;
- }
-
gchar * pref_name = this->pref_name();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
Glib::ustring paramval = prefs->getString(extension_pref_root + pref_name);
@@ -310,7 +308,7 @@ Gtk::Widget * ParamRadioButton::get_widget(SPDocument * doc, Inkscape::XML::Node
Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START, Gtk::ALIGN_START));
label->show();
- hbox->pack_start(*label, false, false, _indent);
+ hbox->pack_start(*label, false, false);
Gtk::ComboBoxText* cbt = 0;
bool comboSet = false;
diff --git a/src/extension/param/radiobutton.h b/src/extension/param/radiobutton.h
index 0e0f643c9..5e15dcb57 100644
--- a/src/extension/param/radiobutton.h
+++ b/src/extension/param/radiobutton.h
@@ -40,10 +40,12 @@ public:
const Parameter::_scope_t scope,
bool gui_hidden,
const gchar * gui_tip,
+ int indent,
Inkscape::Extension::Extension * ext,
Inkscape::XML::Node * xml,
AppearanceMode mode);
virtual ~ParamRadioButton(void);
+
Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
// Explicitly call superclass version to avoid method being hidden.
@@ -63,7 +65,6 @@ private:
It is the value of the current selected string */
gchar * _value;
AppearanceMode _mode;
- int _indent;
GSList * choices; /**< A table to store the choice strings */
}; /* class ParamRadioButton */
diff --git a/src/extension/param/string.cpp b/src/extension/param/string.cpp
index 1d9205502..f7d3c9662 100644
--- a/src/extension/param/string.cpp
+++ b/src/extension/param/string.cpp
@@ -24,7 +24,7 @@
namespace Inkscape {
namespace Extension {
-
+
/** Free the allocated data. */
ParamString::~ParamString(void)
@@ -76,20 +76,23 @@ void ParamString::string(std::string &string) const
}
/** Initialize the object, to do that, copy the data. */
-ParamString::ParamString (const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) :
- Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext),
- _value(NULL), _indent(0)
+ParamString::ParamString(const gchar * name,
+ const gchar * guitext,
+ const gchar * desc,
+ const Parameter::_scope_t scope,
+ bool gui_hidden,
+ const gchar * gui_tip,
+ int indent,
+ Inkscape::Extension::Extension * ext,
+ Inkscape::XML::Node * xml)
+ : Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, indent, ext)
+ , _value(NULL)
{
const char * defaultval = NULL;
if (xml->firstChild() != NULL) {
defaultval = xml->firstChild()->content();
}
- const char * indent = xml->attribute("indent");
- if (indent != NULL) {
- _indent = atoi(indent) * 12;
- }
-
gchar * pref_name = this->pref_name();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
Glib::ustring paramval = prefs->getString(extension_pref_root + pref_name);
@@ -168,7 +171,7 @@ Gtk::Widget * ParamString::get_widget(SPDocument * doc, Inkscape::XML::Node * no
Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START));
label->show();
- hbox->pack_start(*label, false, false, _indent);
+ hbox->pack_start(*label, false, false);
ParamStringEntry * textbox = new ParamStringEntry(this, doc, node, changeSignal);
textbox->show();
diff --git a/src/extension/param/string.h b/src/extension/param/string.h
index 3b137aeac..f5412ebcc 100644
--- a/src/extension/param/string.h
+++ b/src/extension/param/string.h
@@ -19,12 +19,19 @@ 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 leght of the string. Zero meaning unlimited.
+ /** \brief Internal value. This indicates the maximum lenth of the string. Zero meaning unlimited.
*/
- int _indent;
gint _max_length;
public:
- ParamString(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml);
+ ParamString(const gchar * name,
+ const gchar * guitext,
+ const gchar * desc,
+ const Parameter::_scope_t scope,
+ bool gui_hidden,
+ const gchar * gui_tip,
+ int indent,
+ Inkscape::Extension::Extension * ext,
+ Inkscape::XML::Node * xml);
virtual ~ParamString(void);
/** \brief Returns \c _value, with a \i const to protect it. */