15
15
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
# The developers of the Exaile media player hereby grant permission
19
# for non-GPL compatible GStreamer and Exaile plugins to be used and
20
# distributed together with GStreamer and Exaile. This permission is
21
# above and beyond the permissions granted by the GPL license by which
22
# Exaile is covered. If you modify this code, you may extend this
23
# exception to your version of the code, but you are not obligated to
24
# do so. If you do not wish to do so, delete this exception statement
28
# The developers of the Exaile media player hereby grant permission
29
# for non-GPL compatible GStreamer and Exaile plugins to be used and
30
# distributed together with GStreamer and Exaile. This permission is
31
# above and beyond the permissions granted by the GPL license by which
32
# Exaile is covered. If you modify this code, you may extend this
33
# exception to your version of the code, but you are not obligated to
34
# do so. If you do not wish to do so, delete this exception statement
18
# The developers of the Exaile media player hereby grant permission
19
# for non-GPL compatible GStreamer and Exaile plugins to be used and
20
# distributed together with GStreamer and Exaile. This permission is
21
# above and beyond the permissions granted by the GPL license by which
22
# Exaile is covered. If you modify this code, you may extend this
23
# exception to your version of the code, but you are not obligated to
24
# do so. If you do not wish to do so, delete this exception statement
35
25
# from your version.
37
import thread, os, shlex, string, urllib2
38
from xl.nls import gettext as _
41
38
pygtk.require('2.0')
41
from xl.nls import gettext as _
44
43
from xl.settings import _SETTINGSMANAGER
45
44
from xlgui.prefs.widgets import *
46
from xlgui.prefs import playlists_prefs, osd_prefs
45
from xlgui.prefs import playlists_prefs, osd_prefs, collection_prefs
47
46
from xlgui.prefs import cover_prefs, playback_prefs, appearance_prefs
48
47
from xlgui.prefs import plugin_prefs
49
import logging, traceback, gobject
51
49
logger = logging.getLogger(__name__)
58
PAGES = (playlists_prefs, appearance_prefs, playback_prefs,
59
osd_prefs, cover_prefs)
56
PAGES = (playlists_prefs, appearance_prefs, playback_prefs,
57
collection_prefs, osd_prefs, cover_prefs)
60
58
PREFERENCES_DIALOG = None
62
60
def __init__(self, parent, main):
67
65
self.last_child = None
68
66
self.last_page = None
69
67
self.parent = parent
70
self.settings = _SETTINGSMANAGER.clone()
68
self.settings = _SETTINGSMANAGER
71
69
self.plugins = self.main.exaile.plugins.list_installed_plugins()
77
self.xml = xml = gtk.glade.XML(
78
xdg.get_data_path('glade/preferences_dialog.glade'),
79
'PreferencesDialog', 'exaile')
75
self.builder = gtk.Builder()
76
self.builder.set_translation_domain('exaile')
77
self.builder.add_from_file(
78
xdg.get_data_path('ui/preferences_dialog.ui'))
81
self.window = xml.get_widget('PreferencesDialog')
80
self.window = self.builder.get_object('PreferencesDialog')
82
81
self.window.set_transient_for(parent)
83
82
self.window.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
84
83
self.window.connect('delete-event', lambda *e: self.cancel())
86
85
self._connect_events()
88
self.label = xml.get_widget('prefs_frame_label')
89
self.box = xml.get_widget('prefs_box')
87
self.box = self.builder.get_object('prefs_box')
91
self.tree = xml.get_widget('prefs_tree')
89
self.tree = self.builder.get_object('prefs_tree')
92
90
text = gtk.CellRendererText()
93
91
col = gtk.TreeViewColumn(_('Preferences'), text, text=0)
94
92
self.tree.append_column(col)
152
153
Connects the various events to their handlers
154
self.xml.signal_autoconnect({
155
self.builder.connect_signals({
155
156
'on_cancel_button_clicked': lambda *e: self.cancel(),
156
157
'on_apply_button_clicked': self.apply,
157
158
'on_ok_button_clicked': self.ok,
204
205
if not iter: return
205
206
page = self.model.get_value(iter, 1)
206
207
if not page: return
207
self.label.set_markup("<b>%s</b>" %
210
209
if self.last_child:
211
210
self.box.remove(self.last_child)
213
212
if self.last_page:
214
if hasattr(self.last_page, 'page_leave'):
213
if hasattr(self.last_page, 'page_leave'):
215
214
self.last_page.page_leave(self)
217
216
self.last_page = page
219
218
child = self.panes.get(page)
221
220
if hasattr(page, 'ui'):
222
222
builder = gtk.Builder()
223
223
builder.add_from_file(page.ui)
225
builder = gtk.glade.XML(page.glade, 'prefs_pane')
226
builder.get_object = builder.get_widget
226
logger.warning('Please switch to gtk.Builder for preferences panes')
228
builder = gtk.glade.XML(page.glade, 'prefs_pane')
229
builder.get_object = builder.get_widget
230
builder.connect_signals = builder.signal_autoconnect
232
logger.error('Importing Glade as fallback failed')
227
235
child = builder.get_object('prefs_pane')
228
236
init = getattr(page, 'init', None)
229
237
if init: init(self, builder)
252
261
klass = getattr(page, attr)
253
262
if inspect.isclass(klass) and \
254
issubclass(klass, widgets.PrefsItem):
263
issubclass(klass, widgets.PrefsItem):
255
264
widget = builder.get_object(klass.name)
257
logger.warning('Invalid prefs widget: %s' % klass.name)
266
logger.warning('Invalid prefs widget: %s' % klass.name)
259
268
field = klass(self, widget)
260
269
self.fields[page].append(field)
262
271
logger.warning('Broken prefs class: %s' % attr)
263
272
traceback.print_exc()