Attachment 'InsertDateTime.cs'
Download 1 using System;
2 using Mono.Unix;
3 using Gtk;
4 using Tomboy;
5
6 namespace Tomboy.InsertDateTime
7 {
8 public class InsertDateTimeAddin : NoteAddin
9 {
10 Gtk.MenuItem item;
11
12 public override void Initialize ()
13 {
14 item = new Gtk.MenuItem (Catalog.GetString ("Insert date and time"));
15 item.Activated += OnMenuItemActivated;
16 item.Show ();
17 AddPluginMenuItem (item);
18 }
19
20 public override void Shutdown ()
21 {
22 item.Activated -= OnMenuItemActivated;
23 }
24
25 public override void OnNoteOpened ()
26 {
27 }
28
29 void OnMenuItemActivated (object sender, EventArgs args)
30 {
31 string format = Catalog.GetString ("dddd, MMMM d, h:mm tt");
32 string text = DateTime.Now.ToString (format);
33
34 NoteBuffer buffer = Note.Buffer;
35 Gtk.TextIter cursor = buffer.GetIterAtMark (buffer.InsertMark);
36 buffer.InsertWithTagsByName (ref cursor, text, "datetime");
37 }
38 }
39 }
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.