diff options
author | Manish Sinha <manishsinha.tech@gmail.com> | 2010-11-09 01:14:34 +0530 |
---|---|---|
committer | Manish Sinha <manishsinha.tech@gmail.com> | 2010-11-09 01:14:34 +0530 |
commit | affc359a9b11090aa3bbf39f4db39101ce723973 (patch) | |
tree | 1efa0e8c07732eebd57839b539eda597f0c94ce3 /tomboy/NoteHandler.cs | |
parent | 03037857e54b63628cb4ec692009de17db11474d (diff) |
Added tomboy to top level build script and also made adequate checks
Diffstat (limited to 'tomboy/NoteHandler.cs')
-rw-r--r-- | tomboy/NoteHandler.cs | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/tomboy/NoteHandler.cs b/tomboy/NoteHandler.cs new file mode 100644 index 0000000..5e44a10 --- /dev/null +++ b/tomboy/NoteHandler.cs @@ -0,0 +1,69 @@ +using System; +using Zeitgeist.Datamodel; +using System.Collections.Generic; + +namespace Tomboy.Zeitgeist +{ + public class NoteHandler + { + public NoteHandler(Note note) + { + // Check if the Note has already been processes. + // Whent he note is being processed, event handlers are attached to + if (handledNotes.Contains(note) == false) + { + this._note = note; + + note.Opened += HandleNoteOpened; + if (note.HasWindow) + { + HandleNoteOpened(); + } + } + } + + void HandleNoteOpened (object sender, EventArgs e) + { + HandleNoteOpened(); + } + + void HandleNoteOpened() + { + this._note.Window.Hidden += HandleNoteWindowHidden; + this._note.Window.Shown += HandleNoteWindowShown; + this._note.Renamed += HandleNoteRenamed; + if (this._note.Window.Visible) + { + HandleNoteWindowShown(); + } + } + + void HandleNoteRenamed (Note sender, string old_title) + { + Console.WriteLine("Zg#: Renamed: " + this._note.Title); + ZeitgeistHandler.SendEvent(sender, Interpretation.Instance.EventInterpretation.ModifyEvent); + } + + void HandleNoteWindowShown (object sender, EventArgs e) + { + HandleNoteWindowShown(); + } + + void HandleNoteWindowShown () + { + Console.WriteLine("Zg#: Note window opened: " + this._note.Title); + ZeitgeistHandler.SendEvent(this._note, Interpretation.Instance.EventInterpretation.AccessEvent); + } + + void HandleNoteWindowHidden (object sender, EventArgs e) + { + Console.WriteLine("Zg#: Note window closed: " + this._note.Title); + ZeitgeistHandler.SendEvent(this._note, Interpretation.Instance.EventInterpretation.LeaveEvent); + } + + private Note _note; + + private static List<Note> handledNotes = new List<Note>(); + } +} + |