Hi Aaron,
This one will implement the query builder into an expander the way you saw on the screenshot lastnight.
But all tested and bug freed (well hopefully ;) )
This is a very safe patch in order for the appeareance of the app. i am sure some people will not even notice the change at first look.
Well here it goes..
Ulas.
Index: data/glade/player.glade
===================================================================
RCS file: /cvs/gnome/banshee/data/glade/player.glade,v
retrieving revision 1.28
diff -u -r1.28 player.glade
--- data/glade/player.glade 3 Nov 2005 08:04:33 -0000 1.28
+++ data/glade/player.glade 9 Nov 2005 17:36:33 -0000
@@ -17,6 +17,7 @@
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
+ <property name="urgency_hint">False</property>
<signal name="delete_event" handler="OnWindowPlayerDeleteEvent" last_modification_time="Sat, 29 Jan 2005 07:50:08 GMT"/>
<child>
@@ -28,6 +29,8 @@
<child>
<widget class="GtkMenuBar" id="menubar1">
<property name="visible">True</property>
+ <property name="pack_direction">GTK_PACK_DIRECTION_LTR</property>
+ <property name="child_pack_direction">GTK_PACK_DIRECTION_LTR</property>
<child>
<widget class="GtkMenuItem" id="music1">
@@ -896,22 +899,59 @@
<property name="spacing">5</property>
<child>
- <widget class="GtkLabel" id="ViewNameLabel">
+ <widget class="GtkExpander" id="LibraryExpander">
<property name="visible">True</property>
- <property name="label" translatable="yes"><b>Playlist</b></property>
- <property name="use_underline">False</property>
- <property name="use_markup">True</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
+ <property name="can_focus">True</property>
+ <property name="expanded">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkVBox" id="QueryBox">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <placeholder/>
+ </child>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="LibraryBox">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkLabel" id="ViewNameLabel">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Library</b></property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="type">label_item</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="padding">0</property>
@@ -921,27 +961,53 @@
</child>
<child>
- <widget class="GtkLabel" id="SearchLabel">
+ <widget class="GtkVBox" id="SearchVBox">
<property name="visible">True</property>
- <property name="label" translatable="yes">Search:</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
- <property name="width_chars">-1</property>
- <property name="single_line_mode">False</property>
- <property name="angle">0</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkHBox" id="SearchHBox">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkLabel" id="SearchLabel">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Search:</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
- <property name="fill">False</property>
+ <property name="fill">True</property>
</packing>
</child>
</widget>
Index: src/Library.cs
===================================================================
RCS file: /cvs/gnome/banshee/src/Library.cs,v
retrieving revision 1.27
diff -u -r1.27 Library.cs
--- src/Library.cs 31 Oct 2005 05:35:01 -0000 1.27
+++ src/Library.cs 9 Nov 2005 17:36:34 -0000
@@ -47,6 +47,7 @@
public event EventHandler Reloaded;
public event EventHandler Updated;
+ public event EventHandler Queried;
public Library()
{
@@ -110,6 +111,33 @@
playlist.Load();
Playlists[name] = playlist;
}*/
+ }
+
+ public void QueryLibrary(Statement query)
+ {
+ SqlQueryTransaction transaction = new SqlQueryTransaction(query);
+
+ Tracks.Clear();
+ transaction.Finished += OnQueryLibraryFinished;
+ transaction.Register();
+
+ /*string [] names = Playlist.ListAll();
+ if(names == null)
+ return;
+
+ Playlists.Clear();
+ foreach(string name in names) {
+ Playlist playlist = new Playlist(name);
+ playlist.Load();
+ Playlists[name] = playlist;
+ }*/
+ }
+
+ private void OnQueryLibraryFinished(object o, EventArgs args)
+ {
+ EventHandler handler = Queried;
+ if(handler != null)
+ handler(this, new EventArgs());
}
private void OnReloadLibraryFinished(object o, EventArgs args)
Index: src/LibraryTransactions.cs
===================================================================
RCS file: /cvs/gnome/banshee/src/LibraryTransactions.cs,v
retrieving revision 1.24
diff -u -r1.24 LibraryTransactions.cs
--- src/LibraryTransactions.cs 12 Oct 2005 04:04:01 -0000 1.24
+++ src/LibraryTransactions.cs 9 Nov 2005 17:36:35 -0000
@@ -643,6 +643,72 @@
return count;
}
}
+
+ public class SqlQueryTransaction : LibraryTransaction
+ {
+ private string sql;
+
+ public event HaveTrackInfoHandler HaveTrackInfo;
+
+ public override string Name {
+ get {
+ return Catalog.GetString("Library Track Loader");
+ }
+ }
+
+ public SqlQueryTransaction(string sql)
+ {
+ showStatus = false;
+ this.sql = sql;
+ }
+
+ public SqlQueryTransaction(Statement sql) : this(sql.ToString())
+ {
+
+ }
+
+ public override void Run()
+ {
+ totalCount = 0;
+ currentCount = 0;
+ statusMessage = Catalog.GetString("Processing");
+ FilterSql();
+ }
+
+ private void RaiseTrackInfo(TrackInfo ti)
+ {
+ statusMessage = String.Format(
+ Catalog.GetString("Loading {0} - {1} ..."),
+ ti.Artist, ti.Title);
+ currentCount++;
+
+ HaveTrackInfoHandler handler = HaveTrackInfo;
+ if(handler != null) {
+ HaveTrackInfoArgs args = new HaveTrackInfoArgs();
+ args.TrackInfo = ti;
+ handler(this, args);
+ }
+ }
+
+ private void FilterSql()
+ {
+ IDataReader reader = Core.Library.Db.Query(sql);
+ while(reader.Read() && !cancelRequested) {
+ DateTime startStamp = DateTime.Now;
+ int tid = Convert.ToInt32(reader[0]);
+ TrackInfo ti = Core.Library.Tracks[tid] as TrackInfo;
+ try {
+ new LibraryTrackInfo(reader);
+ } catch(Exception e) {
+ Core.Log.Push(LogEntryType.Warning,
+ Catalog.GetString("Could not load track from library"),
+ (reader["Uri"] as string) + ": " + e.Message);
+ }
+ UpdateAverageDuration(startStamp);
+ }
+
+ }
+ }
public class TrackInfoSaveTransaction : LibraryTransaction
{
@@ -709,11 +775,17 @@
+ new Where("PlaylistId", Op.EqualTo, id);
IDataReader reader = Core.Library.Db.Query(query);
while(reader.Read() && !cancelRequested) {
- DateTime startStamp = DateTime.Now;
- int tid = Convert.ToInt32(reader[0]);
- TrackInfo ti = Core.Library.Tracks[tid] as TrackInfo;
- RaiseTrackInfo(ti);
- UpdateAverageDuration(startStamp);
+ try {
+ DateTime startStamp = DateTime.Now;
+ int tid = Convert.ToInt32(reader[0]);
+ TrackInfo ti = Core.Library.Tracks[tid] as TrackInfo;
+ RaiseTrackInfo(ti);
+ UpdateAverageDuration(startStamp);
+ } catch(Exception e) {
+ //The Catalog must be updated with a new warning "The track is either blocked by query filter or removed from library."
+ Core.Log.Push(LogEntryType.Warning,
+ Catalog.GetString("Could not load track from library"),("The reason is: " + e.Message ));
+ }
}
}
Index: src/PlayerInterface.cs
===================================================================
RCS file: /cvs/gnome/banshee/src/PlayerInterface.cs,v
retrieving revision 1.86
diff -u -r1.86 PlayerInterface.cs
--- src/PlayerInterface.cs 3 Nov 2005 08:04:32 -0000 1.86
+++ src/PlayerInterface.cs 9 Nov 2005 17:36:38 -0000
@@ -77,6 +77,7 @@
private Viewport sourceViewLoadingVP;
private Button ipodSyncButton;
private CoverArtThumbnail cover_art;
+ private SqlBuilderUI query_builder;
private bool incrementedCurrentSongPlayCount;
@@ -150,6 +151,8 @@
Core.Instance.AudioCdCore.Updated += OnAudioCdCoreUpdated;
Core.Instance.IpodCore.DeviceAdded += OnIpodCoreDeviceAdded;
+
+ query_builder.SearchButtonClicked += OnSearchButtonClicked;
LoadSettings();
Core.Instance.PlayerInterface = this;
@@ -359,8 +362,14 @@
searchEntry.EnterPress += OnSimpleSearch;
searchEntry.Changed += OnSimpleSearch;
searchEntry.Show();
+ /*
((HBox)gxml["PlaylistHeaderBox"]).PackStart(searchEntry,
false, false, 0);
+ */
+
+ ((HBox)gxml["SearchHBox"]).PackStart(searchEntry,
+ false, false, 0);
+ query_builder = new SqlBuilderUI(((VBox)gxml["QueryBox"]));
toolTips = new Tooltips();
SetTip(gxml["ButtonNewPlaylist"], Catalog.GetString("Create New Playlist"));
@@ -542,6 +551,22 @@
PromptForImport();
});
}
+ }
+
+ private void OnSearchButtonClicked(object o, EventArgs args)
+ {
+ string query = query_builder.Query;
+ //Output query for debug purposes until querybuilder matures enough.
+ Console.WriteLine(query);
+ Statement query_statement = new Statement(query);
+ Core.Library.Queried += OnLibraryQueried;
+ Core.Library.QueryLibrary(query_statement);
+ }
+
+ private void OnLibraryQueried(object o, EventArgs args)
+ {
+ //Check if there is a better way of handling this event.
+ sourceView.SelectLibraryForce();
}
private bool PromptForImportTimeout()
Index: src/QueryBuilderModel.cs
===================================================================
RCS file: /cvs/gnome/banshee/src/QueryBuilderModel.cs,v
retrieving revision 1.3
diff -u -r1.3 QueryBuilderModel.cs
--- src/QueryBuilderModel.cs 31 Aug 2005 07:59:08 -0000 1.3
+++ src/QueryBuilderModel.cs 9 Nov 2005 17:36:38 -0000
@@ -126,12 +126,12 @@
{
get {
string [] validOperations = {
- QueryFilterOperation.Is,
- QueryFilterOperation.IsNot,
QueryFilterOperation.Contains,
QueryFilterOperation.DoesNotContain,
QueryFilterOperation.StartsWith,
- QueryFilterOperation.EndsWith
+ QueryFilterOperation.EndsWith,
+ QueryFilterOperation.Is,
+ QueryFilterOperation.IsNot
};
return validOperations;
@@ -272,6 +272,21 @@
{
private QueryBuilder builder;
private TracksQueryModel model;
+
+ private string built_query;
+ public event EventHandler SearchButtonClicked;
+
+
+ public string Query
+ {
+ get {
+ return built_query;
+ }
+
+ set {
+ built_query = value;
+ }
+ }
public SqlBuilderUI()
{
@@ -298,6 +313,28 @@
btn.Clicked += OnButtonClicked;
}
+ public SqlBuilderUI(VBox parentVBox)
+ {
+ parentVBox.Show();
+
+ VBox box = new VBox();
+ box.Show();
+ parentVBox.Add(box);
+ box.Spacing = 10;
+
+ model = new TracksQueryModel();
+ builder = new QueryBuilder(model);
+ builder.Show();
+ builder.Spacing = 4;
+
+ box.PackStart(builder, true, true, 0);
+
+ Button btn = new Button("Search");
+ btn.Show();
+ box.PackStart(btn, false, false, 0);
+ btn.Clicked += OnButtonClicked;
+ }
+
private void OnButtonClicked(object o, EventArgs args)
{
string query = "SELECT * FROM Tracks";
@@ -310,7 +347,13 @@
if(builder.Limit && builder.LimitNumber > 0)
query += " LIMIT " + builder.LimitNumber;
- Console.WriteLine(query);
+ built_query = query;
+
+ EventHandler handler = SearchButtonClicked;
+ if(handler != null)
+ handler(this, new EventArgs());
+
}
+
}
}
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/banshee/ChangeLog,v
retrieving revision 1.165
diff -u -r1.165 ChangeLog
--- ChangeLog 9 Nov 2005 00:36:08 -0000 1.165
+++ ChangeLog 9 Nov 2005 17:36:40 -0000
@@ -1,3 +1,25 @@
+2005-09-11 Aydemir Ulas Sahin <ulas arttek com tr>
+
+ *data/glade/player.glade: new widgets and containers for the querybuilder expander.
+ *src/Library.cs: new QueryLibrary method to start a new SQLQueryTransaction and
+ eventhandler Queried.
+ *src/LibraryTransactions.cs: new class SqlQueryTransaction : LibraryTransaction to
+ handle querying transactions.
+ *src/LibraryTransactions.cs: possible showstopper bug fix in class
+ PlaylistLoadTransaction : LibraryTransaction Run() Method.
+
+ *src/PlayerInterface.cs: new SqlBuilderUI query_builder propetry for the expander widget and
+ searchbuttonclicked eventhandler.
+ *src/PlayerInterface.cs: searchEntry goes into its new home SearchHBox
+ *src/PlayerInterface.cs: OnSearchButtonClicked callback function and OnLibraryQueried
+ callback implementation.
+
+ *src/QueryBuilderModel.cs: new property and handler (built_query, SearchButtonClicked) for SqlBuilderUI
+ *src/QueryBuilderModel.cs: new constructor SqlBuilderUI(VBox parentVBox) to enable
+ builder to go into expander.
+ *src/QueryBuilderModel.cs: fixed OnButtonClicked method to not only build the query
+ but send an event to the PlayerInterface for transactions to begin
+
2005-11-08 Aaron Bockover <aaron aaronbock net>
* src/Preferences.cs: