[tomboy] Fix loading of notebooks
- From: Stefan Schweizer <sschweiz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tomboy] Fix loading of notebooks
- Date: Fri, 22 Oct 2010 22:39:44 +0000 (UTC)
commit 495ae9009e8725e6bc291adbd19a178fdabfded7
Author: Stefan Schweizer <steve schweizer gmail com>
Date: Fri Oct 22 22:21:13 2010 +0200
Fix loading of notebooks
On mac notebooks were loaded before notes because a mac-specific block
in NotebookApplicationAddin caused NotebookManager's static constructor
to be called too early. We introduced the NotesLoaded event in
NoteManager to better control the initialization of notebooks.
https://bugzilla.gnome.org/show_bug.cgi?id=612992
Tomboy/NoteManager.cs | 5 +++++
Tomboy/Notebooks/NotebookManager.cs | 13 ++++++++++++-
2 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/Tomboy/NoteManager.cs b/Tomboy/NoteManager.cs
index 1895a5f..8c8dc1f 100644
--- a/Tomboy/NoteManager.cs
+++ b/Tomboy/NoteManager.cs
@@ -315,6 +315,7 @@ Ciao!");
protected virtual void LoadNotes ()
{
+ Logger.Debug ("Loading notes");
string [] files = Directory.GetFiles (notes_dir, "*.note");
foreach (string file_path in files) {
@@ -369,6 +370,9 @@ Ciao!");
if (start_note != null)
Preferences.Set (Preferences.START_NOTE_URI, start_note.Uri);
}
+
+ if (NotesLoaded != null)
+ NotesLoaded (this, EventArgs.Empty);
}
void OnExitingEvent (object sender, EventArgs args)
@@ -694,6 +698,7 @@ Ciao!");
public event NoteRenameHandler NoteRenamed;
public event NoteSavedHandler NoteSaved;
public event Action<Note> NoteBufferChanged;
+ public event EventHandler NotesLoaded;
}
public class TrieController
diff --git a/Tomboy/Notebooks/NotebookManager.cs b/Tomboy/Notebooks/NotebookManager.cs
index c1a9514..9c0fb44 100644
--- a/Tomboy/Notebooks/NotebookManager.cs
+++ b/Tomboy/Notebooks/NotebookManager.cs
@@ -51,7 +51,12 @@ namespace Tomboy.Notebooks
// </summary>
notebookMap = new Dictionary<string, Gtk.TreeIter> ();
- LoadNotebooks ();
+ // Load the notebooks now if the notes have already been loaded
+ // or wait for the NotesLoaded event otherwise.
+ if (Tomboy.DefaultNoteManager.Initialized)
+ LoadNotebooks ();
+ else
+ Tomboy.DefaultNoteManager.NotesLoaded += OnNotesLoaded;
}
#endregion // Constructors
@@ -456,11 +461,17 @@ namespace Tomboy.Notebooks
return string.Compare (notebook_a.Name, notebook_b.Name);
}
+ static void OnNotesLoaded(object sender, EventArgs args)
+ {
+ LoadNotebooks ();
+ }
+
/// <summary>
/// Loop through the system tags looking for notebooks
/// </summary>
private static void LoadNotebooks ()
{
+ Logger.Debug ("Loading notebooks");
Gtk.TreeIter iter = Gtk.TreeIter.Zero;
foreach (Tag tag in TagManager.AllTags) {
// Skip over tags that aren't notebooks
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]