[nemiver/monitor-variable: 5/5] Control when to allow variable monitoring better
- From: Dodji Seketeli <dodji src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nemiver/monitor-variable: 5/5] Control when to allow variable monitoring better
- Date: Tue, 1 May 2012 22:07:30 +0000 (UTC)
commit 09f876e99576a8d75074f025346c267923f07a55
Author: Dodji Seketeli <dodji seketeli org>
Date: Tue May 1 23:29:21 2012 +0200
Control when to allow variable monitoring better
* src/persp/dbgperspective/nmv-var-inspector.h (inspect_variable):
Declare new overload.
(var_inspected_signal, cleared_signal): Declare new signal slot
accessors.
* src/persp/dbgperspective/nmv-var-inspector.cc
(no_op_void_variable_slot): New static function.
(VarInspector::Priv::var_inspected_signal)
(VarInspector::Priv::cleared_signal): New members.
(VarInspector::Priv::create_variable): New overload.
(VarInspector::Privon_variable_created_signal): Take a slot in
parameter.
(VarInspector::Priv::inspect_variable): New overload that takes a
slot in parameter.
(VarInspector::var_inspected_signal)
(VarInspector::Priv::cleared_signal): Define new signal slot
accessors.
* src/persp/dbgperspective/nmv-var-inspector-dialog.cc
(VarInspectorDialog::Priv::build_dialog): Connect to the new
VarInspector::cleared_signal to disable the "add to monitor"
button whenever the inspector is cleared.
(VarInspectorDialog::Priv::do_inspect_variable): Style cleanup.
(VarInspectorDialog::Priv::inspect_variable): Adjust to the new
signature of the call to VarInspector::inspect_variable; pass it
the slot to be called whenever a variable is added to the
inspector. This is to enable the "add to monitor" button whenever
the inspected variable is added to the inspector.
(VarInspectorDialog::Priv::on_var_name_changed_signal): Do not
enable/disable the "add to monitor" button based on the presence
of an expression/name in the "variable name" entry field.
(VarInspectorDialog::Priv::on_variable_inspected)
(VarInspectorDialog::Priv::on_variable_inspector_cleared): New
handlers.
.../dbgperspective/nmv-var-inspector-dialog.cc | 58 +++++++++--
src/persp/dbgperspective/nmv-var-inspector.cc | 109 ++++++++++++++++++-
src/persp/dbgperspective/nmv-var-inspector.h | 10 ++
3 files changed, 160 insertions(+), 17 deletions(-)
---
diff --git a/src/persp/dbgperspective/nmv-var-inspector-dialog.cc b/src/persp/dbgperspective/nmv-var-inspector-dialog.cc
index 6959f1d..8701045 100644
--- a/src/persp/dbgperspective/nmv-var-inspector-dialog.cc
+++ b/src/persp/dbgperspective/nmv-var-inspector-dialog.cc
@@ -78,6 +78,9 @@ public:
connect_to_widget_signals ();
}
+ /// Build the inspector dialog.
+ ///
+ /// Fetch widgets from gtkbuilder and initialize them.
void
build_dialog ()
{
@@ -104,9 +107,13 @@ public:
Gtk::Box *box =
ui_utils::get_widget_from_gtkbuilder<Gtk::Box> (gtkbuilder,
"inspectorwidgetbox");
+
var_inspector.reset (new VarInspector (debugger, perspective));
var_inspector->enable_contextual_menu (true);
- THROW_IF_FAIL (var_inspector);
+ var_inspector->cleared_signal ().connect
+ (sigc::mem_fun
+ (*this,
+ &VarInspectorDialog::Priv::on_variable_inspector_cleared));
Gtk::ScrolledWindow *scr = Gtk::manage (new Gtk::ScrolledWindow);
scr->set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
@@ -131,27 +138,42 @@ public:
(*this, &Priv::do_inspect_variable));
}
+ /// Inspect the variable (or, more generally the expression) which
+ /// name the user has typed in the variable name entry, in the UI.
void
do_inspect_variable ()
{
- NEMIVER_TRY
+ NEMIVER_TRY;
THROW_IF_FAIL (var_name_entry);
UString var_name = var_name_entry->get_entry ()->get_text ();
- if (var_name == "") {return;}
- inspect_variable (var_name, true);
+ if (var_name == "")
+ return;
- NEMIVER_CATCH
+ inspect_variable (var_name, /*expand=*/true);
+
+ NEMIVER_CATCH;
}
+ /// Inspect an expression.
+ ///
+ /// \param a_expr the expression to inspect.
+ ///
+ /// \param a_expand whether to expand the resulting expression
+ /// tree.
void
inspect_variable (const UString& a_expr,
bool a_expand)
{
THROW_IF_FAIL (var_inspector);
THROW_IF_FAIL (m_variable_history);
- var_inspector->inspect_variable (a_expr, a_expand);
+ var_inspector->inspect_variable
+ (a_expr,
+ a_expand,
+ sigc::mem_fun (*this,
+ &VarInspectorDialog::Priv::on_variable_inspected));
+
add_to_history (a_expr,
false /*append*/,
false /*don't allow duplicates*/);
@@ -263,6 +285,8 @@ public:
//<signal handlers>
//*************************
+ /// Handler called when the name of the variable changes in the
+ /// variable name entry field.
void
on_var_name_changed_signal ()
{
@@ -273,13 +297,10 @@ public:
THROW_IF_FAIL (inspect_button);
UString var_name = var_name_entry->get_entry ()->get_text ();
- if (var_name == "") {
+ if (var_name == "")
inspect_button->set_sensitive (false);
- add_to_monitor_button->set_sensitive (false);
- } else {
+ else
inspect_button->set_sensitive (true);
- add_to_monitor_button->set_sensitive (true);
- }
// this handler is called when any text is changed in the entry or when
// an item is selected from the combobox. We don't want to inspect any
@@ -304,6 +325,21 @@ public:
NEMIVER_CATCH
}
+ /// Handler called when the variable to be inspected is actually
+ /// added to the inspector.
+ void
+ on_variable_inspected (const IDebugger::VariableSafePtr)
+ {
+ add_to_monitor_button->set_sensitive (true);
+ }
+
+ /// Handler called when the variable inspector is cleared.
+ void
+ on_variable_inspector_cleared ()
+ {
+ add_to_monitor_button->set_sensitive (false);
+ }
+
//************************
//</signal handlers>
//*************************
diff --git a/src/persp/dbgperspective/nmv-var-inspector.cc b/src/persp/dbgperspective/nmv-var-inspector.cc
index 5fc5dfa..f47a0e3 100644
--- a/src/persp/dbgperspective/nmv-var-inspector.cc
+++ b/src/persp/dbgperspective/nmv-var-inspector.cc
@@ -45,6 +45,12 @@ using cmn::DynamicModuleManager;
NEMIVER_BEGIN_NAMESPACE (nemiver)
+/// A no-op variable slot.
+static void
+no_op_void_variable_slot (const IDebugger::VariableSafePtr)
+{
+}
+
class VarInspector::Priv : public sigc::trackable {
friend class VarInspector;
Priv ();
@@ -68,6 +74,9 @@ class VarInspector::Priv : public sigc::trackable {
IVarWalkerSafePtr varobj_walker;
DynamicModuleManager *module_manager;
Glib::RefPtr<Gtk::UIManager> ui_manager;
+ mutable sigc::signal<void,
+ const IDebugger::VariableSafePtr> var_inspected_signal;
+ mutable sigc::signal<void> cleared_signal;
void
build_widget ()
@@ -233,16 +242,46 @@ class VarInspector::Priv : public sigc::trackable {
ui_utils::display_info (message);
}
+ /// Creates a variable (or more generally, an expression).
+ ///
+ /// \param a_name the expression (or name of the variable) to
+ /// create.
+ ///
+ /// \param a_expand whethet to expand the tree representing the
+ /// expression that is going to be created, or not.
void
create_variable (const UString &a_name,
bool a_expand)
{
+ create_variable (a_name, a_expand, &no_op_void_variable_slot);
+ }
+
+ /// Creates a variable (or more generally, an expression).
+ ///
+ /// \param a_name the expression (or name of the variable) to
+ /// create.
+ ///
+ /// \param a_expand whethet to expand the tree representing the
+ /// expression that is going to be created, or not.
+ ///
+ /// \param a_slot a slot (an abstraction of a handler function)
+ /// that is invoked whenever the resulting expression is added to
+ /// the inspector.
+ void
+ create_variable (const UString &a_name,
+ bool a_expand,
+ const sigc::slot<void,
+ const IDebugger::VariableSafePtr> &a_slot)
+ {
LOG_FUNCTION_SCOPE_NORMAL_DD;
expand_variable = a_expand;
debugger->create_variable
- (a_name, sigc::mem_fun
- (this, &VarInspector::Priv::on_variable_created_signal));
+ (a_name,
+ sigc::bind
+ (sigc::mem_fun
+ (this, &VarInspector::Priv::on_variable_created_signal),
+ a_slot));
}
Glib::RefPtr<Gtk::UIManager> get_ui_manager ()
@@ -487,14 +526,27 @@ class VarInspector::Priv : public sigc::trackable {
NEMIVER_CATCH
}
+ /// A handler called whenever a variable is created in the
+ /// debugger interface, as a result of the user requesting that we
+ /// inspect it. The function then adds the variable into the
+ /// inspector.
+ ///
+ /// \param a_var the created variable
+ ///
+ /// \param a_slot a handler to be called whenever the variable is
+ /// added to the inspector.
void
- on_variable_created_signal (const IDebugger::VariableSafePtr a_var)
+ on_variable_created_signal (const IDebugger::VariableSafePtr a_var,
+ sigc::slot<void,
+ const IDebugger::VariableSafePtr> &a_slot)
{
LOG_FUNCTION_SCOPE_NORMAL_DD;
NEMIVER_TRY;
set_variable (a_var, expand_variable, re_visualize);
+ var_inspected_signal.emit (a_var);
+ a_slot (a_var);
NEMIVER_CATCH;
}
@@ -643,16 +695,45 @@ VarInspector::set_variable (IDebugger::VariableSafePtr a_variable,
m_priv->set_variable (a_variable, a_expand, a_revisualize);
}
+/// Inspect a variable/expression.
+///
+/// \param a_variable_name the name of the variable, or more
+/// generally, the expression to the inspected.
+///
+/// \param a_expand whether to expand the resulting tree representing
+/// the expression.
+void
+VarInspector::inspect_variable (const UString &a_variable_name,
+ bool a_expand)
+{
+ inspect_variable (a_variable_name,
+ a_expand,
+ &no_op_void_variable_slot);
+}
+
+/// Inspect a variable/expression.
+///
+/// \param a_variable_name the name of the variable, or more
+/// generally, the expression to the inspected.
+///
+/// \param a_expand whether to expand the resulting tree representing
+/// the expression.
+///
+/// \param a_s a slot (handler function) to be invoked whenever the
+/// resulting tree (representing the expression to the inspected) is
+/// added to the inspector.
void
VarInspector::inspect_variable (const UString &a_variable_name,
- bool a_expand)
+ bool a_expand,
+ const sigc::slot<void,
+ const IDebugger::VariableSafePtr> &a_s)
{
LOG_FUNCTION_SCOPE_NORMAL_DD;
if (a_variable_name == "") {return;}
THROW_IF_FAIL (m_priv);
m_priv->re_init_tree_view ();
- m_priv->create_variable (a_variable_name, a_expand);
+ m_priv->create_variable (a_variable_name, a_expand, a_s);
}
IDebugger::VariableSafePtr
@@ -684,5 +765,21 @@ VarInspector::clear ()
m_priv->re_init_tree_view ();
}
-NEMIVER_END_NAMESPACE (nemiver)
+/// A signal emitted when the variable to be inspected is added to the
+/// inspector.
+sigc::signal<void, const IDebugger::VariableSafePtr>&
+VarInspector::var_inspected_signal () const
+{
+ THROW_IF_FAIL (m_priv);
+ return m_priv->var_inspected_signal;
+}
+/// A signal emitted when the inspector is cleared.
+sigc::signal<void>&
+VarInspector::cleared_signal () const
+{
+ THROW_IF_FAIL (m_priv);
+ return m_priv->cleared_signal;
+}
+
+NEMIVER_END_NAMESPACE (nemiver)
diff --git a/src/persp/dbgperspective/nmv-var-inspector.h b/src/persp/dbgperspective/nmv-var-inspector.h
index 406eacc..1414c71 100644
--- a/src/persp/dbgperspective/nmv-var-inspector.h
+++ b/src/persp/dbgperspective/nmv-var-inspector.h
@@ -57,10 +57,20 @@ public:
bool a_re_visualize = false);
void inspect_variable (const UString &a_variable_name,
bool a_expand = false);
+ void inspect_variable (const UString &a_variable_name,
+ bool a_expand,
+ const sigc::slot<void,
+ const IDebugger::VariableSafePtr> &a_s);
IDebugger::VariableSafePtr get_variable () const;
void enable_contextual_menu (bool a_flag);
bool is_contextual_menu_enabled () const;
void clear ();
+
+ // Signals
+ sigc::signal<void, const IDebugger::VariableSafePtr>&
+ var_inspected_signal () const;
+ sigc::signal<void>& cleared_signal () const;
+
};//end class VarInspector
NEMIVER_END_NAMESPACE (nemiver)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]