[nemiver/varobjs-support] VarInspector2 got a new "copy-varable-path" menu
- From: Dodji Seketeli <dodji src gnome org>
- To: svn-commits-list gnome org
- Subject: [nemiver/varobjs-support] VarInspector2 got a new "copy-varable-path" menu
- Date: Mon, 25 May 2009 05:36:15 -0400 (EDT)
commit 71d8f3f5990eb6b218bcffcdc7f96f088d0826b0
Author: Dodji Seketeli <dodji redhat com>
Date: Mon May 25 09:55:38 2009 +0200
VarInspector2 got a new "copy-varable-path" menu
* src/persp/dbgperspective/nmv-var-inspector2.cc:
(VarInspector2::Priv::Priv): A reference to IPerspective is now
stored into the inspector. It must be passed at construction time.
(VarInspector2::Priv::init_actions): New method that setups menu
actions so that we can have a menu proposing to copy the path
expression of variable node to the gtk clipboard. As we have access
to the perspective, we can access the ui_manager through the
workbench, yay.
(VarInspector2::Priv::build_widget):
Call VarInspector2::Priv::init_actions.
(VarInspector2::Priv::connect_to_signals): Setup the
on_button_press_signal slot for when we right click on a variable
node.
(VarInspector2::Priv::get_var_inspector_menu): New method. Load the
contextual menu from its varinspectorpopup.xml menu file.
(VarInspector2::Priv::popup_var_inspector_menu): New method. Pops
the menu up.
(VarInspector2::Priv::on_button_press_signal): New slot. Popups the
new contextual menu.
(VarInspector2::Priv::on_variable_path_expr_copy_to_clipboard_action):
New method.
(VarInspector2::Priv::on_variable_path_expression_signal): New
method.
(VarInspector2::VarInspector2): The constructor now takes a
reference to IPerspective.
* src/persp/dbgperspective/nmv-var-inspector2.h:
(VarInspector2::VarInspector2): Likewise.
* src/persp/dbgperspective/menus/varinspectorpopup.xml:
This menu file is now used by VarInspector2.
* src/persp/dbgperspective/nmv-var-inspector-dialog.cc,h:
Pass a reference of the perspective to the dialog. That reference
is then passed to the VarInspector2 widget.
* src/persp/dbgperspective/nmv-watchpoint-dialog.cc: Likewise.
* src/persp/dbgperspective/nmv-dbg-perspective.cc:
(DBGPerspective::inspect_variable): Adjust to pass a
reference of the perspective to the var inspector dialog.
(DBGPerspective::set_watchpoint_using_dialog): Likewise for the
watchpoint dialog.
---
.../dbgperspective/menus/varinspectorpopup.xml | 4 +-
src/persp/dbgperspective/nmv-dbg-perspective.cc | 6 +-
.../dbgperspective/nmv-var-inspector-dialog.cc | 23 +++--
.../dbgperspective/nmv-var-inspector-dialog.h | 4 +-
src/persp/dbgperspective/nmv-var-inspector2.cc | 129 +++++++++++++++++++-
src/persp/dbgperspective/nmv-var-inspector2.h | 4 +-
src/persp/dbgperspective/nmv-watchpoint-dialog.cc | 15 ++-
src/persp/dbgperspective/nmv-watchpoint-dialog.h | 4 +-
8 files changed, 165 insertions(+), 24 deletions(-)
diff --git a/src/persp/dbgperspective/menus/varinspectorpopup.xml b/src/persp/dbgperspective/menus/varinspectorpopup.xml
index cd99e22..dd42b04 100644
--- a/src/persp/dbgperspective/menus/varinspectorpopup.xml
+++ b/src/persp/dbgperspective/menus/varinspectorpopup.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<ui>
<popup name="VarInspectorPopup">
- <menuitem action="DereferencePointerMenuItemAction"
- name="DereferencePointerMenuItem" />
+ <menuitem action="CopyVariablePathMenuItemAction"
+ name="CopyVariablePathMenuItem" />
</popup>
</ui>
diff --git a/src/persp/dbgperspective/nmv-dbg-perspective.cc b/src/persp/dbgperspective/nmv-dbg-perspective.cc
index e22106e..99fa794 100644
--- a/src/persp/dbgperspective/nmv-dbg-perspective.cc
+++ b/src/persp/dbgperspective/nmv-dbg-perspective.cc
@@ -5905,7 +5905,7 @@ DBGPerspective::set_watchpoint_using_dialog ()
{
LOG_FUNCTION_SCOPE_NORMAL_DD;
- WatchpointDialog dialog (plugin_path (), debugger ());
+ WatchpointDialog dialog (plugin_path (), debugger (), *this);
int result = dialog.run ();
if (result != Gtk::RESPONSE_OK) {
return;
@@ -5993,7 +5993,9 @@ void
DBGPerspective::inspect_variable (const UString &a_variable_name)
{
THROW_IF_FAIL (debugger ());
- VarInspectorDialog dialog (plugin_path (), debugger ());
+ VarInspectorDialog dialog (plugin_path (),
+ debugger (),
+ *this);
dialog.set_history (m_priv->var_inspector_dialog_history);
if (a_variable_name != "") {
dialog.inspect_variable (a_variable_name);
diff --git a/src/persp/dbgperspective/nmv-var-inspector-dialog.cc b/src/persp/dbgperspective/nmv-var-inspector-dialog.cc
index 0cf4f52..d485f1c 100644
--- a/src/persp/dbgperspective/nmv-var-inspector-dialog.cc
+++ b/src/persp/dbgperspective/nmv-var-inspector-dialog.cc
@@ -63,18 +63,21 @@ class VarInspectorDialog::Priv {
Gtk::Dialog &dialog;
Glib::RefPtr<Gnome::Glade::Xml> glade;
IDebuggerSafePtr debugger;
+ IPerspective &perspective;
Priv ();
public:
Priv (Gtk::Dialog &a_dialog,
const Glib::RefPtr<Gnome::Glade::Xml> &a_glade,
- IDebuggerSafePtr a_debugger) :
+ IDebuggerSafePtr a_debugger,
+ IPerspective &a_perspective) :
var_name_entry (0),
inspect_button (0),
dialog (a_dialog),
glade (a_glade),
- debugger (a_debugger)
+ debugger (a_debugger),
+ perspective (a_perspective)
{
LOG_FUNCTION_SCOPE_NORMAL_DD;
build_dialog ();
@@ -102,7 +105,7 @@ public:
ui_utils::get_widget_from_glade<Gtk::Box> (glade,
"inspectorwidgetbox");
#ifdef WITH_VAROBJS
- var_inspector.reset (new VarInspector2 (debugger));
+ var_inspector.reset (new VarInspector2 (debugger, perspective));
#else
var_inspector.reset (new VarInspector (debugger));
#endif // WITH_VAROBJS
@@ -128,9 +131,6 @@ public:
(*this, &Priv::do_inspect_variable));
}
- //************************
- //<signal handlers>
- //*************************
void do_inspect_variable ()
{
NEMIVER_TRY
@@ -199,6 +199,10 @@ public:
}
}
+ //************************
+ //<signal handlers>
+ //*************************
+
void on_var_name_changed_signal ()
{
LOG_FUNCTION_SCOPE_NORMAL_DD;
@@ -231,14 +235,17 @@ public:
};//end class VarInspectorDialog::Priv
VarInspectorDialog::VarInspectorDialog (const UString &a_root_path,
- IDebuggerSafePtr &a_debugger) :
+ IDebuggerSafePtr &a_debugger,
+ IPerspective &a_perspective) :
Dialog (a_root_path,
"varinspectordialog.glade",
"varinspectordialog")
{
LOG_FUNCTION_SCOPE_NORMAL_DD;
m_priv.reset
- (new VarInspectorDialog::Priv (widget (), glade (), a_debugger));
+ (new VarInspectorDialog::Priv (widget (),
+ glade (), a_debugger,
+ a_perspective));
THROW_IF_FAIL (m_priv);
}
diff --git a/src/persp/dbgperspective/nmv-var-inspector-dialog.h b/src/persp/dbgperspective/nmv-var-inspector-dialog.h
index 9f18dd8..d02928f 100644
--- a/src/persp/dbgperspective/nmv-var-inspector-dialog.h
+++ b/src/persp/dbgperspective/nmv-var-inspector-dialog.h
@@ -26,6 +26,7 @@
#define __NMV_VAR_INSPECTOR_DIALOG_H__
#include "nmv-dialog.h"
+#include "nmv-i-perspective.h"
#include "nmv-i-debugger.h"
NEMIVER_BEGIN_NAMESPACE (nemiver)
@@ -43,7 +44,8 @@ class VarInspectorDialog : public Dialog {
public:
VarInspectorDialog (const UString &a_resource_root_path,
- IDebuggerSafePtr &a_debugger);
+ IDebuggerSafePtr &a_debugger,
+ IPerspective &a_perspective);
virtual ~VarInspectorDialog ();
UString variable_name () const;
diff --git a/src/persp/dbgperspective/nmv-var-inspector2.cc b/src/persp/dbgperspective/nmv-var-inspector2.cc
index 6f0c61d..9a60813 100644
--- a/src/persp/dbgperspective/nmv-var-inspector2.cc
+++ b/src/persp/dbgperspective/nmv-var-inspector2.cc
@@ -52,10 +52,13 @@ class VarInspector2::Priv : public sigc::trackable {
// Variable that is being inspected
// at a given point in time
IDebugger::VariableSafePtr variable;
+ IPerspective &perspective;
VarsTreeViewSafePtr tree_view;
Glib::RefPtr<Gtk::TreeStore> tree_store;
Gtk::TreeModel::iterator var_row_it;
Gtk::TreeModel::iterator cur_selected_row;
+ Glib::RefPtr<Gtk::ActionGroup> var_inspector_action_group;
+ Gtk::Widget *var_inspector_menu;
void
build_widget ()
@@ -65,6 +68,7 @@ class VarInspector2::Priv : public sigc::trackable {
THROW_IF_FAIL (tree_view);
tree_store = tree_view->get_tree_store ();
THROW_IF_FAIL (tree_store);
+ init_actions ();
}
void
@@ -83,6 +87,9 @@ class VarInspector2::Priv : public sigc::trackable {
tree_view->signal_row_expanded ().connect
(sigc::mem_fun (*this, &Priv::on_tree_view_row_expanded_signal));
+ tree_view->signal_button_press_event ().connect_notify
+ (sigc::mem_fun (this, &Priv::on_button_press_signal));
+
Gtk::CellRenderer *r = tree_view->get_column_cell_renderer
(VarsTreeView::VARIABLE_VALUE_COLUMN_INDEX);
THROW_IF_FAIL (r);
@@ -101,6 +108,39 @@ class VarInspector2::Priv : public sigc::trackable {
tree_store->clear ();
}
+ void init_actions ()
+ {
+ static ui_utils::ActionEntry s_var_inspector_action_entries [] = {
+ {
+ "CopyVariablePathMenuItemAction",
+ Gtk::Stock::COPY,
+ _("_Copy variable name"),
+ _("Copy the variable path expression to the clipboard"),
+ sigc::mem_fun
+ (*this,
+ &Priv::on_variable_path_expr_copy_to_clipboard_action),
+ ui_utils::ActionEntry::DEFAULT,
+ ""
+ }
+ };
+
+ var_inspector_action_group =
+ Gtk::ActionGroup::create ("var-inspector-action-group");
+ var_inspector_action_group->set_sensitive (true);
+ int num_actions =
+ sizeof (s_var_inspector_action_entries)
+ /
+ sizeof (ui_utils::ActionEntry);
+
+ ui_utils::add_action_entries_to_action_group
+ (s_var_inspector_action_entries,
+ num_actions,
+ var_inspector_action_group);
+
+ perspective.get_workbench ().get_ui_manager ()->insert_action_group
+ (var_inspector_action_group);
+ }
+
// If the variable we are inspected was created
// with a backend counterpart (variable objects for GDB),
// instruct the backend to delete its variable counterpart.
@@ -178,6 +218,40 @@ class VarInspector2::Priv : public sigc::trackable {
(this, &VarInspector2::Priv::on_variable_created_signal));
}
+ Gtk::Widget* get_var_inspector_menu ()
+ {
+ LOG_FUNCTION_SCOPE_NORMAL_DD;
+
+ if (!var_inspector_menu) {
+ var_inspector_menu =
+ perspective.load_menu ("varinspectorpopup.xml",
+ "/VarInspectorPopup");
+ THROW_IF_FAIL (var_inspector_menu);
+ }
+ return var_inspector_menu;
+ }
+ void popup_var_inspector_menu (GdkEventButton *a_event)
+ {
+ Gtk::Menu *menu =
+ dynamic_cast<Gtk::Menu*> (get_var_inspector_menu ());
+ THROW_IF_FAIL (menu);
+
+ // only pop up a menu if a row exists at that position
+ Gtk::TreeModel::Path path;
+ Gtk::TreeViewColumn* column = 0;
+ int cell_x = 0, cell_y = 0;
+ THROW_IF_FAIL (tree_view);
+ THROW_IF_FAIL (a_event);
+ if (tree_view->get_path_at_pos (static_cast<int> (a_event->x),
+ static_cast<int> (a_event->y),
+ path,
+ column,
+ cell_x,
+ cell_y)) {
+ menu->popup (a_event->button, a_event->time);
+ }
+ }
+
// ******************
// <signal handlers>
// ******************
@@ -284,6 +358,20 @@ class VarInspector2::Priv : public sigc::trackable {
NEMIVER_CATCH
}
+ void on_button_press_signal (GdkEventButton *a_event)
+ {
+ LOG_FUNCTION_SCOPE_NORMAL_DD;
+
+ NEMIVER_TRY
+
+ // right-clicking should pop up a context menu
+ if ((a_event->type == GDK_BUTTON_PRESS) && (a_event->button == 3)) {
+ popup_var_inspector_menu (a_event);
+ }
+
+ NEMIVER_CATCH
+ }
+
void
on_variable_created_signal (const IDebugger::VariableSafePtr a_var)
{
@@ -329,17 +417,49 @@ class VarInspector2::Priv : public sigc::trackable {
NEMIVER_CATCH
}
+ void on_variable_path_expr_copy_to_clipboard_action ()
+ {
+ LOG_FUNCTION_SCOPE_NORMAL_DD;
+
+ NEMIVER_TRY
+
+ THROW_IF_FAIL (cur_selected_row);
+
+ IDebugger::VariableSafePtr variable =
+ cur_selected_row->get_value
+ (vutil::get_variable_columns ().variable);
+ THROW_IF_FAIL (variable);
+
+ debugger->query_variable_path_expr
+ (variable,
+ sigc::mem_fun (*this, &Priv::on_variable_path_expression_signal));
+
+ NEMIVER_CATCH
+ }
+
+ void on_variable_path_expression_signal
+ (const IDebugger::VariableSafePtr a_var)
+ {
+ NEMIVER_TRY
+
+ Gtk::Clipboard::get ()->set_text (a_var->path_expression ());
+
+ NEMIVER_CATCH
+ }
// ******************
// </signal handlers>
// ******************
public:
- Priv (IDebuggerSafePtr a_debugger) :
+ Priv (IDebuggerSafePtr a_debugger,
+ IPerspective &a_perspective) :
requested_variable (false),
requested_type (false),
expand_variable (false),
- debugger (a_debugger)
+ debugger (a_debugger),
+ perspective (a_perspective),
+ var_inspector_menu (0)
{
build_widget ();
re_init_tree_view ();
@@ -352,9 +472,10 @@ public:
}
};//end class VarInspector2::Priv
-VarInspector2::VarInspector2 (IDebuggerSafePtr a_debugger)
+VarInspector2::VarInspector2 (IDebuggerSafePtr a_debugger,
+ IPerspective &a_perspective)
{
- m_priv.reset (new Priv (a_debugger));
+ m_priv.reset (new Priv (a_debugger, a_perspective));
}
VarInspector2::~VarInspector2 ()
diff --git a/src/persp/dbgperspective/nmv-var-inspector2.h b/src/persp/dbgperspective/nmv-var-inspector2.h
index 49c684a..33dbec3 100644
--- a/src/persp/dbgperspective/nmv-var-inspector2.h
+++ b/src/persp/dbgperspective/nmv-var-inspector2.h
@@ -28,6 +28,7 @@
#include "common/nmv-object.h"
#include "common/nmv-safe-ptr-utils.h"
#include "nmv-i-debugger.h"
+#include "nmv-i-perspective.h"
#ifdef WITH_VAROBJS
@@ -49,7 +50,8 @@ class VarInspector2 : public nemiver::common::Object {
SafePtr<Priv> m_priv;
public:
- VarInspector2 (IDebuggerSafePtr a_debugger);
+ VarInspector2 (IDebuggerSafePtr a_debugger,
+ IPerspective &a_perspective);
virtual ~VarInspector2 ();
Gtk::Widget& widget () const;
void set_variable (IDebugger::VariableSafePtr a_variable,
diff --git a/src/persp/dbgperspective/nmv-watchpoint-dialog.cc b/src/persp/dbgperspective/nmv-watchpoint-dialog.cc
index bc295dd..5ef65b7 100644
--- a/src/persp/dbgperspective/nmv-watchpoint-dialog.cc
+++ b/src/persp/dbgperspective/nmv-watchpoint-dialog.cc
@@ -46,17 +46,20 @@ struct WatchpointDialog::Priv {
Gtk::Button *cancel_button;
SafePtr<VarInspector2> var_inspector;
IDebuggerSafePtr debugger;
+ IPerspective &perspective;
Priv (Gtk::Dialog &a_dialog,
const Glib::RefPtr<Gnome::Glade::Xml> &a_glade,
- IDebuggerSafePtr a_debugger) :
+ IDebuggerSafePtr a_debugger,
+ IPerspective &a_perspective) :
dialog (a_dialog),
glade (a_glade),
expression_entry (0),
inspect_button (0),
read_check_button (0),
write_check_button (0),
- debugger (a_debugger)
+ debugger (a_debugger),
+ perspective (a_perspective)
{
LOG_FUNCTION_SCOPE_NORMAL_DD;
@@ -110,7 +113,7 @@ struct WatchpointDialog::Priv {
"varinspectorbox");
THROW_IF_FAIL (box);
- var_inspector.reset (new VarInspector2 (debugger));
+ var_inspector.reset (new VarInspector2 (debugger, perspective));
THROW_IF_FAIL (var_inspector);
Gtk::ScrolledWindow *scr = Gtk::manage (new Gtk::ScrolledWindow);
@@ -196,7 +199,8 @@ struct WatchpointDialog::Priv {
}; // end struct WatchpointDialog
WatchpointDialog::WatchpointDialog (const UString &a_root_path,
- IDebuggerSafePtr a_debugger) :
+ IDebuggerSafePtr a_debugger,
+ IPerspective &a_perspective) :
Dialog (a_root_path,
"watchpointdialog.glade",
"watchpointdialog")
@@ -204,7 +208,8 @@ WatchpointDialog::WatchpointDialog (const UString &a_root_path,
LOG_FUNCTION_SCOPE_NORMAL_DD;
m_priv.reset (new WatchpointDialog::Priv (widget (),
glade (),
- a_debugger));
+ a_debugger,
+ a_perspective));
}
WatchpointDialog::~WatchpointDialog ()
diff --git a/src/persp/dbgperspective/nmv-watchpoint-dialog.h b/src/persp/dbgperspective/nmv-watchpoint-dialog.h
index 93cbae1..d6915a5 100644
--- a/src/persp/dbgperspective/nmv-watchpoint-dialog.h
+++ b/src/persp/dbgperspective/nmv-watchpoint-dialog.h
@@ -29,6 +29,7 @@
#include "common/nmv-safe-ptr-utils.h"
#include "nmv-dialog.h"
#include "nmv-i-debugger.h"
+#include "nmv-i-perspective.h"
NEMIVER_BEGIN_NAMESPACE (nemiver)
@@ -59,7 +60,8 @@ public:
};
WatchpointDialog (const UString &a_resource_root_path,
- IDebuggerSafePtr a_debugger);
+ IDebuggerSafePtr a_debugger,
+ IPerspective &a_perspective);
virtual ~WatchpointDialog ();
const UString expression () const;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]