From a65a0a21e5452ced77123a8b846ff10cc1bc74b0 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 12 Feb 2017 15:59:14 +0100 Subject: Extensions: Make "indent" attribute a common attribute for all parameters that behaves more consistent and predictable than before. - Every "Parameter" now has an "_indent" member variable (specifying the indentation level; set in "Parameter::make()", see parameter.cpp) - Indentation is achieved by using "set_margin_left()" on the parameter's widget. This fixes bug #1662035 (comment #4 contains some more details about this patch). - Specifying "indent" on a parameter will now work consistently for all parameters. Previously the "indent" attribute often had no effect at all, e.g. for notebooks but also for parameters with 'appearance="full"' which was reasonable in most cases but made the outcome of using this attribute often unpredictable and is unnecessarily restrictive. - Most visible change: "description"s always used an indentation level of at least one (even if no indentation was specified). For the sake of consistency this discrepancy was dropped. Previous appearance can easily be restored by setting 'indent="1"'. Fixed bugs: - https://launchpad.net/bugs/1662035 (bzr r15508) --- src/extension/param/enum.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/extension/param/enum.cpp') diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp index 8bc0fbda7..9f254041a 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(); @@ -253,7 +253,7 @@ Gtk::Widget *ParamComboBox::get_widget(SPDocument * doc, Inkscape::XML::Node * n Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); 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: -- cgit v1.2.3 From a2e57d792590665163dd07eb5e926017e40ccb90 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Mon, 13 Feb 2017 02:46:19 +0100 Subject: Extensions: Work around gtk3 width/height calculation bug for long labels Also use constants for most dimensions so they can easily be chaned in future. (bzr r15511) --- src/extension/param/enum.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/extension/param/enum.cpp') diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp index 9f254041a..a26458c35 100644 --- a/src/extension/param/enum.cpp +++ b/src/extension/param/enum.cpp @@ -250,7 +250,7 @@ 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); -- cgit v1.2.3 From bab6dfe02bd9556c931973a272e154251764e88e Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Mon, 24 Apr 2017 20:59:06 +0200 Subject: Restore r14955 which was reverted in r15047 due to messed up merge http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/revision/14955 http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/revision/15047 Fixed bugs: - https://launchpad.net/bugs/1669951 (bzr r15633) --- src/extension/param/enum.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/extension/param/enum.cpp') diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp index a26458c35..7a79e32bb 100644 --- a/src/extension/param/enum.cpp +++ b/src/extension/param/enum.cpp @@ -251,7 +251,7 @@ Gtk::Widget *ParamComboBox::get_widget(SPDocument * doc, Inkscape::XML::Node * n } 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)); + Gtk::Label * label = Gtk::manage(new Gtk::Label(_text, Gtk::ALIGN_START)); label->show(); hbox->pack_start(*label, false, false); -- cgit v1.2.3 From 34a1f9ad048c2aec2149e0bdaca5e66fca8de442 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 9 Apr 2017 15:20:24 +0200 Subject: Remove unused field "gui_tip" ("gui_description" does now what "gui_tip" was supposed to do) (bzr r15633.1.1) --- src/extension/param/enum.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/extension/param/enum.cpp') diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp index 7a79e32bb..d93ed4b5a 100644 --- a/src/extension/param/enum.cpp +++ b/src/extension/param/enum.cpp @@ -51,11 +51,10 @@ ParamComboBox::ParamComboBox(const gchar * name, 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) + : Parameter(name, guitext, desc, scope, gui_hidden, indent, ext) , _value(NULL) , choices(NULL) { -- cgit v1.2.3 From f0ad38f6fd0d18f48d92df4b55ff8352747e6b2c Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 9 Apr 2017 15:39:40 +0200 Subject: Remove unused field "scope" (bzr r15633.1.2) --- src/extension/param/enum.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/extension/param/enum.cpp') diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp index d93ed4b5a..377bb0f57 100644 --- a/src/extension/param/enum.cpp +++ b/src/extension/param/enum.cpp @@ -49,12 +49,11 @@ public: ParamComboBox::ParamComboBox(const gchar * name, const gchar * guitext, const gchar * desc, - const Parameter::_scope_t scope, bool gui_hidden, int indent, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) - : Parameter(name, guitext, desc, scope, gui_hidden, indent, ext) + : Parameter(name, guitext, desc, gui_hidden, indent, ext) , _value(NULL) , choices(NULL) { -- cgit v1.2.3 From bc1ecf9dd11d0b3bb6939114ce6aec229fc86548 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 9 Apr 2017 16:46:33 +0200 Subject: Some code refactoring for consistency (notably "gui_hidden" -> hidden", "guitext" -> "text", "desc" -> "description") (bzr r15633.1.3) --- src/extension/param/enum.cpp | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'src/extension/param/enum.cpp') diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp index 377bb0f57..7cd860465 100644 --- a/src/extension/param/enum.cpp +++ b/src/extension/param/enum.cpp @@ -33,27 +33,27 @@ namespace Inkscape { namespace Extension { /* For internal use only. - Note that value and guitext MUST be non-NULL. This is ensured by newing only at one location in the code where non-NULL checks are made. */ + Note that value and text MUST be non-NULL. This is ensured by newing only at one location in the code where non-NULL checks are made. */ class enumentry { public: enumentry (Glib::ustring &val, Glib::ustring &text) : value(val), - guitext(text) + text(text) {} Glib::ustring value; - Glib::ustring guitext; + Glib::ustring text; }; ParamComboBox::ParamComboBox(const gchar * name, - const gchar * guitext, - const gchar * desc, - bool gui_hidden, + const gchar * text, + const gchar * description, + bool hidden, int indent, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) - : Parameter(name, guitext, desc, gui_hidden, indent, ext) + : Parameter(name, text, description, hidden, indent, ext) , _value(NULL) , choices(NULL) { @@ -64,7 +64,7 @@ ParamComboBox::ParamComboBox(const gchar * name, 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; + Glib::ustring newtext, newvalue; const char * contents = NULL; if (node->firstChild()) { contents = node->firstChild()->content(); @@ -75,12 +75,12 @@ ParamComboBox::ParamComboBox(const gchar * name, // 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); + newtext = g_dpgettext2(NULL, node->attribute("msgctxt"), contents); } else { - newguitext = _(contents); + newtext = _(contents); } } else { - newguitext = contents; + newtext = contents; } } else continue; @@ -92,8 +92,8 @@ ParamComboBox::ParamComboBox(const gchar * name, newvalue = contents; } - if ( (!newguitext.empty()) && (!newvalue.empty()) ) { // logical error if this is not true here - choices = g_slist_append( choices, new enumentry(newvalue, newguitext) ); + if ( (!newtext.empty()) && (!newvalue.empty()) ) { // logical error if this is not true here + choices = g_slist_append( choices, new enumentry(newvalue, newtext) ); } } } @@ -153,7 +153,7 @@ const gchar *ParamComboBox::set(const gchar * in, SPDocument * /*doc*/, Inkscape Glib::ustring settext; for (GSList * list = choices; list != NULL; list = g_slist_next(list)) { enumentry * entr = reinterpret_cast(list->data); - if ( !entr->guitext.compare(in) ) { + if ( !entr->text.compare(in) ) { settext = entr->value; break; // break out of for loop } @@ -173,20 +173,20 @@ const gchar *ParamComboBox::set(const gchar * in, SPDocument * /*doc*/, Inkscape } /** - * function to test if \c guitext is selectable + * function to test if \c text is selectable */ -bool ParamComboBox::contains(const gchar * guitext, SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/) const +bool ParamComboBox::contains(const gchar * text, SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/) const { - if (guitext == NULL) { + if (text == NULL) { return false; /* Can't have NULL string */ } for (GSList * list = choices; list != NULL; list = g_slist_next(list)) { enumentry * entr = reinterpret_cast(list->data); - if ( !entr->guitext.compare(guitext) ) + if ( !entr->text.compare(text) ) return true; } - // if we did not find the guitext in this ParamComboBox: + // if we did not find the text in this ParamComboBox: return false; } @@ -244,7 +244,7 @@ ParamComboBoxEntry::changed (void) */ Gtk::Widget *ParamComboBox::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal) { - if (_gui_hidden) { + if (_hidden) { return NULL; } @@ -258,11 +258,11 @@ Gtk::Widget *ParamComboBox::get_widget(SPDocument * doc, Inkscape::XML::Node * n Glib::ustring settext; for (GSList * list = choices; list != NULL; list = g_slist_next(list)) { enumentry * entr = reinterpret_cast(list->data); - Glib::ustring text = entr->guitext; + Glib::ustring text = entr->text; combo->append(text); if ( _value && !entr->value.compare(_value) ) { - settext = entr->guitext; + settext = entr->text; } } if (!settext.empty()) { -- cgit v1.2.3