10
public class NoteMenuItem : Gtk.ImageMenuItem
15
bool inhibit_activate;
17
static Gdk.Pixbuf note_icon;
18
static Gdk.Pixbuf pinup;
19
static Gdk.Pixbuf pinup_active;
20
static Gdk.Pixbuf pindown;
22
static NoteMenuItem ()
24
// Cache this since we use it a lot.
25
note_icon = GuiUtils.GetIcon ("tomboy-note", 16);
26
pinup = GuiUtils.GetIcon ("pinup", 16);
27
pinup_active = GuiUtils.GetIcon ("pinup-active", 16);
28
pindown = GuiUtils.GetIcon ("pindown", 16);
31
public NoteMenuItem (Note note, bool show_pin)
32
: base (GetDisplayName(note))
35
Image = new Gtk.Image (note_icon);
38
Gtk.HBox box = new Gtk.HBox (false, 0);
39
Gtk.Widget child = Child;
41
box.PackStart (child, true, true, 0);
45
pinned = note.IsPinned;
46
pin_img = new Gtk.Image(pinned ? pindown : pinup);
48
box.PackStart (pin_img, false, false, 0);
52
static string FormatForLabel (string name)
54
// Replace underscores ("_") with double-underscores ("__")
55
// so Note menuitems are not created with mnemonics.
56
return name.Replace ("_", "__");
59
static string GetDisplayName (Note note)
61
string display_name = note.Title;
63
display_name += Catalog.GetString (" (new)");
64
return FormatForLabel (display_name);
67
protected override void OnActivated ()
69
if (!inhibit_activate) {
71
note.Window.Present ();
75
protected override bool OnButtonPressEvent (Gdk.EventButton ev)
77
if (pin_img != null &&
78
ev.X >= pin_img.Allocation.X &&
79
ev.X < pin_img.Allocation.X + pin_img.Allocation.Width) {
80
pinned = note.IsPinned = !pinned;
81
pin_img.Pixbuf = pinned ? pindown : pinup;
82
inhibit_activate = true;
85
return base.OnButtonPressEvent (ev);
88
protected override bool OnButtonReleaseEvent (Gdk.EventButton ev)
90
if (inhibit_activate) {
91
inhibit_activate = false;
94
return base.OnButtonReleaseEvent (ev);
97
protected override bool OnMotionNotifyEvent (Gdk.EventMotion ev)
99
if (!pinned && pin_img != null) {
100
if (ev.X >= pin_img.Allocation.X &&
101
ev.X < pin_img.Allocation.X + pin_img.Allocation.Width) {
102
if (pin_img.Pixbuf != pinup_active)
103
pin_img.Pixbuf = pinup_active;
104
} else if (pin_img.Pixbuf != pinup) {
105
pin_img.Pixbuf = pinup;
108
return base.OnMotionNotifyEvent (ev);
111
protected override bool OnLeaveNotifyEvent (Gdk.EventCrossing ev)
113
if (!pinned && pin_img != null) {
114
pin_img.Pixbuf = pinup;
116
return base.OnLeaveNotifyEvent (ev);
10
120
public class TomboyTray : Gtk.EventBox
12
122
NoteManager manager;
153
255
Preferences.KEYBINDING_CREATE_NEW_NOTE);
155
// FIXME: Pull this from GConf
257
int min_size = (int) Preferences.Get (Preferences.MENU_NOTE_COUNT);
157
258
int max_size = 18;
158
259
int list_size = 0;
160
DateTime two_days_ago = DateTime.Today.AddDays (-2);
261
DateTime days_ago = DateTime.Today.AddDays (-3);
162
// List the i most recently changed notes, and any
163
// currently opened notes...
263
// List the i most recently changed notes, any currently
264
// opened notes, and any pinned notes...
164
265
foreach (Note note in manager.Notes) {
165
266
if (note.IsSpecial)
168
if ((note.IsOpened && note.Window.IsMapped) ||
169
note.ChangeDate > two_days_ago ||
271
if ((note.IsOpened && note.Window.IsMapped) ||
272
note.ChangeDate > days_ago ||
170
273
list_size < min_size) {
171
item = MakeNoteMenuItem (note);
274
if (list_size <= max_size)
276
} else if (note.IsPinned) {
281
item = new NoteMenuItem (note, true);
172
282
menu.Append (item);
174
if (++list_size == max_size)
179
287
Note start = manager.Find (Catalog.GetString ("Start Here"));
180
288
if (start != null) {
181
item = MakeNoteMenuItem (start);
289
item = new NoteMenuItem (start, false);
182
290
menu.Append (item);
184
292
if (enable_keybindings)
200
308
Preferences.KEYBINDING_OPEN_RECENT_CHANGES);
202
item = new Gtk.ImageMenuItem (Catalog.GetString ("_Search Notes..."));
203
item.Image = new Gtk.Image (Gtk.Stock.Find, Gtk.IconSize.Menu);
204
item.Activated += SearchNotes;
207
if (enable_keybindings)
208
GConfKeybindingToAccel.AddAccelerator (
210
Preferences.KEYBINDING_OPEN_SEARCH);
216
Gtk.ImageMenuItem MakeNoteMenuItem (Note note)
218
string display_name = note.Title;
220
display_name += Catalog.GetString (" (new)");
222
display_name = FormatForLabel (display_name);
224
Gtk.ImageMenuItem item = new Gtk.ImageMenuItem (display_name);
225
item.Image = new Gtk.Image (note_icon);
226
item.Data ["Note"] = note;
227
item.Activated += ShowNote;
232
string FormatForLabel (string name)
234
// Replace underscores ("_") with double-underscores ("__")
235
// so Note menuitems are not created with mnemonics.
236
return name.Replace ("_", "__");
239
void ShowNote (object sender, EventArgs args)
241
Note note = (Note) ((Gtk.Widget) sender).Data ["Note"];
243
note.Window.Present ();
246
314
void CreateNewNote (object sender, EventArgs args)
265
void SearchNotes (object sender, EventArgs args)
267
NoteFindDialog find_dialog = NoteFindDialog.GetInstance (manager);
268
find_dialog.Present ();
271
333
void ViewRecentChanges (object sender, EventArgs args)
273
Gtk.Window recent = new NoteRecentChanges (manager);
335
NoteRecentChanges.GetInstance (manager).Present ();
277
338
// Used by TomboyApplet to modify the icon background.
307
368
public void ShowAbout ()
309
370
string [] authors = new string [] {
310
"Alex Graveley <alex@beatniksoftware.com>"
371
"Alex Graveley <alex@beatniksoftware.com>",
372
"Boyd Timothy <btimothy@gmail.com>",
373
"David Trowbridge <trowbrds@gmail.com>",
374
"Ryan Lortie <desrt@desrt.ca>",
375
"Sandy Armstrong <sanfordarmstrong@gmail.com>",
376
"Sebastian Rittau <srittau@jroger.in-berlin.de>"
313
379
string [] documenters = new string [] {