[tomboy-list] Timestamp idea

Raymond rayauge at doublebite.com
Thu Jun 21 07:27:35 PDT 2007


Just a minor update to provide choice of "Date & Time", "Date", or
"Time".

Also changed the bold to monospace which I like better (I also like it
in italic).

Feel free to change to the tags you want... (might be an idea to add a
preferences dialog eventually so these are confable).

Please note that "monospace" is defined by the FixedWidth plugin, so you
need that plugin (on) for this tag to have an effect.

========================================================================

using System;

using Mono.Unix;

using Gtk;
using Tomboy;

[PluginInfo(
	"Insert Date/Time", Defines.VERSION,
	PluginInfoAttribute.OFFICIAL_AUTHOR,
	"Inserts current date and time at the cursor position.",
	WebSite = "http://www.gnome.org/projects/tomboy/"
	)]
public class InsertDateTimePlugin : NotePlugin
{
	Gtk.MenuItem itemDT;
	Gtk.MenuItem itemD;
	Gtk.MenuItem itemT;
	
	protected override void Initialize ()
	{
		itemDT = new Gtk.MenuItem (Catalog.GetString ("Date & Time"));
		itemDT.Activated += DateAndTime;
		itemDT.Show ();
		AddPluginMenuItem (itemDT);

		itemD = new Gtk.MenuItem (Catalog.GetString ("Date"));
		itemD.Activated += Date;
		itemD.Show ();
		AddPluginMenuItem (itemD);

		itemT = new Gtk.MenuItem (Catalog.GetString ("Time"));
		itemT.Activated += Time;
		itemT.Show ();
		AddPluginMenuItem (itemT);
	}
	
	protected override void Shutdown ()
	{
		itemDT.Activated -= DateAndTime;
		itemD.Activated -= Date;
		itemT.Activated -= Time;
	}
	
	protected override void OnNoteOpened ()
	{
	}
	
	void DateAndTime (object sender, EventArgs args)
	{
		string format = Catalog.GetString ("dddd, MMMM dd yyyy, hh:mm tt");
		string text = DateTime.Now.ToString (format);
		
		NoteBuffer buffer = Note.Buffer;
		Gtk.TextIter cursor = buffer.GetIterAtMark (buffer.InsertMark);
		buffer.InsertWithTagsByName (ref cursor, text, "monospace", "italic");
	}
	
	void Date (object sender, EventArgs args)
	{
		string format = Catalog.GetString ("dddd, MMMM dd yyyy");
		string text = DateTime.Now.ToString (format);
		
		NoteBuffer buffer = Note.Buffer;
		Gtk.TextIter cursor = buffer.GetIterAtMark (buffer.InsertMark);
		buffer.InsertWithTagsByName (ref cursor, text, "monospace", "italic");
	}

	void Time (object sender, EventArgs args)
	{
		string format = Catalog.GetString ("hh:mm tt");
		string text = DateTime.Now.ToString (format);
		
		NoteBuffer buffer = Note.Buffer;
		Gtk.TextIter cursor = buffer.GetIterAtMark (buffer.InsertMark);
		buffer.InsertWithTagsByName (ref cursor, text, "monospace", "italic");
	}
}

===============================================================
compile with:

]$  gmcs -debug -out:InsertDateTime.dll -target:library
-pkg:tomboy-plugins -r:Mono.Posix InsertDateTime.cs


On Tue, 2007-06-19 at 21:55 -0400, Boyd Timothy wrote:

