summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2019-02-18 21:16:38 +0000
committerJabiertxof <jabier.arraiza@marker.es>2019-02-20 15:35:31 +0000
commit2aeeb785bf3f166eb9128b72267605bc6535e17f (patch)
tree23001a2d0b1805449f4bfd92916ed04d05381f80 /src/ui
parentFix compiling issues (diff)
downloadinkscape-2aeeb785bf3f166eb9128b72267605bc6535e17f.tar.gz
inkscape-2aeeb785bf3f166eb9128b72267605bc6535e17f.zip
Merge from master
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/dialog/attrdialog.cpp8
-rw-r--r--src/ui/dialog/cssdialog.cpp79
-rw-r--r--src/ui/dialog/cssdialog.h45
-rw-r--r--src/ui/dialog/styledialog.cpp4
-rw-r--r--src/ui/dialog/styledialog.h3
-rw-r--r--src/ui/dialog/xml-tree.cpp4
-rw-r--r--src/ui/dialog/xml-tree.h5
7 files changed, 70 insertions, 78 deletions
diff --git a/src/ui/dialog/attrdialog.cpp b/src/ui/dialog/attrdialog.cpp
index 601037f04..ce24e3272 100644
--- a/src/ui/dialog/attrdialog.cpp
+++ b/src/ui/dialog/attrdialog.cpp
@@ -63,10 +63,10 @@ namespace Dialog {
* A treeview whose each row corresponds to an XML attribute of a selected node
* New attribute can be added by clicking '+' at bottom of the attr pane. '-'
*/
-AttrDialog::AttrDialog():
- UI::Widget::Panel("/dialogs/attr", SP_VERB_DIALOG_ATTR),
- _desktop(nullptr),
- _repr(nullptr)
+AttrDialog::AttrDialog()
+ : UI::Widget::Panel("/dialogs/attr", SP_VERB_DIALOG_ATTR)
+ , _desktop(nullptr)
+ , _repr(nullptr)
{
set_size_request(20, 15);
_mainBox.pack_start(_scrolledWindow, Gtk::PACK_EXPAND_WIDGET);
diff --git a/src/ui/dialog/cssdialog.cpp b/src/ui/dialog/cssdialog.cpp
index 844481163..7c8312301 100644
--- a/src/ui/dialog/cssdialog.cpp
+++ b/src/ui/dialog/cssdialog.cpp
@@ -16,36 +16,31 @@
#include "message-context.h"
#include "message-stack.h"
-#include "style.h"
#include "selection.h"
#include "style-internal.h"
+#include "style.h"
#include "ui/icon-loader.h"
#include "ui/widget/iconrenderer.h"
#include "verbs.h"
-#include "xml/node-event-vector.h"
#include "xml/attribute-record.h"
+#include "xml/node-event-vector.h"
#include <glibmm/i18n.h>
#include <glibmm/i18n.h>
-static void on_attr_changed (Inkscape::XML::Node * repr,
- const gchar * name,
- const gchar * /*old_value*/,
- const gchar * new_value,
- bool /*is_interactive*/,
- gpointer data)
+static void on_attr_changed(Inkscape::XML::Node *repr, const gchar *name, const gchar * /*old_value*/,
+ const gchar *new_value, bool /*is_interactive*/, gpointer data)
{
CSS_DIALOG(data)->onAttrChanged(repr, name, new_value);
}
Inkscape::XML::NodeEventVector css_repr_events = {
- nullptr, /* child_added */
- nullptr, /* child_removed */
- on_attr_changed,
- nullptr, /* content_changed */
- nullptr /* order_changed */
+ nullptr, /* child_added */
+ nullptr, /* child_removed */
+ on_attr_changed, nullptr, /* content_changed */
+ nullptr /* order_changed */
};
namespace Inkscape {
@@ -61,10 +56,10 @@ namespace Dialog {
* and clicking 'Enter' updates the property with changes reflected in the
* drawing.
*/
-CssDialog::CssDialog():
- UI::Widget::Panel("/dialogs/css", SP_VERB_DIALOG_CSS),
- _desktop(nullptr),
- _repr(nullptr)
+CssDialog::CssDialog()
+ : UI::Widget::Panel("/dialogs/css", SP_VERB_DIALOG_CSS)
+ , _desktop(nullptr)
+ , _repr(nullptr)
{
set_size_request(20, 15);
_treeView.set_headers_visible(true);
@@ -135,7 +130,7 @@ CssDialog::CssDialog():
}
// Set the inital sort column (and direction) to place real attributes at the top.
- _store->set_sort_column (_cssColumns.deleteButton, Gtk::SORT_DESCENDING);
+ _store->set_sort_column(_cssColumns.deleteButton, Gtk::SORT_DESCENDING);
_getContents()->pack_start(*_scrolledWindow, Gtk::PACK_EXPAND_WIDGET);
@@ -180,9 +175,10 @@ void CssDialog::setDesktop(SPDesktop* desktop)
*
* Set the internal xml object that I'm working on right now.
*/
-void CssDialog::setRepr(Inkscape::XML::Node * repr)
+void CssDialog::setRepr(Inkscape::XML::Node *repr)
{
- if ( repr == _repr ) return;
+ if (repr == _repr)
+ return;
if (_repr) {
_store->clear();
_repr->removeListenerByData(this);
@@ -210,11 +206,12 @@ std::map<Glib::ustring, Glib::ustring> CssDialog::parseStyle(Glib::ustring style
REMOVE_SPACES(style_string); // We'd use const, but we need to trip spaces
std::vector<Glib::ustring> props = r_props->split(style_string);
- for (auto const token: props) {
- if (token.empty()) break;
+ for (auto const token : props) {
+ if (token.empty())
+ break;
std::vector<Glib::ustring> pair = r_pair->split(token);
- if( pair.size() > 1) {
+ if (pair.size() > 1) {
ret[pair[0]] = pair[1];
}
}
@@ -230,8 +227,8 @@ std::map<Glib::ustring, Glib::ustring> CssDialog::parseStyle(Glib::ustring style
Glib::ustring CssDialog::compileStyle(std::map<Glib::ustring, Glib::ustring> props)
{
auto ret = Glib::ustring("");
- for (auto const pair: props) {
- if(!pair.first.empty() && !pair.second.empty()) {
+ for (auto const pair : props) {
+ if (!pair.first.empty() && !pair.second.empty()) {
ret += pair.first;
ret += ":";
ret += pair.second;
@@ -247,24 +244,25 @@ Glib::ustring CssDialog::compileStyle(std::map<Glib::ustring, Glib::ustring> pro
*
* This is called when the XML has an updated attribute (we only care about style)
*/
-void CssDialog::onAttrChanged(Inkscape::XML::Node *repr, const gchar * name, const gchar * new_value)
+void CssDialog::onAttrChanged(Inkscape::XML::Node *repr, const gchar *name, const gchar *new_value)
{
- if(strcmp(name, "style")!=0) return;
+ if (strcmp(name, "style") != 0)
+ return;
// Clear the list and return if the new_value is empty
_store->clear();
- if(!new_value || new_value[0] == 0) return;
+ if (!new_value || new_value[0] == 0)
+ return;
// Get the object's style attribute and it's calculated properties
SPDocument *document = this->_desktop->doc();
SPObject *obj = document->getObjectByRepr(repr);
- //std::vector<SPIBase *> calc_prop = obj->style->properties();
+ // std::vector<SPIBase *> calc_prop = obj->style->properties();
// Get a dictionary lookup of the style in the attribute
std::map<Glib::ustring, Glib::ustring> attr_prop = parseStyle(new_value);
- for (auto iter: obj->style->properties())
- {
+ for (auto iter : obj->style->properties()) {
if (iter->style && iter->style_src != SP_STYLE_SRC_UNSET) {
Gtk::TreeModel::Row row = *(_store->append());
// Delete is available to attribute properties only in attr mode.
@@ -288,7 +286,7 @@ void CssDialog::onAttrChanged(Inkscape::XML::Node *repr, const gchar * name, con
}
}
- /*
+/*
* Sets the CSSDialog status bar, depending on which attr is selected.
*/
void CssDialog::css_reset_context(gint css)
@@ -314,27 +312,22 @@ bool CssDialog::setStyleProperty(Glib::ustring name, Glib::ustring value)
std::map<Glib::ustring, Glib::ustring> properties = parseStyle(original);
bool updated = false;
- if(value != nullptr && !value.empty())
- {
- if(properties[name] != value)
- {
+ if (value != nullptr && !value.empty()) {
+ if (properties[name] != value) {
// Set value (create or update)
properties[name] = value;
updated = true;
}
- }
- else if (properties.count(name))
- {
+ } else if (properties.count(name)) {
// Delete value
properties.erase(name);
updated = true;
}
- if (updated)
- {
+ if (updated) {
auto new_styles = this->compileStyle(properties);
this->_repr->setAttribute("style", new_styles, false);
- //this->setUndo(_("Delete style property"));
+ // this->setUndo(_("Delete style property"));
}
return updated;
}
@@ -358,7 +351,7 @@ void CssDialog::onPropertyDelete(Glib::ustring path)
*/
bool CssDialog::onPropertyCreate(GdkEventButton *event)
{
- if(event->type == GDK_BUTTON_RELEASE && event->button == 1 && this->_repr) {
+ if (event->type == GDK_BUTTON_RELEASE && event->button == 1 && this->_repr) {
Gtk::TreeIter iter = _store->append();
Gtk::TreeModel::Path path = (Gtk::TreeModel::Path)iter;
_treeView.set_cursor(path, *_propCol, true);
diff --git a/src/ui/dialog/cssdialog.h b/src/ui/dialog/cssdialog.h
index 4c2498b38..6c5a0fe4c 100644
--- a/src/ui/dialog/cssdialog.h
+++ b/src/ui/dialog/cssdialog.h
@@ -18,20 +18,17 @@
#include "desktop.h"
#include "message.h"
-
#include <glibmm/regex.h>
-#include <gtkmm/treeview.h>
-<<<<<<< HEAD
-=======
#include <gtkmm/dialog.h>
->>>>>>> Fix compiling issues
#include <gtkmm/liststore.h>
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/treeview.h>
#include <ui/widget/panel.h>
-#define CSS_DIALOG(obj) (dynamic_cast<Inkscape::UI::Dialog::CssDialog*>((Inkscape::UI::Dialog::CssDialog*)obj))
-#define REMOVE_SPACES(x) x.erase(0, x.find_first_not_of(' ')); x.erase(x.find_last_not_of(' ') + 1);
+#define CSS_DIALOG(obj) (dynamic_cast<Inkscape::UI::Dialog::CssDialog *>((Inkscape::UI::Dialog::CssDialog *)obj))
+#define REMOVE_SPACES(x) \
+ x.erase(0, x.find_first_not_of(' ')); \
+ x.erase(x.find_last_not_of(' ') + 1);
namespace Inkscape {
class MessageStack;
@@ -58,15 +55,15 @@ public:
class CssColumns : public Gtk::TreeModel::ColumnRecord {
public:
CssColumns() {
- add(deleteButton);
- add(label);
- add(_styleSheetVal);
- add(_styleAttrVal);
- add(label_color);
- add(attr_color);
- add(attr_strike);
- add(editable);
- }
+ add(deleteButton);
+ add(label);
+ add(_styleSheetVal);
+ add(_styleAttrVal);
+ add(label_color);
+ add(attr_color);
+ add(attr_strike);
+ add(editable);
+ }
Gtk::TreeModelColumn<bool> deleteButton;
Gtk::TreeModelColumn<Glib::ustring> label;
Gtk::TreeModelColumn<Glib::ustring> _styleAttrVal;
@@ -103,23 +100,20 @@ public:
// Variables - Inkscape
SPDesktop* _desktop;
- Inkscape::XML::Node* _repr;
+ Inkscape::XML::Node *_repr;
// Helper functions
void setDesktop(SPDesktop* desktop) override;
- void setRepr(Inkscape::XML::Node * repr);
+ void setRepr(Inkscape::XML::Node *repr);
// Parsing functions
std::map<Glib::ustring, Glib::ustring> parseStyle(Glib::ustring style_string);
Glib::ustring compileStyle(std::map<Glib::ustring, Glib::ustring> props);
-
- */
// Signal handlers
- void onAttrChanged(Inkscape::XML::Node *repr, const gchar * name, const gchar * new_value);
-
-private:
+ void onAttrChanged(Inkscape::XML::Node *repr, const gchar *name, const gchar *new_value);
+ private:
Glib::RefPtr<Glib::Regex> r_props = Glib::Regex::create("\\s*;\\s*");
Glib::RefPtr<Glib::Regex> r_pair = Glib::Regex::create("\\s*:\\s*");
@@ -127,6 +121,11 @@ private:
void onPropertyDelete(Glib::ustring path);
bool setStyleProperty(Glib::ustring name, Glib::ustring value);
+ /**
+ * Signal handlers
+ */
+ sigc::connection _message_changed_connection;
+ bool _addProperty(GdkEventButton *event);
};
diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp
index d5769b955..2f126452a 100644
--- a/src/ui/dialog/styledialog.cpp
+++ b/src/ui/dialog/styledialog.cpp
@@ -397,7 +397,7 @@ Inkscape::XML::Node* StyleDialog::_getStyleTextNode()
*/
void StyleDialog::_readStyleElement()
{
- g_debug("StyleDialog::_readStyleElement: updating %s", (_updating?"true":"false"));
+ g_debug("StyleDialog::_readStyleElement: updating %s", (_updating ? "true" : "false"));
if (_updating) return; // Don't read if we wrote style element.
_updating = true;
@@ -1098,7 +1098,7 @@ void StyleDialog::_buttonEventsSelectObjs(GdkEventButton* event )
*/
void StyleDialog::_selectRow()
{
- g_debug("StyleDialog::_selectRow: updating: %s", (_updating?"true":"false"));
+ g_debug("StyleDialog::_selectRow: updating: %s", (_updating ? "true" : "false"));
if (_updating || !getDesktop()) return; // Avoid updating if we have set row via dialog.
diff --git a/src/ui/dialog/styledialog.h b/src/ui/dialog/styledialog.h
index d11082bc1..f0fb6eddb 100644
--- a/src/ui/dialog/styledialog.h
+++ b/src/ui/dialog/styledialog.h
@@ -53,8 +53,7 @@ public:
static StyleDialog &getInstance() { return *new StyleDialog(); }
-private:
-
+ private:
// Monitor <style> element for changes.
class NodeObserver;
diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp
index 1cbf01107..1a96356f0 100644
--- a/src/ui/dialog/xml-tree.cpp
+++ b/src/ui/dialog/xml-tree.cpp
@@ -358,11 +358,11 @@ void XmlTree::propagate_tree_select(Inkscape::XML::Node *repr)
{
attributes->setRepr(repr);
styles->setRepr(repr);
- //selectors->setRepr(repr);
+ // selectors->setRepr(repr);
} else {
attributes->setRepr(nullptr);
styles->setRepr(nullptr);
- //selectors->setRepr(nullptr);
+ // selectors->setRepr(nullptr);
}
}
diff --git a/src/ui/dialog/xml-tree.h b/src/ui/dialog/xml-tree.h
index 918a7c8fd..67cc300c8 100644
--- a/src/ui/dialog/xml-tree.h
+++ b/src/ui/dialog/xml-tree.h
@@ -25,11 +25,11 @@
#include <gtkmm/textview.h>
#include <gtkmm/toolbar.h>
+#include "message.h"
#include "ui/dialog/attrdialog.h"
#include "ui/dialog/cssdialog.h"
-#include "ui/dialog/styledialog.h"
#include "ui/dialog/desktop-tracker.h"
-#include "message.h"
+#include "ui/dialog/styledialog.h"
class SPDesktop;
class SPObject;
@@ -184,6 +184,7 @@ private:
FLOWBOX_PAGE_NODES,
FLOWBOX_PAGE_ATTRS,
FLOWBOX_PAGE_STYLES,
+ FLOWBOX_PAGE_SELECTORS,
};
/**