diff options
| author | Jabiertxof <jabier.arraiza@marker.es> | 2019-06-18 02:19:27 +0000 |
|---|---|---|
| committer | Jabiertxof <jabier.arraiza@marker.es> | 2019-06-18 02:19:27 +0000 |
| commit | caa1eca947b1ff97ab96ae30a967aaccd0d23e63 (patch) | |
| tree | e9c2c6166af7de73f0497f25a8afed26a962bd1b | |
| parent | Fix compiling issues (diff) | |
| download | inkscape-caa1eca947b1ff97ab96ae30a967aaccd0d23e63.tar.gz inkscape-caa1eca947b1ff97ab96ae30a967aaccd0d23e63.zip | |
Improving styling
| -rw-r--r-- | share/icons/nextgen/symbolic/actions/dialog-align-and-distribute-symbolic.svg | 18 | ||||
| -rw-r--r-- | share/ui/style.css | 42 | ||||
| -rw-r--r-- | src/inkscape.cpp | 20 | ||||
| -rw-r--r-- | src/inkscape.h | 14 | ||||
| -rw-r--r-- | src/ui/dialog/inkscape-preferences.cpp | 11 | ||||
| -rw-r--r-- | src/ui/icon-loader.cpp | 24 |
6 files changed, 88 insertions, 41 deletions
diff --git a/share/icons/nextgen/symbolic/actions/dialog-align-and-distribute-symbolic.svg b/share/icons/nextgen/symbolic/actions/dialog-align-and-distribute-symbolic.svg new file mode 100644 index 000000000..efba1a044 --- /dev/null +++ b/share/icons/nextgen/symbolic/actions/dialog-align-and-distribute-symbolic.svg @@ -0,0 +1,18 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- Created with Inkscape (http://www.inkscape.org/) and export_objects.py --> +<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"> + .success { fill:#4AD589; } + .warning { fill:#F57900; } + . { fill:#cc0000; } + </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"/> + <path inkscape:connector-curvature="0" id="rect18739" class="success" d="m 139,808.36218 h 7 v 3 h -7 z" style="opacity:1"/> + <path inkscape:connector-curvature="0" id="rect18741" class="warning" d="m 139,813.36218 h 10 v 3 h -10 z" style="opacity:1"/> + <path inkscape:connector-curvature="0" id="rect18743" class="error" d="m 139,-821.36218 h 6 v 3 h -6 z" style="opacity:1" transform="scale(1,-1)"/> + </g> + </svg> diff --git a/share/ui/style.css b/share/ui/style.css index fac3e18a6..6bd0d6307 100644 --- a/share/ui/style.css +++ b/share/ui/style.css @@ -56,26 +56,26 @@ /* Inkscape CSS helper - * to add a class to a widget do some thing like - * widget->get_style_context()->add_class("mycoolclass"); - * we define a bunch of helper CSS styles - * Each Inkscape desktop has some classes in top level window - * called "dark|bright" and "symbolic|regular" so you can style using this clases - * by this way you can always know if the UI is in dark mode - * Also added some helper clases: - * ::::::: Color based - * ::::::: apply to colors - * ::::::: scope widget and all his childs - * ".invertstyle" invert window colors - * ".brightstyle" force bright colors no matter the UI is dark or bright - * ".darkstyle" same but dark - * ".defaultstyle" use default window color for child wigets inside a modified one - * :::::::: Icon Based. - * ".symbolic" Force icon symbolic - * ".regular" Force colorful icons - * :::::::: Combo box. - * "..combobright" Combo bright - */ + * to add a class to a widget do some thing like + * widget->get_style_context()->add_class("mycoolclass"); + * we define a bunch of helper CSS styles + * Each Inkscape desktop has some classes in top level window + * called "dark|bright" and "symbolic|regular" so you can style using this clases + * by this way you can always know if the UI is in dark mode + * Also added some helper clases: + * ::::::: Color based + * ::::::: apply to colors + * ::::::: scope widget and all his childs + * ".invertstyle" invert window colors + * ".brightstyle" force bright colors no matter the UI is dark or bright + * ".darkstyle" same but dark + * ".defaultstyle" use default window color for child wigets inside a modified one + * :::::::: Icon Based. + * ".symbolic" Force icon symbolic + * ".regular" Force colorful icons + * :::::::: Combo box. + * "..combobright" Combo bright + */ image { -gtk-icon-palette: default; @@ -89,6 +89,8 @@ image { -gtk-icon-style: regular; } +.bright *, +.dark *, .bright .brightstyle, .bright .brightstyle *, .dark .darkstyle, diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 11e446ca9..23179ee12 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -383,12 +383,12 @@ Application::add_gtk_css() prefs->getBool("/theme/darkTheme", gtkApplicationPreferDarkTheme), NULL); prefs->setString("/theme/defaultTheme", Glib::ustring(gtkThemeName)); prefs->setString("/theme/defaultIconTheme", Glib::ustring(gtkIconThemeName)); - if (prefs->getString("/theme/gtkTheme") != "") { - g_object_set(settings, "gtk-theme-name", prefs->getString("/theme/gtkTheme").c_str(), NULL); + Glib::ustring gtkthemename = prefs->getString("/theme/gtkTheme"); + if (gtkthemename != "") { + g_object_set(settings, "gtk-theme-name", gtkthemename.c_str(), NULL); } else { prefs->setString("/theme/gtkTheme", Glib::ustring(gtkThemeName)); } - Glib::ustring themeiconname = prefs->getString("/theme/iconTheme"); if (themeiconname != "") { g_object_set(settings, "gtk-icon-theme-name", themeiconname.c_str(), NULL); @@ -397,7 +397,7 @@ Application::add_gtk_css() } g_object_get(settings, "gtk-font-name", >k_font_name, NULL); } - + auto provider = Gtk::CssProvider::create(); Glib::ustring style = get_filename(UIS, "style.css"); if (!style.empty()) { @@ -410,7 +410,9 @@ Application::add_gtk_css() } Gtk::StyleContext::add_provider_for_screen (screen, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); } - colorizeprovider = Gtk::CssProvider::create(); + if (!colorizeprovider) { + colorizeprovider = Gtk::CssProvider::create(); + } Glib::ustring css_str = ""; if (prefs->getBool("/theme/symbolicIcons", false)) { if (!prefs->getBool("/theme/symbolicIconsDefaultColor", true)) { @@ -430,7 +432,7 @@ Application::add_gtk_css() // 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 += "*{-gtk-icon-palette: success "; css_str += colornamedsuccess; css_str += ", warning "; @@ -458,6 +460,7 @@ Application::add_gtk_css() } Gtk::StyleContext::add_provider_for_screen(screen, colorizeprovider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); if (!strncmp(gtk_font_name, "Cantarell", 9)) { + provider = Gtk::CssProvider::create(); css_str = "#monoStrokeWidth,"; css_str += "#fillEmptySpace,"; css_str += "#SelectStatus,"; @@ -469,10 +472,11 @@ Application::add_gtk_css() try { provider->load_from_data(css_str); } catch (const Gtk::CssProviderError &ex) { - g_critical("CSSProviderError::load_from_data(): failed to load '%s'\n(%s)", css_str.c_str(), ex.what().c_str()); + g_critical("CSSProviderError::load_from_data(): failed to load '%s'\n(%s)", css_str.c_str(), + ex.what().c_str()); } Gtk::StyleContext::add_provider_for_screen(screen, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); - } + } } /* \brief Constructor for the application. diff --git a/src/inkscape.h b/src/inkscape.h index 86649e0cb..815da0f1d 100644 --- a/src/inkscape.h +++ b/src/inkscape.h @@ -14,14 +14,14 @@ * Released under GNU GPL v2+, read the file 'COPYING' for more information. */ -#include <map> -#include <vector> -#include <glib.h> -#include <glib-object.h> -#include <sigc++/signal.h> #include "layer-model.h" -#include <gtkmm/cssprovider.h> #include "selection.h" +#include <glib-object.h> +#include <glib.h> +#include <gtkmm/cssprovider.h> +#include <map> +#include <sigc++/signal.h> +#include <vector> class SPDesktop; class SPDocument; @@ -109,7 +109,7 @@ public: Inkscape::UI::Tools::ToolBase * active_event_context(); SPDocument * active_document(); SPDesktop * active_desktop(); - Glib::RefPtr< Gtk::CssProvider > colorizeprovider; + Glib::RefPtr<Gtk::CssProvider> colorizeprovider; // Use this function to get selection model etc for a document Inkscape::ActionContext action_context_for_document(SPDocument *doc); Inkscape::ActionContext active_action_context(); diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index f3bba55c3..6151eeef0 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -630,7 +630,9 @@ void InkscapePreferences::symbolicThemeCheck() void InkscapePreferences::symbolicDefaultColor(){ auto const screen = Gdk::Screen::get_default(); - Gtk::StyleContext::remove_provider_for_screen(screen, INKSCAPE.colorizeprovider); + if (INKSCAPE.colorizeprovider) { + Gtk::StyleContext::remove_provider_for_screen(screen, INKSCAPE.colorizeprovider); + } Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setBool("/theme/symbolicIconsDefaultColor", true); } @@ -638,7 +640,9 @@ void InkscapePreferences::symbolicDefaultColor(){ void InkscapePreferences::symbolicStyling() { auto const screen = Gdk::Screen::get_default(); - Gtk::StyleContext::remove_provider_for_screen(screen, INKSCAPE.colorizeprovider); + if (INKSCAPE.colorizeprovider) { + Gtk::StyleContext::remove_provider_for_screen(screen, INKSCAPE.colorizeprovider); + } using namespace Inkscape::IO::Resource; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setBool("/theme/symbolicIconsDefaultColor", false); @@ -695,7 +699,8 @@ void InkscapePreferences::symbolicStyling() } catch (const Gtk::CssProviderError &ex) { g_critical("CSSProviderError::load_from_data(): failed to load '%s'\n(%s)", css_str.c_str(), ex.what().c_str()); } - Gtk::StyleContext::add_provider_for_screen(screen, INKSCAPE.colorizeprovider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + Gtk::StyleContext::add_provider_for_screen(screen, INKSCAPE.colorizeprovider, + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); } void InkscapePreferences::themeChange() diff --git a/src/ui/icon-loader.cpp b/src/ui/icon-loader.cpp index f69d3148d..6853d7e68 100644 --- a/src/ui/icon-loader.cpp +++ b/src/ui/icon-loader.cpp @@ -13,6 +13,7 @@ #include "icon-loader.h" #include "inkscape.h" +#include "svg/svg-color.h" #include "widgets/toolbox.h" #include <gtkmm/iconinfo.h> #include <gdkmm/display.h> @@ -64,9 +65,26 @@ Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, gint size) Gtk::IconInfo iconinfo = icon_theme->lookup_icon(icon_name + Glib::ustring("-symbolic"), size, Gtk::ICON_LOOKUP_FORCE_SIZE); if (iconinfo && SP_ACTIVE_DESKTOP->getToplevel()) { bool was_symbolic = false; - Glib::RefPtr< Gtk::StyleContext > stylecontext = SP_ACTIVE_DESKTOP->getToplevel()->get_style_context(); - stylecontext->add_provider(INKSCAPE.colorizeprovider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); - _icon_pixbuf = iconinfo.load_symbolic(stylecontext, was_symbolic); + Glib::ustring css_str = ""; + if (!prefs->getBool("/theme/symbolicIconsDefaultColor", true)) { + gchar colornamed[64]; + gchar colornamedsuccess[64]; + gchar colornamedwarning[64]; + gchar colornamederror[64]; + gchar colornamed_inverse[64]; + int colorset = prefs->getInt("/theme/symbolicColor", 0x2E3436ff); + sp_svg_write_color(colornamed, sizeof(colornamed), colorset); + int colorsetsuccess = prefs->getInt("/theme/symbolicSuccessColor", 0x4AD589ff); + sp_svg_write_color(colornamedsuccess, sizeof(colornamedsuccess), colorsetsuccess); + int colorsetwarning = prefs->getInt("/theme/symbolicWarningColor", 0xF57900ff); + sp_svg_write_color(colornamedwarning, sizeof(colornamedwarning), colorsetwarning); + int colorseterror = prefs->getInt("/theme/symbolicErrorColor", 0xcc0000ff); + sp_svg_write_color(colornamederror, sizeof(colornamederror), colorseterror); + _icon_pixbuf = iconinfo.load_symbolic(Gdk::RGBA(colornamed), Gdk::RGBA(colornamedsuccess), Gdk::RGBA(colornamedwarning), Gdk::RGBA(colornamederror), was_symbolic); + } else { + Glib::RefPtr<Gtk::StyleContext> stylecontext = SP_ACTIVE_DESKTOP->getToplevel()->get_style_context(); + _icon_pixbuf = iconinfo.load_symbolic(stylecontext, was_symbolic); + } } else { Gtk::IconInfo iconinfo = icon_theme->lookup_icon(icon_name, size, Gtk::ICON_LOOKUP_FORCE_SIZE); _icon_pixbuf = iconinfo.load_icon(); |