> Something like this is cool.  It ought to be one of the first Tomboy
> Addins (via Mono.Addins).  :)
> 
> -Boyd
> 
> 
> On 6/15/07, Pete Goodall <pete at yellowhouse.org> wrote:
> 
>         Nice.  Thx! 
>         
>         - Pete
>         
>         
>         
>         On 6/15/07, Raymond Auge <rauge at liferay.com> wrote:
>                 I did just this by customizing the example for
>                 InsertDateTime.cs on the site.
>                 
>                 Here is the code I used (virtually the same as that on
>                 the plugin tutorial page)
>                 
>                 =============================================================
>                 using System;
>                 
>                 using Mono.Unix;
>                 
>                 using Gtk;
>                 using Tomboy;
>                 
>                 [PluginInfo(
>                 "Insert Date/Time", Defines.VERSION,
>                 PluginInfoAttribute.OFFICIAL_AUTHOR,
>                 "Inserts current date and time at the cursor
>                 position.",
>                 WebSite = "http://www.gnome.org/projects/tomboy/"
>                 )]
>                 public class InsertDateTimePlugin : NotePlugin
>                 {
>                 Gtk.MenuItem item;
>                 
>                 protected override void Initialize ()
>                 {
>                 item = new Gtk.MenuItem (Catalog.GetString ("Insert
>                 date and time"));
>                 item.Activated += OnMenuItemActivated;
>                 item.Show ();
>                 AddPluginMenuItem (item);
>                 }
>                 
>                 protected override void Shutdown ()
>                 {
>                 item.Activated -= OnMenuItemActivated;
>                 }
>                 
>                 protected override void OnNoteOpened ()
>                 {
>                                 /*
>                                  * To Add the date when a new note is
>                 opened I would just add similar code here.
>                                  */
>                 }
>                 
>                 void OnMenuItemActivated (object sender, EventArgs
>                 args)
>                 {
>                 string format = Catalog.GetString ("dddd, MMMM d yyyy,
>                 h:mm tt");
>                 string text = DateTime.Now.ToString (format);
>                 
>                 NoteBuffer buffer = Note.Buffer;
>                 Gtk.TextIter cursor = buffer.GetIterAtMark
>                 (buffer.InsertMark);
>                 buffer.InsertWithTagsByName (ref cursor, text,
>                 "bold");
>                 }
>                 }
>                 =================================================================
>                 
>                 Compile with 
>                 
>                 $] gmcs -debug -out:InsertDateTime.dll -target:library
>                 -pkg:tomboy-plugins -r:Mono.Posix InsertDateTime.cs
>                 
>                 
>                 
>                 
>                 On Fri, 2007-06-15 at 11:04 -0400, Pete Goodall wrote:
>                 > 
>                 > Hi all,
>                 > 
>                 > Was just browsing through the Place for Ideas site, and noticed the
>                 > Timestamps idea:
>                 > http://live.gnome.org/Tomboy/PlaceForNewIdeas#head-4c3b027684b342a623f2133a20f669f6428dd0a6
>                 > 
>                 > 
>                 > 
>                 > This is similar to what I had in mind, but a bit of overkill.  I
>                 > simply want an "Insert timestamp" option.  For instance, when I start
>                 > a new note, I would like to have "Note started on Friday, 15 June 2007
>                 > @ 11:02 am EST".  Then later in the note I would "Insert timestamp" to
>                 > paste in the time I started an edit.  This would be useful if I have a
>                 > note that includes meeting notes from various meetings over time.
>                 > 
>                 > Anyway, that's my $0.02.
>                 > 
>                 > - Pete
>                 > 
>                 > 
>                 
>                 Raymond Auge <rauge at liferay.com>
>                 Software Engineer
>                 Liferay, Inc.
>                 Enterprise. Open Source. For Life.
>                 
>                 
>                 
>         
>         
>         
>         
>         
>         -- 
>         Pete Goodall <pete at yellowhouse.org>
>         
>         
>         _______________________________________________
>         tomboy-list mailing list
>         tomboy-list at lists.beatniksoftware.com
>         http://lists.beatniksoftware.com/listinfo.cgi/tomboy-list-beatniksoftware.com
>         
> 
> 
> 
> _______________________________________________
> tomboy-list mailing list
> tomboy-list at lists.beatniksoftware.com
> http://lists.beatniksoftware.com/listinfo.cgi/tomboy-list-beatniksoftware.com

Raymond Auge <rauge at liferay.com>
Software Engineer
Liferay, Inc.
Enterprise. Open Source. For Life.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.beatniksoftware.com/pipermail/tomboy-list-beatniksoftware.com/attachments/20070621/3833eee9/attachment-0001.htm 


More information about the tomboy-list mailing list