From e0471fb385a7250815528d23f0c2ecbbca675d42 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 26 Jan 2019 06:16:02 +0100 Subject: Adding styling refactoring, moving after to other branch the CSS part --- NEWS.md | 6 +- .../hicolor/scalable/actions/draw-star-ouline.svg | 133 +++++++ .../actions/draw-star-outline-symbolic.svg | 67 ++++ share/ui/commands-toolbar.ui | 38 -- share/ui/dialog-filter-editor.ui | 381 +++++++++++++++++++++ share/ui/dialog-livepatheffect-add-effect.ui | 118 +++++++ share/ui/dialog-livepatheffect-add.ui | 140 ++++++++ share/ui/filter-editor.glade | 381 --------------------- share/ui/lpe-selector-item.ui | 118 ------- share/ui/lpe-selector.ui | 88 ----- share/ui/select-toolbar.ui | 335 ------------------ share/ui/snap-toolbar.ui | 28 -- share/ui/style.css | 146 ++++++-- share/ui/tool-toolbar.ui | 39 --- share/ui/toolbar-commands.ui | 38 ++ share/ui/toolbar-select.ui | 335 ++++++++++++++++++ share/ui/toolbar-snap.ui | 28 ++ share/ui/toolbar-tool.ui | 39 +++ src/inkscape.cpp | 72 ++-- src/ui/dialog/filter-editor.cpp | 2 +- src/ui/dialog/inkscape-preferences.cpp | 74 +++- src/ui/dialog/livepatheffect-add.cpp | 41 +-- src/ui/dialog/livepatheffect-add.h | 3 +- src/ui/dialog/symbols.cpp | 5 +- src/ui/widget/dash-selector.cpp | 2 +- src/widgets/desktop-widget.cpp | 23 +- src/widgets/stroke-marker-selector.cpp | 2 +- src/widgets/toolbox.cpp | 10 +- 28 files changed, 1564 insertions(+), 1128 deletions(-) create mode 100644 share/icons/hicolor/scalable/actions/draw-star-ouline.svg create mode 100644 share/icons/hicolor/symbolic/actions/draw-star-outline-symbolic.svg delete mode 100644 share/ui/commands-toolbar.ui create mode 100644 share/ui/dialog-filter-editor.ui create mode 100644 share/ui/dialog-livepatheffect-add-effect.ui create mode 100644 share/ui/dialog-livepatheffect-add.ui delete mode 100644 share/ui/filter-editor.glade delete mode 100644 share/ui/lpe-selector-item.ui delete mode 100644 share/ui/lpe-selector.ui delete mode 100644 share/ui/select-toolbar.ui delete mode 100644 share/ui/snap-toolbar.ui delete mode 100644 share/ui/tool-toolbar.ui create mode 100644 share/ui/toolbar-commands.ui create mode 100644 share/ui/toolbar-select.ui create mode 100644 share/ui/toolbar-snap.ui create mode 100644 share/ui/toolbar-tool.ui diff --git a/NEWS.md b/NEWS.md index a52a4cbfb..4906290f7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -676,9 +676,9 @@ User interface customization reconfigured by users. Only one is currently supported (filter editor). • The contents of the menus can be configured by customizing the menus.xml file. - • Toolbar contents for the command bar (commands-toolbar.ui), the snap bar - (snap-toolbar.ui), the tool controls bars for each tool - (select-toolbar.ui), the toolbox (tool-toolbar.ui) is now configurable. + • Toolbar contents for the command bar (toolbar-commands.ui), the snap bar + (toolbar-snap.ui), the tool controls bars for each tool + (toolbar-select.ui), the toolbox (tool-toolbar.ui) is now configurable. • The file keybindings.rc allows you to... (TODO: do what? What does it do in comparison to keys.xml? Seems to not work at all... seems to be ancient. Can be deleted?) diff --git a/share/icons/hicolor/scalable/actions/draw-star-ouline.svg b/share/icons/hicolor/scalable/actions/draw-star-ouline.svg new file mode 100644 index 000000000..f348a88c6 --- /dev/null +++ b/share/icons/hicolor/scalable/actions/draw-star-ouline.svg @@ -0,0 +1,133 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/share/icons/hicolor/symbolic/actions/draw-star-outline-symbolic.svg b/share/icons/hicolor/symbolic/actions/draw-star-outline-symbolic.svg new file mode 100644 index 000000000..5aa4591a1 --- /dev/null +++ b/share/icons/hicolor/symbolic/actions/draw-star-outline-symbolic.svg @@ -0,0 +1,67 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/share/ui/commands-toolbar.ui b/share/ui/commands-toolbar.ui deleted file mode 100644 index c2b1ed965..000000000 --- a/share/ui/commands-toolbar.ui +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/share/ui/dialog-filter-editor.ui b/share/ui/dialog-filter-editor.ui new file mode 100644 index 000000000..908e0d7e3 --- /dev/null +++ b/share/ui/dialog-filter-editor.ui @@ -0,0 +1,381 @@ + + + + + + + + + + + + + + + + + + test1 + a + False + + + + test2 + b + False + + + + test3 + c + False + + + + + + False + + + + + + + + + + + + whatever + + + second choice + + + + + True + False + vertical + + + True + False + + + True + False + + filter1 + filter2 + + + + True + True + 0 + + + + + True + False + FER: + + + False + True + 1 + + + + + True + False + X: + + + False + True + 2 + + + + + True + True + number + vertical + -0.10000000000000001 + + + False + True + 3 + + + + + True + False + Y: + + + False + True + 4 + + + + + True + True + vertical + + + False + True + 5 + + + + + True + False + W: + + + False + True + 6 + + + + + True + True + vertical + + + False + True + 7 + + + + + True + False + H: + + + False + True + 8 + + + + + True + True + vertical + + + False + True + 9 + + + + + False + True + 0 + + + + + True + True + + + True + False + vertical + + + True + True + FilterStore + False + True + True + True + True + + + + + + fixed + Effect + + + + 0 + + + + + + + fixed + Name + + + + 1 + + + + + + + fixed + Origin(s) + True + + + FilterStore1 + 0 + + + + + + + True + True + 0 + + + + + True + False + + + True + False + + + True + True + 0 + + + + + Add + True + True + True + + + False + True + 1 + + + + + False + False + end + 1 + + + + + True + True + + + + + True + False + vertical + + + True + False + + + True + True + 0 + + + + + + + + True + False + + + True + False + gtk-dialog-info + 6 + + + False + False + 0 + + + + + True + False + This effect does this and that. + + + True + True + 1 + + + + + True + True + 2 + + + + + True + True + + + + + True + True + 1 + + + + + True + False + FilterStore1 + 0 + 0 + + diff --git a/share/ui/dialog-livepatheffect-add-effect.ui b/share/ui/dialog-livepatheffect-add-effect.ui new file mode 100644 index 000000000..b423a32f4 --- /dev/null +++ b/share/ui/dialog-livepatheffect-add-effect.ui @@ -0,0 +1,118 @@ + + + + + + 200 + True + True + False + center + False + vertical + top + + + True + False + center + start + 80 + align-vertical-baseline + 6 + + + False + False + 0 + + + + + True + False + LPEName + center + + + + False + False + 1 + + + + + 200 + True + False + Description + center + True + 20 + + + False + False + 10 + 2 + + + + + True + False + end + start + + + False + end + 30 + draw-star-outline + 2 + + + + False + False + end + 1 + True + + + + + False + 30 + on + 2 + + + + False + False + end + 2 + True + + + + + False + False + end + 3 + + + + + diff --git a/share/ui/dialog-livepatheffect-add.ui b/share/ui/dialog-livepatheffect-add.ui new file mode 100644 index 000000000..3bee689a5 --- /dev/null +++ b/share/ui/dialog-livepatheffect-add.ui @@ -0,0 +1,140 @@ + + + + + + LPEDialogSelector + 500 + True + False + Live Path Effect Selector + True + center-on-parent + True + dialog + center + + + + + + False + vertical + 2 + + + False + end + + + + + + + + + False + False + 0 + + + + + True + False + start + vertical + top + + + True + False + True + + + 400 + True + True + edit-find-symbolic + False + False + + + + + + + True + True + 0 + + + + + True + False + Message + center + end + + + + False + True + 1 + + + + + True + True + never + in + 800 + 10 + True + + + True + False + + + lpeflow + True + False + True + 10 + 10 + 3 + + + + + + + False + False + 2 + + + + + False + True + 1 + + + + + + + diff --git a/share/ui/filter-editor.glade b/share/ui/filter-editor.glade deleted file mode 100644 index 908e0d7e3..000000000 --- a/share/ui/filter-editor.glade +++ /dev/null @@ -1,381 +0,0 @@ - - - - - - - - - - - - - - - - - - test1 - a - False - - - - test2 - b - False - - - - test3 - c - False - - - - - - False - - - - - - - - - - - - whatever - - - second choice - - - - - True - False - vertical - - - True - False - - - True - False - - filter1 - filter2 - - - - True - True - 0 - - - - - True - False - FER: - - - False - True - 1 - - - - - True - False - X: - - - False - True - 2 - - - - - True - True - number - vertical - -0.10000000000000001 - - - False - True - 3 - - - - - True - False - Y: - - - False - True - 4 - - - - - True - True - vertical - - - False - True - 5 - - - - - True - False - W: - - - False - True - 6 - - - - - True - True - vertical - - - False - True - 7 - - - - - True - False - H: - - - False - True - 8 - - - - - True - True - vertical - - - False - True - 9 - - - - - False - True - 0 - - - - - True - True - - - True - False - vertical - - - True - True - FilterStore - False - True - True - True - True - - - - - - fixed - Effect - - - - 0 - - - - - - - fixed - Name - - - - 1 - - - - - - - fixed - Origin(s) - True - - - FilterStore1 - 0 - - - - - - - True - True - 0 - - - - - True - False - - - True - False - - - True - True - 0 - - - - - Add - True - True - True - - - False - True - 1 - - - - - False - False - end - 1 - - - - - True - True - - - - - True - False - vertical - - - True - False - - - True - True - 0 - - - - - - - - True - False - - - True - False - gtk-dialog-info - 6 - - - False - False - 0 - - - - - True - False - This effect does this and that. - - - True - True - 1 - - - - - True - True - 2 - - - - - True - True - - - - - True - True - 1 - - - - - True - False - FilterStore1 - 0 - 0 - - diff --git a/share/ui/lpe-selector-item.ui b/share/ui/lpe-selector-item.ui deleted file mode 100644 index 98e35fa92..000000000 --- a/share/ui/lpe-selector-item.ui +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - 200 - True - True - False - center - False - vertical - top - - - True - False - center - start - 80 - align-vertical-baseline - 6 - - - False - False - 0 - - - - - True - False - LPEName - center - - - - False - False - 1 - - - - - 200 - True - False - Description - center - True - 20 - - - False - False - 10 - 2 - - - - - True - False - end - start - - - False - end - 30 - draw-star - 2 - - - - False - False - end - 1 - True - - - - - False - 30 - on - 2 - - - - False - False - end - 2 - True - - - - - False - False - end - 3 - - - - - diff --git a/share/ui/lpe-selector.ui b/share/ui/lpe-selector.ui deleted file mode 100644 index 1c88c9e93..000000000 --- a/share/ui/lpe-selector.ui +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - True - False - start - vertical - top - - - True - False - True - True - - - 400 - True - True - edit-find-symbolic - False - False - - - - - - True - True - 0 - - - - - True - False - Message - center - end - - - - False - True - 1 - - - - - True - True - never - in - 800 - 10 - True - - - True - False - - - lpeflow - True - False - True - 10 - 10 - 3 - - - - - - - False - False - 2 - - - - diff --git a/share/ui/select-toolbar.ui b/share/ui/select-toolbar.ui deleted file mode 100644 index 1c8c1efc3..000000000 --- a/share/ui/select-toolbar.ui +++ /dev/null @@ -1,335 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/share/ui/snap-toolbar.ui b/share/ui/snap-toolbar.ui deleted file mode 100644 index 90fa6bd61..000000000 --- a/share/ui/snap-toolbar.ui +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/share/ui/style.css b/share/ui/style.css index 6598d5e69..8063477bf 100644 --- a/share/ui/style.css +++ b/share/ui/style.css @@ -26,7 +26,6 @@ * */ - /* Our own custom shades... better not to use. * Lightest to darkest based on linear rgb. */ @@ -41,6 +40,121 @@ @define-color bg_color7 #636363; @define-color bg_color8 #000000; /* Black */ + /* 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 + * Ecah Inkscape desktop has a class in top level window + * call "dark" so you can style using 2 clases with or without + * "dark" 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 + * ".colordefault" use default window color + * ".colorinverse" invert window colors + * ".colorbright" force bright colors no matter the UI is dark or bright + * ".colordark" same but dark + * ::::::: Background based + * ::::::: apply to backgrounds + * ::::::: scope widget and all his childs + * ".backgrounddefault" use default window color + * ".backgroundinverse" invert window colors + * ".backgroundbright" force bright colors no matter the UI is dark or bright + * ".backgrounddark" same but dark + * :::::::: Icon Based. + * :::::::: apply to color (foreground) + * :::::::: scope widget and all nested images + * ".iconsymbolic" Force icon symbolic + * ".iconregular" Force colorfull icons + * ".iconcolordefault" Theme color default + * ".iconcolorinverse" Inverse color from theme + * ".iconcolorbright, Force clear icon + * ".iconcolordark" Force dark icon + * ".iconcolornamed" Icon in prefs selected color; + * ".iconcolornamedinverse" Icon in inverse color from prefs" + * :::::::: Combo box. + * "..combobright" Combo bright + */ + +.colordefault, +.colordefault *{ + color: @theme_fg_color; +} + +.colorinverse, +.colorinverse *{ + color: @theme_bg_color; +} +.colorbright, +.colorbright *{ + color: @theme_fg_color; +} +.dark .colorbright, +.dark .colorbright *{ + color: @theme_bg_color; +} +.colordark, +.colordark *{ + color: @theme_bg_color; +} +.dark .colordark, +.dark .colordark *{ + color: @theme_fg_color; +} +.backgrounddefault, +.backgrounddefault *{ + background-color: @theme_bg_color; + background-image:image(@theme_bg_color); +} +.backgroundinverse, +.backgroundinverse *{ + background-color: @theme_fg_color; + background-image:image(@theme_fg_color); +} +.backgroundbright, +.backgroundbright *{ + background-color: @theme_bg_color; + background-image:image(@theme_bg_color); +} +.dark .backgroundbright, +.dark .backgroundbright *{ + background-color: @theme_fg_color; + background-image:image(@theme_fg_color); +} +.backgrounddark, +.backgrounddark *{ + background-color: @theme_fg_color; + background-image:image(@theme_fg_color); +} +.dark .backgrounddark, +.dark .backgrounddark *{ + background-color: @theme_bg_color; + background-image:image(@theme_bg_color); +} +.iconsymbolic, +.iconsymbolic image{ + -gtk-icon-style: symbolic; +} +.iconregular, +.iconregular image{ + -gtk-icon-style: regular; +} + +.combobright *{ + color: @theme_fg_color; + background-color: @theme_bg_color; + background-image:image(@theme_bg_color); + border-radius:4px; +} +.dark .combobright *{ + color: @theme_bg_color; + background-color: @theme_fg_color; + background-image:image(@theme_fg_color); + border-radius:4px; +} + + /* 'GtkWidget' for Gtk <= 3.18 */ /* 'widget' for Gtk <= 3.19.2 */ GtkWidget, widget { @@ -78,10 +192,10 @@ spinbutton undershoot { .lpeinfo{ font-size:16px; padding:20px; - } - #lpedialogselector, - #lpedialogselector .frame, - #lpedialogselector .searchbar { +} +#lpedialogselector, +#lpedialogselector .frame, +#lpedialogselector .searchbar { border-bottom-width:0; border-top-width:0; outline-width:0; @@ -96,22 +210,18 @@ spinbutton undershoot { margin:10px; margin-bottom:30px; padding-bottom:10px; - background-color:@theme_bg_color; - color:@theme_fg_color; } #lpeflow GtkFlowBoxChild.lpeactive, #lpeflow flowboxchild.lpeactive{ - background-color:@theme_fg_color; - color:@theme_bg_color; margin-bottom:0px; padding-bottom:10px; outline:none; } -#lpeflow GtkFlowBoxChild.lpeactive *, -#lpeflow flowboxchild.lpeactive *{ - color:inherit; + +#LPEDialogSelector .frame{ + border-width:0; } SPRuler { @@ -217,15 +327,3 @@ combobox window.popup scrolledwindow treeview separator { padding : 0 ; outline-style : none; } - - - -#symbolsView, -#markerCombo button, -#markerCombo menu, -#dashCombo button, -#dashCombo menu{ - background-image:image(rgb(230,230,230)); - color:rgb(0,0,0); -} - diff --git a/share/ui/tool-toolbar.ui b/share/ui/tool-toolbar.ui deleted file mode 100644 index a5dedad56..000000000 --- a/share/ui/tool-toolbar.ui +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/share/ui/toolbar-commands.ui b/share/ui/toolbar-commands.ui new file mode 100644 index 000000000..c2b1ed965 --- /dev/null +++ b/share/ui/toolbar-commands.ui @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/share/ui/toolbar-select.ui b/share/ui/toolbar-select.ui new file mode 100644 index 000000000..1c8c1efc3 --- /dev/null +++ b/share/ui/toolbar-select.ui @@ -0,0 +1,335 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/share/ui/toolbar-snap.ui b/share/ui/toolbar-snap.ui new file mode 100644 index 000000000..90fa6bd61 --- /dev/null +++ b/share/ui/toolbar-snap.ui @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/share/ui/toolbar-tool.ui b/share/ui/toolbar-tool.ui new file mode 100644 index 000000000..a5dedad56 --- /dev/null +++ b/share/ui/toolbar-tool.ui @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 1418f5c3b..baefd6b9f 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -378,7 +378,15 @@ Application::add_gtk_css() Inkscape::Preferences *prefs = Inkscape::Preferences::get(); auto provider = Gtk::CssProvider::create(); Glib::ustring css_str = ""; + gchar colornamed[64]; + gchar colornamed_inverse[64]; + int colorset = prefs->getInt("/theme/symbolicColor", 0x000000ff); + 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); if (prefs->getBool("/theme/symbolicIcons", false)) { +<<<<<<< HEAD int colorset = prefs->getInt("/theme/symbolicColor", 0x000000ff); gchar colornamed[64]; sp_svg_write_color(colornamed, sizeof(colornamed), colorset); @@ -401,12 +409,47 @@ Application::add_gtk_css() css_str += ";}"; css_str += "#iconregular{ -gtk-icon-style: regular;}"; } +======= + css_str += "*{ -gtk-icon-style: symbolic;}"; + css_str += "image{ color:"; + css_str += colornamed; + css_str += ";}"; +>>>>>>> Adding styling refactoring, moving after to other branch the CSS part } else { css_str += "*{-gtk-icon-style: regular;}"; } - GtkSettings *settings = gtk_settings_get_default(); + css_str += ".iconcolornamed, .iconcolornamed image{ color:"; + css_str += colornamed; + css_str += ";}"; + css_str += ".iconcolornamedinverse, .colornamedinverse image{ color:"; + css_str += colornamed_inverse; + css_str += ";}"; const gchar *gtk_font_name = ""; + const gchar *gtkThemeName; + const gchar *gtkIconThemeName; + gboolean gtkApplicationPreferDarkTheme; + GtkSettings *settings = gtk_settings_get_default(); if (settings) { + g_object_get(settings, "gtk-icon-theme-name", >kIconThemeName, NULL); + g_object_get(settings, "gtk-theme-name", >kThemeName, NULL); + g_object_get(settings, "gtk-application-prefer-dark-theme", >kApplicationPreferDarkTheme, NULL); + g_object_set(settings, "gtk-application-prefer-dark-theme", + prefs->getBool("/theme/darkTheme", gtkApplicationPreferDarkTheme), NULL); + 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); + } + 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); + } + else { + prefs->setString("/theme/iconTheme", Glib::ustring(gtkIconThemeName)); + } g_object_get(settings, "gtk-font-name", >k_font_name, NULL); } if (!strncmp(gtk_font_name, "Cantarell", 9)) { @@ -509,33 +552,6 @@ Application::Application(const char* argv, bool use_gui) : icon_theme->prepend_search_path(get_path_ustring(USER, ICONS)); add_gtk_css(); /* Load the preferences and menus */ - GtkSettings *settings = gtk_settings_get_default(); - if (settings) { - const gchar *gtkThemeName; - const gchar *gtkIconThemeName; - gboolean gtkApplicationPreferDarkTheme; - g_object_get(settings, "gtk-theme-name", >kThemeName, NULL); - g_object_get(settings, "gtk-icon-theme-name", >kIconThemeName, NULL); - g_object_get(settings, "gtk-application-prefer-dark-theme", >kApplicationPreferDarkTheme, NULL); - g_object_set(settings, "gtk-application-prefer-dark-theme", - prefs->getBool("/theme/darkTheme", gtkApplicationPreferDarkTheme), NULL); - 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); - } - 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); - } - else { - prefs->setString("/theme/iconTheme", Glib::ustring(gtkIconThemeName)); - } - } - load_menus(); Inkscape::DeviceManager::getManager().loadConfig(); } diff --git a/src/ui/dialog/filter-editor.cpp b/src/ui/dialog/filter-editor.cpp index 6ad9dca61..ba2c7357a 100644 --- a/src/ui/dialog/filter-editor.cpp +++ b/src/ui/dialog/filter-editor.cpp @@ -69,7 +69,7 @@ FilterEditorDialog::FilterEditorDialog() : UI::Widget::Panel("/dialogs/filtereff { const std::string req_widgets[] = {"FilterEditor", "FilterList", "FilterFERX", "FilterFERY", "FilterFERH", "FilterFERW", "FilterPreview", "FilterPrimitiveDescImage", "FilterPrimitiveList", "FilterPrimitiveDescText", "FilterPrimitiveAdd"}; - Glib::ustring gladefile = get_filename(UIS, "filter-editor.glade"); + Glib::ustring gladefile = get_filename(UIS, "dialog-filter-editor.ui"); try { builder = Gtk::Builder::create_from_file(gladefile); } catch(const Glib::Error& ex) { diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 6634ef170..158aeb617 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -43,6 +43,7 @@ #include "selection.h" #include "shortcuts.h" #include "verbs.h" +#include "inkscape-window.h" #include "display/canvas-grid.h" #include "display/nr-filter-gaussian.h" @@ -59,6 +60,7 @@ #include "svg/svg-color.h" #include "ui/interface.h" #include "ui/widget/style-swatch.h" +#include "widgets/desktop-widget.h" #ifdef HAVE_ASPELL # include @@ -679,30 +681,34 @@ void InkscapePreferences::symbolicDefaultColor(){ void InkscapePreferences::symbolicAddClass() { + using namespace Inkscape::IO::Resource; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setBool("/theme/symbolicIconsDefaultColor", false); auto const screen = Gdk::Screen::get_default(); auto provider = Gtk::CssProvider::create(); Glib::ustring css_str = ""; + + gchar colornamed[64]; + gchar colornamed_inverse[64]; + int colorset = prefs->getInt("/theme/symbolicColor", 0x000000ff); + 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); if (prefs->getBool("/theme/symbolicIcons", false)) { - int colorset = prefs->getInt("/theme/symbolicColor", 0x000000ff); - gchar colornamed[64]; - 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; - gchar colornamed_inverse[64]; - sp_svg_write_color(colornamed_inverse, sizeof(colornamed_inverse), colorset_inverse); css_str += "*{ -gtk-icon-style: symbolic;}"; css_str += "image{ color:"; css_str += colornamed; css_str += ";}"; - css_str += "iconinverse{ color:"; - css_str += colornamed_inverse; - css_str += ";}"; - css_str += "iconregular{ -gtk-icon-style: regular;}"; } else { css_str += "*{-gtk-icon-style: regular;}"; } + css_str += ".iconcolornamed, .iconcolornamed image{ color:"; + css_str += colornamed; + css_str += ";}"; + css_str += ".iconcolornamedinverse, .colornamedinverse image{ color:"; + css_str += colornamed_inverse; + css_str += ";}"; // From 3.16, throws an error which we must catch. try { provider->load_from_data(css_str); @@ -717,6 +723,29 @@ void InkscapePreferences::symbolicAddClass() } #endif Gtk::StyleContext::add_provider_for_screen(screen, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + // we want a tiny file with 3 or 4 lines, so we can load without removing context + // is more understandable than record previously applied + Glib::ustring style = get_filename(UIS, "style.css"); + if (!style.empty()) { + auto provider = Gtk::CssProvider::create(); + + // From 3.16, throws an error which we must catch. + try { + provider->load_from_path (style); + } +#if GTK_CHECK_VERSION(3,16,0) + // Gtk::CssProviderError not defined until 3.16. + catch (const Gtk::CssProviderError& ex) + { + g_critical("CSSProviderError::load_from_path(): failed to load '%s'\n(%s)", + style.c_str(), ex.what().c_str()); + } +#else + catch (...) + {} +#endif + Gtk::StyleContext::add_provider_for_screen (screen, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + } } void InkscapePreferences::themeChange() { @@ -724,6 +753,29 @@ void InkscapePreferences::themeChange() g_object_set(gtk_settings_get_default(), "gtk-theme-name", prefs->getString("/theme/gtkTheme").c_str(), NULL); g_object_set(gtk_settings_get_default(), "gtk-application-prefer-dark-theme", prefs->getBool("/theme/darkTheme", false), NULL); + gchar *gtkThemeName; + gboolean gtkApplicationPreferDarkTheme; + Gtk::Window *window = SP_ACTIVE_DESKTOP->getToplevel(); + GtkSettings *settings = gtk_settings_get_default(); + if (window && settings) { + g_object_get(settings, "gtk-theme-name", >kThemeName, NULL); + g_object_get(settings, "gtk-application-prefer-dark-theme", >kApplicationPreferDarkTheme, NULL); + bool dark = gtkApplicationPreferDarkTheme || Glib::ustring(gtkThemeName).find(":dark") != -1; + if (!dark) { + Glib::RefPtr stylecontext = window->get_style_context(); + Gdk::RGBA rgba; + bool background_set = stylecontext->lookup_color("theme_bg_color", rgba); + if (background_set && rgba.get_red() + rgba.get_green() + rgba.get_blue() < 1.0) { + dark = true; + } + } + if (dark) + { + window->get_style_context()->add_class("dark"); + } else { + window->get_style_context()->remove_class("dark"); + } + } } void InkscapePreferences::initPageUI() diff --git a/src/ui/dialog/livepatheffect-add.cpp b/src/ui/dialog/livepatheffect-add.cpp index f930199cf..9eea4cccd 100644 --- a/src/ui/dialog/livepatheffect-add.cpp +++ b/src/ui/dialog/livepatheffect-add.cpp @@ -24,12 +24,10 @@ namespace UI { namespace Dialog { LivePathEffectAdd::LivePathEffectAdd() : - _add_button(_("_Add"), true), - _close_button(_("_Cancel"), true), converter(Inkscape::LivePathEffect::LPETypeConverter) { - const std::string req_widgets[] = {"LPESelector", "LPESelectorFlowBox"}; - Glib::ustring gladefile = get_filename(Inkscape::IO::Resource::UIS, "lpe-selector.glade"); + const std::string req_widgets[] = {"LPEDialogSelector", "LPESelector", "LPESelectorFlowBox"}; + Glib::ustring gladefile = get_filename(Inkscape::IO::Resource::UIS, "dialog-livepatheffect-add.ui"); try { _builder = Gtk::Builder::create_from_file(gladefile); } catch(const Glib::Error& ex) { @@ -45,9 +43,7 @@ LivePathEffectAdd::LivePathEffectAdd() : return; } } - _builder->get_widget("LPESelector", _LPESelector); - auto mainVBox = get_content_area(); - mainVBox->pack_start(*_LPESelector, true, true); + _builder->get_widget("LPEDialogSelector", _LPEDialogSelector); /** * Initialize Effect list */ @@ -55,8 +51,8 @@ LivePathEffectAdd::LivePathEffectAdd() : _builder->get_widget("LPEFilter", _LPEFilter); _builder->get_widget("LPEInfo", _LPEInfo); _LPEFilter->signal_search_changed().connect(sigc::mem_fun(*this, &LivePathEffectAdd::on_search)); - const std::string le_widgets[] = {"LPESelectorItem", "LPEName","LPEDescription"}; - Glib::ustring le_gladefile = get_filename(Inkscape::IO::Resource::UIS, "lpe-selector-item.glade"); + const std::string le_widgets[] = {"LPESelectorEffect", "LPEName","LPEDescription"}; + Glib::ustring le_gladefile = get_filename(Inkscape::IO::Resource::UIS, "dialog-livepatheffect-add-effect.ui"); for(int i = 0; i < static_cast(converter._length); ++i) { try { @@ -90,16 +86,16 @@ LivePathEffectAdd::LivePathEffectAdd() : newid = "LPEIcon_" + Glib::ustring::format(i); (*LPEIcon).set_name(newid); (*LPEIcon).set_from_icon_name(converter.get_icon(data->id),Gtk::BuiltinIconSize(Gtk::ICON_SIZE_DIALOG)); - Gtk::Box * LPESelectorItem; - _builder->get_widget("LPESelectorItem", LPESelectorItem); - newid = "LPESelectorItem" + Glib::ustring::format(i); - (*LPESelectorItem).set_name(newid); - _LPESelectorFlowBox->insert(*LPESelectorItem, i); + Gtk::Box * LPESelectorEffect; + _builder->get_widget("LPESelectorEffect", LPESelectorEffect); + newid = "LPESelectorEffect" + Glib::ustring::format(i); + (*LPESelectorEffect).set_name(newid); + _LPESelectorFlowBox->insert(*LPESelectorEffect, i); } _visiblelpe = _LPESelectorFlowBox->get_children().size(); _LPESelectorFlowBox->signal_child_activated().connect(sigc::mem_fun(*this, &LivePathEffectAdd::on_activate)); - set_title(_("Live Efects Selector")); - show_all_children(); + _LPEDialogSelector->set_title(_("Live Efects Selector")); + _LPEDialogSelector->show_all_children(); _LPEInfo->set_visible(false); } @@ -107,6 +103,8 @@ void LivePathEffectAdd::on_activate(Gtk::FlowBoxChild *child){ for (auto i:_LPESelectorFlowBox->get_children()) { Gtk::FlowBoxChild * leitem = dynamic_cast(i); leitem->get_style_context()->remove_class("lpeactive"); + leitem->get_style_context()->remove_class("colorinverse"); + leitem->get_style_context()->remove_class("backgroundinverse"); Gtk::Box *box = dynamic_cast(leitem->get_child()); if (box) { std::vector contents = box->get_children(); @@ -117,6 +115,8 @@ void LivePathEffectAdd::on_activate(Gtk::FlowBoxChild *child){ } } child->get_style_context()->add_class("lpeactive"); + child->get_style_context()->add_class("colorinverse"); + child->get_style_context()->add_class("backgroundinverse"); child->show_all_children(); } @@ -170,7 +170,7 @@ void LivePathEffectAdd::onAdd() void LivePathEffectAdd::onClose() { - hide(); + _LPEDialogSelector->hide(); } void LivePathEffectAdd::onKeyEvent(GdkEventKey* evt) @@ -186,12 +186,7 @@ void LivePathEffectAdd::onKeyEvent(GdkEventKey* evt) void LivePathEffectAdd::show(SPDesktop *desktop) { LivePathEffectAdd &dial = instance(); - dial.set_modal(true); - //dial.set_decorated(false); - dial.set_name("lpedialogselector"); - //desktop->setWindowTransient (dial.gobj()); - dial.property_destroy_with_parent() = true; - dial.run(); + dial._LPEDialogSelector->run(); } } // namespace Dialog diff --git a/src/ui/dialog/livepatheffect-add.h b/src/ui/dialog/livepatheffect-add.h index 88aca58b2..17d46487a 100644 --- a/src/ui/dialog/livepatheffect-add.h +++ b/src/ui/dialog/livepatheffect-add.h @@ -70,8 +70,9 @@ protected: private: Gtk::Button _add_button; Gtk::Button _close_button; + Gtk::Dialog *_LPEDialogSelector; Glib::RefPtr _builder; - Gtk::FlowBox * _LPESelectorFlowBox; + Gtk::FlowBox *_LPESelectorFlowBox; Gtk::SearchEntry *_LPEFilter; Gtk::Label *_LPEInfo; Gtk::Box *_LPESelector; diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index fa76fc31a..06a76605b 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -186,7 +186,6 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : icon_view = new Gtk::IconView(static_cast >(store)); //icon_view->set_text_column( columns->symbol_id ); icon_view->set_tooltip_column( 1 ); - icon_view->set_name( "symbolsView" ); icon_view->set_pixbuf_column( columns->symbol_image ); // Giving the iconview a small minimum size will help users understand // What the dialog does. @@ -214,6 +213,8 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : overlay->set_hexpand(); overlay->set_vexpand(); overlay->add(* scroller); + overlay->get_style_context()->add_class("colorbright"); + overlay->get_style_context()->add_class("backgroundbright"); scroller->set_size_request(100, 250); table->attach(*Gtk::manage(overlay),0,row,2,1); @@ -227,7 +228,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : iconsize = Gtk::IconSize().register_new(Glib::ustring("ICON_SIZE_DIALOG_EXTRA"), 110, 110); } overlay_icon = sp_get_icon_image("searching", iconsize); - overlay_icon->set_name("iconinverse"); + overlay_icon->get_style_context()->add_class("iconsymbolic"); overlay_icon->set_halign(Gtk::ALIGN_CENTER ); overlay_icon->set_valign(Gtk::ALIGN_START ); overlay_icon->set_margin_top(45); diff --git a/src/ui/widget/dash-selector.cpp b/src/ui/widget/dash-selector.cpp index 81e7881b6..ea5cc57d2 100644 --- a/src/ui/widget/dash-selector.cpp +++ b/src/ui/widget/dash-selector.cpp @@ -61,7 +61,7 @@ DashSelector::DashSelector() dash_combo.pack_start(image_renderer); dash_combo.set_cell_data_func(image_renderer, sigc::mem_fun(*this, &DashSelector::prepareImageRenderer)); dash_combo.set_tooltip_text(_("Dash pattern")); - dash_combo.set_name("dashCombo"); + dash_combo.get_style_context()->add_class("combobright"); dash_combo.show(); dash_combo.signal_changed().connect( sigc::mem_fun(*this, &DashSelector::on_selection) ); diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index b7b9d2ce0..801e6bc41 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -693,7 +693,6 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) } overallTimer = nullptr; } - // Ensure that ruler ranges are updated correctly whenever the canvas table // is resized dtw->_canvas_tbl_size_allocate_connection = dtw->_canvas_tbl->signal_size_allocate().connect(sigc::mem_fun(dtw, &SPDesktopWidget::canvas_tbl_size_allocate)); @@ -890,6 +889,28 @@ sp_desktop_widget_realize (GtkWidget *widget) dtw->desktop->set_display_area (d, 10); dtw->updateNamedview(); + gchar *gtkThemeName; + gboolean gtkApplicationPreferDarkTheme; + GtkSettings *settings = gtk_settings_get_default(); + Gtk::Window *window = SP_ACTIVE_DESKTOP->getToplevel(); + if (settings && window) { + g_object_get(settings, "gtk-theme-name", >kThemeName, NULL); + g_object_get(settings, "gtk-application-prefer-dark-theme", >kApplicationPreferDarkTheme, NULL); + bool dark = gtkApplicationPreferDarkTheme || Glib::ustring(gtkThemeName).find(":dark") != -1; + if (!dark) { + Glib::RefPtr stylecontext = window->get_style_context(); + Gdk::RGBA rgba; + bool background_set = stylecontext->lookup_color("theme_bg_color", rgba); + if (background_set && rgba.get_red() + rgba.get_green() + rgba.get_blue() < 1.0) { + dark = true; + } + } + if (dark) { + window->get_style_context()->add_class("dark"); + } else { + window->get_style_context()->remove_class("dark"); + } + } } /* This is just to provide access to common functionality from sp_desktop_widget_realize() above diff --git a/src/widgets/stroke-marker-selector.cpp b/src/widgets/stroke-marker-selector.cpp index 5bfebb799..095653cb3 100644 --- a/src/widgets/stroke-marker-selector.cpp +++ b/src/widgets/stroke-marker-selector.cpp @@ -52,7 +52,6 @@ MarkerComboBox::MarkerComboBox(gchar const *id, int l) : pack_start(image_renderer, false); set_cell_data_func(image_renderer, sigc::mem_fun(*this, &MarkerComboBox::prepareImageRenderer)); gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(gobj()), MarkerComboBox::separator_cb, nullptr, nullptr); - gtk_widget_set_name(GTK_WIDGET(gobj()), "markerCombo"); empty_image = sp_get_icon_image("no-marker", Gtk::ICON_SIZE_SMALL_TOOLBAR); sandbox = ink_markers_preview_doc (); @@ -62,6 +61,7 @@ MarkerComboBox::MarkerComboBox(gchar const *id, int l) : modified_connection = doc->getDefs()->connectModified( sigc::hide(sigc::hide(sigc::bind(sigc::ptr_fun(&MarkerComboBox::handleDefsModified), this))) ); init_combo(); + this->get_style_context()->add_class("combobright"); show(); } diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 3199e25ef..6e614f582 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -857,7 +857,7 @@ void ToolboxFactory::setOrientation(GtkWidget* toolbox, GtkOrientation orientati void setup_tool_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { setupToolboxCommon( toolbox, desktop, - "tool-toolbar.ui", + "toolbar-tool.ui", "/ui/ToolToolbar", "/toolbox/tools/small"); } @@ -905,12 +905,12 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop) Glib::RefPtr mainActions = create_or_fetch_actions( desktop ); // The UI Manager creates widgets based on the definitions in the - // "select-toolbar.ui" file. This is only used with the "prep" + // "toolbar-select.ui" file. This is only used with the "prep" // method of toolbar-creation GtkUIManager* mgr = gtk_ui_manager_new(); GError *err = nullptr; gtk_ui_manager_insert_action_group( mgr, mainActions->gobj(), 0 ); - Glib::ustring filename = get_filename(UIS, "select-toolbar.ui"); + Glib::ustring filename = get_filename(UIS, "toolbar-select.ui"); guint ret = gtk_ui_manager_add_ui_from_file(mgr, filename.c_str(), &err); if(err) { g_warning("Failed to load aux toolbar %s: %s", filename.c_str(), err->message); @@ -1061,7 +1061,7 @@ void update_aux_toolbox(SPDesktop * /*desktop*/, ToolBase *eventcontext, GtkWidg void setup_commands_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { setupToolboxCommon( toolbox, desktop, - "commands-toolbar.ui", + "toolbar-commands.ui", "/ui/CommandsToolbar", "/toolbox/small" ); } @@ -1375,7 +1375,7 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) } setupToolboxCommon( toolbox, desktop, - "snap-toolbar.ui", + "toolbar-snap.ui", "/ui/SnapToolbar", "/toolbox/secondary" ); } -- cgit v1.2.3