Lumiera  0.pre.03
»edit your freedom«
infobox-panel.cpp
Go to the documentation of this file.
1 /*
2  InfoBoxPanel - A dockable panel to expose information and parameters
3 
4  Copyright (C)
5  2017, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 * *****************************************************************/
13 
14 
19 #include "stage/gtk-base.hpp"
22 
23 
24 namespace stage {
25 namespace panel{
26 
27  using widget::ErrorLogDisplay;
28 
29 
30  InfoBoxPanel::InfoBoxPanel (workspace::PanelManager& panelManager, Gdl::DockItem& dockItem)
31  : Panel(panelManager, dockItem, getTitle(), getStockID())
32  , twoParts_{Gtk::ORIENTATION_VERTICAL}
33  , buttons_{}
34  , frame_{_("System Information")}
35  , logExpander_{_("Error Log")}
36  , theLog_{}
37  {
38  twoParts_.pack_start(frame_);
39  twoParts_.pack_start(buttons_, Gtk::PACK_SHRINK);
40 
41  buttons_.set_layout (Gtk::BUTTONBOX_START);
42 
43  // buttons to control the error log
44  buttonClear_.set_label (_("_clear Log"));
45  buttonClear_.set_use_underline();
46  buttonClear_.set_tooltip_markup (_("Discard all contents of the error log."));
47  buttonClear_.signal_clicked().connect(
48  [this](){ if (theLog_) theLog_->clearAll(); });
49  buttonClearErr_.set_label (_("_Error OK"));
50  buttonClearErr_.set_use_underline();
51  buttonClearErr_.set_tooltip_markup (_("Clear the error state and turn errors in to information entries."));
52  buttonClearErr_.signal_clicked().connect(
53  [this](){ if (theLog_) theLog_->turnError_into_InfoMsg(); });
54  buttonClearInfo_.set_label (_("drop _Info"));
55  buttonClearInfo_.set_use_underline();
56  buttonClearInfo_.set_tooltip_markup (_("Discard all mere info message, retain error entries only."));
57  buttonClearInfo_.signal_clicked().connect(
58  [this](){ if (theLog_) theLog_->clearInfoMsg(); });
59 
60  buttons_.add (buttonClear_);
61  buttons_.add (buttonClearErr_);
62  buttons_.add (buttonClearInfo_);
63  //(End)buttons...
64 
65  // show initial configuration....
66  this->add (twoParts_);
67  this->show_all();
68 
69  // schedule state update to hide the error related buttons
70  // after the UI is actually mapped to screen.
71  Glib::signal_idle()
72  .connect_once ( sigc::bind<bool>(
73  sigc::mem_fun (*this, &InfoBoxPanel::reflect_LogErrorState), false)
74  );
75  }
76 
77 
78  const char*
80  {
81  return _("InfoBox");
82  }
83 
84  const gchar*
85  InfoBoxPanel::getStockID()
86  {
87  return "panel_infobox";
88  }
89 
90 
101  {
102  if (not theLog_)
103  {
104  theLog_.reset (new ErrorLogDisplay{});
105  logExpander_.set_expanded (false);
106  logExpander_.add (*theLog_);
107  theLog_->expand = model::Expander{[&]() -> bool { return logExpander_.get_expanded(); }
108  ,[&](bool yes) { logExpander_.set_expanded (yes); }
109  };
110  theLog_->reveal = model::Revealer{[&]() { Panel::show(true);
111  theLog_->expand(true);
112  } };
113  frame_.set_border_width (5);
114  frame_.add (logExpander_);
115  frame_.show_all();
116 
117  theLog_->signalErrorChanged().connect(
118  mem_fun(*this, &InfoBoxPanel::reflect_LogErrorState));
119  }
120  return *theLog_;
121  }
122 
123 
124  void
125  InfoBoxPanel::reflect_LogErrorState (bool isError)
126  {
127  buttonClearErr_.set_visible (isError);
128  buttonClearInfo_.set_visible (isError);
129  }
130 
131 
132 }}// namespace stage::panel
static const char * getTitle()
void show(bool show=true)
Shows or hides the panel.
Definition: panel.cpp:92
Functor component to support the default implementation of revealing an UI-Element.
A class to manage DockItem objects for WorkspaceWindow.
The base class for all dockable panels.
Definition: panel.hpp:40
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:37
Widget to display error messages to be accessible in non-modal way.
A (dockable) panel to display and manage information and parameters.
InfoBoxPanel(workspace::PanelManager &, Gdl::DockItem &)
Build a new InfoBox-Panel.
widget::ErrorLogDisplay & getLog()
on demand allocate display of information / error log
Functor component to support the default implementation of expanding/collapsing.
Widget to display log and error messages.
A set of basic GTK includes for the UI.