[nemiver] Variable popup now uses a VarInspector2
- From: Dodji Seketeli <dodji src gnome org>
- To: svn-commits-list gnome org
- Subject: [nemiver] Variable popup now uses a VarInspector2
- Date: Sun, 31 May 2009 16:40:57 -0400 (EDT)
commit 7029473c46f7c67b5f1718e87b6eb5e08de8116a
Author: Dodji Seketeli <dodji redhat com>
Date: Sun May 31 21:15:52 2009 +0200
Variable popup now uses a VarInspector2
* src/uicommon/nmv-popup-tip.cc:
(PopupTip::Priv::Priv): Set a notebook in the popuptip window.
The notebook contains a label for when the tip has to display text, and a
custom widget for when the tip has to display a custom widget.
Don't use the (ugly) gtk tooltip style.
(PopupTip:PopupTip): Don't set any text by defauilt.
(PopupTip::text): To show text, just display the notebook tab that
contains the text label.
(PopupTip::add_child): New method to set a custom widget.
* src/persp/dbgperspective/nmv-dbg-perspective.cc:
(DBGPerspective::on_variable_created_for_tooltip_signal,
DBGPerspective::hide_popup_tip): New
methods.
(DBGPerspective::try_to_request_show_variable_value_at_position):
Show the popup tip exactly at the position of the cursor.
If varobjs support is on, create a variable object backed variable,
hand it to a VarInspector2 and pack the inspector into a popup tip.
(DBGPerspective::restart_mouse_immobile_timer,
DBGPerspective::on_button_pressed_in_source_view_signal,
DBGPerspective::stop_mouse_immobile_timer): Only hide the popup
tip when the mouse moves out of it.
---
src/persp/dbgperspective/nmv-dbg-perspective.cc | 92 +++++++++++++++-
src/uicommon/nmv-popup-tip.cc | 130 ++++++++++++++---------
src/uicommon/nmv-popup-tip.h | 1 +
3 files changed, 168 insertions(+), 55 deletions(-)
diff --git a/src/persp/dbgperspective/nmv-dbg-perspective.cc b/src/persp/dbgperspective/nmv-dbg-perspective.cc
index ec9ddd1..4ada7b9 100644
--- a/src/persp/dbgperspective/nmv-dbg-perspective.cc
+++ b/src/persp/dbgperspective/nmv-dbg-perspective.cc
@@ -77,6 +77,7 @@
#include "nmv-spinner-tool-item.h"
#ifdef WITH_VAROBJS
#include "nmv-local-vars-inspector2.h"
+#include "nmv-var-inspector2.h"
#else
#include "nmv-local-vars-inspector.h"
#endif
@@ -387,6 +388,12 @@ private:
(const UString &a_var_name,
const IDebugger::VariableSafePtr &a_var,
const UString &a_cooker);
+#ifdef WITH_VAROBJS
+
+ void on_variable_created_for_tooltip_signal
+ (const IDebugger::VariableSafePtr);
+
+#endif // WITH_VAROBJS
bool on_file_content_changed (const UString &a_path);
void on_notebook_tabs_reordered(Gtk::Widget* a_page, guint a_page_num);
@@ -443,9 +450,15 @@ private:
void try_to_request_show_variable_value_at_position (int a_x, int a_y);
void show_underline_tip_at_position (int a_x, int a_y,
const UString &a_text);
+#ifdef WITH_VAROBJS
+ void show_underline_tip_at_position (int a_x, int a_y,
+ IDebugger::VariableSafePtr a_var);
+#endif // WITH_VAROBJS
+
void restart_mouse_immobile_timer ();
void stop_mouse_immobile_timer ();
PopupTip& get_popup_tip ();
+ void hide_popup_tip ();
FindTextDialog& get_find_text_dialog ();
public:
@@ -866,6 +879,9 @@ struct DBGPerspective::Priv {
//<variable value popup tip related data>
//****************************************
SafePtr<PopupTip> popup_tip;
+#ifdef WITH_VAROBJS
+ SafePtr<VarInspector2> popup_var_inspector;
+#endif
bool in_show_var_value_at_pos_transaction;
UString var_to_popup;
int var_popup_tip_x;
@@ -1755,7 +1771,7 @@ DBGPerspective::on_button_pressed_in_source_view_signal
NEMIVER_TRY
if (get_popup_tip ().is_visible ()) {
- get_popup_tip ().hide ();
+ hide_popup_tip ();
}
if (a_event->type != GDK_BUTTON_PRESS) {
@@ -2433,6 +2449,26 @@ DBGPerspective::on_debugger_variable_value_signal
NEMIVER_CATCH
}
+#ifdef WITH_VAROBJS
+void
+DBGPerspective::on_variable_created_for_tooltip_signal
+ (const IDebugger::VariableSafePtr a_var)
+{
+ NEMIVER_TRY
+
+ if (m_priv->in_show_var_value_at_pos_transaction
+ && m_priv->var_to_popup == a_var->name ()) {
+ show_underline_tip_at_position (m_priv->var_popup_tip_x,
+ m_priv->var_popup_tip_y,
+ a_var);
+ m_priv->in_show_var_value_at_pos_transaction = false;
+ m_priv->var_to_popup = "";
+ }
+
+ NEMIVER_CATCH
+}
+#endif // WITH_VAROBJS
+
bool
DBGPerspective::on_file_content_changed (const UString &a_path)
{
@@ -4131,12 +4167,19 @@ DBGPerspective::try_to_request_show_variable_value_at_position (int a_x,
int abs_x=0, abs_y=0;
gdk_window->get_origin (abs_x, abs_y);
abs_x += a_x;
- abs_y += a_y + start_rect.get_height () / 2;
+ abs_y += a_y /*+ start_rect.get_height () / 2*/;
m_priv->in_show_var_value_at_pos_transaction = true;
m_priv->var_popup_tip_x = abs_x;
m_priv->var_popup_tip_y = abs_y;
m_priv->var_to_popup = var_name;
+#ifdef WITH_VAROBJS
+ debugger ()->create_variable
+ (var_name,
+ sigc::mem_fun (*this,
+ &DBGPerspective::on_variable_created_for_tooltip_signal));
+#else
debugger ()->print_variable_value (var_name);
+#endif
}
void
@@ -4152,6 +4195,19 @@ DBGPerspective::show_underline_tip_at_position (int a_x,
get_popup_tip ().show_at_position (a_x, a_y);
}
+#ifdef WITH_VAROBJS
+void
+DBGPerspective::show_underline_tip_at_position
+ (int a_x, int a_y,
+ const IDebugger::VariableSafePtr a_var)
+{
+ LOG_FUNCTION_SCOPE_NORMAL_DD
+ m_priv->popup_var_inspector->set_variable (a_var,
+ true /* expand variable */);
+ get_popup_tip ().show_at_position (a_x, a_y);
+}
+#endif // WITH_VAROBJS
+
void
DBGPerspective::restart_mouse_immobile_timer ()
{
@@ -4166,7 +4222,7 @@ DBGPerspective::restart_mouse_immobile_timer ()
(sigc::mem_fun
(*this, &DBGPerspective::on_mouse_immobile_timer_signal),
1);
- get_popup_tip ().hide ();
+ hide_popup_tip ();
}
void
@@ -4175,7 +4231,7 @@ DBGPerspective::stop_mouse_immobile_timer ()
LOG_FUNCTION_SCOPE_NORMAL_D (DBG_PERSPECTIVE_MOUSE_MOTION_DOMAIN);
THROW_IF_FAIL (m_priv);
m_priv->timeout_source_connection.disconnect ();
- get_popup_tip ().hide ();
+ hide_popup_tip ();
}
PopupTip&
@@ -4185,11 +4241,39 @@ DBGPerspective::get_popup_tip ()
if (!m_priv->popup_tip) {
m_priv->popup_tip.reset (new PopupTip);
+#ifdef WITH_VAROBJS
+ m_priv->popup_var_inspector.reset
+ (new VarInspector2 (debugger (), *this));
+ m_priv->popup_tip->add_child (m_priv->popup_var_inspector->widget ());
+#endif
}
THROW_IF_FAIL (m_priv->popup_tip);
return *m_priv->popup_tip;
}
+/// If the pointer is outside of the popup window,
+/// of the variable popup tip, then hide it.
+void
+DBGPerspective::hide_popup_tip ()
+{
+ if (get_popup_tip ().get_window ()) {
+ int x = 0, y = 0;
+ GdkModifierType state = (GdkModifierType) 0;
+ gdk_window_get_pointer (get_popup_tip ().get_window ()->gobj (),
+ &x, &y, &state);
+ Gdk::Rectangle alloc = get_popup_tip ().get_allocation ();
+ if (x < 0
+ || y < 0
+ || x > alloc.get_width ()
+ || y > alloc.get_height ()) {
+ LOG_DD ("(x,y): (" << (int)x << "," << (int)y << "), "
+ << "(w,h): ("
+ << alloc.get_width () << "," << alloc.get_height () << ")");
+ get_popup_tip ().hide ();
+ }
+ }
+}
+
FindTextDialog&
DBGPerspective::get_find_text_dialog ()
{
diff --git a/src/uicommon/nmv-popup-tip.cc b/src/uicommon/nmv-popup-tip.cc
index 74054d2..f602bc9 100644
--- a/src/uicommon/nmv-popup-tip.cc
+++ b/src/uicommon/nmv-popup-tip.cc
@@ -29,44 +29,56 @@
NEMIVER_BEGIN_NAMESPACE (nemiver)
-class PopupTip::Priv {
- Priv () ;
+class PopupTip::Priv
+{
+ Priv ();
public:
- Gtk::Label *label ;
- sigc::connection expose_event_connection ;
- Gtk::Window &window ;
- int show_position_x ;
- int show_position_y ;
+
+ Gtk::Window &window;
+ Gtk::Notebook *notebook;
+ Gtk::Label *label;
+ sigc::connection expose_event_connection;
+ int show_position_x;
+ int show_position_y;
+ int label_index;
+ int custom_widget_index;
Priv (Gtk::Window &a_window) :
- label (0),
window (a_window),
+ label (0),
show_position_x (0),
- show_position_y (0)
+ show_position_y (0),
+ label_index (-1),
+ custom_widget_index (-1)
{
- window.hide () ;
- window.set_name ("gtk-tooltips");
- window.set_resizable (false) ;
- window.set_app_paintable (true) ;
- window.set_border_width (4) ;
- label = Gtk::manage (new Gtk::Label) ;
- label->set_line_wrap (true) ;
- label->set_alignment (0.5, 0.5) ;
- label->show () ;
- window.add (*label) ;
+ window.hide ();
+ // Un-comment this to get tooltip specific colors for the window
+ // window.set_name ("gtk-tooltips");
+ window.set_resizable (false);
+ window.set_app_paintable (true);
+ window.set_border_width (4);
+ notebook = Gtk::manage (new Gtk::Notebook);
+ notebook->set_show_tabs (false);
+ notebook->show ();
+ window.add (*notebook);
+ label = Gtk::manage (new Gtk::Label);
+ label->set_line_wrap (true);
+ label->set_alignment (0.5, 0.5);
+ label->show ();
+ label_index = notebook->append_page (*label);
expose_event_connection = window.signal_expose_event ().connect
(sigc::mem_fun (*this,
- &Priv::on_expose_event_signal)) ;
+ &Priv::on_expose_event_signal));
- window.ensure_style () ;
+ window.ensure_style ();
}
void paint_window ()
{
- Gtk::Requisition req = window.size_request () ;
- Gdk::Rectangle zero_rect ;
- THROW_IF_FAIL (window.get_style ()) ;
+ Gtk::Requisition req = window.size_request ();
+ Gdk::Rectangle zero_rect;
+ THROW_IF_FAIL (window.get_style ());
window.get_style ()->paint_flat_box (window.get_window (),
Gtk::STATE_NORMAL,
Gtk::SHADOW_OUT,
@@ -79,86 +91,102 @@ public:
req.height);
}
- bool on_expose_event_signal (GdkEventExpose *a_event)
+ bool
+ on_expose_event_signal (GdkEventExpose *a_event)
{
NEMIVER_TRY
if (a_event) {}
- LOG_FUNCTION_SCOPE_NORMAL_DD ;
- paint_window () ;
+ LOG_FUNCTION_SCOPE_NORMAL_DD;
+ paint_window ();
NEMIVER_CATCH
- return false ;
+ return false;
}
};//end PopupTip
PopupTip::PopupTip (const UString &a_text) :
Gtk::Window (Gtk::WINDOW_POPUP)
{
- LOG_FUNCTION_SCOPE_NORMAL_DD ;
+ LOG_FUNCTION_SCOPE_NORMAL_DD;
m_priv.reset (new PopupTip::Priv (*this));
- text (a_text) ;
+ if (!a_text.empty ())
+ text (a_text);
}
PopupTip::~PopupTip ()
{
- LOG_FUNCTION_SCOPE_NORMAL_DD ;
+ LOG_FUNCTION_SCOPE_NORMAL_DD;
}
void
PopupTip::text (const UString &a_text)
{
- LOG_FUNCTION_SCOPE_NORMAL_DD ;
- THROW_IF_FAIL (m_priv) ;
- THROW_IF_FAIL (m_priv->label) ;
+ LOG_FUNCTION_SCOPE_NORMAL_DD;
+ THROW_IF_FAIL (m_priv);
+ THROW_IF_FAIL (m_priv->label);
if (a_text != "" ) {
if (a_text.get_number_of_lines () > 1) {
- m_priv->label->set_single_line_mode (false) ;
+ m_priv->label->set_single_line_mode (false);
} else {
- m_priv->label->set_single_line_mode (true) ;
+ m_priv->label->set_single_line_mode (true);
}
}
- m_priv->label->set_text (a_text) ;
+ m_priv->label->set_text (a_text);
+ m_priv->notebook->set_current_page (m_priv->label_index);
}
UString
PopupTip::text () const
{
- THROW_IF_FAIL (m_priv) ;
- THROW_IF_FAIL (m_priv->label) ;
- return m_priv->label->get_text () ;
+ THROW_IF_FAIL (m_priv);
+ THROW_IF_FAIL (m_priv->label);
+ return m_priv->label->get_text ();
+}
+
+void
+PopupTip::add_child (Gtk::Widget &a_widget)
+{
+ THROW_IF_FAIL (m_priv);
+ if (m_priv->custom_widget_index >= 0) {
+ m_priv->notebook->remove_page (m_priv->custom_widget_index);
+ }
+ a_widget.show_all ();
+ m_priv->custom_widget_index =
+ m_priv->notebook->append_page (a_widget);
+ m_priv->notebook->set_current_page (m_priv->custom_widget_index);
}
void
PopupTip::set_show_position (int a_x, int a_y)
{
- LOG_FUNCTION_SCOPE_NORMAL_DD ;
- m_priv->show_position_x = a_x ;
- m_priv->show_position_y = a_y ;
+ LOG_FUNCTION_SCOPE_NORMAL_DD;
+ m_priv->show_position_x = a_x;
+ m_priv->show_position_y = a_y;
}
void
PopupTip::show ()
{
- THROW_IF_FAIL (m_priv) ;
- move (m_priv->show_position_x, m_priv->show_position_y) ;
- Gtk::Window::show () ;
+ THROW_IF_FAIL (m_priv);
+ move (m_priv->show_position_x, m_priv->show_position_y);
+ Gtk::Window::show ();
}
void
PopupTip::show_all ()
{
- THROW_IF_FAIL (m_priv) ;
- move (m_priv->show_position_x, m_priv->show_position_y) ;
- Gtk::Window::show_all () ;
+ THROW_IF_FAIL (m_priv);
+ move (m_priv->show_position_x, m_priv->show_position_y);
+ Gtk::Window::show_all ();
}
void
PopupTip::show_at_position (int a_x, int a_y)
{
- set_show_position (a_x, a_y) ;
- show () ;
+ set_show_position (a_x, a_y);
+ show_all ();
}
NEMIVER_END_NAMESPACE (nemiver)
diff --git a/src/uicommon/nmv-popup-tip.h b/src/uicommon/nmv-popup-tip.h
index a751be9..3e744d5 100644
--- a/src/uicommon/nmv-popup-tip.h
+++ b/src/uicommon/nmv-popup-tip.h
@@ -48,6 +48,7 @@ public:
virtual ~PopupTip ();
void text (const UString &) ;
UString text () const ;
+ void add_child (Gtk::Widget &a_widget);
void set_show_position (int a_x, int a_y) ;
void show () ;
void show_all () ;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]