Re: String change for Tomboy (patch included)



Hi,

Is it possible to get some decision on this string break? I'd really like to get this patch in soon, if possible.

-Alex

Sanford Armstrong wrote:
This email hasn't made it to gnome-i18n or gnome-doc-list, so I have
subscribed to those lists to expedite things.  The patch mentioned
below is also attached to this email.  Sorry for any unnecessary
duplication.

On 8/22/06, Sanford Armstrong <sanfordarmstrong gmail com> wrote:
As part of Tomboy being included in GNOME 2.16 [1], several users have
requested the ability for old Sticky Notes to be automatically
imported into Tomboy [2] [3].  This feature is now ready to be
committed.

Attached is the patch, and it breaks the string freeze for Tomboy in two ways:

1) A GConf key has been added to tomboy.schemas.in.  Since the Sticky
Note import plugin is an official part of Tomboy, and the plugin uses
a GConf key to determine if it has ever been run before, this is a
necessary change.

2) Previously, when manually running the Sticky Note import plugin,
the dialog would say something like "4 of 4 Sticky Notes were
successfully imported".  But if a user upgrades/installs Tomboy, and
the first time it starts is on their next log-in, that message is
somewhat disembodied and needs to be more explicit.  Therefore it now
ends with "successfully imported into Tomboy".  I feel that this is an
important change for users who are just transitioning from Sticky
Notes to Tomboy.  If anyone has a better suggestion for the verbiage
in that dialog, I would be happy to hear it.

I am new to internationalization, so if there is any additional way I
have broken the freeze please let me know.  I would like to commit
this patch to CVS as soon as possible.

Thanks,
Sandy Armstrong

[1] http://mail.gnome.org/archives/devel-announce-list/2006-August/msg00000.html [2] http://mail.gnome.org/archives/desktop-devel-list/2006-July/msg00642.html [3] http://mail.gnome.org/archives/desktop-devel-list/2006-August/msg00211.html




------------------------------------------------------------------------

? INSTALL
? Tomboy/Plugins/.StickyNoteImport.cs.swp
? data/DefaultPlugins.desktop
? data/DefaultPlugins.desktop.in
? data/tomboy-plugins.pc
? po/stamp-it
Index: Tomboy/NoteManager.cs
===================================================================
RCS file: /cvs/gnome/tomboy/Tomboy/NoteManager.cs,v
retrieving revision 1.30
diff -u -p -r1.30 NoteManager.cs
--- Tomboy/NoteManager.cs	27 Jul 2006 08:50:17 -0000	1.30
+++ Tomboy/NoteManager.cs	23 Aug 2006 04:54:00 -0000
@@ -143,7 +143,10 @@ namespace Tomboy
 			trie_controller.Update ();
// Load all the plugins for our notes.
-			foreach (Note note in notes) {
+			// Iterating through copy of notes list, because list may be
+			// changed when loading plugins.
+			ArrayList notesCopy = new ArrayList (notes);
+			foreach (Note note in notesCopy) {
 				plugin_mgr.LoadPluginsForNote (note);
 			}
 		}
Index: Tomboy/Preferences.cs
===================================================================
RCS file: /cvs/gnome/tomboy/Tomboy/Preferences.cs,v
retrieving revision 1.8
diff -u -p -r1.8 Preferences.cs
--- Tomboy/Preferences.cs	2 Aug 2006 07:08:24 -0000	1.8
+++ Tomboy/Preferences.cs	23 Aug 2006 04:54:00 -0000
@@ -23,6 +23,8 @@ namespace Tomboy
 		public const string EXPORTHTML_LAST_DIRECTORY = "/apps/tomboy/export_html/last_directory";
 		public const string EXPORTHTML_EXPORT_LINKED = "/apps/tomboy/export_html/export_linked";
+ public const string STICKYNOTEIMPORTER_FIRST_RUN = "/apps/tomboy/sticky_note_importer/sticky_importer_first_run";
+
 		static GConf.Client client;
 		static GConf.NotifyEventHandler changed_handler;
@@ -70,6 +72,9 @@ namespace Tomboy case EXPORTHTML_LAST_DIRECTORY:
 				return "";
+
+			case STICKYNOTEIMPORTER_FIRST_RUN:
+				return true;
 			}
return null;
Index: Tomboy/Plugins/StickyNoteImport.cs
===================================================================
RCS file: /cvs/gnome/tomboy/Tomboy/Plugins/StickyNoteImport.cs,v
retrieving revision 1.3
diff -u -p -r1.3 StickyNoteImport.cs
--- Tomboy/Plugins/StickyNoteImport.cs	25 Jul 2006 22:34:25 -0000	1.3
+++ Tomboy/Plugins/StickyNoteImport.cs	23 Aug 2006 04:54:00 -0000
@@ -18,9 +18,15 @@ public class StickyNoteImporter : NotePl
 	private const string base_duplicate_note_title = "{0} (#{1})";
private const string debug_no_sticky_file =
-		"StickyNoteImporter: Sticky Notes XML file does not exist!";
+		"StickyNoteImporter: Sticky Notes XML file does not exist or is invalid!";
 	private const string debug_create_error_base =
 		"StickyNoteImporter: Error while trying to create note \"{0}\": {1}";
