Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
Inkscape::UI::Dialog::StyleDialog Class Referencefinal

The StyleDialog class A list of CSS selectors will show up in this dialog. More...

#include <styledialog.h>

Inheritance diagram for Inkscape::UI::Dialog::StyleDialog:
Inkscape::UI::Dialog::DialogBase

Classes

class  CSSData
 
class  ModelColumns
 

Public Member Functions

 StyleDialog ()
 Constructor A treeview and a set of two buttons are added to the dialog.
 
 ~StyleDialog () final
 
void documentReplaced () final
 Handle document replaced.
 
void selectionChanged (Selection *selection) final
 
void setCurrentSelector (Glib::ustring current_selector)
 
void readStyleElement ()
 Fill the Gtk::TreeStore from the svg:style element.
 
- Public Member Functions inherited from Inkscape::UI::Dialog::DialogBase
 DialogBase (char const *prefs_path=nullptr, Glib::ustring dialog_type={})
 DialogBase constructor.
 
 DialogBase (DialogBase const &)=delete
 
DialogBaseoperator= (DialogBase const &)=delete
 
 ~DialogBase () override
 
virtual void update ()
 The update() method is essential to Gtk state management.
 
void setDesktop (SPDesktop *new_desktop)
 Called when the desktop might have changed for this dialog.
 
void on_map () override
 
Glib::ustring const & get_name () const
 
Glib::ustring const & getPrefsPath () const
 
Glib::ustring const & get_type () const
 
const Glib::ustring & get_icon () const
 
void blink ()
 Highlight notebook where dialog already exists.
 
virtual void focus_dialog ()
 
void defocus_dialog ()
 
bool getShowing ()
 
void fix_inner_scroll (Gtk::ScrolledWindow &scrollwin)
 
SPDesktopgetDesktop () const
 

Public Attributes

Gtk::TreeView * _current_css_tree
 
Gtk::TreeViewColumn * _current_value_col
 
Gtk::TreeModel::Path _current_path
 
bool _deletion {false}
 

Private Types

using AttrProp = std::map< Glib::ustring, Glib::ustring >
 

Private Member Functions

void _nodeAdded (Inkscape::XML::Node &repr)
 
void _nodeRemoved (Inkscape::XML::Node &repr)
 
void _nodeChanged (Inkscape::XML::Node &repr)
 
void removeObservers ()
 
Inkscape::XML::Node_getStyleTextNode (bool create_if_missing=false)
 
void _writeStyleElement (Glib::RefPtr< Gtk::TreeStore > const &store, Glib::ustring selector, Glib::ustring const &new_selector={})
 Update the content of the style element as selectors (or objects) are added/removed.
 
void _activeToggled (const Glib::ustring &path, Glib::RefPtr< Gtk::TreeStore > const &store)
 
void _addRow (Glib::RefPtr< Gtk::TreeStore > const &store, Gtk::TreeView *css_tree, Glib::ustring const &selector, int pos)
 
void _onPropDelete (Glib::ustring const &path, Glib::RefPtr< Gtk::TreeStore > const &store)
 StyleDialog::_onPropDelete.
 
void _nameEdited (const Glib::ustring &path, const Glib::ustring &name, Glib::RefPtr< Gtk::TreeStore > store, Gtk::TreeView *css_tree)
 StyleDialog::nameEdited.
 
void _addTreeViewHandlers (Gtk::TreeView &treeview)
 
void _setEditingEntry (Gtk::Entry *entry, Glib::ustring endChars)
 
void _onTreeViewKeyReleased (unsigned keyval, unsigned keycode, Gdk::ModifierType state)
 
void _onTreeViewFocusLeave ()
 
void _onLinkObj (Glib::ustring const &path, Glib::RefPtr< Gtk::TreeStore > const &store)
 
void _valueEdited (const Glib::ustring &path, const Glib::ustring &value, Glib::RefPtr< Gtk::TreeStore > store)
 StyleDialog::valueEdited.
 
void _startNameEdit (Gtk::CellEditable *cell, const Glib::ustring &path)
 
void _startValueEdit (Gtk::CellEditable *cell, const Glib::ustring &path, Glib::RefPtr< Gtk::TreeStore > store)
 
void _setAutocompletion (Gtk::Entry *entry, SPStyleEnum const cssenum[])
 
void _setAutocompletion (Gtk::Entry *entry, Glib::ustring name)
 
bool _on_foreach_iter (const Gtk::TreeModel::iterator &iter)
 
