Ticket #612: dynamically_color_playlist.patch
| File dynamically_color_playlist.patch, 4.2 kB (added by zdogde, 21 months ago) |
|---|
-
src/config.py
71 71 "web_font":"Sans 12", 72 72 "notification" : "true", 73 73 "compact_playlist" : "false", 74 "dynamic_playlist_color": "false", 74 75 "offline" : "false" 75 76 }, 76 77 "dynamic_mode":{ -
src/widget/player_playlist.py
20 20 # 21 21 ### 22 22 23 23 import colorsys, string 24 24 import gtk, pango 25 25 import urllib, random, threading 26 26 … … 472 472 if song.get_str("album")!="": 473 473 text += sep+song.get_str("album",True) 474 474 text += "</span>" 475 if config.getboolean("setting", "dynamic_playlist_color"): 476 data = self.calcSongColors(song) 477 rgb = colorsys.hls_to_rgb(data[0], 0.78 + data[1], 0.90) 478 cell.set_property("cell-background-gdk", gtk.gdk.Color(int(rgb[0] * 65535), int(rgb[1] * 65535), int(rgb[2] * 65535), 0)) 479 elif cell.get_property("cell-background-set"): 480 cell.set_property("cell-background", None) 475 481 cell.set_property("markup", text) 476 482 477 483 def __cell_data_func_duration(self, column, cell, model, iter): … … 478 484 song = model.get_value(iter, 0) 479 485 text = "<span size=\"small\">%s</span>" % song.get_str("#duration",True) 480 486 if config.get("setting","compact_playlist")=="false": text += "\n " 487 if config.getboolean("setting", "dynamic_playlist_color"): 488 data = self.calcSongColors(song) 489 rgb = colorsys.hls_to_rgb(data[0], 0.82 + data[1], 0.90) 490 cell.set_property("cell-background-gdk", gtk.gdk.Color(int(rgb[0] * 65535), int(rgb[1] * 65535), int(rgb[2] * 65535), 0)) 491 elif cell.get_property("cell-background-set"): 492 cell.set_property("cell-background", None) 481 493 cell.set_property("markup", text) 482 494 495 def calcSongColors(self, song): 496 """ 497 return a tuple with 498 first value: hue value of song (from 0..1) 499 second value: lightness variance of song 500 (not too high, usually between -0.1 and +0.1) 501 """ 502 if song.get_str("artist") != "": 503 artistval = (float(string.upper(song.get_str("artist", True)).__hash__() % 1001)) / 1000 504 else: 505 artistval = 1.0 506 if song.get_str("album") != "": 507 albumval = (float(string.upper(song.get_str("album")).__hash__() % 17) / 100) - 0.08 508 else: 509 albumval = 0.0 510 return [artistval, albumval] 511 483 512 """"""""""""""""""""""""""" 484 513 FUNC DRAG DROP 485 514 """"""""""""""""""""""""""" -
src/widget/preference.py
199 199 200 200 vbox_general.pack_start(self.make_check_box(_("Enqueue as default action"),"player","click_enqueue"),False,False) 201 201 vbox_general.pack_start(self.make_check_box(_("Compact current playlist"),"setting","compact_playlist"),False,False) 202 vbox_general.pack_start(self.make_check_box(_("Dynamically color playlist"),"setting","dynamic_playlist_color"),False,False) 202 203 vbox_general.pack_start(self.make_check_box(_("Don't clear the playlist when play a new song"),"player","enqueue"),False,False) 203 204 vbox_general.pack_start(self.make_check_box(_("Play a random file when the playlist is empty"),"setting","empty_random"),False,False) 204 205 … … 484 485 config.set(sect,attr,"false") 485 486 if sect=="setting" and attr=="compact_playlist": 486 487 self.win_parent.player_ui.playlist.refresh() 487 488 if sect=="setting" and attr=="dynamic_playlist_color": 489 self.win_parent.player_ui.playlist.refresh() 490 488 491 if sect=="setting" and attr=="use_trayicon": 489 492 if widget.get_property("active"): 490 493 self.win_parent.tray.tray.show_all()
