Re: [Muine] [PATCH] sometimes display album name in Add Song dialog



Hi,

Thinking about this, I think I came up with a better solution. The
solution I am planning is to have a "Details" expander widget in both
the add album and add song dialogs, which would open song, album
information inline. This way one can easily browse songs instantly
seeing all their metadata.

Jorn

�el kenal p�al (kolmap�, 21. juuli 2004, 08:26+0100), kirjutas Sean
Neakums:
> Here is a patch that causes the Add Song dialog to display the album
> name for songs of the same name by the same artist.  This is useful in
> the presence of compilations and live albums, of which I have a few.
> 
> http://flynn.zork.net/~sneakums/hacked-add-song-4.png
> 
> Early versions of this hack unconditionally showed the album name, in
> various formats.  For reference, here are the earlier attempts:
> 
> http://flynn.zork.net/~sneakums/hacked-add-song.png   (noisy, ugly)
> http://flynn.zork.net/~sneakums/hacked-add-song-2.png (noisy, less ugly)
> http://flynn.zork.net/~sneakums/hacked-add-song-3.png (noisy)
> 
> 
> 
> diff -urN --exclude '*~' muine-0.6.3/src/AddSongWindow.cs muine-0.6.3-hacked/src/AddSongWindow.cs
> --- muine-0.6.3/src/AddSongWindow.cs	2004-06-05 14:57:00.000000000 +0100
> +++ muine-0.6.3-hacked/src/AddSongWindow.cs	2004-07-20 19:38:23.000000000 +0100
> @@ -137,6 +137,9 @@
>  
>  		r.Text = song.Title + "\n" + StringUtils.JoinHumanReadable (song.Artists);
>  
> +		if (!Muine.DB.IsUnique (song))
> +			r.Text += "\n" + song.Album;
> +
>  		MarkupUtils.CellSetMarkup (r, 0, StringUtils.GetByteLength (song.Title),
>  					   false, true, false);
>  	}
> diff -urN --exclude '*~' muine-0.6.3/src/Song.cs muine-0.6.3-hacked/src/Song.cs
> --- muine-0.6.3/src/Song.cs	2004-06-13 14:59:09.000000000 +0100
> +++ muine-0.6.3-hacked/src/Song.cs	2004-07-20 19:41:28.000000000 +0100
> @@ -182,6 +182,12 @@
>  		}
>  	}
>  
> +	public string UniquenessDeterminantKey {
> +		get {
> +			return (String.Join ("/", artists) + "/" + title).ToLower ();
> +		}
> +	}
> +
>  	private bool dead = false;
>  	public bool Dead {
>  		set {
> diff -urN --exclude '*~' muine-0.6.3/src/SongDatabase.cs muine-0.6.3-hacked/src/SongDatabase.cs
> --- muine-0.6.3/src/SongDatabase.cs	2004-06-13 14:49:46.000000000 +0100
> +++ muine-0.6.3-hacked/src/SongDatabase.cs	2004-07-20 19:46:46.000000000 +0100
> @@ -31,6 +31,8 @@
>  
>  	public Hashtable Albums;
>  
> +	private Hashtable SameArtistCounts;
> +
>  	public delegate void SongAddedHandler (Song song);
>  	public event SongAddedHandler SongAdded;
>  
> @@ -78,6 +80,7 @@
>  
>  		Songs = new Hashtable ();
>  		Albums = new Hashtable ();
> +		SameArtistCounts = new Hashtable ();
>  	}
>  
>  	/*** loading ***/
> @@ -88,6 +91,8 @@
>  		Songs.Add (key, song);
>  
>  		AddToAlbum (song, false);
> +
> +		RegisterUniqueness (song);
>  	}
>  
>  	private delegate void DecodeFuncDelegate (string key, IntPtr data, IntPtr user_data);
> @@ -136,6 +141,8 @@
>  
>  		AddToAlbum (song, true);
>  
> +		RegisterUniqueness (song);
> +
>  		if (SongAdded != null)
>  			SongAdded (song);
>  	}
> @@ -154,6 +161,8 @@
>  
>  		RemoveFromAlbum (song);
>  
> +		UnregisterUniqueness (song);
> +
>  		song.Dead = true;
>  	}
>  
> @@ -179,6 +188,34 @@
>  			SongChanged (song);
>  	}
>  
> +	private void RegisterUniqueness (Song song)
> +	{
> +		String key = song.UniquenessDeterminantKey;
> +		if (SameArtistCounts[key] != null) {
> +			SameArtistCounts[key] = (int)SameArtistCounts[key] + 1;
> +		} else {
> +			SameArtistCounts[key] = 1;
> +		}
> +	}
> +
> +	private void UnregisterUniqueness (Song song)
> +	{
> +		String key = song.UniquenessDeterminantKey;
> +		if (SameArtistCounts[key] != null) {
> +			SameArtistCounts[key] = (int)SameArtistCounts[key] - 1;
> +		} else {
> +			SameArtistCounts.Remove (key);
> +		}
> +	}
> +
> +	public bool IsUnique (Song song)
> +	{
> +		String key = song.UniquenessDeterminantKey;
> +		if (SameArtistCounts[key] != null && (int)SameArtistCounts[key] > 1)
> +			return false;
> +		return true;
> +	}
> +
>  	/*** album management ***/
>  	public void SyncAlbumCoverImageWithSong (Song song)
>  	{
> _______________________________________________
> muine-list mailing list
> muine-list gnome org
> http://mail.gnome.org/mailman/listinfo/muine-list




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