diff options
| author | Michael Soegtrop <MSoegtrop@yahoo.de> | 2017-06-05 13:01:17 +0000 |
|---|---|---|
| committer | Michael Soegtrop <MSoegtrop@yahoo.de> | 2017-06-05 13:01:17 +0000 |
| commit | e7248b2fa042f42a5c4dd14cd86ab6a5b4524059 (patch) | |
| tree | 9097520c54e355ded9bd0b4d6618af4e8dacdd91 /src/extension | |
| parent | updated to latest trunk (diff) | |
| parent | [Bug #1695016] Xaml export misses some radialGradients. (diff) | |
| download | inkscape-e7248b2fa042f42a5c4dd14cd86ab6a5b4524059.tar.gz inkscape-e7248b2fa042f42a5c4dd14cd86ab6a5b4524059.zip | |
updated to latest trunk
(bzr r14876.2.4)
Diffstat (limited to 'src/extension')
68 files changed, 973 insertions, 1105 deletions
diff --git a/src/extension/Makefile_insert b/src/extension/Makefile_insert deleted file mode 100644 index fb9713904..000000000 --- a/src/extension/Makefile_insert +++ /dev/null @@ -1,54 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - extension/extension.cpp \ - extension/extension.h \ - extension/db.cpp \ - extension/db.h \ - extension/dependency.cpp \ - extension/dependency.h \ - extension/error-file.cpp \ - extension/error-file.h \ - extension/execution-env.cpp \ - extension/execution-env.h \ - extension/init.cpp \ - extension/init.h \ - extension/loader.h \ - extension/loader.cpp \ - extension/param/parameter.h \ - extension/param/parameter.cpp \ - extension/param/notebook.h \ - extension/param/notebook.cpp \ - extension/param/bool.h \ - extension/param/bool.cpp \ - extension/param/color.h \ - extension/param/color.cpp \ - extension/param/description.h \ - extension/param/description.cpp \ - extension/param/enum.h \ - extension/param/enum.cpp \ - extension/param/float.h \ - extension/param/float.cpp \ - extension/param/int.h \ - extension/param/int.cpp \ - extension/param/radiobutton.h \ - extension/param/radiobutton.cpp \ - extension/param/string.h \ - extension/param/string.cpp \ - extension/prefdialog.cpp \ - extension/prefdialog.h \ - extension/system.cpp \ - extension/system.h \ - extension/timer.cpp \ - extension/timer.h \ - extension/input.h \ - extension/input.cpp \ - extension/output.h \ - extension/output.cpp \ - extension/effect.h \ - extension/effect.cpp \ - extension/patheffect.h \ - extension/patheffect.cpp \ - extension/print.h \ - extension/print.cpp - diff --git a/src/extension/db.cpp b/src/extension/db.cpp index a3c54915d..e885d3531 100644 --- a/src/extension/db.cpp +++ b/src/extension/db.cpp @@ -13,7 +13,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include "db.h" #include "input.h" @@ -35,6 +35,76 @@ DB db; DB::DB (void) { } + +struct ModuleInputCmp { + bool operator()(Input* module1, Input* module2) const { + + // Ensure SVG files are at top + int n1 = 0; + int n2 = 0; + // 12345678901234567890123456789012 + if (strncmp(module1->get_id(),"org.inkscape.input.svg", 22) == 0) n1 = 1; + if (strncmp(module2->get_id(),"org.inkscape.input.svg", 22) == 0) n2 = 1; + if (strncmp(module1->get_id(),"org.inkscape.input.svgz", 23) == 0) n1 = 2; + if (strncmp(module2->get_id(),"org.inkscape.input.svgz", 23) == 0) n2 = 2; + + if (n1 != 0 && n2 != 0) return (n1 < n2); + if (n1 != 0) return true; + if (n2 != 0) return false; + + // GDK filetypenames begin with lower case letters and thus are sorted at the end. + // Special case "sK1" which starts with a lower case letter to keep it out of GDK region. + if (strncmp(module1->get_id(),"org.inkscape.input.sk1", 22) == 0) { + return ( strcmp("SK1", module2->get_filetypename()) <= 0 ); + } + if (strncmp(module2->get_id(),"org.inkscape.input.sk1", 22) == 0) { + return ( strcmp(module1->get_filetypename(), "SK1" ) <= 0 ); + } + + return ( strcmp(module1->get_filetypename(), module2->get_filetypename()) <= 0 ); + } +}; + + +struct ModuleOutputCmp { + bool operator()(Output* module1, Output* module2) const { + + // Ensure SVG files are at top + int n1 = 0; + int n2 = 0; + // 12345678901234567890123456789012 + if (strncmp(module1->get_id(),"org.inkscape.output.svg.inkscape", 32) == 0) n1 = 1; + if (strncmp(module2->get_id(),"org.inkscape.output.svg.inkscape", 32) == 0) n2 = 1; + if (strncmp(module1->get_id(),"org.inkscape.output.svg.plain", 29) == 0) n1 = 2; + if (strncmp(module2->get_id(),"org.inkscape.output.svg.plain", 29) == 0) n2 = 2; + if (strncmp(module1->get_id(),"org.inkscape.output.svgz.inkscape", 33) == 0) n1 = 3; + if (strncmp(module2->get_id(),"org.inkscape.output.svgz.inkscape", 33) == 0) n2 = 3; + if (strncmp(module1->get_id(),"org.inkscape.output.svgz.plain", 30) == 0) n1 = 4; + if (strncmp(module2->get_id(),"org.inkscape.output.svgz.plain", 30) == 0) n2 = 4; + if (strncmp(module1->get_id(),"org.inkscape.output.scour", 25) == 0) n1 = 5; + if (strncmp(module2->get_id(),"org.inkscape.output.scour", 25) == 0) n2 = 5; + if (strncmp(module1->get_id(),"org.inkscape.output.ZIP", 23) == 0) n1 = 6; + if (strncmp(module2->get_id(),"org.inkscape.output.ZIP", 23) == 0) n2 = 6; + if (strncmp(module1->get_id(),"org.inkscape.output.LAYERS", 26) == 0) n1 = 7; + if (strncmp(module2->get_id(),"org.inkscape.output.LAYERS", 26) == 0) n2 = 7; + + if (n1 != 0 && n2 != 0) return (n1 < n2); + if (n1 != 0) return true; + if (n2 != 0) return false; + + // Special case "sK1" which starts with a lower case letter. + if (strncmp(module1->get_id(),"org.inkscape.output.sk1", 23) == 0) { + return ( strcmp("SK1", module2->get_filetypename()) <= 0 ); + } + if (strncmp(module2->get_id(),"org.inkscape.output.sk1", 23) == 0) { + return ( strcmp(module1->get_filetypename(), "SK1" ) <= 0 ); + } + + return ( strcmp(module1->get_filetypename(), module2->get_filetypename()) <= 0 ); + } +}; + + /** \brief Add a module to the module database \param module The module to be registered. @@ -49,10 +119,12 @@ DB::register_ext (Extension *module) bool add_to_list = ( moduledict.find(module->get_id()) == moduledict.end()); - //printf("Registering: '%s' add:%d\n", module->get_id(), add_to_list); + //printf("Registering: '%s' '%s' add:%d\n", module->get_id(), module->get_name(), add_to_list); moduledict[module->get_id()] = module; - if (add_to_list) modulelist.push_back(module); + if (add_to_list) { + modulelist.push_back( module ); + } } /** @@ -85,7 +157,7 @@ DB::unregister_ext (Extension * module) Extension * DB::get (const gchar *key) { - if (key == NULL) return NULL; + if (key == NULL) return NULL; Extension *mod = moduledict[key]; if ( !mod || mod->deactivated() ) @@ -207,6 +279,7 @@ DB::InputList & DB::get_input_list (DB::InputList &ou_list) { foreach(input_internal, (gpointer)&ou_list); + ou_list.sort( ModuleInputCmp() ); return ou_list; } @@ -220,6 +293,7 @@ DB::OutputList & DB::get_output_list (DB::OutputList &ou_list) { foreach(output_internal, (gpointer)&ou_list); + ou_list.sort( ModuleOutputCmp() ); return ou_list; } diff --git a/src/extension/dbus/Makefile_insert b/src/extension/dbus/Makefile_insert deleted file mode 100644 index 192651d87..000000000 --- a/src/extension/dbus/Makefile_insert +++ /dev/null @@ -1,111 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -if WITH_DBUS - -############################# -# Sources for DBus interface -############################# - -ink_common_sources += \ - extension/dbus/dbus-init.cpp \ - extension/dbus/dbus-init.h \ - extension/dbus/application-interface.cpp \ - extension/dbus/application-interface.h \ - extension/dbus/document-interface.cpp \ - extension/dbus/document-interface.h \ - extension/dbus/org.inkscape.service.in - -########################### -# Build DBus wrapper files -########################### - -extension/dbus/application-server-glue.h: extension/dbus/application-interface.xml - dbus-binding-tool --mode=glib-server --output=$@ --prefix=application_interface $^ - -extension/dbus/document-server-glue.h: extension/dbus/document-interface.xml - dbus-binding-tool --mode=glib-server --output=$@ --prefix=document_interface $^ - -extension/dbus/document-client-glue.h: extension/dbus/document-interface.xml - dbus-binding-tool --mode=glib-client --output=$@ --prefix=document_interface $^ - -BUILT_SOURCES += \ - extension/dbus/application-server-glue.h \ - extension/dbus/document-server-glue.h \ - extension/dbus/document-client-glue.h - -########################### -# Distribut DBus interface -########################### - -EXTRA_DIST += \ - extension/dbus/application-interface.xml \ - extension/dbus/document-interface.xml - -########################### -# DBus Activation Service -########################### - -# Dbus service file -servicedir = $(DBUSSERVICEDIR) -service_in_files = extension/dbus/org.inkscape.service.in -service_DATA = $(service_in_files:.service.in=.service) - -# Rule to make the service file with bindir expanded -$(service_DATA): $(service_in_files) Makefile - @sed -e "s|bindir|$(prefix)|" $<> $@ - -############################ -# DBus Interface Helper Lib -############################ - -lib_LTLIBRARIES = \ - libinkdbus.la - -libinkdbusincludedir = $(includedir)/libinkdbus-0.48/libinkdbus -libinkdbusinclude_HEADERS = \ - extension/dbus/wrapper/inkscape-dbus-wrapper.h - -libinkdbus_la_SOURCES = \ - extension/dbus/wrapper/inkscape-dbus-wrapper.h \ - extension/dbus/wrapper/inkscape-dbus-wrapper.c - -libinkdbus_la_LDFLAGS = \ - -version-info 0:0:0 \ - -no-undefined \ - -export-symbols-regex "^[^_d].*" - -libinkdbus_la_CFLAGS = \ - $(DBUS_CFLAGS) \ - $(INKSCAPE_CFLAGS) \ - -I$(builddir)/extension/dbus \ - -Wall - -libinkdbus_la_LIBADD = \ - $(DBUS_LIBS) \ - $(INKSCAPE_LIBS) - -############################ -# DBus Pkgconfig file -############################ - -pkgconfig_DATA = extension/dbus/wrapper/inkdbus.pc -pkgconfigdir = $(libdir)/pkgconfig - -else # WITH_DBUS - -EXTRA_DIST += \ - extension/dbus/dbus-init.cpp \ - extension/dbus/dbus-init.h \ - extension/dbus/application-interface.cpp \ - extension/dbus/application-interface.h \ - extension/dbus/document-interface.cpp \ - extension/dbus/document-interface.h \ - extension/dbus/wrapper/inkscape-dbus-wrapper.h \ - extension/dbus/wrapper/inkscape-dbus-wrapper.c \ - extension/dbus/wrapper/inkdbus.pc \ - extension/dbus/org.inkscape.service.in \ - extension/dbus/application-interface.xml \ - extension/dbus/document-interface.xml - -endif - diff --git a/src/extension/dbus/builddocs.sh b/src/extension/dbus/builddocs.sh index 2c16daf41..2c16daf41 100755..100644 --- a/src/extension/dbus/builddocs.sh +++ b/src/extension/dbus/builddocs.sh diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp index d0a2e81aa..435e347d0 100644 --- a/src/extension/dbus/document-interface.cpp +++ b/src/extension/dbus/document-interface.cpp @@ -189,7 +189,7 @@ selection_get_center_y (Inkscape::Selection *sel){ std::vector<SPObject*> selection_swap(Inkscape::Selection *sel, gchar *name, GError **error) { - std::vector<SPObject*> oldsel = sel->list(); + std::vector<SPObject*> oldsel = std::vector<SPObject*>(sel->objects().begin(), sel->objects().end()); sel->set(get_object_by_name(sel->layers()->getDocument(), name, error)); return oldsel; @@ -405,7 +405,7 @@ document_interface_polygon (DocumentInterface *doc_interface, int cx, int cy, int radius, int rotation, int sides, GError **error) { - gdouble rot = ((rotation / 180.0) * 3.14159265) - ( 3.14159265 / 2.0); + gdouble rot = ((rotation / 180.0) * M_PI) - M_PI_2; Inkscape::XML::Node *newNode = dbus_create_node(doc_interface->target.getDocument(), "svg:path"); newNode->setAttribute("inkscape:flatsided", "true"); newNode->setAttribute("sodipodi:type", "star"); @@ -606,11 +606,7 @@ document_interface_document_set_display_area (DocumentInterface *doc_interface, { SPDesktop *desk = doc_interface->target.getDesktop(); g_return_val_if_fail(ensure_desktop_valid(desk, error), FALSE); - desk->set_display_area (x0, - y0, - x1, - y1, - border, false); + desk->set_display_area (Geom::Rect( Geom::Point(x0,y0), Geom::Point(x1,y1)), border, false ); return TRUE; } @@ -713,7 +709,7 @@ document_interface_move (DocumentInterface *doc_interface, gchar *name, gdouble std::vector<SPObject*> oldsel = selection_swap(doc_interface->target.getSelection(), name, error); if (oldsel.empty()) return FALSE; - sp_selection_move (doc_interface->target.getSelection(), x, 0 - y); + doc_interface->target.getSelection()->move(x, 0 - y); selection_restore(doc_interface->target.getSelection(), oldsel); return TRUE; } @@ -726,7 +722,7 @@ document_interface_move_to (DocumentInterface *doc_interface, gchar *name, gdoub if (oldsel.empty()) return FALSE; Inkscape::Selection * sel = doc_interface->target.getSelection(); - sp_selection_move (doc_interface->target.getSelection(), x - selection_get_center_x(sel), + doc_interface->target.getSelection()->move(x - selection_get_center_x(sel), 0 - (y - selection_get_center_y(sel))); selection_restore(doc_interface->target.getSelection(), oldsel); return TRUE; @@ -1087,14 +1083,14 @@ void document_interface_update(DocumentInterface *doc_interface, GError ** error gboolean document_interface_selection_get(DocumentInterface *doc_interface, char ***out, GError ** /*error*/) { Inkscape::Selection * sel = doc_interface->target.getSelection(); - std::vector<SPObject*> oldsel = sel->list(); + auto oldsel = sel->objects(); int size = oldsel.size(); *out = g_new0 (char *, size + 1); int i = 0; - for (std::vector<SPObject*>::iterator iter = oldsel.begin(), e = oldsel.end(); iter != e; ++iter) { + for (auto iter = oldsel.begin(); iter != oldsel.end(); ++iter) { (*out)[i] = g_strdup((*iter)->getId()); i++; } @@ -1150,7 +1146,7 @@ document_interface_selection_set_list (DocumentInterface *doc_interface, gboolean document_interface_selection_rotate(DocumentInterface *doc_interface, int angle, GError ** /*error*/) { Inkscape::Selection *selection = doc_interface->target.getSelection(); - sp_selection_rotate(selection, angle); + selection->rotate(angle); return TRUE; } @@ -1235,13 +1231,13 @@ gboolean document_interface_selection_scale(DocumentInterface *doc_interface, gd { return FALSE; } - sp_selection_scale (selection, grow); + selection->scale(grow); return TRUE; } gboolean document_interface_selection_move(DocumentInterface *doc_interface, gdouble x, gdouble y, GError ** /*error*/) { - sp_selection_move(doc_interface->target.getSelection(), x, 0 - y); //switching coordinate systems. + doc_interface->target.getSelection()->move(x, 0 - y); //switching coordinate systems. return TRUE; } @@ -1252,7 +1248,7 @@ gboolean document_interface_selection_move_to(DocumentInterface *doc_interface, Geom::OptRect sel_bbox = sel->visualBounds(); if (sel_bbox) { Geom::Point m( x - selection_get_center_x(sel) , 0 - (y - selection_get_center_y(sel)) ); - sp_selection_move_relative(sel, m, true); + sel->moveRelative(m, true); } return TRUE; } @@ -1279,8 +1275,8 @@ document_interface_selection_move_to_layer (DocumentInterface *doc_interface, return FALSE; if (strcmp("layer", (next->getRepr())->attribute("inkscape:groupmode")) == 0) { - - sp_selection_cut(dt); + + dt->selection->cut(); doc_interface->target.getSelection()->layers()->setCurrentLayer(next); diff --git a/src/extension/dependency.cpp b/src/extension/dependency.cpp index 624be12f9..837520381 100644 --- a/src/extension/dependency.cpp +++ b/src/extension/dependency.cpp @@ -9,14 +9,12 @@ */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include <config.h> #endif #include <glibmm/i18n.h> #include <glibmm/fileutils.h> #include <glibmm/miscutils.h> -#include "config.h" -#include "path-prefix.h" #include "dependency.h" #include "db.h" #include "extension.h" diff --git a/src/extension/effect.cpp b/src/extension/effect.cpp index e7299ba51..ef254f623 100644 --- a/src/extension/effect.cpp +++ b/src/extension/effect.cpp @@ -13,7 +13,6 @@ #include "helper/action.h" #include "ui/view/view.h" -#include "selection.h" #include "sp-namedview.h" #include "desktop.h" #include "implementation/implementation.h" diff --git a/src/extension/error-file.cpp b/src/extension/error-file.cpp index db354c0ce..342511ec9 100644 --- a/src/extension/error-file.cpp +++ b/src/extension/error-file.cpp @@ -9,7 +9,7 @@ #ifdef HAVE_CONFIG_H -#include "config.h" +#include <config.h> #endif #include "ui/dialog/extensions.h" @@ -56,11 +56,7 @@ ErrorFileNotice::ErrorFileNotice (void) : g_free(ext_error_file); set_message(dialog_text, true); -#if WITH_GTKMM_3_0 - Gtk::Box * vbox = get_content_area(); -#else - Gtk::Box * vbox = get_vbox(); -#endif + auto vbox = get_content_area(); /* This is some filler text, needs to change before relase */ Inkscape::Preferences *prefs = Inkscape::Preferences::get(); diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp index d5c80f26e..624813863 100644 --- a/src/extension/execution-env.cpp +++ b/src/extension/execution-env.cpp @@ -8,10 +8,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <config.h> - #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include "gtkmm/messagedialog.h" @@ -25,7 +23,6 @@ #include "document.h" #include "document-undo.h" #include "desktop.h" -#include "ui/view/view.h" #include "sp-namedview.h" #include "display/sp-canvas.h" @@ -58,8 +55,8 @@ ExecutionEnv::ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Imp sp_namedview_document_from_window(desktop); if (desktop != NULL) { - std::vector<SPItem*> selected = desktop->getSelection()->itemList(); - for(std::vector<SPItem*>::const_iterator x = selected.begin(); x != selected.end(); ++x){ + auto selected = desktop->getSelection()->items(); + for(auto x = selected.begin(); x != selected.end(); ++x){ Glib::ustring selected_id; selected_id = (*x)->getId(); _selected.insert(_selected.end(), selected_id); diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp index 6f7539360..497f98431 100644 --- a/src/extension/extension.cpp +++ b/src/extension/extension.cpp @@ -1,6 +1,6 @@ /** \file * - * Inkscape::Extension::Extension: + * Inkscape::Extension::Extension: * the ability to have features that are more modular so that they * can be added and removed easily. This is the basis for defining * those actions. @@ -16,18 +16,13 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <gtkmm/box.h> #include <gtkmm/label.h> #include <gtkmm/frame.h> - -#if WITH_GTKMM_3_0 -# include <gtkmm/grid.h> -#else -# include <gtkmm/table.h> -#endif +#include <gtkmm/grid.h> #include <glibmm/i18n.h> #include "inkscape.h" @@ -149,15 +144,15 @@ Extension::~Extension (void) delete timer; timer = NULL; /** \todo Need to do parameters here */ - - // delete parameters: + + // delete parameters: for (GSList * list = parameters; list != NULL; list = g_slist_next(list)) { Parameter * param = reinterpret_cast<Parameter *>(list->data); delete param; } g_slist_free(parameters); - - + + for (unsigned int i = 0 ; i < _deps.size(); i++) { delete _deps[i]; } @@ -335,7 +330,7 @@ Extension::get_repr (void) } /** - \return bool + \return bool \brief Whether this extension should hide the "working, please wait" dialog */ bool @@ -449,7 +444,7 @@ Extension::get_param_enum (const gchar * name, const SPDocument * doc, const Ink /** * This is useful to find out, if a given string \c value is selectable in a ComboBox named \cname. - * + * * @param name The name of the enum parameter to get. * @param doc The document to look in for document specific parameters. * @param node The node to look in for a specific parameter. @@ -697,11 +692,16 @@ public: * @param widg Widget to add. * @param tooltip Tooltip for the widget. */ - void addWidget(Gtk::Widget *widg, gchar const *tooltip) { + void addWidget(Gtk::Widget *widg, gchar const *tooltip, int indent) { if (widg) { - this->pack_start(*widg, false, false, 2); +#if GTK_CHECK_VERSION(3,12,0) + widg->set_margin_start(indent * Parameter::GUI_INDENTATION); +#else + widg->set_margin_left(indent * Parameter::GUI_INDENTATION); +#endif + this->pack_start(*widg, false, false, 0); if (tooltip) { - widg->set_tooltip_text(_(tooltip)); + widg->set_tooltip_text(tooltip); } else { widg->set_tooltip_text(""); widg->set_has_tooltip(false); @@ -718,7 +718,7 @@ public: a Gtk::VBox, which is then returned to the calling function. If there are no visible parameters, this function just returns NULL. - If all parameters are gui_visible = false NULL is returned as well. + If all parameters are gui_hidden = true NULL is returned as well. */ Gtk::Widget * Extension::autogui (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) @@ -726,16 +726,19 @@ Extension::autogui (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<v if (!_gui || param_visible_count() == 0) return NULL; AutoGUI * agui = Gtk::manage(new AutoGUI()); + agui->set_border_width(Parameter::GUI_BOX_MARGIN); + agui->set_spacing(Parameter::GUI_BOX_SPACING); //go through the list of parameters to see if there are any non-hidden ones for (GSList * list = parameters; list != NULL; list = g_slist_next(list)) { Parameter * param = reinterpret_cast<Parameter *>(list->data); - if (param->get_gui_hidden()) continue; //Ignore hidden parameters + if (param->get_hidden()) continue; //Ignore hidden parameters Gtk::Widget * widg = param->get_widget(doc, node, changeSignal); gchar const * tip = param->get_tooltip(); - agui->addWidget(widg, tip); - } - + int indent = param->get_indent(); + agui->addWidget(widg, tip, indent); + } + agui->show(); return agui; }; @@ -766,11 +769,7 @@ Extension::get_info_widget(void) Gtk::Frame * info = Gtk::manage(new Gtk::Frame("General Extension Information")); retval->pack_start(*info, true, true, 5); -#if WITH_GTKMM_3_0 - Gtk::Grid * table = Gtk::manage(new Gtk::Grid()); -#else - Gtk::Table * table = Gtk::manage(new Gtk::Table()); -#endif + auto table = Gtk::manage(new Gtk::Grid()); info->add(*table); @@ -784,26 +783,17 @@ Extension::get_info_widget(void) return retval; } -#if WITH_GTKMM_3_0 void Extension::add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Grid * table, int * row) -#else -void Extension::add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Table * table, int * row) -#endif { Gtk::Label * label; Gtk::Label * value; - (*row)++; + (*row)++; label = Gtk::manage(new Gtk::Label(labelstr)); value = Gtk::manage(new Gtk::Label(valuestr)); -#if WITH_GTKMM_3_0 table->attach(*label, 0, (*row) - 1, 1, 1); table->attach(*value, 1, (*row) - 1, 1, 1); -#else - table->attach(*label, 0, 1, (*row) - 1, *row); - table->attach(*value, 1, 2, (*row) - 1, *row); -#endif label->show(); value->show(); @@ -842,13 +832,13 @@ Extension::get_params_widget(void) return retval; } -unsigned int Extension::param_visible_count ( ) +unsigned int Extension::param_visible_count ( ) { unsigned int _visible_count = 0; for (GSList * list = parameters; list != NULL; list = g_slist_next(list)) { Parameter * param = reinterpret_cast<Parameter *>(list->data); - if (!param->get_gui_hidden()) _visible_count++; - } + if (!param->get_hidden()) _visible_count++; + } return _visible_count; } diff --git a/src/extension/extension.h b/src/extension/extension.h index 1fb8bdfec..bbd6d068b 100644 --- a/src/extension/extension.h +++ b/src/extension/extension.h @@ -22,12 +22,7 @@ #include <sigc++/signal.h> namespace Gtk { -#if WITH_GTKMM_3_0 class Grid; -#else - class Table; -#endif - class VBox; class Widget; } @@ -181,7 +176,7 @@ public: private: void make_param (Inkscape::XML::Node * paramrepr); - + /** * This function looks through the linked list for a parameter * structure with the name of the passed in name. @@ -300,11 +295,7 @@ public: Gtk::VBox * get_help_widget(void); Gtk::VBox * get_params_widget(void); protected: -#if WITH_GTKMM_3_0 inline static void add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Grid * table, int * row); -#else - inline static void add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Table * table, int * row); -#endif }; diff --git a/src/extension/find_extension_by_mime.h b/src/extension/find_extension_by_mime.h new file mode 100644 index 000000000..1686c62e4 --- /dev/null +++ b/src/extension/find_extension_by_mime.h @@ -0,0 +1,36 @@ +/** + * @file + * Find an extension by its mime type. + */ +/* Authors: + * Lauris Kaplinski <lauris@kaplinski.com> + * Frank Felfe <innerspace@iname.com> + * bulia byak <buliabyak@users.sf.net> + * Jon A. Cruz <jon@joncruz.org> + * Abhishek Sharma + * Kris De Gussem <Kris.DeGussem@gmail.com> + * + * Copyright (C) 2012 Kris De Gussem + * Copyright (C) 2010 authors + * Copyright (C) 1999-2005 authors + * Copyright (C) 2004 David Turner + * Copyright (C) 2001-2002 Ximian, Inc. + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +namespace Inkscape { +namespace Extension { +static inline Inkscape::Extension::Extension *find_by_mime(const char *const mime) +{ + + Inkscape::Extension::DB::InputList o; + Inkscape::Extension::db.get_input_list(o); + Inkscape::Extension::DB::InputList::const_iterator i = o.begin(); + while (i != o.end() && strcmp((*i)->get_mimetype(), mime) != 0) { + ++i; + } + return *i; +} +} +} diff --git a/src/extension/implementation/Makefile_insert b/src/extension/implementation/Makefile_insert deleted file mode 100644 index 1b9080f1a..000000000 --- a/src/extension/implementation/Makefile_insert +++ /dev/null @@ -1,9 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - extension/implementation/implementation.cpp \ - extension/implementation/implementation.h \ - extension/implementation/script.cpp \ - extension/implementation/script.h \ - extension/implementation/xslt.cpp \ - extension/implementation/xslt.h diff --git a/src/extension/implementation/implementation.cpp b/src/extension/implementation/implementation.cpp index 92a8a2833..6e6100d2b 100644 --- a/src/extension/implementation/implementation.cpp +++ b/src/extension/implementation/implementation.cpp @@ -11,7 +11,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include "implementation.h" @@ -22,7 +22,6 @@ #include "selection.h" #include "desktop.h" -#include "ui/view/view.h" namespace Inkscape { namespace Extension { @@ -46,10 +45,10 @@ Gtk::Widget *Implementation::prefs_effect(Inkscape::Extension::Effect *module, I SPDocument * current_document = view->doc(); - std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList(); + auto selected = ((SPDesktop *) view)->getSelection()->items(); Inkscape::XML::Node const* first_select = NULL; if (!selected.empty()) { - const SPItem * item = selected[0]; + const SPItem * item = selected.front(); first_select = item->getRepr(); } diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index 01323bee2..b1058d415 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -689,9 +689,9 @@ void Script::effect(Inkscape::Extension::Effect *module, return; } - std::vector<SPItem*> selected = - desktop->getSelection()->itemList(); //desktop should not be NULL since doc was checked and desktop is a casted pointer - for(std::vector<SPItem*>::const_iterator x = selected.begin(); x != selected.end(); ++x){ + auto selected = + desktop->getSelection()->items(); //desktop should not be NULL since doc was checked and desktop is a casted pointer + for(auto x = selected.begin(); x != selected.end(); ++x){ Glib::ustring selected_id; selected_id += "--id="; selected_id += (*x)->getId(); @@ -942,11 +942,7 @@ void Script::checkStderr (const Glib::ustring &data, GtkWidget *dlg = GTK_WIDGET(warning.gobj()); sp_transientize(dlg); -#if WITH_GTKMM_3_0 - Gtk::Box * vbox = warning.get_content_area(); -#else - Gtk::Box * vbox = warning.get_vbox(); -#endif + auto vbox = warning.get_content_area(); /* Gtk::TextView * textview = new Gtk::TextView(Gtk::TextBuffer::create()); */ Gtk::TextView * textview = new Gtk::TextView(); @@ -967,6 +963,9 @@ void Script::checkStderr (const Glib::ustring &data, warning.run(); + delete textview; + delete scrollwindow; + return; } diff --git a/src/extension/implementation/xslt.cpp b/src/extension/implementation/xslt.cpp index 85ae9efde..373378d97 100644 --- a/src/extension/implementation/xslt.cpp +++ b/src/extension/implementation/xslt.cpp @@ -13,7 +13,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include "file.h" @@ -22,13 +22,11 @@ #include "../output.h" #include "extension/input.h" -#include "xml/repr.h" #include "io/sys.h" #include <unistd.h> #include <cstring> #include "document.h" -#include <libxml/parser.h> #include <libxslt/transform.h> #include <libxslt/xsltutils.h> diff --git a/src/extension/input.cpp b/src/extension/input.cpp index 5cef38009..2ba48ffda 100644 --- a/src/extension/input.cpp +++ b/src/extension/input.cpp @@ -8,14 +8,12 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" #endif #include "prefdialog.h" #include "implementation/implementation.h" #include "timer.h" #include "input.h" -#include "io/sys.h" /* Inkscape::Extension::Input */ diff --git a/src/extension/internal/Makefile_insert b/src/extension/internal/Makefile_insert deleted file mode 100644 index 125776d41..000000000 --- a/src/extension/internal/Makefile_insert +++ /dev/null @@ -1,173 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -if WITH_LIBWPG -ink_common_sources += \ - extension/internal/wpg-input.cpp \ - extension/internal/wpg-input.h -endif - -if WITH_LIBVISIO -ink_common_sources += \ - extension/internal/vsd-input.cpp \ - extension/internal/vsd-input.h -endif - -if WITH_LIBCDR -ink_common_sources += \ - extension/internal/cdr-input.cpp \ - extension/internal/cdr-input.h -endif - -if USE_IMAGE_MAGICK -ink_common_sources += \ - extension/internal/bitmap/imagemagick.cpp \ - extension/internal/bitmap/imagemagick.h \ - extension/internal/bitmap/adaptiveThreshold.cpp \ - extension/internal/bitmap/adaptiveThreshold.h \ - extension/internal/bitmap/addNoise.cpp \ - extension/internal/bitmap/addNoise.h \ - extension/internal/bitmap/blur.cpp \ - extension/internal/bitmap/blur.h \ - extension/internal/bitmap/channel.cpp \ - extension/internal/bitmap/channel.h \ - extension/internal/bitmap/charcoal.cpp \ - extension/internal/bitmap/charcoal.h \ - extension/internal/bitmap/colorize.cpp \ - extension/internal/bitmap/colorize.h \ - extension/internal/bitmap/contrast.cpp \ - extension/internal/bitmap/contrast.h \ - extension/internal/bitmap/crop.cpp \ - extension/internal/bitmap/crop.h \ - extension/internal/bitmap/cycleColormap.cpp \ - extension/internal/bitmap/cycleColormap.h \ - extension/internal/bitmap/despeckle.cpp \ - extension/internal/bitmap/despeckle.h \ - extension/internal/bitmap/edge.cpp \ - extension/internal/bitmap/edge.h \ - extension/internal/bitmap/emboss.cpp \ - extension/internal/bitmap/emboss.h \ - extension/internal/bitmap/enhance.cpp \ - extension/internal/bitmap/enhance.h \ - extension/internal/bitmap/equalize.cpp \ - extension/internal/bitmap/equalize.h \ - extension/internal/bitmap/gaussianBlur.cpp \ - extension/internal/bitmap/gaussianBlur.h \ - extension/internal/bitmap/implode.cpp \ - extension/internal/bitmap/implode.h \ - extension/internal/bitmap/level.cpp \ - extension/internal/bitmap/level.h \ - extension/internal/bitmap/levelChannel.cpp \ - extension/internal/bitmap/levelChannel.h \ - extension/internal/bitmap/medianFilter.cpp \ - extension/internal/bitmap/medianFilter.h \ - extension/internal/bitmap/modulate.cpp \ - extension/internal/bitmap/modulate.h \ - extension/internal/bitmap/negate.cpp \ - extension/internal/bitmap/negate.h \ - extension/internal/bitmap/normalize.cpp \ - extension/internal/bitmap/normalize.h \ - extension/internal/bitmap/oilPaint.cpp \ - extension/internal/bitmap/oilPaint.h \ - extension/internal/bitmap/opacity.cpp \ - extension/internal/bitmap/opacity.h \ - extension/internal/bitmap/raise.cpp \ - extension/internal/bitmap/raise.h \ - extension/internal/bitmap/reduceNoise.cpp \ - extension/internal/bitmap/reduceNoise.h \ - extension/internal/bitmap/sample.cpp \ - extension/internal/bitmap/sample.h \ - extension/internal/bitmap/shade.cpp \ - extension/internal/bitmap/shade.h \ - extension/internal/bitmap/sharpen.cpp \ - extension/internal/bitmap/sharpen.h \ - extension/internal/bitmap/solarize.cpp \ - extension/internal/bitmap/solarize.h \ - extension/internal/bitmap/spread.cpp \ - extension/internal/bitmap/spread.h \ - extension/internal/bitmap/swirl.cpp \ - extension/internal/bitmap/swirl.h \ - extension/internal/bitmap/threshold.cpp \ - extension/internal/bitmap/threshold.h \ - extension/internal/bitmap/unsharpmask.cpp \ - extension/internal/bitmap/unsharpmask.h \ - extension/internal/bitmap/wave.cpp \ - extension/internal/bitmap/wave.h -endif - -ink_common_sources += \ - extension/internal/bluredge.h \ - extension/internal/bluredge.cpp \ - extension/internal/clear-n_.h \ - extension/internal/grid.h \ - extension/internal/grid.cpp \ - extension/internal/gimpgrad.h \ - extension/internal/gimpgrad.cpp \ - extension/internal/svg.h \ - extension/internal/svg.cpp \ - extension/internal/svgz.h \ - extension/internal/svgz.cpp \ - extension/internal/cairo-ps-out.h \ - extension/internal/cairo-ps-out.cpp \ - extension/internal/cairo-render-context.h \ - extension/internal/cairo-render-context.cpp \ - extension/internal/cairo-renderer.h \ - extension/internal/cairo-renderer.cpp \ - extension/internal/cairo-renderer-pdf-out.h \ - extension/internal/cairo-renderer-pdf-out.cpp \ - extension/internal/cairo-png-out.h \ - extension/internal/cairo-png-out.cpp \ - extension/internal/javafx-out.cpp \ - extension/internal/javafx-out.h \ - extension/internal/gdkpixbuf-input.h \ - extension/internal/gdkpixbuf-input.cpp \ - extension/internal/latex-text-renderer.h \ - extension/internal/latex-text-renderer.cpp \ - extension/internal/pdfinput/svg-builder.h \ - extension/internal/pdfinput/svg-builder.cpp \ - extension/internal/pdfinput/pdf-parser.h \ - extension/internal/pdfinput/pdf-parser.cpp \ - extension/internal/pdfinput/pdf-input.h \ - extension/internal/pdfinput/pdf-input.cpp \ - extension/internal/pov-out.cpp \ - extension/internal/pov-out.h \ - extension/internal/odf.cpp \ - extension/internal/odf.h \ - extension/internal/latex-pstricks.cpp \ - extension/internal/latex-pstricks.h \ - extension/internal/latex-pstricks-out.cpp \ - extension/internal/latex-pstricks-out.h \ - extension/internal/filter/bevels.h \ - extension/internal/filter/blurs.h \ - extension/internal/filter/bumps.h \ - extension/internal/filter/color.h \ - extension/internal/filter/distort.h \ - extension/internal/filter/filter.h \ - extension/internal/filter/image.h \ - extension/internal/filter/morphology.h \ - extension/internal/filter/overlays.h \ - extension/internal/filter/paint.h \ - extension/internal/filter/protrusions.h \ - extension/internal/filter/shadows.h \ - extension/internal/filter/textures.h \ - extension/internal/filter/transparency.h \ - extension/internal/filter/filter-all.cpp \ - extension/internal/filter/filter-file.cpp \ - extension/internal/filter/filter.cpp \ - extension/internal/filter/filter.h \ - extension/internal/text_reassemble.c \ - extension/internal/text_reassemble.h \ - extension/internal/emf-print.h \ - extension/internal/emf-print.cpp \ - extension/internal/emf-inout.h \ - extension/internal/emf-inout.cpp \ - extension/internal/metafile-inout.h \ - extension/internal/metafile-inout.cpp \ - extension/internal/metafile-print.h \ - extension/internal/metafile-print.cpp \ - extension/internal/wmf-print.h \ - extension/internal/wmf-print.cpp \ - extension/internal/wmf-inout.h \ - extension/internal/wmf-inout.cpp \ - extension/internal/image-resolution.h \ - extension/internal/image-resolution.cpp - diff --git a/src/extension/internal/bitmap/imagemagick.cpp b/src/extension/internal/bitmap/imagemagick.cpp index a235dcb0f..cc5b3d1bc 100644 --- a/src/extension/internal/bitmap/imagemagick.cpp +++ b/src/extension/internal/bitmap/imagemagick.cpp @@ -65,8 +65,8 @@ ImageMagickDocCache::ImageMagickDocCache(Inkscape::UI::View::View * view) : _imageItems(NULL) { SPDesktop *desktop = (SPDesktop*)view; - const std::vector<SPItem*> selectedItemList = desktop->selection->itemList(); - int selectCount = selectedItemList.size(); + auto selectedItemList = desktop->selection->items(); + int selectCount = (int) boost::distance(selectedItemList); // Init the data-holders _nodes = new Inkscape::XML::Node*[selectCount]; @@ -78,7 +78,7 @@ ImageMagickDocCache::ImageMagickDocCache(Inkscape::UI::View::View * view) : _imageItems = new SPItem*[selectCount]; // Loop through selected items - for (std::vector<SPItem*>::const_iterator i = selectedItemList.begin(); i != selectedItemList.end(); ++i) { + for (auto i = selectedItemList.begin(); i != selectedItemList.end(); ++i) { SPItem *item = *i; Inkscape::XML::Node *node = reinterpret_cast<Inkscape::XML::Node *>(item->getRepr()); if (!strcmp(node->name(), "image") || !strcmp(node->name(), "svg:image")) @@ -213,6 +213,7 @@ ImageMagick::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::Vi dc->_nodes[i]->setAttribute("xlink:href", dc->_caches[i], true); dc->_nodes[i]->setAttribute("sodipodi:absref", NULL, true); + delete blob; } catch (Magick::Exception &error_) { printf("Caught exception: %s \n", error_.what()); @@ -235,7 +236,7 @@ ImageMagick::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::Vie { SPDocument * current_document = view->doc(); - std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList(); + auto selected = ((SPDesktop *) view)->getSelection()->items(); Inkscape::XML::Node * first_select = NULL; if (!selected.empty()) { first_select = (selected.front())->getRepr(); diff --git a/src/extension/internal/bluredge.cpp b/src/extension/internal/bluredge.cpp index 4a04e3c33..d1fe357da 100644 --- a/src/extension/internal/bluredge.cpp +++ b/src/extension/internal/bluredge.cpp @@ -62,7 +62,7 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View double old_offset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0, "px"); // TODO need to properly refcount the items, at least - std::vector<SPItem*> items(selection->itemList()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); selection->clear(); for(std::vector<SPItem*>::iterator item = items.begin(); @@ -90,7 +90,7 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View new_group->appendChild(new_items[i]); selection->add(new_items[i]); - sp_selected_path_to_curves(selection, static_cast<SPDesktop *>(desktop)); + selection->toCurves(); if (offset < 0.0) { /* Doing an inset here folks */ @@ -131,8 +131,8 @@ BlurEdge::init (void) "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" "<name>" N_("Inset/Outset Halo") "</name>\n" "<id>org.inkscape.effect.bluredge</id>\n" - "<param name=\"blur-width\" _gui-text=\"" N_("Width:") "\" gui-description=\"" N_("Width in px of the halo") "\" scope=\"document\" type=\"float\" min=\"1.0\" max=\"50.0\">1.0</param>\n" - "<param name=\"num-steps\" _gui-text=\"" N_("Number of steps:") "\" gui-description=\"" N_("Number of inset/outset copies of the object to make") "\" scope=\"document\" type=\"int\" min=\"5\" max=\"100\">11</param>\n" + "<param name=\"blur-width\" _gui-text=\"" N_("Width:") "\" gui-description=\"" N_("Width in px of the halo") "\" type=\"float\" min=\"1.0\" max=\"50.0\">1.0</param>\n" + "<param name=\"num-steps\" _gui-text=\"" N_("Number of steps:") "\" gui-description=\"" N_("Number of inset/outset copies of the object to make") "\" type=\"int\" min=\"5\" max=\"100\">11</param>\n" "<effect>\n" "<object-type>all</object-type>\n" "<effects-menu>\n" diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index 5d8b0e076..21902db7d 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -42,7 +42,7 @@ #include "sp-hatch.h" #include "sp-linear-gradient.h" #include "sp-radial-gradient.h" -#include "sp-mesh.h" +#include "sp-mesh-gradient.h" #include "sp-pattern.h" #include "sp-mask.h" #include "sp-clippath.h" @@ -865,7 +865,7 @@ CairoRenderContext::_finishSurfaceSetup(cairo_surface_t *surface, cairo_matrix_t cairo_scale(_cr, Inkscape::Util::Quantity::convert(1, "px", "pt"), Inkscape::Util::Quantity::convert(1, "px", "pt")); } else if (cairo_surface_get_content(_surface) != CAIRO_CONTENT_ALPHA) { // set background color on non-alpha surfaces - // TODO: bgcolor should be derived from SPDocument + // TODO: bgcolor should be derived from SPDocument (see IconImpl) cairo_set_source_rgb(_cr, 1.0, 1.0, 1.0); cairo_rectangle(_cr, 0, 0, _width, _height); cairo_fill(_cr); @@ -986,13 +986,12 @@ void CairoRenderContext::popState(void) static bool pattern_hasItemChildren(SPPattern *pat) { - bool hasItems = false; - for ( SPObject *child = pat->firstChild() ; child && !hasItems; child = child->getNext() ) { - if (SP_IS_ITEM (child)) { - hasItems = true; + for (auto& child: pat->children) { + if (SP_IS_ITEM (&child)) { + return true; } } - return hasItems; + return false; } cairo_pattern_t* @@ -1087,10 +1086,10 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver // show items and render them for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i && SP_IS_OBJECT(pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children - for ( SPObject *child = pat_i->firstChild() ; child; child = child->getNext() ) { - if (SP_IS_ITEM(child)) { - SP_ITEM(child)->invoke_show(drawing, dkey, SP_ITEM_REFERENCE_FLAGS); - _renderer->renderItem(pattern_ctx, SP_ITEM(child)); + for (auto& child: pat_i->children) { + if (SP_IS_ITEM(&child)) { + SP_ITEM(&child)->invoke_show(drawing, dkey, SP_ITEM_REFERENCE_FLAGS); + _renderer->renderItem(pattern_ctx, SP_ITEM(&child)); } } break; // do not go further up the chain if children are found @@ -1116,9 +1115,9 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver // hide all items for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i && SP_IS_OBJECT(pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children - for ( SPObject *child = pat_i->firstChild() ; child; child = child->getNext() ) { - if (SP_IS_ITEM(child)) { - SP_ITEM(child)->invoke_hide(dkey); + for (auto& child: pat_i->children) { + if (SP_IS_ITEM(&child)) { + SP_ITEM(&child)->invoke_hide(dkey); } } break; // do not go further up the chain if children are found @@ -1258,8 +1257,8 @@ CairoRenderContext::_createPatternForPaintServer(SPPaintServer const *const pain sp_color_get_rgb_floatv(&rg->vector.stops[i].color, rgb); cairo_pattern_add_color_stop_rgba(pattern, rg->vector.stops[i].offset, rgb[0], rgb[1], rgb[2], rg->vector.stops[i].opacity * alpha); } - } else if (SP_IS_MESH (paintserver)) { - SPMesh *mg = SP_MESH(paintserver); + } else if (SP_IS_MESHGRADIENT (paintserver)) { + SPMeshGradient *mg = SP_MESHGRADIENT(paintserver); pattern = mg->pattern_new(_cr, pbox, 1.0); } else if (SP_IS_PATTERN (paintserver)) { @@ -1581,13 +1580,13 @@ bool CairoRenderContext::renderImage(Inkscape::Pixbuf *pb, // http://www.w3.org/TR/css4-images/#the-image-rendering // style.h/style.cpp switch (style->image_rendering.computed) { - case SP_CSS_COLOR_RENDERING_AUTO: - // Do nothing - break; - case SP_CSS_COLOR_RENDERING_OPTIMIZEQUALITY: + case SP_CSS_IMAGE_RENDERING_AUTO: + case SP_CSS_IMAGE_RENDERING_OPTIMIZEQUALITY: + case SP_CSS_IMAGE_RENDERING_CRISPEDGES: cairo_pattern_set_filter(cairo_get_source(_cr), CAIRO_FILTER_BEST ); break; - case SP_CSS_COLOR_RENDERING_OPTIMIZESPEED: + case SP_CSS_IMAGE_RENDERING_OPTIMIZESPEED: + case SP_CSS_IMAGE_RENDERING_PIXELATED: default: cairo_pattern_set_filter(cairo_get_source(_cr), CAIRO_FILTER_NEAREST ); break; diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 5dc20ab06..a2b8fb22f 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -541,8 +541,7 @@ static void sp_item_invoke_render(SPItem *item, CairoRenderContext *ctx) return; } - SPStyle* style = item->style; - if((ctx->getFilterToBitmap() == TRUE) && (style->filter.set != 0)) { + if(ctx->getFilterToBitmap() && (item->style->filter.set != 0)) { return sp_asbitmap_render(item, ctx); } @@ -599,8 +598,7 @@ static void sp_item_invoke_render(SPItem *item, CairoRenderContext *ctx) void CairoRenderer::setStateForItem(CairoRenderContext *ctx, SPItem const *item) { - SPStyle const *style = item->style; - ctx->setStateForStyle(style); + ctx->setStateForStyle(item->style); CairoRenderState *state = ctx->getCurrentState(); state->clip_path = item->clip_ref->getObject(); @@ -741,8 +739,8 @@ CairoRenderer::applyClipPath(CairoRenderContext *ctx, SPClipPath const *cp) TRACE(("BEGIN clip\n")); SPObject const *co = cp; - for ( SPObject const *child = co->firstChild() ; child; child = child->getNext() ) { - SPItem const *item = dynamic_cast<SPItem const *>(child); + for (auto& child: co->children) { + SPItem const *item = dynamic_cast<SPItem const *>(&child); if (item) { // combine transform of the item in clippath and the item using clippath: @@ -800,8 +798,8 @@ CairoRenderer::applyMask(CairoRenderContext *ctx, SPMask const *mask) TRACE(("BEGIN mask\n")); SPObject const *co = mask; - for ( SPObject const *child = co->firstChild() ; child; child = child->getNext() ) { - SPItem const *item = dynamic_cast<SPItem const *>(child); + for (auto& child: co->children) { + SPItem const *item = dynamic_cast<SPItem const *>(&child); if (item) { // TODO fix const correctness: renderItem(ctx, const_cast<SPItem*>(item)); diff --git a/src/extension/internal/cdr-input.cpp b/src/extension/internal/cdr-input.cpp index a26af2078..b94408b36 100644 --- a/src/extension/internal/cdr-input.cpp +++ b/src/extension/internal/cdr-input.cpp @@ -41,6 +41,7 @@ #endif #include <gtkmm/alignment.h> +#include <gtkmm/grid.h> #include <gtkmm/spinbutton.h> #include "extension/system.h" @@ -83,6 +84,8 @@ private: class Gtk::Widget * _previewArea; class Gtk::Button * cancelbutton; class Gtk::Button * okbutton; + + class Gtk::HBox * _page_selector_box; class Gtk::Label * _labelSelect; class Gtk::Label * _labelTotalPages; class Gtk::SpinButton * _pageNumberSpin; @@ -111,48 +114,41 @@ CdrImportDialog::CdrImportDialog(const std::vector<RVNGString> &vec) _previewArea = Gtk::manage(new class Gtk::VBox()); vbox1 = Gtk::manage(new class Gtk::VBox()); vbox1->pack_start(*_previewArea, Gtk::PACK_EXPAND_WIDGET, 0); -#if WITH_GTKMM_3_0 this->get_content_area()->pack_start(*vbox1); -#else - this->get_vbox()->pack_start(*vbox1); -#endif // CONTROLS + _page_selector_box = Gtk::manage(new Gtk::HBox()); - // Buttons - cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel"))); - okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))); - - // Labels + // "Select page:" label _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:"))); _labelTotalPages = Gtk::manage(new class Gtk::Label()); _labelSelect->set_line_wrap(false); _labelSelect->set_use_markup(false); _labelSelect->set_selectable(false); + _page_selector_box->pack_start(*_labelSelect, Gtk::PACK_SHRINK); + + // Adjustment + spinner + auto pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0); + _pageNumberSpin = Gtk::manage(new Gtk::SpinButton(pageNumberSpin_adj, 1, 0)); + _pageNumberSpin->set_can_focus(); + _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS); + _pageNumberSpin->set_numeric(true); + _pageNumberSpin->set_wrap(false); + _page_selector_box->pack_start(*_pageNumberSpin, Gtk::PACK_SHRINK); + _labelTotalPages->set_line_wrap(false); _labelTotalPages->set_use_markup(false); _labelTotalPages->set_selectable(false); gchar *label_text = g_strdup_printf(_("out of %i"), num_pages); _labelTotalPages->set_label(label_text); g_free(label_text); + _page_selector_box->pack_start(*_labelTotalPages, Gtk::PACK_SHRINK); - // Adjustment + spinner -#if WITH_GTKMM_3_0 - Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0); - _pageNumberSpin = Gtk::manage(new Gtk::SpinButton(_pageNumberSpin_adj, 1, 0)); -#else - Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0)); - _pageNumberSpin = Gtk::manage(new Gtk::SpinButton(*_pageNumberSpin_adj, 1, 0)); -#endif - _pageNumberSpin->set_can_focus(); - _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS); - _pageNumberSpin->set_numeric(true); - _pageNumberSpin->set_wrap(false); + vbox1->pack_end(*_page_selector_box, Gtk::PACK_SHRINK); - this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END); - this->get_action_area()->add(*_labelSelect); - this->add_action_widget(*_pageNumberSpin, Gtk::RESPONSE_ACCEPT); - this->get_action_area()->add(*_labelTotalPages); + // Buttons + cancelbutton = Gtk::manage(new Gtk::Button(_("_Cancel"), true)); + okbutton = Gtk::manage(new Gtk::Button(_("_OK"), true)); this->add_action_widget(*cancelbutton, Gtk::RESPONSE_CANCEL); this->add_action_widget(*okbutton, Gtk::RESPONSE_OK); @@ -214,6 +210,19 @@ void CdrImportDialog::_setPreviewPage() } SPDocument *doc = SPDocument::createNewDocFromMem(_vec[_current_page-1].cstr(), strlen(_vec[_current_page-1].cstr()), 0); + if(!doc) { + g_warning("CDR import: Could not create preview for page %d", _current_page); + gchar const *no_preview_template = + "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'>" + " <path style='fill:none;stroke:#ff0000;stroke-width:2px;' d='M 82,10 18,74 m 0,-64 64,64' />" + " <rect style='fill:none;stroke:#000000;stroke-width:1.5px;' width='64' height='64' x='18' y='10' />" + " <text x='50' y='92' style='font-size:10px;text-anchor:middle;font-family:sans-serif;'>%s</text>" + "</svg>"; + gchar * no_preview = g_strdup_printf(no_preview_template, _("No preview")); + doc = SPDocument::createNewDocFromMem(no_preview, strlen(no_preview), 0); + g_free(no_preview); + } + Gtk::Widget * tmpPreviewArea = Glib::wrap(sp_svg_view_widget_new(doc)); std::swap(_previewArea, tmpPreviewArea); delete tmpPreviewArea; @@ -223,7 +232,16 @@ void CdrImportDialog::_setPreviewPage() SPDocument *CdrInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri) { - RVNGFileStream input(uri); + #ifdef WIN32 + // RVNGFileStream uses fopen() internally which unfortunately only uses ANSI encoding on Windows + // therefore attempt to convert uri to the system codepage + // even if this is not possible the alternate short (8.3) file name will be used if available + gchar * converted_uri = g_win32_locale_filename_from_utf8(uri); + RVNGFileStream input(converted_uri); + g_free(converted_uri); + #else + RVNGFileStream input(uri); + #endif if (!libcdr::CDRDocument::isSupported(&input)) { return NULL; diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp index 12751c5ec..92deb2e19 100644 --- a/src/extension/internal/emf-inout.cpp +++ b/src/extension/internal/emf-inout.cpp @@ -165,8 +165,16 @@ Emf::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filena ext->set_param_bool("FixImageRot",new_FixImageRot); ext->set_param_bool("textToPath", new_val); + // ensure usage of dot as decimal separator in scanf/printf functions (indepentendly of current locale) + char *oldlocale = g_strdup(setlocale(LC_NUMERIC, NULL)); + setlocale(LC_NUMERIC, "C"); + print_document_to_file(doc, filename); + // restore decimal separator used in scanf/printf functions to initial value + setlocale(LC_NUMERIC, oldlocale); + g_free(oldlocale); + return; } @@ -3524,6 +3532,10 @@ Emf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) return NULL; } + // ensure usage of dot as decimal separator in scanf/printf functions (indepentendly of current locale) + char *oldlocale = g_strdup(setlocale(LC_NUMERIC, NULL)); + setlocale(LC_NUMERIC, "C"); + EMF_CALLBACK_DATA d; d.n_obj = 0; //these might not be set otherwise if the input file is corrupt @@ -3588,6 +3600,10 @@ Emf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) // in earlier versions no viewbox was generated and a call to setViewBoxIfMissing() was needed here. + // restore decimal separator used in scanf/printf functions to initial value + setlocale(LC_NUMERIC, oldlocale); + g_free(oldlocale); + return doc; } diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp index 9f3b5475f..147324b4f 100644 --- a/src/extension/internal/emf-print.cpp +++ b/src/extension/internal/emf-print.cpp @@ -205,7 +205,7 @@ unsigned int PrintEmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc) } else { p = ansi_uri; } - snprintf(buff, sizeof(buff) - 1, "Inkscape %s (%s)\1%s\1", Inkscape::version_string, __DATE__, p); + snprintf(buff, sizeof(buff) - 1, "Inkscape %s \1%s\1", Inkscape::version_string, p); uint16_t *Description = U_Utf8ToUtf16le(buff, 0, NULL); int cbDesc = 2 + wchar16len(Description); // also count the final terminator (void) U_Utf16leEdit(Description, '\1', '\0'); // swap the temporary \1 characters for nulls @@ -251,11 +251,7 @@ unsigned int PrintEmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc) g_error("Fatal programming error in PrintEmf::begin at textcomment_set 1"); } - char *oldlocale = g_strdup(setlocale(LC_NUMERIC, NULL)); - setlocale(LC_NUMERIC, "C"); snprintf(buff, sizeof(buff) - 1, "Drawing=%.1fx%.1fpx, %.1fx%.1fmm", _width, _height, Inkscape::Util::Quantity::convert(dwInchesX, "in", "mm"), Inkscape::Util::Quantity::convert(dwInchesY, "in", "mm")); - setlocale(LC_NUMERIC, oldlocale); - g_free(oldlocale); rec = textcomment_set(buff); if (!rec || emf_append((PU_ENHMETARECORD)rec, et, U_REC_FREE)) { g_error("Fatal programming error in PrintEmf::begin at textcomment_set 1"); @@ -1042,8 +1038,12 @@ void PrintEmf::do_clip_if_present(SPStyle const *style){ /* find the clipping path */ Geom::PathVector combined_pathvector; Geom::Affine tfc; // clipping transform, generally not the same as item transform - for(item = SP_ITEM(scp->firstChild()); item; item=SP_ITEM(item->getNext())){ - if (SP_IS_GROUP(item)) { // not implemented + for (auto& child: scp->children) { + item = SP_ITEM(&child); + if (!item) { + break; + } + if (SP_IS_GROUP(item)) { // not implemented // return sp_group_render(item); combined_pathvector = merge_PathVector_with_group(combined_pathvector, item, tfc); } else if (SP_IS_SHAPE(item)) { @@ -1060,7 +1060,7 @@ void PrintEmf::do_clip_if_present(SPStyle const *style){ g_error("Fatal programming error in PrintEmf::image at U_EMRSAVEDC_set"); } (void) draw_pathv_to_EMF(combined_pathvector, tf); - rec = U_EMRSELECTCLIPPATH_set(U_RGN_OR); + rec = U_EMRSELECTCLIPPATH_set(U_RGN_COPY); if (!rec || emf_append((PU_ENHMETARECORD)rec, et, U_REC_FREE)) { g_error("Fatal programming error in PrintEmf::do_clip_if_present at U_EMRSELECTCLIPPATH_set"); } @@ -1081,7 +1081,11 @@ Geom::PathVector PrintEmf::merge_PathVector_with_group(Geom::PathVector const &c new_combined_pathvector = combined_pathvector; SPGroup *group = SP_GROUP(item); Geom::Affine tfc = item->transform * transform; - for(SPItem *item = SP_ITEM(group->firstChild()); item; item=SP_ITEM(item->getNext())){ + for (auto& child: group->children) { + item = SP_ITEM(&child); + if (!item) { + break; + } if (SP_IS_GROUP(item)) { new_combined_pathvector = merge_PathVector_with_group(new_combined_pathvector, item, tfc); // could be endlessly recursive on a badly formed SVG } else if (SP_IS_SHAPE(item)) { diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index a6b777d20..6324dafa9 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -1480,7 +1480,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" - "<name>" N_("Quadritone fantasy") "</name>\n" + "<name>" N_("Quadritone Fantasy") "</name>\n" "<id>org.inkscape.effect.filter.Quadritone</id>\n" "<param name=\"dist\" _gui-text=\"" N_("Hue distribution (°)") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">280</param>\n" "<param name=\"colors\" _gui-text=\"" N_("Colors") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"360\">100</param>\n" diff --git a/src/extension/internal/filter/filter.cpp b/src/extension/internal/filter/filter.cpp index 25e89bbf3..0408d516e 100644 --- a/src/extension/internal/filter/filter.cpp +++ b/src/extension/internal/filter/filter.cpp @@ -125,7 +125,7 @@ void Filter::effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::Vie Inkscape::Selection * selection = ((SPDesktop *)document)->selection; // TODO need to properly refcount the items, at least - std::vector<SPItem*> items(selection->itemList()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); Inkscape::XML::Document * xmldoc = document->doc()->getReprDoc(); Inkscape::XML::Node * defsrepr = document->doc()->getDefs()->getRepr(); @@ -143,6 +143,7 @@ void Filter::effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::Vie Inkscape::XML::Node * newfilterroot = xmldoc->createElement("svg:filter"); merge_filters(newfilterroot, filterdoc->root(), xmldoc); defsrepr->appendChild(newfilterroot); + document->doc()->priv->resources_changed_signals[g_quark_from_string("filter")].emit(); Glib::ustring url = "url(#"; url += newfilterroot->attribute("id"); url += ")"; diff --git a/src/extension/internal/filter/protrusions.h b/src/extension/internal/filter/protrusions.h index ad75d8896..d6fd315db 100644 --- a/src/extension/internal/filter/protrusions.h +++ b/src/extension/internal/filter/protrusions.h @@ -45,7 +45,7 @@ public: static void init (void) { Inkscape::Extension::build_from_mem( "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" - "<name>" N_("Snow crest") "</name>\n" + "<name>" N_("Snow Crest") "</name>\n" "<id>org.inkscape.effect.filter.snow</id>\n" "<param name=\"drift\" _gui-text=\"" N_("Drift Size") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"20.0\">3.5</param>\n" "<effect>\n" diff --git a/src/extension/internal/gdkpixbuf-input.cpp b/src/extension/internal/gdkpixbuf-input.cpp index b30c67a4d..e0dc90981 100644 --- a/src/extension/internal/gdkpixbuf-input.cpp +++ b/src/extension/internal/gdkpixbuf-input.cpp @@ -134,8 +134,13 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri) } // Add it to the current layer - doc->getRoot()->appendChildRepr(image_node); + Inkscape::XML::Node *layer_node = xml_doc->createElement("svg:g"); + layer_node->setAttribute("inkscape:groupmode", "layer"); + layer_node->setAttribute("inkscape:label", "Image"); + doc->getRoot()->appendChildRepr(layer_node); + layer_node->appendChild(image_node); Inkscape::GC::release(image_node); + Inkscape::GC::release(layer_node); fit_canvas_to_drawing(doc); // Set viewBox if it doesn't exist diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index c766bd828..9e730f5e5 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -180,10 +180,10 @@ Grid::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View { SPDocument * current_document = view->doc(); - std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList(); + auto selected = ((SPDesktop *) view)->getSelection()->items(); Inkscape::XML::Node * first_select = NULL; if (!selected.empty()) { - first_select = selected[0]->getRepr(); + first_select = selected.front()->getRepr(); } return module->autogui(current_document, first_select, changeSignal); diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp index 386bde1d6..d7ad7e6f7 100644 --- a/src/extension/internal/javafx-out.cpp +++ b/src/extension/internal/javafx-out.cpp @@ -732,9 +732,9 @@ bool JavaFXOutput::doTreeRecursive(SPDocument *doc, SPObject *obj) /** * Descend into children */ - for (SPObject *child = obj->firstChild() ; child ; child = child->next) + for (auto &child: obj->children) { - if (!doTreeRecursive(doc, child)) { + if (!doTreeRecursive(doc, &child)) { return false; } } @@ -804,9 +804,9 @@ bool JavaFXOutput::doBody(SPDocument *doc, SPObject *obj) /** * Descend into children */ - for (SPObject *child = obj->firstChild() ; child ; child = child->next) + for (auto &child: obj->children) { - if (!doBody(doc, child)) { + if (!doBody(doc, &child)) { return false; } } diff --git a/src/extension/internal/metafile-print.cpp b/src/extension/internal/metafile-print.cpp index 47ba5971c..68a425d85 100644 --- a/src/extension/internal/metafile-print.cpp +++ b/src/extension/internal/metafile-print.cpp @@ -293,20 +293,22 @@ void PrintMetafile::brush_classify(SPObject *parent, int depth, Inkscape::Pixbuf } // still looking? Look at this pattern's children, if there are any - SPObject *child = pat_i->firstChild(); - while (child && !(*epixbuf) && (*hatchType == -1)) { - brush_classify(child, depth, epixbuf, hatchType, hatchColor, bkColor); - child = child->getNext(); + for (auto& child: pat_i->children) { + if (*epixbuf || *hatchType != -1) { + break; + } + brush_classify(&child, depth, epixbuf, hatchType, hatchColor, bkColor); } } } else if (SP_IS_IMAGE(parent)) { *epixbuf = ((SPImage *)parent)->pixbuf; return; } else { // some inkscape rearrangements pass through nodes between pattern and image which are not classified as either. - SPObject *child = parent->firstChild(); - while (child && !(*epixbuf) && (*hatchType == -1)) { - brush_classify(child, depth, epixbuf, hatchType, hatchColor, bkColor); - child = child->getNext(); + for (auto& child: parent->children) { + if (*epixbuf || *hatchType != -1) { + break; + } + brush_classify(&child, depth, epixbuf, hatchType, hatchColor, bkColor); } } } @@ -388,7 +390,8 @@ Geom::PathVector PrintMetafile::center_ellipse_as_SVG_PathV(Geom::Point ctr, dou y2 = ctr[Y] + sin(F) * rx * cos(M_PI) + cos(F) * ry * sin(M_PI); char text[256]; - sprintf(text, " M %f,%f A %f %f %f 0 0 %f %f A %f %f %f 0 0 %f %f z", x1, y1, rx, ry, F * 360. / (2.*M_PI), x2, y2, rx, ry, F * 360. / (2.*M_PI), x1, y1); + snprintf(text, 256, " M %f,%f A %f %f %f 0 0 %f %f A %f %f %f 0 0 %f %f z", + x1, y1, rx, ry, F * 360. / (2.*M_PI), x2, y2, rx, ry, F * 360. / (2.*M_PI), x1, y1); Geom::PathVector outres = Geom::parse_svg_path(text); return outres; } @@ -416,9 +419,9 @@ Geom::PathVector PrintMetafile::center_elliptical_ring_as_SVG_PathV(Geom::Point y22 = ctr[Y] + sin(F) * rx2 * cos(M_PI) + cos(F) * ry2 * sin(M_PI); char text[512]; - sprintf(text, " M %f,%f A %f %f %f 0 1 %f %f A %f %f %f 0 1 %f %f z M %f,%f A %f %f %f 0 0 %f %f A %f %f %f 0 0 %f %f z", - x11, y11, rx1, ry1, degrot, x12, y12, rx1, ry1, degrot, x11, y11, - x21, y21, rx2, ry2, degrot, x22, y22, rx2, ry2, degrot, x21, y21); + snprintf(text, 512, " M %f,%f A %f %f %f 0 1 %f %f A %f %f %f 0 1 %f %f z M %f,%f A %f %f %f 0 0 %f %f A %f %f %f 0 0 %f %f z", + x11, y11, rx1, ry1, degrot, x12, y12, rx1, ry1, degrot, x11, y11, + x21, y21, rx2, ry2, degrot, x22, y22, rx2, ry2, degrot, x21, y21); Geom::PathVector outres = Geom::parse_svg_path(text); return outres; @@ -438,8 +441,8 @@ Geom::PathVector PrintMetafile::center_elliptical_hole_as_SVG_PathV(Geom::Point y2 = ctr[Y] + sin(F) * rx * cos(M_PI) + cos(F) * ry * sin(M_PI); char text[256]; - sprintf(text, " M %f,%f A %f %f %f 0 0 %f %f A %f %f %f 0 0 %f %f z M 50000,50000 50000,-50000 -50000,-50000 -50000,50000 z", - x1, y1, rx, ry, F * 360. / (2.*M_PI), x2, y2, rx, ry, F * 360. / (2.*M_PI), x1, y1); + snprintf(text, 256, " M %f,%f A %f %f %f 0 0 %f %f A %f %f %f 0 0 %f %f z M 50000,50000 50000,-50000 -50000,-50000 -50000,50000 z", + x1, y1, rx, ry, F * 360. / (2.*M_PI), x2, y2, rx, ry, F * 360. / (2.*M_PI), x1, y1); Geom::PathVector outres = Geom::parse_svg_path(text); return outres; } diff --git a/src/extension/internal/metafile-print.h b/src/extension/internal/metafile-print.h index d184b72b7..9903cbb98 100644 --- a/src/extension/internal/metafile-print.h +++ b/src/extension/internal/metafile-print.h @@ -101,6 +101,7 @@ protected: static void swapRBinRGBA(char *px, int pixels); int hold_gradient(void *gr, int mode); + static int snprintf_dots(char * s, size_t n, const char * format, ...); static Geom::PathVector center_ellipse_as_SVG_PathV(Geom::Point ctr, double rx, double ry, double F); static Geom::PathVector center_elliptical_ring_as_SVG_PathV(Geom::Point ctr, double rx1, double ry1, double rx2, double ry2, double F); static Geom::PathVector center_elliptical_hole_as_SVG_PathV(Geom::Point ctr, double rx, double ry, double F); diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index 6904eb2fd..f885ef5e5 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -873,11 +873,8 @@ int SingularValueDecomposition::rank() -#define pi 3.14159 //#define pxToCm 0.0275 #define pxToCm 0.03 -#define piToRad 0.0174532925 -#define docHeightCm 22.86 //######################################################################## @@ -1565,7 +1562,7 @@ bool OdfOutput::processGradient(SPItem *item, output += buf; //TODO: apply maths, to define begin of gradient, taking gradient begin and end, as well as object boundary into account double angle = (gi.y2-gi.y1); - angle = (angle != 0.) ? (atan((gi.x2-gi.x1)/(gi.y2-gi.y1))* 180. / pi) : 90; + angle = (angle != 0.) ? (atan((gi.x2-gi.x1)/(gi.y2-gi.y1))* 180. / M_PI) : 90; angle = (angle < 0)?(180+angle):angle; angle = angle * 10; //why do we need this: precision????????????? output += Glib::ustring::compose(" draw:start-intensity=\"%1\" draw:end-intensity=\"%2\" draw:angle=\"%3\"/>\n", diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index c1940b16a..2ee713085 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -39,10 +39,8 @@ #include <gtkmm/radiobutton.h> #include <gtkmm/scale.h> -#if WITH_GTKMM_3_0 #include <glibmm/convert.h> #include <glibmm/miscutils.h> -#endif #include "extension/system.h" #include "extension/input.h" @@ -87,19 +85,13 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) _poppler_doc = NULL; #endif // HAVE_POPPLER_CAIRO _pdf_doc = doc; - cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel"))); - okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))); + cancelbutton = Gtk::manage(new Gtk::Button(_("_Cancel"), true)); + okbutton = Gtk::manage(new Gtk::Button(_("_OK"), true)); _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:"))); // Page number -#if WITH_GTKMM_3_0 - Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _pdf_doc->getNumPages(), 1, 10, 0); + auto _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _pdf_doc->getNumPages(), 1, 10, 0); _pageNumberSpin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(_pageNumberSpin_adj, 1, 1)); -#else - Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage( - new class Gtk::Adjustment(1, 1, _pdf_doc->getNumPages(), 1, 10, 0)); - _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1)); -#endif _labelTotalPages = Gtk::manage(new class Gtk::Label()); hbox2 = Gtk::manage(new class Gtk::HBox(false, 0)); // Disable the page selector when there's only one page @@ -137,13 +129,8 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) _labelViaInternal = Gtk::manage(new class Gtk::Label(_("Import via internal (Poppler derived) library. Text is stored as text but white space is missing. Meshes are converted to tiles, the number depends on the precision set below."))); #endif -#if WITH_GTKMM_3_0 _fallbackPrecisionSlider_adj = Gtk::Adjustment::create(2, 1, 256, 1, 10, 10); _fallbackPrecisionSlider = Gtk::manage(new class Gtk::Scale(_fallbackPrecisionSlider_adj)); -#else - _fallbackPrecisionSlider_adj = Gtk::manage(new class Gtk::Adjustment(2, 1, 256, 1, 10, 10)); - _fallbackPrecisionSlider = Gtk::manage(new class Gtk::HScale(*_fallbackPrecisionSlider_adj)); -#endif _fallbackPrecisionSlider->set_value(2.0); _labelPrecisionComment = Gtk::manage(new class Gtk::Label(_("rough"))); hbox6 = Gtk::manage(new class Gtk::HBox(false, 4)); @@ -170,9 +157,50 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) okbutton->set_can_focus(); okbutton->set_can_default(); okbutton->set_relief(Gtk::RELIEF_NORMAL); - this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END); + +#if GTK_CHECK_VERSION(3,16,0) + _labelSelect->set_xalign(0.5); + _labelSelect->set_yalign(0.5); + _labelTotalPages->set_xalign(0.5); + _labelTotalPages->set_yalign(0.5); + _labelPrecision->set_xalign(0.0); + _labelPrecision->set_yalign(0.5); + _labelPrecisionWarning->set_xalign(0.0); + _labelPrecisionWarning->set_yalign(0.5); + _labelPrecisionComment->set_xalign(0.5); + _labelPrecisionComment->set_yalign(0.5); +#else _labelSelect->set_alignment(0.5,0.5); - _labelSelect->set_padding(4,0); + _labelTotalPages->set_alignment(0.5,0.5); + _labelPrecision->set_alignment(0,0.5); + _labelPrecisionWarning->set_alignment(0,0.5); + _labelPrecisionComment->set_alignment(0.5,0.5); +#endif + +#if GTK_CHECK_VERSION(3,12,0) + _labelSelect->set_margin_start(4); + _labelSelect->set_margin_end(4); + _labelTotalPages->set_margin_start(4); + _labelTotalPages->set_margin_end(4); + _labelPrecision->set_margin_start(4); + _labelPrecision->set_margin_end(4); + _labelPrecisionWarning->set_margin_start(4); + _labelPrecisionWarning->set_margin_end(4); + _labelPrecisionComment->set_margin_start(4); + _labelPrecisionComment->set_margin_end(4); +#else + _labelSelect->set_margin_left(4); + _labelSelect->set_margin_right(4); + _labelTotalPages->set_margin_left(4); + _labelTotalPages->set_margin_right(4); + _labelPrecision->set_margin_left(4); + _labelPrecision->set_margin_right(4); + _labelPrecisionWarning->set_margin_left(4); + _labelPrecisionWarning->set_margin_right(4); + _labelPrecisionComment->set_margin_left(4); + _labelPrecisionComment->set_margin_right(4); +#endif + _labelSelect->set_justify(Gtk::JUSTIFY_LEFT); _labelSelect->set_line_wrap(false); _labelSelect->set_use_markup(false); @@ -182,8 +210,6 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) _pageNumberSpin->set_numeric(true); _pageNumberSpin->set_digits(0); _pageNumberSpin->set_wrap(false); - _labelTotalPages->set_alignment(0.5,0.5); - _labelTotalPages->set_padding(4,0); _labelTotalPages->set_justify(Gtk::JUSTIFY_LEFT); _labelTotalPages->set_line_wrap(false); _labelTotalPages->set_use_markup(false); @@ -202,14 +228,10 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) vbox2->pack_start(*hbox3); _pageSettingsFrame->add(*vbox2); _pageSettingsFrame->set_border_width(4); - _labelPrecision->set_alignment(0,0.5); - _labelPrecision->set_padding(4,0); _labelPrecision->set_justify(Gtk::JUSTIFY_LEFT); _labelPrecision->set_line_wrap(true); _labelPrecision->set_use_markup(false); _labelPrecision->set_selectable(false); - _labelPrecisionWarning->set_alignment(0,0.5); - _labelPrecisionWarning->set_padding(4,0); _labelPrecisionWarning->set_justify(Gtk::JUSTIFY_LEFT); _labelPrecisionWarning->set_line_wrap(true); _labelPrecisionWarning->set_use_markup(true); @@ -226,6 +248,14 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) _importViaInternal->set_active(true); _labelViaPoppler->set_line_wrap(true); _labelViaInternal->set_line_wrap(true); + +# if GTK_CHECK_VERSION(3,16,0) + _labelViaPoppler->set_xalign(0); + _labelViaInternal->set_xalign(0); +# else + _labelViaPoppler->set_alignment(0, 0.5); + _labelViaInternal->set_alignment(0, 0.5); +# endif #endif _fallbackPrecisionSlider->set_size_request(180,-1); @@ -235,8 +265,6 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) _fallbackPrecisionSlider->set_draw_value(true); _fallbackPrecisionSlider->set_value_pos(Gtk::POS_TOP); _labelPrecisionComment->set_size_request(90,-1); - _labelPrecisionComment->set_alignment(0.5,0.5); - _labelPrecisionComment->set_padding(4,0); _labelPrecisionComment->set_justify(Gtk::JUSTIFY_LEFT); _labelPrecisionComment->set_line_wrap(false); _labelPrecisionComment->set_use_markup(false); @@ -273,20 +301,14 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) // vbox3->pack_start(*hbox5, Gtk::PACK_SHRINK, 4); _importSettingsFrame->add(*vbox3); _importSettingsFrame->set_border_width(4); - vbox1->pack_start(*_pageSettingsFrame, Gtk::PACK_EXPAND_PADDING, 0); - vbox1->pack_start(*_importSettingsFrame, Gtk::PACK_EXPAND_PADDING, 0); + vbox1->pack_start(*_pageSettingsFrame, Gtk::PACK_SHRINK, 0); + vbox1->pack_start(*_importSettingsFrame, Gtk::PACK_SHRINK, 0); hbox1->pack_start(*vbox1); - hbox1->pack_start(*_previewArea, Gtk::PACK_EXPAND_WIDGET, 4); + hbox1->pack_start(*_previewArea, Gtk::PACK_SHRINK, 4); -#if WITH_GTKMM_3_0 get_content_area()->set_homogeneous(false); get_content_area()->set_spacing(0); get_content_area()->pack_start(*hbox1); -#else - this->get_vbox()->set_homogeneous(false); - this->get_vbox()->set_spacing(0); - this->get_vbox()->pack_start(*hbox1); -#endif this->set_title(_("PDF Import Settings")); this->set_modal(true); @@ -300,12 +322,7 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) this->show_all(); // Connect signals -#if WITH_GTKMM_3_0 _previewArea->signal_draw().connect(sigc::mem_fun(*this, &PdfImportDialog::_onDraw)); -#else - _previewArea->signal_expose_event().connect(sigc::mem_fun(*this, &PdfImportDialog::_onExposePreview)); -#endif - _pageNumberSpin_adj->signal_value_changed().connect(sigc::mem_fun(*this, &PdfImportDialog::_onPageNumberChanged)); _cropCheck->signal_toggled().connect(sigc::mem_fun(*this, &PdfImportDialog::_onToggleCropping)); _fallbackPrecisionSlider_adj->signal_value_changed().connect(sigc::mem_fun(*this, &PdfImportDialog::_onPrecisionChanged)); @@ -527,16 +544,6 @@ static void copy_cairo_surface_to_pixbuf (cairo_surface_t *surface, #endif -/** - * \brief Updates the preview area with the previously rendered thumbnail - */ -#if !WITH_GTKMM_3_0 -bool PdfImportDialog::_onExposePreview(GdkEventExpose * /*event*/) { - Cairo::RefPtr<Cairo::Context> cr = _previewArea->get_window()->create_cairo_context(); - return _onDraw(cr); -} -#endif - bool PdfImportDialog::_onDraw(const Cairo::RefPtr<Cairo::Context>& cr) { // Check if we have a thumbnail at all if (!_thumb_data) { @@ -939,8 +946,8 @@ void PdfInput::init(void) { "<input>\n" "<extension>.pdf</extension>\n" "<mimetype>application/pdf</mimetype>\n" - "<filetypename>" N_("Adobe PDF (*.pdf)") "</filetypename>\n" - "<filetypetooltip>" N_("Adobe Portable Document Format") "</filetypetooltip>\n" + "<filetypename>" N_("Portable Document Format (*.pdf)") "</filetypename>\n" + "<filetypetooltip>" N_("Portable Document Format") "</filetypetooltip>\n" "</input>\n" "</inkscape-extension>", new PdfInput()); diff --git a/src/extension/internal/pdfinput/pdf-input.h b/src/extension/internal/pdfinput/pdf-input.h index 6e36603c3..a70d40a23 100644 --- a/src/extension/internal/pdfinput/pdf-input.h +++ b/src/extension/internal/pdfinput/pdf-input.h @@ -32,18 +32,13 @@ class Page; class PDFDoc; namespace Gtk { - class Alignment; class Button; class CheckButton; class ComboBoxText; class DrawingArea; class Frame; class HBox; -#if WITH_GTKMM_3_0 class Scale; -#else - class HScale; -#endif class RadioButton; class VBox; class Label; @@ -79,10 +74,6 @@ private: void _setPreviewPage(int page); // Signal handlers -#if !WITH_GTKMM_3_0 - bool _onExposePreview(GdkEventExpose *event); -#endif - bool _onDraw(const Cairo::RefPtr<Cairo::Context>& cr); void _onPageNumberChanged(); void _onToggleCropping(); @@ -110,13 +101,8 @@ private: class Gtk::RadioButton * _importViaInternal; // Use native (poppler based) importing class Gtk::Label * _labelViaInternal; #endif -#if WITH_GTKMM_3_0 - class Gtk::Scale * _fallbackPrecisionSlider; + Gtk::Scale * _fallbackPrecisionSlider; Glib::RefPtr<Gtk::Adjustment> _fallbackPrecisionSlider_adj; -#else - class Gtk::HScale * _fallbackPrecisionSlider; - class Gtk::Adjustment *_fallbackPrecisionSlider_adj; -#endif class Gtk::Label * _labelPrecisionComment; class Gtk::HBox * hbox6; class Gtk::Label * _labelText; diff --git a/src/extension/internal/pov-out.cpp b/src/extension/internal/pov-out.cpp index bd2168b68..8df883069 100644 --- a/src/extension/internal/pov-out.cpp +++ b/src/extension/internal/pov-out.cpp @@ -479,9 +479,9 @@ bool PovOutput::doTreeRecursive(SPDocument *doc, SPObject *obj) /** * Descend into children */ - for (SPObject *child = obj->firstChild() ; child ; child = child->next) + for (auto &child: obj->children) { - if (!doTreeRecursive(doc, child)) + if (!doTreeRecursive(doc, &child)) return false; } diff --git a/src/extension/internal/svg.cpp b/src/extension/internal/svg.cpp index a94bc2141..9cde90519 100644 --- a/src/extension/internal/svg.cpp +++ b/src/extension/internal/svg.cpp @@ -78,6 +78,28 @@ static void pruneExtendedNamespaces( Inkscape::XML::Node *repr ) } } +/* + * Similar to the above sodipodi and inkscape prune, but used on all documents + * to remove problematic elements (for example Adobe's i:pgf tag) only removes + * known garbage tags. + */ +static void pruneProprietaryGarbage( Inkscape::XML::Node *repr ) +{ + if (repr) { + std::vector<Inkscape::XML::Node *> nodesRemoved; + for ( Node *child = repr->firstChild(); child; child = child->next() ) { + if((strncmp("i:pgf", child->name(), 5) == 0)) { + nodesRemoved.push_back(child); + g_warning( "An Adobe proprietary tag was found which is known to cause issues. It was removed before saving."); + } else { + pruneProprietaryGarbage(child); + } + } + for ( std::vector<Inkscape::XML::Node *>::iterator it = nodesRemoved.begin(); it != nodesRemoved.end(); ++it ) { + repr->removeChild(*it); + } + } +} /** \return None @@ -246,6 +268,10 @@ Svg::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filena || !strcmp (mod->get_id(), SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE) || !strcmp (mod->get_id(), SP_MODULE_KEY_OUTPUT_SVGZ_INKSCAPE)); + // We prune the in-use document and deliberately loose data, because there + // is no known use for this data at the present time. + pruneProprietaryGarbage(rdoc->root()); + if (!exportExtensions) { // We make a duplicate document so we don't prune the in-use document // and loose data. Perhaps the user intends to save as inkscape-svg next. diff --git a/src/extension/internal/vsd-input.cpp b/src/extension/internal/vsd-input.cpp index a3d4aad37..c1cfb5cc6 100644 --- a/src/extension/internal/vsd-input.cpp +++ b/src/extension/internal/vsd-input.cpp @@ -84,6 +84,8 @@ private: class Gtk::Widget * _previewArea; class Gtk::Button * cancelbutton; class Gtk::Button * okbutton; + + class Gtk::HBox * _page_selector_box; class Gtk::Label * _labelSelect; class Gtk::Label * _labelTotalPages; class Gtk::SpinButton * _pageNumberSpin; @@ -113,18 +115,10 @@ VsdImportDialog::VsdImportDialog(const std::vector<RVNGString> &vec) _previewArea = Gtk::manage(new class Gtk::VBox()); vbox1 = Gtk::manage(new class Gtk::VBox()); vbox1->pack_start(*_previewArea, Gtk::PACK_EXPAND_WIDGET, 0); -#if WITH_GTKMM_3_0 this->get_content_area()->pack_start(*vbox1); -#else - this->get_vbox()->pack_start(*vbox1); -#endif - // CONTROLS - - // Buttons - cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel"))); - okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))); + _page_selector_box = Gtk::manage(new Gtk::HBox()); // Labels _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:"))); @@ -132,30 +126,30 @@ VsdImportDialog::VsdImportDialog(const std::vector<RVNGString> &vec) _labelSelect->set_line_wrap(false); _labelSelect->set_use_markup(false); _labelSelect->set_selectable(false); - _labelTotalPages->set_line_wrap(false); - _labelTotalPages->set_use_markup(false); - _labelTotalPages->set_selectable(false); - gchar *label_text = g_strdup_printf(_("out of %i"), num_pages); - _labelTotalPages->set_label(label_text); - g_free(label_text); + _page_selector_box->pack_start(*_labelSelect, Gtk::PACK_SHRINK); // Adjustment + spinner -#if WITH_GTKMM_3_0 - Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0); + auto _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0); _pageNumberSpin = Gtk::manage(new Gtk::SpinButton(_pageNumberSpin_adj, 1, 0)); -#else - Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0)); - _pageNumberSpin = Gtk::manage(new Gtk::SpinButton(*_pageNumberSpin_adj, 1, 0)); -#endif _pageNumberSpin->set_can_focus(); _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS); _pageNumberSpin->set_numeric(true); _pageNumberSpin->set_wrap(false); + _page_selector_box->pack_start(*_pageNumberSpin, Gtk::PACK_SHRINK); + + _labelTotalPages->set_line_wrap(false); + _labelTotalPages->set_use_markup(false); + _labelTotalPages->set_selectable(false); + gchar *label_text = g_strdup_printf(_("out of %i"), num_pages); + _labelTotalPages->set_label(label_text); + g_free(label_text); + _page_selector_box->pack_start(*_labelTotalPages, Gtk::PACK_SHRINK); + + vbox1->pack_end(*_page_selector_box, Gtk::PACK_SHRINK); - this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END); - this->get_action_area()->add(*_labelSelect); - this->add_action_widget(*_pageNumberSpin, Gtk::RESPONSE_ACCEPT); - this->get_action_area()->add(*_labelTotalPages); + // Buttons + cancelbutton = Gtk::manage(new Gtk::Button(_("_Cancel"), true)); + okbutton = Gtk::manage(new Gtk::Button(_("_OK"), true)); this->add_action_widget(*cancelbutton, Gtk::RESPONSE_CANCEL); this->add_action_widget(*okbutton, Gtk::RESPONSE_OK); @@ -217,6 +211,19 @@ void VsdImportDialog::_setPreviewPage() } SPDocument *doc = SPDocument::createNewDocFromMem(_vec[_current_page-1].cstr(), strlen(_vec[_current_page-1].cstr()), 0); + if(!doc) { + g_warning("VSD import: Could not create preview for page %d", _current_page); + gchar const *no_preview_template = + "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'>" + " <path style='fill:none;stroke:#ff0000;stroke-width:2px;' d='M 82,10 18,74 m 0,-64 64,64' />" + " <rect style='fill:none;stroke:#000000;stroke-width:1.5px;' width='64' height='64' x='18' y='10' />" + " <text x='50' y='92' style='font-size:10px;text-anchor:middle;font-family:sans-serif;'>%s</text>" + "</svg>"; + gchar * no_preview = g_strdup_printf(no_preview_template, _("No preview")); + doc = SPDocument::createNewDocFromMem(no_preview, strlen(no_preview), 0); + g_free(no_preview); + } + Gtk::Widget * tmpPreviewArea = Glib::wrap(sp_svg_view_widget_new(doc)); std::swap(_previewArea, tmpPreviewArea); delete tmpPreviewArea; @@ -226,7 +233,16 @@ void VsdImportDialog::_setPreviewPage() SPDocument *VsdInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri) { - RVNGFileStream input(uri); + #ifdef WIN32 + // RVNGFileStream uses fopen() internally which unfortunately only uses ANSI encoding on Windows + // therefore attempt to convert uri to the system codepage + // even if this is not possible the alternate short (8.3) file name will be used if available + gchar * converted_uri = g_win32_locale_filename_from_utf8(uri); + RVNGFileStream input(converted_uri); + g_free(converted_uri); + #else + RVNGFileStream input(uri); + #endif if (!libvisio::VisioDocument::isSupported(&input)) { return NULL; diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp index c7226a58a..e2d1433e4 100644 --- a/src/extension/internal/wmf-inout.cpp +++ b/src/extension/internal/wmf-inout.cpp @@ -161,8 +161,16 @@ Wmf::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filena ext->set_param_bool("FixPPTPatternAsHatch",new_FixPPTPatternAsHatch); ext->set_param_bool("textToPath", new_val); + // ensure usage of dot as decimal separator in scanf/printf functions (indepentendly of current locale) + char *oldlocale = g_strdup(setlocale(LC_NUMERIC, NULL)); + setlocale(LC_NUMERIC, "C"); + print_document_to_file(doc, filename); + // restore decimal separator used in scanf/printf functions to initial value + setlocale(LC_NUMERIC, oldlocale); + g_free(oldlocale); + return; } @@ -1762,11 +1770,20 @@ std::cout << "BEFORE DRAW" << " test0 " << ( d->mask & U_DRAW_VISIBLE) << " test1 " << ( d->mask & U_DRAW_FORCE) << " test2 " << (wmr_mask & U_DRAW_ALTERS) + << " test2.5 " << ((d->mask & U_DRAW_NOFILL) != (wmr_mask & U_DRAW_NOFILL) ) << " test3 " << (wmr_mask & U_DRAW_VISIBLE) << " test4 " << !(d->mask & U_DRAW_ONLYTO) << " test5 " << ((d->mask & U_DRAW_ONLYTO) && !(wmr_mask & U_DRAW_ONLYTO) ) << std::endl; */ + /* spurious moveto records should not affect the drawing. However, they set the NOFILL + bit and that messes up the logic about when to emit a path. So prune out any + stray moveto records. That is those which were never followed by a lineto. + */ + if((d->mask & U_DRAW_NOFILL) && !(d->mask & U_DRAW_VISIBLE) && + !(wmr_mask & U_DRAW_ONLYTO) && (wmr_mask & U_DRAW_VISIBLE)){ + d->mask ^= U_DRAW_NOFILL; + } if( (wmr_mask != U_WMR_INVALID) && // next record is valid type @@ -1774,6 +1791,7 @@ std::cout << "BEFORE DRAW" ( (d->mask & U_DRAW_FORCE) || // This draw is forced by STROKE/FILL/STROKEANDFILL PATH (wmr_mask & U_DRAW_ALTERS) || // Next record would alter the drawing environment in some way + ((d->mask & U_DRAW_NOFILL) != (wmr_mask & U_DRAW_NOFILL)) || // Fill<->!Fill requires a draw between ( (wmr_mask & U_DRAW_VISIBLE) && // Next record is visible... ( ( !(d->mask & U_DRAW_ONLYTO) ) || // Non *TO records cannot be followed by any Visible @@ -3087,6 +3105,10 @@ Wmf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) return NULL; } + // ensure usage of dot as decimal separator in scanf/printf functions (indepentendly of current locale) + char *oldlocale = g_strdup(setlocale(LC_NUMERIC, NULL)); + setlocale(LC_NUMERIC, "C"); + WMF_CALLBACK_DATA d; d.n_obj = 0; //these might not be set otherwise if the input file is corrupt @@ -3167,6 +3189,10 @@ Wmf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) // in earlier versions no viewbox was generated and a call to setViewBoxIfMissing() was needed here. + // restore decimal separator used in scanf/printf functions to initial value + setlocale(LC_NUMERIC, oldlocale); + g_free(oldlocale); + return doc; } diff --git a/src/extension/internal/wmf-print.cpp b/src/extension/internal/wmf-print.cpp index 3d913bf1e..29dfa2716 100644 --- a/src/extension/internal/wmf-print.cpp +++ b/src/extension/internal/wmf-print.cpp @@ -312,7 +312,7 @@ unsigned int PrintWmf::finish(Inkscape::Extension::Print * /*mod*/) g_error("Fatal programming error in PrintWmf::finish"); } (void) wmf_finish(wt); // Finalize and write out the WMF - wmf_free(&wt); // clean up + uwmf_free(&wt); // clean up wmf_htable_free(&wht); // clean up return 0; @@ -598,7 +598,28 @@ int PrintWmf::create_pen(SPStyle const *style, const Geom::Affine &transform) if (!style->stroke_dasharray.values.empty()) { if (!FixPPTDashLine) { // if this is set code elsewhere will break dots/dashes into many smaller lines. - penstyle = U_PS_DASH;// userstyle not supported apparently, for now map all Inkscape dot/dash to just dash + int n_dash = style->stroke_dasharray.values.size(); + /* options are dash, dot, dashdot and dashdotdot. Try to pick the closest one. */ + int mark_short=INT_MAX; + int mark_long =0; + int i; + for (i=0;i<n_dash;i++) { + int mark = style->stroke_dasharray.values[i]; + if (mark>mark_long) { mark_long = mark; } + if (mark<mark_short) { mark_short = mark; } + } + if(mark_long == mark_short){ // only one mark size + penstyle = U_PS_DOT; + } + else if (n_dash==2) { + penstyle = U_PS_DASH; + } + else if (n_dash==4) { + penstyle = U_PS_DASHDOT; + } + else { + penstyle = U_PS_DASHDOTDOT; + } } } diff --git a/src/extension/internal/wpg-input.cpp b/src/extension/internal/wpg-input.cpp index 54a14fc72..299614c94 100644 --- a/src/extension/internal/wpg-input.cpp +++ b/src/extension/internal/wpg-input.cpp @@ -81,7 +81,17 @@ namespace Internal { SPDocument *WpgInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri) { - RVNGInputStream* input = new RVNGFileStream(uri); + #ifdef WIN32 + // RVNGFileStream uses fopen() internally which unfortunately only uses ANSI encoding on Windows + // therefore attempt to convert uri to the system codepage + // even if this is not possible the alternate short (8.3) file name will be used if available + gchar * converted_uri = g_win32_locale_filename_from_utf8(uri); + RVNGInputStream* input = new RVNGFileStream(converted_uri); + g_free(converted_uri); + #else + RVNGInputStream* input = new RVNGFileStream(uri); + #endif + #if WITH_LIBWPG03 if (input->isStructured()) { RVNGInputStream* olestream = input->getSubStreamByName("PerfectOffice_MAIN"); diff --git a/src/extension/loader.cpp b/src/extension/loader.cpp index 863a176ca..164a5cecf 100644 --- a/src/extension/loader.cpp +++ b/src/extension/loader.cpp @@ -10,8 +10,10 @@ */ #include "loader.h" + +#include <gmodule.h> + #include "system.h" -#include <exception> #include <string.h> #include "dependency.h" #include "inkscape-version.h" diff --git a/src/extension/loader.h b/src/extension/loader.h index 0d3a69061..0eecc02b9 100644 --- a/src/extension/loader.h +++ b/src/extension/loader.h @@ -14,8 +14,6 @@ #define INKSCAPE_EXTENSION_LOADER_H_ #include "extension.h" -#include "implementation/implementation.h" -#include <gmodule.h> namespace Inkscape { diff --git a/src/extension/param/bool.cpp b/src/extension/param/bool.cpp index d64f798ba..2c7e32480 100644 --- a/src/extension/param/bool.cpp +++ b/src/extension/param/bool.cpp @@ -23,9 +23,15 @@ namespace Inkscape { namespace Extension { -ParamBool::ParamBool(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(false), _indent(0) +ParamBool::ParamBool(const gchar * name, + const gchar * text, + const gchar * description, + bool hidden, + int indent, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml) + : Parameter(name, text, description, hidden, indent, ext) + , _value(false) { const char * defaultval = NULL; if (xml->firstChild() != NULL) { @@ -38,11 +44,6 @@ ParamBool::ParamBool(const gchar * name, const gchar * guitext, const gchar * de _value = false; } - 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(); _value = prefs->getBool(extension_pref_root + pref_name, _value); @@ -65,7 +66,7 @@ bool ParamBool::set( bool in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node bool ParamBool::get(const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) const { - return _value; + return _value; } /** @@ -125,16 +126,12 @@ void ParamBool::string(std::string &string) const Gtk::Widget *ParamBool::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) { - if (_gui_hidden) { + if (_hidden) { return NULL; } -#if WITH_GTKMM_3_0 - Gtk::Box * hbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, 4)); + auto hbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, Parameter::GUI_PARAM_WIDGETS_SPACING)); hbox->set_homogeneous(false); -#else - Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); -#endif Gtk::Label * label = Gtk::manage(new Gtk::Label(_text, Gtk::ALIGN_START)); label->show(); @@ -142,7 +139,7 @@ Gtk::Widget *ParamBool::get_widget(SPDocument * doc, Inkscape::XML::Node * node, ParamBoolCheckButton * checkbox = Gtk::manage(new ParamBoolCheckButton(this, doc, node, changeSignal)); checkbox->show(); - hbox->pack_start(*checkbox, false, false, _indent); + hbox->pack_start(*checkbox, false, false); hbox->show(); diff --git a/src/extension/param/bool.h b/src/extension/param/bool.h index 5d190b9d3..826a98927 100644 --- a/src/extension/param/bool.h +++ b/src/extension/param/bool.h @@ -32,7 +32,13 @@ public: /** * Use the superclass' allocator and set the \c _value. */ - ParamBool(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); + ParamBool(const gchar * name, + const gchar * text, + const gchar * description, + bool hidden, + int indent, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml); /** * Returns the current state/value. @@ -69,7 +75,6 @@ public: private: /** Internal value. */ bool _value; - int _indent; }; } // namespace Extension diff --git a/src/extension/param/color.cpp b/src/extension/param/color.cpp index 0b58c5011..035c43ba8 100644 --- a/src/extension/param/color.cpp +++ b/src/extension/param/color.cpp @@ -52,9 +52,15 @@ guint32 ParamColor::set( guint32 in, SPDocument * /*doc*/, Inkscape::XML::Node * return in; } -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 * text, + const gchar * description, + bool hidden, + int indent, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml) + : Parameter(name, text, description, hidden, indent, ext) + , _changeSignal(0) { const char * defaulthex = NULL; if (xml->firstChild() != NULL) @@ -86,7 +92,7 @@ Gtk::Widget *ParamColor::get_widget( SPDocument * /*doc*/, Inkscape::XML::Node * { using Inkscape::UI::Widget::ColorNotebook; - if (_gui_hidden) return NULL; + if (_hidden) return NULL; if (changeSignal) { _changeSignal = new sigc::signal<void>(*changeSignal); @@ -98,9 +104,9 @@ Gtk::Widget *ParamColor::get_widget( SPDocument * /*doc*/, Inkscape::XML::Node * _color_changed.block(false); } - 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::Widget *selector = Gtk::manage(new ColorNotebook(_color)); - hbox->pack_start (*selector, true, true, 0); + hbox->pack_start(*selector, true, true, 0); selector->show(); hbox->show(); return hbox; diff --git a/src/extension/param/color.h b/src/extension/param/color.h index ed2e57ceb..890f5ba5f 100644 --- a/src/extension/param/color.h +++ b/src/extension/param/color.h @@ -31,8 +31,13 @@ private: Inkscape::UI::SelectedColor _color; sigc::connection _color_changed; public: - 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); - + ParamColor(const gchar * name, + const gchar * text, + const gchar * description, + bool hidden, + int indent, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml); virtual ~ParamColor(void); /** Returns \c _value, with a \i const to protect it. */ diff --git a/src/extension/param/description.cpp b/src/extension/param/description.cpp index 326e75e4a..cf94918f7 100644 --- a/src/extension/param/description.cpp +++ b/src/extension/param/description.cpp @@ -16,6 +16,8 @@ #include <gtkmm/box.h> #include <gtkmm/label.h> #include <glibmm/i18n.h> +#include <glibmm/markup.h> +#include <glibmm/regex.h> #include "xml/node.h" #include "extension/extension.h" @@ -26,35 +28,61 @@ 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, - AppearanceMode mode) : - Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), - _value(NULL), _mode(mode), _indent(0) +ParamDescription::ParamDescription(const gchar * name, + const gchar * text, + const gchar * description, + bool hidden, + int indent, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml, + AppearanceMode mode) + : Parameter(name, text, description, hidden, indent, ext) + , _value(NULL) + , _mode(mode) { - // printf("Building Description\n"); - const char * defaultval = NULL; - if (xml->firstChild() != NULL) { - defaultval = xml->firstChild()->content(); + // construct the text content by concatenating all (non-empty) text nodes, + // removing all other nodes (e.g. comment nodes) and replacing <extension:br> elements with "<br/>" + Glib::ustring value; + Inkscape::XML::Node * cur_child = xml->firstChild(); + while (cur_child != NULL) { + if (cur_child->type() == XML::TEXT_NODE && cur_child->content() != NULL) { + value += cur_child->content(); + } else if (cur_child->type() == XML::ELEMENT_NODE && !g_strcmp0(cur_child->name(), "extension:br")) { + value += "<br/>"; + } + cur_child = cur_child->next(); } - if (defaultval != NULL) { - _value = g_strdup(defaultval); + // if there is no text content we can return immediately (the description will be invisible) + if (value == Glib::ustring("")) { + return; } - _context = xml->attribute("msgctxt"); + // do replacements in the source string to account for the attribute xml:space="preserve" + // (those should match replacements potentially performed by xgettext to allow for proper translation) + if (g_strcmp0(xml->attribute("xml:space"), "preserve") == 0) { + // xgettext copies the source string verbatim in this case, so no changes needed + } else { + // remove all whitespace from start/end of string and replace intermediate whitespace with a single space + value = Glib::Regex::create("^\\s+|\\s+$")->replace_literal(value, 0, "", (Glib::RegexMatchFlags)0); + value = Glib::Regex::create("\\s+")->replace_literal(value, 0, " ", (Glib::RegexMatchFlags)0); + } - const char * indent = xml->attribute("indent"); - if (indent != NULL) { - _indent = atoi(indent) * 12; + // translate if underscored version (_param) was used + if (g_str_has_prefix(xml->name(), "extension:_")) { + const gchar * context = xml->attribute("msgctxt"); + if (context != NULL) { + value = g_dpgettext2(NULL, context, value.c_str()); + } else { + value = _(value.c_str()); + } } + // finally replace all remaining <br/> with a real newline character + value = Glib::Regex::create("<br/>")->replace_literal(value, 0, "\n", (Glib::RegexMatchFlags)0); + + _value = g_strdup(value.c_str()); + return; } @@ -62,36 +90,48 @@ ParamDescription::ParamDescription (const gchar * name, Gtk::Widget * ParamDescription::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * /*changeSignal*/) { - if (_gui_hidden) { + if (_hidden) { return NULL; } if (_value == NULL) { return NULL; } - Glib::ustring newguitext; + Glib::ustring newtext = _value; - if (_context != NULL) { - newguitext = g_dpgettext2(NULL, _context, _value); - } else { - newguitext = _(_value); - } - - Gtk::Label * label; - int padding = 12 + _indent; + Gtk::Label * label = Gtk::manage(new Gtk::Label()); if (_mode == HEADER) { - label = Gtk::manage(new Gtk::Label(Glib::ustring("<b>") +newguitext + Glib::ustring("</b>"), Gtk::ALIGN_START)); - label->set_padding(0,5); - label->set_use_markup(true); - padding = _indent; + label->set_markup(Glib::ustring("<b>") + Glib::Markup::escape_text(newtext) + Glib::ustring("</b>")); + label->set_margin_top(5); + label->set_margin_bottom(5); + } else if (_mode == URL) { + Glib::ustring escaped_url = Glib::Markup::escape_text(newtext); + label->set_markup(Glib::ustring::compose("<a href='%1'>%1</a>", escaped_url)); } else { - label = Gtk::manage(new Gtk::Label(newguitext, Gtk::ALIGN_START)); + label->set_text(newtext); } label->set_line_wrap(); +#if (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION >= 16) + label->set_xalign(0); +#else + label->set_alignment(Gtk::ALIGN_START); +#endif + + // TODO: Ugly "fix" for gtk3 width/height calculation of labels. + // - If not applying any limits long labels will make the window grow horizontally until it uses up + // most of the available space (i.e. most of the screen area) which is ridicously wide + // - By using "set_default_size(0,0)" in prefidalog.cpp we tell the window to shrink as much as possible, + // however this can result in a much to narrow dialog instead and much unnecessary wrapping + // - Here we set a lower limit of GUI_MAX_LINE_LENGTH characters per line that long texts will always use + // This means texts can not shrink anymore (they can still grow, though) and it's also necessary + // to prevent https://bugzilla.gnome.org/show_bug.cgi?id=773572 + int len = newtext.length(); + label->set_width_chars(len > Parameter::GUI_MAX_LINE_LENGTH ? Parameter::GUI_MAX_LINE_LENGTH : len); + label->show(); - Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); - hbox->pack_start(*label, true, true, padding); + Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox()); + hbox->pack_start(*label, true, true); hbox->show(); return hbox; diff --git a/src/extension/param/description.h b/src/extension/param/description.h index 3a72c4112..599c4db78 100644 --- a/src/extension/param/description.h +++ b/src/extension/param/description.h @@ -27,24 +27,22 @@ namespace Extension { class ParamDescription : public Parameter { public: enum AppearanceMode { - DESC, HEADER + DESCRIPTION, HEADER, URL }; ParamDescription(const gchar * name, - const gchar * guitext, - const gchar * desc, - const Parameter::_scope_t scope, - bool gui_hidden, - const gchar * gui_tip, + const gchar * text, + const gchar * description, + bool hidden, + int indent, 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; - int _indent; - const gchar* _context; }; } /* namespace Extension */ diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp index 4e7420807..7cd860465 100644 --- a/src/extension/param/enum.cpp +++ b/src/extension/param/enum.cpp @@ -33,25 +33,28 @@ 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, - 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 * text, + const gchar * description, + bool hidden, + int indent, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml) + : Parameter(name, text, description, hidden, indent, ext) , _value(NULL) - , _indent(0) , choices(NULL) { const char *xmlval = NULL; // the value stored in XML @@ -61,7 +64,7 @@ ParamComboBox::ParamComboBox(const gchar *name, const gchar *guitext, const gcha 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(); @@ -72,12 +75,12 @@ ParamComboBox::ParamComboBox(const gchar *name, const gchar *guitext, const gcha // 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; @@ -89,22 +92,17 @@ ParamComboBox::ParamComboBox(const gchar *name, const gchar *guitext, const gcha 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) ); } } } - + // 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(); @@ -155,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<enumentry *>(list->data); - if ( !entr->guitext.compare(in) ) { + if ( !entr->text.compare(in) ) { settext = entr->value; break; // break out of for loop } @@ -175,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<enumentry *>(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; } @@ -246,25 +244,25 @@ ParamComboBoxEntry::changed (void) */ Gtk::Widget *ParamComboBox::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) { - if (_gui_hidden) { + if (_hidden) { 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, _indent); + hbox->pack_start(*label, false, false); ParamComboBoxEntry * combo = Gtk::manage(new ParamComboBoxEntry(this, doc, node, changeSignal)); // add choice strings: Glib::ustring settext; for (GSList * list = choices; list != NULL; list = g_slist_next(list)) { enumentry * entr = reinterpret_cast<enumentry *>(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()) { diff --git a/src/extension/param/enum.h b/src/extension/param/enum.h index 52e018469..143a648d7 100644 --- a/src/extension/param/enum.h +++ b/src/extension/param/enum.h @@ -34,12 +34,18 @@ private: been allocated in memory. And should be free'd. It is the value of the current selected string */ gchar * _value; - int _indent; GSList * choices; /**< A table to store the choice strings */ public: - 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); + ParamComboBox(const gchar * name, + const gchar * text, + const gchar * description, + bool hidden, + int indent, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml); virtual ~ParamComboBox(void); + Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal); // Explicitly call superclass version to avoid method being hidden. @@ -52,9 +58,9 @@ public: const gchar * set (const gchar * in, SPDocument * doc, Inkscape::XML::Node * node); /** - * @returns true if guitext is part of this enum + * @returns true if text is part of this enum */ - bool contains(const gchar * guitext, SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/) const; + bool contains(const gchar * text, SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/) const; void changed (void); }; /* class ParamComboBox */ diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp index dff7cbf46..69283a572 100644 --- a/src/extension/param/float.cpp +++ b/src/extension/param/float.cpp @@ -26,17 +26,19 @@ namespace Extension { /** 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, - AppearanceMode mode) : - Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), - _value(0.0), _mode(mode), _indent(0), _min(0.0), _max(10.0) +ParamFloat::ParamFloat(const gchar * name, + const gchar * text, + const gchar * description, + bool hidden, + int indent, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml, + AppearanceMode mode) + : Parameter(name, text, description, hidden, indent, ext) + , _value(0.0) + , _mode(mode) + , _min(0.0) + , _max(10.0) { const gchar * defaultval = NULL; if (xml->firstChild() != NULL) { @@ -68,11 +70,6 @@ ParamFloat::ParamFloat (const gchar * name, _min = 0.0; } - 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(); _value = prefs->getDouble(extension_pref_root + pref_name, _value); @@ -170,38 +167,30 @@ void ParamFloatAdjustment::val_changed(void) */ Gtk::Widget * ParamFloat::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) { - if (_gui_hidden) { + if (_hidden) { 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)); -#if WITH_GTKMM_3_0 - ParamFloatAdjustment * pfa = new ParamFloatAdjustment(this, doc, node, changeSignal); + auto pfa = new ParamFloatAdjustment(this, doc, node, changeSignal); Glib::RefPtr<Gtk::Adjustment> fadjust(pfa); -#else - ParamFloatAdjustment * fadjust = Gtk::manage(new ParamFloatAdjustment(this, doc, node, changeSignal)); -#endif - + if (_mode == FULL) { UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(_text, fadjust, _precision); scale->set_size_request(400, -1); scale->show(); - hbox->pack_start(*scale, false, false); + hbox->pack_start(*scale, true, true); } else if (_mode == MINIMAL) { Gtk::Label * label = Gtk::manage(new Gtk::Label(_text, Gtk::ALIGN_START)); label->show(); - hbox->pack_start(*label, true, true, _indent); + hbox->pack_start(*label, true, true); -#if WITH_GTKMM_3_0 - Inkscape::UI::Widget::SpinButton * spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(fadjust, 0.1, _precision)); -#else - Inkscape::UI::Widget::SpinButton * spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(*fadjust, 0.1, _precision)); -#endif + auto spin = Gtk::manage(new Inkscape::UI::Widget::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 42b1698b1..d58253ccb 100644 --- a/src/extension/param/float.h +++ b/src/extension/param/float.h @@ -29,15 +29,15 @@ public: 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); + ParamFloat(const gchar * name, + const gchar * text, + const gchar * description, + bool hidden, + int indent, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml, + AppearanceMode mode); + /** Returns \c _value. */ float get(const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) const { return _value; } @@ -60,7 +60,6 @@ private: /** Internal value. */ float _value; AppearanceMode _mode; - int _indent; float _min; float _max; int _precision; diff --git a/src/extension/param/int.cpp b/src/extension/param/int.cpp index dda801282..357f98590 100644 --- a/src/extension/param/int.cpp +++ b/src/extension/param/int.cpp @@ -26,17 +26,19 @@ namespace Extension { /** 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, - AppearanceMode mode) : - Parameter(name, guitext, desc, scope, gui_hidden, gui_tip, ext), - _value(0), _mode(mode), _indent(0), _min(0), _max(10) +ParamInt::ParamInt(const gchar * name, + const gchar * text, + const gchar * description, + bool hidden, + int indent, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml, + AppearanceMode mode) + : Parameter(name, text, description, hidden, indent, ext) + , _value(0) + , _mode(mode) + , _min(0) + , _max(10) { const char * defaultval = NULL; if (xml->firstChild() != NULL) { @@ -61,11 +63,6 @@ ParamInt::ParamInt (const gchar * name, _min = 0; } - 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(); _value = prefs->getInt(extension_pref_root + pref_name, _value); @@ -151,38 +148,28 @@ void ParamIntAdjustment::val_changed(void) Gtk::Widget * ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) { - if (_gui_hidden) { + if (_hidden) { 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)); -#if WITH_GTKMM_3_0 - ParamIntAdjustment * pia = new ParamIntAdjustment(this, doc, node, changeSignal); + auto pia = new ParamIntAdjustment(this, doc, node, changeSignal); Glib::RefPtr<Gtk::Adjustment> fadjust(pia); -#else - ParamIntAdjustment * fadjust = Gtk::manage(new ParamIntAdjustment(this, doc, node, changeSignal)); -#endif if (_mode == FULL) { UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(_text, fadjust, 0); scale->set_size_request(400, -1); scale->show(); - hbox->pack_start(*scale, false, false); + hbox->pack_start(*scale, true, true); } else if (_mode == MINIMAL) { - Gtk::Label * label = Gtk::manage(new Gtk::Label(_text, Gtk::ALIGN_START)); label->show(); - hbox->pack_start(*label, true, true, _indent); + hbox->pack_start(*label, true, true); -#if WITH_GTKMM_3_0 - Inkscape::UI::Widget::SpinButton * spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(fadjust, 1.0, 0)); -#else - Inkscape::UI::Widget::SpinButton * spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(*fadjust, 1.0, 0)); -#endif + auto spin = Gtk::manage(new Inkscape::UI::Widget::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 3fd6cea9b..fcb1ef3f1 100644 --- a/src/extension/param/int.h +++ b/src/extension/param/int.h @@ -29,15 +29,14 @@ public: 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); + ParamInt(const gchar * name, + const gchar * text, + const gchar * description, + bool hidden, + int indent, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml, + AppearanceMode mode); /** Returns \c _value. */ int get(const SPDocument * /*doc*/, const Inkscape::XML::Node * /*node*/) const { return _value; } @@ -59,7 +58,6 @@ private: /** Internal value. */ int _value; AppearanceMode _mode; - int _indent; int _min; int _max; }; diff --git a/src/extension/param/notebook.cpp b/src/extension/param/notebook.cpp index 20c8e8481..4e94b5216 100644 --- a/src/extension/param/notebook.cpp +++ b/src/extension/param/notebook.cpp @@ -54,17 +54,28 @@ private: public: static ParamNotebookPage * makepage (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * in_ext); - ParamNotebookPage(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); + ParamNotebookPage(const gchar * name, + const gchar * text, + const gchar * description, + bool hidden, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml); ~ParamNotebookPage(void); + Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal); void paramString (std::list <std::string> &list); - gchar * get_guitext (void) {return _text;}; + gchar * get_text (void) {return _text;}; Parameter * get_param (const gchar * name); }; /* class ParamNotebookPage */ -ParamNotebookPage::ParamNotebookPage (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) +ParamNotebookPage::ParamNotebookPage(const gchar * name, + const gchar * text, + const gchar * description, + bool hidden, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml) + : Parameter(name, text, description, hidden, /*indent*/ 0, ext) { parameters = NULL; @@ -136,30 +147,23 @@ ParamNotebookPage * ParamNotebookPage::makepage (Inkscape::XML::Node * in_repr, Inkscape::Extension::Extension * in_ext) { const char * name; - const char * guitext; - const char * desc; - const char * scope_str; - Parameter::_scope_t scope = Parameter::SCOPE_USER; - bool gui_hidden = false; - const char * gui_hide; - const char * gui_tip; + const char * text; + const char * description; + bool hidden = false; + const char * hide; name = in_repr->attribute("name"); - guitext = in_repr->attribute("gui-text"); - if (guitext == NULL) - guitext = in_repr->attribute("_gui-text"); - gui_tip = in_repr->attribute("gui-tip"); - if (gui_tip == NULL) - gui_tip = in_repr->attribute("_gui-tip"); - desc = in_repr->attribute("gui-description"); - if (desc == NULL) - desc = in_repr->attribute("_gui-description"); - scope_str = in_repr->attribute("scope"); - gui_hide = in_repr->attribute("gui-hidden"); - if (gui_hide != NULL) { - if (strcmp(gui_hide, "1") == 0 || - strcmp(gui_hide, "true") == 0) { - gui_hidden = true; + text = in_repr->attribute("gui-text"); + if (text == NULL) + text = in_repr->attribute("_gui-text"); + description = in_repr->attribute("gui-description"); + if (description == NULL) + description = in_repr->attribute("_gui-description"); + hide = in_repr->attribute("gui-hidden"); + if (hide != NULL) { + if (strcmp(hide, "1") == 0 || + strcmp(hide, "true") == 0) { + hidden = true; } /* else stays false */ } @@ -169,17 +173,7 @@ ParamNotebookPage::makepage (Inkscape::XML::Node * in_repr, Inkscape::Extension: return NULL; } - if (scope_str != NULL) { - if (!strcmp(scope_str, "user")) { - scope = Parameter::SCOPE_USER; - } else if (!strcmp(scope_str, "document")) { - scope = Parameter::SCOPE_DOCUMENT; - } else if (!strcmp(scope_str, "node")) { - scope = Parameter::SCOPE_NODE; - } - } - - ParamNotebookPage * page = new ParamNotebookPage(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); + ParamNotebookPage * page = new ParamNotebookPage(name, text, description, hidden, in_ext, in_repr); /* Note: page could equal NULL */ return page; @@ -194,23 +188,30 @@ ParamNotebookPage::makepage (Inkscape::XML::Node * in_repr, Inkscape::Extension: */ Gtk::Widget * ParamNotebookPage::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) { - if (_gui_hidden) { + if (_hidden) { return NULL; } Gtk::VBox * vbox = Gtk::manage(new Gtk::VBox); - vbox->set_border_width(5); + vbox->set_border_width(Parameter::GUI_BOX_MARGIN); + vbox->set_spacing(Parameter::GUI_BOX_SPACING); // add parameters onto page (if any) for (GSList * list = parameters; list != NULL; list = g_slist_next(list)) { Parameter * param = reinterpret_cast<Parameter *>(list->data); Gtk::Widget * widg = param->get_widget(doc, node, changeSignal); if (widg) { + int indent = param->get_indent(); +#if GTK_CHECK_VERSION(3,12,0) + widg->set_margin_start(indent * Parameter::GUI_INDENTATION); +#else + widg->set_margin_left(indent * Parameter::GUI_INDENTATION); +#endif + vbox->pack_start(*widg, false, false, 0); + gchar const * tip = param->get_tooltip(); - // 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); @@ -224,8 +225,14 @@ Gtk::Widget * ParamNotebookPage::get_widget(SPDocument * doc, Inkscape::XML::Nod } -ParamNotebook::ParamNotebook (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) +ParamNotebook::ParamNotebook(const gchar * name, + const gchar * text, + const gchar * description, + bool hidden, + int indent, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml) + : Parameter(name, text, description, hidden, indent, ext) { pages = NULL; @@ -353,11 +360,7 @@ public: // hook function this->signal_switch_page().connect(sigc::mem_fun(this, &ParamNotebookWdg::changed_page)); }; -#if WITH_GTKMM_3_0 void changed_page(Gtk::Widget *page, guint pagenum); -#else - void changed_page(GtkNotebookPage *page, guint pagenum); -#endif bool activated; }; @@ -368,11 +371,7 @@ public: * is actually visible. This to exclude 'fake' changes when the * notebookpages are added or removed. */ -#if WITH_GTKMM_3_0 void ParamNotebookWdg::changed_page(Gtk::Widget * /*page*/, guint pagenum) -#else -void ParamNotebookWdg::changed_page(GtkNotebookPage * /*page*/, guint pagenum) -#endif { if (get_visible()) { _pref->set((int)pagenum, _doc, _node); @@ -424,7 +423,7 @@ Parameter *ParamNotebookPage::get_param(const gchar * name) */ Gtk::Widget * ParamNotebook::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) { - if (_gui_hidden) { + if (_hidden) { return NULL; } @@ -437,7 +436,7 @@ Gtk::Widget * ParamNotebook::get_widget(SPDocument * doc, Inkscape::XML::Node * i++; ParamNotebookPage * page = reinterpret_cast<ParamNotebookPage *>(list->data); Gtk::Widget * widg = page->get_widget(doc, node, changeSignal); - nb->append_page(*widg, _(page->get_guitext())); + nb->append_page(*widg, _(page->get_text())); if (!strcmp(_value, page->name())) { pagenr = i; // this is the page to be displayed? } diff --git a/src/extension/param/notebook.h b/src/extension/param/notebook.h index 3c90964fd..8475de61d 100644 --- a/src/extension/param/notebook.h +++ b/src/extension/param/notebook.h @@ -41,8 +41,15 @@ private: This only gets created if there are pages in this notebook */ public: - ParamNotebook(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); + ParamNotebook(const gchar * name, + const gchar * text, + const gchar * description, + bool hidden, + int indent, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml); virtual ~ParamNotebook(void); + Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal); /** diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index e4a614667..5c4fe591f 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -50,100 +50,112 @@ Parameter *Parameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex const char *name = in_repr->attribute("name"); const char *type = in_repr->attribute("type"); - // In this case we just don't have enough information - if (!name || !type) { + // we can't create a parameter without type + if (!type) { return NULL; } + // also require name unless it's a pure UI element that does not store its value + if (!name) { + static std::vector<std::string> ui_elements = {"description"}; + if (std::find(ui_elements.begin(), ui_elements.end(), type) == ui_elements.end()) { + return NULL; + } + } - const char *guitext = in_repr->attribute("gui-text"); - if (guitext == NULL) { - guitext = in_repr->attribute("_gui-text"); - if (guitext == NULL) { - // guitext = ""; // propably better to require devs to explicitly set an empty gui-text if this is what they want + const char *text = in_repr->attribute("gui-text"); + if (text == NULL) { + text = in_repr->attribute("_gui-text"); + if (text == NULL) { + // text = ""; // propably better to require devs to explicitly set an empty gui-text if this is what they want } else { const char *context = in_repr->attribute("msgctxt"); if (context != NULL) { - guitext = g_dpgettext2(NULL, context, guitext); + text = g_dpgettext2(NULL, context, text); } else { - guitext = _(guitext); + text = _(text); } } } - const char *gui_tip = in_repr->attribute("gui-tip"); - if (gui_tip == NULL) { - gui_tip = in_repr->attribute("_gui-tip"); - } - const char *desc = in_repr->attribute("gui-description"); - if (desc == NULL) { - desc = in_repr->attribute("_gui-description"); + const char *description = in_repr->attribute("gui-description"); + if (description == NULL) { + description = in_repr->attribute("_gui-description"); + if (description != NULL) { + const char *context = in_repr->attribute("msgctxt"); + if (context != NULL) { + description = g_dpgettext2(NULL, context, description); + } else { + description = _(description); + } + } } - bool gui_hidden = false; + bool hidden = false; { const char *gui_hide = in_repr->attribute("gui-hidden"); if (gui_hide != NULL) { if (strcmp(gui_hide, "1") == 0 || strcmp(gui_hide, "true") == 0) { - gui_hidden = true; + hidden = true; } /* else stays false */ } } - const gchar* appearance = in_repr->attribute("appearance"); - - Parameter::_scope_t scope = Parameter::SCOPE_USER; + int indent = 0; { - const char *scope_str = in_repr->attribute("scope"); - if (scope_str != NULL) { - if (!strcmp(scope_str, "user")) { - scope = Parameter::SCOPE_USER; - } else if (!strcmp(scope_str, "document")) { - scope = Parameter::SCOPE_DOCUMENT; - } else if (!strcmp(scope_str, "node")) { - scope = Parameter::SCOPE_NODE; + const char *indent_attr = in_repr->attribute("indent"); + if (indent_attr != NULL) { + if (strcmp(indent_attr, "true") == 0) { + indent = 1; + } else { + indent = atoi(indent_attr); } } } + const gchar* appearance = in_repr->attribute("appearance"); Parameter * param = NULL; if (!strcmp(type, "boolean")) { - param = new ParamBool(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); + param = new ParamBool(name, text, description, hidden, indent, in_ext, in_repr); } else if (!strcmp(type, "int")) { if (appearance && !strcmp(appearance, "full")) { - param = new ParamInt(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamInt::FULL); + param = new ParamInt(name, text, description, hidden, indent, in_ext, in_repr, ParamInt::FULL); } else { - param = new ParamInt(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamInt::MINIMAL); + param = new ParamInt(name, text, description, hidden, indent, in_ext, in_repr, ParamInt::MINIMAL); } } else if (!strcmp(type, "float")) { if (appearance && !strcmp(appearance, "full")) { - param = new ParamFloat(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamFloat::FULL); + param = new ParamFloat(name, text, description, hidden, indent, in_ext, in_repr, ParamFloat::FULL); } else { - param = new ParamFloat(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamFloat::MINIMAL); + param = new ParamFloat(name, text, description, hidden, indent, 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); + param = new ParamString(name, text, description, hidden, indent, in_ext, in_repr); gchar const * max_length = in_repr->attribute("max_length"); if (max_length != NULL) { ParamString * ps = dynamic_cast<ParamString *>(param); ps->setMaxLength(atoi(max_length)); } } else if (!strcmp(type, "description")) { - 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); - } + ParamDescription::AppearanceMode appearance_mode = ParamDescription::DESCRIPTION; + if (appearance) { + if (!strcmp(appearance, "header")) { + appearance_mode = ParamDescription::HEADER; + } else if (!strcmp(appearance, "url")) { + appearance_mode = ParamDescription::URL; + } + } + param = new ParamDescription(name, text, description, hidden, indent, in_ext, in_repr, appearance_mode); } else if (!strcmp(type, "enum")) { - param = new ParamComboBox(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); + param = new ParamComboBox(name, text, description, hidden, indent, in_ext, in_repr); } else if (!strcmp(type, "notebook")) { - param = new ParamNotebook(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); + param = new ParamNotebook(name, text, description, hidden, indent, in_ext, in_repr); } else if (!strcmp(type, "optiongroup")) { if (appearance && !strcmp(appearance, "minimal")) { - param = new ParamRadioButton(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamRadioButton::MINIMAL); + param = new ParamRadioButton(name, text, description, hidden, indent, in_ext, in_repr, ParamRadioButton::MINIMAL); } else { - param = new ParamRadioButton(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr, ParamRadioButton::FULL); + param = new ParamRadioButton(name, text, description, hidden, indent, in_ext, in_repr, ParamRadioButton::FULL); } } else if (!strcmp(type, "color")) { - param = new ParamColor(name, guitext, desc, scope, gui_hidden, gui_tip, in_ext, in_repr); + param = new ParamColor(name, text, description, hidden, indent, in_ext, in_repr); } // Note: param could equal NULL @@ -290,28 +302,24 @@ Parameter::set_color (guint32 in, SPDocument * doc, Inkscape::XML::Node * node) /** Oop, now that we need a parameter, we need it's name. */ -Parameter::Parameter(gchar const * name, gchar const * guitext, gchar const * desc, const Parameter::_scope_t scope, bool gui_hidden, gchar const * gui_tip, Inkscape::Extension::Extension * ext) : - _desc(0), - _scope(scope), +Parameter::Parameter(gchar const * name, gchar const * text, gchar const * description, bool hidden, int indent, Inkscape::Extension::Extension * ext) : + _description(0), _text(0), - _gui_hidden(gui_hidden), - _gui_tip(0), - extension(ext), + _hidden(hidden), + _indent(indent), + _extension(ext), _name(0) { if (name != NULL) { _name = g_strdup(name); } - if (desc != NULL) { - _desc = g_strdup(desc); -// printf("Adding description: '%s' on '%s'\n", _desc, _name); - } - if (gui_tip != NULL) { - _gui_tip = g_strdup(gui_tip); + + if (description != NULL) { + _description = g_strdup(description); } - if (guitext != NULL) { - _text = g_strdup(guitext); + if (text != NULL) { + _text = g_strdup(text); } else { _text = g_strdup(name); } @@ -320,20 +328,19 @@ Parameter::Parameter(gchar const * name, gchar const * guitext, gchar const * de } /** Oop, now that we need a parameter, we need it's name. */ -Parameter::Parameter (gchar const * name, gchar const * guitext, Inkscape::Extension::Extension * ext) : - _desc(0), - _scope(Parameter::SCOPE_USER), +Parameter::Parameter (gchar const * name, gchar const * text, Inkscape::Extension::Extension * ext) : + _description(0), _text(0), - _gui_hidden(false), - _gui_tip(0), - extension(ext), + _hidden(false), + _indent(0), + _extension(ext), _name(0) { if (name != NULL) { _name = g_strdup(name); } - if (guitext != NULL) { - _text = g_strdup(guitext); + if (text != NULL) { + _text = g_strdup(text); } else { _text = g_strdup(name); } @@ -349,16 +356,13 @@ Parameter::~Parameter(void) g_free(_text); _text = 0; - g_free(_gui_tip); - _gui_tip = 0; - - g_free(_desc); - _desc = 0; + g_free(_description); + _description = 0; } gchar *Parameter::pref_name(void) const { - return g_strdup_printf("%s.%s", extension->get_id(), _name); + return g_strdup_printf("%s.%s", _extension->get_id(), _name); } Inkscape::XML::Node * @@ -391,7 +395,7 @@ Inkscape::XML::Node *Parameter::document_param_node(SPDocument * doc) child != NULL; child = child->next()) { if ((GQuark)child->code() == name_quark && - !strcmp(child->attribute("extension"), extension->get_id())) { + !strcmp(child->attribute("extension"), _extension->get_id())) { params = child; break; } @@ -399,7 +403,7 @@ Inkscape::XML::Node *Parameter::document_param_node(SPDocument * doc) if (params == NULL) { params = xml_doc->createElement("inkscape:extension-param"); - params->setAttribute("extension", extension->get_id()); + params->setAttribute("extension", _extension->get_id()); defs->appendChild(params); Inkscape::GC::release(params); } diff --git a/src/extension/param/parameter.h b/src/extension/param/parameter.h index 5e1e3897f..96cc055d8 100644 --- a/src/extension/param/parameter.h +++ b/src/extension/param/parameter.h @@ -37,7 +37,7 @@ class Extension; */ extern Glib::ustring const extension_pref_root; -/** +/** * A class to represent the parameter of an extension. * * This is really a super class that allows them to abstract all @@ -47,25 +47,16 @@ extern Glib::ustring const extension_pref_root; */ class Parameter { -protected: - /** List of possible scopes. */ - typedef enum { - SCOPE_USER, /**< Parameter value is saved in the user's configuration file. (default) */ - SCOPE_DOCUMENT, /**< Parameter value is saved in the document. */ - SCOPE_NODE /**< Parameter value is attached to the node. */ - } _scope_t; - public: Parameter(gchar const *name, - gchar const *guitext, - gchar const *desc, - const Parameter::_scope_t scope, - bool gui_hidden, - gchar const *gui_tip, + gchar const *text, + gchar const *description, + bool hidden, + int indent, Inkscape::Extension::Extension * ext); Parameter(gchar const *name, - gchar const *guitext, + gchar const *text, Inkscape::Extension::Extension * ext); virtual ~Parameter(void); @@ -139,10 +130,13 @@ public: virtual Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal); - gchar const * get_tooltip(void) const { return _desc; } + gchar const * get_tooltip(void) const { return _description; } /** Indicates if the GUI for this parameter is hidden or not */ - bool get_gui_hidden() const { return _gui_hidden; } + bool get_hidden() const { return _hidden; } + + /** Indentation level of the parameter */ + int get_indent() const { return _indent; } virtual void string(std::list <std::string> &list) const; @@ -155,21 +149,31 @@ public: /** All the code in Notebook::get_param to get the notebook content. */ virtual Parameter *get_param(gchar const *name); -protected: - /** Description of the parameter. */ - gchar * _desc; - /** Scope of the parameter. */ - _scope_t _scope; + /** Recommended margin of boxes containing multiple Parameters (in px) */ + const static int GUI_BOX_MARGIN = 10; + /** Recommended spacing between multiple Parameters packed into a box (in px) */ + const static int GUI_BOX_SPACING = 4; + /** Recommended spacing between the widgets making up a signle Parameter (e.g. label and input) (in px) */ + const static int GUI_PARAM_WIDGETS_SPACING = 4; + /** Recommended indentation width of parameters (in px) */ + const static int GUI_INDENTATION = 12; + /** Recommended maximum line lenght for wrapping textual parameters (in chars) */ + const static int GUI_MAX_LINE_LENGTH = 60; + + +protected: + /** Parameter text to show as the GUI label. */ + gchar * _text; - /** Text for the GUI selection of this. */ - gchar * _text; + /** Extended description of the parameter (crrently shown as tooltip on hover). */ + gchar * _description; - /** Whether the GUI is visible. */ - bool _gui_hidden; + /** Whether the parameter is visible. */ + bool _hidden; - /** A tip for the GUI if there is one. */ - gchar * _gui_tip; + /** Indentation level of the parameter. */ + int _indent; /* **** funcs **** */ @@ -187,7 +191,7 @@ protected: private: /** Which extension is this parameter attached to. */ - Inkscape::Extension::Extension *extension; + Inkscape::Extension::Extension *_extension; /** The name of this parameter. */ gchar *_name; diff --git a/src/extension/param/radiobutton.cpp b/src/extension/param/radiobutton.cpp index 1d1b860c6..a08ba6860 100644 --- a/src/extension/param/radiobutton.cpp +++ b/src/extension/param/radiobutton.cpp @@ -41,33 +41,34 @@ 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 optionentry { public: - optionentry (Glib::ustring * val, Glib::ustring * text) { + optionentry (Glib::ustring * val, Glib::ustring * txt) { value = val; - guitext = text; + text = txt; } ~optionentry() { delete value; - delete guitext; + delete text; } Glib::ustring * value; - Glib::ustring * guitext; + Glib::ustring * text; }; -ParamRadioButton::ParamRadioButton (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), _indent(0), choices(0) +ParamRadioButton::ParamRadioButton(const gchar * name, + const gchar * text, + const gchar * description, + bool hidden, + int indent, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml, + AppearanceMode mode) + : Parameter(name, text, description, hidden, indent, ext) + , _value(0) + , _mode(mode) + , choices(0) { // Read XML tree to add enumeration items: // printf("Extension Constructor: "); @@ -76,7 +77,7 @@ ParamRadioButton::ParamRadioButton (const gchar * name, while (child_repr != NULL) { char const * chname = child_repr->name(); if (!strcmp(chname, INKSCAPE_EXTENSION_NS "option") || !strcmp(chname, INKSCAPE_EXTENSION_NS "_option")) { - Glib::ustring * newguitext = NULL; + Glib::ustring * newtext = NULL; Glib::ustring * newvalue = NULL; const char * contents = child_repr->firstChild()->content(); @@ -84,12 +85,12 @@ ParamRadioButton::ParamRadioButton (const gchar * name, // 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)); + newtext = new Glib::ustring(g_dpgettext2(NULL, child_repr->attribute("msgctxt"), contents)); } else { - newguitext = new Glib::ustring(_(contents)); + newtext = new Glib::ustring(_(contents)); } } else { - newguitext = new Glib::ustring(contents); + newtext = new Glib::ustring(contents); } } else { continue; @@ -103,8 +104,8 @@ ParamRadioButton::ParamRadioButton (const gchar * name, newvalue = new Glib::ustring(contents); } - if ( (newguitext) && (newvalue) ) { // logical error if this is not true here - choices = g_slist_append( choices, new optionentry(newvalue, newguitext) ); + if ( (newtext) && (newvalue) ) { // logical error if this is not true here + choices = g_slist_append( choices, new optionentry(newvalue, newtext) ); } } child_repr = child_repr->next(); @@ -118,11 +119,6 @@ ParamRadioButton::ParamRadioButton (const gchar * name, defaultval = (static_cast<optionentry*> (choices->data))->value->c_str(); } - const char *indent = xml ? xml->attribute("indent") : NULL; - 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); @@ -284,7 +280,7 @@ Glib::ustring ParamRadioButton::value_from_label(const Glib::ustring label) for (GSList * list = choices; list != NULL; list = g_slist_next(list)) { optionentry * entr = reinterpret_cast<optionentry *>(list->data); - if ( !entr->guitext->compare(label) ) { + if ( !entr->text->compare(label) ) { value = *(entr->value); break; } @@ -299,23 +295,18 @@ Glib::ustring ParamRadioButton::value_from_label(const Glib::ustring label) */ Gtk::Widget * ParamRadioButton::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) { - if (_gui_hidden) { + if (_hidden) { return NULL; } -#if WITH_GTKMM_3_0 - Gtk::Box * hbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, 4)); + auto hbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, Parameter::GUI_PARAM_WIDGETS_SPACING)); hbox->set_homogeneous(false); - Gtk::Box * vbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL, 0)); + auto vbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL, 0)); vbox->set_homogeneous(false); -#else - Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); - Gtk::VBox * vbox = Gtk::manage(new Gtk::VBox(false, 0)); -#endif Gtk::Label * label = Gtk::manage(new Gtk::Label(_text, Gtk::ALIGN_START, Gtk::ALIGN_START)); label->show(); - hbox->pack_start(*label, false, false, _indent); + hbox->pack_start(*label, false, false); Gtk::ComboBoxText* cbt = 0; bool comboSet = false; @@ -330,7 +321,7 @@ Gtk::Widget * ParamRadioButton::get_widget(SPDocument * doc, Inkscape::XML::Node Gtk::RadioButtonGroup group; for (GSList * list = choices; list != NULL; list = g_slist_next(list)) { optionentry * entr = reinterpret_cast<optionentry *>(list->data); - Glib::ustring * text = entr->guitext; + Glib::ustring * text = entr->text; switch ( _mode ) { case MINIMAL: { diff --git a/src/extension/param/radiobutton.h b/src/extension/param/radiobutton.h index 0e0f643c9..b91b11ea3 100644 --- a/src/extension/param/radiobutton.h +++ b/src/extension/param/radiobutton.h @@ -35,15 +35,15 @@ public: }; ParamRadioButton(const gchar * name, - const gchar * guitext, - const gchar * desc, - const Parameter::_scope_t scope, - bool gui_hidden, - const gchar * gui_tip, + const gchar * text, + const gchar * description, + bool hidden, + int indent, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml, AppearanceMode mode); virtual ~ParamRadioButton(void); + Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal); // Explicitly call superclass version to avoid method being hidden. @@ -63,7 +63,6 @@ private: It is the value of the current selected string */ gchar * _value; AppearanceMode _mode; - int _indent; GSList * choices; /**< A table to store the choice strings */ }; /* class ParamRadioButton */ diff --git a/src/extension/param/string.cpp b/src/extension/param/string.cpp index 6b082b133..51b5dfdf3 100644 --- a/src/extension/param/string.cpp +++ b/src/extension/param/string.cpp @@ -24,7 +24,7 @@ namespace Inkscape { namespace Extension { - + /** Free the allocated data. */ ParamString::~ParamString(void) @@ -76,20 +76,21 @@ void ParamString::string(std::string &string) const } /** Initialize the object, to do that, copy the data. */ -ParamString::ParamString (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) +ParamString::ParamString(const gchar * name, + const gchar * text, + const gchar * description, + bool hidden, + int indent, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml) + : Parameter(name, text, description, hidden, indent, ext) + , _value(NULL) { const char * defaultval = NULL; if (xml->firstChild() != NULL) { defaultval = xml->firstChild()->content(); } - 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); @@ -161,14 +162,14 @@ void ParamStringEntry::changed_text(void) */ Gtk::Widget * ParamString::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) { - if (_gui_hidden) { + if (_hidden) { 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, _indent); + hbox->pack_start(*label, false, false); ParamStringEntry * textbox = new ParamStringEntry(this, doc, node, changeSignal); textbox->show(); diff --git a/src/extension/param/string.h b/src/extension/param/string.h index 3b137aeac..d338f83b9 100644 --- a/src/extension/param/string.h +++ b/src/extension/param/string.h @@ -19,12 +19,17 @@ private: /** \brief Internal value. This should point to a string that has been allocated in memory. And should be free'd. */ gchar * _value; - /** \brief Internal value. This indicates the maximum leght of the string. Zero meaning unlimited. + /** \brief Internal value. This indicates the maximum lenth of the string. Zero meaning unlimited. */ - int _indent; gint _max_length; public: - ParamString(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); + ParamString(const gchar * name, + const gchar * text, + const gchar * description, + bool hidden, + int indent, + Inkscape::Extension::Extension * ext, + Inkscape::XML::Node * xml); virtual ~ParamString(void); /** \brief Returns \c _value, with a \i const to protect it. */ diff --git a/src/extension/patheffect.cpp b/src/extension/patheffect.cpp index bedab7fd8..e30ec97df 100644 --- a/src/extension/patheffect.cpp +++ b/src/extension/patheffect.cpp @@ -8,7 +8,6 @@ */ #include "document-private.h" -#include "sp-object.h" #include "patheffect.h" #include "db.h" diff --git a/src/extension/plugins/grid2/grid.cpp b/src/extension/plugins/grid2/grid.cpp index 6880c574d..233d4e522 100644 --- a/src/extension/plugins/grid2/grid.cpp +++ b/src/extension/plugins/grid2/grid.cpp @@ -186,10 +186,10 @@ Grid::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View { SPDocument * current_document = view->doc(); - std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList(); + auto selected = ((SPDesktop *) view)->getSelection()->items(); Inkscape::XML::Node * first_select = NULL; if (!selected.empty()) { - first_select = selected[0]->getRepr(); + first_select = selected.front()->getRepr(); } return module->autogui(current_document, first_select, changeSignal); diff --git a/src/extension/prefdialog.cpp b/src/extension/prefdialog.cpp index 2521dc1de..92ddd3050 100644 --- a/src/extension/prefdialog.cpp +++ b/src/extension/prefdialog.cpp @@ -8,7 +8,6 @@ */ #include "prefdialog.h" -#include <gtkmm/stock.h> #include <gtkmm/checkbutton.h> #include <gtkmm/separator.h> #include <glibmm/i18n.h> @@ -41,11 +40,7 @@ namespace Extension { them. It also places the passed-in widgets into the dialog. */ PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * controls, Effect * effect) : -#if WITH_GTKMM_3_0 Gtk::Dialog(_(name.c_str()), true), -#else - Gtk::Dialog(_(name.c_str()), true, true), -#endif _help(help), _name(name), _button_ok(NULL), @@ -55,6 +50,8 @@ PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * co _effect(effect), _exEnv(NULL) { + this->set_default_size(0,0); // we want the window to be as small as possible instead of clobbering up space + Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox()); if (controls == NULL) { if (_effect == NULL) { @@ -64,26 +61,18 @@ PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * co controls = _effect->get_imp()->prefs_effect(_effect, SP_ACTIVE_DESKTOP, &_signal_param_change, NULL); _signal_param_change.connect(sigc::mem_fun(this, &PrefDialog::param_change)); } - - hbox->pack_start(*controls, true, true, 6); + hbox->pack_start(*controls, true, true, 0); hbox->show(); -#if WITH_GTKMM_3_0 - this->get_content_area()->pack_start(*hbox, true, true, 6); -#else - this->get_vbox()->pack_start(*hbox, true, true, 6); -#endif + this->get_content_area()->pack_start(*hbox, true, true, 0); /* Gtk::Button * help_button = add_button(Gtk::Stock::HELP, Gtk::RESPONSE_HELP); if (_help == NULL) help_button->set_sensitive(false); */ - _button_cancel = add_button(_effect == NULL ? Gtk::Stock::CANCEL : Gtk::Stock::CLOSE, Gtk::RESPONSE_CANCEL); - _button_cancel->set_use_stock(true); - - _button_ok = add_button(_effect == NULL ? Gtk::Stock::OK : Gtk::Stock::APPLY, Gtk::RESPONSE_OK); - _button_ok->set_use_stock(true); + _button_cancel = add_button(_effect == NULL ? _("_Cancel") : _("_Close"), Gtk::RESPONSE_CANCEL); + _button_ok = add_button(_effect == NULL ? _("_OK") : _("_Apply"), Gtk::RESPONSE_OK); set_default_response(Gtk::RESPONSE_OK); _button_ok->grab_focus(); @@ -97,39 +86,23 @@ PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * co _param_preview = Parameter::make(doc->root(), _effect); } -#if WITH_GTKMM_3_0 - Gtk::Separator * sep = Gtk::manage(new Gtk::Separator()); -#else - Gtk::HSeparator * sep = Gtk::manage(new Gtk::HSeparator()); -#endif - + auto sep = Gtk::manage(new Gtk::Separator()); sep->show(); -#if WITH_GTKMM_3_0 - this->get_content_area()->pack_start(*sep, true, true, 4); -#else - this->get_vbox()->pack_start(*sep, true, true, 4); -#endif + this->get_content_area()->pack_start(*sep, false, false, Parameter::GUI_BOX_SPACING); hbox = Gtk::manage(new Gtk::HBox()); + hbox->set_border_width(Parameter::GUI_BOX_MARGIN); _button_preview = _param_preview->get_widget(NULL, NULL, &_signal_preview); _button_preview->show(); - hbox->pack_start(*_button_preview, true, true,6); + hbox->pack_start(*_button_preview, true, true, 0); hbox->show(); -#if WITH_GTKMM_3_0 - this->get_content_area()->pack_start(*hbox, true, true, 6); -#else - this->get_vbox()->pack_start(*hbox, true, true, 6); -#endif + this->get_content_area()->pack_start(*hbox, false, false, 0); Gtk::Box * hbox = dynamic_cast<Gtk::Box *>(_button_preview); if (hbox != NULL) { -#if WITH_GTKMM_3_0 _checkbox_preview = dynamic_cast<Gtk::CheckButton *>(hbox->get_children().front()); -#else - _checkbox_preview = dynamic_cast<Gtk::CheckButton *>(hbox->children().back().get_widget()); -#endif } preview_toggle(); @@ -273,7 +246,7 @@ PrefDialog::on_response (int signal) { #include "internal/clear-n_.h" -const char * PrefDialog::live_param_xml = "<param name=\"__live_effect__\" type=\"boolean\" _gui-text=\"" N_("Live preview") "\" gui-description=\"" N_("Is the effect previewed live on canvas?") "\" scope=\"user\">false</param>"; +const char * PrefDialog::live_param_xml = "<param name=\"__live_effect__\" type=\"boolean\" _gui-text=\"" N_("Live preview") "\" gui-description=\"" N_("Is the effect previewed live on canvas?") "\">false</param>"; }; }; /* namespace Inkscape, Extension */ diff --git a/src/extension/system.cpp b/src/extension/system.cpp index 3c623455a..afa8346df 100644 --- a/src/extension/system.cpp +++ b/src/extension/system.cpp @@ -17,12 +17,10 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include "ui/interface.h" -#include <unistd.h> -#include <glibmm/miscutils.h> #include "system.h" #include "preferences.h" @@ -41,6 +39,7 @@ #include "document-undo.h" #include "loader.h" +#include <glibmm/miscutils.h> namespace Inkscape { namespace Extension { |
