diff -x .pc -uNr tomboy-1.4.0.orig/configure.in tomboy-1.4.0/configure.in --- tomboy-1.4.0.orig/configure.in 2010-10-18 13:38:54.000000000 +0100 +++ tomboy-1.4.0/configure.in 2010-10-18 13:40:23.000000000 +0100 @@ -206,6 +206,10 @@ gtk-sharp-2.0 >= $GTKSHARP2_MINIMUM_VERSION) AC_SUBST(GTKSHARP_LIBS) +APPINDICATOR_MINIMUM_VERSION=0.0.5 +PKG_CHECK_MODULES(APPINDICATORSHARP, + appindicator-sharp-0.1 >= $APPINDICATOR_MINIMUM_VERSION) +AC_SUBST(APPINDICATORSHARP_LIBS) # # Printing at least needs Mono.Cairo # diff -x .pc -uNr tomboy-1.4.0.orig/po/POTFILES.in tomboy-1.4.0/po/POTFILES.in --- tomboy-1.4.0.orig/po/POTFILES.in 2010-10-18 13:38:54.000000000 +0100 +++ tomboy-1.4.0/po/POTFILES.in 2010-10-18 13:40:23.000000000 +0100 @@ -60,6 +60,7 @@ Tomboy/PreferencesDialog.cs Tomboy/RecentChanges.cs Tomboy/Tomboy.cs +Tomboy/TomboyIndicatorTray.cs Tomboy/Tray.cs Tomboy/Utils.cs Tomboy/Watchers.cs diff -x .pc -uNr tomboy-1.4.0.orig/Tomboy/Makefile.am tomboy-1.4.0/Tomboy/Makefile.am --- tomboy-1.4.0.orig/Tomboy/Makefile.am 2010-10-18 13:38:54.000000000 +0100 +++ tomboy-1.4.0/Tomboy/Makefile.am 2010-10-18 13:40:23.000000000 +0100 @@ -117,6 +117,7 @@ $(srcdir)/Tag.cs \ $(srcdir)/TagButton.cs \ $(srcdir)/TagManager.cs \ + $(srcdir)/TomboyIndicatorTray.cs \ $(srcdir)/Tray.cs \ $(srcdir)/Trie.cs \ $(srcdir)/Undo.cs \ @@ -142,6 +143,7 @@ ASSEMBLIES = \ $(GTKSHARP_LIBS) \ + $(APPINDICATORSHARP_LIBS) \ $(GNOME_LIBS) \ -r:Mono.Posix \ $(DBUS_LIBS) \ diff -x .pc -uNr tomboy-1.4.0.orig/Tomboy/NoteManager.cs tomboy-1.4.0/Tomboy/NoteManager.cs --- tomboy-1.4.0.orig/Tomboy/NoteManager.cs 2010-10-18 13:38:54.000000000 +0100 +++ tomboy-1.4.0/Tomboy/NoteManager.cs 2010-10-18 13:40:23.000000000 +0100 @@ -9,6 +9,7 @@ namespace Tomboy { public delegate void NotesChangedHandler (object sender, Note changed); + public delegate void NotesLoadedHandler (); public class NoteManager { @@ -338,6 +339,9 @@ // Update the trie so addins can access it, if they want. trie_controller.Update (); + if (NotesLoaded != null) + NotesLoaded (); + bool startup_notes_enabled = (bool) Preferences.Get (Preferences.ENABLE_STARTUP_NOTES); @@ -693,6 +697,7 @@ public event NotesChangedHandler NoteAdded; public event NoteRenameHandler NoteRenamed; public event NoteSavedHandler NoteSaved; + public event NotesLoadedHandler NotesLoaded; public event Action NoteBufferChanged; } diff -x .pc -uNr tomboy-1.4.0.orig/Tomboy/RecentChanges.cs tomboy-1.4.0/Tomboy/RecentChanges.cs --- tomboy-1.4.0.orig/Tomboy/RecentChanges.cs 2010-10-18 13:38:54.000000000 +0100 +++ tomboy-1.4.0/Tomboy/RecentChanges.cs 2010-10-18 13:40:23.000000000 +0100 @@ -231,7 +231,8 @@ am ["DeleteNotebookAction"].Activated += OnDeleteNotebook; am ["CloseWindowAction"].Activated += OnCloseWindow; if (Tomboy.TrayIconShowing == false && - (bool) Preferences.Get (Preferences.ENABLE_TRAY_ICON)) + (bool) Preferences.Get (Preferences.ENABLE_TRAY_ICON) && + !TomboyIndicatorTray.IndicatorTrayPresent) am ["CloseWindowAction"].Visible = false; // Allow Escape to close the window as well as W @@ -1013,7 +1014,8 @@ instance = null; #if !MAC if (Tomboy.TrayIconShowing == false && - (bool) Preferences.Get (Preferences.ENABLE_TRAY_ICON)) + (bool) Preferences.Get (Preferences.ENABLE_TRAY_ICON) && + !TomboyIndicatorTray.IndicatorTrayPresent) Tomboy.ActionManager ["QuitTomboyAction"].Activate (); #endif } diff -x .pc -uNr tomboy-1.4.0.orig/Tomboy/Tomboy.cs tomboy-1.4.0/Tomboy/Tomboy.cs --- tomboy-1.4.0.orig/Tomboy/Tomboy.cs 2010-10-18 13:38:54.000000000 +0100 +++ tomboy-1.4.0/Tomboy/Tomboy.cs 2010-10-18 13:40:23.000000000 +0100 @@ -189,11 +189,17 @@ #endif } + static TomboyIndicatorTray indicator; static void StartTrayIcon () { - // Create the tray icon and run the main loop - tray_icon = new TomboyTrayIcon (manager); - tray = tray_icon.Tray; + if (TomboyIndicatorTray.IndicatorTrayPresent) { + indicator = new TomboyIndicatorTray (manager); + } else { + // Create the tray icon and run the main loop + tray_icon = new TomboyTrayIcon (manager); + tray = tray_icon.Tray; + } + StartMainLoop (); } diff -x .pc -uNr tomboy-1.4.0.orig/Tomboy/TomboyIndicatorTray.cs tomboy-1.4.0/Tomboy/TomboyIndicatorTray.cs --- tomboy-1.4.0.orig/Tomboy/TomboyIndicatorTray.cs 1970-01-01 01:00:00.000000000 +0100 +++ tomboy-1.4.0/Tomboy/TomboyIndicatorTray.cs 2010-10-20 19:00:23.000000000 +0100 @@ -0,0 +1,178 @@ +// +// Copyright (C) 2009 GNOME Do +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +using System; +using System.Collections.Generic; +using System.Linq; + +using Mono.Unix; + +using Gnome; +using AppIndicator; + +namespace Tomboy +{ + public class TomboyIndicatorTray + { + public static bool IndicatorTrayPresent { + get { + return true; + } + } + + ApplicationIndicator indicator; + NoteManager manager; + Gtk.Menu menu; + int idle_source = 0; + + public TomboyIndicatorTray (NoteManager manager) + { + this.manager = manager; + indicator = new ApplicationIndicator ("tomboy-notes", "tomboy", Category.ApplicationStatus); + + SetMenuItems (); + indicator.Status = Status.Active; + + manager.NoteDeleted += OnNoteDeleted; + manager.NoteAdded += OnNoteAdded; + manager.NoteRenamed += OnNoteRenamed; + manager.NotesLoaded += OnNotesLoaded; + } + + void OnNoteAdded (object sender, Note added) + { + SetMenuItems (); + } + + void OnNoteDeleted (object sender, Note deleted) + { + SetMenuItems (); + } + + void OnNoteRenamed (Note renamed, string old_title) + { + SetMenuItems (); + } + + void OnNotesLoaded () + { + SetMenuItems (); + } + + void SetMenuItems () + { + if (idle_source == 0) + GLib.Idle.Add(SetMenuItemsIdle); + } + + bool SetMenuItemsIdle () + { + idle_source = 0; + + if (menu != null) { + foreach (Gtk.Widget widget in menu.Children) { + menu.Remove (widget); + widget.Destroy (); + } + } + + menu = new Gtk.Menu (); + + foreach (Gtk.MenuItem item in CurrentMenuItems ()) { + menu.Append (item); + item.Show(); + } + + menu.Show(); + + //if (indicator.Menu == null) + indicator.Menu = menu; + + return false; + } + + Gtk.MenuItem CreateNoteMenuItem(Note n) + { + var item = new Gtk.MenuItem (n.Title); + item.Activated += (o, a) => SetMenuItems (); + item.Activated += (o, a) => n.Window.Present (); + return item; + } + + IEnumerable CurrentMenuItems () + { + Gtk.ImageMenuItem item; + + item = new Gtk.ImageMenuItem (Catalog.GetString ("Create New Note")); + item.Image = new Gtk.Image (Gtk.Stock.New, Gtk.IconSize.Menu); + item.Activated += (o, a) => Tomboy.ActionManager["NewNoteAction"].Activate (); + item.Activated += (o, a) => SetMenuItems (); + yield return item; + + item = new Gtk.ImageMenuItem (Catalog.GetString ("_Search All Notes")); + item.Image = new Gtk.Image (Gtk.Stock.Find, Gtk.IconSize.Menu); + item.Activated += (o, a) => Tomboy.ActionManager["ShowSearchAllNotesAction"].Activate (); + yield return item; + + yield return new Gtk.SeparatorMenuItem (); + + if (manager != null && manager.Notes != null) { + var menuItems = manager.Notes + .Where (n => !n.IsSpecial) + .OrderByDescending (n => n.ChangeDate) + .Take (10) + .Select (n => CreateNoteMenuItem(n)) + .ToArray (); + // avoid lazy eval for menu item construction + + foreach (Gtk.MenuItem mi in menuItems) { + yield return mi; + } + } + + yield return new Gtk.SeparatorMenuItem (); + + Gtk.MenuItem mitem = new Gtk.MenuItem (Catalog.GetString ("S_ynchronize Notes")); + // setting this changes the menu text to "Convert" + // item.Image = new Gtk.Image (Gtk.Stock.Convert, Gtk.IconSize.Menu); + mitem.Activated += (o, a) => Tomboy.ActionManager["NoteSynchronizationAction"].Activate (); + yield return mitem; + + item = new Gtk.ImageMenuItem (Catalog.GetString ("_Preferences")); + item.Image = new Gtk.Image (Gtk.Stock.Preferences, Gtk.IconSize.Menu); + item.Activated += (o, a) => Tomboy.ActionManager["ShowPreferencesAction"].Activate (); + yield return item; + + item = new Gtk.ImageMenuItem (Catalog.GetString ("_Help")); + item.Image = new Gtk.Image (Gtk.Stock.Help, Gtk.IconSize.Menu); + item.Activated += (o, a) => Tomboy.ActionManager["ShowHelpAction"].Activate (); + yield return item; + + item = new Gtk.ImageMenuItem (Catalog.GetString ("_About Tomboy")); + item.Image = new Gtk.Image (Gtk.Stock.About, Gtk.IconSize.Menu); + item.Activated += (o, a) => Tomboy.ActionManager["ShowAboutAction"].Activate (); + yield return item; + + yield return new Gtk.SeparatorMenuItem (); + + item = new Gtk.ImageMenuItem (Catalog.GetString ("_Quit")); + item.Image = new Gtk.Image (Gtk.Stock.Quit, Gtk.IconSize.Menu); + item.Activated += (o, a) => Tomboy.ActionManager["QuitTomboyAction"].Activate (); + yield return item; + } + } +}