3 # LADITools - Linux Audio Desktop Integration Tools
4 # wmladi - Window maker dockapp for jackdbus
5 # Copyright (C) 2007-2010, Marc-Olivier Barre <marco@marcochapeau.org>
6 # Copyright (C) 2007-2009, Nedko Arnaudov <nedko@arnaudov.name>
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 from wmdocklib
import wmoo
, pywmhelpers
32 # Default configuration
36 class wmladi (wmoo
.Application
, laditools
.manager
):
38 # Handle the configuration
39 self
.global_config
= laditools
.config ()
40 self
.param_dict
= self
.global_config
.get_config_section ('wmladi')
41 if self
.param_dict
!= None:
42 if 'autostart' not in self
.param_dict
:
43 self
.param_dict
['autostart'] = str (autostart_default
)
46 self
.param_dict
['autostart'] = str (autostart_default
)
47 autostart
= self
.param_dict
['autostart']
48 wmoo
.Application
.__init
__ (
50 #background = os.path.dirname(sys.argv[0]) + os.sep + "wmjackctl.xpm",
54 laditools
.manager
.__init
__(self
, self
.global_config
.get_config_section ('ladimenu'), int(autostart
))
56 self
.addCallback (self
.on_button_release
, 'buttonrelease', area
=(0,0,64,64))
60 self
.lines
.append ("")
64 def set_starting_status (self
):
65 self
.set_line (0, "JACK")
66 self
.set_line (1, "Starting")
72 def on_button_release (self
, event
):
73 if event
['button'] == 3:
76 def set_line (self
, line
, text
):
77 self
.lines
[line
] = text
78 while len (self
.lines
[line
]) < 9:
79 self
.lines
[line
] += ' '
81 def clear_line (self
, line
):
82 self
.set_line (line
, "")
90 if self
.jack_is_started():
94 if self
.jack_is_realtime():
99 if self
.a2j_is_available():
101 if self
.a2j_is_started():
108 self
.set_line(0, line0
)
109 self
.set_line(1, "started")
110 self
.set_line(2, "%.3f %%" % self
.jack_get_load())
112 xruns
= self
.jack_get_xruns()
114 self
.set_line(3, "no xruns")
116 self
.set_line(3, "1 xrun")
118 self
.set_line(3, "lot xruns")
120 self
.set_line(3, "%s xruns" % xruns
)
122 rate
= self
.jack_get_sample_rate()
123 if rate
% 1000.0 == 0:
124 self
.set_line(4, "%.0f Khz" % (rate
/ 1000.0))
126 self
.set_line(4, "%.1f Khz" % (rate
/ 1000.0))
128 self
.set_line(5, "%.1f ms" % self
.jack_get_latency())
130 self
.set_line(0, "JACK")
131 self
.set_line(1, "stopped")
138 self
.clear_diagnose_text()
140 self
.set_diagnose_text(repr(e
))
143 self
.set_line(0, "JACK")
144 self
.set_line(1, "is sick")
149 self
.clear_jack_proxies()
151 self
.put_lines (self
.lines
)
152 wmoo
.Application
.update (self
)
153 # Take a look at the processes we've started so we don't get any zombies
154 for i
in self
.proc_list
:
157 def put_lines (self
, lines
):
161 self
.putString (x
, y
, line
)
164 def do_dockapp (self
):
165 """this is called from event loop. events are examined and if a
166 callback has been registered, it is called, passing it the event as
169 event
= pywmhelpers
.getEvent ()
170 while not event
is None:
171 if event
['type'] == 'destroynotify':
174 for evtype
, key
, area
, callback
in self
._events
:
175 if evtype
is not None and evtype
!= event
['type']: continue
176 if key
is not None and key
!= event
['button']: continue
178 if not area
[0] <= event
['x'] <= area
[2]: continue
179 if not area
[1] <= event
['y'] <= area
[3]: continue
183 event
= pywmhelpers
.getEvent ()
188 def run_sleep (self
):
191 while gtk
.events_pending ():
192 gtk
.main_iteration ()
194 while gtk
.events_pending ():
195 gtk
.main_iteration ()
196 time
.sleep (self
._sleep
)
200 gobject
.timeout_add (int(self
._sleep
* 1000), self
.do_dockapp
)
205 self
.global_config
.set_config_section ('wmladi', self
.param_dict
)
206 self
.global_config
.set_config_section ('ladimenu', self
.menu_array
)
207 self
.global_config
.save ()