-
Notifications
You must be signed in to change notification settings - Fork 0
/
satyr_main
100 lines (77 loc) · 2.91 KB
/
satyr_main
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
#! /usr/bin/python
# vim: set fileencoding=utf-8 :
# (c) 2009 Marcos Dione <mdione@grulic.org.ar>
# This file is part of satyr.
# satyr is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# satyr is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with satyr. If not, see <http://www.gnu.org/licenses/>.
# dbus
import dbus
import dbus.mainloop.qt
import dbus.service
# std python
import sys
# we needed before loggin to get the handler
import satyr
# logging
import logging
logger = logging.getLogger(__name__)
logger.addHandler(satyr.loggingHandler)
# local
from satyr.common import BUS_NAME, ConfigurableObject
from satyr.player import Player
from satyr.playlist import PlayList
from satyr.collection import Collection
from satyr.collaggr import CollectionAggregator
from satyr import utils
def main ():
app, args= satyr.createApp ()
dbus.mainloop.qt.DBusQtMainLoop (set_as_default=True)
bus= dbus.SessionBus ()
busName= dbus.service.BusName (BUS_NAME, bus=bus)
# synthetize a config
config= ConfigurableObject ('MainWindow')
config.configValues= (
('skin', str, 'default'),
)
config.loadConfig ()
# if the command line is not default, use it
skin= str (args.getOption ("skin"))
if skin!="":
config.skin= skin
# do the import magic
# TODO: add the user's app dir to sys.path so we can load skins from there
mod= utils.import_ ('satyr.skins.'+config.skin)
mw= mod.MainWindow ()
config.saveConfig ()
collaggr= CollectionAggregator (app, busName=busName, busPath='/collaggr')
if collaggr.collsNo==0:
logging.info ("no collections, picking from args")
for index in xrange (args.count ()):
path= args.arg (index)
# paths must be bytes, not ascii or utf-8
path= utils.qstring2path (path)
collection= Collection (app, path, busName=busName, busPath="/collection_%04d" % index)
collaggr.append (collection)
for collection in collaggr.collections:
collection.scanBegins.connect (mw.scanBegins)
collection.scanFinished.connect (mw.scanFinished)
# they're loaded by the CollAggr
# collection.loadOrScan ()
mw.collectionAdded ()
playlist= PlayList (app, collaggr, busName=busName, busPath='/playlist')
player= Player (app, playlist, busName, '/player')
player.finished.connect (app.quit)
mw.connectUi (player)
mw.show ()
return app.exec_ ()
if __name__=='__main__':
sys.exit (main ())
# end