~ubuntu-branches/ubuntu/lucid/tomboy/lucid-proposed

« back to all changes in this revision

Viewing changes to Tomboy/Tray.cs

Tags: upstream-0.3.9+dfsg
ImportĀ upstreamĀ versionĀ 0.3.9+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
using System;
3
3
using System.Collections;
4
4
using System.Text;
5
 
using Mono.Posix;
 
5
using Mono.Unix;
6
6
using System.Runtime.InteropServices;
7
7
 
8
8
namespace Tomboy
12
12
                NoteManager manager;
13
13
                Gtk.Tooltips tips;
14
14
                Gtk.Image image;
 
15
                PreferencesDialog prefs_dlg;
15
16
 
16
 
                static Gdk.Pixbuf tintin;
17
 
                static Gdk.Pixbuf tintin_large;
18
 
                static Gdk.Pixbuf stock_notes;
 
17
                static Gdk.Pixbuf tray_icon;
 
18
                static Gdk.Pixbuf about_icon_large;
 
19
                static Gdk.Pixbuf note_icon;
19
20
 
20
21
                static TomboyTray ()
21
22
                {
22
 
                        tintin = GuiUtils.GetMiniIcon ("tintin.png");
23
 
                        tintin_large = GuiUtils.GetIcon ("tintin.png");
24
 
                        stock_notes = GuiUtils.GetMiniIcon ("stock_notes.png");
 
23
                        tray_icon = GuiUtils.GetIcon ("tomboy", 22);
 
24
                        about_icon_large = GuiUtils.GetIcon ("tomboy", 48);
 
25
                        note_icon = GuiUtils.GetIcon ("tomboy", 16);
25
26
                }
26
27
 
27
28
                public TomboyTray (NoteManager manager) 
28
29
                        : base ()
29
30
                {
30
31
                        this.manager = manager;
31
 
                        this.image = new Gtk.Image (tintin);
 
32
                        this.image = new Gtk.Image (tray_icon);
32
33
 
33
34
                        this.CanFocus = true;
34
35
                        this.ButtonPressEvent += ButtonPress;
51
52
                        tips.Sink ();
52
53
 
53
54
                        SetupDragAndDrop ();
 
55
 
 
56
                        InitSomeStuff ();
54
57
                }
55
58
 
56
59
                void ButtonPress (object sender, Gtk.ButtonPressEventArgs args) 
90
93
                        Gtk.TextIter cursor = buffer.StartIter;
91
94
                        cursor.ForwardLines (1); // skip title
92
95
 
93
 
                        buffer.Insert (cursor, insert_text.ToString ());
 
96
                        buffer.Insert (ref cursor, insert_text.ToString ());
94
97
 
95
98
                        // Make the date string a small font...
96
99
                        cursor = buffer.StartIter;
134
137
                Gtk.Menu MakeRecentNotesMenu (Gtk.Widget parent) 
135
138
                {
136
139
                        Gtk.Menu menu = new Gtk.Menu ();
137
 
                        menu.AttachToWidget (parent, null);
 
140
                        menu.AttachToWidget (parent, GuiUtils.DetachMenu);
138
141
 
139
142
                        bool enable_keybindings = (bool) 
140
143
                                Preferences.Get (Preferences.ENABLE_KEYBINDINGS);
156
159
                        int max_size = 18;
157
160
                        int list_size = 0;
158
161
 
159
 
                        DateTime two_days_ago = DateTime.Now.AddDays (-2);
 
162
                        DateTime two_days_ago = DateTime.Today.AddDays (-2);
160
163
 
161
164
                        // List the i most recently changed notes, and any
162
165
                        // currently opened notes...
221
224
                        display_name = FormatForLabel (display_name);
222
225
 
223
226
                        Gtk.ImageMenuItem item = new Gtk.ImageMenuItem (display_name);
224
 
                        item.Image = new Gtk.Image (stock_notes);
 
227
                        item.Image = new Gtk.Image (note_icon);
225
228
                        item.Data ["Note"] = note;
226
229
                        item.Activated += ShowNote;
227
230
 
288
291
                        GuiUtils.PopupMenu (recent_menu, null);
289
292
                }
