Re: [Muine] NEW PRERELEASE: 0.8.0pre4
- From: Tom Coleman <tmcol bigpond net au>
- To: Muine List <muine-list gnome org>
- Subject: Re: [Muine] NEW PRERELEASE: 0.8.0pre4
- Date: Sun, 09 Jan 2005 12:31:45 +1100
Hey,
> - Support for cover images on single/album-less files [Jorn Baayen]
Attached is the patch I mentioned earlier -- it is against the current
anoncvs, which isn't up to date with this prerelease yet...
It takes a slightly different approach and rather than tagging songs as
album-less, it tags albums as incomplete.. either way seems good to
me...
Also it contains some clean up inside Add*Window so it may be worth
committing that part alone.
Let me know what you think.. suggestions etc. appreciated as my C#
experience is very limited.
Thanks,
Tom
? incomplete_albums.patch
? DBusLib/muine-dbus.dll.mdb
? PluginLib/muine-plugin.dll.mdb
? plugins/DashboardPlugin.dll.mdb
? src/muine.exe.mdb
Index: data/muine.schemas.in
===================================================================
RCS file: /cvs/gnome/muine/data/muine.schemas.in,v
retrieving revision 1.16
diff -a -u -r1.16 muine.schemas.in
--- data/muine.schemas.in 13 Dec 2004 14:59:58 -0000 1.16
+++ data/muine.schemas.in 9 Jan 2005 01:25:42 -0000
@@ -135,6 +135,18 @@
</locale>
</schema>
<schema>
+ <key>/schemas/apps/muine/non_album_folders</key>
+ <applyto>/apps/muine/non_album_folders</applyto>
+ <owner>muine</owner>
+ <type>list</type>
+ <list_type>string</list_type>
+ <default>[]</default>
+ <locale name="C">
+ <short>Non album folders</short>
+ <long>Folders that don't contain entire albums.</long>
+ </locale>
+ </schema>
+ <schema>
<key>/schemas/apps/muine/default_import_folder</key>
<applyto>/apps/muine/default_import_folder</applyto>
<owner>muine</owner>
Index: src/AddAlbumWindow.cs
===================================================================
RCS file: /cvs/gnome/muine/src/AddAlbumWindow.cs,v
retrieving revision 1.56
diff -a -u -r1.56 AddAlbumWindow.cs
--- src/AddAlbumWindow.cs 7 Jan 2005 03:01:44 -0000 1.56
+++ src/AddAlbumWindow.cs 9 Jan 2005 01:25:43 -0000
@@ -67,13 +67,11 @@
Muine.CoverDB.DoneLoading += new CoverDatabase.DoneLoadingHandler (OnCoversDoneLoading);
- foreach (Album a in Muine.DB.Albums.Values)
- view.Append (a.Handle);
- SelectFirst ();
-
view.DragDataReceived += new DragDataReceivedHandler (OnDragDataReceived);
Gtk.Drag.DestSet (view, DestDefaults.All,
CoverImage.DragEntries, Gdk.DragAction.Copy);
+
+ Reset ();
}
private int SortFunc (IntPtr a_ptr,
@@ -118,41 +116,25 @@
false, true, false);
}
- protected override bool Search ()
- {
- List l = new List (IntPtr.Zero, typeof (int));
-
- if (search_entry.Text.Length > 0) {
- foreach (Album a in Muine.DB.Albums.Values) {
- if (a.FitsCriteria (SearchBits))
- l.Append (a.Handle);
- }
- } else {
- foreach (Album a in Muine.DB.Albums.Values)
- l.Append (a.Handle);
- }
-
- view.RemoveDelta (l);
+ protected override Item [] PotentialItems {
+ get {
+ // filter out all non-complete albums
+ ArrayList items = new ArrayList ();
+ foreach (Album album in Muine.DB.Albums.Values)
+ if (album.Complete)
+ items.Add (album);
+ return (Item []) items.ToArray (typeof (Item));
+ }
+ }
- foreach (int i in l) {
- IntPtr ptr = new IntPtr (i);
-
- view.Append (ptr);
- }
-
- SelectFirst ();
-
- return false;
- }
-
private void OnAlbumAdded (Album album)
{
- base.HandleAdded (album.Handle, album.FitsCriteria (SearchBits));
+ base.HandleAdded (album.Handle, album.FitsCriteria (SearchBits) && album.Complete);
}
private void OnAlbumChanged (Album album)
{
- base.HandleChanged (album.Handle, album.FitsCriteria (SearchBits));
+ base.HandleChanged (album.Handle, album.FitsCriteria (SearchBits) && album.Complete);
}
private void OnAlbumRemoved (Album album)
Index: src/AddSongWindow.cs
===================================================================
RCS file: /cvs/gnome/muine/src/AddSongWindow.cs,v
retrieving revision 1.51
diff -a -u -r1.51 AddSongWindow.cs
--- src/AddSongWindow.cs 7 Jan 2005 01:28:37 -0000 1.51
+++ src/AddSongWindow.cs 9 Jan 2005 01:25:44 -0000
@@ -29,8 +29,14 @@
{
public class AddSongWindow : AddWindow
{
- private const int FakeLength = 150;
- private const int MinQueryLength = 3;
+ private const int fake_length = 150;
+ protected override int FakeLength {
+ get { return fake_length; }
+ }
+ private const int min_query_length = 3;
+ protected override int MinQueryLength {
+ get { return min_query_length; }
+ }
private const string GConfKeyWidth = "/apps/muine/add_song_window/width";
private const int GConfDefaultWidth = 500;
@@ -62,14 +68,7 @@
Muine.DB.SongChanged += new SongDatabase.SongChangedHandler (OnSongChanged);
Muine.DB.SongRemoved += new SongDatabase.SongRemovedHandler (OnSongRemoved);
- int i = 0;
- foreach (Song s in Muine.DB.Songs.Values) {
- view.Append (s.Handle);
-
- i++;
- if (i >= FakeLength)
- break;
- }
+ Reset ();
}
private int SortFunc (IntPtr a_ptr,
@@ -94,50 +93,15 @@
false, true, false);
}
- protected override bool Search ()
- {
- List l = new List (IntPtr.Zero, typeof (int));
-
- int max_len = -1;
-
- /* show max. FakeLength songs if < MinQueryLength chars are entered. this is to fake speed. */
- if (search_entry.Text.Length < MinQueryLength)
- max_len = FakeLength;
-
- int i = 0;
- if (search_entry.Text.Length > 0) {
- foreach (Song s in Muine.DB.Songs.Values) {
- if (!s.FitsCriteria (SearchBits))
- continue;
-
- l.Append (s.Handle);
-
- i++;
- if (max_len > 0 && i >= max_len)
- break;
- }
- } else {
- foreach (Song s in Muine.DB.Songs.Values) {
- l.Append (s.Handle);
-
- i++;
- if (max_len > 0 && i >= max_len)
- break;
- }
- }
-
- view.RemoveDelta (l);
-
- foreach (int p in l) {
- IntPtr ptr = new IntPtr (p);
-
- view.Append (ptr);
- }
-
- SelectFirst ();
-
- return false;
- }
+ protected override Item [] PotentialItems {
+ get {
+ // filter out all non-complete albums
+ ArrayList items = new ArrayList ();
+ foreach (Song song in Muine.DB.Songs.Values)
+ items.Add (song);
+ return (Item []) items.ToArray (typeof (Item));
+ }
+ }
private void OnSongAdded (Song song)
{
Index: src/AddWindow.cs
===================================================================
RCS file: /cvs/gnome/muine/src/AddWindow.cs,v
retrieving revision 1.5
diff -a -u -r1.5 AddWindow.cs
--- src/AddWindow.cs 7 Jan 2005 01:28:37 -0000 1.5
+++ src/AddWindow.cs 9 Jan 2005 01:25:44 -0000
@@ -20,6 +20,7 @@
using System;
using Gtk;
+using GLib;
namespace Muine
{
@@ -52,6 +53,16 @@
protected HandleView view = new HandleView ();
protected CellRenderer text_renderer = new CellRendererText ();
+ // Override these to limit number of items searched (see AddSongWindow)
+ private const int fake_length = 0;
+ protected virtual int FakeLength {
+ get { return fake_length; }
+ }
+ private const int min_query_length = -1;
+ protected virtual int MinQueryLength {
+ get { return min_query_length; }
+ }
+
// Variables
private string gconf_key_width, gconf_key_height;
private int gconf_default_width, gconf_default_height;
@@ -59,6 +70,11 @@
private bool process_changes_immediately = false;
private uint search_idle_id = 0;
+ // Abstract member variables
+ protected abstract Item [] PotentialItems {
+ get;
+ }
+
// Constructor
public AddWindow () : base (IntPtr.Zero)
{
@@ -94,9 +110,6 @@
}
}
- // Abstract methods
- protected abstract bool Search ();
-
// Public Methods
public void Run ()
{
@@ -143,10 +156,50 @@
{
process_changes_immediately = true;
- search_entry.Text = "";
+ // to avoid two OnSearchEntryChanged events
+ if (search_entry.Text != "")
+ search_entry.Text = "";
+ else // is this the right way to fire the event?
+ OnSearchEntryChanged (search_entry, null);
process_changes_immediately = false;
}
+
+ protected bool Search ()
+ {
+ List l = new List (IntPtr.Zero, typeof (int));
+
+ int max_len = -1;
+
+ /* show max. FakeLength songs if < MinQueryLength chars are entered. this is to fake speed. */
+ if (search_entry.Text.Length < MinQueryLength)
+ max_len = FakeLength;
+
+ int i = 0;
+ foreach (Item item in PotentialItems) {
+ if (!item.FitsCriteria (SearchBits))
+ continue;
+
+ l.Append (item.Handle);
+
+ i++;
+ if (max_len != -1 && i >= max_len)
+ break;
+ }
+
+ view.RemoveDelta (l);
+
+ foreach (int p in l) {
+ IntPtr ptr = new IntPtr (p);
+
+ view.Append (ptr);
+ }
+
+ SelectFirst ();
+
+ return false;
+
+ }
// Private Methods
// Private Methods :: Assertions
Index: src/Album.cs
===================================================================
RCS file: /cvs/gnome/muine/src/Album.cs,v
retrieving revision 1.34
diff -a -u -r1.34 Album.cs
--- src/Album.cs 7 Jan 2005 05:47:18 -0000 1.34
+++ src/Album.cs 9 Jan 2005 01:25:45 -0000
@@ -28,6 +28,10 @@
{
public class Album : Item
{
+ private const string GConfKeyNonAlbumFolders = "/apps/muine/non_album_folders";
+ private readonly string [] GConfDefaultNonAlbumFolders = new string [0];
+ private string [] non_album_folders = new string [0];
+
private string name;
public string Name {
get { return name; }
@@ -79,6 +83,13 @@
}
}
+ // is this album from the 'non_album_folders' directory?
+ private bool complete = true;
+ public bool Complete {
+ get { return complete; }
+ }
+
+
private static string [] prefixes = null;
public Album (Song initial_song)
@@ -97,6 +108,13 @@
folder = initial_song.Folder;
+ // work out which folders we are ignoring for albums
+ non_album_folders = (string []) Config.Get (GConfKeyNonAlbumFolders, GConfDefaultNonAlbumFolders);
+
+ foreach (string check_folder in non_album_folders)
+ if (folder.StartsWith (check_folder))
+ complete = false;
+
cur_ptr = new IntPtr (((int) cur_ptr) + 1);
pointers [cur_ptr] = this;
base.handle = cur_ptr;
@@ -210,7 +228,7 @@
return true;
}
- public bool FitsCriteria (string [] search_bits)
+ public override bool FitsCriteria (string [] search_bits)
{
int n_matches = 0;
Index: src/Item.cs
===================================================================
RCS file: /cvs/gnome/muine/src/Item.cs,v
retrieving revision 1.1
diff -a -u -r1.1 Item.cs
--- src/Item.cs 7 Jan 2005 05:47:18 -0000 1.1
+++ src/Item.cs 9 Jan 2005 01:25:45 -0000
@@ -30,7 +30,7 @@
// Properties
// Properties :: Handle (get;)
- public IntPtr Handle {
+ public virtual IntPtr Handle {
get { return handle; }
}
@@ -57,6 +57,7 @@
// Methods :: Abstract
protected abstract string GenerateSortKey ();
protected abstract string GenerateSearchKey ();
+ public abstract bool FitsCriteria (string [] search_bits);
// Methods :: Public
public int CompareTo (object o)
Index: src/Song.cs
===================================================================
RCS file: /cvs/gnome/muine/src/Song.cs,v
retrieving revision 1.63
diff -a -u -r1.63 Song.cs
--- src/Song.cs 7 Jan 2005 05:47:18 -0000 1.63
+++ src/Song.cs 9 Jan 2005 01:25:45 -0000
@@ -144,7 +144,7 @@
get { return dead; }
}
- public new IntPtr Handle {
+ public override IntPtr Handle {
get { return (IntPtr) handles [0]; }
}
@@ -305,7 +305,7 @@
return (Song) pointers [handle];
}
- public bool FitsCriteria (string [] search_bits)
+ public override bool FitsCriteria (string [] search_bits)
{
int n_matches = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]