diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2011-04-07 23:42:04 +0000 |
|---|---|---|
| committer | Krzysztof KosiĆski <tweenk.pl@gmail.com> | 2011-04-07 23:42:04 +0000 |
| commit | 945ce419c806c73d70203dec33ececafbe108a92 (patch) | |
| tree | cfcdb59bf47e9db7f9e01f7eebb59924bdeaea94 /src/extension/param | |
| parent | Merge from trunk (again) (diff) | |
| parent | Extensions. SVG+media fix (see Bug #400356). (diff) | |
| download | inkscape-945ce419c806c73d70203dec33ececafbe108a92.tar.gz inkscape-945ce419c806c73d70203dec33ececafbe108a92.zip | |
Merge from trunk
(bzr r9508.1.73)
Diffstat (limited to 'src/extension/param')
| -rw-r--r-- | src/extension/param/description.cpp | 26 | ||||
| -rw-r--r-- | src/extension/param/description.h | 18 | ||||
| -rw-r--r-- | src/extension/param/float.cpp | 25 | ||||
| -rw-r--r-- | src/extension/param/float.h | 26 | ||||
| -rwxr-xr-x | src/extension/param/groupheader.cpp | 78 | ||||
| -rwxr-xr-x | src/extension/param/groupheader.h | 45 | ||||
| -rw-r--r-- | src/extension/param/int.cpp | 25 | ||||
| -rw-r--r-- | src/extension/param/int.h | 24 | ||||
| -rw-r--r-- | src/extension/param/parameter.cpp | 23 |
9 files changed, 133 insertions, 157 deletions
diff --git a/src/extension/param/description.cpp b/src/extension/param/description.cpp index f17b45b4b..049b7d5a3 100644 --- a/src/extension/param/description.cpp +++ b/src/extension/param/description.cpp @@ -30,8 +30,16 @@ 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) : - Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _value(NULL) +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) { // printf("Building Description\n"); const char * defaultval = NULL; @@ -60,13 +68,21 @@ ParamDescription::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node newguitext = _(_value); } - Gtk::Label * label = Gtk::manage(new Gtk::Label(newguitext, Gtk::ALIGN_LEFT)); - + Gtk::Label * label; + int padding = 12; + if (_mode == HEADER) { + label = Gtk::manage(new Gtk::Label(Glib::ustring("<b>") +newguitext + Glib::ustring("</b>"), Gtk::ALIGN_LEFT)); + label->set_padding(0,5); + label->set_use_markup(true); + padding = 0; + } else { + 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, 12); + hbox->pack_start(*label, true, true, padding); hbox->show(); return hbox; diff --git a/src/extension/param/description.h b/src/extension/param/description.h index c56b5c21d..c34e4ee38 100644 --- a/src/extension/param/description.h +++ b/src/extension/param/description.h @@ -18,13 +18,25 @@ namespace Extension { /** \brief A description parameter */ class ParamDescription : public Parameter { +public: + enum AppearanceMode { + DESC, HEADER + }; + 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); + Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal); private: /** \brief Internal value. */ gchar * _value; + AppearanceMode _mode; 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); }; } /* namespace Extension */ diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp index 62762b3bb..d94463a5b 100644 --- a/src/extension/param/float.cpp +++ b/src/extension/param/float.cpp @@ -11,6 +11,7 @@ #include <gtkmm/adjustment.h> #include <gtkmm/box.h> +#include <gtkmm/scale.h> #include <gtkmm/spinbutton.h> #include "xml/node.h" @@ -23,8 +24,17 @@ namespace Extension { /** \brief 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) : - Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _value(0.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, + 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), _min(0.0), _max(10.0) { const gchar * defaultval = NULL; if (sp_repr_children(xml) != NULL) @@ -110,7 +120,7 @@ public: /** \brief Make the adjustment using an extension and the string describing the parameter. */ ParamFloatAdjustment (ParamFloat * param, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) : - Gtk::Adjustment(0.0, param->min(), param->max(), 0.1, 0), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) { + Gtk::Adjustment(0.0, param->min(), param->max(), 0.1, 1.0, 0), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) { this->set_value(_pref->get(NULL, NULL) /* \todo fix */); this->signal_value_changed().connect(sigc::mem_fun(this, &ParamFloatAdjustment::val_changed)); return; @@ -153,6 +163,15 @@ ParamFloat::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::sign hbox->pack_start(*label, true, true); ParamFloatAdjustment * fadjust = Gtk::manage(new ParamFloatAdjustment(this, doc, node, changeSignal)); + + if (_mode == FULL) { + Gtk::HScale * scale = Gtk::manage(new Gtk::HScale(*fadjust)); + scale->set_draw_value(false); + scale->set_size_request(200, -1); + scale->show(); + hbox->pack_start(*scale, false, false); + } + Gtk::SpinButton * spin = Gtk::manage(new Gtk::SpinButton(*fadjust, 0.1, _precision)); spin->show(); hbox->pack_start(*spin, false, false); diff --git a/src/extension/param/float.h b/src/extension/param/float.h index f105d8f0e..2e816d4dc 100644 --- a/src/extension/param/float.h +++ b/src/extension/param/float.h @@ -17,14 +17,19 @@ namespace Inkscape { namespace Extension { class ParamFloat : public Parameter { -private: - /** \brief Internal value. */ - float _value; - float _min; - float _max; - int _precision; public: - 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); + 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); /** \brief Returns \c _value */ float get (const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) { return _value; } float set (float in, SPDocument * doc, Inkscape::XML::Node * node); @@ -33,6 +38,13 @@ public: float precision (void) { return _precision; } Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal); void string (std::string &string); +private: + /** \brief Internal value. */ + float _value; + AppearanceMode _mode; + float _min; + float _max; + int _precision; }; } /* namespace Extension */ diff --git a/src/extension/param/groupheader.cpp b/src/extension/param/groupheader.cpp deleted file mode 100755 index abf5f8beb..000000000 --- a/src/extension/param/groupheader.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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 deleted file mode 100755 index 94fe880f9..000000000 --- a/src/extension/param/groupheader.h +++ /dev/null @@ -1,45 +0,0 @@ -#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 ae69d0661..69849c656 100644 --- a/src/extension/param/int.cpp +++ b/src/extension/param/int.cpp @@ -11,6 +11,7 @@ #include <gtkmm/adjustment.h> #include <gtkmm/box.h> +#include <gtkmm/scale.h> #include <gtkmm/spinbutton.h> #include "xml/node.h" @@ -23,8 +24,17 @@ namespace Extension { /** \brief 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) : - Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), _value(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, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml, + AppearanceMode mode) : + Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), + _value(0), _mode(mode), _min(0), _max(10) { const char * defaultval = NULL; if (sp_repr_children(xml) != NULL) @@ -95,7 +105,7 @@ public: /** \brief Make the adjustment using an extension and the string describing the parameter. */ ParamIntAdjustment (ParamInt * param, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) : - Gtk::Adjustment(0.0, param->min(), param->max(), 1.0, 0), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) { + Gtk::Adjustment(0.0, param->min(), param->max(), 1.0, 10.0, 0), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) { this->set_value(_pref->get(NULL, NULL) /* \todo fix */); this->signal_value_changed().connect(sigc::mem_fun(this, &ParamIntAdjustment::val_changed)); return; @@ -138,6 +148,15 @@ ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal hbox->pack_start(*label, true, true); ParamIntAdjustment * fadjust = Gtk::manage(new ParamIntAdjustment(this, doc, node, changeSignal)); + + if (_mode == FULL) { + Gtk::HScale * scale = Gtk::manage(new Gtk::HScale(*fadjust)); + scale->set_draw_value(false); + scale->set_size_request(200, -1); + scale->show(); + hbox->pack_start(*scale, false, false); + } + Gtk::SpinButton * spin = Gtk::manage(new Gtk::SpinButton(*fadjust, 1.0, 0)); spin->show(); hbox->pack_start(*spin, false, false); diff --git a/src/extension/param/int.h b/src/extension/param/int.h index a4eb54c81..fce085378 100644 --- a/src/extension/param/int.h +++ b/src/extension/param/int.h @@ -17,13 +17,19 @@ namespace Inkscape { namespace Extension { class ParamInt : public Parameter { -private: - /** \brief Internal value. */ - int _value; - int _min; - int _max; public: - 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); + 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); /** \brief Returns \c _value */ int get (const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) { return _value; } int set (int in, SPDocument * doc, Inkscape::XML::Node * node); @@ -31,6 +37,12 @@ public: int min (void) { return _min; } Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal); void string (std::string &string); +private: + /** \brief Internal value. */ + int _value; + AppearanceMode _mode; + int _min; + int _max; }; } /* namespace Extension */ diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index ac7c8b8dd..a9935cfe6 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -36,7 +36,6 @@ #include "bool.h" #include "color.h" #include "description.h" -#include "groupheader.h" #include "enum.h" #include "float.h" #include "int.h" @@ -124,9 +123,17 @@ Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * if (!strcmp(type, "boolean")) { param = new ParamBool(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); } else if (!strcmp(type, "int")) { - param = new ParamInt(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); + if (appearance && !strcmp(appearance, "full")) { + param = new ParamInt(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamInt::FULL); + } else { + param = new ParamInt(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamInt::MINIMAL); + } } else if (!strcmp(type, "float")) { - param = new ParamFloat(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); + if (appearance && !strcmp(appearance, "full")) { + param = new ParamFloat(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamFloat::FULL); + } else { + param = new ParamFloat(name, guitext, desc, scope, gui_hidden, gui_tip, 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); const gchar * max_length = in_repr->attribute("max_length"); @@ -135,9 +142,11 @@ Parameter::make (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * ps->setMaxLength(atoi(max_length)); } } 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); + 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); + } } 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")) { @@ -349,7 +358,7 @@ Parameter::new_child (Inkscape::XML::Node * parent) Inkscape::XML::Node *Parameter::document_param_node(SPDocument * doc) { Inkscape::XML::Document *xml_doc = doc->getReprDoc(); - Inkscape::XML::Node * defs = SP_OBJECT_REPR(SP_DOCUMENT_DEFS(doc)); + Inkscape::XML::Node * defs = SP_DOCUMENT_DEFS(doc)->getRepr(); Inkscape::XML::Node * params = NULL; GQuark const name_quark = g_quark_from_string("inkscape:extension-params"); |