+	private const string debug_first_run_detected =
+		"StickyNoteImporter: Detecting that importer has never been run...";
+	private const string debug_gconf_set_error_base =
+		"StickyNoteImporter: Error setting initial GConf first run key value: {0}";
+
+	private string sticky_xml_path;
 	
 	protected override void Initialize ()
 	{
@@ -30,6 +36,12 @@ public class StickyNoteImporter : NotePl
 		item.Activated += ImportButtonClicked;
 		item.Show ();
 		AddPluginMenuItem (item);
+		
+		sticky_xml_path =
+			Environment.GetFolderPath (System.Environment.SpecialFolder.Personal)
+			+ sticky_xml_rel_path;
+		
+		CheckForFirstRun ();
 	}
 	
 	protected override void Shutdown ()
@@ -41,19 +53,54 @@ public class StickyNoteImporter : NotePl
 	{
 		// Do nothing.
 	}
-	
-	void ImportButtonClicked (object sender, EventArgs args)
+
+	void CheckForFirstRun ()
 	{
-		string sticky_xml_path =
-			Environment.GetFolderPath (System.Environment.SpecialFolder.Personal)
-			+ sticky_xml_rel_path;
+		bool firstRun = (bool) Preferences.Get (Preferences.STICKYNOTEIMPORTER_FIRST_RUN);
+		
+		if (firstRun) {
+			try {
+				Preferences.Set (Preferences.STICKYNOTEIMPORTER_FIRST_RUN, false);
+			} catch (Exception e) {
+				Logger.Log (debug_gconf_set_error_base, e);
+			}
+
+			Logger.Log (debug_first_run_detected);
+
+			XmlDocument xmlDoc = GetStickyXmlDoc ();		
+			if (xmlDoc != null)
+				ImportNotes (xmlDoc);
+		}
+	}
- if (File.Exists (sticky_xml_path))
-			ImportNotes (sticky_xml_path);
+	XmlDocument GetStickyXmlDoc ()
+	{
+		if (File.Exists (sticky_xml_path)) {
+			try {
+				XmlDocument xmlDoc = new XmlDocument ();
+				xmlDoc.Load (sticky_xml_path);
+				return xmlDoc;
+			}
+			catch {
+				Logger.Log (debug_no_sticky_file);
+				return null;
+			}
+		}
 		else {
 			Logger.Log (debug_no_sticky_file);
-			ShowNoStickyXMLDialog (sticky_xml_path);
+			return null;
 		}
+		
+	}
+	
+	void ImportButtonClicked (object sender, EventArgs args)
+	{
+		XmlDocument xmlDoc = GetStickyXmlDoc ();
+		
+		if (xmlDoc != null)
+			ImportNotes (xmlDoc);
+		else
+			ShowNoStickyXMLDialog (sticky_xml_path);
 	}
 	
 	void ShowNoStickyXMLDialog (string xmlPath)
@@ -73,24 +120,14 @@ public class StickyNoteImporter : NotePl
 		ShowMessageDialog (
 			Catalog.GetString ("Sticky Notes import completed"),
 			string.Format (Catalog.GetString ("<b>{0}</b> of <b>{1}</b> Sticky Notes " +
-							  "were successfully imported."),
+							  "were successfully imported into Tomboy."),
 				       numNotesImported,
 				       numNotesTotal),
 			Gtk.MessageType.Info);
 	}
 	
-	void ImportNotes (string xmlPath)
+	void ImportNotes (XmlDocument xmlDoc)
 	{
-		XmlDocument xmlDoc = new XmlDocument ();
-		try {
-			xmlDoc.Load (xmlPath);
-		}
-		catch {
-			// TODO: Should this show a different message?
-			ShowNoStickyXMLDialog (xmlPath);
-			return;
-		}
-
 		XmlNodeList nodes = xmlDoc.SelectNodes (sticky_note_query);
 		
 		int numSuccessful = 0;
@@ -133,6 +170,7 @@ public class StickyNoteImporter : NotePl
 		
 		try {
 			Note newNote = Manager.Create (title, noteXml);
+			newNote.QueueSave (false);
 			newNote.Save ();
 			return true;
 		} catch (Exception e) {
Index: data/tomboy.schemas.in
===================================================================
RCS file: /cvs/gnome/tomboy/data/tomboy.schemas.in,v
retrieving revision 1.4
diff -u -p -r1.4 tomboy.schemas.in
--- data/tomboy.schemas.in	27 May 2006 01:58:25 -0000	1.4
+++ data/tomboy.schemas.in	23 Aug 2006 04:54:01 -0000
@@ -207,6 +207,21 @@
     </schema>
<schema>
+      <key>/schemas/apps/tomboy/sticky_note_importer/sticky_importer_first_run</key>
+      <applyto>/apps/tomboy/sticky_note_importer/sticky_importer_first_run</applyto>
+      <owner>tomboy</owner>
+      <type>bool</type>
+      <default>true</default>
+      <locale name="C">
+         <short>Sticky Note Importer First Run</short>
+         <long>
+	   Indicates that the Sticky Note Importer plugin has not been run, so it should run
+	   automatically the next time Tomboy starts.
+         </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]