summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/grux.rb56
1 files changed, 46 insertions, 10 deletions
diff --git a/bin/grux.rb b/bin/grux.rb
index ea75e69..954ea5f 100755
--- a/bin/grux.rb
+++ b/bin/grux.rb
@@ -73,13 +73,23 @@ class Grux::ClientWin < Gtk::VBox
@toolTabs = [
[ @extinfoTab = Gtk::VBox.new,
@extinfoTabLbl = Gtk::Label.new( "Status" ) ],
- [ @tageditorTab = Gtk::VBox.new,
- @tageditorTabLbl = Gtk::Label.new( "Tag Editor" ) ]
+ [ @tageditorTab = Gtk::VBox.new,
+ @tageditorTabLbl = Gtk::Label.new( "Tag Editor" ) ],
+ [ @searchTab = Gtk::VBox.new,
+ @searchTabLbl = Gtk::Label.new( "Search" ) ]
]
@toolTabs.each do |content, label|
@toolChsr.append_page( Gtk::ScrolledWindow.new.add_with_viewport( content ), label )
end
+ @searchTabItems = [
+ @searchTermEntry = Gtk::Entry.new,
+ @startsearchBtn = Gtk::Button.new( "Search" )
+ ]
+ @searchTabItems.each do |wdgt|
+ @searchTab.pack_start( wdgt )
+ end
+
@medialistTextRenderer = Gtk::CellRendererText.new
@medialistColumns = [ 'id', 'artist', 'title' ]
@@ -89,12 +99,17 @@ class Grux::ClientWin < Gtk::VBox
@playlistViewWin = Gtk::ScrolledWindow.new,
@playlistView = Gtk::TreeView.new,
@playlistStore = Gtk::ListStore.new( String, String, String )
- ],
+ ],
[ @medialibViewLbl = Gtk::Label.new( "Medialib" ),
@medialibViewWin = Gtk::ScrolledWindow.new,
@medialibView = Gtk::TreeView.new,
@medialibStore = Gtk::ListStore.new( String, String, String )
- ]
+ ],
+ [ @searchResultViewLbl = Gtk::Label.new( "Search Results" ),
+ @searchResultViewWin = Gtk::ScrolledWindow.new,
+ @searchResultView = Gtk::TreeView.new,
+ @searchResultStore = Gtk::ListStore.new( String, String, String )
+ ]
]
@medialists.each do |label, window, view, store|
@@ -134,6 +149,23 @@ class Grux::ClientWin < Gtk::VBox
self.toggle_repeat_one
end
+ @startsearchBtn.signal_connect :clicked do
+ searchregex = Regexp.new( /#{@searchTermEntry.text}/ix )
+ results = []
+ @status[:medialib].each_with_index do |songinfo, id|
+ songinfo && songinfo.each do |key, info|
+ info.each do |src, value|
+ if searchregex.match( value.to_s )
+ results << id
+ break
+ end
+ end
+ end
+ end
+ searchResultIds, searchResult = self.xmmspls_to_lststor( results.uniq!, @searchResultStore )
+ @searchResultView.model = searchResult
+ end
+
@playlistView.signal_connect :row_activated do |view, path, column|
@server.playlist_set_next( path.to_str.to_i ).notifier do
@@ -261,7 +293,7 @@ class Grux::ClientWin < Gtk::VBox
def handle_playback_current_id( id )
p "Current playback ID changed: #{id}"
- songpath = Gtk::TreePath.new( @status[:playlist].index id )
+ songpath = Gtk::TreePath.new( @status[:playlistids].index id )
@playlistView.scroll_to_cell( songpath, nil, true, 0.5, 0.5 )
@playlistView.set_cursor( songpath, nil, false )
@@ -343,16 +375,19 @@ class Grux::ClientWin < Gtk::VBox
def xmmspls_to_lststor( songids, store )
+ songinfos = []
+ store.clear
songids.each do |id|
current_row = store.append
@server.medialib_get_info( id ).notifier do |songinfo|
+ songinfos[id] = songinfo
current_row[0] = id.to_s
current_row[1] = songinfo[:artist] ? songinfo[:artist].first[1] : ""
current_row[2] = songinfo[:title] ? songinfo[:title].first[1] : ""
true
end
end
- store
+ return [songinfos, store]
end
@@ -505,14 +540,15 @@ class Grux::ClientWin < Gtk::VBox
def resync_complete
- @server.playlist.entries.notifier do |playlist|
- @status[:playlist] = playlist
- @playlistView.model = self.xmmspls_to_lststor( playlist, @playlistStore )
+ @server.playlist.entries.notifier do |playlistids|
+ @status[:playlistids] = playlistids
+ @status[:playlist], @playlistView.model = self.xmmspls_to_lststor( playlistids, @playlistStore )
true
end
@server.coll_query_ids( Xmms::Collection.universe ).notifier do |medialibids|
- @medialibView.model = self.xmmspls_to_lststor( medialibids, @medialibStore )
+ @status[:medialibids] = medialibids
+ @status[:medialib], @medialibView.model = self.xmmspls_to_lststor( medialibids, @medialibStore )
true
end