1 |
#!/usr/bin/python |
---|
2 |
# |
---|
3 |
# Copyright (C) 2005-2008 by Pieter Palmers |
---|
4 |
# 2007-2008 by Arnold Krille |
---|
5 |
# |
---|
6 |
# This file is part of FFADO |
---|
7 |
# FFADO = Free Firewire (pro-)audio drivers for linux |
---|
8 |
# |
---|
9 |
# FFADO is based upon FreeBoB. |
---|
10 |
# |
---|
11 |
# This program is free software: you can redistribute it and/or modify |
---|
12 |
# it under the terms of the GNU General Public License as published by |
---|
13 |
# the Free Software Foundation, either version 3 of the License, or |
---|
14 |
# (at your option) any later version. |
---|
15 |
# |
---|
16 |
# This program is distributed in the hope that it will be useful, |
---|
17 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
18 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
19 |
# GNU General Public License for more details. |
---|
20 |
# |
---|
21 |
# You should have received a copy of the GNU General Public License |
---|
22 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
23 |
# |
---|
24 |
|
---|
25 |
# |
---|
26 |
# QT 4 version |
---|
27 |
# |
---|
28 |
|
---|
29 |
import sys |
---|
30 |
|
---|
31 |
# Add the path of the installed ffado-mixer-modules |
---|
32 |
sys.path.append( "$PYTHONDIR" ) |
---|
33 |
|
---|
34 |
from ffadomixer_config import * #POLL_SLEEP_TIME_MSEC, FFADO_DBUS_SERVER, FFADO_DBUS_BASEPATH |
---|
35 |
|
---|
36 |
import os |
---|
37 |
import time |
---|
38 |
|
---|
39 |
from PyQt4.QtCore import SIGNAL, SLOT, QObject, QTimer, Qt |
---|
40 |
from PyQt4.QtGui import * #QApplication, QMessageBox, QIcon |
---|
41 |
|
---|
42 |
from ffado_dbus_util import * |
---|
43 |
|
---|
44 |
from ffado_panelmanager import PanelManager |
---|
45 |
|
---|
46 |
from ffado_logginghandler import * |
---|
47 |
|
---|
48 |
"""Just a small helper to ask the retry-question without a blocking messagebox""" |
---|
49 |
class StartDialog(QWidget): |
---|
50 |
def __init__(self, parent): |
---|
51 |
QWidget.__init__(self, parent) |
---|
52 |
self.setObjectName("Restart Dialog") |
---|
53 |
self.label = QLabel("Somehow the connection to the dbus-service of FFADO couldn't be established.\nShall we take another try?",self) |
---|
54 |
self.button = QPushButton("Retry", self) |
---|
55 |
self.layout = QGridLayout(self) |
---|
56 |
self.layout.addWidget(self.label, 0, 0, Qt.AlignCenter) |
---|
57 |
self.layout.addWidget(self.button, 1, 0, Qt.AlignCenter) |
---|
58 |
|
---|
59 |
class FFADOWindow(QMainWindow): |
---|
60 |
def __init__(self, parent): |
---|
61 |
QMainWindow.__init__(self, parent) |
---|
62 |
|
---|
63 |
self.textlogger = QTextLogger(self) |
---|
64 |
dock = QDockWidget("Log Messages",self) |
---|
65 |
dock.setWidget(self.textlogger) |
---|
66 |
logging.getLogger('').addHandler(self.textlogger) |
---|
67 |
self.addDockWidget(Qt.BottomDockWidgetArea, dock) |
---|
68 |
|
---|
69 |
self.statuslogger = QStatusLogger(self, self.statusBar(), 20) |
---|
70 |
logging.getLogger('').addHandler(self.statuslogger) |
---|
71 |
|
---|
72 |
self.manager = PanelManager(self) |
---|
73 |
|
---|
74 |
filemenu = self.menuBar().addMenu("File") |
---|
75 |
quitaction = QAction("Quit", self) |
---|
76 |
quitaction.setShortcut(self.tr("Ctrl+q")) |
---|
77 |
self.connect(quitaction, SIGNAL("triggered()"), self, SLOT("close()")) |
---|
78 |
filemenu.addAction(quitaction) |
---|
79 |
|
---|
80 |
editmenu = self.menuBar().addMenu("Edit") |
---|
81 |
self.updateaction = QAction("Update Mixer Panels", self) |
---|
82 |
self.updateaction.setEnabled(False) |
---|
83 |
self.connect(self.updateaction, SIGNAL("triggered()"), self.manager.updatePanels) |
---|
84 |
editmenu.addAction(self.updateaction) |
---|
85 |
|
---|
86 |
helpmenu = self.menuBar().addMenu( "Help" ) |
---|
87 |
aboutaction = QAction( "About FFADO", self ) |
---|
88 |
self.connect( aboutaction, SIGNAL( "triggered()" ), self.aboutFFADO ) |
---|
89 |
helpmenu.addAction( aboutaction ) |
---|
90 |
aboutqtaction = QAction( "About Qt", self ) |
---|
91 |
self.connect( aboutqtaction, SIGNAL( "triggered()" ), qApp, SLOT( "aboutQt()" ) ) |
---|
92 |
helpmenu.addAction( aboutqtaction ) |
---|
93 |
|
---|
94 |
log.info( "Starting up" ) |
---|
95 |
|
---|
96 |
QTimer.singleShot( 1, self.connectToDBUS ) |
---|
97 |
|
---|
98 |
def connectToDBUS(self): |
---|
99 |
try: |
---|
100 |
self.setupDeviceManager() |
---|
101 |
except dbus.DBusException, ex: |
---|
102 |
log.error("Could not communicate with the FFADO DBus service...") |
---|
103 |
if not hasattr(self,"retry"): |
---|
104 |
self.retry = StartDialog(self) |
---|
105 |
self.setCentralWidget(self.retry) |
---|
106 |
self.connect(self.retry.button, SIGNAL("clicked()"), self.tryStartDBUSServer) |
---|
107 |
self.retry.setEnabled(True) |
---|
108 |
|
---|
109 |
def tryStartDBUSServer(self): |
---|
110 |
try: |
---|
111 |
self.setupDeviceManager() |
---|
112 |
except dbus.DBusException, ex: |
---|
113 |
self.retry.setEnabled(False) |
---|
114 |
os.spawnlp( os.P_NOWAIT, "ffado-dbus-server" ) |
---|
115 |
QTimer.singleShot(2000, self.connectToDBUS) |
---|
116 |
|
---|
117 |
def setupDeviceManager(self): |
---|
118 |
devmgr = DeviceManagerInterface(FFADO_DBUS_SERVER, FFADO_DBUS_BASEPATH) |
---|
119 |
nbDevices = devmgr.getNbDevices() |
---|
120 |
self.manager.setManager(devmgr) |
---|
121 |
self.setCentralWidget(self.manager) |
---|
122 |
self.updateaction.setEnabled(True) |
---|
123 |
|
---|
124 |
def aboutFFADO(self): |
---|
125 |
QMessageBox.about( self, "About FFADO", """ |
---|
126 |
<h1>ffado.org</h1> |
---|
127 |
|
---|
128 |
<p>FFADO is the new approach to have firewire audio on linux.</p> |
---|
129 |
|
---|
130 |
<p>© 2006-2008 by the FFADO developers<br />ffado is licensed under the GPLv3, for the full license text see <a href="http://www.gnu.org/licenses/">www.gnu.org/licenses</a> or the LICENSE.* files shipped with ffado.</p> |
---|
131 |
|
---|
132 |
<p>FFADO developers are:<ul> |
---|
133 |
<li>Pieter Palmers |
---|
134 |
<li>Daniel Wagner |
---|
135 |
<li>Jonathan Woithe |
---|
136 |
<li>Arnold Krille |
---|
137 |
</ul> |
---|
138 |
""" ) |
---|
139 |
|
---|
140 |
|
---|
141 |
if __name__ == "__main__": |
---|
142 |
#set up logging |
---|
143 |
import logging |
---|
144 |
logging.basicConfig( datefmt="%H:%M:%S", format="%(asctime)s %(name)-16s %(levelname)-8s %(message)s" ) |
---|
145 |
|
---|
146 |
if DEBUG: |
---|
147 |
debug_level = logging.DEBUG |
---|
148 |
else: |
---|
149 |
debug_level = logging.INFO |
---|
150 |
|
---|
151 |
logging.getLogger('main').setLevel(debug_level) |
---|
152 |
logging.getLogger('dbus').setLevel(debug_level) |
---|
153 |
logging.getLogger('registration').setLevel(debug_level) |
---|
154 |
logging.getLogger('panelmanager').setLevel(debug_level) |
---|
155 |
logging.getLogger('configparser').setLevel(debug_level) |
---|
156 |
|
---|
157 |
logging.getLogger('global').setLevel(debug_level) |
---|
158 |
|
---|
159 |
logging.getLogger('audiofire').setLevel(debug_level) |
---|
160 |
logging.getLogger('bridgeco').setLevel(debug_level) |
---|
161 |
logging.getLogger('edirolfa101').setLevel(debug_level) |
---|
162 |
logging.getLogger('edirolfa66').setLevel(debug_level) |
---|
163 |
logging.getLogger('motu').setLevel(debug_level) |
---|
164 |
logging.getLogger('phase24').setLevel(debug_level) |
---|
165 |
logging.getLogger('phase88').setLevel(debug_level) |
---|
166 |
logging.getLogger('quatafire').setLevel(debug_level) |
---|
167 |
logging.getLogger('saffirebase').setLevel(debug_level) |
---|
168 |
logging.getLogger('saffire').setLevel(debug_level) |
---|
169 |
logging.getLogger('saffirepro').setLevel(debug_level) |
---|
170 |
|
---|
171 |
log = logging.getLogger('main') |
---|
172 |
|
---|
173 |
app = QApplication(sys.argv) |
---|
174 |
app.setWindowIcon( QIcon( SHAREDIR + "/icons/hi64-apps-ffado.png" ) ) |
---|
175 |
|
---|
176 |
|
---|
177 |
mainwindow = FFADOWindow(None) |
---|
178 |
|
---|
179 |
|
---|
180 |
# rock & roll |
---|
181 |
mainwindow.show() |
---|
182 |
QObject.connect(app,SIGNAL("lastWindowClosed()"),app,SLOT("quit()")) |
---|
183 |
app.exec_() |
---|
184 |
|
---|
185 |
# |
---|
186 |
# vim: ts=4 sw=4 et |
---|