From abfb897336772f9268ac87071f0646437a90a80d Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 29 Sep 2018 15:23:47 +0200 Subject: [PATCH] DemoGuiRoundtrip: now invoke the Proc-Layer commands from within the UI dialog --- src/gui/dialog/test-control.hpp | 32 +++++++++++++++----- src/gui/model/tangible.hpp | 28 +++++++++++++----- src/proc/cmd/meta-cmd.cpp | 52 +++++++++++++-------------------- wiki/thinkPad.ichthyo.mm | 20 +++++++++---- 4 files changed, 79 insertions(+), 53 deletions(-) diff --git a/src/gui/dialog/test-control.hpp b/src/gui/dialog/test-control.hpp index 2377a07c8..e9045c5cb 100644 --- a/src/gui/dialog/test-control.hpp +++ b/src/gui/dialog/test-control.hpp @@ -42,6 +42,9 @@ #include "gui/gtk-base.hpp" #include "gui/dialog/dialog.hpp" #include "gui/ctrl/bus-term.hpp" +#include "gui/model/tangible.hpp" +#include "proc/cmd.hpp" +#include "include/gui-notification-facade.h" #include "lib/scoped-ptrvect.hpp" #include "lib/diff/gen-node.hpp" #include "lib/nocopy.hpp" @@ -179,14 +182,27 @@ namespace dialog { Gtk::Box markParam_; Gtk::ComboBoxText actionID_{true}; // has free-text entry field - string + int getLogLevel() { - return level_info_.get_active()? "NOTE_INFO" : - level_warn_.get_active()? "NOTE_WARN" : "NOTE_ERROR"; + return level_info_.get_active()? NOTE_INFO : + level_warn_.get_active()? NOTE_WARN : NOTE_ERROR; } - Page1(Bus bus) + string + getContent() + { + return string{content_.get_text()}; + } + + string + getActionID() + { + return string{actionID_.get_entry_text()}; + } + + + Page1 (Bus bus) { content_.set_tooltip_markup (_("Ticket #1099:\n" "text message content\n" @@ -247,13 +263,13 @@ namespace dialog { // define the action triggers... trig_1_.signal_clicked().connect( - [&]{ demoGuiRoundtrip(bus, "displayInfo("+getLogLevel()+", \""+content_.get_text()+"\")"); }); + [&]{ bus.act (model::commandMessage (proc::cmd::test_meta_displayInfo, getLogLevel(), getContent())); }); trig_2_.signal_clicked().connect( - [&]{ demoGuiRoundtrip(bus, "markError(\""+content_.get_text()+"\")"); }); + [&]{ bus.act (model::commandMessage (proc::cmd::test_meta_markError, getContent())); }); trig_3_.signal_clicked().connect( - [&]{ demoGuiRoundtrip(bus, "markNote(\""+content_.get_text()+"\")"); }); + [&]{ bus.act (model::commandMessage (proc::cmd::test_meta_markNote, getContent())); }); trig_4_.signal_clicked().connect( - [&]{ demoGuiRoundtrip(bus, "mark("+actionID_.get_entry_text()+", \""+content_.get_text()+"\")"); }); + [&]{ bus.act (model::commandMessage (proc::cmd::test_meta_markAction, getActionID(), getContent())); }); } void diff --git a/src/gui/model/tangible.hpp b/src/gui/model/tangible.hpp index fb07452a4..55f8d73ae 100644 --- a/src/gui/model/tangible.hpp +++ b/src/gui/model/tangible.hpp @@ -241,18 +241,32 @@ namespace model { + /** convenience shortcut to build a message suitable for command invocation + * @param args... sequence of arguments to be packaged into a lib::diff::Rec for invocation + */ + template + inline lib::diff::GenNode + commandMessage (Symbol cmdID, ARGS&&... args) + { + using lib::diff::Rec; + using lib::diff::GenNode; + using GenNodeIL = std::initializer_list; + + + return GenNode (string{cmdID}, + Rec(Rec::TYPE_NIL_SYM + ,GenNodeIL{} + ,GenNodeIL {std::forward (args)...})); + } // not typed, no attributes, all arguments as children + + /** convenience shortcut to issue a command with several arguments */ template inline void Tangible::invoke (Symbol cmdID, ARGS&&... args) { - using GenNodeIL = std::initializer_list; - - invoke (cmdID, - Rec(Rec::TYPE_NIL_SYM - ,GenNodeIL{} - ,GenNodeIL {std::forward (args)...})); - } // not typed, no attributes, all arguments as children + uiBus_.act (commandMessage (cmdID, std::forward (args)...)); + } /** diff --git a/src/proc/cmd/meta-cmd.cpp b/src/proc/cmd/meta-cmd.cpp index ef0cf7ed3..2369fda9b 100644 --- a/src/proc/cmd/meta-cmd.cpp +++ b/src/proc/cmd/meta-cmd.cpp @@ -42,7 +42,7 @@ #include "gui/interact/wizard.hpp" //////////////////////////////////////////////////////////////TICKET #1099 : include needed temporarily //#include "lib/symbol.hpp" #include "lib/idi/entry-id.hpp" -//#include "lib/format-string.hpp" +#include "lib/format-string.hpp" //////////////////////////////////////////////////////////////TICKET #1099 : include needed temporarily #include @@ -54,7 +54,7 @@ using gui::NOTE_ERROR; using gui::NotifyLevel; using gui::GuiNotification; //using util::cStr; -//using util::_Fmt; +using util::_Fmt; //////////////////////////////////////////////////////////////TICKET #1099 : include needed temporarily using std::string; @@ -144,20 +144,17 @@ COMMAND_DEFINITION (meta_deactivateContentDiff) */ COMMAND_DEFINITION (test_meta_displayInfo) { - def.operation ([](NotifyLevel level, string message) + def.operation ([](int level, string message) { - GuiNotification::facade().displayInfo (level, message); + GuiNotification::facade().displayInfo (static_cast(level), message); }) - .captureUndo ([](NotifyLevel level, string message) -> bool + .captureUndo ([](int level, string message) -> string { - return true; + return _Fmt{"displayInfo(%d, '%s')"} % level % message; }) - .undoOperation ([](NotifyLevel level, string message, bool wasActive) + .undoOperation ([](int, string, string uiAction) { - if (wasActive) - { - GuiNotification::facade().displayInfo (NOTE_WARN, "Sorry, can't do that Dave."); - } + GuiNotification::facade().displayInfo (NOTE_WARN, "can not UNDO UI-Action: "+uiAction); }); }; @@ -172,16 +169,13 @@ COMMAND_DEFINITION (test_meta_markError) ID errorLogID = gui::interact::Wizard::getErrorLogID(); GuiNotification::facade().markError (errorLogID, message); }) - .captureUndo ([](string message) -> bool + .captureUndo ([](string message) -> string { - return true; + return _Fmt{"GUI::errorLog <- markError('%s')"} % message; }) - .undoOperation ([](string message, bool wasActive) + .undoOperation ([](string, string uiAction) { - if (wasActive) - { - GuiNotification::facade().displayInfo (NOTE_WARN, "Sorry, can't do that Dave."); - } + GuiNotification::facade().displayInfo (NOTE_WARN, "can not UNDO UI-Action: "+uiAction); }); }; @@ -196,16 +190,13 @@ COMMAND_DEFINITION (test_meta_markNote) ID errorLogID = gui::interact::Wizard::getErrorLogID(); GuiNotification::facade().markNote (errorLogID, message); }) - .captureUndo ([](string message) -> bool + .captureUndo ([](string message) -> string { - return true; + return _Fmt{"GUI::errorLog <- markNote('%s')"} % message; }) - .undoOperation ([](string message, bool wasActive) + .undoOperation ([](string, string uiAction) { - if (wasActive) - { - GuiNotification::facade().displayInfo (NOTE_WARN, "Sorry, can't do that Dave."); - } + GuiNotification::facade().displayInfo (NOTE_WARN, "can not UNDO UI-Action: "+uiAction); }); }; @@ -220,16 +211,13 @@ COMMAND_DEFINITION (test_meta_markAction) ID errorLogID = gui::interact::Wizard::getErrorLogID(); UNIMPLEMENTED ("GuiNotification::facade().mark (errorLogID, actionID, message);"); }) - .captureUndo ([](string actionID, string message) -> bool + .captureUndo ([](string actionID, string message) -> string { - return true; + return _Fmt{"GUI::errorLog <- mark(%s, '%s')"} % actionID % message; }) - .undoOperation ([](string actionID, string message, bool wasActive) + .undoOperation ([](string, string, string uiAction) { - if (wasActive) - { - GuiNotification::facade().displayInfo (NOTE_WARN, "Sorry, can't do that Dave."); - } + GuiNotification::facade().displayInfo (NOTE_WARN, "can not UNDO UI-Action: "+uiAction); }); }; diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 51b725218..880cff9e8 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -2801,15 +2801,23 @@ - + - + - - - - + + + + + + + + + + + +