290
293
 
 
294
                void OnPreferencesResponse (object sender, Gtk.ResponseArgs args)
 
295
                {
 
296
                        ((Gtk.Widget) sender).Destroy ();
 
297
                        prefs_dlg = null;
 
298
                }
 
299
 
291
300
                public void ShowPreferences ()
292
301
                {
293
 
                        PreferencesDialog prefs = new PreferencesDialog ();
294
 
                        prefs.Run ();
295
 
                        prefs.Destroy ();
 
302
                        if (prefs_dlg == null) {
 
303
                                prefs_dlg = new PreferencesDialog ();
 
304
                                prefs_dlg.Response += OnPreferencesResponse;
 
305
                        }
 
306
                        prefs_dlg.Present ();
296
307
                }
297
308
 
298
309
                public void ShowAbout ()
306
317
                        };
307
318
 
308
319
                        string translators = Catalog.GetString ("translator-credits");
 
320
                        if (translators == "translator-credits")
 
321
                                translators = null;
309
322
 
310
 
                        Gnome.About about = 
311
 
                                new Gnome.About (
312
 
                                        "Tomboy", 
313
 
                                        Defines.VERSION,
314
 
                                        Catalog.GetString ("Copyright \xa9 2004-2006 Alex Graveley"),
315
 
                                        Catalog.GetString ("A simple and easy to use desktop " +
316
 
                                                           "note-taking application."),
317
 
                                        authors, 
318
 
                                        documenters, 
319
 
                                        translators,
320
 
                                        tintin_large);
321
 
                        about.Icon = tintin_large;
 
323
                        Gtk.AboutDialog about = new Gtk.AboutDialog ();
 
324
                        about.Name = "Tomboy";
 
325
                        about.Version = Defines.VERSION;
 
326
                        about.Logo = about_icon_large;
 
327
                        about.Copyright = 
 
328
                                Catalog.GetString ("Copyright \xa9 2004-2006 Alex Graveley");
 
329
                        about.Comments = Catalog.GetString ("A simple and easy to use desktop " +
 
330
                                                            "note-taking application.");
 
331
                        about.Website = "http://www.beatniksoftware.com/tomboy";
 
332
                        about.WebsiteLabel = Catalog.GetString("Homepage");
 
333
                        about.Authors = authors;
 
334
                        about.Documenters = documenters;
 
335
                        about.TranslatorCredits = translators;
 
336
                        about.IconName = "tomboy";
322
337
                        about.Show ();
323
338
                }
324
339
 
376
391
                                                        insert_text.ToString ());
377
392
                        }
378
393
                }
 
394
 
 
395
                // NOTHING TO SEE HERE
 
396
                void InitSomeStuff ()
 
397
                {
 
398
                        manager.NoteDeleted += OnNoteDeletedUpdateIcon;
 
399
                        manager.NoteAdded += OnNoteAddedUpdateIcon;
 
400
                        manager.NoteRenamed += OnNoteRenamedUpdateIcon;
 
401
                        if (manager.Find ("Tintin") != null)
 
402
                                image.Pixbuf = GuiUtils.GetIcon ("tintin", 22);
 
403
                }
 
404
 
 
405
                void OnNoteDeletedUpdateIcon (object sender, Note changed)
 
406
                {
 
407
                        if (changed.Title == "Tintin")
 
408
                                image.Pixbuf = tray_icon;
 
409
                }
 
410
 
 
411
                void OnNoteAddedUpdateIcon (object sender, Note changed)
 
412
                {
 
413
                        if (changed.Title == "Tintin")
 
414
                                image.Pixbuf = GuiUtils.GetIcon ("tintin", 22);
 
415
                }
 
416
 
 
417
                void OnNoteRenamedUpdateIcon (Note note, string old_title)
 
418
                {
 
419
                        if (note.Title == "Tintin")
 
420
                                image.Pixbuf = GuiUtils.GetIcon ("tintin", 22);
 
421
                        else if (old_title == "Tintin")
 
422
                                image.Pixbuf = tray_icon;
 
423
                }
 
424
                // GO ABOUT YOUR BUSINESS
379
425
        }
380
426
 
381
427
        //