hi Aaron,
read some great documents. and now i am ready to go :)))
here is a patch file for query builder "perfectly" commitable against BANSHEE_0_9_11.
please ignore alllll previous ones.
Need to read a lot more though :)
Best
Ulas
? player.diff ? player2.diff ? query_BANSHEE_0_9_11.diff ? querybuildercommitable.diff ? burn-sharp/.deps ? burn-sharp/.libs ? burn-sharp/glue.lo ? burn-sharp/libnautilusburnglue.la ? libbanshee/.deps ? libbanshee/.libs ? libbanshee/cd-detect.lo ? libbanshee/cd-rip.lo ? libbanshee/gst-encode.lo ? libbanshee/gst-init.lo ? libbanshee/gst-misc.lo ? libbanshee/gst-player-engine.lo ? libbanshee/libbanshee.la ? libbanshee/xing/.deps ? po/.intltool-merge-cache Index: ChangeLog =================================================================== RCS file: /cvs/gnome/banshee/ChangeLog,v retrieving revision 1.176 diff -r1.176 ChangeLog 0a1,20 > 2005-11-09 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/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 > Index: data/glade/player.glade =================================================================== RCS file: /cvs/gnome/banshee/data/glade/player.glade,v retrieving revision 1.30 diff -r1.30 player.glade 912c912 < <widget class="GtkLabel" id="ViewNameLabel"> --- > <widget class="GtkExpander" id="LibraryExpander"> 914,927c914,964 < <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> 937c974 < <widget class="GtkLabel" id="SearchLabel"> --- > <widget class="GtkVBox" id="SearchVBox"> 939,952c976,1015 < <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> 957c1020 < <property name="fill">False</property> --- > <property name="fill">True</property> Index: src/Library.cs =================================================================== RCS file: /cvs/gnome/banshee/src/Library.cs,v retrieving revision 1.27 diff -r1.27 Library.cs 49a50 > public event EventHandler Queried; 112a114,140 > } > > 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()); Index: src/LibraryTransactions.cs =================================================================== RCS file: /cvs/gnome/banshee/src/LibraryTransactions.cs,v retrieving revision 1.27 diff -r1.27 LibraryTransactions.cs 669a670,734 > 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.PushWarning(Catalog.GetString("Could not load track from library"), > (reader["Uri"] as string) + ": " + e.Message, false); > } > UpdateAverageDuration(startStamp); > } > > } > } > Index: src/PlayerInterface.cs =================================================================== RCS file: /cvs/gnome/banshee/src/PlayerInterface.cs,v retrieving revision 1.90 diff -r1.90 PlayerInterface.cs 80a81 > private SqlBuilderUI query_builder; 154a156,157 > > query_builder.SearchButtonClicked += OnSearchButtonClicked; 364c367,368 < ((HBox)gxml["PlaylistHeaderBox"]).PackStart(searchEntry, --- > /* > ((HBox)gxml["PlaylistHeaderBox"]).PackStart(searchEntry, 365a370,374 > */ > > ((HBox)gxml["SearchHBox"]).PackStart(searchEntry, > false, false, 0); > query_builder = new SqlBuilderUI(((VBox)gxml["QueryBox"])); 546a556,571 > } > > 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(); Index: src/QueryBuilderModel.cs =================================================================== RCS file: /cvs/gnome/banshee/src/QueryBuilderModel.cs,v retrieving revision 1.3 diff -r1.3 QueryBuilderModel.cs 129,130d128 < QueryFilterOperation.Is, < QueryFilterOperation.IsNot, 134c132,134 < QueryFilterOperation.EndsWith --- > QueryFilterOperation.EndsWith, > QueryFilterOperation.Is, > QueryFilterOperation.IsNot 274a275,289 > > private string built_query; > public event EventHandler SearchButtonClicked; > > > public string Query > { > get { > return built_query; > } > > set { > built_query = value; > } > } 300a316,337 > 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; > } > 313c350,355 < Console.WriteLine(query); --- > built_query = query; > > EventHandler handler = SearchButtonClicked; > if(handler != null) > handler(this, new EventArgs()); > 314a357 >