summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJabiertxof <jabier.arraiza@marker.es>2019-06-19 11:03:46 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2019-07-08 21:04:12 +0000
commit08b64685a1a55a681ded366c680817b6d92646ea (patch)
tree92ba04750a866dcdb7f7e6549fd0bad5c6b5e1a6
parentFixing coding style (diff)
downloadinkscape-08b64685a1a55a681ded366c680817b6d92646ea.tar.gz
inkscape-08b64685a1a55a681ded366c680817b6d92646ea.zip
Add initial commit
-rw-r--r--share/icons/hicolor/symbolic/actions/dialog-align-and-distribute-symbolic.svg2
-rw-r--r--src/inkscape.cpp71
-rw-r--r--src/inkscape.h3
-rw-r--r--src/ui/dialog/inkscape-preferences.cpp26
-rw-r--r--src/ui/dialog/selectorsdialog.cpp51
-rw-r--r--src/ui/dialog/selectorsdialog.h1
-rw-r--r--src/ui/dialog/styledialog.cpp53
-rw-r--r--src/ui/dialog/styledialog.h1
-rw-r--r--src/ui/icon-loader.cpp2
-rw-r--r--src/ui/widget/color-picker.cpp5
10 files changed, 131 insertions, 84 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 5774f9731..fb33ebec6 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
@@ -3,7 +3,7 @@
<svg xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" version="1.1" id="svg1" width="16" height="16" viewBox="0 0 16 16" sodipodi:docname="dialog-align-and-distribute-symbolic.svg"><sodipodi:namedview objecttolerance="10" gridtolerance="10" guidetolerance="10" id="namedview" showgrid="true" inkscape:zoom="0.6002936" inkscape:cx="732.67439" inkscape:cy="-567.94603" inkscape:window-width="1920" inkscape:window-height="1016" inkscape:window-x="0" inkscape:window-y="27" inkscape:window-maximized="1" inkscape:current-layer="layer1">
<inkscape:grid type="xygrid" id="grid"/>
</sodipodi:namedview>
- <style id="style226">
+ <style id="style226">
.success { fill:#4AD589; }
.warning { fill:#F57900; }
.error { fill:#cc0000; }
diff --git a/src/inkscape.cpp b/src/inkscape.cpp
index 7593c0666..168218393 100644
--- a/src/inkscape.cpp
+++ b/src/inkscape.cpp
@@ -365,14 +365,55 @@ void Application::autosave_init()
}
}
-void Application::set_higlightcolors(gchar *colornamedsuccess, gchar *colornamedwarning, gchar *colornamederror);
+Glib::ustring Application::get_symbolic_colors()
{
+ Glib::ustring css_str;
+ gchar colornamed[64];
+ gchar colornamedsuccess[64];
+ gchar colornamedwarning[64];
+ gchar colornamederror[64];
+ gchar colornamed_inverse[64];
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ Glib::ustring themeiconname = prefs->getString("/theme/iconTheme");
+ int colorset = 0x2E3436ff;
+ get_higlight_colors(colornamedsuccess, colornamedwarning, colornamederror);
+ colorset = prefs->getInt("/theme/" + themeiconname + "/symbolicColor", colorset);
+ sp_svg_write_color(colornamed, sizeof(colornamed), colorset);
+ int colorset_inverse = colorset ^ 0xffffff00;
+ sp_svg_write_color(colornamed_inverse, sizeof(colornamed_inverse), colorset_inverse);
+ css_str += "*{-gtk-icon-palette: success ";
+ css_str += colornamedsuccess;
+ css_str += ", warning ";
+ css_str += colornamedwarning;
+ css_str += ", error ";
+ css_str += colornamederror;
+ css_str += ";}";
+ css_str += "SPRuler, ruler-widget,";
+ css_str += ".bright image, .dark image";
+ css_str += "{color:";
+ css_str += colornamed;
+ css_str += ";}";
+ css_str += ".dark .brightstyle image,";
+ css_str += ".bright .darkstyle image,";
+ css_str += ".invertstyle image";
+ css_str += "{color:";
+ css_str += colornamed_inverse;
+ css_str += ";}";
+ return css_str;
+}
+
+void Application::get_higlight_colors(gchar *colornamedsuccess, gchar *colornamedwarning, gchar *colornamederror)
+{
+ using namespace Inkscape::IO::Resource;
int colorsetsuccess = 0x4AD589ff;
int colorsetwarning = 0xF57900ff;
int colorseterror = 0xcc0000ff;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
Glib::ustring themeiconname = prefs->getString("/theme/iconTheme");
- Glib::ustring higlight = get_filename(ICONS, Glib::ustring(themeiconname + "/higlights.css").c_str(), false, false);
+ if (themeiconname == prefs->getString("/theme/defaultIconTheme")) {
+ themeiconname = "hicolor";
+ }
+ Glib::ustring higlight = get_filename(ICONS, Glib::ustring(themeiconname + "/highlights.css").c_str(), false, false);
if (!higlight.empty()) {
std::ifstream ifs(higlight);
std::string content((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()));
@@ -411,13 +452,15 @@ void Application::set_higlightcolors(gchar *colornamedsuccess, gchar *colornamed
colorseterror = error_color_sp.toRGBA32(1);
}
}
+ if (themeiconname == "hicolor") {
+ themeiconname = prefs->getString("/theme/defaultIconTheme");
+ }
colorsetsuccess = prefs->getInt("/theme/" + themeiconname + "/symbolicSuccessColor", colorsetsuccess);
sp_svg_write_color(colornamedsuccess, sizeof(colornamedsuccess), colorsetsuccess);
colorsetwarning = prefs->getInt("/theme/" + themeiconname + "/symbolicWarningColor", colorsetwarning);
sp_svg_write_color(colornamedwarning, sizeof(colornamedwarning), colorsetwarning);
colorseterror = prefs->getInt("/theme/" + themeiconname + "/symbolicErrorColor", colorseterror);
sp_svg_write_color(colornamederror, sizeof(colornamederror), colorseterror);
- // Use in case the special widgets have inverse theme background and symbolic
}
/**
@@ -477,27 +520,7 @@ Application::add_gtk_css()
Glib::ustring css_str = "";
if (prefs->getBool("/theme/symbolicIcons", false)) {
if (!prefs->getBool("/theme/symbolicIconsDefaultColor", true)) {
- gchar colornamed[64];
- gchar colornamed_inverse[64];
- Glib::ustring themeiconname = prefs->getString("/theme/iconTheme");
- set_higlightcolors(colornamedsuccess, colornamedwarning, colornamederror);
- int colorset = 0x2E3436ff;
- colorset = prefs->getInt("/theme/" + themeiconname + "/symbolicColor", colorset);
- sp_svg_write_color(colornamed, sizeof(colornamed), colorset);
- // Use in case the special widgets have inverse theme background and symbolic
- int colorset_inverse = colorset ^ 0xffffff00;
- sp_svg_write_color(colornamed_inverse, sizeof(colornamed_inverse), colorset_inverse);
- css_str += "#InkRuler, ";
- css_str += ".bright image, .dark image";
- css_str += "{color:";
- css_str += colornamed;
- css_str += ";}";
- css_str += ".dark .brightstyle image,";
- css_str += ".bright .darkstyle image,";
- css_str += ".invertstyle image";
- css_str += "{color:";
- css_str += colornamed_inverse;
- css_str += ";}";
+ css_str = get_symbolic_colors();
}
}
try {
diff --git a/src/inkscape.h b/src/inkscape.h
index 3e70c0fc3..fe09098be 100644
--- a/src/inkscape.h
+++ b/src/inkscape.h
@@ -139,7 +139,8 @@ public:
void selection_changed (Inkscape::Selection * selection);
void subselection_changed (SPDesktop *desktop);
void selection_set (Inkscape::Selection * selection);
- void set_higlightcolors(gchar *colornamedsuccess, gchar *colornamedwarning, gchar *colornamederror);
+ Glib::ustring get_symbolic_colors();
+ void get_higlight_colors(gchar *colornamedsuccess, gchar *colornamedwarning, gchar *colornamederror);
void eventcontext_set (Inkscape::UI::Tools::ToolBase * eventcontext);
// Moved document add/remove functions into public inkscape.h as they are used
diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp
index b02e60bbe..9b8e35384 100644
--- a/src/ui/dialog/inkscape-preferences.cpp
+++ b/src/ui/dialog/inkscape-preferences.cpp
@@ -703,27 +703,7 @@ void InkscapePreferences::symbolicCustomColors()
Gtk::CssProvider::create();
Glib::ustring css_str = "";
if (prefs->getBool("/theme/symbolicIcons", false)) {
- gchar colornamed[64];
- gchar colornamed_inverse[64];
- Glib::ustring themeiconname = prefs->getString("/theme/iconTheme");
- INKSCAPE.set_higlightcolors(colornamedsuccess, colornamedwarning, colornamederror);
- int colorset = 0x2E3436ff;
- colorset = prefs->getInt("/theme/" + themeiconname + "/symbolicColor", colorset);
- sp_svg_write_color(colornamed, sizeof(colornamed), colorset);
- // Use in case the special widgets have inverse theme background and symbolic
- int colorset_inverse = colorset ^ 0xffffff00;
- sp_svg_write_color(colornamed_inverse, sizeof(colornamed_inverse), colorset_inverse);
- css_str += "#InkRuler, ";
- css_str += ".bright image, .dark image";
- css_str += "{color:";
- css_str += colornamed;
- css_str += ";}";
- css_str += ".dark .brightstyle image,";
- css_str += ".bright .darkstyle image,";
- css_str += ".invertstyle image";
- css_str += "{color:";
- css_str += colornamed_inverse;
- css_str += ";}";
+ css_str = INKSCAPE.get_symbolic_colors();
if (window ) {
window->get_style_context()->add_class("symbolic");
window->get_style_context()->remove_class("regular");
@@ -1042,10 +1022,12 @@ void InkscapePreferences::initPageUI()
icon_buttons_hight->pack_start(_symbolic_error_color, true, true, 4);
_page_theme.add_line(false, _("Change icon highlights:"), *icon_buttons_hight, "",
_("HSet the predefined colors fro the creator of icon set"), false);
+ Gtk::Box *icon_buttons_def = Gtk::manage(new Gtk::Box());
Gtk::Button *theme_decide_color = Gtk::manage(new Gtk::Button(_("Theme defaults")));
theme_decide_color->set_tooltip_text(_("Defaul colors from theme)"));
theme_decide_color->signal_clicked().connect(sigc::mem_fun(*this, &InkscapePreferences::symbolicCustomColorsReset));
- _page_theme.add_line(false, _("Defaul colors:"), *icon_buttons_hight, "",
+ icon_buttons_def->pack_start(*theme_decide_color, true, true, 4);
+ _page_theme.add_line(false, _("Default colors:"), *icon_buttons_def, "",
_("Set the predefined colors fro the creator of icon set"), false);
symbolicChangeCustom();
{
diff --git a/src/ui/dialog/selectorsdialog.cpp b/src/ui/dialog/selectorsdialog.cpp
index 0857f1bef..806ce61c2 100644
--- a/src/ui/dialog/selectorsdialog.cpp
+++ b/src/ui/dialog/selectorsdialog.cpp
@@ -20,7 +20,8 @@
#include "selection.h"
#include "style.h"
#include "verbs.h"
-
+#include "object/sp-style-elem.h"
+#include "object/sp-root.h"
#include "ui/icon-loader.h"
#include "ui/widget/iconrenderer.h"
@@ -484,27 +485,22 @@ Inkscape::XML::Node *SelectorsDialog::_getStyleTextNode()
Inkscape::XML::Node *textNode = nullptr;
Inkscape::XML::Node *root = SP_ACTIVE_DOCUMENT->getReprRoot();
- bool first = false;
for (unsigned i = 0; i < root->childCount(); ++i) {
if (Glib::ustring(root->nthChild(i)->name()) == "svg:style") {
styleNode = root->nthChild(i);
- if (!first) {
- for (unsigned j = 0; j < styleNode->childCount(); ++j) {
- if (styleNode->nthChild(j)->type() == Inkscape::XML::TEXT_NODE) {
- textNode = styleNode->nthChild(j);
- }
- }
-
- if (textNode == nullptr) {
- // Style element found but does not contain text node!
- std::cerr << "StyleDialog::_getStyleTextNode(): No text node!" << std::endl;
- textNode = SP_ACTIVE_DOCUMENT->getReprDoc()->createTextNode("");
- styleNode->appendChild(textNode);
- Inkscape::GC::release(textNode);
+ for (unsigned j = 0; j < styleNode->childCount(); ++j) {
+ if (styleNode->nthChild(j)->type() == Inkscape::XML::TEXT_NODE) {
+ textNode = styleNode->nthChild(j);
}
- first = true;
}
- styleNode->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
+ if (textNode == nullptr) {
+ // Style element found but does not contain text node!
+ std::cerr << "StyleDialog::_getStyleTextNode(): No text node!" << std::endl;
+ textNode = SP_ACTIVE_DOCUMENT->getReprDoc()->createTextNode("");
+ styleNode->appendChild(textNode);
+ Inkscape::GC::release(textNode);
+ }
+ break;
}
}
@@ -530,6 +526,25 @@ 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()
@@ -697,7 +712,7 @@ void SelectorsDialog::_writeStyleElement()
// harm in keeping it around ...
Inkscape::XML::Node *textNode = _getStyleTextNode();
textNode->setContent(styleContent.c_str());
- INKSCAPE.readStyleSheets(true);
+ _updateStyleSheets();
DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_SELECTORS, _("Edited style element."));
_updating = false;
diff --git a/src/ui/dialog/selectorsdialog.h b/src/ui/dialog/selectorsdialog.h
index 6830a0124..c12772e5a 100644
--- a/src/ui/dialog/selectorsdialog.h
+++ b/src/ui/dialog/selectorsdialog.h
@@ -130,6 +130,7 @@ class SelectorsDialog : public Widget::Panel {
StyleDialog *_style_dialog;
// Reading and writing the style element.
Inkscape::XML::Node *_getStyleTextNode();
+ void _updateStyleSheets();
void _readStyleElement();
void _writeStyleElement();
diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp
index d867bce76..d89114ca5 100644
--- a/src/ui/dialog/styledialog.cpp
+++ b/src/ui/dialog/styledialog.cpp
@@ -23,6 +23,8 @@
#include "style-internal.h"
#include "style.h"
#include "svg/svg-color.h"
+#include "object/sp-style-elem.h"
+#include "object/sp-root.h"
#include "ui/icon-loader.h"
#include "ui/widget/iconrenderer.h"
#include "verbs.h"
@@ -266,27 +268,22 @@ Inkscape::XML::Node *StyleDialog::_getStyleTextNode()
Inkscape::XML::Node *textNode = nullptr;
Inkscape::XML::Node *root = SP_ACTIVE_DOCUMENT->getReprRoot();
- bool first = false;
for (unsigned i = 0; i < root->childCount(); ++i) {
if (Glib::ustring(root->nthChild(i)->name()) == "svg:style") {
styleNode = root->nthChild(i);
- if (!first) {
- for (unsigned j = 0; j < styleNode->childCount(); ++j) {
- if (styleNode->nthChild(j)->type() == Inkscape::XML::TEXT_NODE) {
- textNode = styleNode->nthChild(j);
- }
- }
-
- if (textNode == nullptr) {
- // Style element found but does not contain text node!
- std::cerr << "StyleDialog::_getStyleTextNode(): No text node!" << std::endl;
- textNode = SP_ACTIVE_DOCUMENT->getReprDoc()->createTextNode("");
- styleNode->appendChild(textNode);
- Inkscape::GC::release(textNode);
+ for (unsigned j = 0; j < styleNode->childCount(); ++j) {
+ if (styleNode->nthChild(j)->type() == Inkscape::XML::TEXT_NODE) {
+ textNode = styleNode->nthChild(j);
}
- first = true;
}
- styleNode->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
+ if (textNode == nullptr) {
+ // Style element found but does not contain text node!
+ std::cerr << "StyleDialog::_getStyleTextNode(): No text node!" << std::endl;
+ textNode = SP_ACTIVE_DOCUMENT->getReprDoc()->createTextNode("");
+ styleNode->appendChild(textNode);
+ Inkscape::GC::release(textNode);
+ }
+ break;
}
}
@@ -311,6 +308,23 @@ 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)
{
@@ -1003,11 +1017,16 @@ 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();
diff --git a/src/ui/dialog/styledialog.h b/src/ui/dialog/styledialog.h
index 90b9d298f..22d85620c 100644
--- a/src/ui/dialog/styledialog.h
+++ b/src/ui/dialog/styledialog.h
@@ -123,6 +123,7 @@ class StyleDialog : public Widget::Panel {
// Reading and writing the style element.
Inkscape::XML::Node *_getStyleTextNode();
+ void _updateStyleSheets();
void _readStyleElement();
Glib::RefPtr<Gtk::TreeModel> _selectTree(Glib::ustring selector);
void _writeStyleElement(Glib::RefPtr<Gtk::TreeStore> store, Glib::ustring selector);
diff --git a/src/ui/icon-loader.cpp b/src/ui/icon-loader.cpp
index e4168ceeb..337a53aa4 100644
--- a/src/ui/icon-loader.cpp
+++ b/src/ui/icon-loader.cpp
@@ -74,7 +74,7 @@ Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, gint size)
gchar colornamedwarning[64];
gchar colornamederror[64];
Glib::ustring themeiconname = prefs->getString("/theme/iconTheme");
- INKSCAPE.set_higlightcolors(colornamedsuccess, colornamedwarning, colornamederror);
+ INKSCAPE.get_higlight_colors(colornamedsuccess, colornamedwarning, colornamederror);
int colorset = 0x2E3436ff;
colorset = prefs->getInt("/theme/" + themeiconname + "/symbolicColor", colorset);
sp_svg_write_color(colornamed, sizeof(colornamed), colorset);
diff --git a/src/ui/widget/color-picker.cpp b/src/ui/widget/color-picker.cpp
index b3b6db451..0e9984eac 100644
--- a/src/ui/widget/color-picker.cpp
+++ b/src/ui/widget/color-picker.cpp
@@ -66,6 +66,7 @@ void ColorPicker::setupDialog(const Glib::ustring &title)
_colorSelectorDialog.get_content_area()->pack_start (
*_color_selector, true, true, 0);
_color_selector->show();
+
}
void ColorPicker::setTransientFor(Glib::RefPtr<Gdk::Window> transientwindow) { _transientwindow = transientwindow; }
@@ -100,6 +101,10 @@ void ColorPicker::on_clicked()
_updating = false;
}
_colorSelectorDialog.show();
+ Glib::RefPtr<Gdk::Window> window = get_parent_window();
+ if (window) {
+ window->focus(1);
+ }
}
void ColorPicker::on_changed (guint32)