From 939f84facd2f8beb4f5a1601c09bf7b71f1274a0 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 25 Mar 2011 16:09:55 +0100 Subject: Extensions. Replacing the groupheader element with an appearance mode in the description element. (bzr r10129) --- src/extension/Makefile_insert | 2 - src/extension/internal/filter/experimental.h | 6 +-- src/extension/param/description.cpp | 26 ++++++++-- src/extension/param/description.h | 18 +++++-- src/extension/param/groupheader.cpp | 78 ---------------------------- src/extension/param/groupheader.h | 45 ---------------- src/extension/param/parameter.cpp | 9 ++-- 7 files changed, 44 insertions(+), 140 deletions(-) delete mode 100755 src/extension/param/groupheader.cpp delete mode 100755 src/extension/param/groupheader.h (limited to 'src') diff --git a/src/extension/Makefile_insert b/src/extension/Makefile_insert index b9ce224ca..ffcee5f9a 100644 --- a/src/extension/Makefile_insert +++ b/src/extension/Makefile_insert @@ -24,8 +24,6 @@ ink_common_sources += \ extension/param/color.cpp \ extension/param/description.h \ extension/param/description.cpp \ - extension/param/groupheader.h \ - extension/param/groupheader.cpp \ extension/param/enum.h \ extension/param/enum.cpp \ extension/param/float.h \ diff --git a/src/extension/internal/filter/experimental.h b/src/extension/internal/filter/experimental.h index 6617866f5..efc35b418 100755 --- a/src/extension/internal/filter/experimental.h +++ b/src/extension/internal/filter/experimental.h @@ -331,16 +331,16 @@ public: "org.inkscape.effect.filter.Drawing\n" "\n" "\n" - "<_param name=\"simplifyheader\" type=\"groupheader\">Simplify\n" + "<_param name=\"simplifyheader\" type=\"description\" appearance=\"header\">Simplify\n" "0.6\n" "10\n" "0\n" "false\n" - "<_param name=\"smoothheader\" type=\"groupheader\">Smoothness\n" + "<_param name=\"smoothheader\" type=\"description\" appearance=\"header\">Smoothness\n" "0.6\n" "6\n" "2\n" - "<_param name=\"meltheader\" type=\"groupheader\">Melt\n" + "<_param name=\"meltheader\" type=\"description\" appearance=\"header\">Melt\n" "1\n" "6\n" "2\n" 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("") +newguitext + Glib::ustring(""), 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 * 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 * changeSignal); }; } /* 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 - * Johan Engelen * - * Nicolas Dufour - * 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 -#include -#include -#include -#include - -#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 * /*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("") +newguitext + Glib::ustring(""), 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 - * Johan Engelen * - * Nicolas Dufour - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include -#include -#include -#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 * 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/parameter.cpp b/src/extension/param/parameter.cpp index d35fb3d3c..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" @@ -143,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")) { -- cgit v1.2.3