summaryrefslogtreecommitdiffstats
path: root/src/extension/param
diff options
context:
space:
mode:
authorJabiertxof <jtx@jtx>2017-03-16 19:08:44 +0000
committerJabiertxof <jtx@jtx>2017-03-16 19:08:44 +0000
commit8330d0ef2b97c73121ead78ea9fbcec6ee01f879 (patch)
tree1b1717d1706ee6ebfecc800f2cc80430eb0450e0 /src/extension/param
parentupdate to trunk (diff)
parentFix rendering when canvas rotated. General code clean-up and documentation. (diff)
downloadinkscape-8330d0ef2b97c73121ead78ea9fbcec6ee01f879.tar.gz
inkscape-8330d0ef2b97c73121ead78ea9fbcec6ee01f879.zip
Update to trunk
(bzr r13645.1.170)
Diffstat (limited to 'src/extension/param')
-rw-r--r--src/extension/param/bool.cpp25
-rw-r--r--src/extension/param/bool.h11
-rw-r--r--src/extension/param/color.cpp20
-rw-r--r--src/extension/param/color.h11
-rw-r--r--src/extension/param/description.cpp69
-rw-r--r--src/extension/param/description.h7
-rw-r--r--src/extension/param/enum.cpp26
-rw-r--r--src/extension/param/enum.h12
-rw-r--r--src/extension/param/float.cpp39
-rw-r--r--src/extension/param/float.h21
-rw-r--r--src/extension/param/int.cpp39
-rw-r--r--src/extension/param/int.h20
-rw-r--r--src/extension/param/notebook.cpp46
-rw-r--r--src/extension/param/notebook.h11
-rw-r--r--src/extension/param/parameter.cpp62
-rw-r--r--src/extension/param/parameter.h22
-rw-r--r--src/extension/param/radiobutton.cpp34
-rw-r--r--src/extension/param/radiobutton.h3
-rw-r--r--src/extension/param/string.cpp25
-rw-r--r--src/extension/param/string.h13
20 files changed, 328 insertions, 188 deletions
diff --git a/src/extension/param/bool.cpp b/src/extension/param/bool.cpp
index ca61d8c51..9f8d3dcc0 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;
}
/**
@@ -130,7 +133,7 @@ Gtk::Widget *ParamBool::get_widget(SPDocument * doc, Inkscape::XML::Node * node,
return NULL;
}
- auto hbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, 4));
+ auto hbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, Parameter::GUI_PARAM_WIDGETS_SPACING));
hbox->set_homogeneous(false);
Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START));
@@ -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..fd88e9adb 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);
@@ -98,9 +106,9 @@ Gtk::Widget *ParamColor::get_widget( SPDocument * /*doc*/, Inkscape::XML::Node *
_color_changed.block(false);
}
- Gtk::HBox *hbox = Gtk::manage(new Gtk::HBox(false, 4));
+ 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);
+ hbox->pack_start(*selector, true, true, 0);
selector->show();
hbox->show();
return hbox;
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..3c29b7c49 100644
--- a/src/extension/param/description.cpp
+++ b/src/extension/param/description.cpp
@@ -16,6 +16,7 @@
#include <gtkmm/box.h>
#include <gtkmm/label.h>
#include <glibmm/i18n.h>
+#include <glibmm/markup.h>
#include "xml/node.h"
#include "extension/extension.h"
@@ -26,17 +27,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 +53,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,23 +74,40 @@ ParamDescription::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node
} else {
newguitext = _(_value);
}
-
- Gtk::Label * label;
- int padding = 12 + _indent;
+
+ Gtk::Label * label = Gtk::manage(new Gtk::Label());
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_use_markup(true);
- padding = _indent;
+ label->set_markup(Glib::ustring("<b>") + Glib::Markup::escape_text(newguitext) + Glib::ustring("</b>"));
+ label->set_margin_top(5);
+ label->set_margin_bottom(5);
+ } else if (_mode == URL) {
+ Glib::ustring escaped_url = Glib::Markup::escape_text(newguitext);
+ label->set_markup(Glib::ustring::compose("<a href='%1'>%1</a>", escaped_url));
} else {
- label = Gtk::manage(new Gtk::Label(newguitext, Gtk::ALIGN_START));
+ label->set_text(newguitext);
}
label->set_line_wrap();
+#if (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION >= 16)
+ label->set_xalign(0);
+#else
+ label->set_alignment(Gtk::ALIGN_START);
+#endif
+
+ // 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
+ // - 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
+ // 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 = newguitext.length();
+ label->set_width_chars(len > Parameter::GUI_MAX_LINE_LENGTH ? Parameter::GUI_MAX_LINE_LENGTH : len);
+
label->show();
- Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
- hbox->pack_start(*label, true, true, padding);
+ Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox());
+ 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..c6c5f4013 100644
--- a/src/extension/param/description.h
+++ b/src/extension/param/description.h
@@ -27,23 +27,24 @@ namespace Extension {
class ParamDescription : public Parameter {
public:
enum AppearanceMode {
- DESC, HEADER
+ DESC, HEADER, URL
};
ParamDescription(const gchar * name,
const gchar * guitext,
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..a26458c35 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();
@@ -250,10 +250,10 @@ Gtk::Widget *ParamComboBox::get_widget(SPDocument * doc, Inkscape::XML::Node * n
return NULL;
}
- Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
+ 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, _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..e3fdba826 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);
@@ -175,24 +174,24 @@ Gtk::Widget * ParamFloat::get_widget(SPDocument * doc, Inkscape::XML::Node * nod
return NULL;
}
- Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
+ 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) {
UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(_(_text), fadjust, _precision);
scale->set_size_request(400, -1);
scale->show();
- hbox->pack_start(*scale, false, false);
+ 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, _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..538ddc08d 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);
@@ -156,7 +155,7 @@ ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal
return NULL;
}
- Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
+ 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);
@@ -166,13 +165,13 @@ ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal
UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(_(_text), fadjust, 0);
scale->set_size_request(400, -1);
scale->show();
- hbox->pack_start(*scale, false, false);
+ 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, _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..de86d1005 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;
@@ -199,16 +214,23 @@ Gtk::Widget * ParamNotebookPage::get_widget(SPDocument * doc, Inkscape::XML::Nod
}
Gtk::VBox * vbox = Gtk::manage(new Gtk::VBox);
- vbox->set_border_width(5);
+ vbox->set_border_width(Parameter::GUI_BOX_MARGIN);
+ vbox->set_spacing(Parameter::GUI_BOX_SPACING);
// add parameters onto page (if any)
for (GSList * list = parameters; list != NULL; list = g_slist_next(list)) {
Parameter * param = reinterpret_cast<Parameter *>(list->data);
Gtk::Widget * widg = param->get_widget(doc, node, changeSignal);
if (widg) {
+ int indent = param->get_indent();
+#if GTK_CHECK_VERSION(3,12,0)
+ widg->set_margin_start(indent * Parameter::GUI_INDENTATION);
+#else
+ widg->set_margin_left(indent * Parameter::GUI_INDENTATION);
+#endif
+ vbox->pack_start(*widg, false, false, 0);
+
gchar const * tip = param->get_tooltip();
- // printf("Tip: '%s'\n", tip);
- vbox->pack_start(*widg, false, false, 2);
if (tip) {
widg->set_tooltip_text(_(tip));
} else {
@@ -224,8 +246,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..0eb491078 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<std::string> 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) {
@@ -78,6 +85,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,44 +114,48 @@ 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);
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, in_ext, in_repr, ParamDescription::HEADER);
- } else {
- param = new ParamDescription(name, guitext, desc, scope, gui_hidden, gui_tip, 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, 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 +302,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 +339,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..c107f24f9 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;
/**
@@ -155,6 +159,19 @@ public:
/** 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 signle 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 lenght for wrapping textual parameters (in chars) */
+ const static int GUI_MAX_LINE_LENGTH = 60;
+
+
protected:
/** Description of the parameter. */
gchar * _desc;
@@ -171,6 +188,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..178dc20e8 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);
@@ -303,14 +301,14 @@ Gtk::Widget * ParamRadioButton::get_widget(SPDocument * doc, Inkscape::XML::Node
return NULL;
}
- auto hbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, 4));
+ 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, _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..0c5238f99 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);
@@ -165,10 +168,10 @@ Gtk::Widget * ParamString::get_widget(SPDocument * doc, Inkscape::XML::Node * no
return NULL;
}
- Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
+ 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, _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. */