/** @file * @brief A dialog for XML attributes based on Gtk TreeView */ /* Authors: * Martin Owens * * Copyright (C) Martin Owens 2018 * * Released under GNU GPLv2 or later, read the file 'COPYING' for more information */ #ifndef ATTRDIALOG_H #define ATTRDIALOG_H #include #include #include #include #include #include "desktop.h" #define ATTR_DIALOG(obj) (dynamic_cast((Inkscape::UI::Dialog::AttrDialog*)obj)) namespace Inkscape { namespace UI { namespace Dialog { /** * @brief The AttrDialog class * This dialog allows to add, delete and modify XML attributes created in the * xml editor. */ class AttrDialog : public UI::Widget::Panel { public: AttrDialog(); ~AttrDialog() override; static AttrDialog &getInstance() { return *new AttrDialog(); } // Data structure class AttrColumns : public Gtk::TreeModel::ColumnRecord { public: AttrColumns() { add(_attributeName); add(_attributeValue); } Gtk::TreeModelColumn _attributeName; Gtk::TreeModelColumn _attributeValue; }; AttrColumns _attrColumns; // TreeView Gtk::TreeView _treeView; Glib::RefPtr _store; Gtk::CellRendererText *_nameRenderer; Gtk::CellRendererText *_valueRenderer; Gtk::TreeViewColumn *_nameCol; Gtk::TreeViewColumn *_valueCol; // Widgets Gtk::VBox _mainBox; Gtk::ScrolledWindow _scrolledWindow; Gtk::HBox _buttonBox; Gtk::Button _buttonAddAttribute; // Variables - Inkscape SPDesktop* _desktop; Inkscape::XML::Node* _repr; // Helper functions void setDesktop(SPDesktop* desktop) override; void setRepr(Inkscape::XML::Node * repr); void setUndo(Glib::ustring const &event_description); // Signal handlers void onAttrChanged(Inkscape::XML::Node *repr, const gchar * name, const gchar * new_value); void onAttrDelete(Glib::ustring path); bool onAttrCreate(GdkEventButton *event); bool onKeyPressed(GdkEventKey *event); void nameEdited(const Glib::ustring &path, const Glib::ustring &name); void valueEdited(const Glib::ustring &path, const Glib::ustring &value); }; } // namespace Dialog } // namespace UI } // namespace Inkscape #endif // ATTRDIALOG_H