1
Description: Adds support for rendering menus in the application
4
This patch moves tomboy out of the notification area, and into
5
the indicator-applet using libappindicator.
7
Forwarded: Not forwarded yet
8
Author: Jason Smith <jason.smith@canonical.com>
9
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/tomboy/+bug/497058
10
Last-Update: 2010-01-07
12
=== modified file 'Tomboy/Makefile.am'
13
--- old/Tomboy/Makefile.am 2010-01-07 16:43:35 +0000
14
+++ new/Tomboy/Makefile.am 2010-01-07 17:33:42 +0000
17
$(srcdir)/TagButton.cs \
18
$(srcdir)/TagManager.cs \
19
+ $(srcdir)/TomboyIndicatorTray.cs \
27
+ $(APPINDICATORSHARP_LIBS) \
32
=== modified file 'Tomboy/RecentChanges.cs'
33
--- old/Tomboy/RecentChanges.cs 2010-01-07 16:43:35 +0000
34
+++ new/Tomboy/RecentChanges.cs 2010-01-07 20:31:00 +0000
36
am ["NewNotebookAction"].Activated += OnNewNotebook;
37
am ["DeleteNotebookAction"].Activated += OnDeleteNotebook;
38
am ["CloseWindowAction"].Activated += OnCloseWindow;
39
- if (Tomboy.TrayIconShowing == false)
40
+ if (Tomboy.TrayIconShowing == false && !TomboyIndicatorTray.IndicatorTrayPresent)
41
am ["CloseWindowAction"].Visible = false;
43
// Allow Escape to close the window as well as <Control>W
48
- if (Tomboy.TrayIconShowing == false)
49
+ if (Tomboy.TrayIconShowing == false && !TomboyIndicatorTray.IndicatorTrayPresent)
50
Tomboy.ActionManager ["QuitTomboyAction"].Activate ();
54
=== modified file 'Tomboy/Tomboy.cs'
55
--- old/Tomboy/Tomboy.cs 2010-01-07 16:43:35 +0000
56
+++ new/Tomboy/Tomboy.cs 2010-01-07 20:48:10 +0000
61
+ static TomboyIndicatorTray indicator;
62
static void StartTrayIcon ()
64
- // Create the tray icon and run the main loop
65
- tray_icon = new TomboyTrayIcon (manager);
66
- tray = tray_icon.Tray;
68
- // Give the TrayIcon 2 seconds to appear. If it
69
- // doesn't by then, open the SearchAllNotes window.
70
- tray_icon_showing = tray_icon.IsEmbedded && tray_icon.Visible;
71
- if (!tray_icon_showing)
72
- GLib.Timeout.Add (2000, CheckTrayIconShowing);
73
+ if (TomboyIndicatorTray.IndicatorTrayPresent) {
74
+ indicator = new TomboyIndicatorTray (manager);
76
+ // Create the tray icon and run the main loop
77
+ tray_icon = new TomboyTrayIcon (manager);
78
+ tray = tray_icon.Tray;
80
+ // Give the TrayIcon 2 seconds to appear. If it
81
+ // doesn't by then, open the SearchAllNotes window.
82
+ tray_icon_showing = tray_icon.IsEmbedded && tray_icon.Visible;
83
+ if (!tray_icon_showing)
84
+ GLib.Timeout.Add (2000, CheckTrayIconShowing);
90
// instead, launch the Search All Notes window so the user can
91
// can still use Tomboy.
93
- if (tray_icon_showing == false)
94
+ if (tray_icon_showing == false && indicator != null)
95
ActionManager ["ShowSearchAllNotesAction"].Activate ();
99
=== added file 'Tomboy/TomboyIndicatorTray.cs'
100
--- old/Tomboy/TomboyIndicatorTray.cs 1970-01-01 00:00:00 +0000
101
+++ new/Tomboy/TomboyIndicatorTray.cs 2010-01-07 17:33:42 +0000
104
+// Copyright (C) 2009 GNOME Do
106
+// This program is free software: you can redistribute it and/or modify
107
+// it under the terms of the GNU General Public License as published by
108
+// the Free Software Foundation, either version 3 of the License, or
109
+// (at your option) any later version.
111
+// This program is distributed in the hope that it will be useful,
112
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
113
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
114
+// GNU General Public License for more details.
116
+// You should have received a copy of the GNU General Public License
117
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
121
+using System.Collections.Generic;
132
+ public class TomboyIndicatorTray
134
+ public static bool IndicatorTrayPresent {
140
+ ApplicationIndicator indicator;
141
+ NoteManager manager;
144
+ public TomboyIndicatorTray (NoteManager manager)
146
+ this.manager = manager;
147
+ indicator = new ApplicationIndicator ("tomboy-notes", "tomboy", Category.ApplicationStatus);
150
+ indicator.Status = Status.Active;
153
+ void SetMenuItems ()
155
+ if (menu != null) {
156
+ foreach (Gtk.Widget widget in menu.Children) {
157
+ menu.Remove (widget);
162
+ menu = new Gtk.Menu ();
164
+ foreach (Gtk.MenuItem item in CurrentMenuItems ())
165
+ menu.Append (item);
167
+ indicator.Menu = menu;
170
+ IEnumerable<Gtk.MenuItem> CurrentMenuItems ()
172
+ Gtk.ImageMenuItem item;
174
+ item = new Gtk.ImageMenuItem (Catalog.GetString ("_Create New Note"));
175
+ item.Image = new Gtk.Image (Gtk.Stock.New, Gtk.IconSize.Menu);
176
+ item.Activated += (o, a) => Tomboy.ActionManager["NewNoteAction"].Activate ();
177
+ item.Activated += (o, a) => SetMenuItems ();
180
+ item = new Gtk.ImageMenuItem (Catalog.GetString ("_Search All Notes"));
181
+ item.Image = new Gtk.Image (Gtk.Stock.Find, Gtk.IconSize.Menu);
182
+ item.Activated += (o, a) => Tomboy.ActionManager["ShowSearchAllNotesAction"].Activate ();
185
+ yield return new Gtk.SeparatorMenuItem ();
187
+ var menuItems = manager.Notes
188
+ .Where (n => !n.IsSpecial)
189
+ .OrderByDescending (n => n.ChangeDate)
191
+ .Select (n => new NoteMenuItem (n, n.IsPinned))
193
+ // avoid lazy eval for menu item construction
195
+ foreach (Gtk.MenuItem mi in menuItems) {
196
+ mi.Activated += (o, a) => SetMenuItems ();
200
+ yield return new Gtk.SeparatorMenuItem ();
202
+ item = new Gtk.ImageMenuItem (Catalog.GetString ("S_ynchronize Notes"));
203
+ // setting this changes the menu text to "Convert"
204
+ // item.Image = new Gtk.Image (Gtk.Stock.Convert, Gtk.IconSize.Menu);
205
+ item.Activated += (o, a) => Tomboy.ActionManager["NoteSynchronizationAction"].Activate ();
208
+ item = new Gtk.ImageMenuItem (Catalog.GetString ("_Preferences"));
209
+ item.Image = new Gtk.Image (Gtk.Stock.Preferences, Gtk.IconSize.Menu);
210
+ item.Activated += (o, a) => Tomboy.ActionManager["ShowPreferencesAction"].Activate ();
213
+ item = new Gtk.ImageMenuItem (Catalog.GetString ("_Help"));
214
+ item.Image = new Gtk.Image (Gtk.Stock.Help, Gtk.IconSize.Menu);
215
+ item.Activated += (o, a) => Tomboy.ActionManager["ShowHelpAction"].Activate ();
218
+ item = new Gtk.ImageMenuItem (Catalog.GetString ("_About Tomboy"));
219
+ item.Image = new Gtk.Image (Gtk.Stock.About, Gtk.IconSize.Menu);
220
+ item.Activated += (o, a) => Tomboy.ActionManager["ShowAboutAction"].Activate ();
223
+ yield return new Gtk.SeparatorMenuItem ();
225
+ item = new Gtk.ImageMenuItem (Catalog.GetString ("_Quit"));
226
+ item.Image = new Gtk.Image (Gtk.Stock.Quit, Gtk.IconSize.Menu);
227
+ item.Activated += (o, a) => Tomboy.ActionManager["QuitTomboyAction"].Activate ();
233
=== modified file 'configure.in'
234
--- old/configure.in 2010-01-07 16:43:35 +0000
235
+++ new/configure.in 2010-01-07 17:33:42 +0000
237
gtk-sharp-2.0 >= $GTKSHARP2_MINIMUM_VERSION)
238
AC_SUBST(GTKSHARP_LIBS)
240
+APPINDICATOR_MINIMUM_VERSION=0.0.5
241
+PKG_CHECK_MODULES(APPINDICATORSHARP,
242
+ appindicator-sharp-0.1 >= $APPINDICATOR_MINIMUM_VERSION)
243
+AC_SUBST(APPINDICATORSHARP_LIBS)
245
# Printing at least needs Mono.Cairo