[Muine] [patch] Add gconf key to control whether played tracks are deleted on closing the player



Hi,

I started using muine, and really liked it, but one thing was bothering
me: the way muine deletes tracks I'd already played from my playlist
when I close it.

I wrote a small patch to add a gconf key (/apps/muine/delete_on_close)
that controls whether this happens or not.

I imagine that the current behaviour is the way the community
wants it, so the default behaviour of the patch is the same as the
current behaviour.

Suggestions or criticisms welcome.

Cheers,

-- 
| Patrick Farrell
| cyan compsoc nuigalway ie
----------------------------
--- src/PlaylistWindow.cs.orig	2005-06-14 14:37:17.000000000 +0100
+++ src/PlaylistWindow.cs	2005-10-03 22:38:56.000000000 +0100
@@ -63,6 +63,9 @@
 		private const string GConfKeyRepeat = "/apps/muine/repeat";
 		private const bool   GConfDefaultRepeat = false;
 
+		private const string GConfKeyDeleteOnClose = "/apps/muine/delete_on_close";
+		private const bool   GConfDefaultDeleteOnClose = true;
+
 		// Strings
 		private static readonly string string_program = 
 			Catalog.GetString ("Muine Music Player");
@@ -224,6 +227,8 @@
 		private Hashtable random_sort_keys;
 
 		private bool repeat;
+		
+		private bool delete_on_close;
 
 		// Constructor
 		public PlaylistWindow () : base (WindowType.Toplevel)
@@ -408,6 +413,19 @@
 			get { return repeat; }
 		}
 
+		// Properties :: DeleteOnClose (set; get;)
+		public bool DeleteOnClose {
+			set {
+				delete_on_close = value;
+
+				Config.Set (GConfKeyDeleteOnClose, value);
+
+				PlaylistChanged();
+			}
+
+			get { return delete_on_close; }
+		}
+
 		// Methods
 		// Methods :: Public
 		// Methods :: Public :: RestorePlaylist
@@ -1109,7 +1127,8 @@
 
 			UpdateTimeLabels (player.Position);
 
-			SavePlaylist (FileUtils.PlaylistFile, !repeat, true);
+			bool delete_playlist = (delete_on_close == false) ? false : !repeat;
+			SavePlaylist (FileUtils.PlaylistFile, delete_playlist, true);
 
 			// Run PlaylistChangedEvent Handlers
 			if (PlaylistChangedEvent != null)
@@ -1430,6 +1449,13 @@
 
 			Config.AddNotify (GConfKeyRepeat,
 				new GConf.NotifyEventHandler (OnConfigRepeatChanged));
+			
+			// Delete on close
+			DeleteOnClose = (bool) Config.Get (GConfKeyDeleteOnClose,
+				GConfDefaultDeleteOnClose);
+
+			Config.AddNotify(GConfKeyDeleteOnClose,
+				new GConf.NotifyEventHandler (OnDeleteOnCloseChanged));
 		}
 
 		// Handlers
@@ -1667,6 +1693,18 @@
 			this.Repeat = val;
 		}
 
+		// Handlers :: OnDeleteOnCloseChanged
+		private void OnDeleteOnCloseChanged (object o, GConf.NotifyEventArgs args)
+		{
+			// Get new setting from GConf
+			bool val = (bool) args.Value;
+
+			if (val == this.DeleteOnClose)
+				return;
+
+			this.DeleteOnClose = val;
+		}
+
 		// Handlers :: OnPlaylistRowActivated
 		private void OnPlaylistRowActivated (object o, RowActivatedArgs args)
 		{

Attachment: pgpFHZEVznYAL.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]