void _reload ()
 
void _vscroll ()
 
std::vector< SPObject * > _getObjVec (Glib::ustring selector)
 
AttrProp parseStyle (Glib::ustring style_string)
 StyleDialog::parseStyle.
 
void _addOwnerStyle (Glib::ustring name, Glib::ustring selector)
 
void _closeDialog (Gtk::Dialog *textDialogPtr)
 

Private Attributes

ModelColumns _mColumns
 
CSSData _mCSSData
 
unsigned _deleted_pos {0}
 
Gtk::ScrolledWindow _scrolledWindow
 
Glib::RefPtr< Gtk::Adjustment > _vadj
 
Gtk::Box _mainBox
 
Gtk::Box _styleBox
 
Gtk::Entry * _editingEntry = nullptr
 
bool _scrollock
 
double _scrollpos {0}
 
Glib::ustring _current_selector
 
std::unique_ptr< XML::NodeObserver > const m_nodewatcher
 
std::unique_ptr< XML::NodeObserver > const m_styletextwatcher
 
AttrProp _owner_style
 
Inkscape::XML::Nodem_root {nullptr}
 
Inkscape::XML::Node_textNode {nullptr}
 
bool _updating {false}
 

Additional Inherited Members

- Protected Member Functions inherited from Inkscape::UI::Dialog::DialogBase
InkscapeApplicationgetApp () const
 
SPDocumentgetDocument () const
 
SelectiongetSelection () const
 
void setShowing (bool showing)
 function called from notebook dialog that performs an update of the dialog and sets the dialog showing state true
 
- Protected Attributes inherited from Inkscape::UI::Dialog::DialogBase
Glib::ustring _name
 
Glib::ustring const _prefs_path
 
Glib::ustring const _dialog_type
 

Detailed Description

The StyleDialog class A list of CSS selectors will show up in this dialog.

This dialog allows one to add and delete selectors. Elements can be added to and removed from the selectors in the dialog. Selection of any selector row selects the matching objects in the drawing and vice-versa. (Only simple selectors supported for now.)

This class must keep two things in sync:

  1. The text node of the style element.
  2. The Gtk::TreeModel.

Definition at line 63 of file styledialog.h.

Member Typedef Documentation

◆ AttrProp

using Inkscape::UI::Dialog::StyleDialog::AttrProp = std::map<Glib::ustring, Glib::ustring>
private

Definition at line 80 of file styledialog.h.

Constructor & Destructor Documentation

◆ StyleDialog()

Inkscape::UI::Dialog::StyleDialog::StyleDialog ( )

Constructor A treeview and a set of two buttons are added to the dialog.

_addSelector adds selectors to treeview. _delSelector deletes the selector from the dialog. Any addition/deletion of the selectors updates XML style element accordingly.

Definition at line 210 of file styledialog.cpp.

References _mainBox, _scrolledWindow, _styleBox, _vadj, _vscroll(), Inkscape::UI::expand_widget, and Inkscape::UI::pack_start().

◆ ~StyleDialog()

Inkscape::UI::Dialog::StyleDialog::~StyleDialog ( )
final

Definition at line 234 of file styledialog.cpp.

References removeObservers().

Member Function Documentation

◆ _activeToggled()

void Inkscape::UI::Dialog::StyleDialog::_activeToggled ( const Glib::ustring &  path,
Glib::RefPtr< Gtk::TreeStore > const &  store 
)
private

◆ _addOwnerStyle()

void Inkscape::UI::Dialog::StyleDialog::_addOwnerStyle ( Glib::ustring  name,
Glib::ustring  selector 
)
private

Definition at line 872 of file styledialog.cpp.

References _owner_style, and name.

Referenced by readStyleElement().

◆ _addRow()

void Inkscape::UI::Dialog::StyleDialog::_addRow ( Glib::RefPtr< Gtk::TreeStore > const &  store,
Gtk::TreeView *  css_tree,
Glib::ustring const &  selector,
int  pos 
)
private

◆ _addTreeViewHandlers()

void Inkscape::UI::Dialog::StyleDialog::_addTreeViewHandlers ( Gtk::TreeView &  treeview)
private

Definition at line 1318 of file styledialog.cpp.

References _onTreeViewFocusLeave(), _onTreeViewKeyReleased(), and key.

Referenced by readStyleElement().

◆ _closeDialog()

void Inkscape::UI::Dialog::StyleDialog::_closeDialog ( Gtk::Dialog *  textDialogPtr)
private

Definition at line 1399 of file styledialog.cpp.

◆ _getObjVec()

std::vector< SPObject * > Inkscape::UI::Dialog::StyleDialog::_getObjVec ( Glib::ustring  selector)
private
Parameters
selectora valid CSS selector string.
Returns
objVec: a vector of pointers to SPObject's the selector matches. Return a vector of all objects that selector matches.

Definition at line 1390 of file styledialog.cpp.

References Inkscape::UI::Dialog::DialogBase::getDocument(), and SPDocument::getObjectsBySelector().

Referenced by _valueEdited(), and readStyleElement().

◆ _getStyleTextNode()

Inkscape::XML::Node * Inkscape::UI::Dialog::StyleDialog::_getStyleTextNode ( bool  create_if_missing = false)
private
Returns
Inkscape::XML::Node* pointing to a style element's text node. Returns the style element's text node. If there is no style element, one is created. Ditto for text node.

Definition at line 256 of file styledialog.cpp.

References _textNode, Inkscape::XML::Node::addObserver(), Inkscape::UI::Dialog::get_first_style_text_node(), m_root, m_styletextwatcher, and Inkscape::XML::Node::removeObserver().

Referenced by _writeStyleElement(), and readStyleElement().

◆ _nameEdited()

void Inkscape::UI::Dialog::StyleDialog::_nameEdited ( const Glib::ustring &  path,
const Glib::ustring &  name,
Glib::RefPtr< Gtk::TreeStore >  store,
Gtk::TreeView *  css_tree 
)
private

◆ _nodeAdded()

void Inkscape::UI::Dialog::StyleDialog::_nodeAdded ( Inkscape::XML::Node repr)
private

◆ _nodeChanged()

void Inkscape::UI::Dialog::StyleDialog::_nodeChanged ( Inkscape::XML::Node repr)
private

◆ _nodeRemoved()

void Inkscape::UI::Dialog::StyleDialog::_nodeRemoved ( Inkscape::XML::Node repr)
private

◆ _on_foreach_iter()

bool Inkscape::UI::Dialog::StyleDialog::_on_foreach_iter ( const Gtk::TreeModel::iterator &  iter)
private

◆ _onLinkObj()

◆ _onPropDelete()

void Inkscape::UI::Dialog::StyleDialog::_onPropDelete ( Glib::ustring const &  path,
Glib::RefPtr< Gtk::TreeStore > const &  store 
)
private

◆ _onTreeViewFocusLeave()

void Inkscape::UI::Dialog::StyleDialog::_onTreeViewFocusLeave ( )
private

Definition at line 1373 of file styledialog.cpp.

References _editingEntry.

Referenced by _addTreeViewHandlers().

◆ _onTreeViewKeyReleased()

void Inkscape::UI::Dialog::StyleDialog::_onTreeViewKeyReleased ( unsigned  keyval,
unsigned  keycode,
Gdk::ModifierType  state 
)
private

Definition at line 1361 of file styledialog.cpp.

References _editingEntry.

Referenced by _addTreeViewHandlers().

◆ _reload()

void Inkscape::UI::Dialog::StyleDialog::_reload ( )
private

Definition at line 249 of file styledialog.cpp.

References readStyleElement().

◆ _setAutocompletion() [1/2]

void Inkscape::UI::Dialog::StyleDialog::_setAutocompletion ( Gtk::Entry *  entry,
Glib::ustring  name 
)
private

◆ _setAutocompletion() [2/2]

void Inkscape::UI::Dialog::StyleDialog::_setAutocompletion ( Gtk::Entry *  entry,
SPStyleEnum const  cssenum[] 
)
private

◆ _setEditingEntry()

void Inkscape::UI::Dialog::StyleDialog::_setEditingEntry ( Gtk::Entry *  entry,
Glib::ustring  endChars 
)
private

Definition at line 1335 of file styledialog.cpp.

References _editingEntry, and _setEditingEntry().

Referenced by _setEditingEntry(), _startNameEdit(), and _startValueEdit().

◆ _startNameEdit()

void Inkscape::UI::Dialog::StyleDialog::_startNameEdit ( Gtk::CellEditable *  cell,
const Glib::ustring &  path 
)
private

◆ _startValueEdit()

◆ _valueEdited()

void Inkscape::UI::Dialog::StyleDialog::_valueEdited ( const Glib::ustring &  path,
const Glib::ustring &  value,
Glib::RefPtr< Gtk::TreeStore >  store 
)
private

