[nemiver] Append (not prepend) exprs to call function history



commit 6aaa0b2d765e7d9022b82bbb5fee37717e75ef4f
Author: Dodji Seketeli <dodji redhat com>
Date:   Thu Sep 9 10:29:45 2010 +0200

    Append (not prepend) exprs to call function history
    
    	* src/persp/dbgperspective/nmv-call-function-dialog.cc
    	(CallFunctionDialog::Priv::add_to_history): By default, append
    	expressions to history rather than prepend them.
    	(CallFunctionDialog::Priv::call_expr_history): Rename
    	CallFunctionDialog::Priv::m_call_expr_history into this.
    	(CallFunctionDialog::add_to_history): Append expressions to
    	history, rather than prepend them.
    	(CallFunctionDialog::Priv::on_ok_button_clicked_signal): New
    	signal handler.
    	(CallFunctionDialog::Priv::Priv): Connect
    	CallFunctionDialog::Priv::on_ok_button_clicked_signal to the
    	ok_button clicked signal. Update to the m_call_expr_history ->
    	call_expr_history rename.
    	(CallFunctionDialog::Priv::exists_in_history)
    	(CallFunctionDialog::Priv::clear_history): Update against
    	renaming.
    	(CallFunctionDialog::Priv::get_history): Clear the output parm
    	before appending the history elements to it.
    	* src/persp/dbgperspective/nmv-dbg-perspective.cc
    	(DBGPerspective::call_function): Let the CallFunctionDialog do the
    	history updating work.

 .../dbgperspective/nmv-call-function-dialog.cc     |   44 ++++++++++++-------
 src/persp/dbgperspective/nmv-dbg-perspective.cc    |    8 +---
 .../dbgperspective/nmv-var-inspector-dialog.cc     |    2 +-
 3 files changed, 31 insertions(+), 23 deletions(-)
