tomboy r1768 - in trunk: . Tomboy Tomboy/Addins/InsertTimestamp data
- From: sharm svn gnome org
- To: svn-commits-list gnome org
- Subject: tomboy r1768 - in trunk: . Tomboy Tomboy/Addins/InsertTimestamp data
- Date: Sat, 12 Jan 2008 15:11:41 +0000 (GMT)
Author: sharm
Date: Sat Jan 12 15:11:41 2008
New Revision: 1768
URL: http://svn.gnome.org/viewvc/tomboy?rev=1768&view=rev
Log:
* Tomboy.mdp: Added InsertTimestamp addin files to Monodevelop
solution.
* Tomboy/NoteWindow.cs: Exposed accel_group as public AccelGrou
property.
* Tomboy/Addins/InsertTimestamp/InsertTimestampNoteAddin.cs,
Tomboy/Addins/InsertTimestamp/InsertTimestamp.addin.xml,
Tomboy/Addins/InsertTimestamp/InsertTimestampPreferencesFactory.cs,
Tomboy/Addins/InsertTimestamp/Makefile.am,
Tomboy/Addins/InsertTimestamp/InsertTimestampPreferences.cs,
Tomboy/Preferences.cs, data/tomboy.schemas.in: Adding in
configuration dialog for Insert Timestamp addin. Last patch to
close bug #359168. Patch courtesy of Stefan Schweizer, of course.
Added:
trunk/Tomboy/Addins/InsertTimestamp/InsertTimestampPreferences.cs
trunk/Tomboy/Addins/InsertTimestamp/InsertTimestampPreferencesFactory.cs
Modified:
trunk/ChangeLog
trunk/Tomboy.mdp
trunk/Tomboy/Addins/InsertTimestamp/InsertTimestamp.addin.xml
trunk/Tomboy/Addins/InsertTimestamp/InsertTimestampNoteAddin.cs
trunk/Tomboy/Addins/InsertTimestamp/Makefile.am
trunk/Tomboy/NoteWindow.cs
trunk/Tomboy/Preferences.cs
trunk/data/tomboy.schemas.in
Modified: trunk/Tomboy.mdp
==============================================================================
--- trunk/Tomboy.mdp (original)
+++ trunk/Tomboy.mdp Sat Jan 12 15:11:41 2008
@@ -219,6 +219,9 @@
<File name="Tomboy/Notebooks/NotebookNewNoteMenuItem.cs" subtype="Code" buildaction="Compile" />
<File name="Tomboy/PreferenceTabAddin.cs" subtype="Code" buildaction="Compile" />
<File name="Tomboy/Notebooks/NotebooksTreeView.cs" subtype="Code" buildaction="Compile" />
+ <File name="Tomboy/Addins/InsertTimestamp/InsertTimestampNoteAddin.cs" subtype="Code" buildaction="Compile" />
+ <File name="Tomboy/Addins/InsertTimestamp/InsertTimestampPreferences.cs" subtype="Code" buildaction="Compile" />
+ <File name="Tomboy/Addins/InsertTimestamp/InsertTimestampPreferencesFactory.cs" subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="gdk-sharp, Version=2.8.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
Modified: trunk/Tomboy/Addins/InsertTimestamp/InsertTimestamp.addin.xml
==============================================================================
--- trunk/Tomboy/Addins/InsertTimestamp/InsertTimestamp.addin.xml (original)
+++ trunk/Tomboy/Addins/InsertTimestamp/InsertTimestamp.addin.xml Sat Jan 12 15:11:41 2008
@@ -18,4 +18,8 @@
<Extension path="/Tomboy/NoteAddins">
<NoteAddin type="Tomboy.InsertTimestamp.InsertTimestampNoteAddin" />
</Extension>
-+</Addin>
+
+ <Extension path="/Tomboy/AddinPreferences">
+ <AddinPreferenceFactory type="Tomboy.InsertTimestamp.InsertTimestampPreferencesFactory" />
+ </Extension>
+</Addin>
Modified: trunk/Tomboy/Addins/InsertTimestamp/InsertTimestampNoteAddin.cs
==============================================================================
--- trunk/Tomboy/Addins/InsertTimestamp/InsertTimestampNoteAddin.cs (original)
+++ trunk/Tomboy/Addins/InsertTimestamp/InsertTimestampNoteAddin.cs Sat Jan 12 15:11:41 2008
@@ -9,33 +9,48 @@
namespace Tomboy.InsertTimestamp {
public class InsertTimestampNoteAddin : NoteAddin {
+ String date_format;
Gtk.MenuItem item;
public override void Initialize ()
{
- item = new Gtk.MenuItem (
- Catalog.GetString ("Insert Timestamp"));
- item.Activated += OnMenuItemActivated;
- item.Show ();
- AddPluginMenuItem (item);
}
public override void Shutdown ()
{
- item.Activated -= OnMenuItemActivated;
+ if (item != null)
+ item.Activated -= OnMenuItemActivated;
}
public override void OnNoteOpened ()
{
+ // Add the menu item when the window is created
+ item = new Gtk.MenuItem (
+ Catalog.GetString ("Insert Timestamp"));
+ item.Activated += OnMenuItemActivated;
+ item.AddAccelerator ("activate", Window.AccelGroup,
+ (uint) Gdk.Key.d, Gdk.ModifierType.ControlMask,
+ Gtk.AccelFlags.Visible);
+ item.Show ();
+ AddPluginMenuItem (item);
+
+ // Get the format from GConf and subscribe to changes
+ date_format = (string) Preferences.Get (
+ Preferences.INSERT_TIMESTAMP_FORMAT);
+ Preferences.SettingChanged += OnFormatSettingChanged;
}
void OnMenuItemActivated (object sender, EventArgs args)
{
- string format = Catalog.GetString ("dddd, MMMM d, h:mm tt");
- string text = DateTime.Now.ToString (format);
-
+ string text = DateTime.Now.ToString (date_format);
Gtk.TextIter cursor = Buffer.GetIterAtMark (Buffer.InsertMark);
Buffer.InsertWithTagsByName (ref cursor, text, "datetime");
}
+
+ void OnFormatSettingChanged (object sender, GConf.NotifyEventArgs args)
+ {
+ if (args.Key == Preferences.INSERT_TIMESTAMP_FORMAT)
+ date_format = (string) args.Value;
+ }
}
}
Added: trunk/Tomboy/Addins/InsertTimestamp/InsertTimestampPreferences.cs
==============================================================================
--- (empty file)
+++ trunk/Tomboy/Addins/InsertTimestamp/InsertTimestampPreferences.cs Sat Jan 12 15:11:41 2008
@@ -0,0 +1,169 @@
+//
+// InsertTimestampPreferences.cs: Preferences dialog for InsertTimestamp addin.
+// Allows configuration of timestamp format.
+//
+
+using System;
+using System.Collections.Generic;
+
+using GConf.PropertyEditors;
+using Mono.Unix;
+
+using Tomboy;
+
+namespace Tomboy.InsertTimestamp {
+ public class InsertTimestampPreferences : Gtk.VBox {
+
+ static List<string> formats;
+
+ Gtk.RadioButton selected_radio;
+ Gtk.RadioButton custom_radio;
+
+ Gtk.ScrolledWindow scroll;
+ Gtk.TreeView tv;
+ Gtk.ListStore store;
+ Gtk.Entry custom_entry;
+
+ static InsertTimestampPreferences ()
+ {
+ String defaultFormat = Catalog.GetString (
+ "dddd, MMMM d, h:mm tt");
+
+ formats = new List<string> ();
+ formats.Add (defaultFormat);
+ formats.Add ("MM/dd/yyyy hh:mm tt");
+ formats.Add ("dd.MM.yyyy HH:mm");
+ formats.Add ("MM/dd/yyyy");
+ formats.Add ("MM.dd.yyyy");
+ formats.Add ("dd/MM/yyyy");
+ formats.Add ("dd.MM.yyyy");
+ formats.Add ("hh:mm tt");
+ formats.Add ("HH:mm");
+ formats.Add ("HH:mm:ss");
+ }
+
+ public InsertTimestampPreferences () : base (false, 12)
+ {
+ // Get current values
+ String dateFormat = (string) Preferences.Get (
+ Preferences.INSERT_TIMESTAMP_FORMAT);
+
+ DateTime now = DateTime.Now;
+
+ // Label
+ Gtk.Label label = new Gtk.Label (Catalog.GetString (
+ "Choose one of the predefined formats " +
+ "or use your own."));
+ label.Wrap = true;
+ label.Xalign = 0;
+ PackStart (label);
+
+ // Use Selected Format
+ selected_radio = new Gtk.RadioButton (Catalog.GetString (
+ "Use _Selected Format"));
+ PackStart (selected_radio);
+
+ // 1st column (visible): formatted date
+ // 2nd column (not visible): date format
+ store = new Gtk.ListStore (typeof (string),
+ typeof (string));
+ foreach (String format in formats)
+ store.AppendValues (now.ToString (format), format);
+
+ scroll = new Gtk.ScrolledWindow();
+ scroll.ShadowType = Gtk.ShadowType.In;
+ PackStart (scroll);
+
+ tv = new Gtk.TreeView (store);
+ tv.HeadersVisible = false;
+ tv.AppendColumn ("Format", new Gtk.CellRendererText (),
+ "text", 0);
+ scroll.Add (tv);
+
+ // Use Custom Format
+ Gtk.HBox customBox = new Gtk.HBox (false, 12);
+ PackStart (customBox);
+
+ custom_radio = new Gtk.RadioButton (
+ selected_radio, Catalog.GetString ("_Use Custom Format"));
+ customBox.PackStart (custom_radio);
+
+ custom_entry = new Gtk.Entry ();
+ customBox.PackStart (custom_entry);
+
+ PropertyEditorEntry entryEditor = new PropertyEditorEntry (
+ Preferences.INSERT_TIMESTAMP_FORMAT, custom_entry);
+ entryEditor.Setup ();
+
+ // Activate/deactivate widgets
+ bool useCustom = true;
+ Gtk.TreeIter iter;
+ store.GetIterFirst (out iter);
+
+ foreach (object[] row in store) {
+ if (dateFormat.Equals (row[1])) {
+ // Found format in list
+ useCustom = false;
+ break;
+ }
+ store.IterNext (ref iter);
+ }
+
+ if (useCustom) {
+ custom_radio.Active = true;
+ scroll.Sensitive = false;
+ } else {
+ selected_radio.Active = true;
+ custom_entry.Sensitive = false;
+ tv.Selection.SelectIter (iter);
+ Gtk.TreePath path = store.GetPath (iter);
+ tv.ScrollToCell (path, null, false, 0, 0);
+ }
+
+ // Register Toggled event for one radio button only
+ selected_radio.Toggled += OnSelectedRadioToggled;
+ tv.Selection.Changed += OnSelectionChanged;
+
+ ShowAll ();
+ }
+
+ /// <summary>
+ /// Called when toggling between radio buttons.
+ /// Activate/deactivat widgets depending on selection.
+ /// </summary>
+ void OnSelectedRadioToggled (object sender, EventArgs args)
+ {
+ if (selected_radio.Active) {
+ scroll.Sensitive = true;
+ custom_entry.Sensitive = false;
+ // select 1st row
+ Gtk.TreeIter iter;
+ store.GetIterFirst (out iter);
+ tv.Selection.SelectIter (iter);
+ Gtk.TreePath path = store.GetPath (iter);
+ tv.ScrollToCell (path, null, false, 0, 0);
+ } else {
+ scroll.Sensitive = false;
+ custom_entry.Sensitive = true;
+ tv.Selection.UnselectAll ();
+ }
+ }
+
+ /// <summary>
+ /// Called when a different format is selected in the TreeView.
+ /// Set the GConf key to selected format.
+ /// </summary>
+ void OnSelectionChanged (object sender, EventArgs args)
+ {
+ Gtk.TreeModel model;
+ Gtk.TreeIter iter;
+
+ if (((Gtk.TreeSelection) sender).GetSelected (out model,
+ out iter)) {
+ string format = (string) model.GetValue (iter, 1);
+ Preferences.Set (Preferences.INSERT_TIMESTAMP_FORMAT,
+ format);
+ }
+ }
+ }
+}
Added: trunk/Tomboy/Addins/InsertTimestamp/InsertTimestampPreferencesFactory.cs
==============================================================================
--- (empty file)
+++ trunk/Tomboy/Addins/InsertTimestamp/InsertTimestampPreferencesFactory.cs Sat Jan 12 15:11:41 2008
@@ -0,0 +1,17 @@
+//
+// InsertTimestampPreferencesFactory.cs: Creates a widget that will be used in
+// the addin's preferences dialog.
+//
+
+using System;
+
+using Tomboy;
+
+namespace Tomboy.InsertTimestamp {
+ public class InsertTimestampPreferencesFactory : AddinPreferenceFactory {
+ public override Gtk.Widget CreatePreferenceWidget ()
+ {
+ return new InsertTimestampPreferences ();
+ }
+ }
+}
Modified: trunk/Tomboy/Addins/InsertTimestamp/Makefile.am
==============================================================================
--- trunk/Tomboy/Addins/InsertTimestamp/Makefile.am (original)
+++ trunk/Tomboy/Addins/InsertTimestamp/Makefile.am Sat Jan 12 15:11:41 2008
@@ -14,7 +14,9 @@
ADDIN_NAME = InsertTimestamp
TARGET = $(ADDIN_NAME).dll
CSFILES = \
- $(srcdir)/InsertTimestampNoteAddin.cs
+ $(srcdir)/InsertTimestampNoteAddin.cs \
+ $(srcdir)/InsertTimestampPreferences.cs \
+ $(srcdir)/InsertTimestampPreferencesFactory.cs
RESOURCES = \
-resource:$(srcdir)/$(ADDIN_NAME).addin.xml
Modified: trunk/Tomboy/NoteWindow.cs
==============================================================================
--- trunk/Tomboy/NoteWindow.cs (original)
+++ trunk/Tomboy/NoteWindow.cs Sat Jan 12 15:11:41 2008
@@ -290,6 +290,12 @@
}
}
+ public Gtk.AccelGroup AccelGroup {
+ get {
+ return accel_group;
+ }
+ }
+
//
// Sensitize the Link toolbar button on text selection
//
Modified: trunk/Tomboy/Preferences.cs
==============================================================================
--- trunk/Tomboy/Preferences.cs (original)
+++ trunk/Tomboy/Preferences.cs Sat Jan 12 15:11:41 2008
@@ -1,6 +1,8 @@
using System;
+using Mono.Unix;
+
namespace Tomboy
{
public class Preferences
@@ -34,6 +36,8 @@
public const string SYNC_SELECTED_SERVICE_ADDIN = "/apps/tomboy/sync/sync_selected_service_addin";
public const string SYNC_CONFIGURED_CONFLICT_BEHAVIOR = "/apps/tomboy/sync/sync_conflict_behavior";
+ public const string INSERT_TIMESTAMP_FORMAT = "/apps/tomboy/insert_timestamp/format";
+
static GConf.Client client;
static GConf.NotifyEventHandler changed_handler;
@@ -114,6 +118,9 @@
case SYNC_CONFIGURED_CONFLICT_BEHAVIOR:
return 0;
+
+ case INSERT_TIMESTAMP_FORMAT:
+ return Catalog.GetString ("dddd, MMMM d, h:mm tt");
}
return null;
Modified: trunk/data/tomboy.schemas.in
==============================================================================
--- trunk/data/tomboy.schemas.in (original)
+++ trunk/data/tomboy.schemas.in Sat Jan 12 15:11:41 2008
@@ -378,6 +378,20 @@
</schema>
<schema>
+ <key>/schemas/apps/tomboy/insert_timestamp/format</key>
+ <applyto>/apps/tomboy/insert_timestamp/format</applyto>
+ <owner>tomboy</owner>
+ <type>string</type>
+ <default>dddd, MMMM d, h:mm tt</default>
+ <locale name="C">
+ <short>Timestamp format</short>
+ <long>
+ The date format that is used for the timestamp.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
<key>/schemas/desktop/gnome/url-handlers/note/command</key>
<applyto>/desktop/gnome/url-handlers/note/command</applyto>
<owner>tomboy</owner>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]