/usr/share/pyshared/quodlibet/qltk/pluginwin.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 | # -*- coding: utf-8 -*-
# Copyright 2004-2005 Joe Wreschnig, Michael Urman, IƱigo Serna
#
# 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 const
from quodlibet import qltk
from quodlibet import util
from quodlibet.plugins import Manager
from quodlibet.qltk.views import HintedTreeView
from quodlibet.qltk.entry import ClearEntry
TAG, ALL, NO, DIS, EN, SEP = range(6)
class PluginErrorWindow(qltk.UniqueWindow):
def __init__(self, parent):
if self.is_not_unique(): return
super(PluginErrorWindow, self).__init__()
self.set_title(_("Plugin Errors") + " - Quod Libet")
self.set_border_width(12)
self.set_transient_for(parent)
self.set_default_size(420, 250)
scrolledwin = gtk.ScrolledWindow()
vbox = gtk.VBox(spacing=6)
vbox.set_border_width(6)
scrolledwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
scrolledwin.add_with_viewport(vbox)
failures = {}
for pm in Manager.instances.values():
failures.update(pm.list_failures())
keys = failures.keys()
show_expanded = len(keys) <= 3
for key in sorted(keys):
expander = gtk.Expander("<b>%s</b>" % util.escape(key))
expander.set_use_markup(True)
if show_expanded: expander.set_expanded(True)
# second line is always the __rescan line; don't show it
message = failures[key][0:1] + failures[key][2:]
failure = gtk.Label(''.join(message).strip())
failure.set_alignment(0, 0)
failure.set_padding(12, 6)
failure.set_selectable(True)
vbox.pack_start(expander, expand=False)
expander.add(failure)
vbox2 = gtk.VBox(spacing=12)
close = gtk.Button(stock=gtk.STOCK_CLOSE)
close.connect('clicked', lambda *x: self.destroy())
b = gtk.HButtonBox()
b.set_layout(gtk.BUTTONBOX_END)
b.pack_start(close)
vbox2.pack_start(scrolledwin)
vbox2.pack_start(b, expand=False)
self.add(vbox2)
self.show_all()
close.grab_focus()
class PluginWindow(qltk.UniqueWindow):
def __init__(self, parent):
if self.is_not_unique(): return
super(PluginWindow, self).__init__()
self.set_title(_("Quod Libet Plugins"))
self.set_border_width(12)
self.set_default_size(625, 350)
self.set_transient_for(parent)
hbox = gtk.HBox(spacing=12)
vbox = gtk.VBox(spacing=6)
sw = gtk.ScrolledWindow()
sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
tv = HintedTreeView()
model = gtk.ListStore(object, object)
filter = model.filter_new()
tv.set_model(filter)
tv.set_rules_hint(True)
filter_entry = ClearEntry()
filter_entry.connect("changed", lambda s: filter.refilter())
combo_store = gtk.ListStore(str, int)
filter_combo = gtk.ComboBox(combo_store)
cell = gtk.CellRendererText()
filter_combo.pack_start(cell, True)
filter_combo.add_attribute(cell, "text", 0)
filter_combo.connect("changed", lambda s: filter.refilter())
combo_sep = lambda model, iter: model[iter][1] == SEP
filter_combo.set_row_separator_func(combo_sep)
fb = gtk.HBox(spacing=6)
fb.pack_start(filter_combo, expand=False)
input = gtk.HBox()
input.pack_start(filter_entry)
filter_entry.pack_clear_button(input)
fb.pack_start(input)
render = gtk.CellRendererToggle()
def cell_data(col, render, model, iter):
row = model[iter]
render.set_active(row[1].enabled(row[0]))
render.connect('toggled', self.__toggled, filter)
column = gtk.TreeViewColumn("enabled", render)
column.set_cell_data_func(render, cell_data)
tv.append_column(column)
render = gtk.CellRendererPixbuf()
def cell_data(col, render, model, iter):
icon = getattr(model[iter][0], 'PLUGIN_ICON', gtk.STOCK_EXECUTE)
render.set_property('stock-id', icon)
column = gtk.TreeViewColumn("image", render)
column.set_cell_data_func(render, cell_data)
tv.append_column(column)
render = gtk.CellRendererText()
render.set_property('ellipsize', pango.ELLIPSIZE_END)
render.set_property('xalign', 0.0)
column = gtk.TreeViewColumn("name", render)
def cell_data(col, render, model, iter):
render.set_property('text', model[iter][0].PLUGIN_NAME)
column.set_cell_data_func(render, cell_data)
column.set_expand(True)
tv.append_column(column)
sw.add(tv)
sw.set_shadow_type(gtk.SHADOW_IN)
tv.set_headers_visible(False)
bbox = gtk.HBox(homogeneous=True, spacing=12)
errors = qltk.Button(_("Show _Errors"), gtk.STOCK_DIALOG_WARNING)
errors.set_focus_on_click(False)
bbox.pack_start(errors)
refresh = gtk.Button(stock=gtk.STOCK_REFRESH)
refresh.set_focus_on_click(False)
bbox.pack_start(refresh)
vbox.pack_start(fb, expand=False)
vbox.pack_start(sw)
vbox.pack_start(bbox, expand=False)
vbox.set_size_request(250, -1)
hbox.pack_start(vbox, expand=False)
selection = tv.get_selection()
desc = gtk.Label()
desc.set_alignment(0, 0)
desc.set_selectable(True)
desc.set_line_wrap(True)
desc.set_size_request(self.get_default_size()[0] - 300, -1)
selection.connect('changed', self.__description, desc)
prefs = gtk.Frame()
prefs.set_shadow_type(gtk.SHADOW_NONE)
close = gtk.Button(stock=gtk.STOCK_CLOSE)
close.connect('clicked', lambda *x: self.destroy())
bb_align = gtk.Alignment(0, 1, 1, 0)
bb = gtk.HButtonBox()
bb.set_layout(gtk.BUTTONBOX_END)
bb.pack_start(close)
bb_align.add(bb)
vb2 = gtk.VBox(spacing=12)
vb2.pack_start(desc, expand=False)
vb2.pack_start(prefs, expand=False)
vb2.pack_start(bb_align)
hbox.pack_start(vb2, expand=True)
self.add(hbox)
selection.connect('changed', self.__preferences, prefs)
refresh.connect('clicked', self.__refresh, tv, desc, errors,
filter_combo, combo_store)
errors.connect('clicked', self.__show_errors)
tv.get_selection().emit('changed')
refresh.clicked()
self.connect('destroy', self.__destroy)
filter.set_visible_func(
self.__filter, (filter_entry, filter_combo, combo_store))
self.show_all()
filter_entry.grab_focus()
def __filter(self, model, iter, widgets):
row = model[iter]
plugin = row[0]
if not plugin or not row[1]:
return False
entry, combo, model = widgets
plugin_tags = getattr(plugin, "PLUGIN_TAGS", ())
if isinstance(plugin_tags, basestring):
plugin_tags = [plugin_tags]
iter = combo.get_active_iter()
if iter:
enabled = row[1].enabled(plugin)
tag = model[iter][0]
flag = model[iter][1]
if flag == NO and plugin_tags or \
flag == TAG and not tag in plugin_tags or \
flag == EN and not enabled or \
flag == DIS and enabled:
return False
filter = entry.get_text().lower()
if not filter or filter in plugin.PLUGIN_NAME.lower() or \
filter in getattr(plugin, "PLUGIN_DESC" , "").lower():
return True
return False
def __destroy(self, *args):
config.write(const.CONFIG)
def __description(self, selection, label):
model, iter = selection.get_selected()
if not iter: return
text = "<big><b>%s</b></big>\n" % util.escape(model[iter][0].PLUGIN_NAME)
try: text += "<small>%s %s</small>\n" %(_("Version:"),
util.escape(model[iter][0].PLUGIN_VERSION))
except (TypeError, AttributeError): pass
try: text += "\n" + util.escape(model[iter][0].PLUGIN_DESC)
except (TypeError, AttributeError): pass
label.set_markup(text)
def __preferences(self, selection, frame):
model, iter = selection.get_selected()
if frame.child: frame.child.destroy()
if iter and hasattr(model[iter][0], 'PluginPreferences'):
try:
prefs = model[iter][0].PluginPreferences(self)
except:
util.print_exc()
frame.hide()
else:
if isinstance(prefs, gtk.Window):
b = gtk.Button(stock=gtk.STOCK_PREFERENCES)
b.connect_object('clicked', gtk.Window.show, prefs)
b.connect_object('destroy', gtk.Window.destroy, prefs)
frame.add(b)
frame.child.set_border_width(6)
else:
frame.add(prefs)
frame.show_all()
else: frame.hide()
def __toggled(self, render, fpath, fmodel):
render.set_active(not render.get_active())
path = fmodel.convert_path_to_child_path(fpath)
model = fmodel.get_model()
row = model[path]
pm = row[1]
pm.enable(row[0], render.get_active())
pm.save()
model.row_changed(row.path, row.iter)
def __refresh(self, activator, view, desc, errors, combo, combo_store):
fmodel, fiter = view.get_selection().get_selected()
model = fmodel.get_model()
selected = None
if fiter:
iter = fmodel.convert_iter_to_child_iter(fiter)
selected = model[iter][0]
plugins = []
failures = False
model.clear()
for pm in Manager.instances.values():
pm.rescan()
for plugin in pm.list():
plugins.append((plugin.PLUGIN_NAME, plugin, pm))
failures = failures or bool(pm.list_failures())
tags = []
no_tags = False
plugins.sort()
for plugin in plugins:
it = model.append(row=plugin[1:])
if plugin[1] is selected:
fit = fmodel.convert_child_iter_to_iter(it)
view.get_selection().select_iter(fit)
plugin_tags = getattr(plugin[1], "PLUGIN_TAGS", ())
if isinstance(plugin_tags, basestring):
plugin_tags = [plugin_tags]
if not plugin_tags:
no_tags = True
tags.extend(plugin_tags)
tags = list(set(tags))
active = max(combo.get_active(), 0)
combo_store.clear()
combo_store.append([_("All"), ALL])
combo_store.append(["", SEP])
combo_store.append([_("Enabled"), EN])
combo_store.append([_("Disabled"), DIS])
if tags:
combo_store.append(["", SEP])
for tag in sorted(tags):
combo_store.append([tag, TAG])
if no_tags:
combo_store.append([_("No category"), NO])
combo.set_active(active)
if not plugins:
desc.set_text(_("No plugins found."))
errors.set_sensitive(failures)
def __show_errors(self, activator):
PluginErrorWindow(self)
|