---
diff --git a/src/persp/dbgperspective/nmv-call-function-dialog.cc b/src/persp/dbgperspective/nmv-call-function-dialog.cc
index 529c4cc..f2ee907 100644
--- a/src/persp/dbgperspective/nmv-call-function-dialog.cc
+++ b/src/persp/dbgperspective/nmv-call-function-dialog.cc
@@ -45,7 +45,7 @@ get_call_expr_history_cols ()
 
 struct CallFunctionDialog::Priv {
     Gtk::ComboBoxEntry *call_expr_entry;
-    Glib::RefPtr<Gtk::ListStore> m_call_expr_history;
+    Glib::RefPtr<Gtk::ListStore> call_expr_history;
     Gtk::Button *ok_button;
     Priv (Gtk::Dialog &a_dialog,
           const Glib::RefPtr<Gtk::Builder> &a_gtkbuilder) :
@@ -59,14 +59,16 @@ struct CallFunctionDialog::Priv {
                                                           "okbutton");
         THROW_IF_FAIL (ok_button);
         ok_button->set_sensitive (false);
+	ok_button->signal_clicked ().connect
+            (sigc::mem_fun (*this, &Priv::on_ok_button_clicked_signal));
 
         call_expr_entry =
             ui_utils::get_widget_from_gtkbuilder<Gtk::ComboBoxEntry>
                                             (a_gtkbuilder, "callexpressionentry");
         THROW_IF_FAIL (call_expr_entry);
-        m_call_expr_history=
+        call_expr_history=
             Gtk::ListStore::create (get_call_expr_history_cols ());
-        call_expr_entry->set_model (m_call_expr_history);
+        call_expr_entry->set_model (call_expr_history);
         call_expr_entry->set_text_column (get_call_expr_history_cols ().expr);
 
         call_expr_entry->signal_changed ().connect
@@ -74,6 +76,15 @@ struct CallFunctionDialog::Priv {
         call_expr_entry->get_entry ()->set_activates_default ();
     }
 
+    void on_ok_button_clicked_signal ()
+    {
+        THROW_IF_FAIL (call_expr_entry);
+
+        add_to_history (call_expr_entry->get_entry ()->get_text (),
+                        /*prepend=*/false,
+                        /*allow_dups=*/false);
+    }
+
     void on_call_expr_entry_changed_signal ()
     {
         NEMIVER_TRY
@@ -95,10 +106,10 @@ struct CallFunctionDialog::Priv {
 
     bool exists_in_history (const UString &a_expr) const
     {
-        THROW_IF_FAIL (m_call_expr_history);
+        THROW_IF_FAIL (call_expr_history);
         Gtk::TreeModel::iterator it;
-        for (it = m_call_expr_history->children ().begin ();
-             it != m_call_expr_history->children ().end ();
+        for (it = call_expr_history->children ().begin ();
+             it != call_expr_history->children ().end ();
              ++it) {
             if ((*it)[get_call_expr_history_cols ().expr] == a_expr) {
                 return true;
@@ -109,33 +120,34 @@ struct CallFunctionDialog::Priv {
 
     void clear_history ()
     {
-        m_call_expr_history->clear ();
+        call_expr_history->clear ();
     }
 
     void add_to_history (const UString &a_expr,
-                         bool a_prepend = true,
+                         bool a_prepend = false,
                          bool allow_dups = true)
     {
-        if (a_expr.empty () // don't append empty expressiosn
+        if (a_expr.empty () // don't append empty expressions
             // don't append an expression if it exists already.
             || (!allow_dups && exists_in_history (a_expr)))
             return;
 
-        THROW_IF_FAIL (m_call_expr_history);
+        THROW_IF_FAIL (call_expr_history);
         Gtk::TreeModel::iterator it;
         if (a_prepend)
-            it = m_call_expr_history->insert
-                                    (m_call_expr_history->children ().begin ());
+            it = call_expr_history->insert
+                                    (call_expr_history->children ().begin ());
         else
-            it = m_call_expr_history->append ();
+            it = call_expr_history->append ();
         (*it)[get_call_expr_history_cols ().expr] = a_expr;
     }
 
     void get_history (std::list<UString> &a_hist) const
     {
         Gtk::TreeModel::iterator it;
-        for (it = m_call_expr_history->children ().begin ();
-             it != m_call_expr_history->children ().end ();
+        a_hist.clear ();
+        for (it = call_expr_history->children ().begin ();
+             it != call_expr_history->children ().end ();
              ++it) {
             Glib::ustring elem = (*it)[get_call_expr_history_cols ().expr];
             a_hist.push_back (elem);
@@ -200,7 +212,7 @@ CallFunctionDialog::add_to_history (const UString &a_expr)
 {
     THROW_IF_FAIL (m_priv);
     m_priv->add_to_history (a_expr,
-                            true /* prepends */,
+                            false /* append */,
                             false /* disallow duplicates */);
 }
 NEMIVER_END_NAMESPACE (nemiver)
diff --git a/src/persp/dbgperspective/nmv-dbg-perspective.cc b/src/persp/dbgperspective/nmv-dbg-perspective.cc
index 95f99d6..bf64279 100644
--- a/src/persp/dbgperspective/nmv-dbg-perspective.cc
+++ b/src/persp/dbgperspective/nmv-dbg-perspective.cc
@@ -7325,18 +7325,14 @@ DBGPerspective::call_function ()
     int result = dialog.run ();
     if (result != Gtk::RESPONSE_OK)
         return;
+
     UString call_expr = dialog.call_expression ();
 
     if (call_expr.empty ())
         return;
 
     // Update our copy of call expression history.
-    list<UString>::iterator from = m_priv->call_expr_history.begin (),
-                            to = m_priv->call_expr_history.end (),
-                            nil = to;
-
-    if (std::find (from, to, call_expr) == nil)
-        m_priv->call_expr_history.push_front (call_expr);
+    dialog.get_history (m_priv->call_expr_history);
 
     // Really execute the function call expression now.
     call_function (call_expr);
diff --git a/src/persp/dbgperspective/nmv-var-inspector-dialog.cc b/src/persp/dbgperspective/nmv-var-inspector-dialog.cc
index 5c53dd5..2993417 100644
--- a/src/persp/dbgperspective/nmv-var-inspector-dialog.cc
+++ b/src/persp/dbgperspective/nmv-var-inspector-dialog.cc
@@ -160,7 +160,7 @@ public:
     }
 
     void add_to_history (const UString &a_expr,
-                         bool a_prepend = true,
+                         bool a_prepend = false,
                          bool a_allow_dups = true)
     {
         if (a_expr.empty () // don't append empty exprs.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]