diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2019-01-26 05:16:02 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2019-01-27 00:40:25 +0000 |
| commit | e0471fb385a7250815528d23f0c2ecbbca675d42 (patch) | |
| tree | 33ac5b8f91a55e7de73cd61dcb206f2e2e04ce78 /src/ui | |
| parent | Add style file (diff) | |
| download | inkscape-e0471fb385a7250815528d23f0c2ecbbca675d42.tar.gz inkscape-e0471fb385a7250815528d23f0c2ecbbca675d42.zip | |
Adding styling refactoring, moving after to other branch the CSS part
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/dialog/filter-editor.cpp | 2 | ||||
| -rw-r--r-- | src/ui/dialog/inkscape-preferences.cpp | 74 | ||||
| -rw-r--r-- | src/ui/dialog/livepatheffect-add.cpp | 41 | ||||
| -rw-r--r-- | src/ui/dialog/livepatheffect-add.h | 3 | ||||
| -rw-r--r-- | src/ui/dialog/symbols.cpp | 5 | ||||
| -rw-r--r-- | src/ui/widget/dash-selector.cpp | 2 |
6 files changed, 88 insertions, 39 deletions
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 <aspell.h> @@ -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<Gtk::StyleContext> 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<int>(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<Gtk::FlowBoxChild *>(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<Gtk::Box *>(leitem->get_child()); if (box) { std::vector<Gtk::Widget*> 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<Gtk::Builder> _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<Glib::RefPtr<Gtk::TreeModel> >(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) ); |
