diff options
Diffstat (limited to 'src/ui/dialog')
| -rw-r--r-- | src/ui/dialog/selectorsdialog.cpp | 19 | ||||
| -rw-r--r-- | src/ui/dialog/selectorsdialog.h | 8 | ||||
| -rw-r--r-- | src/ui/dialog/styledialog.cpp | 46 | ||||
| -rw-r--r-- | src/ui/dialog/styledialog.h | 3 |
4 files changed, 41 insertions, 35 deletions
diff --git a/src/ui/dialog/selectorsdialog.cpp b/src/ui/dialog/selectorsdialog.cpp index 3cc0a1739..bbe0576dc 100644 --- a/src/ui/dialog/selectorsdialog.cpp +++ b/src/ui/dialog/selectorsdialog.cpp @@ -34,9 +34,9 @@ #include <regex> #include <utility> -// G_MESSAGES_DEBUG=DEBUG_STYLEDIALOG gdb ./inkscape -//#define DEBUG_SELECTORSDIALOG -//#define G_LOG_DOMAIN "SELECTORSDIALOG" +// G_MESSAGES_DEBUG=DEBUG_SELECTORSDIALOG gdb ./inkscape +// #define DEBUG_SELECTORSDIALOG +// #define G_LOG_DOMAIN "SELECTORSDIALOG" using Inkscape::DocumentUndo; using Inkscape::Util::List; @@ -380,6 +380,7 @@ void SelectorsDialog::_showWidgets() int panedpos = prefs->getInt("/dialogs/selectors/panedpos", widthpos / 2); _paned.property_position().signal_changed().connect(sigc::mem_fun(*this, &SelectorsDialog::_childresized)); _paned.signal_size_allocate().connect(sigc::mem_fun(*this, &SelectorsDialog::_panedresized)); + _paned.signal_realize().connect(sigc::mem_fun(*this, &SelectorsDialog::_panedrealized)); _updating = true; _paned.property_position() = panedpos; _updating = false; @@ -393,6 +394,11 @@ void SelectorsDialog::_panedresized(Gtk::Allocation allocation) _resized(); } +void SelectorsDialog::_panedrealized() +{ + _style_dialog->readStyleElement(); +} + void SelectorsDialog::_childresized() { g_debug("SelectorsDialog::_childresized"); @@ -417,6 +423,7 @@ void SelectorsDialog::_resized() if (_paned.property_position() < min) { _paned.property_position() = min; } + prefs->setInt("/dialogs/selectors/panedpos", _paned.property_position()); _updating = false; } @@ -504,14 +511,14 @@ Inkscape::XML::Node *SelectorsDialog::_getStyleTextNode() */ void SelectorsDialog::_readStyleElement() { - g_debug("SelectorsDialog::_readStyleElement: updating %s", (_updating ? "true" : "false")); + g_debug("SelectorsDialog::_readStyleElement(): updating %s", (_updating ? "true" : "false")); if (_updating) return; // Don't read if we wrote style element. _updating = true; _scroollock = true; Inkscape::XML::Node * textNode = _getStyleTextNode(); if (textNode == nullptr) { - std::cerr << "SelectorsDialog::_readStyleElement: No text node!" << std::endl; + std::cerr << "SelectorsDialog::_readStyleElement(): No text node!" << std::endl; } // Get content from style text node. @@ -583,7 +590,7 @@ void SelectorsDialog::_readStyleElement() if ((i+1) < tokens.size()) { properties = tokens[i+1]; } else { - std::cerr << "SelectorsDialog::_readStyleElement: Missing values " + std::cerr << "SelectorsDialog::_readStyleElement(): Missing values " "for last selector!" << std::endl; } diff --git a/src/ui/dialog/selectorsdialog.h b/src/ui/dialog/selectorsdialog.h index 66d9bb859..d304ccfad 100644 --- a/src/ui/dialog/selectorsdialog.h +++ b/src/ui/dialog/selectorsdialog.h @@ -55,9 +55,8 @@ class SelectorsDialog : public Widget::Panel { SelectorsDialog(); SelectorsDialog(SelectorsDialog const &d) = delete; SelectorsDialog operator=(SelectorsDialog const &d) = delete; - static SelectorsDialog &getInstance() { return *new SelectorsDialog(); } - + private: // Monitor <style> element for changes. class NodeObserver; @@ -119,6 +118,7 @@ class SelectorsDialog : public Widget::Panel { Gtk::TreeView _treeView; Gtk::TreeModel::Path _lastpath; // Widgets + StyleDialog *_style_dialog; Gtk::Paned _paned; Glib::RefPtr<Gtk::Adjustment> _vadj; Gtk::Box _button_box; @@ -127,7 +127,6 @@ class SelectorsDialog : public Widget::Panel { Gtk::Button _del; Gtk::Button _create; - StyleDialog *_style_dialog; // Reading and writing the style element. Inkscape::XML::Node *_getStyleTextNode(); void _readStyleElement(); @@ -154,9 +153,9 @@ class SelectorsDialog : public Widget::Panel { void _selectObjects(int, int); // Variables - bool _updating; // Prevent cyclic actions: read <-> write, select via dialog <-> via desktop double _scroolpos; bool _scroollock; + bool _updating; // Prevent cyclic actions: read <-> write, select via dialog <-> via desktop Inkscape::XML::Node *_textNode; // Track so we know when to add a NodeObserver. // Signals and handlers - External @@ -167,6 +166,7 @@ class SelectorsDialog : public Widget::Panel { void _handleDocumentReplaced(SPDesktop* desktop, SPDocument *document); void _handleDesktopChanged(SPDesktop* desktop); void _handleSelectionChanged(); + void _panedrealized(); void _rowExpand(const Gtk::TreeModel::iterator &iter, const Gtk::TreeModel::Path &path); void _rowCollapse(const Gtk::TreeModel::iterator &iter, const Gtk::TreeModel::Path &path); void _closeDialog(Gtk::Dialog *textDialogPtr); diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp index 89c6337ef..975e28dd7 100644 --- a/src/ui/dialog/styledialog.cpp +++ b/src/ui/dialog/styledialog.cpp @@ -79,7 +79,7 @@ void StyleDialog::NodeObserver::notifyContentChanged(Inkscape::XML::Node & /*nod g_debug("StyleDialog::NodeObserver::notifyContentChanged"); _styledialog->_updating = false; - _styledialog->_readStyleElement(); + _styledialog->readStyleElement(); } @@ -148,7 +148,7 @@ void StyleDialog::_nodeAdded(Inkscape::XML::Node &node) node.addObserver(*w); _nodeWatchers.push_back(w); - _readStyleElement(); + readStyleElement(); } void StyleDialog::_nodeRemoved(Inkscape::XML::Node &repr) @@ -163,19 +163,19 @@ void StyleDialog::_nodeRemoved(Inkscape::XML::Node &repr) break; } } - _readStyleElement(); + readStyleElement(); } void StyleDialog::_nodeChanged(Inkscape::XML::Node &object) { g_debug("StyleDialog::_nodeChanged"); - _readStyleElement(); + readStyleElement(); } /* void StyleDialog::_stylesheetChanged( Inkscape::XML::Node &repr ) { std::cout << "Style tag modified" << std::endl; - _readStyleElement(); + readStyleElement(); } */ /** @@ -221,7 +221,7 @@ StyleDialog::StyleDialog() _updateWatchers(); // Load tree - _readStyleElement(); + readStyleElement(); } void StyleDialog::_vscrool() @@ -282,7 +282,7 @@ 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. @@ -379,7 +379,7 @@ void StyleDialog::setCurrentSelector(Glib::ustring current_selector) { g_debug("StyleDialog::setCurrentSelector"); _current_selector = current_selector; - _readStyleElement(); + readStyleElement(); } // copied from style.cpp:1499 @@ -397,9 +397,9 @@ static bool is_url(char const *p) /** * Fill the Gtk::TreeStore from the svg:style element. */ -void StyleDialog::_readStyleElement() +void StyleDialog::readStyleElement() { - g_debug("StyleDialog::_readStyleElement"); + g_debug("StyleDialog::readStyleElement"); if (_updating) return; // Don't read if we wrote style element. @@ -407,7 +407,7 @@ void StyleDialog::_readStyleElement() _scroollock = true; Inkscape::XML::Node *textNode = _getStyleTextNode(); if (textNode == nullptr) { - std::cerr << "StyleDialog::_readStyleElement: No text node!" << std::endl; + std::cerr << "StyleDialog::readStyleElement: No text node!" << std::endl; } SPDocument *document = SP_ACTIVE_DOCUMENT; @@ -620,7 +620,7 @@ void StyleDialog::_readStyleElement() if ((i + 1) < tokens.size()) { properties = tokens[i + 1]; } else { - std::cerr << "StyleDialog::_readStyleElement: Missing values " + std::cerr << "StyleDialog::readStyleElement: Missing values " "for last selector!" << std::endl; } @@ -659,14 +659,14 @@ void StyleDialog::_readStyleElement() */ 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; + int addCol = css_tree->append_column("", *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)); } Gtk::CellRendererToggle *active = Gtk::manage(new Gtk::CellRendererToggle); - addCol = css_tree->append_column("Active Property", *active) - 1; + addCol = css_tree->append_column("", *active) - 1; col = css_tree->get_column(addCol); if (col) { col->add_attribute(active->property_active(), _mColumns._colActive); @@ -692,7 +692,7 @@ void StyleDialog::_readStyleElement() sigc::bind<Glib::RefPtr<Gtk::TreeStore>>(sigc::mem_fun(*this, &StyleDialog::_valueEdited), store)); value->signal_editing_started().connect( sigc::bind<Glib::RefPtr<Gtk::TreeStore>>(sigc::mem_fun(*this, &StyleDialog::_startValueEdit), store)); - addCol = css_tree->append_column("CSS Value", *value) - 1; + addCol = css_tree->append_column("", *value) - 1; col = css_tree->get_column(addCol); if (col) { col->add_attribute(value->property_text(), _mColumns._colValue); @@ -808,7 +808,7 @@ void StyleDialog::_readStyleElement() 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; + int addCol = css_tree->append_column("", *addRenderer) - 1; Gtk::TreeViewColumn *col = css_tree->get_column(addCol); if (col) { addRenderer->signal_activated().connect(sigc::bind<Glib::RefPtr<Gtk::TreeStore>>( @@ -820,7 +820,7 @@ void StyleDialog::_readStyleElement() label->signal_edited().connect(sigc::bind<Glib::RefPtr<Gtk::TreeStore>, Gtk::TreeView *>( sigc::mem_fun(*this, &StyleDialog::_nameEdited), store, css_tree)); label->signal_editing_started().connect(sigc::mem_fun(*this, &StyleDialog::_startNameEdit)); - addCol = css_tree->append_column("CSS Property", *label) - 1; + addCol = css_tree->append_column("", *label) - 1; col = css_tree->get_column(addCol); if (col) { col->set_resizable(true); @@ -834,7 +834,7 @@ void StyleDialog::_readStyleElement() value->signal_editing_started().connect(sigc::bind<Glib::RefPtr<Gtk::TreeStore>>( sigc::mem_fun(*this, &StyleDialog::_startValueEdit), store)); - addCol = css_tree->append_column("CSS Value", *value) - 1; + addCol = css_tree->append_column("", *value) - 1; col = css_tree->get_column(addCol); if (col) { col->add_attribute(value->property_text(), _mColumns._colValue); @@ -1046,7 +1046,7 @@ void StyleDialog::_writeStyleElement(Glib::RefPtr<Gtk::TreeStore> store, Glib::u obj = getDesktop()->getDocument()->getXMLDialogSelectedObject(); } if (selection->objects().size() < 2 && !obj) { - _readStyleElement(); + readStyleElement(); return; } _updating = true; @@ -1119,7 +1119,7 @@ void StyleDialog::_writeStyleElement(Glib::RefPtr<Gtk::TreeStore> store, Glib::u INKSCAPE.readStyleSheets(true); } _updating = false; - _readStyleElement(); + readStyleElement(); /* SPDocument *document = SP_ACTIVE_DOCUMENT; for (auto iter : document->getObjectsBySelector(selector)) { std::cout << std::endl; @@ -1556,7 +1556,7 @@ void StyleDialog::_handleDocumentReplaced(SPDesktop *desktop, SPDocument * /* do desktop->getSelection()->connectChanged(sigc::hide(sigc::mem_fun(this, &StyleDialog::_handleSelectionChanged))); _updateWatchers(); - _readStyleElement(); + readStyleElement(); } @@ -1583,7 +1583,7 @@ void StyleDialog::_handleDesktopChanged(SPDesktop *desktop) desktop->connectDocumentReplaced(sigc::mem_fun(this, &StyleDialog::_handleDocumentReplaced)); _updateWatchers(); - _readStyleElement(); + readStyleElement(); } @@ -1595,7 +1595,7 @@ void StyleDialog::_handleSelectionChanged() g_debug("StyleDialog::_handleSelectionChanged()"); _scroolpos = 0; _vadj->set_value(0); - _readStyleElement(); + readStyleElement(); } } // namespace Dialog diff --git a/src/ui/dialog/styledialog.h b/src/ui/dialog/styledialog.h index b7ccf6619..07dfd8a0e 100644 --- a/src/ui/dialog/styledialog.h +++ b/src/ui/dialog/styledialog.h @@ -71,7 +71,7 @@ class StyleDialog : public Widget::Panel { Gtk::TreeViewColumn *_current_value_col; Gtk::TreeModel::Path _current_path; Glib::ustring fixCSSSelectors(Glib::ustring selector); - + void readStyleElement(); private: // Monitor <style> element for changes. class NodeObserver; @@ -125,7 +125,6 @@ class StyleDialog : public Widget::Panel { Gtk::Box _styleBox; // Reading and writing the style element. Inkscape::XML::Node *_getStyleTextNode(); - void _readStyleElement(); Glib::RefPtr<Gtk::TreeModel> _selectTree(Glib::ustring selector); void _writeStyleElement(Glib::RefPtr<Gtk::TreeStore> store, Glib::ustring selector, Glib::ustring new_selector = ""); |
