diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2019-10-11 21:40:42 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2019-10-11 21:40:42 +0000 |
| commit | b8e9f23d66a6b47550225cb831240b31d5b470dc (patch) | |
| tree | 5cdd116777502d5a4b87673d6da66c1b36de1c90 | |
| parent | Fix wrong value (diff) | |
| download | inkscape-b8e9f23d66a6b47550225cb831240b31d5b470dc.tar.gz inkscape-b8e9f23d66a6b47550225cb831240b31d5b470dc.zip | |
Separate Adwaita and Adwaita-dark with specific styling (alowing to tweak any theme with his theme name as css file)to allow better theming. Use this issue as reference: https://gitlab.com/inkscape/inkscape/issues/461
| -rw-r--r-- | share/ui/Adwaita-dark.css | 62 | ||||
| -rw-r--r-- | share/ui/Adwaita.css | 63 | ||||
| -rw-r--r-- | share/ui/style.css | 48 | ||||
| -rw-r--r-- | src/inkscape.cpp | 43 | ||||
| -rw-r--r-- | src/inkscape.h | 1 |
5 files changed, 148 insertions, 69 deletions
diff --git a/share/ui/Adwaita-dark.css b/share/ui/Adwaita-dark.css new file mode 100644 index 000000000..db89ba272 --- /dev/null +++ b/share/ui/Adwaita-dark.css @@ -0,0 +1,62 @@ +/* ADWAITA DARK SPECIFIC STYLE */ + +/* + * Keep as small as possible + */ + +spinbutton { + padding: 0; + outline-style: none; +} + +spinbutton entry { + padding-left: 2px; + padding-right: 0; +} + +spinbutton undershoot { + outline-style: none; +} + +spinbutton entry { + padding-left: 2px; + padding-right: 0; +} + +spinbutton undershoot { + outline-style: none; +} + +.inkswitch slider { + min-width: 18px; + min-height: 18px; +} + +.inkswitch image { + color: transparent; + background-color: transparent; + background-image: image(transparent); + -gtk-icon-style:symbolic; +} + +.inkswitch { + margin: 2px; + padding: 0; + font-size: 8px; +} + +/* Reduce width of +/- buttons. */ +.up, +.down { + padding-left: 0; + padding-right: 0; +} + +#monoStrokeWidth, +#fillEmptySpace, +#SelectStatus, +#CoordinateStatusX, +#CoordinateStatusY, +#DesktopMainTable spinbutton{ + font-family: sans-serif; +}
\ No newline at end of file diff --git a/share/ui/Adwaita.css b/share/ui/Adwaita.css new file mode 100644 index 000000000..ebec8d2ee --- /dev/null +++ b/share/ui/Adwaita.css @@ -0,0 +1,63 @@ +/* ADWAITA SPECIFIC STYLE */ + + +/* + * Keep as small as possible + */ + +spinbutton { + padding: 0; + outline-style: none; +} + +spinbutton entry { + padding-left: 2px; + padding-right: 0; +} + +spinbutton undershoot { + outline-style: none; +} + +spinbutton entry { + padding-left: 2px; + padding-right: 0; +} + +spinbutton undershoot { + outline-style: none; +} + +.inkswitch slider { + min-width: 18px; + min-height: 18px; +} + +.inkswitch image { + color: transparent; + background-color: transparent; + background-image: image(transparent); + -gtk-icon-style:symbolic; +} + +.inkswitch { + margin: 2px; + padding: 0; + font-size: 8px; +} + +/* Reduce width of +/- buttons. */ +.up, +.down { + padding-left: 0; + padding-right: 0; +} + +#monoStrokeWidth, +#fillEmptySpace, +#SelectStatus, +#CoordinateStatusX, +#CoordinateStatusY, +#DesktopMainTable spinbutton{ + font-family: sans-serif; +}
\ No newline at end of file diff --git a/share/ui/style.css b/share/ui/style.css index b103c323b..46a4de0cd 100644 --- a/share/ui/style.css +++ b/share/ui/style.css @@ -122,6 +122,7 @@ color: inherit; } +/* atribute dialog popup size */ .attrpop textview { font-size: 13px; } @@ -149,29 +150,6 @@ color: @success_color; } -spinbutton { - padding: 0; - outline-style: none; -} - -spinbutton entry { - padding-left: 2px; - padding-right: 0; -} - -spinbutton undershoot { - outline-style: none; -} - -spinbutton entry { - padding-left: 2px; - padding-right: 0; -} - -spinbutton undershoot { - outline-style: none; -} - iconview *:hover { border-width: 1px; border-color: @theme_fg_color; @@ -187,23 +165,6 @@ iconview *:hover { font-size: 11px; } -.inkswitch slider { - min-width: 18px; - min-height: 18px; -} - -.inkswitch image { - color: transparent; - background-color: transparent; - background-image: image(transparent); - -gtk-icon-style:symbolic; -} - -.inkswitch { - margin: 2px; - padding: 0; - font-size: 8px; -} /* LPE Dialog add */ #LPESelectorFlowBox GtkFlowBoxChild, @@ -404,13 +365,6 @@ SPCanvas { padding-right: 0; } -/* Reduce width of +/- buttons. */ -.up, -.down { - padding-left: 0; - padding-right: 0; -} - /* InkSpinScale */ #InkSpinScale { background: @theme_bg_color; diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 030072df8..5a49b1ade 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -558,7 +558,6 @@ void Application::add_gtk_css() // Add style sheet (GTK3) auto const screen = Gdk::Screen::get_default(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - gchar *gtk_font_name = nullptr; gchar *gtkThemeName = nullptr; gchar *gtkIconThemeName = nullptr; Glib::ustring themeiconname; @@ -584,7 +583,7 @@ void Application::add_gtk_css() } else { prefs->setString("/theme/iconTheme", Glib::ustring(gtkIconThemeName)); } - g_object_get(settings, "gtk-font-name", >k_font_name, NULL); + } g_free(gtkThemeName); @@ -601,6 +600,26 @@ void Application::add_gtk_css() } Gtk::StyleContext::add_provider_for_screen(screen, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); } + + Glib::ustring gtkthemename = prefs->getString("/theme/gtkTheme"); + gtkthemename += ".css"; + style = get_filename(UIS, gtkthemename.c_str()); + if (!style.empty()) { + if (themeprovider) { + Gtk::StyleContext::remove_provider_for_screen(screen, themeprovider); + } + if (!themeprovider) { + themeprovider = Gtk::CssProvider::create(); + } + try { + themeprovider->load_from_path(style); + } catch (const Gtk::CssProviderError &ex) { + g_critical("CSSProviderError::load_from_path(): failed to load '%s'\n(%s)", style.c_str(), + ex.what().c_str()); + } + Gtk::StyleContext::add_provider_for_screen(screen, themeprovider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + } + if (!colorizeprovider) { colorizeprovider = Gtk::CssProvider::create(); } @@ -614,26 +633,6 @@ void Application::add_gtk_css() 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, colorizeprovider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); - - if (gtk_font_name && !strncmp(gtk_font_name, "Cantarell", 9)) { - auto provider = Gtk::CssProvider::create(); - css_str = "#monoStrokeWidth,"; - css_str += "#fillEmptySpace,"; - css_str += "#SelectStatus,"; - css_str += "#CoordinateStatusX,"; - css_str += "#CoordinateStatusY,"; - css_str += "#DesktopMainTable spinbutton{"; - css_str += " font-family: sans-serif;"; - css_str += "}"; // we also can add to * but seems to me Cantarell looks better for other places - 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()); - } - Gtk::StyleContext::add_provider_for_screen(screen, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); - } - g_free(gtk_font_name); } void Application::readStyleSheets(bool forceupd) diff --git a/src/inkscape.h b/src/inkscape.h index 897f9e296..2ee35651a 100644 --- a/src/inkscape.h +++ b/src/inkscape.h @@ -109,6 +109,7 @@ public: Inkscape::UI::Tools::ToolBase * active_event_context(); SPDocument * active_document(); SPDesktop * active_desktop(); + Glib::RefPtr<Gtk::CssProvider> themeprovider; Glib::RefPtr<Gtk::CssProvider> colorizeprovider; // Use this function to get selection model etc for a document Inkscape::ActionContext action_context_for_document(SPDocument *doc); |
