summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorkamalpreetgrewal <grewalkamal005@gmail.com>2016-07-17 18:44:29 +0000
committerkamalpreetgrewal <grewalkamal005@gmail.com>2016-07-17 18:44:29 +0000
commite0396836d3738f9b6d2182f310795fc6fe9d8857 (patch)
tree5d621b9b5a35cbffb2a14b64708ef713a46199ca /src
parentMerge changes from trunk (diff)
downloadinkscape-e0396836d3738f9b6d2182f310795fc6fe9d8857.tar.gz
inkscape-e0396836d3738f9b6d2182f310795fc6fe9d8857.zip
Add CSS panel with editing support (no changes reflected yet)
(bzr r14949.1.52)
Diffstat (limited to 'src')
-rw-r--r--src/ui/CMakeLists.txt2
-rw-r--r--src/ui/dialog/Makefile_insert2
-rw-r--r--src/ui/dialog/cssdialog.cpp83
-rw-r--r--src/ui/dialog/cssdialog.h66
-rw-r--r--src/ui/dialog/dialog-manager.cpp3
-rw-r--r--src/ui/dialog/styledialog.cpp55
-rw-r--r--src/ui/dialog/styledialog.h2
-rw-r--r--src/verbs.cpp5
-rw-r--r--src/verbs.h1
9 files changed, 219 insertions, 0 deletions
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index 4be3fa3d2..4d838eb7f 100644
--- a/src/ui/CMakeLists.txt
+++ b/src/ui/CMakeLists.txt
@@ -57,6 +57,7 @@ set(ui_SRC
dialog/calligraphic-profile-rename.cpp
dialog/clonetiler.cpp
dialog/color-item.cpp
+ dialog/cssdialog.cpp
dialog/debug.cpp
dialog/desktop-tracker.cpp
dialog/dialog-manager.cpp
@@ -197,6 +198,7 @@ set(ui_SRC
dialog/calligraphic-profile-rename.h
dialog/clonetiler.h
dialog/color-item.h
+ dialog/cssdialog.h
dialog/debug.h
dialog/desktop-tracker.h
dialog/dialog-manager.h
diff --git a/src/ui/dialog/Makefile_insert b/src/ui/dialog/Makefile_insert
index 982908731..3add3f214 100644
--- a/src/ui/dialog/Makefile_insert
+++ b/src/ui/dialog/Makefile_insert
@@ -13,6 +13,8 @@ ink_common_sources += \
ui/dialog/clonetiler.h \
ui/dialog/color-item.cpp \
ui/dialog/color-item.h \
+ ui/dialog/cssdialog.cpp \
+ ui/dialog/cssdialog.h \
ui/dialog/debug.cpp \
ui/dialog/debug.h \
ui/dialog/desktop-tracker.cpp \
diff --git a/src/ui/dialog/cssdialog.cpp b/src/ui/dialog/cssdialog.cpp
new file mode 100644
index 000000000..b0123482b
--- /dev/null
+++ b/src/ui/dialog/cssdialog.cpp
@@ -0,0 +1,83 @@
+/** @file
+ * @brief A dialog for CSS selectors
+ */
+/* Authors:
+ * Kamalpreet Kaur Grewal
+ *
+ * Copyright (C) Kamalpreet Kaur Grewal 2016 <grewalkamal005@gmail.com>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "cssdialog.h"
+#include "ui/widget/addtoicon.h"
+#include "widgets/icon.h"
+#include "verbs.h"
+#include "sp-object.h"
+#include "selection.h"
+#include "xml/attribute-record.h"
+
+namespace Inkscape {
+namespace UI {
+namespace Dialog {
+
+CssDialog::CssDialog():
+ UI::Widget::Panel("", "/dialogs/css", SP_VERB_DIALOG_CSS),
+ _desktop(0)
+{
+ set_size_request(50, 50);
+ _mainBox.pack_start(_scrolledWindow, Gtk::PACK_EXPAND_WIDGET);
+ _treeView.set_headers_visible(false);
+ _scrolledWindow.add(_treeView);
+ _scrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+
+ _store = Gtk::ListStore::create(_cssColumns);
+ _treeView.set_model(_store);
+
+ Inkscape::UI::Widget::AddToIcon * addRenderer = manage(
+ new Inkscape::UI::Widget::AddToIcon() );
+ addRenderer->property_active() = false;
+
+ int addCol = _treeView.append_column("Unset Property", *addRenderer) - 1;
+ Gtk::TreeViewColumn *col = _treeView.get_column(addCol);
+ if ( col ) {
+ col->add_attribute( addRenderer->property_active(), _cssColumns._colUnsetProp);
+ }
+ _textRenderer = Gtk::manage(new Gtk::CellRendererText());
+ _textRenderer->property_editable() = true;
+
+ int nameColNum = _treeView.append_column("Property", *_textRenderer) - 1;
+ _propCol = _treeView.get_column(nameColNum);
+
+ _getContents()->pack_start(_mainBox, Gtk::PACK_EXPAND_WIDGET);
+
+ _targetDesktop = getDesktop();
+ setDesktop(_targetDesktop);
+
+ _textRenderer->signal_edited().connect(sigc::mem_fun(*this, &CssDialog::
+ _handleEdited));
+}
+
+CssDialog::~CssDialog()
+{
+ setDesktop(NULL);
+}
+
+void CssDialog::setDesktop( SPDesktop* desktop )
+{
+ _desktop = desktop;
+}
+
+void CssDialog::_handleEdited(const Glib::ustring& path, const Glib::ustring& new_text)
+{
+ Gtk::TreeModel::iterator iter = _treeView.get_model()->get_iter(path);
+ if (iter) {
+ Gtk::TreeModel::Row row = *iter;
+ row[_cssColumns._propertyLabel] = new_text;
+ editedProp = new_text;
+ }
+}
+
+} // namespace Dialog
+} // namespace UI
+} // namespace Inkscape
diff --git a/src/ui/dialog/cssdialog.h b/src/ui/dialog/cssdialog.h
new file mode 100644
index 000000000..03ffdf972
--- /dev/null
+++ b/src/ui/dialog/cssdialog.h
@@ -0,0 +1,66 @@
+/** @file
+ * @brief A dialog for CSS selectors
+ */
+/* Authors:
+ * Kamalpreet Kaur Grewal
+ *
+ * Copyright (C) Kamalpreet Kaur Grewal 2016 <grewalkamal005@gmail.com>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifndef CSSDIALOG_H
+#define CSSDIALOG_H
+
+#include <gtkmm/treeview.h>
+#include <gtkmm/liststore.h>
+#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/dialog.h>
+#include <ui/widget/panel.h>
+
+#include "desktop.h"
+
+namespace Inkscape {
+namespace UI {
+namespace Dialog {
+
+class CssDialog : public UI::Widget::Panel
+{
+public:
+ CssDialog();
+ ~CssDialog();
+
+ static CssDialog &getInstance() { return *new CssDialog(); }
+ void setDesktop( SPDesktop* desktop);
+
+ class CssColumns : public Gtk::TreeModel::ColumnRecord
+ {
+ public:
+ CssColumns()
+ { add(_colUnsetProp); add(_propertyLabel); }
+ Gtk::TreeModelColumn<bool> _colUnsetProp;
+ Gtk::TreeModelColumn<Glib::ustring> _propertyLabel;
+ };
+
+ SPDesktop* _desktop;
+ SPDesktop* _targetDesktop;
+ CssColumns _cssColumns;
+ Gtk::VBox _mainBox;
+ Gtk::TreeView _treeView;
+ Glib::RefPtr<Gtk::ListStore> _store;
+ Gtk::ScrolledWindow _scrolledWindow;
+ Gtk::TreeModel::Row propRow;
+ Gtk::CellRendererText *_textRenderer;
+ Gtk::TreeViewColumn *_propCol;
+ Glib::ustring editedProp;
+
+ void _handleButtonEvent(const Gtk::TreeModel::Path &path, Gtk::TreeViewColumn*col);
+ void _handleEdited(const Glib::ustring& path, const Glib::ustring& new_text);
+};
+
+
+} // namespace Dialog
+} // namespace UI
+} // namespace Inkscape
+
+#endif // CSSDIALOG_H
diff --git a/src/ui/dialog/dialog-manager.cpp b/src/ui/dialog/dialog-manager.cpp
index 4bb5215fd..a225d193c 100644
--- a/src/ui/dialog/dialog-manager.cpp
+++ b/src/ui/dialog/dialog-manager.cpp
@@ -61,6 +61,7 @@
#include "ui/dialog/objects.h"
#include "ui/dialog/tags.h"
#include "ui/dialog/styledialog.h"
+#include "ui/dialog/cssdialog.h"
namespace Inkscape {
namespace UI {
@@ -130,6 +131,7 @@ DialogManager::DialogManager() {
registerFactory("TileDialog", &create<ArrangeDialog, FloatingBehavior>);
registerFactory("Symbols", &create<SymbolsDialog, FloatingBehavior>);
registerFactory("StyleDialog", &create<StyleDialog, FloatingBehavior>);
+ registerFactory("CssDialog", &create<CssDialog, FloatingBehavior>);
#if HAVE_POTRACE
registerFactory("Trace", &create<TraceDialog, FloatingBehavior>);
@@ -170,6 +172,7 @@ DialogManager::DialogManager() {
registerFactory("TileDialog", &create<ArrangeDialog, DockBehavior>);
registerFactory("Symbols", &create<SymbolsDialog, DockBehavior>);
registerFactory("StyleDialog", &create<StyleDialog, DockBehavior>);
+ registerFactory("CssDialog", &create<CssDialog, DockBehavior>);
#if HAVE_POTRACE
registerFactory("Trace", &create<TraceDialog, DockBehavior>);
diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp
index 174dd5ece..8eeeda3e6 100644
--- a/src/ui/dialog/styledialog.cpp
+++ b/src/ui/dialog/styledialog.cpp
@@ -119,6 +119,8 @@ StyleDialog::StyleDialog() :
(*this, &StyleDialog::
_buttonEventsSelectObjs),
false);
+
+ _cssPane = new CssDialog;
}
StyleDialog::~StyleDialog()
@@ -695,7 +697,60 @@ void StyleDialog::_buttonEventsSelectObjs(GdkEventButton* event )
int x = static_cast<int>(event->x);
int y = static_cast<int>(event->y);
_selectObjects(x, y);
+
//Open CSS dialog here.
+ if (!_cssPane->get_visible()) {
+ _mainBox.pack_end(*_cssPane, Gtk::PACK_SHRINK);
+ _cssPane->show_all();
+ }
+ Glib::RefPtr<Gtk::TreeSelection> refTreeSelection = _treeView.get_selection();
+ Gtk::TreeModel::iterator iter = refTreeSelection->get_selected();
+ if (iter) {
+ Gtk::TreeModel::Row row = *iter;
+ std::string sel, key, value;
+ std::vector<_selectorVecType>::iterator it;
+ for (it = _selectorVec.begin(); it != _selectorVec.end(); ++it) {
+ sel = (*it).second;
+ REMOVE_SPACES(sel);
+ if (!sel.empty()) {
+ key = strtok(strdup(sel.c_str()), "{");
+ REMOVE_SPACES(key);
+ char *temp = strtok(NULL, "}");
+ if (strtok(temp, "}") != NULL) {
+ value = strtok(temp, "}");
+ }
+ }
+
+ Glib::ustring selectedRowLabel = row[_mColumns._selectorLabel];
+ std::string matchSelector = selectedRowLabel;
+ REMOVE_SPACES(matchSelector);
+
+ if (key == matchSelector) {
+ _cssPane->_store->clear();
+ std::stringstream ss(value);
+ std::string token;
+ std::size_t found = value.find(";");
+ if (found!=std::string::npos) {
+ while(std::getline(ss, token, ';')) {
+ REMOVE_SPACES(token);
+ if (!token.empty()) {
+ _cssPane->propRow = *(_cssPane->_store->append());
+ _cssPane->propRow[_cssPane->_cssColumns._colUnsetProp] = false;
+ _cssPane->propRow[_cssPane->_cssColumns._propertyLabel] = token;
+ _cssPane->_propCol->add_attribute(_cssPane->_textRenderer
+ ->property_text(),
+ _cssPane->_cssColumns
+ ._propertyLabel);
+ }
+ }
+ }
+ }
+ }
+ }
+ else {
+ _cssPane->_store->clear();
+ _cssPane->hide();
+ }
}
}
diff --git a/src/ui/dialog/styledialog.h b/src/ui/dialog/styledialog.h
index 08061d923..4f5f212b2 100644
--- a/src/ui/dialog/styledialog.h
+++ b/src/ui/dialog/styledialog.h
@@ -21,6 +21,7 @@
#include "desktop.h"
#include "document.h"
+#include "ui/dialog/cssdialog.h"
namespace Inkscape {
namespace UI {
@@ -85,6 +86,7 @@ private:
std::string _selectorValue;
Gtk::TreeModel::Row _row;
bool _newDrawing;
+ CssDialog *_cssPane;
// Signal handlers
void _addSelector();
diff --git a/src/verbs.cpp b/src/verbs.cpp
index 2908ae580..d4c9c8945 100644
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
@@ -2122,6 +2122,9 @@ void DialogVerb::perform(SPAction *action, void *data)
case SP_VERB_DIALOG_STYLE:
dt->_dlg_mgr->showDialog("StyleDialog");
break;
+ case SP_VERB_DIALOG_CSS:
+ dt->_dlg_mgr->showDialog("CssDialog");
+ break;
default:
break;
@@ -2954,6 +2957,8 @@ Verb *Verb::_base_verbs[] = {
N_("View Tags"), INKSCAPE_ICON("edit-select-all-layers")),
new DialogVerb(SP_VERB_DIALOG_STYLE, "DialogStyle", N_("Style Dialog..."),
N_("View Style Dialog"), NULL),
+ new DialogVerb(SP_VERB_DIALOG_CSS, "DialogCss", N_("Css Dialog..."),
+ N_("View Css Dialog"), NULL),
new DialogVerb(SP_VERB_DIALOG_LIVE_PATH_EFFECT, "DialogLivePathEffect", N_("Path E_ffects ..."),
N_("Manage, edit, and apply path effects"), INKSCAPE_ICON("dialog-path-effects")),
new DialogVerb(SP_VERB_DIALOG_FILTER_EFFECTS, "DialogFilterEffects", N_("Filter _Editor..."),
diff --git a/src/verbs.h b/src/verbs.h
index 35a9ca738..27e913648 100644
--- a/src/verbs.h
+++ b/src/verbs.h
@@ -309,6 +309,7 @@ enum {
SP_VERB_DIALOG_OBJECTS,
SP_VERB_DIALOG_TAGS,
SP_VERB_DIALOG_STYLE,
+ SP_VERB_DIALOG_CSS,
SP_VERB_DIALOG_LIVE_PATH_EFFECT,
SP_VERB_DIALOG_FILTER_EFFECTS,
SP_VERB_DIALOG_SVG_FONTS,