nemiver r977 - in trunk: . src/persp/dbgperspective src/persp/dbgperspective/glade
- From: dodji svn gnome org
- To: svn-commits-list gnome org
- Subject: nemiver r977 - in trunk: . src/persp/dbgperspective src/persp/dbgperspective/glade
- Date: Mon, 2 Feb 2009 00:42:18 +0000 (UTC)
Author: dodji
Date: Mon Feb 2 00:42:17 2009
New Revision: 977
URL: http://svn.gnome.org/viewvc/nemiver?rev=977&view=rev
Log:
Fix 568821 - "Call function" dialog should remember history
2009-02-02 Dodji Seketeli <dodji redhat com>
* src/persp/dbgperspective/nmv-call-function-dialog.cc:
(CallFunctionDialog::Priv::Priv): Use and initialize a
Gtk::ComboBoxEntry instead of a Gtk::Entry.
Store the history in a Gtk::ListStore.
(CallFunctionDialog::Priv::exists_in_history): New entry point.
(CallFunctionDialog::Priv::clear_history): Likewise.
(CallFunctionDialog::Priv::add_to_history): Likewise.
(CallFunctionDialog::Priv::get_history): Likewise.
(CallFunctionDialog::set_history): Likewise.
(CallFunctionDialog::get_history): Likewise.
(CallFunctionDialog::add_to_history): Likewise.
(CallFunctionDialog::call_expression): Add the call expression
To history.
* src/persp/dbgperspective/nmv-dbg-perspective.cc:
(DBGPerspective::call_function): Feed the CallFunctionDialog
instance with call expression history, and update our own copy
of that history before destroying the dialog.
Modified:
trunk/ChangeLog
trunk/src/persp/dbgperspective/glade/callfunctiondialog.glade
trunk/src/persp/dbgperspective/nmv-call-function-dialog.cc
trunk/src/persp/dbgperspective/nmv-call-function-dialog.h
trunk/src/persp/dbgperspective/nmv-dbg-perspective.cc
Modified: trunk/src/persp/dbgperspective/glade/callfunctiondialog.glade
==============================================================================
--- trunk/src/persp/dbgperspective/glade/callfunctiondialog.glade (original)
+++ trunk/src/persp/dbgperspective/glade/callfunctiondialog.glade Mon Feb 2 00:42:17 2009
@@ -1,129 +1,90 @@
-<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
-<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
-
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--*- mode: xml -*-->
<glade-interface>
-
-<widget class="GtkDialog" id="callfunctiondialog">
- <property name="border_width">5</property>
- <property name="title" translatable="yes">Call Function</property>
- <property name="type">GTK_WINDOW_TOPLEVEL</property>
- <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
- <property name="modal">True</property>
- <property name="default_width">300</property>
- <property name="resizable">True</property>
- <property name="destroy_with_parent">False</property>
- <property name="decorated">True</property>
- <property name="skip_taskbar_hint">False</property>
- <property name="skip_pager_hint">False</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
- <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
- <property name="focus_on_map">True</property>
- <property name="urgency_hint">False</property>
- <property name="has_separator">False</property>
-
- <child internal-child="vbox">
- <widget class="GtkVBox" id="dialog-vbox1">
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">2</property>
-
- <child internal-child="action_area">
- <widget class="GtkHButtonBox" id="dialog-action_area1">
- <property name="visible">True</property>
- <property name="layout_style">GTK_BUTTONBOX_END</property>
-
- <child>
- <widget class="GtkButton" id="cancelbutton">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-cancel</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="response_id">-6</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkButton" id="okbutton">
- <property name="visible">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="label">gtk-ok</property>
- <property name="use_stock">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="response_id">-5</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">GTK_PACK_END</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkVBox" id="vbox1">
- <property name="border_width">6</property>
- <property name="visible">True</property>
- <property name="homogeneous">False</property>
- <property name="spacing">6</property>
-
- <child>
- <widget class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="label" translatable="yes"><b>Call a function:</b></property>
- <property name="use_underline">False</property>
- <property name="use_markup">True</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <widget class="GtkEntry" id="callexpressionentry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">True</property>
- <property name="visibility">True</property>
- <property name="max_length">0</property>
- <property name="text" translatable="yes"></property>
- <property name="has_frame">True</property>
- <property name="invisible_char">â</property>
- <property name="activates_default">True</property>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="padding">0</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- </widget>
- </child>
-</widget>
-
+ <widget class="GtkDialog" id="callfunctiondialog">
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">Call Function</property>
+ <property name="modal">True</property>
+ <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
+ <property name="default_width">300</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="has_separator">False</property>
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox1">
+ <property name="visible">True</property>
+ <property name="spacing">2</property>
+ <child>
+ <widget class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="border_width">6</property>
+ <property name="spacing">6</property>
+ <child>
+ <widget class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes"><b>Call a function:</b></property>
+ <property name="use_markup">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkComboBoxEntry" id="callexpressionentry">
+ <property name="visible">True</property>
+ <child internal-child="entry">
+ <widget class="GtkEntry" id="comboboxentry-entry1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="dialog-action_area1">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+ <child>
+ <widget class="GtkButton" id="cancelbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-cancel</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">-6</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkButton" id="okbutton">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="label">gtk-ok</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">-5</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
</glade-interface>
Modified: trunk/src/persp/dbgperspective/nmv-call-function-dialog.cc
==============================================================================
--- trunk/src/persp/dbgperspective/nmv-call-function-dialog.cc (original)
+++ trunk/src/persp/dbgperspective/nmv-call-function-dialog.cc Mon Feb 2 00:42:17 2009
@@ -32,8 +32,21 @@
NEMIVER_BEGIN_NAMESPACE (nemiver)
+struct CallExprHistoryCols : public Gtk::TreeModel::ColumnRecord {
+ Gtk::TreeModelColumn<Glib::ustring> expr;
+ CallExprHistoryCols () { add (expr); }
+};
+
+static CallExprHistoryCols&
+get_call_expr_history_cols ()
+{
+ static CallExprHistoryCols cols;
+ return cols;
+}
+
struct CallFunctionDialog::Priv {
- Gtk::Entry *call_expr_entry;
+ Gtk::ComboBoxEntry *call_expr_entry;
+ Glib::RefPtr<Gtk::ListStore> m_call_expr_history;
Gtk::Button *ok_button;
Priv (Gtk::Dialog &a_dialog,
const Glib::RefPtr<Gnome::Glade::Xml> &a_glade) :
@@ -41,6 +54,7 @@
ok_button (0)
{
a_dialog.set_default_response (Gtk::RESPONSE_OK);
+
ok_button =
ui_utils::get_widget_from_glade<Gtk::Button> (a_glade,
"okbutton");
@@ -48,12 +62,17 @@
ok_button->set_sensitive (false);
call_expr_entry =
- ui_utils::get_widget_from_glade<Gtk::Entry>
+ ui_utils::get_widget_from_glade<Gtk::ComboBoxEntry>
(a_glade, "callexpressionentry");
THROW_IF_FAIL (call_expr_entry);
+ m_call_expr_history=
+ Gtk::ListStore::create (get_call_expr_history_cols ());
+ call_expr_entry->set_model (m_call_expr_history);
+ call_expr_entry->set_text_column (get_call_expr_history_cols ().expr);
+
call_expr_entry->signal_changed ().connect
(sigc::mem_fun (*this, &Priv::on_call_expr_entry_changed_signal));
- call_expr_entry->set_activates_default ();
+ call_expr_entry->get_entry ()->set_activates_default ();
}
void on_call_expr_entry_changed_signal ()
@@ -68,12 +87,61 @@
THROW_IF_FAIL (call_expr_entry);
THROW_IF_FAIL (ok_button);
- if (call_expr_entry->get_text ().empty ()) {
+ if (call_expr_entry->get_entry ()->get_text ().empty ()) {
ok_button->set_sensitive (false);
} else {
ok_button->set_sensitive (true);
}
}
+
+ bool exists_in_history (const UString &a_expr) const
+ {
+ THROW_IF_FAIL (m_call_expr_history);
+ Gtk::TreeModel::iterator it;
+ for (it = m_call_expr_history->children ().begin ();
+ it != m_call_expr_history->children ().end ();
+ ++it) {
+ if ((*it)[get_call_expr_history_cols ().expr] == a_expr) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ void clear_history ()
+ {
+ m_call_expr_history->clear ();
+ }
+
+ void add_to_history (const UString &a_expr,
+ bool a_prepend = true,
+ bool allow_dups = true)
+ {
+ if (a_expr.empty () // don't append empty expressiosn
+ // don't append an expression if it exists already.
+ || (!allow_dups && exists_in_history (a_expr)))
+ return;
+
+ THROW_IF_FAIL (m_call_expr_history);
+ Gtk::TreeModel::iterator it;
+ if (a_prepend)
+ it = m_call_expr_history->insert
+ (m_call_expr_history->children ().begin ());
+ else
+ it = m_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 ();
+ ++it) {
+ Glib::ustring elem = (*it)[get_call_expr_history_cols ().expr];
+ a_hist.push_back (elem);
+ }
+ }
};//end struct CallFunctionDialog::Priv
CallFunctionDialog::CallFunctionDialog (const UString &a_root_path):
@@ -92,17 +160,49 @@
THROW_IF_FAIL (m_priv);
THROW_IF_FAIL (m_priv->call_expr_entry);
- return m_priv->call_expr_entry->get_text ();
+ return m_priv->call_expr_entry->get_active_text ();
}
void
-CallFunctionDialog::call_expressoin (const UString &a_expr)
+CallFunctionDialog::call_expression (const UString &a_expr)
{
+ if (a_expr.empty ())
+ return;
+
THROW_IF_FAIL (m_priv);
THROW_IF_FAIL (m_priv->call_expr_entry);
- m_priv->call_expr_entry->set_text (a_expr);
+ m_priv->call_expr_entry->get_entry ()->set_text (a_expr);
+ add_to_history (a_expr);
+}
+
+void
+CallFunctionDialog::set_history (const std::list<UString> &a_hist)
+{
+ THROW_IF_FAIL (m_priv);
+
+ m_priv->clear_history ();
+
+ list<UString>::const_iterator it;
+ for (it = a_hist.begin (); it != a_hist.end (); ++it) {
+ m_priv->add_to_history (*it, false /*append*/);
+ }
}
+void
+CallFunctionDialog::get_history (std::list<UString> &a_hist) const
+{
+ THROW_IF_FAIL (m_priv);
+ m_priv->get_history (a_hist);
+}
+
+void
+CallFunctionDialog::add_to_history (const UString &a_expr)
+{
+ THROW_IF_FAIL (m_priv);
+ m_priv->add_to_history (a_expr,
+ true /* prepends */,
+ false /* disallow duplicates */);
+}
NEMIVER_END_NAMESPACE (nemiver)
Modified: trunk/src/persp/dbgperspective/nmv-call-function-dialog.h
==============================================================================
--- trunk/src/persp/dbgperspective/nmv-call-function-dialog.h (original)
+++ trunk/src/persp/dbgperspective/nmv-call-function-dialog.h Mon Feb 2 00:42:17 2009
@@ -25,17 +25,14 @@
#ifndef __NEMIVER_CALL_FUNCTION_DIALOG_H__
#define __NEMIVER_CALL_FUNCTION_DIALOG_H__
+#include <list>
#include "common/nmv-safe-ptr-utils.h"
+#include "common/nmv-ustring.h"
#include "nmv-dialog.h"
NEMIVER_BEGIN_NAMESPACE (nemiver)
-namespace common {
-class UString;
-}
-
-using nemiver::common::UString;
using nemiver::common::SafePtr;
class CallFunctionDialog : public Dialog {
@@ -48,7 +45,10 @@
virtual ~CallFunctionDialog ();
UString call_expression () const;
- void call_expressoin (const UString &a_expr);
+ void call_expression (const UString &a_expr);
+ void set_history (const std::list<UString> &);
+ void get_history (std::list<UString> &) const;
+ void add_to_history (const UString &a_expr);
};//end class CallFunctionDialog
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 Mon Feb 2 00:42:17 2009
@@ -849,6 +849,8 @@
//find text dialog
FindTextDialogSafePtr find_text_dialog;
+ list<UString> call_expr_history;
+
Priv () :
initialized (false),
@@ -5827,14 +5829,26 @@
void
DBGPerspective::call_function ()
{
+ THROW_IF_FAIL (m_priv);
+
CallFunctionDialog dialog (plugin_path ());
+ // Fill the dialog with the "function call" expression history.
+ if (!m_priv->call_expr_history.empty ())
+ dialog.set_history (m_priv->call_expr_history);
+
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.
+ m_priv->call_expr_history.push_front (call_expr);
+
+ // Really execute the function call expression now.
call_function (call_expr);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]