[nemiver] 543488 Support renaming of sessions
- From: Fabien Parent <fparent src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nemiver] 543488 Support renaming of sessions
- Date: Fri, 9 Dec 2011 14:26:33 +0000 (UTC)
commit 9fa95815f87243e460dd616cc24fdff64754b422
Author: Fabien Parent <parent f gmail com>
Date: Wed Oct 19 16:42:44 2011 +0200
543488 Support renaming of sessions
* src/persp/dbgperspective/nmv-dbg-perspective.cc
(DBGPerspective::record_and_save_session): Restore the custom user
defined name of the session when updating a previous session
* src/persp/dbgperspective/nmv-saved-sessions-dialog.cc
(SavedSessionsDialog::Priv::Priv): Take the session manager as parameter
(SavedSessionsDialog::Priv::init): Add a custom cell renderer for
the session name column and display the custom session name is present.
(SavedSessionsDialog::Priv::session_name_cell_data_func): New API
(SavedSessionsDialog::Priv::on_session_name_edited): New API
(SavedSessionsDialog::SavedSessionsDialog): The session manager is given
to the constructor of Priv instead of the method Priv::init.
src/persp/dbgperspective/nmv-dbg-perspective.cc | 10 +++
.../dbgperspective/nmv-saved-sessions-dialog.cc | 72 +++++++++++++++++---
2 files changed, 73 insertions(+), 9 deletions(-)
---
diff --git a/src/persp/dbgperspective/nmv-dbg-perspective.cc b/src/persp/dbgperspective/nmv-dbg-perspective.cc
index 7f00a2d..54c6544 100644
--- a/src/persp/dbgperspective/nmv-dbg-perspective.cc
+++ b/src/persp/dbgperspective/nmv-dbg-perspective.cc
@@ -119,6 +119,7 @@ const char *BREAKPOINTS_VIEW_TITLE = _("Breakpoints");
const char *REGISTERS_VIEW_TITLE = _("Registers");
const char *MEMORY_VIEW_TITLE = _("Memory");
+const char *CAPTION_SESSION_NAME = "captionname";
const char *SESSION_NAME = "sessionname";
const char *PROGRAM_NAME = "programname";
const char *PROGRAM_ARGS = "programarguments";
@@ -4958,6 +4959,11 @@ DBGPerspective::record_and_save_session (ISessMgr::Session &a_session)
if (session_name == "") {return;}
+ UString caption_session_name;
+ if (a_session.properties ().count (CAPTION_SESSION_NAME)) {
+ caption_session_name = a_session.properties ()[CAPTION_SESSION_NAME];
+ }
+
if (a_session.session_id ()) {
session_manager ().clear_session (a_session.session_id ());
LOG_DD ("cleared current session: "
@@ -4967,6 +4973,9 @@ DBGPerspective::record_and_save_session (ISessMgr::Session &a_session)
UString today;
dateutils::get_current_datetime (today);
session_name += "-" + today;
+ if (caption_session_name.empty ()) {
+ caption_session_name = session_name;
+ }
UString prog_args = UString::join (m_priv->prog_args,
PROG_ARG_SEPARATOR);
a_session.properties ().clear ();
@@ -4976,6 +4985,7 @@ DBGPerspective::record_and_save_session (ISessMgr::Session &a_session)
a_session.properties ()[PROGRAM_CWD] = m_priv->prog_cwd;
a_session.properties ()[REMOTE_TARGET] = m_priv->remote_target;
a_session.properties ()[SOLIB_PREFIX] = m_priv->solib_prefix;
+ a_session.properties ()[CAPTION_SESSION_NAME] = caption_session_name;
GTimeVal timeval;
g_get_current_time (&timeval);
diff --git a/src/persp/dbgperspective/nmv-saved-sessions-dialog.cc b/src/persp/dbgperspective/nmv-saved-sessions-dialog.cc
index dbd81d8..3bb1fdc 100644
--- a/src/persp/dbgperspective/nmv-saved-sessions-dialog.cc
+++ b/src/persp/dbgperspective/nmv-saved-sessions-dialog.cc
@@ -53,24 +53,30 @@ public:
SafePtr<Gtk::TreeView> treeview_sessions;
Gtk::Button *okbutton;
SessionModelColumns session_columns;
+ Gtk::CellRendererText name_column_cell_renderer;
+ Gtk::TreeView::Column name_column;
Glib::RefPtr<Gtk::ListStore> model;
Gtk::Dialog &dialog;
Glib::RefPtr<Gtk::Builder> gtkbuilder;
+ ISessMgr &session_manager;
private:
Priv ();
public:
Priv (Gtk::Dialog &a_dialog,
- const Glib::RefPtr<Gtk::Builder> &a_gtkbuilder) :
+ const Glib::RefPtr<Gtk::Builder> &a_gtkbuilder,
+ ISessMgr &a_session_manager) :
okbutton (0),
+ name_column (_("Session"), name_column_cell_renderer),
model(Gtk::ListStore::create (session_columns)),
dialog (a_dialog),
- gtkbuilder (a_gtkbuilder)
+ gtkbuilder (a_gtkbuilder),
+ session_manager (a_session_manager)
{
}
- void init (ISessMgr *a_session_manager)
+ void init ()
{
okbutton =
ui_utils::get_widget_from_gtkbuilder<Gtk::Button> (gtkbuilder, "okbutton1");
@@ -78,8 +84,7 @@ public:
(ui_utils::get_widget_from_gtkbuilder<Gtk::TreeView>
(gtkbuilder, "treeview_sessions"));
okbutton->set_sensitive (false);
- THROW_IF_FAIL (a_session_manager);
- list<ISessMgr::Session> sessions = a_session_manager->sessions ();
+ list<ISessMgr::Session> sessions = session_manager.sessions ();
THROW_IF_FAIL (model);
for (list<ISessMgr::Session>::iterator iter = sessions.begin();
iter != sessions.end(); ++iter)
@@ -87,14 +92,24 @@ public:
Gtk::TreeModel::iterator treeiter = model->append ();
(*treeiter)[session_columns.id] = iter->session_id ();
(*treeiter)[session_columns.name] =
- iter->properties ()["sessionname"];
+ iter->properties ()["captionname"];
(*treeiter)[session_columns.session] = *iter;
}
THROW_IF_FAIL (treeview_sessions);
treeview_sessions->set_model (model);
treeview_sessions->append_column (_("ID"), session_columns.id);
- treeview_sessions->append_column (_("Session"), session_columns.name);
+ treeview_sessions->append_column (name_column);
+
+ name_column_cell_renderer.property_editable () = true;
+
+ name_column.set_cell_data_func
+ (name_column_cell_renderer, sigc::mem_fun
+ (*this,
+ &SavedSessionsDialog::Priv::session_name_cell_data_func));
+
+ name_column_cell_renderer.signal_edited ().connect (sigc::mem_fun
+ (*this, &SavedSessionsDialog::Priv::on_session_name_edited));
// update the sensitivity of the OK
// button when the selection is changed
@@ -107,6 +122,44 @@ public:
&SavedSessionsDialog::Priv::on_row_activated));
}
+ void
+ session_name_cell_data_func (Gtk::CellRenderer*,
+ const Gtk::TreeModel::iterator &a_iter)
+ {
+ NEMIVER_TRY
+
+ if (a_iter) {
+ UString session_name ((*a_iter)[session_columns.name]);
+ name_column_cell_renderer.property_text () = session_name;
+ }
+
+ NEMIVER_CATCH
+ }
+
+ void
+ on_session_name_edited (const UString &a_path, const UString &a_name)
+ {
+ NEMIVER_TRY
+
+ UString name = a_name;
+ Gtk::TreePath path (a_path);
+ Gtk::TreeModel::iterator iter = model->get_iter (path);
+ if (iter) {
+ ISessMgr::Session session = (*iter)[session_columns.session];
+ if (name.empty ()) {
+ name = session.properties ()["sessionname"];
+ }
+ session.properties ()["captionname"] = name;
+ Transaction &transaction = session_manager.default_transaction ();
+ session_manager.store_session (session, transaction);
+ session_manager.load_sessions ();
+
+ (*iter)[session_columns.name] = name;
+ }
+
+ NEMIVER_CATCH
+ }
+
void on_selection_changed ()
{
THROW_IF_FAIL (okbutton);
@@ -125,9 +178,10 @@ SavedSessionsDialog::SavedSessionsDialog (const UString &a_root_path,
ISessMgr *a_session_manager) :
Dialog(a_root_path, "savedsessionsdialog.ui", "savedsessionsdialog")
{
- m_priv.reset (new Priv (widget (), gtkbuilder ()));
+ THROW_IF_FAIL (a_session_manager);
+ m_priv.reset (new Priv (widget (), gtkbuilder (), *a_session_manager));
THROW_IF_FAIL (m_priv);
- m_priv->init (a_session_manager);
+ m_priv->init ();
}
SavedSessionsDialog::~SavedSessionsDialog ()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]