[tomboy] Allow notebook renaming by editing rows in treeview (BGO #435734)
- From: Sanford Armstrong <sharm src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tomboy] Allow notebook renaming by editing rows in treeview (BGO #435734)
- Date: Mon, 10 Aug 2009 21:44:32 +0000 (UTC)
commit 56671475898649e0046ee78b5e6445562e152ff5
Author: Sandy Armstrong <sanfordarmstrong gmail com>
Date: Mon Aug 10 14:41:16 2009 -0700
Allow notebook renaming by editing rows in treeview (BGO #435734)
Tomboy/RecentChanges.cs | 30 +++++++++++++++++++++++++++---
1 files changed, 27 insertions(+), 3 deletions(-)
---
diff --git a/Tomboy/RecentChanges.cs b/Tomboy/RecentChanges.cs
index 6803b41..ab95940 100644
--- a/Tomboy/RecentChanges.cs
+++ b/Tomboy/RecentChanges.cs
@@ -257,10 +257,13 @@ namespace Tomboy
column.SetCellDataFunc (renderer,
new Gtk.TreeCellDataFunc (NotebookPixbufCellDataFunc));
- renderer = new Gtk.CellRendererText ();
- column.PackStart (renderer, true);
- column.SetCellDataFunc (renderer,
+ var textRenderer = new Gtk.CellRendererText ();
+ // TODO: Make special notebooks' rows uneditable
+ textRenderer.Editable = true;
+ column.PackStart (textRenderer, true);
+ column.SetCellDataFunc (textRenderer,
new Gtk.TreeCellDataFunc (NotebookTextCellDataFunc));
+ textRenderer.Edited += OnNotebookRowEdited;
notebooksTree.AppendColumn (column);
@@ -677,6 +680,27 @@ namespace Tomboy
args.SelectionData.Text = Catalog.GetString ("Notes");
}
+ void OnNotebookRowEdited (object sender, Gtk.EditedArgs args)
+ {
+ if (Notebooks.NotebookManager.NotebookExists (args.NewText))
+ return;
+ var oldNotebook = GetSelectedNotebook ();
+ if (oldNotebook is Notebooks.SpecialNotebook)
+ return;
+ var newNotebook = Notebooks.NotebookManager.GetOrCreateNotebook (args.NewText);
+ Logger.Debug ("Renaming notebook '{0}' to '{1}'",
+ oldNotebook.Name,
+ args.NewText);
+ foreach (Note note in oldNotebook.Tag.Notes)
+ Notebooks.NotebookManager.MoveNoteToNotebook (note, newNotebook);
+ Notebooks.NotebookManager.DeleteNotebook (oldNotebook);
+ Gtk.TreeIter iter;
+ if (Notebooks.NotebookManager.GetNotebookIter (newNotebook, out iter)) {
+ // TODO: Why doesn't this work?
+ notebooksTree.Selection.SelectIter (iter);
+ }
+ }
+
void OnSelectionChanged (object sender, EventArgs args)
{
List<Note> selected_notes = GetSelectedNotes ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]