◆ _vscroll()

void Inkscape::UI::Dialog::StyleDialog::_vscroll ( )
private

Definition at line 239 of file styledialog.cpp.

References _scrollock, _scrollpos, and _vadj.

Referenced by StyleDialog().

◆ _writeStyleElement()

◆ documentReplaced()

void Inkscape::UI::Dialog::StyleDialog::documentReplaced ( )
finalvirtual

Handle document replaced.

(Happens when a default document is immediately replaced by another document in a new window.)

Reimplemented from Inkscape::UI::Dialog::DialogBase.

Definition at line 1418 of file styledialog.cpp.

References Inkscape::XML::Node::addSubtreeObserver(), Inkscape::UI::Dialog::DialogBase::document, Inkscape::UI::Dialog::DialogBase::getDocument(), SPDocument::getReprRoot(), m_nodewatcher, m_root, readStyleElement(), and removeObservers().

◆ parseStyle()

StyleDialog::AttrProp Inkscape::UI::Dialog::StyleDialog::parseStyle ( Glib::ustring  style_string)
private

StyleDialog::parseStyle.

Convert a style string into a vector map. This should be moved to style.cpp

Definition at line 888 of file styledialog.cpp.

References props, and Inkscape::Util::trim().

Referenced by readStyleElement().

◆ readStyleElement()

void Inkscape::UI::Dialog::StyleDialog::readStyleElement ( )

Fill the Gtk::TreeStore from the svg:style element.

Definition at line 299 of file styledialog.cpp.

References _activeToggled(), _addOwnerStyle(), _addRow(), _addTreeViewHandlers(), Inkscape::UI::Dialog::StyleDialog::ModelColumns::_colActive, Inkscape::UI::Dialog::StyleDialog::ModelColumns::_colHref, Inkscape::UI::Dialog::StyleDialog::ModelColumns::_colLinked, Inkscape::UI::Dialog::StyleDialog::ModelColumns::_colName, Inkscape::UI::Dialog::StyleDialog::ModelColumns::_colOwner, Inkscape::UI::Dialog::StyleDialog::ModelColumns::_colSelector, Inkscape::UI::Dialog::StyleDialog::ModelColumns::_colSelectorPos, Inkscape::UI::Dialog::StyleDialog::ModelColumns::_colStrike, Inkscape::UI::Dialog::StyleDialog::ModelColumns::_colValue, _current_selector, _deletion, _getObjVec(), _getStyleTextNode(), _mColumns, _nameEdited(), _on_foreach_iter(), _onLinkObj(), _onPropDelete(), _owner_style, _scrollock, _startNameEdit(), _startValueEdit(), _styleBox, _updating, _valueEdited(), Inkscape::XML::Node::attribute(), builder, Inkscape::XML::Node::content(), Inkscape::UI::create_builder(), D, Inkscape::UI::Dialog::DialogBase::document, Inkscape::UI::end, Inkscape::UI::expand_widget, FONT, Inkscape::UI::get_children(), Inkscape::UI::Dialog::DialogBase::getDocument(), SPDocument::getObjectById(), SPObject::getRepr(), Inkscape::UI::Dialog::DialogBase::getSelection(), SPDocument::getXMLDialogSelectedObject(), Inkscape::UI::Dialog::is_url(), key, label, MARKER, name, node, Inkscape::ObjectSet::objects(), Inkscape::UI::pack_start(), parseStyle(), SPStyle::properties(), SPStyle::readFromObject(), Inkscape::UI::remove_all_children(), SPObject::requestDisplayUpdate(), Inkscape::UI::Dialog::DialogBase::selection, Inkscape::UI::start, store, SPObject::style, Inkscape::Util::trim(), and UNSET.

Referenced by _nodeAdded(), _nodeChanged(), _nodeRemoved(), _reload(), _writeStyleElement(), documentReplaced(), selectionChanged(), and setCurrentSelector().

◆ removeObservers()

void Inkscape::UI::Dialog::StyleDialog::removeObservers ( )
private

◆ selectionChanged()

void Inkscape::UI::Dialog::StyleDialog::selectionChanged ( Selection selection)
finalvirtual

◆ setCurrentSelector()

void Inkscape::UI::Dialog::StyleDialog::setCurrentSelector ( Glib::ustring  current_selector)

Definition at line 277 of file styledialog.cpp.

References _current_selector, and readStyleElement().

Member Data Documentation

◆ _current_css_tree

Gtk::TreeView* Inkscape::UI::Dialog::StyleDialog::_current_css_tree

◆ _current_path

Gtk::TreeModel::Path Inkscape::UI::Dialog::StyleDialog::_current_path

◆ _current_selector

Glib::ustring Inkscape::UI::Dialog::StyleDialog::_current_selector
private

Definition at line 170 of file styledialog.h.

Referenced by readStyleElement(), and setCurrentSelector().

◆ _current_value_col

Gtk::TreeViewColumn* Inkscape::UI::Dialog::StyleDialog::_current_value_col

◆ _deleted_pos

unsigned Inkscape::UI::Dialog::StyleDialog::_deleted_pos {0}
private

Definition at line 125 of file styledialog.h.

Referenced by _nameEdited(), _onPropDelete(), _valueEdited(), and _writeStyleElement().

◆ _deletion

bool Inkscape::UI::Dialog::StyleDialog::_deletion {false}

Definition at line 76 of file styledialog.h.

Referenced by _onPropDelete(), and readStyleElement().

◆ _editingEntry

Gtk::Entry* Inkscape::UI::Dialog::StyleDialog::_editingEntry = nullptr
private

Definition at line 150 of file styledialog.h.

Referenced by _onTreeViewFocusLeave(), _onTreeViewKeyReleased(), and _setEditingEntry().

◆ _mainBox

Gtk::Box Inkscape::UI::Dialog::StyleDialog::_mainBox
private

Definition at line 130 of file styledialog.h.

Referenced by StyleDialog().

◆ _mColumns

ModelColumns Inkscape::UI::Dialog::StyleDialog::_mColumns
private

◆ _mCSSData

CSSData Inkscape::UI::Dialog::StyleDialog::_mCSSData
private

Definition at line 123 of file styledialog.h.

Referenced by _setAutocompletion(), _setAutocompletion(), and _startNameEdit().

◆ _owner_style

AttrProp Inkscape::UI::Dialog::StyleDialog::_owner_style
private

Definition at line 179 of file styledialog.h.

Referenced by _addOwnerStyle(), _on_foreach_iter(), and readStyleElement().

◆ _scrolledWindow

Gtk::ScrolledWindow Inkscape::UI::Dialog::StyleDialog::_scrolledWindow
private

Definition at line 128 of file styledialog.h.

Referenced by StyleDialog().

◆ _scrollock

bool Inkscape::UI::Dialog::StyleDialog::_scrollock
private

◆ _scrollpos

double Inkscape::UI::Dialog::StyleDialog::_scrollpos {0}
private

Definition at line 169 of file styledialog.h.

Referenced by _vscroll(), and selectionChanged().

◆ _styleBox

Gtk::Box Inkscape::UI::Dialog::StyleDialog::_styleBox
private

Definition at line 131 of file styledialog.h.

Referenced by readStyleElement(), and StyleDialog().

◆ _textNode

Inkscape::XML::Node* Inkscape::UI::Dialog::StyleDialog::_textNode {nullptr}
private

Definition at line 184 of file styledialog.h.

Referenced by _getStyleTextNode(), _nodeRemoved(), and removeObservers().

◆ _updating

bool Inkscape::UI::Dialog::StyleDialog::_updating {false}
private

Definition at line 185 of file styledialog.h.

Referenced by _writeStyleElement(), and readStyleElement().

◆ _vadj

Glib::RefPtr<Gtk::Adjustment> Inkscape::UI::Dialog::StyleDialog::_vadj
private

Definition at line 129 of file styledialog.h.

Referenced by _vscroll(), selectionChanged(), and StyleDialog().

◆ m_nodewatcher

std::unique_ptr<XML::NodeObserver> const Inkscape::UI::Dialog::StyleDialog::m_nodewatcher
private

Definition at line 173 of file styledialog.h.

Referenced by documentReplaced(), and removeObservers().

◆ m_root

Inkscape::XML::Node* Inkscape::UI::Dialog::StyleDialog::m_root {nullptr}
private

Definition at line 183 of file styledialog.h.

Referenced by _getStyleTextNode(), documentReplaced(), and removeObservers().

◆ m_styletextwatcher

std::unique_ptr<XML::NodeObserver> const Inkscape::UI::Dialog::StyleDialog::m_styletextwatcher
private

Definition at line 174 of file styledialog.h.

Referenced by _getStyleTextNode(), and removeObservers().


The documentation for this class was generated from the following files: