From 181aa996ccde6b1cc3f48f285878413a616b6a34 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Thu, 5 Aug 2010 23:17:57 +0100 Subject: [PATCH] [ui] Don't create a gtkbookmark if there is one already --- SparkleShare/SparkleUI.cs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/SparkleShare/SparkleUI.cs b/SparkleShare/SparkleUI.cs index 3d03e6b2..0992dcc6 100644 --- a/SparkleShare/SparkleUI.cs +++ b/SparkleShare/SparkleUI.cs @@ -199,13 +199,26 @@ namespace SparkleShare { public void AddToBookmarks () { - // TODO: don't add when the bookmark is already there + string bookmarks_file_path = Path.Combine (SparklePaths.HomePath, ".gtk-bookmarks"); + string sparkleshare_bookmark = "file://" + SparklePaths.SparklePath + " SparkleShare"; - string bookmarks_file_name = Path.Combine (SparklePaths.HomePath, ".gtk-bookmarks"); + if (File.Exists (bookmarks_file_path)) { - if (File.Exists (bookmarks_file_name)) { + StreamReader reader = new StreamReader (bookmarks_file_path); + string bookmarks = reader.ReadToEnd (); + reader.Close (); - TextWriter writer = File.AppendText (bookmarks_file_name); + if (!bookmarks.Contains (sparkleshare_bookmark)) { + + TextWriter writer = File.AppendText (bookmarks_file_path); + writer.WriteLine ("file://" + SparklePaths.SparklePath + " SparkleShare"); + writer.Close (); + + } + + } else { + + StreamWriter writer = new StreamWriter (bookmarks_file_path); writer.WriteLine ("file://" + SparklePaths.SparklePath + " SparkleShare"); writer.Close ();