diff options
| author | Martin Owens <doctormo@gmail.com> | 2018-09-14 16:58:18 +0000 |
|---|---|---|
| committer | Martin Owens <doctormo@gmail.com> | 2018-09-14 16:58:18 +0000 |
| commit | b92e577ea62c2a94ba38390fa67d9dcea3db88af (patch) | |
| tree | 3b48af7caf1e7fd14fd0015f6113a6545f11e9b7 /src/ui/dialog/attrdialog.h | |
| parent | Merge branch 'master' of gitlab.com:jordim/inkscape (diff) | |
| download | inkscape-b92e577ea62c2a94ba38390fa67d9dcea3db88af.tar.gz inkscape-b92e577ea62c2a94ba38390fa67d9dcea3db88af.zip | |
Remove sp-xmlview-attr with attrdialog (C++) and improve interface
Diffstat (limited to 'src/ui/dialog/attrdialog.h')
| -rw-r--r-- | src/ui/dialog/attrdialog.h | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/src/ui/dialog/attrdialog.h b/src/ui/dialog/attrdialog.h new file mode 100644 index 000000000..23ba8f321 --- /dev/null +++ b/src/ui/dialog/attrdialog.h @@ -0,0 +1,92 @@ +/** @file + * @brief A dialog for XML attributes based on Gtk TreeView + */ +/* Authors: + * Martin Owens + * + * Copyright (C) Martin Owens 2018 <doctormo@gmail.com> + * + * Released under GNU GPLv2 or later, read the file 'COPYING' for more information + */ + +#ifndef ATTRDIALOG_H +#define ATTRDIALOG_H + +#include <gtkmm/treeview.h> +#include <gtkmm/liststore.h> +#include <gtkmm/scrolledwindow.h> +#include <gtkmm/dialog.h> +#include <ui/widget/panel.h> + +#include "desktop.h" + +#define ATTR_DIALOG(obj) (dynamic_cast<Inkscape::UI::Dialog::AttrDialog*>((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(_colUnsetAttr); + add(_attributeName); + add(_attributeValue); + } + Gtk::TreeModelColumn<bool> _colUnsetAttr; + Gtk::TreeModelColumn<Glib::ustring> _attributeName; + Gtk::TreeModelColumn<Glib::ustring> _attributeValue; + }; + AttrColumns _attrColumns; + + // TreeView + Gtk::TreeView _treeView; + Glib::RefPtr<Gtk::ListStore> _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); + + // Signal handlers + void onAttrChanged(Inkscape::XML::Node *repr, const gchar * name, const gchar * new_value); + bool onAttrCreate(GdkEventButton *event); + bool onAttrDelete(GdkEventButton *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 |
