nemiver r982 - in trunk: . src/persp/dbgperspective
- From: dodji svn gnome org
- To: svn-commits-list gnome org
- Subject: nemiver r982 - in trunk: . src/persp/dbgperspective
- Date: Sat, 14 Feb 2009 14:03:28 +0000 (UTC)
Author: dodji
Date: Sat Feb 14 14:03:27 2009
New Revision: 982
URL: http://svn.gnome.org/viewvc/nemiver?rev=982&view=rev
Log:
Persist the Variable inspector dialog history
* src/persp/dbgperspective/nmv-dbg-perspective.cc:
(DBGPerspective::inspect_variable): Save the history of the variable
inspection dialog, and restaure it whenever a new dialog is
instantiated.
* src/persp/dbgperspective/nmv-var-inspector-dialog.cc:
(get_cols): New entry point to statically create the ListStore columns
only once. There is no need to instantiate those columns each time
a Dialog is instantiated.
(VarInspectorDialog::Priv::exists_in_history): New entry point.
(VarInspectorDialog::Priv::add_to_history): Likewise.
(VarInspectorDialog::Priv::inspect_variable): Reuse the new
VarInspectorDialog::Priv::add_to_history.
(VarInspectorDialog::set_history): New entry point.
(VarInspectorDialog::get_history): Likewise.
* src/persp/dbgperspective/nmv-var-inspector-dialog.h:
(VarInspectorDialog::set_history VarInspectorDialog::get_history):
Declare the new entry points.
Modified:
trunk/ChangeLog
trunk/src/persp/dbgperspective/nmv-dbg-perspective.cc
trunk/src/persp/dbgperspective/nmv-var-inspector-dialog.cc
trunk/src/persp/dbgperspective/nmv-var-inspector-dialog.h
Modified: trunk/src/persp/dbgperspective/nmv-dbg-perspective.cc
==============================================================================
--- trunk/src/persp/dbgperspective/nmv-dbg-perspective.cc (original)
+++ trunk/src/persp/dbgperspective/nmv-dbg-perspective.cc Sat Feb 14 14:03:27 2009
@@ -850,6 +850,7 @@
FindTextDialogSafePtr find_text_dialog;
list<UString> call_expr_history;
+ list<UString> var_inspector_dialog_history;
Priv () :
@@ -5820,10 +5821,13 @@
{
THROW_IF_FAIL (debugger ());
VarInspectorDialog dialog (plugin_path (), debugger ());
+ dialog.set_history (m_priv->var_inspector_dialog_history);
if (a_variable_name != "") {
dialog.inspect_variable (a_variable_name);
}
dialog.run ();
+ m_priv->var_inspector_dialog_history.clear ();
+ dialog.get_history (m_priv->var_inspector_dialog_history);
}
void
Modified: trunk/src/persp/dbgperspective/nmv-var-inspector-dialog.cc
==============================================================================
--- trunk/src/persp/dbgperspective/nmv-var-inspector-dialog.cc (original)
+++ trunk/src/persp/dbgperspective/nmv-var-inspector-dialog.cc Sat Feb 14 14:03:27 2009
@@ -39,11 +39,17 @@
VariableHistoryStoreColumns() { add (varname); }
};
+VariableHistoryStoreColumns&
+get_cols ()
+{
+ static VariableHistoryStoreColumns cols;
+ return cols;
+}
+
class VarInspectorDialog::Priv {
friend class VarInspectorDialog;
Gtk::ComboBoxEntry *var_name_entry;
- Glib::RefPtr<Gtk::ListStore> m_variable_history_store;
- VariableHistoryStoreColumns m_variable_store_columns;
+ Glib::RefPtr<Gtk::ListStore> m_variable_history;
Gtk::Button *inspect_button;
SafePtr<VarInspector2> var_inspector;
Gtk::Dialog &dialog;
@@ -72,12 +78,12 @@
LOG_FUNCTION_SCOPE_NORMAL_DD;
var_name_entry =
- ui_utils::get_widget_from_glade<Gtk::ComboBoxEntry> (glade,
- "variablenameentry");
- m_variable_history_store =
- Gtk::ListStore::create (m_variable_store_columns);
- var_name_entry->set_model (m_variable_history_store);
- var_name_entry->set_text_column (m_variable_store_columns.varname);
+ ui_utils::get_widget_from_glade<Gtk::ComboBoxEntry>
+ (glade, "variablenameentry");
+ m_variable_history =
+ Gtk::ListStore::create (get_cols ());
+ var_name_entry->set_model (m_variable_history);
+ var_name_entry->set_text_column (get_cols ().varname);
inspect_button =
ui_utils::get_widget_from_glade<Gtk::Button> (glade,
@@ -125,29 +131,57 @@
NEMIVER_CATCH
}
- void inspect_variable (const UString& a_varname)
+ void inspect_variable (const UString& a_expr)
{
THROW_IF_FAIL (var_inspector);
- THROW_IF_FAIL (m_variable_history_store);
-
- var_inspector->inspect_variable (a_varname);
-
- // now update the history in the entry combobox
- bool found = false;
- // first check if this variable is already in the history
- Gtk::TreeModel::iterator tree_iter;
- for (tree_iter = m_variable_history_store->children ().begin ();
- tree_iter != m_variable_history_store->children ().end ();
- ++tree_iter) {
- if (a_varname == (*tree_iter)[m_variable_store_columns.varname]) {
- found = true;
- break;
+ THROW_IF_FAIL (m_variable_history);
+ var_inspector->inspect_variable (a_expr);
+ add_to_history (a_expr,
+ false /*append*/,
+ false /*don't allow duplicates*/);
+ }
+
+ bool exists_in_history (const UString &a_expr)
+ {
+ THROW_IF_FAIL (m_variable_history);
+
+ Gtk::TreeModel::iterator it;
+ for (it = m_variable_history->children ().begin ();
+ it != m_variable_history->children ().end ();
+ ++it) {
+ if ((*it)[get_cols ().varname] == a_expr) {
+ return true;
}
}
- if (!found) {
- // if it's not already in the list, add it.
- Gtk::TreeModel::iterator new_iter = m_variable_history_store->append ();
- (*new_iter)[m_variable_store_columns.varname] = a_varname;
+ return false;
+ }
+
+ void add_to_history (const UString &a_expr,
+ bool a_prepend = true,
+ bool a_allow_dups = true)
+ {
+ if (a_expr.empty () // don't append empty exprs.
+ // don't append an expr if it exists already.
+ || (!a_allow_dups && exists_in_history (a_expr)))
+ return;
+ Gtk::TreeModel::iterator it;
+
+ if (a_prepend)
+ it = m_variable_history->insert
+ (m_variable_history->children ().begin ());
+ else
+ it = m_variable_history->append ();
+ (*it)[get_cols ().varname] = a_expr;
+ }
+
+ void get_history (std::list<UString> &a_hist) const
+ {
+ Gtk::TreeModel::iterator it;
+ for (it = m_variable_history->children ().begin ();
+ it != m_variable_history->children ().end ();
+ ++it) {
+ Glib::ustring elem = (*it)[get_cols ().varname];
+ a_hist.push_back (elem);
}
}
@@ -227,5 +261,23 @@
return m_priv->var_inspector->get_variable ();
}
+void
+VarInspectorDialog::set_history (const std::list<UString> &a_hist)
+{
+ THROW_IF_FAIL (m_priv);
+
+ list<UString>::const_iterator it;
+ for (it = a_hist.begin (); it != a_hist.end (); ++it) {
+ m_priv->add_to_history (*it, false /*append*/);
+ }
+}
+
+void
+VarInspectorDialog::get_history (std::list<UString> &a_hist) const
+{
+ THROW_IF_FAIL (m_priv);
+ m_priv->get_history (a_hist);
+}
+
NEMIVER_END_NAMESPACE (nemiver)
Modified: trunk/src/persp/dbgperspective/nmv-var-inspector-dialog.h
==============================================================================
--- trunk/src/persp/dbgperspective/nmv-var-inspector-dialog.h (original)
+++ trunk/src/persp/dbgperspective/nmv-var-inspector-dialog.h Sat Feb 14 14:03:27 2009
@@ -50,6 +50,8 @@
UString variable_name () const;
void inspect_variable (const UString &a_variable_name);
const IDebugger::VariableSafePtr variable () const;
+ void set_history (const std::list<UString> &);
+ void get_history (std::list<UString> &) const;
};//end class VarInspectorDialog
NEMIVER_END_NAMESPACE (nemiver)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]