summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/menus-skeleton.h1
-rw-r--r--src/ui/CMakeLists.txt2
-rw-r--r--src/ui/dialog/dialog-manager.cpp3
-rw-r--r--src/ui/dialog/styledialog.cpp113
-rw-r--r--src/ui/dialog/styledialog.h69
-rw-r--r--src/verbs.cpp5
-rw-r--r--src/verbs.h1
7 files changed, 194 insertions, 0 deletions
diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h
index 9c7c65140..9b8586ec2 100644
--- a/src/menus-skeleton.h
+++ b/src/menus-skeleton.h
@@ -183,6 +183,7 @@ static char const menus_skeleton[] =
" <submenu name=\"" N_("_Object") "\">\n"
" <verb verb-id=\"DialogObjects\" />\n"
" <verb verb-id=\"DialogTags\" />\n"
+" <verb verb-id=\"DialogStyle\" />\n"
" <separator/>\n"
" <verb verb-id=\"DialogFillStroke\" />\n"
" <verb verb-id=\"DialogObjectProperties\" />\n"
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index 587974b90..4be3fa3d2 100644
--- a/src/ui/CMakeLists.txt
+++ b/src/ui/CMakeLists.txt
@@ -99,6 +99,7 @@ set(ui_SRC
dialog/print-colors-preview-dialog.cpp
dialog/print.cpp
dialog/spellcheck.cpp
+ dialog/styledialog.cpp
dialog/svg-fonts-dialog.cpp
dialog/swatches.cpp
dialog/symbols.cpp
@@ -240,6 +241,7 @@ set(ui_SRC
dialog/print-colors-preview-dialog.h
dialog/print.h
dialog/spellcheck.h
+ dialog/styledialog.h
dialog/svg-fonts-dialog.h
dialog/swatches.h
dialog/symbols.h
diff --git a/src/ui/dialog/dialog-manager.cpp b/src/ui/dialog/dialog-manager.cpp
index 49853277c..4bb5215fd 100644
--- a/src/ui/dialog/dialog-manager.cpp
+++ b/src/ui/dialog/dialog-manager.cpp
@@ -60,6 +60,7 @@
#include "ui/dialog/svg-fonts-dialog.h"
#include "ui/dialog/objects.h"
#include "ui/dialog/tags.h"
+#include "ui/dialog/styledialog.h"
namespace Inkscape {
namespace UI {
@@ -128,6 +129,7 @@ DialogManager::DialogManager() {
registerFactory("Swatches", &create<SwatchesPanel, FloatingBehavior>);
registerFactory("TileDialog", &create<ArrangeDialog, FloatingBehavior>);
registerFactory("Symbols", &create<SymbolsDialog, FloatingBehavior>);
+ registerFactory("StyleDialog", &create<StyleDialog, FloatingBehavior>);
#if HAVE_POTRACE
registerFactory("Trace", &create<TraceDialog, FloatingBehavior>);
@@ -167,6 +169,7 @@ DialogManager::DialogManager() {
registerFactory("Swatches", &create<SwatchesPanel, DockBehavior>);
registerFactory("TileDialog", &create<ArrangeDialog, DockBehavior>);
registerFactory("Symbols", &create<SymbolsDialog, DockBehavior>);
+ registerFactory("StyleDialog", &create<StyleDialog, DockBehavior>);
#if HAVE_POTRACE
registerFactory("Trace", &create<TraceDialog, DockBehavior>);
diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp
new file mode 100644
index 000000000..7e555ddb2
--- /dev/null
+++ b/src/ui/dialog/styledialog.cpp
@@ -0,0 +1,113 @@
+#include "styledialog.h"
+#include "widgets/icon.h"
+#include "verbs.h"
+#include "sp-object.h"
+#include "selection.h"
+
+namespace Inkscape {
+namespace UI {
+namespace Dialog {
+
+void StyleDialog::_styleButton(Gtk::Button& btn, char const* iconName,
+ char const* tooltip)
+{
+ GtkWidget *child = sp_icon_new(Inkscape::ICON_SIZE_SMALL_TOOLBAR, iconName);
+ gtk_widget_show(child);
+ btn.add(*manage(Glib::wrap(child)));
+ btn.set_relief(Gtk::RELIEF_NONE);
+ btn.set_tooltip_text (tooltip);
+}
+
+/**
+ * Constructor
+ * A treeview and a set of two buttons are added to the dialog. _addSelector
+ * adds selectors to treeview. Currently, delete button is disabled.
+ */
+StyleDialog::StyleDialog() :
+ UI::Widget::Panel("", "/dialogs/style", SP_VERB_DIALOG_STYLE),
+ _desktop(0)
+{
+ set_size_request(200, 200);
+ add(_mainBox);
+
+ _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(_mColumns);
+ _treeView.set_model(_store);
+ _treeView.append_column("Selector Number", _mColumns._selectorNumber);
+ _treeView.append_column("Selector Name", _mColumns._selectorLabel);
+
+ Gtk::Button* create = manage( new Gtk::Button() );
+ _styleButton(*create, "list-add", "Add a new CSS Selector");
+ create->signal_clicked().connect(sigc::mem_fun(*this,
+ &StyleDialog::_addSelector));
+
+ Gtk::Button* del = manage( new Gtk::Button() );
+ _styleButton(*del, "list-remove", "Remove a CSS Selector");
+ del->set_sensitive(false);
+
+ _mainBox.pack_start(_buttonBox, Gtk::PACK_SHRINK);
+ _buttonBox.pack_start(*create, Gtk::PACK_SHRINK);
+ _buttonBox.pack_start(*del, Gtk::PACK_SHRINK);
+
+ SPDesktop* targetDesktop = getDesktop();
+ setDesktop(targetDesktop);
+}
+
+StyleDialog::~StyleDialog()
+{
+ setDesktop(NULL);
+}
+
+void StyleDialog::setDesktop( SPDesktop* desktop )
+{
+ Panel::setDesktop(desktop);
+ _desktop = Panel::getDesktop();
+}
+
+void StyleDialog::_addSelector()
+{
+ Gtk::TreeModel::Row row = *(_store->append());
+
+ /**
+ * On clicking '+' button, an entrybox with default text opens up. If an
+ * object is already selected, 'class' attribute with value in the entry
+ * is added to the selected object.
+ */
+ Gtk::Dialog *textDialogPtr = new Gtk::Dialog();
+ Gtk::Entry *textEditPtr = manage ( new Gtk::Entry() );
+ textDialogPtr->add_button("Add", Gtk::RESPONSE_OK);
+ textDialogPtr->get_vbox()->pack_start(*textEditPtr, Gtk::PACK_SHRINK);
+ textEditPtr->set_text("Class1");
+
+ textDialogPtr->set_size_request(200, 100);
+ textDialogPtr->show_all();
+ int result = textDialogPtr->run();
+ static int number = 1;
+
+ switch (result) {
+ case Gtk::RESPONSE_OK:
+ textDialogPtr->hide();
+ row[_mColumns._selectorNumber] = number;
+ row[_mColumns._selectorLabel] = textEditPtr->get_text();
+ number++;
+ break;
+ default:
+ break;
+ }
+
+ if (_desktop->selection) {
+ std::vector<SPObject*> selected = _desktop->getSelection()->list();
+ for (int i = 0; i < selected.size(); ++i ) {
+ SPObject *obj = selected.at(i);
+ obj->setAttribute("class", textEditPtr->get_text());
+ }
+ }
+}
+
+} // namespace Dialog
+} // namespace UI
+} // namespace Inkscape
diff --git a/src/ui/dialog/styledialog.h b/src/ui/dialog/styledialog.h
new file mode 100644
index 000000000..044737add
--- /dev/null
+++ b/src/ui/dialog/styledialog.h
@@ -0,0 +1,69 @@
+/** @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 STYLEDIALOG_H
+#define STYLEDIALOG_H
+
+#include <ui/widget/panel.h>
+#include <gtkmm/treeview.h>
+#include <gtkmm/liststore.h>
+#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/dialog.h>
+
+#include "desktop.h"
+
+namespace Inkscape {
+namespace UI {
+namespace Dialog {
+
+/**
+ * @brief The StyleDialog class
+ * A list of CSS selectors will show up in this dialog.
+ */
+
+class StyleDialog : public UI::Widget::Panel
+{
+public:
+ StyleDialog();
+ ~StyleDialog();
+
+ static StyleDialog &getInstance() { return *new StyleDialog(); }
+ void setDesktop( SPDesktop* desktop);
+
+private:
+ void _styleButton( Gtk::Button& btn, char const* iconName, char const* tooltip);
+
+ class ModelColumns : public Gtk::TreeModel::ColumnRecord
+ {
+ public:
+ ModelColumns()
+ { add(_selectorNumber); add(_selectorLabel); }
+ Gtk::TreeModelColumn<int> _selectorNumber;
+ Gtk::TreeModelColumn<Glib::ustring> _selectorLabel;
+ };
+
+ SPDesktop* _desktop;
+ ModelColumns _mColumns;
+ Gtk::VBox _mainBox;
+ Gtk::HBox _buttonBox;
+ Gtk::TreeView _treeView;
+ Glib::RefPtr<Gtk::ListStore> _store;
+ Gtk::ScrolledWindow _scrolledWindow;
+
+ // Signal handlers
+ void _addSelector();
+};
+
+} // namespace Dialog
+} // namespace UI
+} // namespace Inkscape
+
+#endif // STYLEDIALOG_H
diff --git a/src/verbs.cpp b/src/verbs.cpp
index 299cfe8e7..2908ae580 100644
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
@@ -2119,6 +2119,9 @@ void DialogVerb::perform(SPAction *action, void *data)
case SP_VERB_DIALOG_PRINT_COLORS_PREVIEW:
dt->_dlg_mgr->showDialog("PrintColorsPreviewDialog");
break;
+ case SP_VERB_DIALOG_STYLE:
+ dt->_dlg_mgr->showDialog("StyleDialog");
+ break;
default:
break;
@@ -2949,6 +2952,8 @@ Verb *Verb::_base_verbs[] = {
N_("View Objects"), INKSCAPE_ICON("dialog-layers")),
new DialogVerb(SP_VERB_DIALOG_TAGS, "DialogTags", N_("Selection se_ts..."),
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_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 ffb9b23d8..35a9ca738 100644
--- a/src/verbs.h
+++ b/src/verbs.h
@@ -308,6 +308,7 @@ enum {
SP_VERB_DIALOG_LAYERS,
SP_VERB_DIALOG_OBJECTS,
SP_VERB_DIALOG_TAGS,
+ SP_VERB_DIALOG_STYLE,
SP_VERB_DIALOG_LIVE_PATH_EFFECT,
SP_VERB_DIALOG_FILTER_EFFECTS,
SP_VERB_DIALOG_SVG_FONTS,