/usr/share/pyshared/quodlibet/qltk/browser.py is in exfalso 2.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | # Copyright 2005 Joe Wreschnig, Michael Urman
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation
import gtk
import pango
from quodlibet import config
from quodlibet import util
from quodlibet.qltk.songlist import SongList
from quodlibet.qltk.x import Window
from quodlibet.qltk.x import RPaned
from quodlibet.util.library import background_filter
class LibraryBrowser(Window):
def __init__(self, Kind, library):
super(LibraryBrowser, self).__init__(dialog=False)
self.set_border_width(6)
self.set_title("Quod Libet - " + Kind.name)
self.add(gtk.VBox(spacing=6))
name = Kind.__name__
cfg_name = "browser_size_" + name
try: x, y = map(int, config.get('memory', cfg_name).split())
except (config.error, ValueError):
x, y = 500, 300
screen = self.get_screen()
x = min(x, screen.get_width())
y = min(y, screen.get_height())
self.set_default_size(x, y)
self.connect('configure-event', LibraryBrowser.__save_size, cfg_name)
view = SongList(library, update=True)
self.add_accel_group(view.accelerators)
self.songlist = view
sw = gtk.ScrolledWindow()
sw.set_shadow_type(gtk.SHADOW_IN)
sw.add(view)
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
self.browser = browser = Kind(library, None)
if browser.reordered:
view.enable_drop()
elif browser.dropped:
view.enable_drop(False)
if browser.accelerators:
self.add_accel_group(browser.accelerators)
self.__container = browser.pack(sw)
self.child.pack_start(self.__container)
self.__statusbar = gtk.Label()
self.__statusbar.set_text(_("No time information"))
self.__statusbar.set_alignment(1.0, 0.5)
self.__statusbar.set_ellipsize(pango.ELLIPSIZE_START)
self.child.pack_end(self.__statusbar, expand=False)
browser.connect('songs-selected', self.__browser_cb)
browser.finalize(False)
view.connect('popup-menu', self.__menu, library)
view.connect('drag-data-received', self.__drag_data_recv)
view.connect('row-activated', self.__enqueue)
view.get_selection().connect('changed', self.__set_time)
if browser.headers is not None:
view.connect('columns-changed', self.__cols_changed, browser)
self.__cols_changed(view, browser)
sw.show_all()
for c in self.child.get_children():
c.show()
self.child.show()
self.show()
self.__set_pane_size()
def __set_pane_size(self):
if isinstance(self.__container, RPaned):
try:
key = "%s_pos" % self.browser.__class__.__name__
val = config.getfloat("browsers", key)
except:
val = 0.4
self.__container.set_relative(val)
def __browser_cb(self, browser, songs, sorted):
if browser.background:
bg = background_filter()
if bg: songs = filter(bg, songs)
self.__set_time(songs=songs)
self.songlist.set_songs(songs, sorted)
def __enqueue(self, view, path, column):
from quodlibet.widgets import main
from quodlibet.player import playlist as player
main.playlist.enqueue([view.get_model()[path][0]])
if player.song is None: player.next()
def __drag_data_recv(self, view, *args):
if callable(self.browser.reordered): self.browser.reordered(view)
view.set_sort_by(None, refresh=False)
def __cols_changed(self, view, browser):
for header in view.get_columns():
tag = header.header_name
for t in util.tagsplit(tag):
if t in browser.headers:
header.set_visible(True)
break
else: header.set_visible(False)
def __menu(self, view, library):
path, col = view.get_cursor()
header = col.header_name
menu = view.Menu(header, self.browser, library)
if menu is not None:
view.popup_menu(menu, 0, gtk.get_current_event_time())
return True
def __set_time(self, *args, **kwargs):
statusbar = self.__statusbar
songs = kwargs.get("songs") or self.songlist.get_selected_songs()
if "songs" not in kwargs and len(songs) <= 1:
songs = self.songlist.get_songs()
i = len(songs)
length = sum([song.get("~#length", 0) for song in songs])
t = self.browser.statusbar(i) % {
'count': i, 'time': util.format_time_long(length)}
statusbar.set_text(t)
def __save_size(self, event, cfg_name):
config.set('memory', cfg_name, '%d %d' %(event.width, event.height))
|