summaryrefslogtreecommitdiffstats
path: root/src/extension/param
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2014-11-23 23:36:49 +0000
committerJabiertxof <jtx@jtx.marker.es>2014-11-23 23:36:49 +0000
commit0969085ddf607a7a98cf7fd6d9b10da5fbebe62d (patch)
tree59b2bc9ed3412ab2de4c703ef30342dfe2401704 /src/extension/param
parentrefactor from lastApplied (diff)
parentFixed a bug pointed by suv running from comand line, also removed another des... (diff)
downloadinkscape-0969085ddf607a7a98cf7fd6d9b10da5fbebe62d.tar.gz
inkscape-0969085ddf607a7a98cf7fd6d9b10da5fbebe62d.zip
fixing to trunk
(bzr r12588.1.34)
Diffstat (limited to 'src/extension/param')
-rw-r--r--src/extension/param/color.cpp12
-rw-r--r--src/extension/param/enum.cpp55
-rw-r--r--src/extension/param/notebook.cpp2
-rw-r--r--src/extension/param/radiobutton.cpp2
4 files changed, 37 insertions, 34 deletions
diff --git a/src/extension/param/color.cpp b/src/extension/param/color.cpp
index 0a2598c56..5bd70359f 100644
--- a/src/extension/param/color.cpp
+++ b/src/extension/param/color.cpp
@@ -59,9 +59,10 @@ guint32 ParamColor::set( guint32 in, SPDocument * /*doc*/, Inkscape::XML::Node *
return _value;
}
-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, Inkscape::Extension::Extension *ext,
+ Inkscape::XML::Node *xml)
+ : Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _value(0), _changeSignal(0)
{
const char * defaulthex = NULL;
if (xml->firstChild() != NULL)
@@ -75,7 +76,8 @@ ParamColor::ParamColor (const gchar * name, const gchar * guitext, const gchar *
if (!paramval.empty())
defaulthex = paramval.data();
- _value = atoi(defaulthex);
+ if (defaulthex)
+ _value = atoi(defaulthex);
}
void ParamColor::string(std::string &string) const
@@ -87,7 +89,7 @@ void ParamColor::string(std::string &string) const
Gtk::Widget *ParamColor::get_widget( SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * changeSignal )
{
- if (_gui_hidden) return NULL;
+ if (_gui_hidden) return NULL;
_changeSignal = new sigc::signal<void>(*changeSignal);
Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp
index bb50c06e1..74b2a75ad 100644
--- a/src/extension/param/enum.cpp
+++ b/src/extension/param/enum.cpp
@@ -41,8 +41,8 @@ namespace Extension {
class enumentry {
public:
enumentry (Glib::ustring &val, Glib::ustring &text) :
- value(val),
- guitext(text)
+ value(val),
+ guitext(text)
{}
Glib::ustring value;
@@ -50,16 +50,19 @@ 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), _indent(0)
+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)
+ , _value(NULL)
+ , _indent(0)
+ , choices(NULL)
{
- choices = NULL;
- _value = NULL;
+ const char *xmlval = NULL; // the value stored in XML
- // Read XML tree to add enumeration items:
- // printf("Extension Constructor: ");
if (xml != NULL) {
- for (Inkscape::XML::Node *node = xml->firstChild(); node; node = node->next()) {
+ // Read XML tree to add enumeration items:
+ for (Inkscape::XML::Node *node = xml->firstChild(); node; node = node->next()) {
char const * chname = node->name();
if (!strcmp(chname, INKSCAPE_EXTENSION_NS "item") || !strcmp(chname, INKSCAPE_EXTENSION_NS "_item")) {
Glib::ustring newguitext, newvalue;
@@ -69,8 +72,8 @@ ParamComboBox::ParamComboBox (const gchar * name, const gchar * guitext, const g
}
if (contents != NULL) {
// don't translate when 'item' but do translate when '_item'
- // NOTE: internal extensions use build_from_mem and don't need _item but
- // still need to include if are to be localized
+ // NOTE: internal extensions use build_from_mem and don't need _item but
+ // still need to include if are to be localized
if (!strcmp(chname, INKSCAPE_EXTENSION_NS "_item")) {
if (node->attribute("msgctxt") != NULL) {
newguitext = g_dpgettext2(NULL, node->attribute("msgctxt"), contents);
@@ -95,30 +98,28 @@ ParamComboBox::ParamComboBox (const gchar * name, const gchar * guitext, const g
}
}
}
- }
-
- // Initialize _value with the default value from xml
- // for simplicity : default to the contents of the first xml-child
- const char * defaultval = NULL;
- if (xml->firstChild() && xml->firstChild()->firstChild()) {
- defaultval = xml->firstChild()->attribute("value");
- }
+
+ // 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;
+ 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);
+ Glib::ustring paramval = prefs ? prefs->getString(extension_pref_root + pref_name) : "";
g_free(pref_name);
if (!paramval.empty()) {
- defaultval = paramval.data();
- }
- if (defaultval != NULL) {
- _value = g_strdup(defaultval);
+ _value = g_strdup(paramval.data());
+ } else if (xmlval) {
+ _value = g_strdup(xmlval);
}
}
diff --git a/src/extension/param/notebook.cpp b/src/extension/param/notebook.cpp
index 97002e33f..9ec31ca6b 100644
--- a/src/extension/param/notebook.cpp
+++ b/src/extension/param/notebook.cpp
@@ -214,7 +214,7 @@ Gtk::Widget * ParamNotebookPage::get_widget(SPDocument * doc, Inkscape::XML::Nod
// printf("Tip: '%s'\n", tip);
vbox->pack_start(*widg, false, false, 2);
if (tip) {
- widg->set_tooltip_text(tip);
+ widg->set_tooltip_text(_(tip));
} else {
widg->set_tooltip_text("");
widg->set_has_tooltip(false);
diff --git a/src/extension/param/radiobutton.cpp b/src/extension/param/radiobutton.cpp
index 75d5a40e3..f9515197c 100644
--- a/src/extension/param/radiobutton.cpp
+++ b/src/extension/param/radiobutton.cpp
@@ -122,7 +122,7 @@ ParamRadioButton::ParamRadioButton (const gchar * name,
defaultval = (static_cast<optionentry*> (choices->data))->value->c_str();
}
- const char * indent = xml->attribute("indent");
+ const char *indent = xml ? xml->attribute("indent") : NULL;
if (indent != NULL) {
_indent = atoi(indent) * 12;
}