18#include <glibmm/i18n.h>
19#include <gtkmm/entry.h>
20#include <gtkmm/enums.h>
21#include <gtkmm/grid.h>
22#include <gtkmm/object.h>
23#include <gtkmm/scrolledwindow.h>
24#include <gtkmm/textview.h>
25#include <gtkmm/label.h>
26#include <sigc++/adaptors/bind.h>
47 return _entry ? _entry->get_text() : _text_view->get_buffer()->get_text();
51 return _entry ?
static_cast<Gtk::Widget*
>(_entry) :
static_cast<Gtk::Widget*
>(_text_view);
54static constexpr int XPAD = 4;
55static constexpr int YPAD = 2;
58 std::vector<Glib::ustring>
const &attributes)
60 create(labels, attributes);
70 table = std::make_unique<Gtk::Grid>();
75 for (std::size_t i = 0; i < attributes.size(); ++i) {
76 auto const ll = Gtk::make_managed<Gtk::Label>(_(labels[i].c_str()));
77 ll->set_halign(Gtk::Align::START);
78 ll->set_valign(Gtk::Align::CENTER);
79 ll->set_vexpand(
false);
80 ll->set_margin_end(
XPAD);
81 ll->set_margin_top(
YPAD);
82 ll->set_margin_bottom(
YPAD);
83 table->attach(*ll, 0, i, 1, 1);
86 if (
_syntax != SyntaxMode::PlainText) {
88 edit->setStyle(theme);
89 auto& tv = edit->getTextView();
91 tv.set_wrap_mode(Gtk::WrapMode::WORD);
92 auto wnd = Gtk::make_managed<Gtk::ScrolledWindow>();
94 wnd->set_vexpand(
false);
95 wnd->set_margin_start(
XPAD);
96 wnd->set_margin_top(
YPAD);
97 wnd->set_margin_bottom(
YPAD);
99 wnd->set_has_frame(
true);
100 wnd->set_policy(Gtk::PolicyType::NEVER, Gtk::PolicyType::AUTOMATIC);
101 table->attach(*wnd, 1, i, 1, 1);
103 tv.get_buffer()->signal_end_user_action().connect([i,
this](){
109 auto const ee = Gtk::make_managed<Gtk::Entry>();
112 ee->set_vexpand(
false);
113 ee->set_margin_start(
XPAD);
114 ee->set_margin_top(
YPAD);
115 ee->set_margin_bottom(
YPAD);
116 table->attach(*ee, 1, i, 1, 1);
118 ee->signal_changed().connect([i,
this](){
123 _entries.push_back(std::move(entry));
151 for (std::size_t i = 0; i <
_attributes.size(); ++i) {
152 auto const val =
object ?
object->getRepr()->attribute(
_attributes[i].c_str()) :
nullptr;
153 _entries[i].set_text(val ? val :
"");
162 for (std::size_t i = 0; i <
_attributes.size(); ++i) {
164 _entries.at(i).set_text(val ? val :
"");
177 if (!(flags & SP_OBJECT_MODIFIED_FLAG))
return;
179 for (std::size_t i = 0; i <
_attributes.size(); ++i) {
182 auto const new_text = Glib::ustring{val ? val :
""};
183 if (e.get_text() != new_text) {
186 e.set_text(new_text);
203 g_warning(
"file %s: line %d: Entry signalled change, but there is no such entry", __FILE__, __LINE__);
210 auto text = e.get_text();
Glib::ustring getString(Glib::ustring const &pref_path, Glib::ustring const &def="")
Retrieve an UTF-8 string.
static Preferences * get()
Access the singleton Preferences object.
static std::unique_ptr< TextEditView > create(SyntaxMode mode)
Create a styled text view using the desired syntax highlighting mode.
void setAttribute(Util::const_char_ptr key, Util::const_char_ptr value)
Change an attribute of this node.
virtual char const * attribute(char const *key) const =0
Get the string representation of a node's attribute.
sigc::scoped_connection modified_connection
Sets the callback for a modification of the selection.
void change_object(SPObject *object)
Update values in entry boxes on change of object.
void attribute_table_object_release(SPObject *object)
Callback for the deletion of the selected object.
void create(const std::vector< Glib::ustring > &labels, const std::vector< Glib::ustring > &attributes)
SPObject * _object
Stores pointer to the selected object.
std::vector< std::unique_ptr< Inkscape::UI::Syntax::TextEditView > > _textviews
void attribute_table_object_modified(SPObject *object, unsigned flags)
Callback for a modification of the selected object (size, color, properties, etc.).
std::unique_ptr< Gtk::Grid > table
Container widget for the dynamically created child widgets (labels and entry boxes).
void reread_properties()
Reads the object attributes.
bool blocked
Indicates whether SPAttributeTable is processing callbacks and whether it should accept any updating.
std::vector< Glib::ustring > _attributes
List of attributes.
void attribute_table_entry_changed(size_t index)
Callback for user input in one of the entries.
Inkscape::UI::Syntax::SyntaxMode _syntax
SPAttributeTable(Inkscape::UI::Syntax::SyntaxMode mode=Inkscape::UI::Syntax::SyntaxMode::PlainText)
Constructor defaulting to no content.
std::vector< EntryWidget > _entries
List of pointers to the respective entry boxes.
sigc::scoped_connection release_connection
Sets the callback for the deletion of the selected object.
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Inkscape::XML::Node * getRepr()
Returns the XML representation of tree.
sigc::connection connectModified(sigc::slot< void(SPObject *, unsigned int)> slot)
Connects to the modification notification signal.
static constexpr int XPAD
static constexpr int YPAD
TODO: insert short description here.
SyntaxMode
Syntax highlighting mode (language).
Singleton class to access the preferences file in a convenient way.
void append(std::vector< T > &vec, std::vector< T > const &other)
Gtk::TextView * _text_view
const Gtk::Widget * get_widget() const
Glib::ustring get_text() const
void set_text(const Glib::ustring &text)