summaryrefslogtreecommitdiffstats
path: root/src/extension/param
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2010-11-25 20:51:17 +0000
committerKrzysztof KosiƄski <tweenk.pl@gmail.com>2010-11-25 20:51:17 +0000
commit0bd9f7e209d522dbcebe0449a91397fdd9e38977 (patch)
tree834c7d02456658b57625ab68cc28f7854a5a85dc /src/extension/param
parentFix handling of x and y attributes of patterns (diff)
parentFix ruler redraw issue on GTK 2.22 (diff)
downloadinkscape-0bd9f7e209d522dbcebe0449a91397fdd9e38977.tar.gz
inkscape-0bd9f7e209d522dbcebe0449a91397fdd9e38977.zip
Merge from trunk
(bzr r9508.1.70)
Diffstat (limited to 'src/extension/param')
-rw-r--r--src/extension/param/CMakeLists.txt1
-rw-r--r--src/extension/param/bool.cpp6
-rw-r--r--src/extension/param/description.cpp17
-rw-r--r--src/extension/param/description.h1
-rw-r--r--src/extension/param/enum.cpp14
-rw-r--r--src/extension/param/float.cpp4
-rwxr-xr-xsrc/extension/param/groupheader.cpp78
-rwxr-xr-xsrc/extension/param/groupheader.h45
-rw-r--r--src/extension/param/int.cpp2
-rw-r--r--src/extension/param/notebook.cpp6
-rw-r--r--src/extension/param/parameter.cpp8
-rw-r--r--src/extension/param/parameter.h2
-rw-r--r--src/extension/param/radiobutton.cpp18
13 files changed, 180 insertions, 22 deletions
diff --git a/src/extension/param/CMakeLists.txt b/src/extension/param/CMakeLists.txt
index 843de8b7a..2ef5d5005 100644
--- a/src/extension/param/CMakeLists.txt
+++ b/src/extension/param/CMakeLists.txt
@@ -2,6 +2,7 @@ SET(extension_param_SRC
bool.cpp
color.cpp
description.cpp
+groupheader.cpp
enum.cpp
parameter.cpp
float.cpp
diff --git a/src/extension/param/bool.cpp b/src/extension/param/bool.cpp
index 1dda3d73f..a8a410382 100644
--- a/src/extension/param/bool.cpp
+++ b/src/extension/param/bool.cpp
@@ -139,9 +139,9 @@ ParamBool::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signa
Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_LEFT));
label->show();
- hbox->pack_start(*label, true, true);
+ hbox->pack_end(*label, true, true);
- ParamBoolCheckButton * checkbox = new ParamBoolCheckButton(this, doc, node, changeSignal);
+ ParamBoolCheckButton * checkbox = Gtk::manage(new ParamBoolCheckButton(this, doc, node, changeSignal));
checkbox->show();
hbox->pack_start(*checkbox, false, false);
@@ -162,4 +162,4 @@ ParamBool::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signa
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/extension/param/description.cpp b/src/extension/param/description.cpp
index 656e58c49..f17b45b4b 100644
--- a/src/extension/param/description.cpp
+++ b/src/extension/param/description.cpp
@@ -40,7 +40,9 @@ ParamDescription::ParamDescription (const gchar * name, const gchar * guitext, c
if (defaultval != NULL)
_value = g_strdup(defaultval);
-
+
+ _context = xml->attribute("msgctxt");
+
return;
}
@@ -50,12 +52,21 @@ ParamDescription::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node
{
if (_gui_hidden) return NULL;
- Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_value)));
+ Glib::ustring newguitext;
+
+ if (_context != NULL) {
+ newguitext = g_dpgettext2(NULL, _context, _value);
+ } else {
+ newguitext = _(_value);
+ }
+
+ Gtk::Label * label = Gtk::manage(new Gtk::Label(newguitext, Gtk::ALIGN_LEFT));
+
label->set_line_wrap();
label->show();
Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
- hbox->pack_start(*label, true, true, 5);
+ hbox->pack_start(*label, true, true, 12);
hbox->show();
return hbox;
diff --git a/src/extension/param/description.h b/src/extension/param/description.h
index c305ea6df..c56b5c21d 100644
--- a/src/extension/param/description.h
+++ b/src/extension/param/description.h
@@ -21,6 +21,7 @@ class ParamDescription : public Parameter {
private:
/** \brief Internal value. */
gchar * _value;
+ const gchar* _context;
public:
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);
Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp
index 03c1f839b..9ed5aac16 100644
--- a/src/extension/param/enum.cpp
+++ b/src/extension/param/enum.cpp
@@ -63,12 +63,20 @@ ParamComboBox::ParamComboBox (const gchar * name, const gchar * guitext, const g
Glib::ustring newguitext, newvalue;
const char * contents = NULL;
if (node->firstChild()) contents = node->firstChild()->content();
- if (contents != NULL)
+ 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
- newguitext = !strcmp(chname, INKSCAPE_EXTENSION_NS "_item") ? _(contents) : contents;
- else
+ if (!strcmp(chname, INKSCAPE_EXTENSION_NS "_item")) {
+ if (node->attribute("msgctxt") != NULL) {
+ newguitext = g_dpgettext2(NULL, node->attribute("msgctxt"), contents);
+ } else {
+ newguitext = _(contents);
+ }
+ } else {
+ newguitext = contents;
+ }
+ } else
continue;
const char * val = node->attribute("value");
diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp
index 5dce0f9e3..62762b3bb 100644
--- a/src/extension/param/float.cpp
+++ b/src/extension/param/float.cpp
@@ -35,11 +35,11 @@ ParamFloat::ParamFloat (const gchar * name, const gchar * guitext, const gchar *
const char * maxval = xml->attribute("max");
if (maxval != NULL)
- _max = atof(maxval);
+ _max = g_ascii_strtod (maxval,NULL);
const char * minval = xml->attribute("min");
if (minval != NULL)
- _min = atof(minval);
+ _min = g_ascii_strtod (minval,NULL);
_precision = 1;
const char * precision = xml->attribute("precision");
diff --git a/src/extension/param/groupheader.cpp b/src/extension/param/groupheader.cpp
new file mode 100755
index 000000000..abf5f8beb
--- /dev/null
+++ b/src/extension/param/groupheader.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2005-2010 Authors:
+ * Ted Gould <ted@gould.cx>
+ * Johan Engelen <johan@shouraizou.nl> *
+ * Nicolas Dufour <nicoduf@yahoo.fr>
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifdef linux // does the dollar sign need escaping when passed as string parameter?
+# define ESCAPE_DOLLAR_COMMANDLINE
+#endif
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+
+#include "groupheader.h"
+
+#include <gtkmm/adjustment.h>
+#include <gtkmm/box.h>
+#include <gtkmm/spinbutton.h>
+#include <sstream>
+#include <glibmm/i18n.h>
+
+#include "xml/node.h"
+#include "extension/extension.h"
+
+namespace Inkscape {
+namespace Extension {
+
+
+/** \brief Initialize the object, to do that, copy the data. */
+ParamGroupHeader::ParamGroupHeader (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)
+{
+ // printf("Building GroupHeader\n");
+ const char * defaultval = NULL;
+ if (sp_repr_children(xml) != NULL)
+ defaultval = sp_repr_children(xml)->content();
+
+ if (defaultval != NULL)
+ _value = g_strdup(defaultval);
+
+ _context = xml->attribute("msgctxt");
+
+ return;
+}
+
+/** \brief Create a label for the GroupHeader */
+Gtk::Widget *
+ParamGroupHeader::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * /*changeSignal*/)
+{
+ if (_gui_hidden) return NULL;
+
+ Glib::ustring newguitext;
+
+ if (_context != NULL) {
+ newguitext = g_dpgettext2(NULL, _context, _value);
+ } else {
+ newguitext = _(_value);
+ }
+
+ Gtk::Label * label = Gtk::manage(new Gtk::Label(Glib::ustring("<b>") +newguitext + Glib::ustring("</b>"), Gtk::ALIGN_LEFT));
+ label->set_line_wrap();
+ label->set_padding(0,5);
+ label->set_use_markup(true);
+ label->show();
+
+ Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
+ hbox->pack_start(*label, true, true);
+ hbox->show();
+
+ return hbox;
+}
+
+} /* namespace Extension */
+} /* namespace Inkscape */
diff --git a/src/extension/param/groupheader.h b/src/extension/param/groupheader.h
new file mode 100755
index 000000000..94fe880f9
--- /dev/null
+++ b/src/extension/param/groupheader.h
@@ -0,0 +1,45 @@
+#ifndef __INK_EXTENSION_PARAMGROUPHEADER_H__
+#define __INK_EXTENSION_PARAMGROUPHEADER_H__
+
+/*
+ * Copyright (C) 2005-2010 Authors:
+ * Ted Gould <ted@gould.cx>
+ * Johan Engelen <johan@shouraizou.nl> *
+ * Nicolas Dufour <nicoduf@yahoo.fr>
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <gtkmm/widget.h>
+#include <xml/node.h>
+#include <document.h>
+#include "parameter.h"
+
+namespace Inkscape {
+namespace Extension {
+
+/** \brief A GroupLabel parameter */
+class ParamGroupHeader : public Parameter {
+private:
+ /** \brief Internal value. */
+ gchar * _value;
+ const gchar* _context;
+public:
+ ParamGroupHeader(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);
+ Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal);
+};
+
+} /* namespace Extension */
+} /* namespace Inkscape */
+
+#endif /* __INK_EXTENSION_PARAMGROUPHEADER_H__ */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/extension/param/int.cpp b/src/extension/param/int.cpp
index 301d54ed0..ae69d0661 100644
--- a/src/extension/param/int.cpp
+++ b/src/extension/param/int.cpp
@@ -169,4 +169,4 @@ ParamInt::string (std::string &string)
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/extension/param/notebook.cpp b/src/extension/param/notebook.cpp
index 1c30b7e0e..86e3cefe6 100644
--- a/src/extension/param/notebook.cpp
+++ b/src/extension/param/notebook.cpp
@@ -210,8 +210,8 @@ ParamNotebookPage::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sig
Parameter * param = reinterpret_cast<Parameter *>(list->data);
Gtk::Widget * widg = param->get_widget(doc, node, changeSignal);
gchar const * tip = param->get_tooltip();
-
- vbox->pack_start(*widg, true, true, 2);
+// printf("Tip: '%s'\n", tip);
+ vbox->pack_start(*widg, false, false, 2);
if (tip != NULL) {
_tooltips->set_tip(*widg, Glib::ustring(tip));
}
@@ -428,4 +428,4 @@ ParamNotebook::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::s
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp
index 3320cddca..1347653a2 100644
--- a/src/extension/param/parameter.cpp
+++ b/src/extension/param/parameter.cpp
@@ -35,6 +35,7 @@
#include "bool.h"
#include "color.h"
#include "description.h"
+#include "groupheader.h"
#include "enum.h"
#include "float.h"
#include "int.h"
@@ -134,6 +135,8 @@ Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension *
}
} else if (!strcmp(type, "description")) {
param = new ParamDescription(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr);
+ } else if (!strcmp(type, "groupheader")) {
+ param = new ParamGroupHeader(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr);
} else if (!strcmp(type, "enum")) {
param = new ParamComboBox(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr);
} else if (!strcmp(type, "notebook")) {
@@ -294,7 +297,7 @@ Parameter::Parameter (const gchar * name, const gchar * guitext, const gchar * d
}
if (desc != NULL) {
_desc = g_strdup(desc);
- // printf("Adding description: '%s' on '%s'\n", _desc, _name);
+// printf("Adding description: '%s' on '%s'\n", _desc, _name);
}
if (gui_tip != NULL) {
_gui_tip = g_strdup(gui_tip);
@@ -315,6 +318,7 @@ Parameter::~Parameter (void)
g_free(_name);
g_free(_text);
g_free(_gui_tip);
+ g_free(_desc);
}
/** \brief Build the name to write the parameter from the extension's
@@ -419,4 +423,4 @@ Glib::ustring const extension_pref_root = "/extensions/";
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/extension/param/parameter.h b/src/extension/param/parameter.h
index c62dad9cc..beddf5936 100644
--- a/src/extension/param/parameter.h
+++ b/src/extension/param/parameter.h
@@ -136,4 +136,4 @@ public:
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/extension/param/radiobutton.cpp b/src/extension/param/radiobutton.cpp
index c17839001..23655baea 100644
--- a/src/extension/param/radiobutton.cpp
+++ b/src/extension/param/radiobutton.cpp
@@ -84,12 +84,22 @@ ParamRadioButton::ParamRadioButton (const gchar * name,
Glib::ustring * newvalue = NULL;
const char * contents = sp_repr_children(child_repr)->content();
- if (contents != NULL)
- // don't translate when 'option' but do translate when '_option'
- newguitext = new Glib::ustring( !strcmp(chname, INKSCAPE_EXTENSION_NS "_option") ? _(contents) : contents );
- else
+ if (contents != NULL) {
+ // don't translate when 'item' but do translate when '_option'
+ if (!strcmp(chname, INKSCAPE_EXTENSION_NS "_option")) {
+ if (child_repr->attribute("msgctxt") != NULL) {
+ newguitext = new Glib::ustring(g_dpgettext2(NULL, child_repr->attribute("msgctxt"), contents));
+ } else {
+ newguitext = new Glib::ustring(_(contents));
+ }
+ } else {
+ newguitext = new Glib::ustring(contents);
+ }
+ } else
continue;
+
+
const char * val = child_repr->attribute("value");
if (val != NULL)
newvalue = new Glib::ustring(val);