From 1dcbdd9b9d6f1db457878515fe041bf360ead042 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Wed, 29 May 2019 15:44:16 +0200 Subject: Add CSS and remove XML toggler button --- share/ui/dialog-css.ui | 8 +- share/ui/style.css | 846 +++++++++++++++++++++-------------------- src/ui/dialog/attrdialog.cpp | 1 - src/ui/dialog/styledialog.cpp | 212 ++++++----- src/ui/widget/ink-flow-box.cpp | 6 +- 5 files changed, 538 insertions(+), 535 deletions(-) diff --git a/share/ui/dialog-css.ui b/share/ui/dialog-css.ui index 9664f5175..2374b22f1 100644 --- a/share/ui/dialog-css.ui +++ b/share/ui/dialog-css.ui @@ -67,7 +67,6 @@ True True start - natural False False True @@ -79,7 +78,7 @@ - True + False True 2 @@ -113,9 +112,4 @@ - - 100 - 1 - 10 - diff --git a/share/ui/style.css b/share/ui/style.css index ef4aa98e6..516219491 100644 --- a/share/ui/style.css +++ b/share/ui/style.css @@ -32,424 +32,428 @@ * Lightest to darkest based on linear rgb. */ -@define-color bg_color0 #ffffff; - -/* White */ - -@define-color bg_color05 #f8f8f8; - -/* Slightly off white */ - -@define-color bg_color1 #f0f0f0; -@define-color bg_color2 #e0e0e0; -@define-color bg_color3 #d0d0d0; -@define-color bg_color4 #bbbbbb; - -/* 50% Gray */ - -@define-color bg_color5 #a5a5a5; -@define-color bg_color6 #898989; -@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 daLPESelectorButtonBoxk - * :::::::: Icon Based. - * :::::::: apply to color (foreground) - * :::::::: scope widget and all nested images - * ".iconsymbolic" Force icon symbolic - * ".iconregular" Force colorful 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 - * ".regular ..." Inkscape is in regular icon mode - * ".symbolic ..." Inkscape is in symbolic icon mode - */ - -.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_text_color; - background-color: @theme_base_color; - background-image: image(@theme_base_color); - border-radius: 4px; -} - -.dark .combobright * { - color: @theme_base_color; - background-color: @theme_text_color; - background-image: image(@theme_text_color); - border-radius: 4px; -} - - -/* 'GtkWidget' for Gtk <= 3.18 */ - - -/* 'widget' for Gtk <= 3.19.2 */ - -GtkWidget, -widget { - /* font-size: 12pt; */ -} - -GtkSpinButton { - padding: 0; - outline-style: none; -} - -spinbutton { - padding: 0; - outline-style: none; -} - -GtkSpinButton entry { - padding-left: 2px; - padding-right: 0; -} - -spinbutton entry { - padding-left: 2px; - padding-right: 0; -} - -GtkSpinButton undershoot { - outline-style: none; -} - -spinbutton undershoot { - outline-style: none; -} - -GtkSpinButton entry { - padding-left: 2px; - padding-right: 0; -} - -spinbutton entry { - padding-left: 2px; - padding-right: 0; -} - -GtkSpinButton undershoot { - outline-style: none; -} - -spinbutton undershoot { - outline-style: none; -} - -#LPEDialogSelector, -#LPEDialogSelector .frame, -#LPEDialogSelector .searchbar { - outline-width: 0; - border-width: 0; -} - -#LPESelectorFlowBox GtkFlowBoxChild, -#LPESelectorFlowBox flowboxchild { - border-width: 0px; - border-radius: 6px; - margin: 10px; - padding: 10px; - margin-bottom: 0px; - padding-bottom: 10px; - outline: none; -} - -#LPESelectorFlowBox flowboxchild * { - color: @theme_fg_color; -} - -#LPESelectorFlowBox flowboxchild:selected image, -#LPESelectorFlowBox flowboxchild:selected label { - background-color: @theme_selected_bg_color; - color: @theme_selected_fg_color; - background-image: image(@theme_selected_bg_color); -} - -#LPESelectorFlowBox *:selected #LPESelectorEffectFavTop, -#LPESelectorFlowBox *:selected:focus #LPESelectorEffectFavTop { - opacity: 0; -} - -#LPESelectorFlowBox .lpename { - font-size: 16px; - margin-bottom: 5px; -} - -#LPESelectorFlowBox .lpeinfo { - font-size: 16px; - padding: 20px; -} - -#LPESelectorFlowBox .lpedisabled { - opacity: 0.3; -} - -#LPESelectorEffectInfoPop { - padding: 15px; -} - -#LPESelectorEffectInfoName { - font-weight: bold; - padding: 15px; -} - -#LPEDialogSelector .lpeinfo { - padding: 8px; - background-color: @theme_selected_fg_color; - color: @theme_selected_bg_color; - margin: 10px 10px 0px 10px; - border-radius: 5px; -} - -.switchclean image, -#LPEExperimental image { - color: transparent; -} - -#LPEDialogSelector .searchbar entry image, -#LPEDialogSelector .searchbar label, -#LPEDialogSelector .searchbar #LPESelectorEffectFavShowImage { - color: @theme_fg_color; -} - -#XMLFlow .toggle { - min-width: 18px; - padding-left: 6px; - padding-right: 6px; - padding-top: 0; - padding-bottom: 0; -} - -#XMLFlow GtkFlowBoxChild, -#XMLFlow flowboxchild{ - border-right-width:1px; - border-top-width:1px; - border-bottom-width:1px; - margin-top:-1px; - border-style:solid; - border-color:@borders; - padding:7px; -} - -SPRuler { - background-color: @theme_bg_color; - color: @theme_fg_color; -} - -ruler-widget { - background-color: @theme_bg_color; - color: @theme_fg_color; -} - - -/* The actual canvas (Inkscape's drawing area). */ - -SPCanvas { - background-color: white; -} - -combobox window.popup scrolledwindow treeview separator {} - -#font_selector_family {} - -#TextFontFamilyAction_combobox { - -GtkComboBox-appears-as-list: true; -} - -#LockGuides, -#StickyZoom, -#CMS_Adjust { - padding: 0; -} - - -/* Keep palette scrollbar from generating warnings. */ - -#PreviewHolderScroller .vertical slider { - min-height: 15px; -} - - -/* Override minimum size of container children for palette. */ - -#ColorItemPreview { - min-height: 5px; - min-width: 5px; -} - - -/* Reduce width of Fill and Stroke dialog */ - -#ColorModeButton { - padding-left: 0; - padding-right: 0; -} - - -/* Reduce width of +/- buttons. */ - -.up, -.down { - padding-left: 0; - padding-right: 0; -} - - -/* InkSpinScale */ - -#InkSpinScale { - background: @theme_bg_color; - border: 1px black; - border-radius: 3px; - padding: 0px; -} - -#InkSpinScale spinbutton { - border-color: #eee; - border-width: 0 0 0 0; - border-radius: 0 3px 3px 0; - box-shadow: none; - padding: 0 0 0 1px; - min-height: 10px; -} - - -/* Hide slider */ - -#InkSpinScale slider { - background: none; - border: none; - outline: none; - min-width: 0px; - min-height: 0px; - padding: 0px; - margin: 0px; -} - -#InkSpinScale slider, -#InkSpinScale highlight { - border-top-right-radius: 0; - border-bottom-right-radius: 0; -} - -#InkSpinScale scale { - padding: 0px; -} - -#InkSpinScale trough { - min-height: 30px; -} - -#InkSpinScale box.active { - box-shadow: 0 0 0 1px rgb(74, 144, 217); -} - -#InkSpinScale spinbutton entry { - padding: 0; - outline-style: none; -} \ No newline at end of file + @define-color bg_color0 #ffffff; + + /* White */ + + @define-color bg_color05 #f8f8f8; + + /* Slightly off white */ + + @define-color bg_color1 #f0f0f0; + @define-color bg_color2 #e0e0e0; + @define-color bg_color3 #d0d0d0; + @define-color bg_color4 #bbbbbb; + + /* 50% Gray */ + + @define-color bg_color5 #a5a5a5; + @define-color bg_color6 #898989; + @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 daLPESelectorButtonBoxk + * :::::::: Icon Based. + * :::::::: apply to color (foreground) + * :::::::: scope widget and all nested images + * ".iconsymbolic" Force icon symbolic + * ".iconregular" Force colorful 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 + * ".regular ..." Inkscape is in regular icon mode + * ".symbolic ..." Inkscape is in symbolic icon mode + */ + + .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_text_color; + background-color: @theme_base_color; + background-image: image(@theme_base_color); + border-radius: 4px; + } + + .dark .combobright * { + color: @theme_base_color; + background-color: @theme_text_color; + background-image: image(@theme_text_color); + border-radius: 4px; + } + + + /* 'GtkWidget' for Gtk <= 3.18 */ + + + /* 'widget' for Gtk <= 3.19.2 */ + + GtkWidget, + widget { + /* font-size: 12pt; */ + } + + GtkSpinButton { + padding: 0; + outline-style: none; + } + + spinbutton { + padding: 0; + outline-style: none; + } + + GtkSpinButton entry { + padding-left: 2px; + padding-right: 0; + } + + spinbutton entry { + padding-left: 2px; + padding-right: 0; + } + + GtkSpinButton undershoot { + outline-style: none; + } + + spinbutton undershoot { + outline-style: none; + } + + GtkSpinButton entry { + padding-left: 2px; + padding-right: 0; + } + + spinbutton entry { + padding-left: 2px; + padding-right: 0; + } + + GtkSpinButton undershoot { + outline-style: none; + } + + spinbutton undershoot { + outline-style: none; + } + + #LPEDialogSelector, + #LPEDialogSelector .frame, + #LPEDialogSelector .searchbar { + outline-width: 0; + border-width: 0; + } + + #LPESelectorFlowBox GtkFlowBoxChild, + #LPESelectorFlowBox flowboxchild { + border-width: 0px; + border-radius: 6px; + margin: 10px; + padding: 10px; + margin-bottom: 0px; + padding-bottom: 10px; + outline: none; + } + + #LPESelectorFlowBox flowboxchild * { + color: @theme_fg_color; + } + + #LPESelectorFlowBox flowboxchild:selected image, + #LPESelectorFlowBox flowboxchild:selected label { + background-color: @theme_selected_bg_color; + color: @theme_selected_fg_color; + background-image: image(@theme_selected_bg_color); + } + + #LPESelectorFlowBox *:selected #LPESelectorEffectFavTop, + #LPESelectorFlowBox *:selected:focus #LPESelectorEffectFavTop { + opacity: 0; + } + + #LPESelectorFlowBox .lpename { + font-size: 16px; + margin-bottom: 5px; + } + + #LPESelectorFlowBox .lpeinfo { + font-size: 16px; + padding: 20px; + } + + #LPESelectorFlowBox .lpedisabled { + opacity: 0.3; + } + + #LPESelectorEffectInfoPop { + padding: 15px; + } + + #LPESelectorEffectInfoName { + font-weight: bold; + padding: 15px; + } + + #LPEDialogSelector .lpeinfo { + padding: 8px; + background-color: @theme_selected_fg_color; + color: @theme_selected_bg_color; + margin: 10px 10px 0px 10px; + border-radius: 5px; + } + + + #LPEExperimental image { + color: transparent; + } + + #LPEDialogSelector .searchbar entry image, + #LPEDialogSelector .searchbar label, + #LPEDialogSelector .searchbar #LPESelectorEffectFavShowImage { + color: @theme_fg_color; + } + + #XMLFlow .stylesheettoggler image { + color: transparent; + } + + #XMLFlow .toggle { + min-width: 18px; + padding-left: 6px; + padding-right: 6px; + padding-top: 0; + padding-bottom: 0; + } + + #XMLFlow GtkFlowBoxChild, + #XMLFlow flowboxchild{ + border-right-width:1px; + border-top-width:1px; + border-bottom-width:1px; + margin-top:-1px; + border-style:solid; + border-color:@borders; + padding:7px; + } + + SPRuler { + background-color: @theme_bg_color; + color: @theme_fg_color; + } + + ruler-widget { + background-color: @theme_bg_color; + color: @theme_fg_color; + } + + + /* The actual canvas (Inkscape's drawing area). */ + + SPCanvas { + background-color: white; + } + + combobox window.popup scrolledwindow treeview separator {} + + #font_selector_family {} + + #TextFontFamilyAction_combobox { + -GtkComboBox-appears-as-list: true; + } + + #LockGuides, + #StickyZoom, + #CMS_Adjust { + padding: 0; + } + + + /* Keep palette scrollbar from generating warnings. */ + + #PreviewHolderScroller .vertical slider { + min-height: 15px; + } + + + /* Override minimum size of container children for palette. */ + + #ColorItemPreview { + min-height: 5px; + min-width: 5px; + } + + + /* Reduce width of Fill and Stroke dialog */ + + #ColorModeButton { + padding-left: 0; + padding-right: 0; + } + + + /* Reduce width of +/- buttons. */ + + .up, + .down { + padding-left: 0; + padding-right: 0; + } + + + /* InkSpinScale */ + + #InkSpinScale { + background: @theme_bg_color; + border: 1px black; + border-radius: 3px; + padding: 0px; + } + + #InkSpinScale spinbutton { + border-color: #eee; + border-width: 0 0 0 0; + border-radius: 0 3px 3px 0; + box-shadow: none; + padding: 0 0 0 1px; + min-height: 10px; + } + + + /* Hide slider */ + + #InkSpinScale slider { + background: none; + border: none; + outline: none; + min-width: 0px; + min-height: 0px; + padding: 0px; + margin: 0px; + } + + #InkSpinScale slider, + #InkSpinScale highlight { + border-top-right-radius: 0; + border-bottom-right-radius: 0; + } + + #InkSpinScale scale { + padding: 0px; + } + + #InkSpinScale trough { + min-height: 30px; + } + + #InkSpinScale box.active { + box-shadow: 0 0 0 1px rgb(74, 144, 217); + } + + #InkSpinScale spinbutton entry { + padding: 0; + outline-style: none; + } \ No newline at end of file diff --git a/src/ui/dialog/attrdialog.cpp b/src/ui/dialog/attrdialog.cpp index d07623325..8d4e74548 100644 --- a/src/ui/dialog/attrdialog.cpp +++ b/src/ui/dialog/attrdialog.cpp @@ -235,7 +235,6 @@ void AttrDialog::onAttrChanged(Inkscape::XML::Node *repr, const gchar * name, co } } } - std::cout << new_value << "aaa" << new_value << std::endl; if (new_value && strcmp(new_value, "") != 0) { if ((repr->type() == Inkscape::XML::TEXT_NODE || repr->type() == Inkscape::XML::COMMENT_NODE) && strcmp(name, "content") != 0) diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp index b7eec923c..9f3d85622 100644 --- a/src/ui/dialog/styledialog.cpp +++ b/src/ui/dialog/styledialog.cpp @@ -199,7 +199,6 @@ StyleDialog::StyleDialog() Gtk::Box *alltoggler = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL)); Gtk::Label *infotoggler = Gtk::manage(new Gtk::Label(_("Edit Full Stylesheet"))); _all_css = Gtk::manage(new Gtk::Switch()); - _all_css->get_style_context()->add_class("switchclean"); _all_css->set_margin_right(5); _all_css->set_margin_top(2); _all_css->property_active().signal_changed().connect(sigc::mem_fun(*this, &StyleDialog::_reload)); @@ -209,6 +208,7 @@ StyleDialog::StyleDialog() _mainBox.pack_start(*alltoggler, false, false, 0); _mainBox.set_orientation(Gtk::ORIENTATION_VERTICAL); _getContents()->pack_start(_mainBox, Gtk::PACK_EXPAND_WIDGET); + _all_css->get_style_context()->add_class("stylesheettoggler"); // Document & Desktop _desktop_changed_connection = _desktopTracker.connectDesktopChanged(sigc::mem_fun(*this, &StyleDialog::_handleDesktopChanged)); @@ -489,87 +489,6 @@ void StyleDialog::_readStyleElement() _styleBox.pack_start(*css_selector_container, Gtk::PACK_EXPAND_WIDGET); } selectorpos++; - try { - _builder = Gtk::Builder::create_from_file(gladefile); - } catch (const Glib::Error &ex) { - g_warning("Glade file loading failed for filter effect dialog"); - return; - } - _builder->get_widget("CSSSelector", css_selector); - css_selector->set_text("element.attributes"); - _builder->get_widget("CSSSelectorContainer", css_selector_container); - _builder->get_widget("CSSSelectorEventAdd", css_selector_event_add); - css_selector_event_add->add_events(Gdk::BUTTON_RELEASE_MASK); - store = Gtk::TreeStore::create(_mColumns); - _builder->get_widget("CSSTree", css_tree); - css_tree->set_model(store); - css_selector_event_add->signal_button_release_event().connect( - sigc::bind, Gtk::TreeView *, Glib::ustring, gint>( - sigc::mem_fun(*this, &StyleDialog::_addRow), store, css_tree, "attributes", selectorpos)); - bool hasattributes = false; - if (!_all_css->get_active()) { - for (auto iter : obj->style->properties()) { - if (iter->style_src != SP_STYLE_SRC_UNSET) { - if (iter->name != "font" && iter->name != "d" && iter->name != "marker") { - const gchar *attr = obj->getRepr()->attribute(iter->name.c_str()); - if (attr) { - if (!hasattributes) { - Inkscape::UI::Widget::IconRenderer *addRenderer = - manage(new Inkscape::UI::Widget::IconRenderer()); - addRenderer->add_icon("edit-delete"); - int addCol = css_tree->append_column("Delete row", *addRenderer) - 1; - Gtk::TreeViewColumn *col = css_tree->get_column(addCol); - if (col) { - addRenderer->signal_activated().connect(sigc::bind>( - sigc::mem_fun(*this, &StyleDialog::_onPropDelete), store)); - } - Gtk::CellRendererText *label = Gtk::manage(new Gtk::CellRendererText()); - label->property_placeholder_text() = _("property"); - label->property_editable() = true; - label->signal_edited().connect( - sigc::bind, Gtk::TreeView *>( - sigc::mem_fun(*this, &StyleDialog::_nameEdited), store, css_tree)); - addCol = css_tree->append_column("CSS Property", *label) - 1; - col = css_tree->get_column(addCol); - if (col) { - col->add_attribute(label->property_text(), _mColumns._colName); - } - Gtk::CellRendererText *value = Gtk::manage(new Gtk::CellRendererText()); - value->property_placeholder_text() = _("value"); - value->property_editable() = true; - value->signal_edited().connect(sigc::bind>( - sigc::mem_fun(*this, &StyleDialog::_valueEdited), store)); - addCol = css_tree->append_column("CSS Value", *value) - 1; - col = css_tree->get_column(addCol); - if (col) { - col->add_attribute(value->property_text(), _mColumns._colValue); - col->add_attribute(value->property_strikethrough(), _mColumns._colStrike); - } - } - Gtk::TreeModel::Row row = *(store->append()); - row[_mColumns._colSelector] = "attributes"; - row[_mColumns._colSelectorPos] = 1; - row[_mColumns._colActive] = true; - row[_mColumns._colName] = iter->name; - row[_mColumns._colValue] = attr; - if (attr_prop.count(iter->name)) { - row[_mColumns._colStrike] = true; - } else { - row[_mColumns._colStrike] = false; - } - hasattributes = true; - } - } - } - } - if (!hasattributes) { - for (auto widg : css_selector_container->get_children()) { - delete widg; - } - } - _styleBox.pack_start(*css_selector_container, Gtk::PACK_EXPAND_WIDGET); - } - selectorpos++; if (tokens.size() == 0) { _updating = false; return; @@ -720,12 +639,93 @@ void StyleDialog::_readStyleElement() _styleBox.pack_start(*css_selector_container, Gtk::PACK_EXPAND_WIDGET); selectorpos++; } + /* try { + _builder = Gtk::Builder::create_from_file(gladefile); + } catch (const Glib::Error &ex) { + g_warning("Glade file loading failed for filter effect dialog"); + return; + } + _builder->get_widget("CSSSelector", css_selector); + css_selector->set_text("element.attributes"); + _builder->get_widget("CSSSelectorContainer", css_selector_container); + _builder->get_widget("CSSSelectorEventAdd", css_selector_event_add); + css_selector_event_add->add_events(Gdk::BUTTON_RELEASE_MASK); + store = Gtk::TreeStore::create(_mColumns); + _builder->get_widget("CSSTree", css_tree); + css_tree->set_model(store); + css_selector_event_add->signal_button_release_event().connect( + sigc::bind, Gtk::TreeView *, Glib::ustring, gint>( + sigc::mem_fun(*this, &StyleDialog::_addRow), store, css_tree, "attributes", selectorpos)); + bool hasattributes = false; + if (!_all_css->get_active()) { + for (auto iter : obj->style->properties()) { + if (iter->style_src != SP_STYLE_SRC_UNSET) { + if (iter->name != "font" && iter->name != "d" && iter->name != "marker") { + const gchar *attr = obj->getRepr()->attribute(iter->name.c_str()); + if (attr) { + if (!hasattributes) { + Inkscape::UI::Widget::IconRenderer *addRenderer = + manage(new Inkscape::UI::Widget::IconRenderer()); + addRenderer->add_icon("edit-delete"); + int addCol = css_tree->append_column("Delete row", *addRenderer) - 1; + Gtk::TreeViewColumn *col = css_tree->get_column(addCol); + if (col) { + addRenderer->signal_activated().connect(sigc::bind>( + sigc::mem_fun(*this, &StyleDialog::_onPropDelete), store)); + } + Gtk::CellRendererText *label = Gtk::manage(new Gtk::CellRendererText()); + label->property_placeholder_text() = _("property"); + label->property_editable() = true; + label->signal_edited().connect( + sigc::bind, Gtk::TreeView *>( + sigc::mem_fun(*this, &StyleDialog::_nameEdited), store, css_tree)); + addCol = css_tree->append_column("CSS Property", *label) - 1; + col = css_tree->get_column(addCol); + if (col) { + col->add_attribute(label->property_text(), _mColumns._colName); + } + Gtk::CellRendererText *value = Gtk::manage(new Gtk::CellRendererText()); + value->property_placeholder_text() = _("value"); + value->property_editable() = true; + value->signal_edited().connect(sigc::bind>( + sigc::mem_fun(*this, &StyleDialog::_valueEdited), store)); + addCol = css_tree->append_column("CSS Value", *value) - 1; + col = css_tree->get_column(addCol); + if (col) { + col->add_attribute(value->property_text(), _mColumns._colValue); + col->add_attribute(value->property_strikethrough(), _mColumns._colStrike); + } + } + Gtk::TreeModel::Row row = *(store->append()); + row[_mColumns._colSelector] = "attributes"; + row[_mColumns._colSelectorPos] = 1; + row[_mColumns._colActive] = true; + row[_mColumns._colName] = iter->name; + row[_mColumns._colValue] = attr; + //for this we comment this code + if (attr_prop.count(iter->name)) { + row[_mColumns._colStrike] = true; + } else { + row[_mColumns._colStrike] = false; + } + hasattributes = true; + } + } + } + } + if (!hasattributes) { + for (auto widg : css_selector_container->get_children()) { + delete widg; + } + } + _styleBox.pack_start(*css_selector_container, Gtk::PACK_EXPAND_WIDGET); */ + //} } - _mainBox.show_all_children(); if (obj) { obj->style->readFromObject(obj); obj->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); } + _mainBox.show_all_children(); _updating = false; } @@ -819,7 +819,29 @@ void StyleDialog::_writeStyleElement(Glib::RefPtr store, Glib::u } if (selector == "style_properties") { obj->getRepr()->setAttribute("style", styleContent, false); - } else if (selector == "attributes") { + } else if (!selector.empty()) { // styleshet + // We could test if styleContent is empty and then delete the style node here but there is no + // harm in keeping it around ... + SPDocument *document = SP_ACTIVE_DOCUMENT; + document->setStyleSheet(nullptr); + std::string pos = std::to_string(selectorpos); + std::string selectormatch = "("; + for (selectorpos; selectorpos > 1; selectorpos--) { + selectormatch = selectormatch + "[^}]*?}"; + } + selectormatch = selectormatch + ")([^}]*?})((.|\n)*)"; + Inkscape::XML::Node *textNode = _getStyleTextNode(); + std::regex e(selectormatch.c_str()); + std::string content = (textNode->content() ? textNode->content() : ""); + std::string result; + std::regex_replace(std::back_inserter(result), content.begin(), content.end(), e, "$1" + styleContent + "$3"); + textNode->setContent(result.c_str()); + for (auto iter : document->getObjectsByClass(selector)) { + iter->style->readFromObject(iter); + iter->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); + } + } + /* if (selector == "attributes") { for (auto iter : obj->style->properties()) { if (iter->style_src != SP_STYLE_SRC_UNSET) { if (iter->name != "font" && iter->name != "d" && iter->name != "marker") { @@ -837,23 +859,7 @@ void StyleDialog::_writeStyleElement(Glib::RefPtr store, Glib::u obj->getRepr()->setAttribute(name.c_str(), value); } } - } else if (!selector.empty()) { // styleshet - // We could test if styleContent is empty and then delete the style node here but there is no - // harm in keeping it around ... - SP_ACTIVE_DOCUMENT->setStyleSheet(nullptr); - std::string pos = std::to_string(selectorpos); - std::string selectormatch = "("; - for (selectorpos; selectorpos > 2; selectorpos--) { - selectormatch = selectormatch + "[^}]*?}"; - } - selectormatch = selectormatch + ")([^}]*?})((.|\n)*)"; - Inkscape::XML::Node *textNode = _getStyleTextNode(); - std::regex e(selectormatch.c_str()); - std::string content = (textNode->content() ? textNode->content() : ""); - std::string result; - std::regex_replace(std::back_inserter(result), content.begin(), content.end(), e, "$1" + styleContent + "$3"); - textNode->setContent(result.c_str()); - } + } else */ _readStyleElement(); DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_DIALOG_STYLE, _("Edited style element.")); @@ -875,7 +881,7 @@ bool StyleDialog::_addRow(GdkEventButton *evt, Glib::RefPtr stor row[_mColumns._colValue] = ""; row[_mColumns._colStrike] = false; gint col = 2; - if (pos < 2) { + if (pos < 1) { col = 1; } css_tree->set_cursor(path, *(css_tree->get_column(col)), true); @@ -910,7 +916,7 @@ void StyleDialog::_nameEdited(const Glib::ustring &path, const Glib::ustring &na store->erase(row); } gint col = 3; - if (pos < 2) { + if (pos < 1) { col = 2; } if (write) { diff --git a/src/ui/widget/ink-flow-box.cpp b/src/ui/widget/ink-flow-box.cpp index c753a41da..5b108ebb6 100644 --- a/src/ui/widget/ink-flow-box.cpp +++ b/src/ui/widget/ink-flow-box.cpp @@ -30,7 +30,7 @@ InkFlowBox::InkFlowBox(const gchar *name) tbutton->set_always_show_image(true); _flowbox.set_selection_mode(Gtk::SelectionMode::SELECTION_NONE); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - tbutton->set_active(prefs->getBool(Glib::ustring("/dialogs/") + get_name() + Glib::ustring("/flowbox/lock"), true)); + tbutton->set_active(true);// commented for furter use prefs->getBool(Glib::ustring("/dialogs/") + get_name() + Glib::ustring("/flowbox/lock"), true)); Glib::ustring iconname = "object-unlocked"; if (tbutton->get_active()) { iconname = "object-locked"; @@ -38,8 +38,8 @@ InkFlowBox::InkFlowBox(const gchar *name) tbutton->set_image(*sp_get_icon_image(iconname, Gtk::ICON_SIZE_MENU)); tbutton->signal_toggled().connect( sigc::bind(sigc::mem_fun(*this, &InkFlowBox::on_global_toggle), tbutton)); - _controller.pack_start(*tbutton); - tbutton->show(); + //_controller.pack_start(*tbutton); + //tbutton->show(); showing = 0; sensitive = true; } -- cgit v1.2.3