import gtk, gobject
from mutagen_backend import MutagenBackend
from player_backend import MediaPlayer
+from utils import escape_html
import album_art_spec
import os
# Fields in the tuple!
-FILE_URI = 0
-ARTIST_KEY = 2
-TITLE_KEY = 3
-ALBUM_KEY = 4
-MIME_KEY = 5
+# Shared with browse_panel
+URI_COLUMN = 0
+ARTIST_COLUMN = 2
+TITLE_COLUMN = 3
+ALBUM_COLUMN = 4
+MIME_COLUMN = 5
+UI_COLUMN = 6
+SEARCH_COLUMN = 7
class MussorgskyEditPanel (hildon.StackableWindow):
self.current = self.model.iter_next (self.current)
if (not self.current):
- print "Destroy"
self.destroy ()
else:
self.set_data_in_view (self.get_current_row ())
# 1 - "Music" -> doesn't change
# 5 - mimetype -> doesn't change
if (type (self.model) == gtk.TreeModelFilter):
- print "Ye un filtered"
m = self.model.get_model ()
c = self.model.convert_iter_to_child_iter (self.current)
else:
m = self.model
c = self.current
+ artist = self.artist_button.get_value ()
+ title = self.title_entry.get_text ()
+ album = self.album_button.get_value ()
+ text = "<b>%s</b>\n<small>%s</small>" % (escape_html (title),
+ escape_html (artist) + " / " + escape_html (album))
+ search_str = artist.lower () + " " + title.lower () + " " + album.lower ()
+
m.set (c,
- 2, self.artist_button.get_value (),
- 3, self.title_entry.get_text (),
- 4, self.album_button.get_value ())
+ ARTIST_COLUMN, artist,
+ TITLE_COLUMN, title,
+ ALBUM_COLUMN, album,
+ UI_COLUMN, text,
+ SEARCH_COLUMN, search_str)
new_song = self.get_current_row ()
try:
- self.writer.save_metadata_on_file (new_song[FILE_URI],
- new_song[MIME_KEY],
+ self.writer.save_metadata_on_file (new_song[URI_COLUMN],
+ new_song[MIME_COLUMN],
self.artist_button.get_value (),
self.title_entry.get_text (),
self.album_button.get_value ())
"""
song = self.get_current_row ()
- return not (self.filename_data.get_text() == song[FILE_URI] and
- self.artist_button.get_value () == song[ARTIST_KEY] and
- self.title_entry.get_text () == song[TITLE_KEY] and
- self.album_button.get_value () == song[ALBUM_KEY] )
+ return not (self.filename_data.get_text() == song[URI_COLUMN] and
+ self.artist_button.get_value () == song[ARTIST_COLUMN] and
+ self.title_entry.get_text () == song[TITLE_COLUMN] and
+ self.album_button.get_value () == song[ALBUM_COLUMN] )
def __create_view (self):
"""
assert len (song) == 6
- self.filename_data.set_markup ("<small>" + song[FILE_URI] + "</small>")
- self.title_entry.set_text (song[TITLE_KEY])
+ self.filename_data.set_markup ("<small>" + song[URI_COLUMN] + "</small>")
+ self.title_entry.set_text (song[TITLE_COLUMN])
# Disconnect the value-change signal to avoid extra album art retrievals
# Set values in the picker buttons
try:
- self.artist_button.set_active (self.artists_list.index(song[ARTIST_KEY]))
+ self.artist_button.set_active (self.artists_list.index(song[ARTIST_COLUMN]))
except ValueError:
- print "'%s' not in artist list!?" % (song[ARTIST_KEY])
+ print "'%s' not in artist list!?" % (song[ARTIST_COLUMN])
self.artist_button.set_value ("")
except AttributeError:
print "WARNING: Use set_artist_alternatives method to set a list of artists"
try:
- self.album_button.set_active (self.albums_list.index (song[ALBUM_KEY]))
+ self.album_button.set_active (self.albums_list.index (song[ALBUM_COLUMN]))
except ValueError:
- print "'%s' is not in the album list!?" % (song[ALBUM_KEY])
+ print "'%s' is not in the album list!?" % (song[ALBUM_COLUMN])
self.album_button.set_value ("")
except AttributeError:
print "WARNING: Use set_album_alternatives method to set a list of artists"
self.artist_selection_cb)
# Set the album art given the current data
- self.set_album_art (song[ALBUM_KEY])
+ self.set_album_art (song[ALBUM_COLUMN])
- if (not song[MIME_KEY] in self.writer.get_supported_mimes ()):
+ if (not song[MIME_COLUMN] in self.writer.get_supported_mimes ()):
self.artist_button.set_sensitive (False)
self.album_button.set_sensitive (False)
self.title_entry.set_sensitive (False)
self.player.stop ()
else:
song = self.songs_list [self.song_counter]
- self.player.play ("file://" + song[FILE_URI])
+ self.player.play ("file://" + song[URI_COLUMN])
def album_selection_cb (self, widget):
"""