NotificationDisplay: investigate ways to define the markup tag(s)
...with the option to expand this approach later to use a central StyleManager (#1169)
This commit is contained in:
parent
5b14e83ebf
commit
fa55ff63d5
2 changed files with 57 additions and 24 deletions
|
|
@ -59,7 +59,7 @@
|
||||||
#include "gui/gtk-base.hpp"
|
#include "gui/gtk-base.hpp"
|
||||||
#include "gui/model/expander-revealer.hpp"
|
#include "gui/model/expander-revealer.hpp"
|
||||||
#include "include/gui-notification-facade.h"
|
#include "include/gui-notification-facade.h"
|
||||||
|
#include "lib/symbol.hpp"
|
||||||
//#include "lib/util.hpp"
|
//#include "lib/util.hpp"
|
||||||
|
|
||||||
//#include <memory>
|
//#include <memory>
|
||||||
|
|
@ -70,8 +70,30 @@
|
||||||
namespace gui {
|
namespace gui {
|
||||||
namespace widget {
|
namespace widget {
|
||||||
|
|
||||||
|
using lib::Literal;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
const Literal TAG_ERROR{"ERROR"}; /////////////////////////////////////////////////////////////TICKET #1168 : find a way to manage style of custom extended UI elements
|
||||||
|
|
||||||
|
|
||||||
|
using Tag = Glib::RefPtr<Gtk::TextBuffer::Tag>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal inject some generic standard styles for use in `TextView` components.
|
||||||
|
* @param tagTable reference to a `TagTable` bound with an existing `Gtk::TextBuffer`.
|
||||||
|
* @todo 9/2018 dummy placeholder code, later to be transformed into a framework /////////////////////TICKET #1168 : find a way to manage style of custom extended UI elements
|
||||||
|
*/
|
||||||
|
inline void
|
||||||
|
populateStandardTextTags (Glib::RefPtr<TextBuffer::TagTable> tagTable)
|
||||||
|
{
|
||||||
|
Tag errorTag = Gtk::TextBuffer::Tag::create();
|
||||||
|
errorTag->property_background() = "yellow"; ////////////////////////////////////////////TICKET #1168 : should be retrieved from a central location
|
||||||
|
tagTable->add (errorTag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo WIP-WIP as of 9/2017
|
* @todo WIP-WIP as of 9/2017
|
||||||
|
|
@ -104,6 +126,8 @@ namespace widget {
|
||||||
set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS);
|
set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS);
|
||||||
this->add (textLog_);
|
this->add (textLog_);
|
||||||
textLog_.set_editable (false);
|
textLog_.set_editable (false);
|
||||||
|
|
||||||
|
populateStandardTextTags (textLog_.get_buffer()->get_tag_table());
|
||||||
}
|
}
|
||||||
|
|
||||||
model::Expander expand;
|
model::Expander expand;
|
||||||
|
|
@ -159,24 +183,6 @@ namespace widget {
|
||||||
|
|
||||||
private:/* ===== Internals ===== */
|
private:/* ===== Internals ===== */
|
||||||
|
|
||||||
void
|
|
||||||
showMsg (NotifyLevel severity, string const& text)
|
|
||||||
{
|
|
||||||
//////////////////////////////////////////////////TICKET #1102 : add formatting according to the error level
|
|
||||||
switch (severity) {
|
|
||||||
case NOTE_ERROR:
|
|
||||||
addEntry ("ERROR: "+text);
|
|
||||||
break;
|
|
||||||
case NOTE_WARN:
|
|
||||||
addEntry ("WARN: "+text);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
addEntry (text);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/** add message entry to the (ever growing) text buffer.
|
/** add message entry to the (ever growing) text buffer.
|
||||||
* @remark According to the [GTKmm tutorial], `TextView::scroll_to(iter)` is not reliable;
|
* @remark According to the [GTKmm tutorial], `TextView::scroll_to(iter)` is not reliable;
|
||||||
* rather we need to use a text mark and set that text mark to the insert position.
|
* rather we need to use a text mark and set that text mark to the insert position.
|
||||||
|
|
@ -187,7 +193,7 @@ namespace widget {
|
||||||
* [GTKmm tutorial]: https://developer.gnome.org/gtkmm-tutorial/stable/sec-textview-buffer.html.en#textview-marks
|
* [GTKmm tutorial]: https://developer.gnome.org/gtkmm-tutorial/stable/sec-textview-buffer.html.en#textview-marks
|
||||||
* [insert-mark]: https://developer.gnome.org/gtkmm/3.22/classGtk_1_1TextMark.html#details
|
* [insert-mark]: https://developer.gnome.org/gtkmm/3.22/classGtk_1_1TextMark.html#details
|
||||||
*/
|
*/
|
||||||
void
|
auto
|
||||||
addEntry (string const& text)
|
addEntry (string const& text)
|
||||||
{
|
{
|
||||||
auto buff = textLog_.get_buffer();
|
auto buff = textLog_.get_buffer();
|
||||||
|
|
@ -195,6 +201,25 @@ namespace widget {
|
||||||
buff->move_mark (cursor, buff->end());
|
buff->move_mark (cursor, buff->end());
|
||||||
buff->insert (buff->end(), text);
|
buff->insert (buff->end(), text);
|
||||||
textLog_.scroll_to (cursor);
|
textLog_.scroll_to (cursor);
|
||||||
|
return cursor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
showMsg (NotifyLevel severity, string const& text)
|
||||||
|
{
|
||||||
|
//////////////////////////////////////////////////TICKET #1102 : add formatting according to the error level
|
||||||
|
switch (severity) {
|
||||||
|
case NOTE_ERROR:
|
||||||
|
errorMarks_.emplace_back(
|
||||||
|
addEntry ("ERROR: "+text));
|
||||||
|
break;
|
||||||
|
case NOTE_WARN:
|
||||||
|
addEntry ("WARN: "+text);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
addEntry (text);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1985,17 +1985,24 @@
|
||||||
</node>
|
</node>
|
||||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1537661787387" ID="ID_20967740" MODIFIED="1537661797859" TEXT="vorläufig hart verdrahten">
|
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1537661787387" ID="ID_20967740" MODIFIED="1537661797859" TEXT="vorläufig hart verdrahten">
|
||||||
<icon BUILTIN="flag-yellow"/>
|
<icon BUILTIN="flag-yellow"/>
|
||||||
|
<node CREATED="1537752420235" ID="ID_922959985" MODIFIED="1537752432342" TEXT="Funktion zum Populieren der Tag-Table"/>
|
||||||
|
<node CREATED="1537752434280" ID="ID_1053927695" MODIFIED="1537752468330" TEXT="könnte in den StyleManager wandern">
|
||||||
|
<arrowlink COLOR="#b3a9c1" DESTINATION="ID_758790930" ENDARROW="Default" ENDINCLINATION="96;-5;" ID="Arrow_ID_1283375190" STARTARROW="None" STARTINCLINATION="-17;39;"/>
|
||||||
|
<icon BUILTIN="idea"/>
|
||||||
</node>
|
</node>
|
||||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1537661799354" ID="ID_758790930" MODIFIED="1537661906780" TEXT="Style-Manager vorsehen">
|
</node>
|
||||||
|
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1537661799354" ID="ID_758790930" MODIFIED="1537752455019" TEXT="Style-Manager vorsehen">
|
||||||
<arrowlink COLOR="#8f81b2" DESTINATION="ID_407535546" ENDARROW="Default" ENDINCLINATION="3769;-2728;" ID="Arrow_ID_1203118148" STARTARROW="None" STARTINCLINATION="-1594;0;"/>
|
<arrowlink COLOR="#8f81b2" DESTINATION="ID_407535546" ENDARROW="Default" ENDINCLINATION="3769;-2728;" ID="Arrow_ID_1203118148" STARTARROW="None" STARTINCLINATION="-1594;0;"/>
|
||||||
|
<linktarget COLOR="#877796" DESTINATION="ID_758790930" ENDARROW="Default" ENDINCLINATION="315;0;" ID="Arrow_ID_564282272" SOURCE="ID_951505172" STARTARROW="None" STARTINCLINATION="649;0;"/>
|
||||||
|
<linktarget COLOR="#b3a9c1" DESTINATION="ID_758790930" ENDARROW="Default" ENDINCLINATION="96;-5;" ID="Arrow_ID_1283375190" SOURCE="ID_1053927695" STARTARROW="None" STARTINCLINATION="-17;39;"/>
|
||||||
<icon BUILTIN="flag-yellow"/>
|
<icon BUILTIN="flag-yellow"/>
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1537571928143" ID="ID_221069673" MODIFIED="1537571967923" TEXT="Tag für Warnung">
|
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1537571928143" ID="ID_221069673" MODIFIED="1537571967923" TEXT="Tag für Warnung">
|
||||||
<icon BUILTIN="flag-yellow"/>
|
<icon BUILTIN="flag-yellow"/>
|
||||||
</node>
|
</node>
|
||||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1537571934143" ID="ID_447258227" MODIFIED="1537571967219" TEXT="Tag für Fehler">
|
<node COLOR="#338800" CREATED="1537571934143" ID="ID_447258227" MODIFIED="1537752476750" TEXT="Tag für Fehler">
|
||||||
<icon BUILTIN="flag-yellow"/>
|
<icon BUILTIN="button_ok"/>
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1537571949893" ID="ID_328949056" MODIFIED="1537571962861" TEXT="Tags zuweisen">
|
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1537571949893" ID="ID_328949056" MODIFIED="1537571962861" TEXT="Tags zuweisen">
|
||||||
|
|
@ -2102,7 +2109,8 @@
|
||||||
<icon BUILTIN="flag-yellow"/>
|
<icon BUILTIN="flag-yellow"/>
|
||||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1534725283337" ID="ID_1256364821" MODIFIED="1534725298760" TEXT="farbigen Rahmen">
|
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1534725283337" ID="ID_1256364821" MODIFIED="1534725298760" TEXT="farbigen Rahmen">
|
||||||
<icon BUILTIN="flag-yellow"/>
|
<icon BUILTIN="flag-yellow"/>
|
||||||
<node CREATED="1534725366734" ID="ID_951505172" MODIFIED="1534725377925" TEXT="vorläufig feste Farbe">
|
<node CREATED="1534725366734" ID="ID_951505172" MODIFIED="1537752365219" TEXT="vorläufig feste Farbe">
|
||||||
|
<arrowlink COLOR="#877796" DESTINATION="ID_758790930" ENDARROW="Default" ENDINCLINATION="315;0;" ID="Arrow_ID_564282272" STARTARROW="None" STARTINCLINATION="649;0;"/>
|
||||||
<icon BUILTIN="yes"/>
|
<icon BUILTIN="yes"/>
|
||||||
</node>
|
</node>
|
||||||
</node>
|
</node>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue