Attachment 'InsertDateTime.cs'
Download 1 using System;
2
3 using Mono.Unix;
4
5 using Gtk;
6 using Tomboy;
7
8 [PluginInfo(
9 "Insert Date/Time", Defines.VERSION,
10 PluginInfoAttribute.OFFICIAL_AUTHOR,
11 "Inserts current date and time at the cursor position.",
12 WebSite = "http://www.gnome.org/projects/tomboy/"
13 )]
14 public class InsertDateTimePlugin : NotePlugin
15 {
16 Gtk.MenuItem item;
17
18 protected override void Initialize ()
19 {
20 item = new Gtk.MenuItem (Catalog.GetString ("Insert date and time"));
21 item.Activated += OnMenuItemActivated;
22 item.Show ();
23 AddPluginMenuItem (item);
24 }
25
26 protected override void Shutdown ()
27 {
28 item.Activated -= OnMenuItemActivated;
29 }
30
31 protected override void OnNoteOpened ()
32 {
33 }
34
35 void OnMenuItemActivated (object sender, EventArgs args)
36 {
37 string format = Catalog.GetString ("dddd, MMMM d, h:mm tt");
38 string text = DateTime.Now.ToString (format);
39
40 NoteBuffer buffer = Note.Buffer;
41 Gtk.TextIter cursor = buffer.GetIterAtMark (buffer.InsertMark);
42 buffer.InsertWithTagsByName (ref cursor, text, "datetime");
43 }
44 }
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.