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) Lumiera.org
5  2017, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 * *****************************************************/
22 
23 
28 #include "stage/gtk-base.hpp"
31 
32 
33 namespace stage {
34 namespace panel{
35 
36  using widget::ErrorLogDisplay;
37 
38 
39  InfoBoxPanel::InfoBoxPanel (workspace::PanelManager& panelManager, Gdl::DockItem& dockItem)
40  : Panel(panelManager, dockItem, getTitle(), getStockID())
41  , twoParts_{Gtk::ORIENTATION_VERTICAL}
42  , buttons_{}
43  , frame_{_("System Information")}
44  , logExpander_{_("Error Log")}
45  , theLog_{}
46  {
47  twoParts_.pack_start(frame_);
48  twoParts_.pack_start(buttons_, Gtk::PACK_SHRINK);
49 
50  buttons_.set_layout (Gtk::BUTTONBOX_START);
51 
52  // buttons to control the error log
53  buttonClear_.set_label (_("_clear Log"));
54  buttonClear_.set_use_underline();
55  buttonClear_.set_tooltip_markup (_("Discard all contents of the error log."));
56  buttonClear_.signal_clicked().connect(
57  [this](){ if (theLog_) theLog_->clearAll(); });
58  buttonClearErr_.set_label (_("_Error OK"));
59  buttonClearErr_.set_use_underline();
60  buttonClearErr_.set_tooltip_markup (_("Clear the error state and turn errors in to information entries."));
61  buttonClearErr_.signal_clicked().connect(
62  [this](){ if (theLog_) theLog_->turnError_into_InfoMsg(); });
63  buttonClearInfo_.set_label (_("drop _Info"));
64  buttonClearInfo_.set_use_underline();
65  buttonClearInfo_.set_tooltip_markup (_("Discard all mere info message, retain error entries only."));
66  buttonClearInfo_.signal_clicked().connect(
67  [this](){ if (theLog_) theLog_->clearInfoMsg(); });
68 
69  buttons_.add (buttonClear_);
70  buttons_.add (buttonClearErr_);
71  buttons_.add (buttonClearInfo_);
72  //(End)buttons...
73 
74  // show initial configuration....
75  this->add (twoParts_);
76  this->show_all();
77 
78  // schedule state update to hide the error related buttons
79  // after the UI is actually mapped to screen.
80  Glib::signal_idle()
81  .connect_once ( sigc::bind<bool>(
82  sigc::mem_fun (*this, &InfoBoxPanel::reflect_LogErrorState), false)
83  );
84  }
85 
86 
87  const char*
89  {
90  return _("InfoBox");
91  }
92 
93  const gchar*
94  InfoBoxPanel::getStockID()
95  {
96  return "panel_infobox";
97  }
98 
99 
110  {
111  if (not theLog_)
112  {
113  theLog_.reset (new ErrorLogDisplay{});
114  logExpander_.set_expanded (false);
115  logExpander_.add (*theLog_);
116  theLog_->expand = model::Expander{[&]() -> bool { return logExpander_.get_expanded(); }
117  ,[&](bool yes) { logExpander_.set_expanded (yes); }
118  };
119  theLog_->reveal = model::Revealer{[&]() { Panel::show(true);
120  theLog_->expand(true);
121  } };
122  frame_.set_border_width (5);
123  frame_.add (logExpander_);
124  frame_.show_all();
125 
126  theLog_->signalErrorChanged().connect(
127  mem_fun(*this, &InfoBoxPanel::reflect_LogErrorState));
128  }
129  return *theLog_;
130  }
131 
132 
133  void
134  InfoBoxPanel::reflect_LogErrorState (bool isError)
135  {
136  buttonClearErr_.set_visible (isError);
137  buttonClearInfo_.set_visible (isError);
138  }
139 
140 
141 }}// namespace stage::panel
static const char * getTitle()
void show(bool show=true)
Shows or hides the panel.
Definition: panel.cpp:101
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:49
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:46
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.