summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2019-05-05 11:06:47 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2019-06-02 09:50:17 +0000
commit964a5ef8c110762fdd39578c45261e4d65e06404 (patch)
tree96082900d6aa349b9bfb8dc1250440baf1fccf12 /src
parentstarting refactor (diff)
downloadinkscape-964a5ef8c110762fdd39578c45261e4d65e06404.tar.gz
inkscape-964a5ef8c110762fdd39578c45261e4d65e06404.zip
simplification of code
Diffstat (limited to 'src')
-rw-r--r--src/ui/dialog/styledialog.cpp51
-rw-r--r--src/ui/dialog/styledialog.h13
2 files changed, 11 insertions, 53 deletions
diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp
index f98e77720..d721badc9 100644
--- a/src/ui/dialog/styledialog.cpp
+++ b/src/ui/dialog/styledialog.cpp
@@ -194,7 +194,7 @@ StyleDialog::StyleDialog() :
_selection_changed_connection = getDesktop()->getSelection()->connectChanged(
sigc::hide(sigc::mem_fun(this, &StyleDialog::_handleSelectionChanged)));
-
+
// Add watchers
_updateWatchers();
@@ -269,25 +269,12 @@ Inkscape::XML::Node* StyleDialog::_getStyleTextNode()
return textNode;
}
-void StyleDialog::_hideRootToggle( Gtk::CellRenderer* renderer, const Gtk::TreeModel::iterator& iter)
-{
- //Get the value from the model and show it appropriately in the view:
- Gtk::CellRendererToggle* toggle = dynamic_cast<Gtk::CellRendererToggle*>(renderer);
- Gtk::TreeModel::Row row = *iter;
- Gtk::TreeModel::iterator parent = row->parent();
- if (parent) {
- toggle->set_visible(true);
- } else {
- toggle->set_visible(false);
- }
-}
-
/**
* Fill the Gtk::TreeStore from the svg:style element.
*/
void StyleDialog::_readStyleElement()
{
- g_debug("StyleDialog::_readStyleElement: updating %s", (_updating ? "true" : "false"));
+ g_debug("StyleDialog::_readStyleElement");
if (_updating) return; // Don't read if we wrote style element.
_updating = true;
@@ -356,10 +343,6 @@ void StyleDialog::_readStyleElement()
std::vector<Glib::ustring> tokens = Glib::Regex::split_simple("[}{]", content);
// If text node is empty, return (avoids problem with negative below).
- if (tokens.size() == 0) {
- _updating = false;
- return;
- }
for (auto child:_styleBox.get_children()) {
_styleBox.remove(*child);
@@ -487,7 +470,7 @@ void StyleDialog::_readStyleElement()
Glib::RefPtr<Gtk::TreeStore> store = Gtk::TreeStore::create(_mColumns);
for (auto iter : obj->style->properties()) {
if (iter->style_src != SP_STYLE_SRC_UNSET) {
- if( iter->name != "font" && 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) {
@@ -543,6 +526,10 @@ void StyleDialog::_readStyleElement()
}
}
if (obj) {
+ if (tokens.size() == 0) {
+ _updating = false;
+ return;
+ }
for (unsigned i = 0; i < tokens.size()-1; i += 2) {
Glib::ustring selector = tokens[i];
REMOVE_SPACES(selector); // Remove leading/trailing spaces
@@ -708,7 +695,7 @@ void StyleDialog::_writeStyleElement()
return;
}
_updating = true;
-
+
Glib::ustring styleContent;
/* for (auto& row: _store->children()) {
Glib::ustring selector = row[_mColumns._colData];
@@ -793,28 +780,6 @@ std::vector<SPObject *> StyleDialog::_getObjVec(Glib::ustring selector) {
void StyleDialog::_closeDialog(Gtk::Dialog *textDialogPtr) { textDialogPtr->response(Gtk::RESPONSE_OK); }
-// -------------------------------------------------------------------
-
-class PropertyData
-{
-public:
- PropertyData() = default;;
- PropertyData(Glib::ustring name) : _name(std::move(name)) {};
-
- void _setSheetValue(Glib::ustring value) { _sheetValue = value; };
- void _setAttrValue(Glib::ustring value) { _attrValue = value; };
- Glib::ustring _getName() { return _name; };
- Glib::ustring _getSheetValue() { return _sheetValue; };
- Glib::ustring _getAttrValue() { return _attrValue; };
-
-private:
- Glib::ustring _name;
- Glib::ustring _sheetValue;
- Glib::ustring _attrValue;
-};
-
-// -------------------------------------------------------------------
-
/**
* Handle document replaced. (Happens when a default document is immediately replaced by another
diff --git a/src/ui/dialog/styledialog.h b/src/ui/dialog/styledialog.h
index 6ba4fe345..dab0fed8c 100644
--- a/src/ui/dialog/styledialog.h
+++ b/src/ui/dialog/styledialog.h
@@ -57,7 +57,6 @@ public:
private:
// Monitor <style> element for changes.
class NodeObserver;
-
// Monitor all objects for addition/removal/attribute change
class NodeWatcher;
Glib::RefPtr<Glib::Regex> r_props = Glib::Regex::create("\\s*;\\s*");
@@ -96,17 +95,16 @@ public:
// Update watchers
void _addWatcherRecursive(Inkscape::XML::Node *node);
- void _updateWatchers();
-
+ void _updateWatchers();
+
// Manipulate Tree
std::vector<SPObject *> _getObjVec(Glib::ustring selector);
std::map<Glib::ustring, Glib::ustring> parseStyle(Glib::ustring style_string);
-
// 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
-
+
// Signals and handlers - External
sigc::connection _document_replaced_connection;
sigc::connection _desktop_changed_connection;
@@ -115,13 +113,8 @@ public:
void _handleDocumentReplaced(SPDesktop* desktop, SPDocument *document);
void _handleDesktopChanged(SPDesktop* desktop);
void _handleSelectionChanged();
- 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);
- void _hideRootToggle( Gtk::CellRenderer* renderer, const Gtk::TreeModel::iterator& iter);
DesktopTracker _desktopTracker;
-
- Inkscape::XML::SignalObserver _objObserver; // Track object in selected row (for style change).
};
} // namespace Dialogc