/usr/share/pyshared/quodlibet/qltk/prefs.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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 | # -*- coding: utf-8 -*-
# Copyright 2004-2010 Joe Wreschnig, Michael Urman, IƱigo Serna,
# Steven Robertson, Nick Boultbee
#
# 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 os
import gtk
from quodlibet import config
from quodlibet import const
from quodlibet import player
from quodlibet import qltk
from quodlibet import util
from quodlibet.parse import Query
from quodlibet.qltk.ccb import ConfigCheckButton
from quodlibet.qltk.chooser import FolderChooser
from quodlibet.qltk.entry import ValidatingEntry, UndoEntry
from quodlibet.qltk.songlist import SongList
class PreferencesWindow(qltk.UniqueWindow):
class SongList(gtk.VBox):
name = "songlist"
def __init__(self):
super(PreferencesWindow.SongList, self).__init__(spacing=12)
self.set_border_width(12)
self.title = _("Song List")
c = ConfigCheckButton(
_("_Jump to playing song automatically"), 'settings', 'jump')
c.set_tooltip_text(_("When the playing song changes, "
"scroll to it in the song list"))
c.set_active(config.getboolean("settings", "jump"))
self.pack_start(c, expand=False)
vbox = gtk.VBox(spacing=12)
buttons = {}
table = gtk.Table(3, 3)
table.set_homogeneous(True)
checks = config.get("settings", "headers").split()
for j, l in enumerate(
[[("~#disc", _("_Disc")),
("album", _("Al_bum")),
("~basename",_("_Filename"))],
[("~#track", _("_Track")),
("artist", _("_Artist")),
("~#rating", _("_Rating"))],
[("title", util.tag("title")),
("date", _("_Date")),
("~#length",_("_Length"))]]):
for i, (k, t) in enumerate(l):
buttons[k] = gtk.CheckButton(t)
if k in checks:
buttons[k].set_active(True)
checks.remove(k)
table.attach(buttons[k], i, i + 1, j, j + 1)
vbox.pack_start(table, expand=False)
vbox2 = gtk.VBox()
tiv = gtk.CheckButton(_("Title includes _version"))
if "~title~version" in checks:
buttons["title"].set_active(True)
tiv.set_active(True)
checks.remove("~title~version")
aip = gtk.CheckButton(_("Album includes _disc subtitle"))
if "~album~discsubtitle" in checks:
buttons["album"].set_active(True)
aip.set_active(True)
checks.remove("~album~discsubtitle")
fip = gtk.CheckButton(_("Filename includes _folder"))
if "~filename" in checks:
buttons["~basename"].set_active(True)
fip.set_active(True)
checks.remove("~filename")
t = gtk.Table(2, 2)
t.set_homogeneous(True)
t.attach(tiv, 0, 1, 0, 1)
t.attach(aip, 0, 1, 1, 2)
t.attach(fip, 1, 2, 0, 1)
vbox.pack_start(t, expand=False)
hbox = gtk.HBox(spacing=6)
l = gtk.Label(_("_Others:"))
hbox.pack_start(l, expand=False)
others = UndoEntry()
if "~current" in checks: checks.remove("~current")
others.set_text(" ".join(checks))
others.set_tooltip_text(
_("Other columns to display, separated by spaces"))
l.set_mnemonic_widget(others)
l.set_use_underline(True)
hbox.pack_start(others)
vbox.pack_start(hbox, expand=False)
apply = gtk.Button(stock=gtk.STOCK_APPLY)
apply.connect(
'clicked', self.__apply, buttons, tiv, aip, fip, others)
b = gtk.HButtonBox()
b.set_layout(gtk.BUTTONBOX_END)
b.pack_start(apply)
vbox.pack_start(b)
frame = qltk.Frame(_("Visible Columns"), child=vbox)
self.pack_start(frame, expand=False)
self.show_all()
def __apply(self, button, buttons, tiv, aip, fip, others):
headers = []
for key in ["~#disc", "~#track", "title", "album", "artist",
"date", "~basename", "~#rating", "~#length"]:
if buttons[key].get_active(): headers.append(key)
if tiv.get_active():
try: headers[headers.index("title")] = "~title~version"
except ValueError: pass
if aip.get_active():
try: headers[headers.index("album")] = "~album~discsubtitle"
except ValueError: pass
if fip.get_active():
try: headers[headers.index("~basename")] = "~filename"
except ValueError: pass
headers.extend(others.get_text().split())
if "~current" in headers: headers.remove("~current")
headers = [header.lower() for header in headers]
SongList.set_all_column_headers(headers)
class Browsers(gtk.VBox):
name = "browser"
def __init__(self):
super(PreferencesWindow.Browsers, self).__init__(spacing=12)
self.set_border_width(12)
self.title = _("Browsers")
hb = gtk.HBox(spacing=6)
l = gtk.Label(_("_Global filter:"))
l.set_use_underline(True)
e = ValidatingEntry(Query.is_valid_color)
e.set_text(config.get("browsers", "background"))
e.connect('changed', self._entry, 'background', 'browsers')
l.set_mnemonic_widget(e)
hb.pack_start(l, expand=False)
hb.pack_start(e)
self.pack_start(hb, expand=False)
vb = gtk.VBox(spacing=6)
c = ConfigCheckButton(
_("Search after _typing"), 'settings', 'eager_search')
c.set_active(config.getboolean('settings', 'eager_search'))
c.set_tooltip_text(_("Show search results after the user "
"stops typing."))
vb.pack_start(c)
c = ConfigCheckButton(
_("Color _search terms"), 'browsers', 'color')
c.set_active(config.getboolean("browsers", "color"))
c.set_tooltip_text(_("Display simple searches in blue, "
"advanced ones in green, and invalid ones in red"))
vb.pack_start(c)
f = qltk.Frame(_("Search Library"), child=vb)
self.pack_start(f, expand=False)
c1 = ConfigCheckButton(
_("Confirm _multiple ratings"),
'browsers', 'rating_confirm_multiple')
c1.set_active(
config.getboolean("browsers", "rating_confirm_multiple"))
c1.set_tooltip_text(_("Ask for confirmation before changing the "
"rating of multiple songs at once"))
c2 = ConfigCheckButton(
_("Enable _one-click ratings"),
'browsers', 'rating_click')
c2.set_active(
config.getboolean("browsers", "rating_click"))
c2.set_tooltip_text(_("Enable rating by clicking on the rating "
"column in the song list"))
vbox = gtk.VBox(spacing=6)
vbox.pack_start(c1, expand=False)
vbox.pack_start(c2, expand=False)
f1 = qltk.Frame(_("Ratings"), child=vbox)
self.pack_start(f1, expand=False)
def _entry(self, entry, name, section="settings"):
config.set(section, name, entry.get_text())
class Player(gtk.VBox):
name = "playback"
def __init__(self):
super(PreferencesWindow.Player, self).__init__(spacing=12)
self.set_border_width(12)
self.title = _("Playback")
if player.backend and hasattr(player.device, 'PlayerPreferences'):
player_prefs = player.device.PlayerPreferences()
self.pack_start(player_prefs, expand=False)
vbox = gtk.VBox(spacing=6)
c = ConfigCheckButton(_("_Enable Replay Gain volume adjustment"),
"player", "replaygain")
c.set_active(config.getboolean("player", "replaygain"))
c.connect('toggled', self.__toggled_gain)
vbox.pack_start(c, expand=False)
try:
fallback_gain = config.getfloat("player", "fallback_gain")
except:
fallback_gain = 0.0
adj = gtk.Adjustment(fallback_gain, -12.0, 12.0, 0.5, 0.5, 0.0)
s = gtk.SpinButton(adj)
s.set_digits(1)
s.connect('changed', self.__changed, 'player', 'fallback_gain')
s.set_tooltip_text(_("If no Replay Gain information is available "
"for a song, scale the volume by this value"))
l = gtk.Label(_("Fall-back gain (dB):"))
l.set_use_underline(True)
l.set_mnemonic_widget(s)
hb = gtk.HBox(spacing=6)
hb.pack_start(l, expand=False)
hb.pack_start(s, expand=False)
vbox.pack_start(hb, expand=False)
try:
pre_amp_gain = config.getfloat("player", "pre_amp_gain")
except:
pre_amp_gain = 0
adj = gtk.Adjustment(pre_amp_gain, -6, 6, 0.5, 0.5, 0.0)
adj.connect('value-changed', self.__changed,
'player', 'pre_amp_gain')
s = gtk.SpinButton(adj)
s.set_digits(1)
s.set_tooltip_text(_("Scale volume for all songs by this value, "
"as long as the result will not clip"))
l = gtk.Label(_("Pre-amp gain (dB):"))
l.set_use_underline(True)
l.set_mnemonic_widget(s)
hb = gtk.HBox(spacing=6)
hb.pack_start(l, expand=False)
hb.pack_start(s, expand=False)
vbox.pack_start(hb, expand=False)
f = qltk.Frame(_("Replay Gain Volume Adjustment"), child=vbox)
self.pack_start(f)
self.show_all()
def __toggled_gain(self, activator):
player.playlist.volume = player.playlist.volume
def __changed(self, adj, section, name):
config.set(section, name, str(adj.get_value()))
player.playlist.volume = player.playlist.volume
class Library(gtk.VBox):
name = "library"
def __init__(self):
super(PreferencesWindow.Library, self).__init__(spacing=12)
self.set_border_width(12)
self.title = _("Library")
hb = gtk.HBox(spacing=6)
b = qltk.Button(_("_Select"), gtk.STOCK_OPEN)
e = UndoEntry()
e.set_text(util.fsdecode(config.get("settings", "scan")))
hb.pack_start(e)
e.set_tooltip_text(_("Songs placed in these folders (separated "
"by ':') will be added to your library"))
hb.pack_start(b, expand=False)
scandirs = util.split_scan_dirs(config.get("settings", "scan"))
if scandirs and os.path.isdir(scandirs[-1]):
# start with last added directory
initial = scandirs[-1]
else:
initial = const.HOME
b.connect('clicked', self.__select, e, initial)
e.connect('changed', self.__changed, 'settings', 'scan')
cb = ConfigCheckButton(
_("_Refresh library on start"), "library", "refresh_on_start")
cb.set_active(config.getboolean("library", "refresh_on_start"))
vb3 = gtk.VBox(spacing=6)
vb3.pack_start(hb)
vb3.pack_start(cb)
f = qltk.Frame(_("Scan _Directories"), child=vb3)
f.get_label_widget().set_mnemonic_widget(e)
self.pack_start(f, expand=False)
vbox = gtk.VBox(spacing=6)
hb = gtk.HBox(spacing=6)
e = UndoEntry()
e.set_text(config.get("editing", "split_on"))
e.connect('changed', self.__changed, 'editing', 'split_on')
e.set_tooltip_text(_('Separators for splitting tags'))
l = gtk.Label(_("Split _on:"))
l.set_use_underline(True)
l.set_mnemonic_widget(e)
hb.pack_start(l, expand=False)
hb.pack_start(e)
vbox.pack_start(hb, expand=False)
cb = ConfigCheckButton(
_("Enable _human title case"), 'editing', 'human_title_case')
cb.set_active(config.getboolean("editing", 'human_title_case'))
cb.set_tooltip_text(_("Uses common English rules for title casing, as in \"Dark Night of the Soul\""))
vbox.pack_start(cb, expand=False)
vb2 = gtk.VBox(spacing=0)
cb = ConfigCheckButton(
_("Save ratings and play _counts"), "editing", "save_to_songs")
cb.set_active(config.getboolean("editing", "save_to_songs"))
vb2.pack_start(cb)
hb = gtk.HBox(spacing=3)
lab = gtk.Label(_("_Email:"))
entry = UndoEntry()
entry.set_tooltip_text(_("Ratings and play counts will be set "
"for this email address"))
entry.set_text(config.get("editing", "save_email"))
entry.connect('changed', self.__changed, 'editing', 'save_email')
hb.pack_start(lab, expand=False)
hb.pack_start(entry)
lab.set_mnemonic_widget(entry)
lab.set_use_underline(True)
vb2.pack_start(hb)
vbox.pack_start(vb2, expand=False)
cb = ConfigCheckButton(
_("Show _programmatic tags"), 'editing', 'alltags')
cb.set_active(config.getboolean("editing", 'alltags'))
vbox.pack_start(cb, expand=False)
f = qltk.Frame(_("Tag Editing"), child=vbox)
self.pack_start(f)
self.show_all()
def __select(self, button, entry, initial):
chooser = FolderChooser(self, _("Select Directories"), initial)
fns = chooser.run()
chooser.destroy()
if fns: entry.set_text(":".join(map(util.fsdecode, fns)))
def __changed(self, entry, section, name):
config.set(section, name, entry.get_text())
class AlbumArt(gtk.VBox):
name = "albumart"
def __init__(self):
super(PreferencesWindow.AlbumArt, self).__init__(spacing=12)
self.set_border_width(12)
self.title = _("Album Art")
vb = gtk.VBox(spacing=6)
display_frame = qltk.Frame(_("Display"), child=vb)
c = ConfigCheckButton(
_("_Use rounded corners on thumbnails"), 'albumart', 'round')
c.set_tooltip_text(_("Round the corners of album artwork "
"thumbnail images. May require restart to take effect."))
c.set_active(config.getboolean('albumart', 'round'))
vb.pack_start(c, expand=False)
# Filename choice algorithm config
vb = gtk.VBox(spacing=6)
file_frame = qltk.Frame(_("Art sources"), child=vb)
cb = ConfigCheckButton(
_("Prefer _embedded art"), 'albumart', 'prefer_embedded')
cb.set_tooltip_text(_("Choose to use artwork embedded in the audio "
"(where available) over other sources"))
cb.set_active(config.getboolean('albumart', 'prefer_embedded'))
vb.pack_start(cb, expand=False)
hb = gtk.HBox(spacing=3)
cb = ConfigCheckButton(
_("_Force image filename:"), 'albumart', 'force_filename')
cb.set_active(config.getboolean('albumart', 'force_filename'))
hb.pack_start(cb, expand=False)
entry = UndoEntry()
entry.set_tooltip_text(
_("The album art image file to use when forced"))
entry.set_text(config.get("albumart", "filename"))
entry.connect('changed', self.__changed_text, 'filename')
# Disable entry when not forcing
entry.set_sensitive(cb.get_active())
cb.connect('toggled', self.__toggled_force_filename, entry)
hb.pack_start(entry)
vb.pack_start(hb, expand=False)
self.pack_start(display_frame, expand=False)
self.pack_start(file_frame, expand=False)
def __changed_text(self, entry, name):
config.set('albumart', name, entry.get_text())
def __toggled_force_filename(self, cb, fn_entry):
fn_entry.set_sensitive(cb.get_active())
def __init__(self, parent):
if self.is_not_unique(): return
super(PreferencesWindow, self).__init__()
self.set_title(_("Quod Libet Preferences"))
self.set_border_width(12)
self.set_resizable(False)
self.set_transient_for(qltk.get_top_parent(parent))
self.__notebook = notebook = qltk.Notebook()
for Page in [self.SongList, self.Browsers, self.AlbumArt, self.Player,
self.Library]: notebook.append_page(Page())
close = gtk.Button(stock=gtk.STOCK_CLOSE)
close.connect_object('clicked', lambda x: x.destroy(), self)
button_box = gtk.HButtonBox()
button_box.set_layout(gtk.BUTTONBOX_END)
button_box.pack_start(close)
vbox = gtk.VBox(spacing=12)
vbox.pack_start(notebook)
vbox.pack_start(button_box, expand=False)
self.add(vbox)
self.connect_object('destroy', PreferencesWindow.__destroy, self)
self.show_all()
def set_page(self, name):
notebook = self.__notebook
for p in range(notebook.get_n_pages()):
if notebook.get_nth_page(p).name == name:
notebook.set_current_page(p)
def __destroy(self):
config.write(const.CONFIG)
|