summaryrefslogtreecommitdiffstats
path: root/src/ui/dialog/cssdialog.cpp
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/ui/dialog/cssdialog.cpp
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/ui/dialog/cssdialog.cpp')
-rw-r--r--src/ui/dialog/cssdialog.cpp83
1 files changed, 83 insertions, 0 deletions
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