[tomboy-list] Watching Plugin for Tomboy

Boyd Timothy btimothy at gmail.com
Fri Jan 12 09:53:22 PST 2007


I assume this would work for people using iFolder as well.  They'd have to
manually deal with any conflicts, but at least this is a workable solution.
Good work!

-Boyd

On 1/12/07, José Sánchez Moreno <jose at oxigenow.com> wrote:
>
>  Actually, I have to check unison syncs to indicate what is the newer
> version of the note.
>
> Of course, a approach like conduit is much better.
>
> Regards
>
>
> On vie, 2007-01-12 at 09:15 -0700, Boyd Timothy wrote:
>
> Looks cool!
>
> Like I've said before though, there's still conflicts to deal with.  While
> they might not happen often, what happens if you edit the same note on two
> different machines before Unison has had a chance to synchronize?
>
> -Boyd
>
>  On 1/12/07, *José Sánchez Moreno* <jose at oxigenow.com> wrote:
>
>  Now the plugin works. Detect new files, deleted files and files changed.
>
> I can use unison to sync my notes.
> Thanks for reply my question.
>
> using System;
> using System.IO;
> using System.Collections;
> using System.Runtime.InteropServices;
> using Mono.Unix;
>
> using Tomboy;
>
> public class InotifyPlugin : NotePlugin
> {
> static FileSystemWatcher dir_watcher = null;
> const string GCONF_ENABLED_KEY = "/apps/tomboy/inotify/enable_inotify";
>
> protected override void Initialize ()
> {
> // Inotify code. Monitor changes in .notes files
> if(dir_watcher == null) {
> try {
> Logger.Log("Watching " + Path.GetDirectoryName(Note.FilePath));
> dir_watcher = new FileSystemWatcher (Path.GetDirectoryName(Note.FilePath),
> "*.note");
> dir_watcher.Changed += OnChangedNote;
> dir_watcher.Deleted += OnDeletedNote;
> dir_watcher.Created += OnCreatedNote;
> dir_watcher.EnableRaisingEvents = true;
> } catch (ArgumentException e) {
> Console.WriteLine ("Error creating a FileSystemWatcher {0}", e);
> }
> }
>
> }
>
> void OnCreatedNote(object sender, FileSystemEventArgs args)
> {
> NoteArchiver archiver =  NoteArchiver.Instance;
> NoteData data =  archiver.ReadFile(args.FullPath,  "note://tomboy/" +
> Path.GetFileNameWithoutExtension (args.FullPath));
> Note new_note = Note.Load (args.FullPath, Note.Manager);
> Note.Manager.Notes.Add(new_note);
> }
>
> void OnDeletedNote(object sender, FileSystemEventArgs args)
> {
> foreach (Note note in Note.Manager.Notes) {
> if(args.FullPath == note.FilePath) {
> Note.Manager.Notes.Remove(note);
> note.Delete();
> }
> }
> }
>
> void OnChangedNote (object sender, FileSystemEventArgs args)
> {
> foreach (Note note in Note.Manager.Notes) {
> if(args.FullPath == note.FilePath) {
> NoteArchiver archiver =  NoteArchiver.Instance;
> NoteData modified =  archiver.ReadFile(args.FullPath,  "note://tomboy/" +
> Path.GetFileNameWithoutExtension (args.FullPath));
> note.XmlContent = modified.Text;
> note.Title = modified.Title;
> }
> }
> }
>
> protected override void Shutdown ()
> {
> //Preferences.SettingChanged -= OnSettingChanged;
> }
>
> protected override void OnNoteOpened ()
> {
> // Do nothing.
> }
> }
>   --
> José Sánchez Moreno <jose at oxigenow.com>
>
>
> _______________________________________________
> tomboy-list mailing list
> tomboy-list at lists.beatniksoftware.com
>
> http://lists.beatniksoftware.com/listinfo.cgi/tomboy-list-beatniksoftware.com
>
>
>
>
>   --
> José Sánchez Moreno <jose at oxigenow.com>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.beatniksoftware.com/pipermail/tomboy-list-beatniksoftware.com/attachments/20070112/5f91835d/attachment.htm 


More information about the tomboy-list mailing list