diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2019-05-29 09:20:37 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2019-06-02 09:50:17 +0000 |
| commit | 930ca25606ddefe59afa37f32c823bedcea8ed30 (patch) | |
| tree | 13c77bfb2faa8e78fc9512dc54c32f640b25e1d7 | |
| parent | Fixed UI issues (diff) | |
| download | inkscape-930ca25606ddefe59afa37f32c823bedcea8ed30.tar.gz inkscape-930ca25606ddefe59afa37f32c823bedcea8ed30.zip | |
Fixing coding style
| -rw-r--r-- | clang_format_diff | 1476 | ||||
| -rw-r--r-- | src/style.cpp | 11 | ||||
| -rw-r--r-- | src/ui/dialog/attrdialog.cpp | 6 | ||||
| -rw-r--r-- | src/ui/dialog/selectordialog.cpp | 71 | ||||
| -rw-r--r-- | src/ui/dialog/selectordialog.h | 16 | ||||
| -rw-r--r-- | src/ui/dialog/styledialog.cpp | 437 | ||||
| -rw-r--r-- | src/ui/dialog/styledialog.h | 73 | ||||
| -rw-r--r-- | src/ui/dialog/xml-tree.cpp | 4 | ||||
| -rw-r--r-- | src/ui/dialog/xml-tree.h | 4 | ||||
| -rw-r--r-- | src/ui/icon-loader.cpp | 2 |
10 files changed, 1786 insertions, 314 deletions
diff --git a/clang_format_diff b/clang_format_diff new file mode 100644 index 000000000..4999b6f40 --- /dev/null +++ b/clang_format_diff @@ -0,0 +1,1476 @@ +--- src/ui/dialog/styledialog.h (before formatting) ++++ src/ui/dialog/styledialog.h (after formatting) +@@ -15,18 +15,18 @@ + #ifndef STYLEDIALOG_H + #define STYLEDIALOG_H + +-#include <ui/widget/panel.h> +-#include <gtkmm/treeview.h> +-#include <gtkmm/treestore.h> +-#include <gtkmm/treemodelfilter.h> +-#include <gtkmm/scrolledwindow.h> ++#include <glibmm/regex.h> ++#include <gtkmm/builder.h> + #include <gtkmm/dialog.h> +-#include <gtkmm/treeselection.h> +-#include <gtkmm/switch.h> + #include <gtkmm/eventbox.h> + #include <gtkmm/paned.h> +-#include <glibmm/regex.h> +-#include <gtkmm/builder.h> ++#include <gtkmm/scrolledwindow.h> ++#include <gtkmm/switch.h> ++#include <gtkmm/treemodelfilter.h> ++#include <gtkmm/treeselection.h> ++#include <gtkmm/treestore.h> ++#include <gtkmm/treeview.h> ++#include <ui/widget/panel.h> + + #include "ui/dialog/desktop-tracker.h" + +@@ -49,7 +49,7 @@ + */ + class StyleDialog : public Widget::Panel { + +-public: ++ public: + ~StyleDialog() override; + // No default constructor, noncopyable, nonassignable + StyleDialog(); +@@ -57,6 +57,7 @@ + StyleDialog operator=(StyleDialog const &d) = delete; + + static StyleDialog &getInstance() { return *new StyleDialog(); } ++ + private: + // Monitor <style> element for changes. + class NodeObserver; +@@ -64,15 +65,16 @@ + class NodeWatcher; + Glib::RefPtr<Glib::Regex> r_props = Glib::Regex::create("\\s*;\\s*"); + Glib::RefPtr<Glib::Regex> r_pair = Glib::Regex::create("\\s*:\\s*"); +- std::vector<StyleDialog::NodeWatcher*> _nodeWatchers; +- void _nodeAdded( Inkscape::XML::Node &repr ); +- void _nodeRemoved( Inkscape::XML::Node &repr ); +- void _nodeChanged( Inkscape::XML::Node &repr ); ++ std::vector<StyleDialog::NodeWatcher *> _nodeWatchers; ++ void _nodeAdded(Inkscape::XML::Node &repr); ++ void _nodeRemoved(Inkscape::XML::Node &repr); ++ void _nodeChanged(Inkscape::XML::Node &repr); + /* void _stylesheetChanged( Inkscape::XML::Node &repr ); */ + // Data structure + class ModelColumns : public Gtk::TreeModel::ColumnRecord { +- public: +- ModelColumns() { ++ public: ++ ModelColumns() ++ { + add(_colActive); + add(_colName); + add(_colValue); +@@ -80,36 +82,37 @@ + add(_colSelector); + add(_colSelectorPos); + } +- Gtk::TreeModelColumn<bool> _colActive; // Active or inative property +- Gtk::TreeModelColumn<Glib::ustring> _colName; // Name of the property. +- Gtk::TreeModelColumn<Glib::ustring> _colValue; // Value of the property. +- Gtk::TreeModelColumn<bool> _colStrike; // Propery not used, overloaded +- Gtk::TreeModelColumn<Glib::ustring> _colSelector; // Style or matching object id. +- Gtk::TreeModelColumn<gint> _colSelectorPos; // Position of the selector to hadle dup selectors +- ++ Gtk::TreeModelColumn<bool> _colActive; // Active or inative property ++ Gtk::TreeModelColumn<Glib::ustring> _colName; // Name of the property. ++ Gtk::TreeModelColumn<Glib::ustring> _colValue; // Value of the property. ++ Gtk::TreeModelColumn<bool> _colStrike; // Propery not used, overloaded ++ Gtk::TreeModelColumn<Glib::ustring> _colSelector; // Style or matching object id. ++ Gtk::TreeModelColumn<gint> _colSelectorPos; // Position of the selector to hadle dup selectors + }; + ModelColumns _mColumns; + + // Widgets + Gtk::ScrolledWindow _scrolledWindow; +- Gtk::Box _mainBox; +- Gtk::Box _styleBox; ++ Gtk::Box _mainBox; ++ Gtk::Box _styleBox; + Gtk::Switch *_all_css; + // Reading and writing the style element. + Inkscape::XML::Node *_getStyleTextNode(); + void _readStyleElement(); +- Glib::RefPtr< Gtk::TreeModel > _selectTree(Glib::ustring selector); ++ Glib::RefPtr<Gtk::TreeModel> _selectTree(Glib::ustring selector); + void _writeStyleElement(Glib::RefPtr<Gtk::TreeStore> store, Glib::ustring selector); +- void _activeToggled(const Glib::ustring& path, Glib::RefPtr<Gtk::TreeStore> store); +- bool _addRow(GdkEventButton *evt, Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeView *css_tree, Glib::ustring selector, gint pos); +- void _nameEdited(const Glib::ustring& path, const Glib::ustring& name, Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeView *css_tree); +- void _valueEdited(const Glib::ustring& path, const Glib::ustring& value, Glib::RefPtr<Gtk::TreeStore> store); ++ void _activeToggled(const Glib::ustring &path, Glib::RefPtr<Gtk::TreeStore> store); ++ bool _addRow(GdkEventButton *evt, Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeView *css_tree, ++ Glib::ustring selector, gint pos); ++ void _nameEdited(const Glib::ustring &path, const Glib::ustring &name, Glib::RefPtr<Gtk::TreeStore> store, ++ Gtk::TreeView *css_tree); ++ void _valueEdited(const Glib::ustring &path, const Glib::ustring &value, Glib::RefPtr<Gtk::TreeStore> store); + void _onPropDelete(Glib::ustring path, Glib::RefPtr<Gtk::TreeStore> store); + void _reload(); + + // Update watchers + void _addWatcherRecursive(Inkscape::XML::Node *node); +- void _updateWatchers(); ++ void _updateWatchers(); + + // Manipulate Tree + std::vector<SPObject *> _getObjVec(Glib::ustring selector); +@@ -117,21 +120,21 @@ + + // Variables + Inkscape::XML::Node *_textNode; // Track so we know when to add a NodeObserver. +- bool _updating; // Prevent cyclic actions: read <-> write, select via dialog <-> via desktop ++ bool _updating; // Prevent cyclic actions: read <-> write, select via dialog <-> via desktop + + // Signals and handlers - External + sigc::connection _document_replaced_connection; + sigc::connection _desktop_changed_connection; + sigc::connection _selection_changed_connection; + +- void _handleDocumentReplaced(SPDesktop* desktop, SPDocument *document); +- void _handleDesktopChanged(SPDesktop* desktop); ++ void _handleDocumentReplaced(SPDesktop *desktop, SPDocument *document); ++ void _handleDesktopChanged(SPDesktop *desktop); + void _handleSelectionChanged(); + void _closeDialog(Gtk::Dialog *textDialogPtr); + DesktopTracker _desktopTracker; + }; + +-} // namespace Dialogc ++} // namespace Dialog + } // namespace UI + } // namespace Inkscape + +--- src/ui/dialog/xml-tree.cpp (before formatting) ++++ src/ui/dialog/xml-tree.cpp (after formatting) +@@ -356,11 +356,11 @@ + repr->type() == Inkscape::XML::COMMENT_NODE)) + { + attributes->setRepr(repr); +- //styles->setRepr(repr); ++ // styles->setRepr(repr); + // selectors->setRepr(repr); + } else { + attributes->setRepr(nullptr); +- //styles->setRepr(nullptr); ++ // styles->setRepr(nullptr); + // selectors->setRepr(nullptr); + } + } +--- src/ui/dialog/xml-tree.h (before formatting) ++++ src/ui/dialog/xml-tree.h (after formatting) +@@ -27,10 +27,10 @@ + + #include "message.h" + ++#include "ui/dialog/attrdialog.h" ++#include "ui/dialog/desktop-tracker.h" + #include "ui/dialog/selectordialog.h" +-#include "ui/dialog/attrdialog.h" + #include "ui/dialog/styledialog.h" +-#include "ui/dialog/desktop-tracker.h" + + + class SPDesktop; +--- src/ui/dialog/styledialog.cpp (before formatting) ++++ src/ui/dialog/styledialog.cpp (after formatting) +@@ -13,24 +13,23 @@ + */ + + #include "styledialog.h" ++#include "attribute-rel-svg.h" + #include "attributes.h" +-#include "verbs.h" +-#include "selection.h" +-#include "attribute-rel-svg.h" ++#include "document-undo.h" + #include "inkscape.h" +-#include "document-undo.h" ++#include "io/resource.h" + #include "selection.h" + #include "style-internal.h" + #include "style.h" +-#include "io/resource.h" + #include "ui/icon-loader.h" + #include "ui/widget/iconrenderer.h" ++#include "verbs.h" + + #include "xml/attribute-record.h" + #include "xml/node-observer.h" + ++#include <map> + #include <regex> +-#include <map> + #include <utility> + + #include <glibmm/i18n.h> +@@ -46,7 +45,8 @@ + * This macro is used to remove spaces around selectors or any strings when + * parsing is done to update XML style element or row labels in this dialog. + */ +-#define REMOVE_SPACES(x) x.erase(0, x.find_first_not_of(' ')); \ ++#define REMOVE_SPACES(x) \ ++ x.erase(0, x.find_first_not_of(' ')); \ + x.erase(x.find_last_not_of(' ') + 1); + + namespace Inkscape { +@@ -55,26 +55,24 @@ + + // Keeps a watch on style element + class StyleDialog::NodeObserver : public Inkscape::XML::NodeObserver { +-public: +- NodeObserver(StyleDialog* styledialog) : +- _styledialog(styledialog) ++ public: ++ NodeObserver(StyleDialog *styledialog) ++ : _styledialog(styledialog) + { + g_debug("StyleDialog::NodeObserver: Constructor"); + }; + +- void notifyContentChanged(Inkscape::XML::Node &node, +- Inkscape::Util::ptr_shared old_content, +- Inkscape::Util::ptr_shared new_content) override; +- +- StyleDialog * _styledialog; ++ void notifyContentChanged(Inkscape::XML::Node &node, Inkscape::Util::ptr_shared old_content, ++ Inkscape::Util::ptr_shared new_content) override; ++ ++ StyleDialog *_styledialog; + }; + + +-void +-StyleDialog::NodeObserver::notifyContentChanged( +- Inkscape::XML::Node &/*node*/, +- Inkscape::Util::ptr_shared /*old_content*/, +- Inkscape::Util::ptr_shared /*new_content*/ ) { ++void StyleDialog::NodeObserver::notifyContentChanged(Inkscape::XML::Node & /*node*/, ++ Inkscape::Util::ptr_shared /*old_content*/, ++ Inkscape::Util::ptr_shared /*new_content*/) ++{ + + g_debug("StyleDialog::NodeObserver::notifyContentChanged"); + _styledialog->_updating = false; +@@ -85,61 +83,58 @@ + // Keeps a watch for new/removed/changed nodes + // (Must update objects that selectors match.) + class StyleDialog::NodeWatcher : public Inkscape::XML::NodeObserver { +-public: +- NodeWatcher(StyleDialog* styledialog, Inkscape::XML::Node *repr) : +- _styledialog(styledialog), +- _repr(repr) ++ public: ++ NodeWatcher(StyleDialog *styledialog, Inkscape::XML::Node *repr) ++ : _styledialog(styledialog) ++ , _repr(repr) + { + g_debug("StyleDialog::NodeWatcher: Constructor"); + }; + +- void notifyChildAdded( Inkscape::XML::Node &/*node*/, +- Inkscape::XML::Node &child, +- Inkscape::XML::Node */*prev*/ ) override ++ void notifyChildAdded(Inkscape::XML::Node & /*node*/, Inkscape::XML::Node &child, ++ Inkscape::XML::Node * /*prev*/) override + { +- if ( _styledialog && _repr ) { +- _styledialog->_nodeAdded( child ); +- } +- } +- +- void notifyChildRemoved( Inkscape::XML::Node &/*node*/, +- Inkscape::XML::Node &child, +- Inkscape::XML::Node */*prev*/ ) override ++ if (_styledialog && _repr) { ++ _styledialog->_nodeAdded(child); ++ } ++ } ++ ++ void notifyChildRemoved(Inkscape::XML::Node & /*node*/, Inkscape::XML::Node &child, ++ Inkscape::XML::Node * /*prev*/) override + { +- if ( _styledialog && _repr ) { +- _styledialog->_nodeRemoved( child ); +- } +- } +-/* void notifyContentChanged(Inkscape::XML::Node &node, +- Inkscape::Util::ptr_shared old_content, +- Inkscape::Util::ptr_shared new_content) override{ +- if ( _styledialog && _repr && _textNode == node) { +- _styledialog->_stylesheetChanged( node ); +- } +- }; +- */ +- void notifyAttributeChanged( Inkscape::XML::Node &node, +- GQuark qname, +- Util::ptr_shared /*old_value*/, +- Util::ptr_shared /*new_value*/ ) override { +- if ( _styledialog && _repr ) { ++ if (_styledialog && _repr) { ++ _styledialog->_nodeRemoved(child); ++ } ++ } ++ /* void notifyContentChanged(Inkscape::XML::Node &node, ++ Inkscape::Util::ptr_shared old_content, ++ Inkscape::Util::ptr_shared new_content) override{ ++ if ( _styledialog && _repr && _textNode == node) { ++ _styledialog->_stylesheetChanged( node ); ++ } ++ }; ++ */ ++ void notifyAttributeChanged(Inkscape::XML::Node &node, GQuark qname, Util::ptr_shared /*old_value*/, ++ Util::ptr_shared /*new_value*/) override ++ { ++ if (_styledialog && _repr) { + + // For the moment only care about attributes that are directly used in selectors. +- const gchar * cname = g_quark_to_string (qname); ++ const gchar *cname = g_quark_to_string(qname); + Glib::ustring name; + if (cname) { + name = cname; + } + +- if ( name == "id" || name == "class" || name == "style" ) { +- _styledialog->_nodeChanged( node ); ++ if (name == "id" || name == "class" || name == "style") { ++ _styledialog->_nodeChanged(node); + } + SPObject *obj = SP_ACTIVE_DOCUMENT->getObjectById(node.attribute("id")); + if (obj) { + for (auto iter : obj->style->properties()) { + if (iter->style_src != SP_STYLE_SRC_UNSET) { +- if( iter->name == name) { +- _styledialog->_nodeChanged( node ); ++ if (iter->name == name) { ++ _styledialog->_nodeChanged(node); + } + } + } +@@ -147,37 +142,34 @@ + } + } + +- StyleDialog * _styledialog; +- Inkscape::XML::Node * _repr; // Need to track if document changes. ++ StyleDialog *_styledialog; ++ Inkscape::XML::Node *_repr; // Need to track if document changes. + }; + +-void +-StyleDialog::_nodeAdded( Inkscape::XML::Node &node ) { +- +- StyleDialog::NodeWatcher *w = new StyleDialog::NodeWatcher (this, &node); +- node.addObserver (*w); ++void StyleDialog::_nodeAdded(Inkscape::XML::Node &node) ++{ ++ ++ StyleDialog::NodeWatcher *w = new StyleDialog::NodeWatcher(this, &node); ++ node.addObserver(*w); + _nodeWatchers.push_back(w); + + _readStyleElement(); + } + +-void +-StyleDialog::_nodeRemoved( Inkscape::XML::Node &repr ) { ++void StyleDialog::_nodeRemoved(Inkscape::XML::Node &repr) ++{ + + for (auto it = _nodeWatchers.begin(); it != _nodeWatchers.end(); ++it) { +- if ( (*it)->_repr == &repr ) { +- (*it)->_repr->removeObserver (**it); +- _nodeWatchers.erase( it ); ++ if ((*it)->_repr == &repr) { ++ (*it)->_repr->removeObserver(**it); ++ _nodeWatchers.erase(it); + break; + } + } + _readStyleElement(); + } + +-void +-StyleDialog::_nodeChanged( Inkscape::XML::Node &object ) { +- _readStyleElement(); +-} ++void StyleDialog::_nodeChanged(Inkscape::XML::Node &object) { _readStyleElement(); } + + /* void + StyleDialog::_stylesheetChanged( Inkscape::XML::Node &repr ) { +@@ -191,11 +183,11 @@ + * adds selectors to treeview. _delSelector deletes the selector from the dialog. + * Any addition/deletion of the selectors updates XML style element accordingly. + */ +-StyleDialog::StyleDialog() : +- UI::Widget::Panel("/dialogs/style", SP_VERB_DIALOG_STYLE), +- _updating(false), +- _textNode(nullptr), +- _desktopTracker() ++StyleDialog::StyleDialog() ++ : UI::Widget::Panel("/dialogs/style", SP_VERB_DIALOG_STYLE) ++ , _updating(false) ++ , _textNode(nullptr) ++ , _desktopTracker() + { + g_debug("StyleDialog::StyleDialog"); + // Pack widgets +@@ -204,8 +196,8 @@ + _styleBox.set_orientation(Gtk::ORIENTATION_VERTICAL); + _styleBox.set_valign(Gtk::ALIGN_START); + _scrolledWindow.add(_styleBox); +- Gtk::Box *alltoggler = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL)); +- Gtk::Label *infotoggler = Gtk::manage(new Gtk::Label(_("Edit Full Stylesheet"))); ++ 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); +@@ -218,13 +210,13 @@ + _mainBox.set_orientation(Gtk::ORIENTATION_VERTICAL); + _getContents()->pack_start(_mainBox, Gtk::PACK_EXPAND_WIDGET); + // Document & Desktop +- _desktop_changed_connection = _desktopTracker.connectDesktopChanged( +- sigc::mem_fun(*this, &StyleDialog::_handleDesktopChanged) ); ++ _desktop_changed_connection = ++ _desktopTracker.connectDesktopChanged(sigc::mem_fun(*this, &StyleDialog::_handleDesktopChanged)); + _desktopTracker.connect(GTK_WIDGET(gobj())); + +- _document_replaced_connection = getDesktop()->connectDocumentReplaced( +- sigc::mem_fun(this, &StyleDialog::_handleDocumentReplaced)); +- ++ _document_replaced_connection = ++ getDesktop()->connectDocumentReplaced(sigc::mem_fun(this, &StyleDialog::_handleDocumentReplaced)); ++ + _selection_changed_connection = getDesktop()->getSelection()->connectChanged( + sigc::hide(sigc::mem_fun(this, &StyleDialog::_handleSelectionChanged))); + // Add watchers +@@ -245,18 +237,14 @@ + _selection_changed_connection.disconnect(); + } + +-void +-StyleDialog::_reload() +-{ +- _readStyleElement(); +-} ++void StyleDialog::_reload() { _readStyleElement(); } + + /** + * @return Inkscape::XML::Node* pointing to a style element's text node. + * Returns the style element's text node. If there is no style element, one is created. + * Ditto for text node. + */ +-Inkscape::XML::Node* StyleDialog::_getStyleTextNode() ++Inkscape::XML::Node *StyleDialog::_getStyleTextNode() + { + + Inkscape::XML::Node *styleNode = nullptr; +@@ -287,7 +275,7 @@ + if (styleNode == nullptr) { + // Style element not found, create one + styleNode = SP_ACTIVE_DOCUMENT->getReprDoc()->createElement("svg:style"); +- textNode = SP_ACTIVE_DOCUMENT->getReprDoc()->createTextNode(""); ++ textNode = SP_ACTIVE_DOCUMENT->getReprDoc()->createTextNode(""); + + styleNode->appendChild(textNode); + Inkscape::GC::release(textNode); +@@ -305,35 +293,33 @@ + return textNode; + } + +-Glib::RefPtr< Gtk::TreeModel > StyleDialog::_selectTree(Glib::ustring selector) +-{ +- Gtk::Label * selectorlabel; +- Glib::RefPtr< Gtk::TreeModel > model; +- for (auto fullstyle:_styleBox.get_children()){ ++Glib::RefPtr<Gtk::TreeModel> StyleDialog::_selectTree(Glib::ustring selector) ++{ ++ Gtk::Label *selectorlabel; ++ Glib::RefPtr<Gtk::TreeModel> model; ++ for (auto fullstyle : _styleBox.get_children()) { + Gtk::Box *style = dynamic_cast<Gtk::Box *>(fullstyle); +- for (auto stylepart:style->get_children()){ ++ for (auto stylepart : style->get_children()) { + switch (style->child_property_position(*stylepart)) { +- case 0: +- { +- Gtk::Box *selectorbox = dynamic_cast<Gtk::Box *>(stylepart); +- for (auto styleheader:selectorbox->get_children()){ +- if (!selectorbox->child_property_position(*styleheader)) { +- selectorlabel = dynamic_cast<Gtk::Label *>(styleheader); +- } ++ case 0: { ++ Gtk::Box *selectorbox = dynamic_cast<Gtk::Box *>(stylepart); ++ for (auto styleheader : selectorbox->get_children()) { ++ if (!selectorbox->child_property_position(*styleheader)) { ++ selectorlabel = dynamic_cast<Gtk::Label *>(styleheader); + } +- break; + } +- case 1: +- { +- Glib::ustring wdg_selector = selectorlabel->get_text(); +- if (wdg_selector == selector){ +- Gtk::TreeView* treeview = dynamic_cast<Gtk::TreeView *>(stylepart); +- if (treeview) { +- return treeview->get_model(); +- } ++ break; ++ } ++ case 1: { ++ Glib::ustring wdg_selector = selectorlabel->get_text(); ++ if (wdg_selector == selector) { ++ Gtk::TreeView *treeview = dynamic_cast<Gtk::TreeView *>(stylepart); ++ if (treeview) { ++ return treeview->get_model(); + } +- break; + } ++ break; ++ } + default: + break; + } +@@ -349,10 +335,11 @@ + { + g_debug("StyleDialog::_readStyleElement"); + +- if (_updating) return; // Don't read if we wrote style element. ++ if (_updating) ++ return; // Don't read if we wrote style element. + _updating = true; + +- Inkscape::XML::Node * textNode = _getStyleTextNode(); ++ Inkscape::XML::Node *textNode = _getStyleTextNode(); + if (textNode == nullptr) { + std::cerr << "StyleDialog::_readStyleElement: No text node!" << std::endl; + } +@@ -370,11 +357,8 @@ + size_t open = content.find("{", start + 1); + size_t close = content.find("}", start + 1); + size_t end = content.find("*/", close + 1); +- while(!breakme) { +- if (open == std::string::npos || +- close == std::string::npos || +- end == std::string::npos) +- { ++ while (!breakme) { ++ if (open == std::string::npos || close == std::string::npos || end == std::string::npos) { + breakme = true; + break; + } +@@ -383,10 +367,7 @@ + close = content.find("}", close + 1); + end = content.find("*/", close + 1); + size_t reopen = content.find("{", close + 1); +- if (open == std::string::npos || +- end == std::string::npos || +- end < reopen) +- { ++ if (open == std::string::npos || end == std::string::npos || end < reopen) { + if (end < reopen) { + content = content.erase(start, end - start + 2); + } else { +@@ -417,13 +398,13 @@ + + // If text node is empty, return (avoids problem with negative below). + +- for (auto child:_styleBox.get_children()) { ++ for (auto child : _styleBox.get_children()) { + _styleBox.remove(*child); + delete child; + } +- Inkscape::Selection* selection = getDesktop()->getSelection(); ++ Inkscape::Selection *selection = getDesktop()->getSelection(); + SPObject *obj = nullptr; +- if(selection->objects().size() == 1) { ++ if (selection->objects().size() == 1) { + obj = selection->objects().back(); + } + +@@ -448,28 +429,30 @@ + _builder->get_widget("CSSTree", css_tree); + Glib::RefPtr<Gtk::TreeStore> store = Gtk::TreeStore::create(_mColumns); + css_tree->set_model(store); +- // We need to handle comments on SPStyle to activate ++ // We need to handle comments on SPStyle to activate + /* Gtk::CellRendererToggle *active = Gtk::manage(new Gtk::CellRendererToggle); + int addCol = css_tree->append_column("", *active) - 1; + Gtk::TreeViewColumn *col = css_tree->get_column(addCol); + if (col) { + col->add_attribute(active->property_active(), _mColumns._colActive); + } */ +- ++ + css_selector_event_add->signal_button_release_event().connect( +- sigc::bind<Glib::RefPtr<Gtk::TreeStore>, Gtk::TreeView *, Glib::ustring, gint>( +- sigc::mem_fun(*this, &StyleDialog::_addRow), store, css_tree, "style_properties", selectorpos)); +- Inkscape::UI::Widget::IconRenderer * addRenderer = manage(new Inkscape::UI::Widget::IconRenderer()); ++ sigc::bind<Glib::RefPtr<Gtk::TreeStore>, Gtk::TreeView *, Glib::ustring, gint>( ++ sigc::mem_fun(*this, &StyleDialog::_addRow), store, css_tree, "style_properties", selectorpos)); ++ 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<Glib::RefPtr<Gtk::TreeStore> >(sigc::mem_fun(*this, &StyleDialog::_onPropDelete), store)); ++ addRenderer->signal_activated().connect( ++ sigc::bind<Glib::RefPtr<Gtk::TreeStore>>(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< Glib::RefPtr<Gtk::TreeStore>, Gtk::TreeView *>(sigc::mem_fun(*this, &StyleDialog::_nameEdited), store, css_tree)); ++ label->signal_edited().connect(sigc::bind<Glib::RefPtr<Gtk::TreeStore>, 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) { +@@ -478,7 +461,8 @@ + Gtk::CellRendererText *value = Gtk::manage(new Gtk::CellRendererText()); + value->property_placeholder_text() = _("value"); + value->property_editable() = true; +- value->signal_edited().connect(sigc::bind<Glib::RefPtr<Gtk::TreeStore> >(sigc::mem_fun(*this, &StyleDialog::_valueEdited), store)); ++ value->signal_edited().connect( ++ sigc::bind<Glib::RefPtr<Gtk::TreeStore>>(sigc::mem_fun(*this, &StyleDialog::_valueEdited), store)); + addCol = css_tree->append_column("CSS Value", *value) - 1; + col = css_tree->get_column(addCol); + if (col) { +@@ -488,7 +472,7 @@ + std::map<Glib::ustring, Glib::ustring> attr_prop; + if (obj || _all_css->get_active()) { + Gtk::TreeModel::Path path; +- if(!_all_css->get_active() && obj && obj->getRepr()->attribute("style")) { ++ if (!_all_css->get_active() && obj && obj->getRepr()->attribute("style")) { + Glib::ustring style = obj->getRepr()->attribute("style"); + attr_prop = parseStyle(style); + for (auto iter : obj->style->properties()) { +@@ -502,9 +486,9 @@ + row[_mColumns._colStrike] = false; + } + } +- _styleBox.pack_start(*css_selector_container, Gtk::PACK_EXPAND_WIDGET); +- } +- selectorpos ++; ++ _styleBox.pack_start(*css_selector_container, Gtk::PACK_EXPAND_WIDGET); ++ } ++ selectorpos++; + try { + _builder = Gtk::Builder::create_from_file(gladefile); + } catch (const Glib::Error &ex) { +@@ -520,27 +504,31 @@ + _builder->get_widget("CSSTree", css_tree); + css_tree->set_model(store); + css_selector_event_add->signal_button_release_event().connect( +- sigc::bind<Glib::RefPtr<Gtk::TreeStore>, Gtk::TreeView *, Glib::ustring, gint>( +- sigc::mem_fun(*this, &StyleDialog::_addRow), store, css_tree, "attributes", selectorpos)); ++ sigc::bind<Glib::RefPtr<Gtk::TreeStore>, Gtk::TreeView *, Glib::ustring, gint>( ++ sigc::mem_fun(*this, &StyleDialog::_addRow), store, css_tree, "attributes", selectorpos)); + bool hasattributes = false; +- if(!_all_css->get_active()) { ++ 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") { ++ 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()); ++ 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<Glib::RefPtr<Gtk::TreeStore> >(sigc::mem_fun(*this, &StyleDialog::_onPropDelete), store)); ++ addRenderer->signal_activated().connect(sigc::bind<Glib::RefPtr<Gtk::TreeStore>>( ++ 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< Glib::RefPtr<Gtk::TreeStore>, Gtk::TreeView * >(sigc::mem_fun(*this, &StyleDialog::_nameEdited), store, css_tree)); ++ label->signal_edited().connect( ++ sigc::bind<Glib::RefPtr<Gtk::TreeStore>, 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) { +@@ -549,7 +537,8 @@ + Gtk::CellRendererText *value = Gtk::manage(new Gtk::CellRendererText()); + value->property_placeholder_text() = _("value"); + value->property_editable() = true; +- value->signal_edited().connect(sigc::bind<Glib::RefPtr<Gtk::TreeStore> >(sigc::mem_fun(*this, &StyleDialog::_valueEdited), store)); ++ value->signal_edited().connect(sigc::bind<Glib::RefPtr<Gtk::TreeStore>>( ++ sigc::mem_fun(*this, &StyleDialog::_valueEdited), store)); + addCol = css_tree->append_column("CSS Value", *value) - 1; + col = css_tree->get_column(addCol); + if (col) { +@@ -574,18 +563,18 @@ + } + } + if (!hasattributes) { +- for (auto widg:css_selector_container->get_children()) { ++ for (auto widg : css_selector_container->get_children()) { + delete widg; + } + } + _styleBox.pack_start(*css_selector_container, Gtk::PACK_EXPAND_WIDGET); + } +- selectorpos ++; ++ selectorpos++; + if (tokens.size() == 0) { + _updating = false; + return; + } +- for (unsigned i = 0; i < tokens.size()-1; i += 2) { ++ for (unsigned i = 0; i < tokens.size() - 1; i += 2) { + Glib::ustring selector = tokens[i]; + REMOVE_SPACES(selector); // Remove leading/trailing spaces + std::vector<Glib::ustring> tokensplus = Glib::Regex::split_simple("[,]+", selector); +@@ -593,27 +582,28 @@ + REMOVE_SPACES(tok); + } + // Get list of objects selector matches +- std::vector<SPObject *> objVec = _getObjVec( selector ); ++ std::vector<SPObject *> objVec = _getObjVec(selector); + if (!_all_css->get_active()) { + bool stop = true; +- for (auto objel:objVec) { +- if (objel->getId() == obj->getId()){ ++ for (auto objel : objVec) { ++ if (objel->getId() == obj->getId()) { + stop = false; + } + } + if (stop) { + _updating = false; +- selectorpos ++; ++ selectorpos++; + continue; + } + } + Glib::ustring properties; + // Check to make sure we do have a value to match selector. +- if ((i+1) < tokens.size()) { +- properties = tokens[i+1]; ++ if ((i + 1) < tokens.size()) { ++ properties = tokens[i + 1]; + } else { + std::cerr << "StyleDialog::_readStyleElement: Missing values " +- "for last selector!" << std::endl; ++ "for last selector!" ++ << std::endl; + } + Glib::RefPtr<Gtk::Builder> _builder; + try { +@@ -634,24 +624,27 @@ + _builder->get_widget("CSSTree", css_tree); + Glib::RefPtr<Gtk::TreeStore> store = Gtk::TreeStore::create(_mColumns); + css_tree->set_model(store); +- Inkscape::UI::Widget::IconRenderer * addRenderer = manage(new Inkscape::UI::Widget::IconRenderer()); ++ 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<Glib::RefPtr<Gtk::TreeStore> >(sigc::mem_fun(*this, &StyleDialog::_onPropDelete), store)); +- } ++ addRenderer->signal_activated().connect( ++ sigc::bind<Glib::RefPtr<Gtk::TreeStore>>(sigc::mem_fun(*this, &StyleDialog::_onPropDelete), store)); ++ } + Gtk::CellRendererToggle *active = Gtk::manage(new Gtk::CellRendererToggle); + addCol = css_tree->append_column("Active Property", *active) - 1; + col = css_tree->get_column(addCol); + if (col) { + col->add_attribute(active->property_active(), _mColumns._colActive); +- active->signal_toggled().connect(sigc::bind<Glib::RefPtr<Gtk::TreeStore> >(sigc::mem_fun(*this, &StyleDialog::_activeToggled), store)); ++ active->signal_toggled().connect(sigc::bind<Glib::RefPtr<Gtk::TreeStore>>( ++ sigc::mem_fun(*this, &StyleDialog::_activeToggled), store)); + } + Gtk::CellRendererText *label = Gtk::manage(new Gtk::CellRendererText()); + label->property_placeholder_text() = _("property"); + label->property_editable() = true; +- label->signal_edited().connect(sigc::bind< Glib::RefPtr<Gtk::TreeStore>, Gtk::TreeView * >(sigc::mem_fun(*this, &StyleDialog::_nameEdited), store, css_tree)); ++ label->signal_edited().connect(sigc::bind<Glib::RefPtr<Gtk::TreeStore>, Gtk::TreeView *>( ++ sigc::mem_fun(*this, &StyleDialog::_nameEdited), store, css_tree)); + addCol = css_tree->append_column("CSS Selector", *label) - 1; + col = css_tree->get_column(addCol); + if (col) { +@@ -659,7 +652,8 @@ + } + Gtk::CellRendererText *value = Gtk::manage(new Gtk::CellRendererText()); + value->property_editable() = true; +- value->signal_edited().connect(sigc::bind<Glib::RefPtr<Gtk::TreeStore> >(sigc::mem_fun(*this, &StyleDialog::_valueEdited), store)); ++ value->signal_edited().connect( ++ sigc::bind<Glib::RefPtr<Gtk::TreeStore>>(sigc::mem_fun(*this, &StyleDialog::_valueEdited), store)); + value->property_placeholder_text() = _("value"); + addCol = css_tree->append_column("CSS Value", *value) - 1; + col = css_tree->get_column(addCol); +@@ -669,20 +663,18 @@ + } + Glib::ustring style = properties; + Glib::ustring comments = ""; +- while(style.find("/*") != std::string::npos) { ++ while (style.find("/*") != std::string::npos) { + size_t beg = style.find("/*"); + size_t end = style.find("*/"); +- if (end != std::string::npos && +- beg != std::string::npos) +- { ++ if (end != std::string::npos && beg != std::string::npos) { + comments = comments.append(style, beg + 2, end - beg - 2); + style = style.erase(beg, end - beg + 2); + } + } + std::map<Glib::ustring, Glib::ustring> attr_prop_styleshet = parseStyle(style); + css_selector_event_add->signal_button_release_event().connect( +- sigc::bind<Glib::RefPtr<Gtk::TreeStore>, Gtk::TreeView *, Glib::ustring, gint>( +- sigc::mem_fun(*this, &StyleDialog::_addRow), store, css_tree, selector, selectorpos)); ++ sigc::bind<Glib::RefPtr<Gtk::TreeStore>, Gtk::TreeView *, Glib::ustring, gint>( ++ sigc::mem_fun(*this, &StyleDialog::_addRow), store, css_tree, selector, selectorpos)); + if (!_all_css->get_active()) { + for (auto iter : obj->style->properties()) { + if (iter->style_src != SP_STYLE_SRC_UNSET) { +@@ -713,7 +705,7 @@ + } + } + std::map<Glib::ustring, Glib::ustring> attr_prop_styleshet_comments = parseStyle(comments); +- ++ + for (auto iter : attr_prop_styleshet_comments) { + if (!attr_prop_styleshet.count(iter.first)) { + Gtk::TreeModel::Row row = *(store->append()); +@@ -726,7 +718,7 @@ + } + } + _styleBox.pack_start(*css_selector_container, Gtk::PACK_EXPAND_WIDGET); +- selectorpos ++; ++ selectorpos++; + } + } + _mainBox.show_all_children(); +@@ -743,14 +735,13 @@ + * @return true + * Delete the attribute from the style + */ +-void +-StyleDialog::_onPropDelete(Glib::ustring path, Glib::RefPtr<Gtk::TreeStore> store) ++void StyleDialog::_onPropDelete(Glib::ustring path, Glib::RefPtr<Gtk::TreeStore> store) + { + Gtk::TreeModel::Row row = *store->get_iter(path); + if (row) { +- _updating = true; //to avoid a crash on deleting an obsolete widget ++ _updating = true; // to avoid a crash on deleting an obsolete widget + Glib::ustring selector = row[_mColumns._colSelector]; +- row[_mColumns._colName] = ""; ++ row[_mColumns._colName] = ""; + store->erase(row); + _updating = false; + _writeStyleElement(store, selector); +@@ -763,8 +754,7 @@ + * Convert a style string into a vector map. This should be moved to style.cpp + * + */ +-std::map<Glib::ustring, Glib::ustring> +-StyleDialog::parseStyle(Glib::ustring style_string) ++std::map<Glib::ustring, Glib::ustring> StyleDialog::parseStyle(Glib::ustring style_string) + { + std::map<Glib::ustring, Glib::ustring> ret; + +@@ -794,7 +784,7 @@ + if (_updating) { + return; + } +- Inkscape::Selection* selection = getDesktop()->getSelection(); ++ Inkscape::Selection *selection = getDesktop()->getSelection(); + SPObject *obj = nullptr; + if (selection->objects().size() == 1) { + obj = selection->objects().back(); +@@ -806,37 +796,33 @@ + _updating = true; + gint selectorpos = 0; + std::string styleContent = ""; +- if (selector != "style_properties" && +- selector != "attributes") +- { ++ if (selector != "style_properties" && selector != "attributes") { + styleContent = "\n" + selector + " { \n"; + } +- for (auto& row: store->children()) { ++ for (auto &row : store->children()) { + selector = row[_mColumns._colSelector]; + selectorpos = row[_mColumns._colSelectorPos]; +- Glib::ustring opencomment =""; +- Glib::ustring closecomment = "" ; +- if (selector != "style_properties" && +- selector != "attributes") { ++ Glib::ustring opencomment = ""; ++ Glib::ustring closecomment = ""; ++ if (selector != "style_properties" && selector != "attributes") { + opencomment = row[_mColumns._colActive] ? " " : " /*"; +- closecomment = row[_mColumns._colActive] ? "\n" : "*/\n" ; +- } +- Glib::ustring name = row[_mColumns._colName]; ++ closecomment = row[_mColumns._colActive] ? "\n" : "*/\n"; ++ } ++ Glib::ustring name = row[_mColumns._colName]; + Glib::ustring value = row[_mColumns._colValue]; +- if (!(name.empty() && value.empty())){ ++ if (!(name.empty() && value.empty())) { + styleContent = styleContent + opencomment + name + ":" + value + ";" + closecomment; + } + } +- if (selector != "style_properties" && +- selector != "attributes" ) { ++ if (selector != "style_properties" && selector != "attributes") { + styleContent = styleContent + "}"; + } + if (selector == "style_properties") { +- obj->getRepr()->setAttribute("style",styleContent, false); ++ obj->getRepr()->setAttribute("style", styleContent, false); + } else 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") { ++ if (iter->name != "font" && iter->name != "d" && iter->name != "marker") { + const gchar *attr = obj->getRepr()->attribute(iter->name.c_str()); + if (attr) { + obj->getRepr()->setAttribute(iter->name.c_str(), nullptr); +@@ -844,14 +830,14 @@ + } + } + } +- for (auto& row: store->children()) { +- Glib::ustring name = row[_mColumns._colName]; +- Glib::ustring value = row[_mColumns._colValue]; +- if (!(name.empty() && value.empty())){ ++ for (auto &row : store->children()) { ++ Glib::ustring name = row[_mColumns._colName]; ++ Glib::ustring value = row[_mColumns._colValue]; ++ if (!(name.empty() && value.empty())) { + obj->getRepr()->setAttribute(name.c_str(), value); + } + } +- } else if (!selector.empty()) { //styleshet ++ } 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); +@@ -862,10 +848,10 @@ + } + selectormatch = selectormatch + ")([^}]*?})((.|\n)*)"; + Inkscape::XML::Node *textNode = _getStyleTextNode(); +- std::regex e (selectormatch.c_str()); ++ 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"); ++ std::regex_replace(std::back_inserter(result), content.begin(), content.end(), e, "$1" + styleContent + "$3"); + textNode->setContent(result.c_str()); + } + _readStyleElement(); +@@ -875,19 +861,21 @@ + g_debug("StyleDialog::_writeStyleElement(): | %s |", styleContent.c_str()); + } + +-bool StyleDialog::_addRow(GdkEventButton *evt, Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeView *css_tree, Glib::ustring selector, gint pos) { +- if(evt->type == GDK_BUTTON_RELEASE && evt->button == 1) { ++bool StyleDialog::_addRow(GdkEventButton *evt, Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeView *css_tree, ++ Glib::ustring selector, gint pos) ++{ ++ if (evt->type == GDK_BUTTON_RELEASE && evt->button == 1) { + Gtk::TreeIter iter = store->append(); + Gtk::TreeModel::Path path = (Gtk::TreeModel::Path)iter; + Gtk::TreeModel::Row row = *(iter); + row[_mColumns._colSelector] = selector; + row[_mColumns._colSelectorPos] = pos; + row[_mColumns._colActive] = true; +- row[_mColumns._colName] = ""; ++ row[_mColumns._colName] = ""; + row[_mColumns._colValue] = ""; + row[_mColumns._colStrike] = false; + gint col = 2; +- if (pos < 2 ){ ++ if (pos < 2) { + col = 1; + } + css_tree->set_cursor(path, *(css_tree->get_column(col)), true); +@@ -903,12 +891,13 @@ + * @return + * Called when the name is edited in the TreeView editable column + */ +-void StyleDialog::_nameEdited (const Glib::ustring& path, const Glib::ustring& name, Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeView *css_tree) ++void StyleDialog::_nameEdited(const Glib::ustring &path, const Glib::ustring &name, Glib::RefPtr<Gtk::TreeStore> store, ++ Gtk::TreeView *css_tree) + { + Gtk::TreeModel::Row row = *store->get_iter(path); + Gtk::TreeModel::Path pathel = (Gtk::TreeModel::Path)*store->get_iter(path); + +- if(row) { ++ if (row) { + gint pos = row[_mColumns._colSelectorPos]; + bool write = false; + if (row[_mColumns._colName] != name && row[_mColumns._colValue] != "") { +@@ -917,11 +906,11 @@ + Glib::ustring value = row[_mColumns._colValue]; + Glib::ustring selector = row[_mColumns._colSelector]; + row[_mColumns._colName] = name; +- if(name.empty() && value.empty()) { ++ if (name.empty() && value.empty()) { + store->erase(row); + } + gint col = 3; +- if (pos < 2 ){ ++ if (pos < 2) { + col = 2; + } + if (write) { +@@ -940,31 +929,33 @@ + * @return + * Called when the value is edited in the TreeView editable column + */ +-void StyleDialog::_valueEdited(const Glib::ustring& path, const Glib::ustring& value, Glib::RefPtr<Gtk::TreeStore> store) ++void StyleDialog::_valueEdited(const Glib::ustring &path, const Glib::ustring &value, ++ Glib::RefPtr<Gtk::TreeStore> store) + { + Gtk::TreeModel::Row row = *store->get_iter(path); +- if(row) { ++ if (row) { + row[_mColumns._colValue] = value; + Glib::ustring selector = row[_mColumns._colSelector]; + Glib::ustring name = row[_mColumns._colName]; +- if(name.empty() && value.empty()) { ++ if (name.empty() && value.empty()) { + store->erase(row); + } + _writeStyleElement(store, selector); + } + } + +-void StyleDialog::_activeToggled(const Glib::ustring& path, Glib::RefPtr<Gtk::TreeStore> store) ++void StyleDialog::_activeToggled(const Glib::ustring &path, Glib::RefPtr<Gtk::TreeStore> store) + { + Gtk::TreeModel::Row row = *store->get_iter(path); +- if(row) { ++ if (row) { + row[_mColumns._colActive] = !row[_mColumns._colActive]; + Glib::ustring selector = row[_mColumns._colSelector]; + _writeStyleElement(store, selector); + } + } + +-void StyleDialog::_addWatcherRecursive(Inkscape::XML::Node *node) { ++void StyleDialog::_addWatcherRecursive(Inkscape::XML::Node *node) ++{ + + g_debug("StyleDialog::_addWatcherRecursive()"); + +@@ -1007,12 +998,13 @@ + * @return objVec: a vector of pointers to SPObject's the selector matches. + * Return a vector of all objects that selector matches. + */ +-std::vector<SPObject *> StyleDialog::_getObjVec(Glib::ustring selector) { +- +- std::vector<SPObject *> objVec = SP_ACTIVE_DOCUMENT->getObjectsBySelector( selector ); ++std::vector<SPObject *> StyleDialog::_getObjVec(Glib::ustring selector) ++{ ++ ++ std::vector<SPObject *> objVec = SP_ACTIVE_DOCUMENT->getObjectsBySelector(selector); + + g_debug("StyleDialog::_getObjVec: | %s |", selector.c_str()); +- for (auto& obj: objVec) { ++ for (auto &obj : objVec) { + g_debug(" %s", obj->getId() ? obj->getId() : "null"); + } + +@@ -1026,15 +1018,14 @@ + * Handle document replaced. (Happens when a default document is immediately replaced by another + * document in a new window.) + */ +-void +-StyleDialog::_handleDocumentReplaced(SPDesktop *desktop, SPDocument * /* document */) ++void StyleDialog::_handleDocumentReplaced(SPDesktop *desktop, SPDocument * /* document */) + { + g_debug("StyleDialog::handleDocumentReplaced()"); + + _selection_changed_connection.disconnect(); + +- _selection_changed_connection = desktop->getSelection()->connectChanged( +- sigc::hide(sigc::mem_fun(this, &StyleDialog::_handleSelectionChanged))); ++ _selection_changed_connection = ++ desktop->getSelection()->connectChanged(sigc::hide(sigc::mem_fun(this, &StyleDialog::_handleSelectionChanged))); + + _updateWatchers(); + _readStyleElement(); +@@ -1044,8 +1035,8 @@ + /* + * When a dialog is floating, it is connected to the active desktop. + */ +-void +-StyleDialog::_handleDesktopChanged(SPDesktop* desktop) { ++void StyleDialog::_handleDesktopChanged(SPDesktop *desktop) ++{ + g_debug("StyleDialog::handleDesktopReplaced()"); + + if (getDesktop() == desktop) { +@@ -1057,12 +1048,12 @@ + _selection_changed_connection.disconnect(); + _document_replaced_connection.disconnect(); + +- setDesktop( desktop ); +- +- _selection_changed_connection = desktop->getSelection()->connectChanged( +- sigc::hide(sigc::mem_fun(this, &StyleDialog::_handleSelectionChanged))); +- _document_replaced_connection = desktop->connectDocumentReplaced( +- sigc::mem_fun(this, &StyleDialog::_handleDocumentReplaced)); ++ setDesktop(desktop); ++ ++ _selection_changed_connection = ++ desktop->getSelection()->connectChanged(sigc::hide(sigc::mem_fun(this, &StyleDialog::_handleSelectionChanged))); ++ _document_replaced_connection = ++ desktop->connectDocumentReplaced(sigc::mem_fun(this, &StyleDialog::_handleDocumentReplaced)); + + _updateWatchers(); + _readStyleElement(); +@@ -1072,8 +1063,8 @@ + /* + * Handle a change in which objects are selected in a document. + */ +-void +-StyleDialog::_handleSelectionChanged() { ++void StyleDialog::_handleSelectionChanged() ++{ + g_debug("StyleDialog::_handleSelectionChanged()"); + _readStyleElement(); + } +--- src/ui/dialog/selectordialog.h (before formatting) ++++ src/ui/dialog/selectordialog.h (after formatting) +@@ -15,14 +15,14 @@ + #ifndef SELECTORDIALOG_H + #define SELECTORDIALOG_H + ++#include <gtkmm/dialog.h> ++#include <gtkmm/paned.h> ++#include <gtkmm/scrolledwindow.h> ++#include <gtkmm/treemodelfilter.h> ++#include <gtkmm/treeselection.h> ++#include <gtkmm/treestore.h> ++#include <gtkmm/treeview.h> + #include <ui/widget/panel.h> +-#include <gtkmm/treeview.h> +-#include <gtkmm/treestore.h> +-#include <gtkmm/treemodelfilter.h> +-#include <gtkmm/scrolledwindow.h> +-#include <gtkmm/dialog.h> +-#include <gtkmm/treeselection.h> +-#include <gtkmm/paned.h> + + #include "ui/dialog/desktop-tracker.h" + +@@ -81,7 +81,7 @@ + Gtk::TreeModelColumn<gint> _colType; // Selector row or child object row. + Gtk::TreeModelColumn<std::vector<SPObject *> > _colObj; // List of matching objects. + Gtk::TreeModelColumn<Glib::ustring> _colProperties; // List of properties. +- Gtk::TreeModelColumn<bool> _colVisible; // Make visible or not. ++ Gtk::TreeModelColumn<bool> _colVisible; // Make visible or not. + }; + ModelColumns _mColumns; + +@@ -100,7 +100,7 @@ + void on_row_deleted(const TreeModel::Path& path) override; + + public: +- static Glib::RefPtr<SelectorDialog::TreeStore> create(SelectorDialog *styledialog); ++ static Glib::RefPtr<SelectorDialog::TreeStore> create(SelectorDialog *styledialog); + + private: + SelectorDialog *_selectordialog; +--- src/ui/icon-loader.cpp (before formatting) ++++ src/ui/icon-loader.cpp (after formatting) +@@ -62,7 +62,7 @@ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (prefs->getBool("/theme/symbolicIcons", false)) { + Gtk::IconInfo iconinfo = icon_theme->lookup_icon(icon_name + Glib::ustring("-symbolic"), size, Gtk::ICON_LOOKUP_FORCE_SIZE); +- if (iconinfo) { ++ if (iconinfo) { + bool was_simbolic = false; + _icon_pixbuf = iconinfo.load_symbolic(SP_ACTIVE_DESKTOP->getToplevel()->get_style_context(), was_simbolic); + } else { +--- src/ui/dialog/selectordialog.cpp (before formatting) ++++ src/ui/dialog/selectordialog.cpp (after formatting) +@@ -52,17 +52,17 @@ + // Keeps a watch on style element + class SelectorDialog::NodeObserver : public Inkscape::XML::NodeObserver { + public: +- NodeObserver(SelectorDialog* selectordialog) : +- _selectordialog(selectordialog) +- { +- g_debug("SelectorDialog::NodeObserver: Constructor"); ++ NodeObserver(SelectorDialog *selectordialog) ++ : _selectordialog(selectordialog) ++ { ++ g_debug("SelectorDialog::NodeObserver: Constructor"); + }; + + void notifyContentChanged(Inkscape::XML::Node &node, + Inkscape::Util::ptr_shared old_content, + Inkscape::Util::ptr_shared new_content) override; + +- SelectorDialog * _selectordialog; ++ SelectorDialog *_selectordialog; + }; + + +@@ -83,19 +83,19 @@ + // (Must update objects that selectors match.) + class SelectorDialog::NodeWatcher : public Inkscape::XML::NodeObserver { + public: +- NodeWatcher(SelectorDialog* selectordialog, Inkscape::XML::Node *repr) : +- _selectordialog(selectordialog), +- _repr(repr) +- { +- g_debug("SelectorDialog::NodeWatcher: Constructor"); ++ NodeWatcher(SelectorDialog *selectordialog, Inkscape::XML::Node *repr) ++ : _selectordialog(selectordialog) ++ , _repr(repr) ++ { ++ g_debug("SelectorDialog::NodeWatcher: Constructor"); + }; + + void notifyChildAdded( Inkscape::XML::Node &/*node*/, + Inkscape::XML::Node &child, + Inkscape::XML::Node */*prev*/ ) override + { +- if ( _selectordialog && _repr ) { +- _selectordialog->_nodeAdded( child ); ++ if (_selectordialog && _repr) { ++ _selectordialog->_nodeAdded(child); + } + } + +@@ -103,8 +103,8 @@ + Inkscape::XML::Node &child, + Inkscape::XML::Node */*prev*/ ) override + { +- if ( _selectordialog && _repr ) { +- _selectordialog->_nodeRemoved( child ); ++ if (_selectordialog && _repr) { ++ _selectordialog->_nodeRemoved(child); + } + } + +@@ -112,7 +112,7 @@ + GQuark qname, + Util::ptr_shared /*old_value*/, + Util::ptr_shared /*new_value*/ ) override { +- if ( _selectordialog && _repr ) { ++ if (_selectordialog && _repr) { + + // For the moment only care about attributes that are directly used in selectors. + const gchar * cname = g_quark_to_string (qname ); +@@ -122,12 +122,12 @@ + } + + if ( name == "id" || name == "class" ) { +- _selectordialog->_nodeChanged( node ); +- } +- } +- } +- +- SelectorDialog * _selectordialog; ++ _selectordialog->_nodeChanged(node); ++ } ++ } ++ } ++ ++ SelectorDialog *_selectordialog; + Inkscape::XML::Node * _repr; // Need to track if document changes. + }; + +@@ -243,7 +243,7 @@ + addRenderer->add_icon("edit-delete"); + addRenderer->add_icon("list-add"); + addRenderer->add_icon("object-locked"); +- ++ + _store = TreeStore::create(this); + _treeView.set_model(_store); + +@@ -407,10 +407,10 @@ + content.erase(std::remove(content.begin(), content.end(), '\n'), content.end()); + + // Remove comments (/* xxx */) +-/* while(content.find("/*") != std::string::npos) { +- size_t start = content.find("/*"); +- content.erase(start, (content.find("*\/", start) - start) +2); +- } */ ++ /* while(content.find("/*") != std::string::npos) { ++ size_t start = content.find("/*"); ++ content.erase(start, (content.find("*\/", start) - start) +2); ++ } */ + + // First split into selector/value chunks. + // An attempt to use Glib::Regex failed. A C++11 version worked but +@@ -453,7 +453,7 @@ + for (auto tok : tokensplus) { + REMOVE_SPACES(tok); + if (SPAttributeRelSVG::isSVGElement(tok) || tok.find(" ") != -1 || tok[0] == '>' || tok[0] == '+' || +- tok[0] == '~' || tok[0] == '*' || tok.erase(0, 1).find(".") != -1) { ++ tok[0] == '~' || tok[0] == '*' || tok.erase(0, 1).find(".") != -1) { + colType = UNHANDLED; + } + } +@@ -488,14 +488,15 @@ + Gtk::TreeModel::Row childrow = *(_store->append(row->children())); + childrow[_mColumns._colSelector] = "#" + Glib::ustring(obj->getId()); + childrow[_mColumns._colExpand] = false; +- childrow[_mColumns._colType] = colType == UNHANDLED ? UNHANDLED : OBJECT;; ++ childrow[_mColumns._colType] = colType == UNHANDLED ? UNHANDLED : OBJECT; ++ ; + childrow[_mColumns._colObj] = std::vector<SPObject *>(1, obj); + childrow[_mColumns._colProperties] = ""; // Unused +- childrow[_mColumns._colVisible] = true; // Unused +- } +-} +- +- ++ childrow[_mColumns._colVisible] = true; // Unused ++ } ++ } ++ ++ + _updating = false; + } + +@@ -624,7 +625,7 @@ + childrow[_mColumns._colType] = OBJECT; + childrow[_mColumns._colObj] = std::vector<SPObject *>(1, obj); + childrow[_mColumns._colProperties] = ""; // Unused +- childrow[_mColumns._colVisible] = true; // Unused ++ childrow[_mColumns._colVisible] = true; // Unused + } + } + } +@@ -665,7 +666,7 @@ + childrow[_mColumns._colType] = OBJECT; + childrow[_mColumns._colObj] = std::vector<SPObject *>(1, obj); + childrow[_mColumns._colProperties] = ""; // Unused +- childrow[_mColumns._colVisible] = true; // Unused ++ childrow[_mColumns._colVisible] = true; // Unused + } + } + } +@@ -986,7 +987,7 @@ + textLabelPtr->show(); + } else { + invalid = false; +- } ++ } + } + delete textDialogPtr; + // ==== Handle response ==== +@@ -1209,13 +1210,13 @@ + { + g_debug("SelectorDialog::_selectRow: updating: %s", (_updating ? "true" : "false")); + del->hide(); +- std::vector< Gtk::TreeModel::Path > selectedrows = _treeView.get_selection()->get_selected_rows(); +- if(selectedrows.size() == 1) { ++ std::vector<Gtk::TreeModel::Path> selectedrows = _treeView.get_selection()->get_selected_rows(); ++ if (selectedrows.size() == 1) { + Gtk::TreeModel::Row row = *_store->get_iter(selectedrows[0]); +- if (!row->parent() && row->children().size() < 2 ) { ++ if (!row->parent() && row->children().size() < 2) { + del->show(); + } +- } else if(selectedrows.size() == 0) { ++ } else if (selectedrows.size() == 0) { + del->show(); + } + if (_updating || !getDesktop()) return; // Avoid updating if we have set row via dialog. +@@ -1231,7 +1232,7 @@ + if (!selection->isEmpty()) { + obj = selection->objects().back(); + } +- ++ + for (auto row : children) { + std::vector<SPObject *> objVec = row[_mColumns._colObj]; + if (obj) { +--- src/ui/dialog/attrdialog.cpp (before formatting) ++++ src/ui/dialog/attrdialog.cpp (after formatting) +@@ -18,9 +18,9 @@ + + #include "message-context.h" + #include "message-stack.h" ++#include "style.h" + #include "ui/icon-loader.h" + #include "ui/widget/iconrenderer.h" +-#include "style.h" + + #include "xml/node-event-vector.h" + #include "xml/attribute-record.h" +@@ -383,7 +383,7 @@ + if (obj) { + for (auto iter : obj->style->properties()) { + if (iter->style_src != SP_STYLE_SRC_UNSET) { +- if( iter->name == name) { ++ if (iter->name == name) { + obj->style->readFromObject(obj); + obj->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); + } +@@ -413,7 +413,7 @@ + row[_attrColumns._attributeValue] = value; + } + reloadStyles(name); +- ++ + this->setUndo(_("Change attribute value")); + } + } +--- src/style.cpp (before formatting) ++++ src/style.cpp (after formatting) +@@ -721,8 +721,8 @@ + } + + // return if is seted property +-bool +-SPStyle::isSet(SPAttributeEnum id) { ++bool SPStyle::isSet(SPAttributeEnum id) ++{ + bool set = false; + switch (id) { + case SP_PROP_CLIP_PATH: +@@ -730,7 +730,8 @@ + case SP_PROP_MASK: + return set; + case SP_PROP_FILTER: +- if( !filter.inherit ) set = filter.set; ++ if (!filter.inherit) ++ set = filter.set; + return set; + case SP_PROP_COLOR_INTERPOLATION: + // We read it but issue warning +@@ -912,11 +913,11 @@ + gchar *const str_value = reinterpret_cast<gchar *>(str_value_unsigned); + + // Add "!important" rule if necessary as this is not handled by cr_term_to_string(). +- gchar const * important = decl->important ? " !important" : ""; ++ gchar const *important = decl->important ? " !important" : ""; + Inkscape::CSSOStringStream os; + os << str_value << important; + +- readIfUnset( prop_idx, os.str().c_str(), source ); ++ readIfUnset(prop_idx, os.str().c_str(), source); + g_free(str_value); + } + } diff --git a/src/style.cpp b/src/style.cpp index ac4f1f37e..17ad85dc3 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -721,8 +721,8 @@ SPStyle::readIfUnset(SPAttributeEnum id, gchar const *val, SPStyleSrc const &sou } // return if is seted property -bool -SPStyle::isSet(SPAttributeEnum id) { +bool SPStyle::isSet(SPAttributeEnum id) +{ bool set = false; switch (id) { case SP_PROP_CLIP_PATH: @@ -730,7 +730,8 @@ SPStyle::isSet(SPAttributeEnum id) { case SP_PROP_MASK: return set; case SP_PROP_FILTER: - if( !filter.inherit ) set = filter.set; + if (!filter.inherit) + set = filter.set; return set; case SP_PROP_COLOR_INTERPOLATION: // We read it but issue warning @@ -912,11 +913,11 @@ SPStyle::_mergeDecl( CRDeclaration const *const decl, SPStyleSrc const &source gchar *const str_value = reinterpret_cast<gchar *>(str_value_unsigned); // Add "!important" rule if necessary as this is not handled by cr_term_to_string(). - gchar const * important = decl->important ? " !important" : ""; + gchar const *important = decl->important ? " !important" : ""; Inkscape::CSSOStringStream os; os << str_value << important; - readIfUnset( prop_idx, os.str().c_str(), source ); + readIfUnset(prop_idx, os.str().c_str(), source); g_free(str_value); } } diff --git a/src/ui/dialog/attrdialog.cpp b/src/ui/dialog/attrdialog.cpp index e8a7078c6..d07623325 100644 --- a/src/ui/dialog/attrdialog.cpp +++ b/src/ui/dialog/attrdialog.cpp @@ -18,9 +18,9 @@ #include "message-context.h" #include "message-stack.h" +#include "style.h" #include "ui/icon-loader.h" #include "ui/widget/iconrenderer.h" -#include "style.h" #include "xml/node-event-vector.h" #include "xml/attribute-record.h" @@ -383,7 +383,7 @@ void AttrDialog::reloadStyles(Glib::ustring name) if (obj) { for (auto iter : obj->style->properties()) { if (iter->style_src != SP_STYLE_SRC_UNSET) { - if( iter->name == name) { + if (iter->name == name) { obj->style->readFromObject(obj); obj->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); } @@ -413,7 +413,7 @@ void AttrDialog::valueEdited (const Glib::ustring& path, const Glib::ustring& va row[_attrColumns._attributeValue] = value; } reloadStyles(name); - + this->setUndo(_("Change attribute value")); } } diff --git a/src/ui/dialog/selectordialog.cpp b/src/ui/dialog/selectordialog.cpp index 81130e61a..2501214c5 100644 --- a/src/ui/dialog/selectordialog.cpp +++ b/src/ui/dialog/selectordialog.cpp @@ -52,17 +52,17 @@ namespace Dialog { // Keeps a watch on style element class SelectorDialog::NodeObserver : public Inkscape::XML::NodeObserver { public: - NodeObserver(SelectorDialog* selectordialog) : - _selectordialog(selectordialog) - { - g_debug("SelectorDialog::NodeObserver: Constructor"); + NodeObserver(SelectorDialog *selectordialog) + : _selectordialog(selectordialog) + { + g_debug("SelectorDialog::NodeObserver: Constructor"); }; void notifyContentChanged(Inkscape::XML::Node &node, Inkscape::Util::ptr_shared old_content, Inkscape::Util::ptr_shared new_content) override; - SelectorDialog * _selectordialog; + SelectorDialog *_selectordialog; }; @@ -83,19 +83,19 @@ SelectorDialog::NodeObserver::notifyContentChanged( // (Must update objects that selectors match.) class SelectorDialog::NodeWatcher : public Inkscape::XML::NodeObserver { public: - NodeWatcher(SelectorDialog* selectordialog, Inkscape::XML::Node *repr) : - _selectordialog(selectordialog), - _repr(repr) - { - g_debug("SelectorDialog::NodeWatcher: Constructor"); + NodeWatcher(SelectorDialog *selectordialog, Inkscape::XML::Node *repr) + : _selectordialog(selectordialog) + , _repr(repr) + { + g_debug("SelectorDialog::NodeWatcher: Constructor"); }; void notifyChildAdded( Inkscape::XML::Node &/*node*/, Inkscape::XML::Node &child, Inkscape::XML::Node */*prev*/ ) override { - if ( _selectordialog && _repr ) { - _selectordialog->_nodeAdded( child ); + if (_selectordialog && _repr) { + _selectordialog->_nodeAdded(child); } } @@ -103,8 +103,8 @@ public: Inkscape::XML::Node &child, Inkscape::XML::Node */*prev*/ ) override { - if ( _selectordialog && _repr ) { - _selectordialog->_nodeRemoved( child ); + if (_selectordialog && _repr) { + _selectordialog->_nodeRemoved(child); } } @@ -112,7 +112,7 @@ public: GQuark qname, Util::ptr_shared /*old_value*/, Util::ptr_shared /*new_value*/ ) override { - if ( _selectordialog && _repr ) { + if (_selectordialog && _repr) { // For the moment only care about attributes that are directly used in selectors. const gchar * cname = g_quark_to_string (qname ); @@ -122,12 +122,12 @@ public: } if ( name == "id" || name == "class" ) { - _selectordialog->_nodeChanged( node ); + _selectordialog->_nodeChanged(node); } } } - SelectorDialog * _selectordialog; + SelectorDialog *_selectordialog; Inkscape::XML::Node * _repr; // Need to track if document changes. }; @@ -243,7 +243,7 @@ SelectorDialog::SelectorDialog() : addRenderer->add_icon("edit-delete"); addRenderer->add_icon("list-add"); addRenderer->add_icon("object-locked"); - + _store = TreeStore::create(this); _treeView.set_model(_store); @@ -407,10 +407,10 @@ void SelectorDialog::_readStyleElement() content.erase(std::remove(content.begin(), content.end(), '\n'), content.end()); // Remove comments (/* xxx */) -/* while(content.find("/*") != std::string::npos) { - size_t start = content.find("/*"); - content.erase(start, (content.find("*\/", start) - start) +2); - } */ + /* while(content.find("/*") != std::string::npos) { + size_t start = content.find("/*"); + content.erase(start, (content.find("*\/", start) - start) +2); + } */ // First split into selector/value chunks. // An attempt to use Glib::Regex failed. A C++11 version worked but @@ -453,7 +453,7 @@ void SelectorDialog::_readStyleElement() for (auto tok : tokensplus) { REMOVE_SPACES(tok); if (SPAttributeRelSVG::isSVGElement(tok) || tok.find(" ") != -1 || tok[0] == '>' || tok[0] == '+' || - tok[0] == '~' || tok[0] == '*' || tok.erase(0, 1).find(".") != -1) { + tok[0] == '~' || tok[0] == '*' || tok.erase(0, 1).find(".") != -1) { colType = UNHANDLED; } } @@ -488,14 +488,15 @@ void SelectorDialog::_readStyleElement() Gtk::TreeModel::Row childrow = *(_store->append(row->children())); childrow[_mColumns._colSelector] = "#" + Glib::ustring(obj->getId()); childrow[_mColumns._colExpand] = false; - childrow[_mColumns._colType] = colType == UNHANDLED ? UNHANDLED : OBJECT;; + childrow[_mColumns._colType] = colType == UNHANDLED ? UNHANDLED : OBJECT; + ; childrow[_mColumns._colObj] = std::vector<SPObject *>(1, obj); childrow[_mColumns._colProperties] = ""; // Unused - childrow[_mColumns._colVisible] = true; // Unused + childrow[_mColumns._colVisible] = true; // Unused } -} + } + - _updating = false; } @@ -624,7 +625,7 @@ void SelectorDialog::_addToSelector(Gtk::TreeModel::Row row) childrow[_mColumns._colType] = OBJECT; childrow[_mColumns._colObj] = std::vector<SPObject *>(1, obj); childrow[_mColumns._colProperties] = ""; // Unused - childrow[_mColumns._colVisible] = true; // Unused + childrow[_mColumns._colVisible] = true; // Unused } } } @@ -665,7 +666,7 @@ void SelectorDialog::_addToSelector(Gtk::TreeModel::Row row) childrow[_mColumns._colType] = OBJECT; childrow[_mColumns._colObj] = std::vector<SPObject *>(1, obj); childrow[_mColumns._colProperties] = ""; // Unused - childrow[_mColumns._colVisible] = true; // Unused + childrow[_mColumns._colVisible] = true; // Unused } } } @@ -986,7 +987,7 @@ void SelectorDialog::_addSelector() textLabelPtr->show(); } else { invalid = false; - } + } } delete textDialogPtr; // ==== Handle response ==== @@ -1209,13 +1210,13 @@ void SelectorDialog::_selectRow() { g_debug("SelectorDialog::_selectRow: updating: %s", (_updating ? "true" : "false")); del->hide(); - std::vector< Gtk::TreeModel::Path > selectedrows = _treeView.get_selection()->get_selected_rows(); - if(selectedrows.size() == 1) { + std::vector<Gtk::TreeModel::Path> selectedrows = _treeView.get_selection()->get_selected_rows(); + if (selectedrows.size() == 1) { Gtk::TreeModel::Row row = *_store->get_iter(selectedrows[0]); - if (!row->parent() && row->children().size() < 2 ) { + if (!row->parent() && row->children().size() < 2) { del->show(); } - } else if(selectedrows.size() == 0) { + } else if (selectedrows.size() == 0) { del->show(); } if (_updating || !getDesktop()) return; // Avoid updating if we have set row via dialog. @@ -1231,7 +1232,7 @@ void SelectorDialog::_selectRow() if (!selection->isEmpty()) { obj = selection->objects().back(); } - + for (auto row : children) { std::vector<SPObject *> objVec = row[_mColumns._colObj]; if (obj) { diff --git a/src/ui/dialog/selectordialog.h b/src/ui/dialog/selectordialog.h index 35a7167f3..1702f087d 100644 --- a/src/ui/dialog/selectordialog.h +++ b/src/ui/dialog/selectordialog.h @@ -15,14 +15,14 @@ #ifndef SELECTORDIALOG_H #define SELECTORDIALOG_H -#include <ui/widget/panel.h> -#include <gtkmm/treeview.h> -#include <gtkmm/treestore.h> -#include <gtkmm/treemodelfilter.h> -#include <gtkmm/scrolledwindow.h> #include <gtkmm/dialog.h> -#include <gtkmm/treeselection.h> #include <gtkmm/paned.h> +#include <gtkmm/scrolledwindow.h> +#include <gtkmm/treemodelfilter.h> +#include <gtkmm/treeselection.h> +#include <gtkmm/treestore.h> +#include <gtkmm/treeview.h> +#include <ui/widget/panel.h> #include "ui/dialog/desktop-tracker.h" @@ -81,7 +81,7 @@ public: Gtk::TreeModelColumn<gint> _colType; // Selector row or child object row. Gtk::TreeModelColumn<std::vector<SPObject *> > _colObj; // List of matching objects. Gtk::TreeModelColumn<Glib::ustring> _colProperties; // List of properties. - Gtk::TreeModelColumn<bool> _colVisible; // Make visible or not. + Gtk::TreeModelColumn<bool> _colVisible; // Make visible or not. }; ModelColumns _mColumns; @@ -100,7 +100,7 @@ public: void on_row_deleted(const TreeModel::Path& path) override; public: - static Glib::RefPtr<SelectorDialog::TreeStore> create(SelectorDialog *styledialog); + static Glib::RefPtr<SelectorDialog::TreeStore> create(SelectorDialog *styledialog); private: SelectorDialog *_selectordialog; diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp index adab927fb..b7eec923c 100644 --- a/src/ui/dialog/styledialog.cpp +++ b/src/ui/dialog/styledialog.cpp @@ -13,24 +13,23 @@ */ #include "styledialog.h" -#include "attributes.h" -#include "verbs.h" -#include "selection.h" #include "attribute-rel-svg.h" -#include "inkscape.h" +#include "attributes.h" #include "document-undo.h" +#include "inkscape.h" +#include "io/resource.h" #include "selection.h" #include "style-internal.h" #include "style.h" -#include "io/resource.h" #include "ui/icon-loader.h" #include "ui/widget/iconrenderer.h" +#include "verbs.h" #include "xml/attribute-record.h" #include "xml/node-observer.h" -#include <regex> #include <map> +#include <regex> #include <utility> #include <glibmm/i18n.h> @@ -46,7 +45,8 @@ using Inkscape::XML::AttributeRecord; * This macro is used to remove spaces around selectors or any strings when * parsing is done to update XML style element or row labels in this dialog. */ -#define REMOVE_SPACES(x) x.erase(0, x.find_first_not_of(' ')); \ +#define REMOVE_SPACES(x) \ + x.erase(0, x.find_first_not_of(' ')); \ x.erase(x.find_last_not_of(' ') + 1); namespace Inkscape { @@ -55,26 +55,24 @@ namespace Dialog { // Keeps a watch on style element class StyleDialog::NodeObserver : public Inkscape::XML::NodeObserver { -public: - NodeObserver(StyleDialog* styledialog) : - _styledialog(styledialog) + public: + NodeObserver(StyleDialog *styledialog) + : _styledialog(styledialog) { g_debug("StyleDialog::NodeObserver: Constructor"); }; - void notifyContentChanged(Inkscape::XML::Node &node, - Inkscape::Util::ptr_shared old_content, - Inkscape::Util::ptr_shared new_content) override; + void notifyContentChanged(Inkscape::XML::Node &node, Inkscape::Util::ptr_shared old_content, + Inkscape::Util::ptr_shared new_content) override; - StyleDialog * _styledialog; + StyleDialog *_styledialog; }; -void -StyleDialog::NodeObserver::notifyContentChanged( - Inkscape::XML::Node &/*node*/, - Inkscape::Util::ptr_shared /*old_content*/, - Inkscape::Util::ptr_shared /*new_content*/ ) { +void StyleDialog::NodeObserver::notifyContentChanged(Inkscape::XML::Node & /*node*/, + Inkscape::Util::ptr_shared /*old_content*/, + Inkscape::Util::ptr_shared /*new_content*/) +{ g_debug("StyleDialog::NodeObserver::notifyContentChanged"); _styledialog->_updating = false; @@ -85,61 +83,58 @@ StyleDialog::NodeObserver::notifyContentChanged( // Keeps a watch for new/removed/changed nodes // (Must update objects that selectors match.) class StyleDialog::NodeWatcher : public Inkscape::XML::NodeObserver { -public: - NodeWatcher(StyleDialog* styledialog, Inkscape::XML::Node *repr) : - _styledialog(styledialog), - _repr(repr) + public: + NodeWatcher(StyleDialog *styledialog, Inkscape::XML::Node *repr) + : _styledialog(styledialog) + , _repr(repr) { g_debug("StyleDialog::NodeWatcher: Constructor"); }; - void notifyChildAdded( Inkscape::XML::Node &/*node*/, - Inkscape::XML::Node &child, - Inkscape::XML::Node */*prev*/ ) override + void notifyChildAdded(Inkscape::XML::Node & /*node*/, Inkscape::XML::Node &child, + Inkscape::XML::Node * /*prev*/) override { - if ( _styledialog && _repr ) { - _styledialog->_nodeAdded( child ); + if (_styledialog && _repr) { + _styledialog->_nodeAdded(child); } } - void notifyChildRemoved( Inkscape::XML::Node &/*node*/, - Inkscape::XML::Node &child, - Inkscape::XML::Node */*prev*/ ) override + void notifyChildRemoved(Inkscape::XML::Node & /*node*/, Inkscape::XML::Node &child, + Inkscape::XML::Node * /*prev*/) override { - if ( _styledialog && _repr ) { - _styledialog->_nodeRemoved( child ); + if (_styledialog && _repr) { + _styledialog->_nodeRemoved(child); } } -/* void notifyContentChanged(Inkscape::XML::Node &node, - Inkscape::Util::ptr_shared old_content, - Inkscape::Util::ptr_shared new_content) override{ - if ( _styledialog && _repr && _textNode == node) { - _styledialog->_stylesheetChanged( node ); - } - }; - */ - void notifyAttributeChanged( Inkscape::XML::Node &node, - GQuark qname, - Util::ptr_shared /*old_value*/, - Util::ptr_shared /*new_value*/ ) override { - if ( _styledialog && _repr ) { + /* void notifyContentChanged(Inkscape::XML::Node &node, + Inkscape::Util::ptr_shared old_content, + Inkscape::Util::ptr_shared new_content) override{ + if ( _styledialog && _repr && _textNode == node) { + _styledialog->_stylesheetChanged( node ); + } + }; + */ + void notifyAttributeChanged(Inkscape::XML::Node &node, GQuark qname, Util::ptr_shared /*old_value*/, + Util::ptr_shared /*new_value*/) override + { + if (_styledialog && _repr) { // For the moment only care about attributes that are directly used in selectors. - const gchar * cname = g_quark_to_string (qname); + const gchar *cname = g_quark_to_string(qname); Glib::ustring name; if (cname) { name = cname; } - if ( name == "id" || name == "class" || name == "style" ) { - _styledialog->_nodeChanged( node ); + if (name == "id" || name == "class" || name == "style") { + _styledialog->_nodeChanged(node); } SPObject *obj = SP_ACTIVE_DOCUMENT->getObjectById(node.attribute("id")); if (obj) { for (auto iter : obj->style->properties()) { if (iter->style_src != SP_STYLE_SRC_UNSET) { - if( iter->name == name) { - _styledialog->_nodeChanged( node ); + if (iter->name == name) { + _styledialog->_nodeChanged(node); } } } @@ -147,37 +142,34 @@ public: } } - StyleDialog * _styledialog; - Inkscape::XML::Node * _repr; // Need to track if document changes. + StyleDialog *_styledialog; + Inkscape::XML::Node *_repr; // Need to track if document changes. }; -void -StyleDialog::_nodeAdded( Inkscape::XML::Node &node ) { +void StyleDialog::_nodeAdded(Inkscape::XML::Node &node) +{ - StyleDialog::NodeWatcher *w = new StyleDialog::NodeWatcher (this, &node); - node.addObserver (*w); + StyleDialog::NodeWatcher *w = new StyleDialog::NodeWatcher(this, &node); + node.addObserver(*w); _nodeWatchers.push_back(w); _readStyleElement(); } -void -StyleDialog::_nodeRemoved( Inkscape::XML::Node &repr ) { +void StyleDialog::_nodeRemoved(Inkscape::XML::Node &repr) +{ for (auto it = _nodeWatchers.begin(); it != _nodeWatchers.end(); ++it) { - if ( (*it)->_repr == &repr ) { - (*it)->_repr->removeObserver (**it); - _nodeWatchers.erase( it ); + if ((*it)->_repr == &repr) { + (*it)->_repr->removeObserver(**it); + _nodeWatchers.erase(it); break; } } _readStyleElement(); } -void -StyleDialog::_nodeChanged( Inkscape::XML::Node &object ) { - _readStyleElement(); -} +void StyleDialog::_nodeChanged(Inkscape::XML::Node &object) { _readStyleElement(); } /* void StyleDialog::_stylesheetChanged( Inkscape::XML::Node &repr ) { @@ -191,11 +183,11 @@ StyleDialog::_stylesheetChanged( Inkscape::XML::Node &repr ) { * adds selectors to treeview. _delSelector deletes the selector from the dialog. * Any addition/deletion of the selectors updates XML style element accordingly. */ -StyleDialog::StyleDialog() : - UI::Widget::Panel("/dialogs/style", SP_VERB_DIALOG_STYLE), - _updating(false), - _textNode(nullptr), - _desktopTracker() +StyleDialog::StyleDialog() + : UI::Widget::Panel("/dialogs/style", SP_VERB_DIALOG_STYLE) + , _updating(false) + , _textNode(nullptr) + , _desktopTracker() { g_debug("StyleDialog::StyleDialog"); // Pack widgets @@ -204,8 +196,8 @@ StyleDialog::StyleDialog() : _styleBox.set_orientation(Gtk::ORIENTATION_VERTICAL); _styleBox.set_valign(Gtk::ALIGN_START); _scrolledWindow.add(_styleBox); - Gtk::Box *alltoggler = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL)); - Gtk::Label *infotoggler = Gtk::manage(new Gtk::Label(_("Edit Full Stylesheet"))); + 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); @@ -218,13 +210,13 @@ StyleDialog::StyleDialog() : _mainBox.set_orientation(Gtk::ORIENTATION_VERTICAL); _getContents()->pack_start(_mainBox, Gtk::PACK_EXPAND_WIDGET); // Document & Desktop - _desktop_changed_connection = _desktopTracker.connectDesktopChanged( - sigc::mem_fun(*this, &StyleDialog::_handleDesktopChanged) ); + _desktop_changed_connection = + _desktopTracker.connectDesktopChanged(sigc::mem_fun(*this, &StyleDialog::_handleDesktopChanged)); _desktopTracker.connect(GTK_WIDGET(gobj())); - _document_replaced_connection = getDesktop()->connectDocumentReplaced( - sigc::mem_fun(this, &StyleDialog::_handleDocumentReplaced)); - + _document_replaced_connection = + getDesktop()->connectDocumentReplaced(sigc::mem_fun(this, &StyleDialog::_handleDocumentReplaced)); + _selection_changed_connection = getDesktop()->getSelection()->connectChanged( sigc::hide(sigc::mem_fun(this, &StyleDialog::_handleSelectionChanged))); // Add watchers @@ -245,18 +237,14 @@ StyleDialog::~StyleDialog() _selection_changed_connection.disconnect(); } -void -StyleDialog::_reload() -{ - _readStyleElement(); -} +void StyleDialog::_reload() { _readStyleElement(); } /** * @return Inkscape::XML::Node* pointing to a style element's text node. * Returns the style element's text node. If there is no style element, one is created. * Ditto for text node. */ -Inkscape::XML::Node* StyleDialog::_getStyleTextNode() +Inkscape::XML::Node *StyleDialog::_getStyleTextNode() { Inkscape::XML::Node *styleNode = nullptr; @@ -287,7 +275,7 @@ Inkscape::XML::Node* StyleDialog::_getStyleTextNode() if (styleNode == nullptr) { // Style element not found, create one styleNode = SP_ACTIVE_DOCUMENT->getReprDoc()->createElement("svg:style"); - textNode = SP_ACTIVE_DOCUMENT->getReprDoc()->createTextNode(""); + textNode = SP_ACTIVE_DOCUMENT->getReprDoc()->createTextNode(""); styleNode->appendChild(textNode); Inkscape::GC::release(textNode); @@ -305,35 +293,33 @@ Inkscape::XML::Node* StyleDialog::_getStyleTextNode() return textNode; } -Glib::RefPtr< Gtk::TreeModel > StyleDialog::_selectTree(Glib::ustring selector) +Glib::RefPtr<Gtk::TreeModel> StyleDialog::_selectTree(Glib::ustring selector) { - Gtk::Label * selectorlabel; - Glib::RefPtr< Gtk::TreeModel > model; - for (auto fullstyle:_styleBox.get_children()){ + Gtk::Label *selectorlabel; + Glib::RefPtr<Gtk::TreeModel> model; + for (auto fullstyle : _styleBox.get_children()) { Gtk::Box *style = dynamic_cast<Gtk::Box *>(fullstyle); - for (auto stylepart:style->get_children()){ + for (auto stylepart : style->get_children()) { switch (style->child_property_position(*stylepart)) { - case 0: - { - Gtk::Box *selectorbox = dynamic_cast<Gtk::Box *>(stylepart); - for (auto styleheader:selectorbox->get_children()){ - if (!selectorbox->child_property_position(*styleheader)) { - selectorlabel = dynamic_cast<Gtk::Label *>(styleheader); - } + case 0: { + Gtk::Box *selectorbox = dynamic_cast<Gtk::Box *>(stylepart); + for (auto styleheader : selectorbox->get_children()) { + if (!selectorbox->child_property_position(*styleheader)) { + selectorlabel = dynamic_cast<Gtk::Label *>(styleheader); } - break; } - case 1: - { - Glib::ustring wdg_selector = selectorlabel->get_text(); - if (wdg_selector == selector){ - Gtk::TreeView* treeview = dynamic_cast<Gtk::TreeView *>(stylepart); - if (treeview) { - return treeview->get_model(); - } + break; + } + case 1: { + Glib::ustring wdg_selector = selectorlabel->get_text(); + if (wdg_selector == selector) { + Gtk::TreeView *treeview = dynamic_cast<Gtk::TreeView *>(stylepart); + if (treeview) { + return treeview->get_model(); } - break; } + break; + } default: break; } @@ -349,10 +335,11 @@ void StyleDialog::_readStyleElement() { g_debug("StyleDialog::_readStyleElement"); - if (_updating) return; // Don't read if we wrote style element. + if (_updating) + return; // Don't read if we wrote style element. _updating = true; - Inkscape::XML::Node * textNode = _getStyleTextNode(); + Inkscape::XML::Node *textNode = _getStyleTextNode(); if (textNode == nullptr) { std::cerr << "StyleDialog::_readStyleElement: No text node!" << std::endl; } @@ -370,11 +357,8 @@ void StyleDialog::_readStyleElement() size_t open = content.find("{", start + 1); size_t close = content.find("}", start + 1); size_t end = content.find("*/", close + 1); - while(!breakme) { - if (open == std::string::npos || - close == std::string::npos || - end == std::string::npos) - { + while (!breakme) { + if (open == std::string::npos || close == std::string::npos || end == std::string::npos) { breakme = true; break; } @@ -383,10 +367,7 @@ void StyleDialog::_readStyleElement() close = content.find("}", close + 1); end = content.find("*/", close + 1); size_t reopen = content.find("{", close + 1); - if (open == std::string::npos || - end == std::string::npos || - end < reopen) - { + if (open == std::string::npos || end == std::string::npos || end < reopen) { if (end < reopen) { content = content.erase(start, end - start + 2); } else { @@ -417,13 +398,13 @@ void StyleDialog::_readStyleElement() // If text node is empty, return (avoids problem with negative below). - for (auto child:_styleBox.get_children()) { + for (auto child : _styleBox.get_children()) { _styleBox.remove(*child); delete child; } - Inkscape::Selection* selection = getDesktop()->getSelection(); + Inkscape::Selection *selection = getDesktop()->getSelection(); SPObject *obj = nullptr; - if(selection->objects().size() == 1) { + if (selection->objects().size() == 1) { obj = selection->objects().back(); } @@ -448,28 +429,30 @@ void StyleDialog::_readStyleElement() _builder->get_widget("CSSTree", css_tree); Glib::RefPtr<Gtk::TreeStore> store = Gtk::TreeStore::create(_mColumns); css_tree->set_model(store); - // We need to handle comments on SPStyle to activate + // We need to handle comments on SPStyle to activate /* Gtk::CellRendererToggle *active = Gtk::manage(new Gtk::CellRendererToggle); int addCol = css_tree->append_column("", *active) - 1; Gtk::TreeViewColumn *col = css_tree->get_column(addCol); if (col) { col->add_attribute(active->property_active(), _mColumns._colActive); } */ - + css_selector_event_add->signal_button_release_event().connect( - sigc::bind<Glib::RefPtr<Gtk::TreeStore>, Gtk::TreeView *, Glib::ustring, gint>( - sigc::mem_fun(*this, &StyleDialog::_addRow), store, css_tree, "style_properties", selectorpos)); - Inkscape::UI::Widget::IconRenderer * addRenderer = manage(new Inkscape::UI::Widget::IconRenderer()); + sigc::bind<Glib::RefPtr<Gtk::TreeStore>, Gtk::TreeView *, Glib::ustring, gint>( + sigc::mem_fun(*this, &StyleDialog::_addRow), store, css_tree, "style_properties", selectorpos)); + 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<Glib::RefPtr<Gtk::TreeStore> >(sigc::mem_fun(*this, &StyleDialog::_onPropDelete), store)); + addRenderer->signal_activated().connect( + sigc::bind<Glib::RefPtr<Gtk::TreeStore>>(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< Glib::RefPtr<Gtk::TreeStore>, Gtk::TreeView *>(sigc::mem_fun(*this, &StyleDialog::_nameEdited), store, css_tree)); + label->signal_edited().connect(sigc::bind<Glib::RefPtr<Gtk::TreeStore>, 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) { @@ -478,7 +461,8 @@ void StyleDialog::_readStyleElement() Gtk::CellRendererText *value = Gtk::manage(new Gtk::CellRendererText()); value->property_placeholder_text() = _("value"); value->property_editable() = true; - value->signal_edited().connect(sigc::bind<Glib::RefPtr<Gtk::TreeStore> >(sigc::mem_fun(*this, &StyleDialog::_valueEdited), store)); + value->signal_edited().connect( + sigc::bind<Glib::RefPtr<Gtk::TreeStore>>(sigc::mem_fun(*this, &StyleDialog::_valueEdited), store)); addCol = css_tree->append_column("CSS Value", *value) - 1; col = css_tree->get_column(addCol); if (col) { @@ -488,7 +472,7 @@ void StyleDialog::_readStyleElement() std::map<Glib::ustring, Glib::ustring> attr_prop; if (obj || _all_css->get_active()) { Gtk::TreeModel::Path path; - if(!_all_css->get_active() && obj && obj->getRepr()->attribute("style")) { + if (!_all_css->get_active() && obj && obj->getRepr()->attribute("style")) { Glib::ustring style = obj->getRepr()->attribute("style"); attr_prop = parseStyle(style); for (auto iter : obj->style->properties()) { @@ -502,9 +486,9 @@ void StyleDialog::_readStyleElement() row[_mColumns._colStrike] = false; } } - _styleBox.pack_start(*css_selector_container, Gtk::PACK_EXPAND_WIDGET); + _styleBox.pack_start(*css_selector_container, Gtk::PACK_EXPAND_WIDGET); } - selectorpos ++; + selectorpos++; try { _builder = Gtk::Builder::create_from_file(gladefile); } catch (const Glib::Error &ex) { @@ -520,27 +504,31 @@ void StyleDialog::_readStyleElement() _builder->get_widget("CSSTree", css_tree); css_tree->set_model(store); css_selector_event_add->signal_button_release_event().connect( - sigc::bind<Glib::RefPtr<Gtk::TreeStore>, Gtk::TreeView *, Glib::ustring, gint>( - sigc::mem_fun(*this, &StyleDialog::_addRow), store, css_tree, "attributes", selectorpos)); + sigc::bind<Glib::RefPtr<Gtk::TreeStore>, Gtk::TreeView *, Glib::ustring, gint>( + sigc::mem_fun(*this, &StyleDialog::_addRow), store, css_tree, "attributes", selectorpos)); bool hasattributes = false; - if(!_all_css->get_active()) { + 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") { + 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()); + 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<Glib::RefPtr<Gtk::TreeStore> >(sigc::mem_fun(*this, &StyleDialog::_onPropDelete), store)); + addRenderer->signal_activated().connect(sigc::bind<Glib::RefPtr<Gtk::TreeStore>>( + 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< Glib::RefPtr<Gtk::TreeStore>, Gtk::TreeView * >(sigc::mem_fun(*this, &StyleDialog::_nameEdited), store, css_tree)); + label->signal_edited().connect( + sigc::bind<Glib::RefPtr<Gtk::TreeStore>, 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) { @@ -549,7 +537,8 @@ void StyleDialog::_readStyleElement() Gtk::CellRendererText *value = Gtk::manage(new Gtk::CellRendererText()); value->property_placeholder_text() = _("value"); value->property_editable() = true; - value->signal_edited().connect(sigc::bind<Glib::RefPtr<Gtk::TreeStore> >(sigc::mem_fun(*this, &StyleDialog::_valueEdited), store)); + value->signal_edited().connect(sigc::bind<Glib::RefPtr<Gtk::TreeStore>>( + sigc::mem_fun(*this, &StyleDialog::_valueEdited), store)); addCol = css_tree->append_column("CSS Value", *value) - 1; col = css_tree->get_column(addCol); if (col) { @@ -574,18 +563,18 @@ void StyleDialog::_readStyleElement() } } if (!hasattributes) { - for (auto widg:css_selector_container->get_children()) { + for (auto widg : css_selector_container->get_children()) { delete widg; } } _styleBox.pack_start(*css_selector_container, Gtk::PACK_EXPAND_WIDGET); } - selectorpos ++; + selectorpos++; if (tokens.size() == 0) { _updating = false; return; } - for (unsigned i = 0; i < tokens.size()-1; i += 2) { + for (unsigned i = 0; i < tokens.size() - 1; i += 2) { Glib::ustring selector = tokens[i]; REMOVE_SPACES(selector); // Remove leading/trailing spaces std::vector<Glib::ustring> tokensplus = Glib::Regex::split_simple("[,]+", selector); @@ -593,27 +582,28 @@ void StyleDialog::_readStyleElement() REMOVE_SPACES(tok); } // Get list of objects selector matches - std::vector<SPObject *> objVec = _getObjVec( selector ); + std::vector<SPObject *> objVec = _getObjVec(selector); if (!_all_css->get_active()) { bool stop = true; - for (auto objel:objVec) { - if (objel->getId() == obj->getId()){ + for (auto objel : objVec) { + if (objel->getId() == obj->getId()) { stop = false; } } if (stop) { _updating = false; - selectorpos ++; + selectorpos++; continue; } } Glib::ustring properties; // Check to make sure we do have a value to match selector. - if ((i+1) < tokens.size()) { - properties = tokens[i+1]; + if ((i + 1) < tokens.size()) { + properties = tokens[i + 1]; } else { std::cerr << "StyleDialog::_readStyleElement: Missing values " - "for last selector!" << std::endl; + "for last selector!" + << std::endl; } Glib::RefPtr<Gtk::Builder> _builder; try { @@ -634,24 +624,27 @@ void StyleDialog::_readStyleElement() _builder->get_widget("CSSTree", css_tree); Glib::RefPtr<Gtk::TreeStore> store = Gtk::TreeStore::create(_mColumns); css_tree->set_model(store); - Inkscape::UI::Widget::IconRenderer * addRenderer = manage(new Inkscape::UI::Widget::IconRenderer()); + 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<Glib::RefPtr<Gtk::TreeStore> >(sigc::mem_fun(*this, &StyleDialog::_onPropDelete), store)); - } + addRenderer->signal_activated().connect( + sigc::bind<Glib::RefPtr<Gtk::TreeStore>>(sigc::mem_fun(*this, &StyleDialog::_onPropDelete), store)); + } Gtk::CellRendererToggle *active = Gtk::manage(new Gtk::CellRendererToggle); addCol = css_tree->append_column("Active Property", *active) - 1; col = css_tree->get_column(addCol); if (col) { col->add_attribute(active->property_active(), _mColumns._colActive); - active->signal_toggled().connect(sigc::bind<Glib::RefPtr<Gtk::TreeStore> >(sigc::mem_fun(*this, &StyleDialog::_activeToggled), store)); + active->signal_toggled().connect(sigc::bind<Glib::RefPtr<Gtk::TreeStore>>( + sigc::mem_fun(*this, &StyleDialog::_activeToggled), store)); } Gtk::CellRendererText *label = Gtk::manage(new Gtk::CellRendererText()); label->property_placeholder_text() = _("property"); label->property_editable() = true; - label->signal_edited().connect(sigc::bind< Glib::RefPtr<Gtk::TreeStore>, Gtk::TreeView * >(sigc::mem_fun(*this, &StyleDialog::_nameEdited), store, css_tree)); + label->signal_edited().connect(sigc::bind<Glib::RefPtr<Gtk::TreeStore>, Gtk::TreeView *>( + sigc::mem_fun(*this, &StyleDialog::_nameEdited), store, css_tree)); addCol = css_tree->append_column("CSS Selector", *label) - 1; col = css_tree->get_column(addCol); if (col) { @@ -659,7 +652,8 @@ void StyleDialog::_readStyleElement() } Gtk::CellRendererText *value = Gtk::manage(new Gtk::CellRendererText()); value->property_editable() = true; - value->signal_edited().connect(sigc::bind<Glib::RefPtr<Gtk::TreeStore> >(sigc::mem_fun(*this, &StyleDialog::_valueEdited), store)); + value->signal_edited().connect( + sigc::bind<Glib::RefPtr<Gtk::TreeStore>>(sigc::mem_fun(*this, &StyleDialog::_valueEdited), store)); value->property_placeholder_text() = _("value"); addCol = css_tree->append_column("CSS Value", *value) - 1; col = css_tree->get_column(addCol); @@ -669,20 +663,18 @@ void StyleDialog::_readStyleElement() } Glib::ustring style = properties; Glib::ustring comments = ""; - while(style.find("/*") != std::string::npos) { + while (style.find("/*") != std::string::npos) { size_t beg = style.find("/*"); size_t end = style.find("*/"); - if (end != std::string::npos && - beg != std::string::npos) - { + if (end != std::string::npos && beg != std::string::npos) { comments = comments.append(style, beg + 2, end - beg - 2); style = style.erase(beg, end - beg + 2); } } std::map<Glib::ustring, Glib::ustring> attr_prop_styleshet = parseStyle(style); css_selector_event_add->signal_button_release_event().connect( - sigc::bind<Glib::RefPtr<Gtk::TreeStore>, Gtk::TreeView *, Glib::ustring, gint>( - sigc::mem_fun(*this, &StyleDialog::_addRow), store, css_tree, selector, selectorpos)); + sigc::bind<Glib::RefPtr<Gtk::TreeStore>, Gtk::TreeView *, Glib::ustring, gint>( + sigc::mem_fun(*this, &StyleDialog::_addRow), store, css_tree, selector, selectorpos)); if (!_all_css->get_active()) { for (auto iter : obj->style->properties()) { if (iter->style_src != SP_STYLE_SRC_UNSET) { @@ -713,7 +705,7 @@ void StyleDialog::_readStyleElement() } } std::map<Glib::ustring, Glib::ustring> attr_prop_styleshet_comments = parseStyle(comments); - + for (auto iter : attr_prop_styleshet_comments) { if (!attr_prop_styleshet.count(iter.first)) { Gtk::TreeModel::Row row = *(store->append()); @@ -726,7 +718,7 @@ void StyleDialog::_readStyleElement() } } _styleBox.pack_start(*css_selector_container, Gtk::PACK_EXPAND_WIDGET); - selectorpos ++; + selectorpos++; } } _mainBox.show_all_children(); @@ -743,14 +735,13 @@ void StyleDialog::_readStyleElement() * @return true * Delete the attribute from the style */ -void -StyleDialog::_onPropDelete(Glib::ustring path, Glib::RefPtr<Gtk::TreeStore> store) +void StyleDialog::_onPropDelete(Glib::ustring path, Glib::RefPtr<Gtk::TreeStore> store) { Gtk::TreeModel::Row row = *store->get_iter(path); if (row) { - _updating = true; //to avoid a crash on deleting an obsolete widget + _updating = true; // to avoid a crash on deleting an obsolete widget Glib::ustring selector = row[_mColumns._colSelector]; - row[_mColumns._colName] = ""; + row[_mColumns._colName] = ""; store->erase(row); _updating = false; _writeStyleElement(store, selector); @@ -763,8 +754,7 @@ StyleDialog::_onPropDelete(Glib::ustring path, Glib::RefPtr<Gtk::TreeStore> stor * Convert a style string into a vector map. This should be moved to style.cpp * */ -std::map<Glib::ustring, Glib::ustring> -StyleDialog::parseStyle(Glib::ustring style_string) +std::map<Glib::ustring, Glib::ustring> StyleDialog::parseStyle(Glib::ustring style_string) { std::map<Glib::ustring, Glib::ustring> ret; @@ -794,7 +784,7 @@ void StyleDialog::_writeStyleElement(Glib::RefPtr<Gtk::TreeStore> store, Glib::u if (_updating) { return; } - Inkscape::Selection* selection = getDesktop()->getSelection(); + Inkscape::Selection *selection = getDesktop()->getSelection(); SPObject *obj = nullptr; if (selection->objects().size() == 1) { obj = selection->objects().back(); @@ -806,37 +796,33 @@ void StyleDialog::_writeStyleElement(Glib::RefPtr<Gtk::TreeStore> store, Glib::u _updating = true; gint selectorpos = 0; std::string styleContent = ""; - if (selector != "style_properties" && - selector != "attributes") - { + if (selector != "style_properties" && selector != "attributes") { styleContent = "\n" + selector + " { \n"; } - for (auto& row: store->children()) { + for (auto &row : store->children()) { selector = row[_mColumns._colSelector]; selectorpos = row[_mColumns._colSelectorPos]; - Glib::ustring opencomment =""; - Glib::ustring closecomment = "" ; - if (selector != "style_properties" && - selector != "attributes") { + Glib::ustring opencomment = ""; + Glib::ustring closecomment = ""; + if (selector != "style_properties" && selector != "attributes") { opencomment = row[_mColumns._colActive] ? " " : " /*"; - closecomment = row[_mColumns._colActive] ? "\n" : "*/\n" ; + closecomment = row[_mColumns._colActive] ? "\n" : "*/\n"; } - Glib::ustring name = row[_mColumns._colName]; + Glib::ustring name = row[_mColumns._colName]; Glib::ustring value = row[_mColumns._colValue]; - if (!(name.empty() && value.empty())){ + if (!(name.empty() && value.empty())) { styleContent = styleContent + opencomment + name + ":" + value + ";" + closecomment; } } - if (selector != "style_properties" && - selector != "attributes" ) { + if (selector != "style_properties" && selector != "attributes") { styleContent = styleContent + "}"; } if (selector == "style_properties") { - obj->getRepr()->setAttribute("style",styleContent, false); + obj->getRepr()->setAttribute("style", styleContent, false); } else 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") { + if (iter->name != "font" && iter->name != "d" && iter->name != "marker") { const gchar *attr = obj->getRepr()->attribute(iter->name.c_str()); if (attr) { obj->getRepr()->setAttribute(iter->name.c_str(), nullptr); @@ -844,14 +830,14 @@ void StyleDialog::_writeStyleElement(Glib::RefPtr<Gtk::TreeStore> store, Glib::u } } } - for (auto& row: store->children()) { - Glib::ustring name = row[_mColumns._colName]; - Glib::ustring value = row[_mColumns._colValue]; - if (!(name.empty() && value.empty())){ + for (auto &row : store->children()) { + Glib::ustring name = row[_mColumns._colName]; + Glib::ustring value = row[_mColumns._colValue]; + if (!(name.empty() && value.empty())) { obj->getRepr()->setAttribute(name.c_str(), value); } } - } else if (!selector.empty()) { //styleshet + } 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); @@ -862,10 +848,10 @@ void StyleDialog::_writeStyleElement(Glib::RefPtr<Gtk::TreeStore> store, Glib::u } selectormatch = selectormatch + ")([^}]*?})((.|\n)*)"; Inkscape::XML::Node *textNode = _getStyleTextNode(); - std::regex e (selectormatch.c_str()); + 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"); + std::regex_replace(std::back_inserter(result), content.begin(), content.end(), e, "$1" + styleContent + "$3"); textNode->setContent(result.c_str()); } _readStyleElement(); @@ -875,19 +861,21 @@ void StyleDialog::_writeStyleElement(Glib::RefPtr<Gtk::TreeStore> store, Glib::u g_debug("StyleDialog::_writeStyleElement(): | %s |", styleContent.c_str()); } -bool StyleDialog::_addRow(GdkEventButton *evt, Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeView *css_tree, Glib::ustring selector, gint pos) { - if(evt->type == GDK_BUTTON_RELEASE && evt->button == 1) { +bool StyleDialog::_addRow(GdkEventButton *evt, Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeView *css_tree, + Glib::ustring selector, gint pos) +{ + if (evt->type == GDK_BUTTON_RELEASE && evt->button == 1) { Gtk::TreeIter iter = store->append(); Gtk::TreeModel::Path path = (Gtk::TreeModel::Path)iter; Gtk::TreeModel::Row row = *(iter); row[_mColumns._colSelector] = selector; row[_mColumns._colSelectorPos] = pos; row[_mColumns._colActive] = true; - row[_mColumns._colName] = ""; + row[_mColumns._colName] = ""; row[_mColumns._colValue] = ""; row[_mColumns._colStrike] = false; gint col = 2; - if (pos < 2 ){ + if (pos < 2) { col = 1; } css_tree->set_cursor(path, *(css_tree->get_column(col)), true); @@ -903,12 +891,13 @@ bool StyleDialog::_addRow(GdkEventButton *evt, Glib::RefPtr<Gtk::TreeStore> stor * @return * Called when the name is edited in the TreeView editable column */ -void StyleDialog::_nameEdited (const Glib::ustring& path, const Glib::ustring& name, Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeView *css_tree) +void StyleDialog::_nameEdited(const Glib::ustring &path, const Glib::ustring &name, Glib::RefPtr<Gtk::TreeStore> store, + Gtk::TreeView *css_tree) { Gtk::TreeModel::Row row = *store->get_iter(path); Gtk::TreeModel::Path pathel = (Gtk::TreeModel::Path)*store->get_iter(path); - if(row) { + if (row) { gint pos = row[_mColumns._colSelectorPos]; bool write = false; if (row[_mColumns._colName] != name && row[_mColumns._colValue] != "") { @@ -917,11 +906,11 @@ void StyleDialog::_nameEdited (const Glib::ustring& path, const Glib::ustring& n Glib::ustring value = row[_mColumns._colValue]; Glib::ustring selector = row[_mColumns._colSelector]; row[_mColumns._colName] = name; - if(name.empty() && value.empty()) { + if (name.empty() && value.empty()) { store->erase(row); } gint col = 3; - if (pos < 2 ){ + if (pos < 2) { col = 2; } if (write) { @@ -940,31 +929,33 @@ void StyleDialog::_nameEdited (const Glib::ustring& path, const Glib::ustring& n * @return * Called when the value is edited in the TreeView editable column */ -void StyleDialog::_valueEdited(const Glib::ustring& path, const Glib::ustring& value, Glib::RefPtr<Gtk::TreeStore> store) +void StyleDialog::_valueEdited(const Glib::ustring &path, const Glib::ustring &value, + Glib::RefPtr<Gtk::TreeStore> store) { Gtk::TreeModel::Row row = *store->get_iter(path); - if(row) { + if (row) { row[_mColumns._colValue] = value; Glib::ustring selector = row[_mColumns._colSelector]; Glib::ustring name = row[_mColumns._colName]; - if(name.empty() && value.empty()) { + if (name.empty() && value.empty()) { store->erase(row); } _writeStyleElement(store, selector); } } -void StyleDialog::_activeToggled(const Glib::ustring& path, Glib::RefPtr<Gtk::TreeStore> store) +void StyleDialog::_activeToggled(const Glib::ustring &path, Glib::RefPtr<Gtk::TreeStore> store) { Gtk::TreeModel::Row row = *store->get_iter(path); - if(row) { + if (row) { row[_mColumns._colActive] = !row[_mColumns._colActive]; Glib::ustring selector = row[_mColumns._colSelector]; _writeStyleElement(store, selector); } } -void StyleDialog::_addWatcherRecursive(Inkscape::XML::Node *node) { +void StyleDialog::_addWatcherRecursive(Inkscape::XML::Node *node) +{ g_debug("StyleDialog::_addWatcherRecursive()"); @@ -1007,12 +998,13 @@ void StyleDialog::_updateWatchers() * @return objVec: a vector of pointers to SPObject's the selector matches. * Return a vector of all objects that selector matches. */ -std::vector<SPObject *> StyleDialog::_getObjVec(Glib::ustring selector) { +std::vector<SPObject *> StyleDialog::_getObjVec(Glib::ustring selector) +{ - std::vector<SPObject *> objVec = SP_ACTIVE_DOCUMENT->getObjectsBySelector( selector ); + std::vector<SPObject *> objVec = SP_ACTIVE_DOCUMENT->getObjectsBySelector(selector); g_debug("StyleDialog::_getObjVec: | %s |", selector.c_str()); - for (auto& obj: objVec) { + for (auto &obj : objVec) { g_debug(" %s", obj->getId() ? obj->getId() : "null"); } @@ -1026,15 +1018,14 @@ void StyleDialog::_closeDialog(Gtk::Dialog *textDialogPtr) { textDialogPtr->resp * Handle document replaced. (Happens when a default document is immediately replaced by another * document in a new window.) */ -void -StyleDialog::_handleDocumentReplaced(SPDesktop *desktop, SPDocument * /* document */) +void StyleDialog::_handleDocumentReplaced(SPDesktop *desktop, SPDocument * /* document */) { g_debug("StyleDialog::handleDocumentReplaced()"); _selection_changed_connection.disconnect(); - _selection_changed_connection = desktop->getSelection()->connectChanged( - sigc::hide(sigc::mem_fun(this, &StyleDialog::_handleSelectionChanged))); + _selection_changed_connection = + desktop->getSelection()->connectChanged(sigc::hide(sigc::mem_fun(this, &StyleDialog::_handleSelectionChanged))); _updateWatchers(); _readStyleElement(); @@ -1044,8 +1035,8 @@ StyleDialog::_handleDocumentReplaced(SPDesktop *desktop, SPDocument * /* documen /* * When a dialog is floating, it is connected to the active desktop. */ -void -StyleDialog::_handleDesktopChanged(SPDesktop* desktop) { +void StyleDialog::_handleDesktopChanged(SPDesktop *desktop) +{ g_debug("StyleDialog::handleDesktopReplaced()"); if (getDesktop() == desktop) { @@ -1057,12 +1048,12 @@ StyleDialog::_handleDesktopChanged(SPDesktop* desktop) { _selection_changed_connection.disconnect(); _document_replaced_connection.disconnect(); - setDesktop( desktop ); + setDesktop(desktop); - _selection_changed_connection = desktop->getSelection()->connectChanged( - sigc::hide(sigc::mem_fun(this, &StyleDialog::_handleSelectionChanged))); - _document_replaced_connection = desktop->connectDocumentReplaced( - sigc::mem_fun(this, &StyleDialog::_handleDocumentReplaced)); + _selection_changed_connection = + desktop->getSelection()->connectChanged(sigc::hide(sigc::mem_fun(this, &StyleDialog::_handleSelectionChanged))); + _document_replaced_connection = + desktop->connectDocumentReplaced(sigc::mem_fun(this, &StyleDialog::_handleDocumentReplaced)); _updateWatchers(); _readStyleElement(); @@ -1072,8 +1063,8 @@ StyleDialog::_handleDesktopChanged(SPDesktop* desktop) { /* * Handle a change in which objects are selected in a document. */ -void -StyleDialog::_handleSelectionChanged() { +void StyleDialog::_handleSelectionChanged() +{ g_debug("StyleDialog::_handleSelectionChanged()"); _readStyleElement(); } diff --git a/src/ui/dialog/styledialog.h b/src/ui/dialog/styledialog.h index 5f65ad7a7..4bbbb689d 100644 --- a/src/ui/dialog/styledialog.h +++ b/src/ui/dialog/styledialog.h @@ -15,18 +15,18 @@ #ifndef STYLEDIALOG_H #define STYLEDIALOG_H -#include <ui/widget/panel.h> -#include <gtkmm/treeview.h> -#include <gtkmm/treestore.h> -#include <gtkmm/treemodelfilter.h> -#include <gtkmm/scrolledwindow.h> +#include <glibmm/regex.h> +#include <gtkmm/builder.h> #include <gtkmm/dialog.h> -#include <gtkmm/treeselection.h> -#include <gtkmm/switch.h> #include <gtkmm/eventbox.h> #include <gtkmm/paned.h> -#include <glibmm/regex.h> -#include <gtkmm/builder.h> +#include <gtkmm/scrolledwindow.h> +#include <gtkmm/switch.h> +#include <gtkmm/treemodelfilter.h> +#include <gtkmm/treeselection.h> +#include <gtkmm/treestore.h> +#include <gtkmm/treeview.h> +#include <ui/widget/panel.h> #include "ui/dialog/desktop-tracker.h" @@ -49,7 +49,7 @@ namespace Dialog { */ class StyleDialog : public Widget::Panel { -public: + public: ~StyleDialog() override; // No default constructor, noncopyable, nonassignable StyleDialog(); @@ -57,6 +57,7 @@ public: StyleDialog operator=(StyleDialog const &d) = delete; static StyleDialog &getInstance() { return *new StyleDialog(); } + private: // Monitor <style> element for changes. class NodeObserver; @@ -64,15 +65,16 @@ public: class NodeWatcher; Glib::RefPtr<Glib::Regex> r_props = Glib::Regex::create("\\s*;\\s*"); Glib::RefPtr<Glib::Regex> r_pair = Glib::Regex::create("\\s*:\\s*"); - std::vector<StyleDialog::NodeWatcher*> _nodeWatchers; - void _nodeAdded( Inkscape::XML::Node &repr ); - void _nodeRemoved( Inkscape::XML::Node &repr ); - void _nodeChanged( Inkscape::XML::Node &repr ); + std::vector<StyleDialog::NodeWatcher *> _nodeWatchers; + void _nodeAdded(Inkscape::XML::Node &repr); + void _nodeRemoved(Inkscape::XML::Node &repr); + void _nodeChanged(Inkscape::XML::Node &repr); /* void _stylesheetChanged( Inkscape::XML::Node &repr ); */ // Data structure class ModelColumns : public Gtk::TreeModel::ColumnRecord { - public: - ModelColumns() { + public: + ModelColumns() + { add(_colActive); add(_colName); add(_colValue); @@ -80,36 +82,37 @@ public: add(_colSelector); add(_colSelectorPos); } - Gtk::TreeModelColumn<bool> _colActive; // Active or inative property - Gtk::TreeModelColumn<Glib::ustring> _colName; // Name of the property. - Gtk::TreeModelColumn<Glib::ustring> _colValue; // Value of the property. - Gtk::TreeModelColumn<bool> _colStrike; // Propery not used, overloaded - Gtk::TreeModelColumn<Glib::ustring> _colSelector; // Style or matching object id. - Gtk::TreeModelColumn<gint> _colSelectorPos; // Position of the selector to hadle dup selectors - + Gtk::TreeModelColumn<bool> _colActive; // Active or inative property + Gtk::TreeModelColumn<Glib::ustring> _colName; // Name of the property. + Gtk::TreeModelColumn<Glib::ustring> _colValue; // Value of the property. + Gtk::TreeModelColumn<bool> _colStrike; // Propery not used, overloaded + Gtk::TreeModelColumn<Glib::ustring> _colSelector; // Style or matching object id. + Gtk::TreeModelColumn<gint> _colSelectorPos; // Position of the selector to hadle dup selectors }; ModelColumns _mColumns; // Widgets Gtk::ScrolledWindow _scrolledWindow; - Gtk::Box _mainBox; - Gtk::Box _styleBox; + Gtk::Box _mainBox; + Gtk::Box _styleBox; Gtk::Switch *_all_css; // Reading and writing the style element. Inkscape::XML::Node *_getStyleTextNode(); void _readStyleElement(); - Glib::RefPtr< Gtk::TreeModel > _selectTree(Glib::ustring selector); + Glib::RefPtr<Gtk::TreeModel> _selectTree(Glib::ustring selector); void _writeStyleElement(Glib::RefPtr<Gtk::TreeStore> store, Glib::ustring selector); - void _activeToggled(const Glib::ustring& path, Glib::RefPtr<Gtk::TreeStore> store); - bool _addRow(GdkEventButton *evt, Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeView *css_tree, Glib::ustring selector, gint pos); - void _nameEdited(const Glib::ustring& path, const Glib::ustring& name, Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeView *css_tree); - void _valueEdited(const Glib::ustring& path, const Glib::ustring& value, Glib::RefPtr<Gtk::TreeStore> store); + void _activeToggled(const Glib::ustring &path, Glib::RefPtr<Gtk::TreeStore> store); + bool _addRow(GdkEventButton *evt, Glib::RefPtr<Gtk::TreeStore> store, Gtk::TreeView *css_tree, + Glib::ustring selector, gint pos); + void _nameEdited(const Glib::ustring &path, const Glib::ustring &name, Glib::RefPtr<Gtk::TreeStore> store, + Gtk::TreeView *css_tree); + void _valueEdited(const Glib::ustring &path, const Glib::ustring &value, Glib::RefPtr<Gtk::TreeStore> store); void _onPropDelete(Glib::ustring path, Glib::RefPtr<Gtk::TreeStore> store); void _reload(); // Update watchers void _addWatcherRecursive(Inkscape::XML::Node *node); - void _updateWatchers(); + void _updateWatchers(); // Manipulate Tree std::vector<SPObject *> _getObjVec(Glib::ustring selector); @@ -117,21 +120,21 @@ public: // Variables Inkscape::XML::Node *_textNode; // Track so we know when to add a NodeObserver. - bool _updating; // Prevent cyclic actions: read <-> write, select via dialog <-> via desktop + bool _updating; // Prevent cyclic actions: read <-> write, select via dialog <-> via desktop // Signals and handlers - External sigc::connection _document_replaced_connection; sigc::connection _desktop_changed_connection; sigc::connection _selection_changed_connection; - void _handleDocumentReplaced(SPDesktop* desktop, SPDocument *document); - void _handleDesktopChanged(SPDesktop* desktop); + void _handleDocumentReplaced(SPDesktop *desktop, SPDocument *document); + void _handleDesktopChanged(SPDesktop *desktop); void _handleSelectionChanged(); void _closeDialog(Gtk::Dialog *textDialogPtr); DesktopTracker _desktopTracker; }; -} // namespace Dialogc +} // namespace Dialog } // namespace UI } // namespace Inkscape diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp index 3afce0164..0a3cabef2 100644 --- a/src/ui/dialog/xml-tree.cpp +++ b/src/ui/dialog/xml-tree.cpp @@ -356,11 +356,11 @@ void XmlTree::propagate_tree_select(Inkscape::XML::Node *repr) repr->type() == Inkscape::XML::COMMENT_NODE)) { attributes->setRepr(repr); - //styles->setRepr(repr); + // styles->setRepr(repr); // selectors->setRepr(repr); } else { attributes->setRepr(nullptr); - //styles->setRepr(nullptr); + // styles->setRepr(nullptr); // selectors->setRepr(nullptr); } } diff --git a/src/ui/dialog/xml-tree.h b/src/ui/dialog/xml-tree.h index 71930ae42..e829a3c75 100644 --- a/src/ui/dialog/xml-tree.h +++ b/src/ui/dialog/xml-tree.h @@ -27,10 +27,10 @@ #include "message.h" -#include "ui/dialog/selectordialog.h" #include "ui/dialog/attrdialog.h" -#include "ui/dialog/styledialog.h" #include "ui/dialog/desktop-tracker.h" +#include "ui/dialog/selectordialog.h" +#include "ui/dialog/styledialog.h" class SPDesktop; diff --git a/src/ui/icon-loader.cpp b/src/ui/icon-loader.cpp index 2b477f573..45e885a74 100644 --- a/src/ui/icon-loader.cpp +++ b/src/ui/icon-loader.cpp @@ -62,7 +62,7 @@ Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, gint size) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/theme/symbolicIcons", false)) { Gtk::IconInfo iconinfo = icon_theme->lookup_icon(icon_name + Glib::ustring("-symbolic"), size, Gtk::ICON_LOOKUP_FORCE_SIZE); - if (iconinfo) { + if (iconinfo) { bool was_simbolic = false; _icon_pixbuf = iconinfo.load_symbolic(SP_ACTIVE_DESKTOP->getToplevel()->get_style_context(), was_simbolic); } else { |
