summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2019-05-04 06:30:36 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2019-06-02 09:50:16 +0000
commit004b76058646b58ad54b986ddfeb5aa361b41816 (patch)
tree43e08c23248747ac7fdd11a2a86cdec1b1313cd2
parentAdd visualization of style dialog (diff)
downloadinkscape-004b76058646b58ad54b986ddfeb5aa361b41816.tar.gz
inkscape-004b76058646b58ad54b986ddfeb5aa361b41816.zip
fix attributes and add ui file
-rw-r--r--share/ui/dialog-css.ui106
-rw-r--r--src/ui/dialog/styledialog.cpp59
2 files changed, 164 insertions, 1 deletions
diff --git a/share/ui/dialog-css.ui b/share/ui/dialog-css.ui
new file mode 100644
index 000000000..799583a43
--- /dev/null
+++ b/share/ui/dialog-css.ui
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface>
+ <requires lib="gtk+" version="3.20"/>
+ <object class="GtkBox" id="CSSSelectorContainer">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">start</property>
+ <property name="orientation">vertical</property>
+ <property name="baseline_position">top</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="valign">start</property>
+ <child>
+ <object class="GtkLabel" id="CSSSelector">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Selector</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label">{</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="CSSSelectorAdd">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="no_show_all">True</property>
+ <property name="label"> &lt;b&gt;+&lt;/b&gt; }</property>
+ <property name="use_markup">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkTreeView" id="CSSTree">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="CSSTreeData"/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="CSSSelectorFilled">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="no_show_all">True</property>
+ <property name="halign">start</property>
+ <property name="valign">start</property>
+ <property name="label" translatable="yes">}</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSeparator">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_top">6</property>
+ <property name="margin_bottom">6</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ </object>
+</interface>
diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp
index e10a215bb..1b3775054 100644
--- a/src/ui/dialog/styledialog.cpp
+++ b/src/ui/dialog/styledialog.cpp
@@ -463,11 +463,68 @@ void StyleDialog::_readStyleElement()
contract = false;
}
}
+ if (contract) {
+ CSSSelectorAdd->show();
+ CSSSelectorFilled->hide();
+ } else {
+ CSSSelectorAdd->hide();
+ CSSSelectorFilled->show();
+ }
+ _styleBox.pack_start(*CSSSelectorContainer, Gtk::PACK_EXPAND_WIDGET);
+ bool hasattributes = false;
+ contract = true;
+ Glib::RefPtr<Gtk::Builder> _builder;
+ try {
+ _builder = Gtk::Builder::create_from_file(gladefile);
+ } catch (const Glib::Error &ex) {
+ g_warning("Glade file loading failed for filter effect dialog");
+ return;
+ }
+ Gtk::Box *CSSSelectorContainer;
+ _builder->get_widget("CSSSelectorContainer", CSSSelectorContainer);
+ Gtk::Label *CSSSelectorAdd;
+ _builder->get_widget("CSSSelectorAdd", CSSSelectorAdd);
+ Gtk::Label *CSSSelectorFilled;
+ _builder->get_widget("CSSSelectorFilled", CSSSelectorFilled);
+ 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") {
const gchar *attr = obj->getRepr()->attribute(iter->name.c_str());
if (attr) {
+ if (!hasattributes) {
+ Gtk::Label *CSSSelector;
+ _builder->get_widget("CSSSelector", CSSSelector);
+ CSSSelector->set_text("element.attributes");
+ Gtk::TreeView *CSSTree;
+ _builder->get_widget("CSSTree", CSSTree);
+ CSSTree->set_model(store);
+ Gtk::CellRendererToggle *active = Gtk::manage(new Gtk::CellRendererToggle);
+ int addCol = CSSTree->append_column("", *active) - 1;
+ Gtk::TreeViewColumn *col = CSSTree->get_column(addCol);
+ if (col) {
+ col->add_attribute(active->property_active(), _mColumns._colActive);
+ }
+ //col->set_cell_data_func(*active, sigc::mem_fun(*this, &StyleDialog::_hideRootToggle));
+ CSSTree->set_headers_visible(false);
+ Gtk::CellRendererText *label = Gtk::manage(new Gtk::CellRendererText());
+ CSSTree->set_reorderable(false);
+ label->property_editable() = true;
+ addCol = CSSTree->append_column("CSS Selector", *label) - 1;
+ col = CSSTree->get_column(addCol);
+ if (col) {
+ col->add_attribute(label->property_text(), _mColumns._colLabel);
+ }
+ Gtk::CellRendererText *value = Gtk::manage(new Gtk::CellRendererText());
+ CSSTree->set_reorderable(false);
+ value->property_editable() = true;
+ addCol = CSSTree->append_column("CSS Selector", *value) - 1;
+ col = CSSTree->get_column(addCol);
+ if (col) {
+ col->add_attribute(value->property_text(), _mColumns._colValue);
+ col->add_attribute(value->property_strikethrough(), _mColumns._colStrike);
+ }
+ }
Gtk::TreeModel::Row row = *(store->append());
row[_mColumns._colActive] = true;
row[_mColumns._colSelector] = "attribute";
@@ -479,6 +536,7 @@ void StyleDialog::_readStyleElement()
row[_mColumns._colStrike] = false;
}
contract = false;
+ hasattributes = true;
}
}
}
@@ -514,7 +572,6 @@ void StyleDialog::_readStyleElement()
std::cerr << "StyleDialog::_readStyleElement: Missing values "
"for last selector!" << std::endl;
}
- Glib::ustring gladefile = get_filename(Inkscape::IO::Resource::UIS, "dialog-css.ui");
Glib::RefPtr<Gtk::Builder> _builder;
try {
_builder = Gtk::Builder::create_from_file(gladefile);