summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2018-12-24 16:29:36 +0000
committerJabiertxof <jabier.arraiza@marker.es>2018-12-26 11:46:57 +0000
commit175e906e69dfcc66ba2e67675e4bc120b8b08d94 (patch)
tree6e3b81e065f2eb44434b9e51323e6cba2a29dcbc /src
parentfix CNakeLists.txt (diff)
downloadinkscape-175e906e69dfcc66ba2e67675e4bc120b8b08d94.tar.gz
inkscape-175e906e69dfcc66ba2e67675e4bc120b8b08d94.zip
Add status to attribute widget
Diffstat (limited to 'src')
-rw-r--r--src/ui/dialog/attrdialog.cpp43
-rw-r--r--src/ui/dialog/attrdialog.h24
-rw-r--r--src/ui/dialog/xml-tree.cpp19
-rw-r--r--src/ui/dialog/xml-tree.h7
4 files changed, 66 insertions, 27 deletions
diff --git a/src/ui/dialog/attrdialog.cpp b/src/ui/dialog/attrdialog.cpp
index 374020a89..7861e13b5 100644
--- a/src/ui/dialog/attrdialog.cpp
+++ b/src/ui/dialog/attrdialog.cpp
@@ -16,6 +16,8 @@
#include "selection.h"
#include "document-undo.h"
+#include "message-context.h"
+#include "message-stack.h"
#include "ui/icon-loader.h"
#include "ui/widget/iconrenderer.h"
@@ -96,6 +98,18 @@ AttrDialog::AttrDialog():
if (_nameCol) {
_nameCol->add_attribute(_nameRenderer->property_text(), _attrColumns._attributeName);
}
+ status.set_halign(Gtk::ALIGN_START);
+ status.set_valign(Gtk::ALIGN_CENTER);
+ status.set_size_request(1, -1);
+ status.set_markup("");
+ status.set_line_wrap(true);
+ status_box.pack_start( status, TRUE, TRUE, 0);
+ _getContents()->pack_end(status_box, false, false, 2);
+
+ _message_stack = std::make_shared<Inkscape::MessageStack>();
+ _message_context = std::unique_ptr<Inkscape::MessageContext>(new Inkscape::MessageContext(_message_stack));
+ _message_changed_connection = _message_stack->connectChanged(
+ sigc::bind(sigc::ptr_fun(_set_status_message), GTK_WIDGET(status.gobj())));
_valueRenderer = Gtk::manage(new Gtk::CellRendererText());
_valueRenderer->property_editable() = true;
@@ -107,7 +121,7 @@ AttrDialog::AttrDialog():
if (_valueCol) {
_valueCol->add_attribute(_valueRenderer->property_text(), _attrColumns._attributeValue);
}
-
+ attr_reset_context(0);
_getContents()->pack_start(_mainBox, Gtk::PACK_EXPAND_WIDGET);
setDesktop(getDesktop());
@@ -121,6 +135,10 @@ AttrDialog::AttrDialog():
AttrDialog::~AttrDialog()
{
setDesktop(nullptr);
+ _message_changed_connection.disconnect();
+ _message_context = nullptr;
+ _message_stack = nullptr;
+ _message_changed_connection.~connection();
}
@@ -167,6 +185,29 @@ void AttrDialog::setUndo(Glib::ustring const &event_description)
DocumentUndo::done(document, SP_VERB_DIALOG_XML_EDITOR, event_description);
}
+void AttrDialog::_set_status_message(Inkscape::MessageType /*type*/, const gchar *message, GtkWidget *widget)
+{
+ if (widget) {
+ gtk_label_set_markup(GTK_LABEL(widget), message ? message : "");
+ }
+}
+
+/**
+ * Sets the AttrDialog status bar, depending on which attr is selected.
+ */
+void AttrDialog::attr_reset_context(gint attr)
+{
+ if (attr == 0) {
+ _message_context->set(Inkscape::NORMAL_MESSAGE,
+ _("<b>Click</b> attribute to edit."));
+ }
+ else {
+ const gchar *name = g_quark_to_string(attr);
+ _message_context->setF(Inkscape::NORMAL_MESSAGE,
+ _("Attribute <b>%s</b> selected. Press <b>Ctrl+Enter</b> when done editing to commit changes."), name);
+ }
+}
+
/**
* @brief AttrDialog::onAttrChanged
* This is called when the XML has an updated attribute
diff --git a/src/ui/dialog/attrdialog.h b/src/ui/dialog/attrdialog.h
index a290d55c9..b263120ce 100644
--- a/src/ui/dialog/attrdialog.h
+++ b/src/ui/dialog/attrdialog.h
@@ -18,12 +18,14 @@
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/dialog.h>
#include <ui/widget/panel.h>
-
+#include "message.h"
#include "desktop.h"
#define ATTR_DIALOG(obj) (dynamic_cast<Inkscape::UI::Dialog::AttrDialog*>((Inkscape::UI::Dialog::AttrDialog*)obj))
namespace Inkscape {
+class MessageStack;
+class MessageContext;
namespace UI {
namespace Dialog {
@@ -60,6 +62,12 @@ public:
Gtk::TreeViewColumn *_nameCol;
Gtk::TreeViewColumn *_valueCol;
+ /**
+ * Status bar
+ */
+ std::shared_ptr<Inkscape::MessageStack> _message_stack;
+ std::unique_ptr<Inkscape::MessageContext> _message_context;
+
// Widgets
Gtk::VBox _mainBox;
Gtk::ScrolledWindow _scrolledWindow;
@@ -69,13 +77,23 @@ public:
// Variables - Inkscape
SPDesktop* _desktop;
Inkscape::XML::Node* _repr;
+ Gtk::HBox status_box;
+ Gtk::Label status;
// Helper functions
void setDesktop(SPDesktop* desktop) override;
void setRepr(Inkscape::XML::Node * repr);
void setUndo(Glib::ustring const &event_description);
-
- // Signal handlers
+ /**
+ * Sets the XML status bar, depending on which attr is selected.
+ */
+ void attr_reset_context(gint attr);
+ static void _set_status_message(Inkscape::MessageType type, const gchar *message, GtkWidget *dialog);
+
+ /**
+ * Signal handlers
+ */
+ sigc::connection _message_changed_connection;
void onAttrChanged(Inkscape::XML::Node *repr, const gchar * name, const gchar * new_value);
void onAttrDelete(Glib::ustring path);
bool onAttrCreate(GdkEventButton *event);
diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp
index 488bc8246..4a1a2d550 100644
--- a/src/ui/dialog/xml-tree.cpp
+++ b/src/ui/dialog/xml-tree.cpp
@@ -90,7 +90,6 @@ XmlTree::XmlTree() :
status.set_markup("");
status.set_line_wrap(true);
status_box.pack_start( status, TRUE, TRUE, 0);
- contents->pack_end(status_box, false, false, 2);
contents->pack_start(*flowbox_content, true, true, 0);
@@ -179,6 +178,8 @@ XmlTree::XmlTree() :
node_box.pack_start(*tree_scroller);
+ node_box.pack_end(status_box, false, false, 2);
+
/* attributes */
attributes = new AttrDialog;
attr_box.pack_start(*attributes);
@@ -250,22 +251,6 @@ void XmlTree::tree_reset_context()
}
-/**
- * Sets the XML status bar, depending on which attr is selected.
- */
-void XmlTree::attr_reset_context(gint attr)
-{
- if (attr == 0) {
- _message_context->set(Inkscape::NORMAL_MESSAGE,
- _("<b>Click</b> attribute to edit."));
- }
- else {
- const gchar *name = g_quark_to_string(attr);
- _message_context->setF(Inkscape::NORMAL_MESSAGE,
- _("Attribute <b>%s</b> selected. Press <b>Ctrl+Enter</b> when done editing to commit changes."), name);
- }
-}
-
void XmlTree::set_tree_desktop(SPDesktop *desktop)
{
if ( desktop == current_desktop ) {
diff --git a/src/ui/dialog/xml-tree.h b/src/ui/dialog/xml-tree.h
index 4a98100a8..b39c4d1be 100644
--- a/src/ui/dialog/xml-tree.h
+++ b/src/ui/dialog/xml-tree.h
@@ -82,11 +82,6 @@ private:
void tree_reset_context();
/**
- * Sets the XML status bar, depending on which attr is selected.
- */
- void attr_reset_context(gint attr);
-
- /**
* Is the selected tree node editable
*/
gboolean xml_tree_node_mutable(GtkTreeIter *node);
@@ -228,7 +223,7 @@ private:
Gtk::VBox css_box;
Gtk::HBox status_box;
Gtk::Label status;
- Gtk::Toolbar tree_toolbar;
+ Gtk::Toolbar tree_toolbar;
Gtk::ToolButton xml_element_new_button;
Gtk::ToolButton xml_text_new_button;
Gtk::ToolButton xml_node_delete_button;