root/branches/libffado-2.0/support/mixer-qt4/ffado-mixer.in

Revision 1415, 4.5 kB (checked in by arnonym, 15 years ago)

Quite some stuff:

  • add a simple python-parser for the format of the configuration-file already used by ffado
  • add the names of the mixers to be used to the configuration-file
  • port the PanelManager? to QMainWindow and introduce a menu and a statusbar
  • set the icon of the application to the beautiful ffado-icon

TODO for the next time:

  • overwrite the global config with the local config in PanelManager?
  • "About FFADO" in the help-menu
  • maybe also move the names of the mixers python-files into the configuration and load them only on demand. And then use this info also in the SConscript :-)
  • also add menu-items to recheck the status of the mixer and maybe even the ability to trigger a bus-reset from gui. But that would need ppalmers to implement that action in the dbus-server.
  • Property svn:executable set to *
Line 
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
40 from PyQt4.QtGui import QApplication, QMessageBox, QIcon
41
42 from ffado_dbus_util import *
43
44 from ffado_panelmanager import PanelManager
45
46 if __name__ == "__main__":
47     #set up logging
48     import logging
49     logging.basicConfig()
50
51     if DEBUG:
52         debug_level = logging.DEBUG
53     else:
54         debug_level = logging.INFO
55
56     logging.getLogger('main').setLevel(debug_level)
57     logging.getLogger('dbus').setLevel(debug_level)
58     logging.getLogger('registration').setLevel(debug_level)
59     logging.getLogger('panelmanager').setLevel(debug_level)
60
61     logging.getLogger('global').setLevel(debug_level)
62
63     logging.getLogger('audiofire').setLevel(debug_level)
64     logging.getLogger('bridgeco').setLevel(debug_level)
65     logging.getLogger('edirolfa101').setLevel(debug_level)
66     logging.getLogger('edirolfa66').setLevel(debug_level)
67     logging.getLogger('motu').setLevel(debug_level)
68     logging.getLogger('phase24').setLevel(debug_level)
69     logging.getLogger('phase88').setLevel(debug_level)
70     logging.getLogger('quatafire').setLevel(debug_level)
71     logging.getLogger('saffirebase').setLevel(debug_level)
72     logging.getLogger('saffire').setLevel(debug_level)
73     logging.getLogger('saffirepro').setLevel(debug_level)
74
75     log = logging.getLogger('main')
76
77     app = QApplication(sys.argv)
78     app.setWindowIcon( QIcon( SHAREDIR + "/icons/hi64-apps-ffado.png" ) )
79
80     msg = QMessageBox()
81
82     repeat = 1
83     while repeat > 0:
84         try:
85             devmgr = DeviceManagerInterface(FFADO_DBUS_SERVER, FFADO_DBUS_BASEPATH)
86             nbDevices = devmgr.getNbDevices()
87             repeat -= 1
88         except dbus.DBusException, ex:
89             log.error("")
90             log.error("")
91             log.error("===========================================================")
92             log.error("ERROR: Could not communicate with the FFADO DBus service...")
93             log.error("===========================================================")
94             log.error("")
95             log.error("")
96             tmp = msg.question( msg, "FFADO-DBus not found", "<qt><b>The connection to FFADOs DBus service could not be established.</b><p>Probably you didn't start the ffado-dbus-server. Should I try this now?</qt>", QMessageBox.Yes, QMessageBox.No )
97             if tmp == QMessageBox.No:
98                 sys.exit(-1)
99             else:
100                 os.spawnlp( os.P_NOWAIT, "ffado-dbus-server" )
101                 nb_checks = 20
102                 while nb_checks > 0:
103                     nb_checks = nb_checks - 1
104                     try:
105                         devmgr = DeviceManagerInterface(FFADO_DBUS_SERVER, FFADO_DBUS_BASEPATH)
106                         nbDevices = devmgr.getNbDevices()
107                         nb_checks = 0
108                         repeat = 0
109                     except dbus.DBusException, ex:
110                         time.sleep( 1 )
111
112     manager = PanelManager(None, devmgr)
113
114     # create a timer to poll the panels
115     polltimer = QTimer()
116     QObject.connect( polltimer, SIGNAL('timeout()'), manager.pollPanels )
117     polltimer.start( POLL_SLEEP_TIME_MSEC )
118
119     # create a timer to initialize the panel after the main form is shown
120     # since initialization can take a while
121     showtimer = QTimer()
122     QObject.connect( showtimer, SIGNAL('timeout()'), manager.updatePanels )
123     showtimer.setSingleShot(True)
124     showtimer.start( POLL_SLEEP_TIME_MSEC )
125
126     # rock & roll
127     manager.show()
128     QObject.connect(app,SIGNAL("lastWindowClosed()"),app,SLOT("quit()"))
129     app.exec_()
Note: See TracBrowser for help on using the browser.