32
32
if (caller.rating_width != caller.old_r_w and caller.rating_width != 0):
33
33
caller.rating_images = []
34
star_size = caller.rating_width / 4
34
star_size = caller.rating_width / 5
36
36
star = gtk.gdk.pixbuf_new_from_file_at_size(
37
37
xl.path.get_data('images', 'star.png'), star_size, star_size)
41
39
full_image = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, caller.rating_width, star_size)
42
40
full_image.fill(0xffffff00) # transparent white
44
42
star.copy_area(0, 0, star_size, star_size, full_image, star_size * x, 0)
45
43
caller.rating_images.insert(0, full_image)
46
for x in range(7, 0, -1):
44
for x in range(5, 0, -1):
47
45
this_image = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, caller.rating_width, star_size)
48
46
this_image.fill(0xffffff00) # transparent white
49
full_image.copy_area(0, 0, int(x * star_size / 2.0), star_size, this_image, 0, 0)
47
full_image.copy_area(0, 0, int(x * star_size), star_size, this_image, 0, 0)
50
48
caller.rating_images.insert(0, this_image)
51
49
caller.old_r_w = caller.rating_width
75
73
Column('album', _('Album'), 150),
76
74
Column('length', _('Length'), 50),
77
75
Column('disc_id', _('Disc'), 30),
78
Column('rating', _('Rating'), 80),
76
Column('rating', _('Rating'), 64),
79
77
Column('year', _('Year'), 50),
80
78
Column('genre', _('Genre'), 100),
81
79
Column('bitrate', _('Bitrate'), 30),
107
105
self.exaile = exaile
108
106
self.list = xlmisc.DragTreeView(self)
109
107
self.list.set_rules_hint(True)
110
self.list.set_enable_search(False)
108
self.list.set_enable_search(True)
111
109
self.songs = library.TrackData()
113
111
self.scroll = gtk.ScrolledWindow()
134
132
self.plugins_item = None
135
133
self.setup_columns()
137
136
create_rating_images(self)
144
140
def close_page(self):
146
142
Called when this page in the notebook is closed
144
#Save the playlist order to the db
145
cur = self.db.cursor()
147
for track in self.songs:
148
if track.type == 'stream': continue
149
path_id = library.get_column_id(self.db, 'paths', 'name', track.loc)
150
self.db.execute("UPDATE playlist_items SET sort_index=? " \
151
"WHERE playlist_items.path=?"
152
, (sort_index,path_id) )
153
sort_index = sort_index + 1
150
156
def drag_data_received(self, tv, context, x, y, selection, info, etime):
451
457
path = pathlist[0]
452
458
if path[0] >= len(self.songs): path = (path[0] - 1,)
453
459
selection.select_path(path)
455
elif event.keyval == gtk.keysyms.q and self.type != 'queue':
456
for path in pathlist:
457
iter = model.get_iter(path)
458
track = model.get_value(iter, 0)
459
if not track in self.exaile.player.queued:
460
self.exaile.player.queued.append(track)
462
self.exaile.player.queued.remove(track)
464
461
update_queued(self.exaile)
465
462
self.queue_draw()
588
587
if col_struct.id in ('track', 'playcount'):
589
588
cellr.set_property('xalign', 1.0)
590
# Update which column to search for when columns are changed
591
if col_struct.display == search_column:
592
self.list.set_search_column(count)
591
593
col.set_widget(gtk.Label(col_struct.display))
592
594
col.get_widget().show()
593
595
self.list.append_column(col)
667
669
def rating_data_func(self, col, cell, model, iter):
668
670
item = model.get_value(iter, 0)
669
if not item.rating: return
670
idx = len(item.rating) / 2 - 1
671
cell.set_property('pixbuf', self.rating_images[idx])
671
if not item._rating: return
673
idx = item._rating - 1
674
cell.set_property('pixbuf', self.rating_images[idx])
677
elif idx < 0: idx = 0
673
679
def set_cell_weight(self, cell, item):
819
825
Sets the songs in this table (expects a list of tracks)
821
827
self.songs = library.TrackData()
828
search_column = self.exaile.settings.get_str("ui/search_column","Title")
823
829
# save sort indicators, because they get reset when you set the model
825
831
self.model.clear()
829
835
self.list.set_model(self.model_blank)
830
836
if update_playlist: self.playlist_songs = songs
831
837
for song in songs:
832
self.append_song(song)
838
self.append_song(song,False)
834
841
self.list.set_model(self.model)
835
843
for col in self.list.get_columns():
836
844
col.set_sort_indicator(indicators[col.get_title()])
845
# We have to set search_column here because the model was cleared
846
if col.get_title() == search_column:
847
self.list.set_search_column(count)
838
850
def get_ar(self, song):
844
856
ar.append(getattr(song, field))
847
def append_song(self, song):
859
def append_song(self, song, append_to_list = True):
849
861
Adds a song to this view
851
863
ar = self.get_ar(song)
853
865
self.model.append(ar)
854
if not song in self.songs: self.songs.append(song)
866
if append_to_list: self.songs.append(song)
856
868
def update_iter(self, iter, song):
929
941
editor.TrackEditor(self.exaile, self), 'gtk-edit')
931
943
rm = xlmisc.Menu()
934
for i in range(0, 8):
935
item = rm.append_image(self.rating_images[i],
936
lambda w, e, i=i: editor.update_rating(self, i))
945
for i in range(0, 5):
947
item = rm.append('-', lambda w, e, i=i:
948
editor.update_rating(self, i))
950
item = rm.append_image(self.rating_images[i],
951
lambda w, e, i=i: editor.update_rating(self, i))
938
953
star_icon = gtk.gdk.pixbuf_new_from_file_at_size(
939
954
xl.path.get_data('images', 'star.png'), 16, 16)
1070
1085
The popup menu that is displayed when you right click in the
1073
if not event.button == 3: return
1088
if not event.button == 3:
1089
try: path, col, cellx, celly = self.list.get_path_at_pos(int(event.x),
1092
xlmisc.log_exception()
1095
if col.get_title() == _('Rating'):
1096
count = int(float(cellx + 5) / (float(self.rating_width / 5)))
1099
print path, col, cellx, celly, col.get_title()
1074
1101
selection = self.list.get_selection()
1075
1102
self.setup_tracks_menu()