diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2019-06-19 13:59:29 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2019-07-08 21:04:13 +0000 |
| commit | af9c8d266f97d9ae17f13ee42f3078a85371b38c (patch) | |
| tree | b34991e98958d476c9d13a64a368ae083ac48617 | |
| parent | Add initial commit (diff) | |
| download | inkscape-af9c8d266f97d9ae17f13ee42f3078a85371b38c.tar.gz inkscape-af9c8d266f97d9ae17f13ee42f3078a85371b38c.zip | |
allow multiple style tags
| -rw-r--r-- | share/icons/hicolor/symbolic/actions/dialog-align-and-distribute-symbolic.svg | 6 | ||||
| -rw-r--r-- | src/inkscape.cpp | 275 | ||||
| -rw-r--r-- | src/inkscape.h | 1 | ||||
| -rw-r--r-- | src/io/file.cpp | 2 | ||||
| -rw-r--r-- | src/ui/dialog/selectorsdialog.cpp | 21 | ||||
| -rw-r--r-- | src/ui/dialog/styledialog.cpp | 26 |
6 files changed, 146 insertions, 185 deletions
diff --git a/share/icons/hicolor/symbolic/actions/dialog-align-and-distribute-symbolic.svg b/share/icons/hicolor/symbolic/actions/dialog-align-and-distribute-symbolic.svg index fb33ebec6..0f280bb38 100644 --- a/share/icons/hicolor/symbolic/actions/dialog-align-and-distribute-symbolic.svg +++ b/share/icons/hicolor/symbolic/actions/dialog-align-and-distribute-symbolic.svg @@ -8,7 +8,11 @@ .warning { fill:#F57900; } .error { fill:#cc0000; } </style> - <style id="highlights"> @import "../../highlights.css"; </style> + <style id="style226"> + .success { fill:#009911; } + .warning { fill:#009911; } + .error { fill:#00ffff; } + </style> <g transform="translate(-135,-807.36218)" inkscape:label="00069" id="dialog-align-and-distribute"> <path inkscape:connector-curvature="0" id="rect18735" d="m 135,807.36218 h 16 v 16 h -16 z" style="opacity:0;fill:none"/> <path inkscape:connector-curvature="0" id="rect18737" d="m 136,808.36218 h 1 v 13 h -1 z" style="opacity:1"/> diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 168218393..b7d2c02c2 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -402,6 +402,131 @@ Glib::ustring Application::get_symbolic_colors() return css_str; } + +/* \brief Constructor for the application. + * Creates a new Inkscape::Application. + * + * \pre Application::_S_inst == NULL + */ + +Application::Application(bool use_gui) : + _menus(nullptr), + _desktops(nullptr), + refCount(1), + _dialogs_toggle(TRUE), + _mapalt(GDK_MOD1_MASK), + _trackalt(FALSE), + _use_gui(use_gui) +{ + using namespace Inkscape::IO::Resource; + /* fixme: load application defaults */ + + segv_handler = signal (SIGSEGV, Application::crash_handler); + abrt_handler = signal (SIGABRT, Application::crash_handler); + fpe_handler = signal (SIGFPE, Application::crash_handler); + ill_handler = signal (SIGILL, Application::crash_handler); +#ifndef _WIN32 + bus_handler = signal (SIGBUS, Application::crash_handler); +#endif + + // \TODO: this belongs to Application::init but if it isn't here + // then the Filters and Extensions menus don't work. + _S_inst = this; + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + InkErrorHandler* handler = new InkErrorHandler(use_gui); + prefs->setErrorHandler(handler); + { + Glib::ustring msg; + Glib::ustring secondary; + if (prefs->getLastError( msg, secondary )) { + handler->handleError(msg, secondary); + } + } + + if (use_gui) { + using namespace Inkscape::IO::Resource; + auto icon_theme = Gtk::IconTheme::get_default(); + icon_theme->prepend_search_path(get_path_ustring(SYSTEM, ICONS)); + icon_theme->prepend_search_path(get_path_ustring(USER, ICONS)); + add_gtk_css(); + /* Load the preferences and menus */ + load_menus(); + Inkscape::DeviceManager::getManager().loadConfig(); + } + + Inkscape::ResourceManager::getManager(); + + /* set language for user interface according setting in preferences */ + Glib::ustring ui_language = prefs->getString("/ui/language"); + if(!ui_language.empty()) + { + setenv("LANGUAGE", ui_language, true); + } + + /* DebugDialog redirection. On Linux, default to OFF, on Win32, default to ON. + * Use only if use_gui is enabled + */ +#ifdef _WIN32 +#define DEFAULT_LOG_REDIRECT true +#else +#define DEFAULT_LOG_REDIRECT false +#endif + + if (use_gui && prefs->getBool("/dialogs/debug/redirect", DEFAULT_LOG_REDIRECT)) + { + Inkscape::UI::Dialog::DebugDialog::getInstance()->captureLogMessages(); + } + + if (use_gui) + { + Inkscape::UI::Tools::init_latin_keys_group(); + /* Check for global remapping of Alt key */ + mapalt(guint(prefs->getInt("/options/mapalt/value", 0))); + trackalt(guint(prefs->getInt("/options/trackalt/value", 0))); + } + + /* Initialize the extensions */ + Inkscape::Extension::init(); + + autosave_init(); + + /* Initialize font factory */ + font_factory *factory = font_factory::Default(); + if (prefs->getBool("/options/font/use_fontsdir_system", true)) { + char const *fontsdir = get_path(SYSTEM, FONTS); + factory->AddFontsDir(fontsdir); + } + if (prefs->getBool("/options/font/use_fontsdir_user", true)) { + char const *fontsdir = get_path(USER, FONTS); + factory->AddFontsDir(fontsdir); + } + Glib::ustring fontdirs_pref = prefs->getString("/options/font/custom_fontdirs"); + std::vector<Glib::ustring> fontdirs = Glib::Regex::split_simple("\\|", fontdirs_pref); + for (auto &fontdir : fontdirs) { + factory->AddFontsDir(fontdir.c_str()); + } +} + +Application::~Application() +{ + if (_desktops) { + g_error("FATAL: desktops still in list on application destruction!"); + } + + Inkscape::Preferences::unload(); + + if (_menus) { + Inkscape::GC::release(_menus); + _menus = nullptr; + } + + _S_inst = nullptr; // this will probably break things + + refCount = 0; + // gtk_main_quit (); +} + void Application::get_higlight_colors(gchar *colornamedsuccess, gchar *colornamedwarning, gchar *colornamederror) { using namespace Inkscape::IO::Resource; @@ -550,152 +675,26 @@ Application::add_gtk_css() } } -void Application::readStyleSheets(bool forceupd) +void Application::readStyleSheets() { SPDocument *document = SP_ACTIVE_DOCUMENT; + document->setStyleSheet(nullptr); Inkscape::XML::Node *root = document->getReprRoot(); - std::vector<Inkscape::XML::Node *> styles; + std::vector <Inkscape::XML::Node *> styles; for (unsigned i = 0; i < root->childCount(); ++i) { - Inkscape::XML::Node *child = root->nthChild(i); - if (child && strcmp(child->name(), "svg:style") == 0) { - styles.insert(styles.begin(), child); + Inkscape::XML::Node * child = root->nthChild(i); + if (child && strcmp(child->name(),"svg:style") == 0) { + styles.insert(styles.begin(),child); } } - if (forceupd || styles.size() > 1) { - document->setStyleSheet(nullptr); - for (auto style : styles) { - gchar const *id = style->attribute("id"); - if (id) { - SPStyleElem *styleelem = dynamic_cast<SPStyleElem *>(document->getObjectById(id)); - styleelem->read_content(); - } + for (auto style : styles) { + gchar const * id = style->attribute("id"); + if (id) { + SPStyleElem *styleelem = dynamic_cast<SPStyleElem *>(document->getObjectById(id)); + styleelem->read_content(); } - document->getRoot()->emitModified(SP_OBJECT_MODIFIED_CASCADE); - } -} - -/* \brief Constructor for the application. - * Creates a new Inkscape::Application. - * - * \pre Application::_S_inst == NULL - */ - -Application::Application(bool use_gui) : - _menus(nullptr), - _desktops(nullptr), - refCount(1), - _dialogs_toggle(TRUE), - _mapalt(GDK_MOD1_MASK), - _trackalt(FALSE), - _use_gui(use_gui) -{ - using namespace Inkscape::IO::Resource; - /* fixme: load application defaults */ - - segv_handler = signal (SIGSEGV, Application::crash_handler); - abrt_handler = signal (SIGABRT, Application::crash_handler); - fpe_handler = signal (SIGFPE, Application::crash_handler); - ill_handler = signal (SIGILL, Application::crash_handler); -#ifndef _WIN32 - bus_handler = signal (SIGBUS, Application::crash_handler); -#endif - - // \TODO: this belongs to Application::init but if it isn't here - // then the Filters and Extensions menus don't work. - _S_inst = this; - - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - InkErrorHandler* handler = new InkErrorHandler(use_gui); - prefs->setErrorHandler(handler); - { - Glib::ustring msg; - Glib::ustring secondary; - if (prefs->getLastError( msg, secondary )) { - handler->handleError(msg, secondary); - } - } - - if (use_gui) { - using namespace Inkscape::IO::Resource; - auto icon_theme = Gtk::IconTheme::get_default(); - icon_theme->prepend_search_path(get_path_ustring(SYSTEM, ICONS)); - icon_theme->prepend_search_path(get_path_ustring(USER, ICONS)); - add_gtk_css(); - /* Load the preferences and menus */ - load_menus(); - Inkscape::DeviceManager::getManager().loadConfig(); - } - - Inkscape::ResourceManager::getManager(); - - /* set language for user interface according setting in preferences */ - Glib::ustring ui_language = prefs->getString("/ui/language"); - if(!ui_language.empty()) - { - setenv("LANGUAGE", ui_language, true); } - - /* DebugDialog redirection. On Linux, default to OFF, on Win32, default to ON. - * Use only if use_gui is enabled - */ -#ifdef _WIN32 -#define DEFAULT_LOG_REDIRECT true -#else -#define DEFAULT_LOG_REDIRECT false -#endif - - if (use_gui && prefs->getBool("/dialogs/debug/redirect", DEFAULT_LOG_REDIRECT)) - { - Inkscape::UI::Dialog::DebugDialog::getInstance()->captureLogMessages(); - } - - if (use_gui) - { - Inkscape::UI::Tools::init_latin_keys_group(); - /* Check for global remapping of Alt key */ - mapalt(guint(prefs->getInt("/options/mapalt/value", 0))); - trackalt(guint(prefs->getInt("/options/trackalt/value", 0))); - } - - /* Initialize the extensions */ - Inkscape::Extension::init(); - - autosave_init(); - - /* Initialize font factory */ - font_factory *factory = font_factory::Default(); - if (prefs->getBool("/options/font/use_fontsdir_system", true)) { - char const *fontsdir = get_path(SYSTEM, FONTS); - factory->AddFontsDir(fontsdir); - } - if (prefs->getBool("/options/font/use_fontsdir_user", true)) { - char const *fontsdir = get_path(USER, FONTS); - factory->AddFontsDir(fontsdir); - } - Glib::ustring fontdirs_pref = prefs->getString("/options/font/custom_fontdirs"); - std::vector<Glib::ustring> fontdirs = Glib::Regex::split_simple("\\|", fontdirs_pref); - for (auto &fontdir : fontdirs) { - factory->AddFontsDir(fontdir.c_str()); - } -} - -Application::~Application() -{ - if (_desktops) { - g_error("FATAL: desktops still in list on application destruction!"); - } - - Inkscape::Preferences::unload(); - - if (_menus) { - Inkscape::GC::release(_menus); - _menus = nullptr; - } - - _S_inst = nullptr; // this will probably break things - - refCount = 0; - // gtk_main_quit (); + document->getRoot()->emitModified( SP_OBJECT_MODIFIED_CASCADE ); } /** Sets the keyboard modifier to map to Alt. diff --git a/src/inkscape.h b/src/inkscape.h index fe09098be..cd0568f35 100644 --- a/src/inkscape.h +++ b/src/inkscape.h @@ -139,6 +139,7 @@ public: void selection_changed (Inkscape::Selection * selection); void subselection_changed (SPDesktop *desktop); void selection_set (Inkscape::Selection * selection); + void readStyleSheets(); Glib::ustring get_symbolic_colors(); void get_higlight_colors(gchar *colornamedsuccess, gchar *colornamedwarning, gchar *colornamederror); void eventcontext_set (Inkscape::UI::Tools::ToolBase * eventcontext); diff --git a/src/io/file.cpp b/src/io/file.cpp index a87453d47..a23ef8fbc 100644 --- a/src/io/file.cpp +++ b/src/io/file.cpp @@ -65,6 +65,7 @@ ink_file_open(const Glib::ustring& data) SPRoot *root = doc->getRoot(); root->original.inkscape = root->version.inkscape; root->original.svg = root->version.svg; + INKSCAPE.readStyleSheets(); } return doc; @@ -115,6 +116,7 @@ ink_file_open(const Glib::RefPtr<Gio::File>& file, bool &cancelled) SPRoot *root = doc->getRoot(); root->original.inkscape = root->version.inkscape; root->original.svg = root->version.svg; + INKSCAPE.readStyleSheets(); } return doc; diff --git a/src/ui/dialog/selectorsdialog.cpp b/src/ui/dialog/selectorsdialog.cpp index 806ce61c2..dfa3f3aeb 100644 --- a/src/ui/dialog/selectorsdialog.cpp +++ b/src/ui/dialog/selectorsdialog.cpp @@ -526,25 +526,6 @@ Inkscape::XML::Node *SelectorsDialog::_getStyleTextNode() } /** - * Ditto for update stylesheets. - */ -void SelectorsDialog::_updateStyleSheets() -{ - SPDocument *document = SP_ACTIVE_DOCUMENT; - document->setStyleSheet(nullptr); - Inkscape::XML::Node *root = document->getReprRoot(); - for (unsigned i = 0; i < root->childCount(); --i) { - gchar const * name = root->nthChild(i)->name(); - if (name && strcmp(name,"svg:style") == 0) { - SPStyleElem *styleelem = dynamic_cast<SPStyleElem *>(document->getObjectByRepr(root->nthChild(i))); - styleelem->read_content(); - } - } - document->getRoot()->emitModified( SP_OBJECT_MODIFIED_CASCADE ); -} - - -/** * Fill the Gtk::TreeStore from the svg:style element. */ void SelectorsDialog::_readStyleElement() @@ -712,7 +693,7 @@ void SelectorsDialog::_writeStyleElement() // harm in keeping it around ... Inkscape::XML::Node *textNode = _getStyleTextNode(); textNode->setContent(styleContent.c_str()); - _updateStyleSheets(); + INKSCAPE.readStyleSheets(); DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_SELECTORS, _("Edited style element.")); _updating = false; diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp index d89114ca5..2b95d0fc3 100644 --- a/src/ui/dialog/styledialog.cpp +++ b/src/ui/dialog/styledialog.cpp @@ -308,23 +308,6 @@ Inkscape::XML::Node *StyleDialog::_getStyleTextNode() return textNode; } -/** - * Ditto for update stylesheets. - */ -void StyleDialog::_updateStyleSheets() -{ - SPDocument *document = SP_ACTIVE_DOCUMENT; - document->setStyleSheet(nullptr); - Inkscape::XML::Node *root = document->getReprRoot(); - for (unsigned i = 0; i < root->childCount(); --i) { - gchar const * name = root->nthChild(i)->name(); - if (name && strcmp(name,"svg:style") == 0) { - SPStyleElem *styleelem = dynamic_cast<SPStyleElem *>(document->getObjectByRepr(root->nthChild(i))); - styleelem->read_content(); - } - } - document->getRoot()->emitModified( SP_OBJECT_MODIFIED_CASCADE ); -} Glib::RefPtr<Gtk::TreeModel> StyleDialog::_selectTree(Glib::ustring selector) { @@ -1017,16 +1000,7 @@ void StyleDialog::_writeStyleElement(Glib::RefPtr<Gtk::TreeStore> store, Glib::u std::string result; std::regex_replace(std::back_inserter(result), content.begin(), content.end(), e, "$1" + styleContent + "$3"); textNode->setContent(result.c_str()); -<<<<<<< HEAD - INKSCAPE.readStyleSheets(true); - for (auto iter : document->getObjectsBySelector(selector)) { -======= _updateStyleSheets(); - /* for (auto iter : document->getObjectsBySelector(selector)) { ->>>>>>> Add initial commit - iter->style->readFromObject(iter); - iter->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); - } */ } _updating = false; _readStyleElement(); |
