summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2018-12-24 16:42:06 +0000
committerJabiertxof <jabier.arraiza@marker.es>2018-12-26 11:46:58 +0000
commit2e9f2b6e96cec362e1b3f2ed884186cc49c2455c (patch)
tree46857ec1fe481768ca11c980e95a020aec8fc421 /src/ui
parentAdd status to attribute widget (diff)
downloadinkscape-2e9f2b6e96cec362e1b3f2ed884186cc49c2455c.tar.gz
inkscape-2e9f2b6e96cec362e1b3f2ed884186cc49c2455c.zip
Add messagess to CSS dialog
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/dialog/cssdialog.cpp46
-rw-r--r--src/ui/dialog/cssdialog.h23
2 files changed, 67 insertions, 2 deletions
diff --git a/src/ui/dialog/cssdialog.cpp b/src/ui/dialog/cssdialog.cpp
index 5b3fe7660..54713315b 100644
--- a/src/ui/dialog/cssdialog.cpp
+++ b/src/ui/dialog/cssdialog.cpp
@@ -16,11 +16,13 @@
#include "verbs.h"
#include "selection.h"
-
+#include "message-context.h"
+#include "message-stack.h"
#include "ui/icon-loader.h"
#include "ui/widget/iconrenderer.h"
#include "xml/attribute-record.h"
+#include <glibmm/i18n.h>
namespace Inkscape {
namespace UI {
@@ -78,6 +80,20 @@ CssDialog::CssDialog():
_attrCol->add_attribute(_attrRenderer->property_text(), _cssColumns._styleAttrVal);
}
+ 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())));
+
+
GtkWidget *child = sp_get_icon_image("list-add", GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_widget_show(child);
_buttonAddProperty.add(*manage(Glib::wrap(child)));
@@ -89,6 +105,7 @@ CssDialog::CssDialog():
_getContents()->pack_start(_mainBox, Gtk::PACK_EXPAND_WIDGET);
+ css_reset_context(0);
setDesktop(getDesktop());
_buttonAddProperty.signal_clicked().connect(sigc::mem_fun(*this, &CssDialog::_addProperty));
@@ -102,6 +119,17 @@ CssDialog::CssDialog():
CssDialog::~CssDialog()
{
setDesktop(nullptr);
+ _message_changed_connection.disconnect();
+ _message_context = nullptr;
+ _message_stack = nullptr;
+ _message_changed_connection.~connection();
+}
+
+void CssDialog::_set_status_message(Inkscape::MessageType /*type*/, const gchar *message, GtkWidget *widget)
+{
+ if (widget) {
+ gtk_label_set_markup(GTK_LABEL(widget), message ? message : "");
+ }
}
@@ -116,6 +144,22 @@ void CssDialog::setDesktop(SPDesktop* desktop)
}
/**
+ * Sets the CSSDialog status bar, depending on which attr is selected.
+ */
+void CssDialog::css_reset_context(gint css)
+{
+ if (css == 0) {
+ _message_context->set(Inkscape::NORMAL_MESSAGE,
+ _("<b>Click</b> CSS property to edit."));
+ }
+ else {
+ const gchar *name = g_quark_to_string(css);
+ _message_context->setF(Inkscape::NORMAL_MESSAGE,
+ _("Propery <b>%s</b> selected. Press <b>Ctrl+Enter</b> when done editing to commit changes."), name);
+ }
+}
+
+/**
* @brief CssDialog::_addProperty
* This function is a slot to signal_clicked for '+' button at the bottom of CSS
* panel. A new row is added, double clicking which text for new property can be
diff --git a/src/ui/dialog/cssdialog.h b/src/ui/dialog/cssdialog.h
index c34575a1a..39de8acd0 100644
--- a/src/ui/dialog/cssdialog.h
+++ b/src/ui/dialog/cssdialog.h
@@ -20,10 +20,13 @@
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/dialog.h>
#include <ui/widget/panel.h>
+#include "message.h"
#include "desktop.h"
namespace Inkscape {
+class MessageStack;
+class MessageContext;
namespace UI {
namespace Dialog {
@@ -58,6 +61,12 @@ public:
};
CssColumns _cssColumns;
+ /**
+ * Status bar
+ */
+ std::shared_ptr<Inkscape::MessageStack> _message_stack;
+ std::unique_ptr<Inkscape::MessageContext> _message_context;
+
// TreeView
Gtk::TreeView _treeView;
Glib::RefPtr<Gtk::ListStore> _store;
@@ -68,6 +77,15 @@ public:
Gtk::TreeViewColumn *_propCol;
Gtk::TreeViewColumn *_sheetCol;
Gtk::TreeViewColumn *_attrCol;
+ Gtk::HBox status_box;
+ Gtk::Label status;
+
+ /**
+ * Sets the XML status bar, depending on which attr is selected.
+ */
+ void css_reset_context(gint css);
+ static void _set_status_message(Inkscape::MessageType type, const gchar *message, GtkWidget *dialog);
+
// Widgets
Gtk::VBox _mainBox;
@@ -81,7 +99,10 @@ public:
// Helper functions
void setDesktop(SPDesktop* desktop) override;
- // Signal handlers
+ /**
+ * Signal handlers
+ */
+ sigc::connection _message_changed_connection;
void _addProperty();
};