/usr/bin/ladi-player is in laditools 1.1.0-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | #!/usr/bin/python
# LADITools - Linux Audio Desktop Integration Tools
# laditray - System tray integration for LADI
# Copyright (C) 2012 Alessio Treglia <quadrispro@ubuntu.com>
#
# This program 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 3 of the License, or
# (at your option) any later version.
#
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
import os
import sys
import time
import gettext
import argparse
from laditools import _gettext_domain
gettext.install(_gettext_domain)
from laditools import get_version_string
from laditools import LadiConfiguration
from laditools import LadiApp
from gi.repository import Gtk
from gi.repository import GObject
from laditools import LadiManager
from laditools.gtk import LadiManagerGtk
from laditools.gtk import find_data_file
timeout_add = GObject.timeout_add
class LadiPlayer(LadiManagerGtk, LadiApp):
_appname = 'ladi-player'
_appname_long = _("LADI Player")
_appid = 'org.linuxaudio.ladi.player'
# Default configuration
_default_config = {
'autostart' : False,
}
def on_about(self, *args):
LadiManagerGtk.on_about(self, parent=self.window_main, version=get_version_string())
def quit(self, *args, **kwargs):
self.global_config.set_config_section (self.appname,
self.config_dict)
self.global_config.save()
Gtk.main_quit()
def _run_select_studio_dialog(self, title, *args):
studio_list = self.get_ladish_controller().studio_list()
if not studio_list:
dlg = Gtk.MessageDialog(None,Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
Gtk.MessageType.INFO,
Gtk.ButtonsType.CLOSE,
_('No studio is available.'))
dlg.set_transient_for(self.window_main)
dlg.set_title(title)
dlg.run()
dlg.destroy()
return None
dlg = Gtk.Dialog()
treeview = Gtk.TreeView()
model = Gtk.ListStore(GObject.TYPE_STRING)
renderer = Gtk.CellRendererText()
column = Gtk.TreeViewColumn('Available studios', renderer, text=0)
treeview.set_model(model)
treeview.append_column(column)
treeview.set_cursor(Gtk.TreePath(path=0),
focus_column=column,
start_editing=False)
for studio in studio_list:
model.append((studio,))
dlg.set_transient_for(self.window_main)
dlg.set_modal(True)
dlg.set_destroy_with_parent(True)
dlg.set_title(title)
dlg.get_content_area().pack_start(child=treeview,
expand=True,
fill=True,
padding=10)
dlg.add_button(Gtk.STOCK_OK, Gtk.ResponseType.OK)
dlg.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
dlg.show_all()
response = dlg.run()
ret = None
if response == Gtk.ResponseType.OK:
path, column = treeview.get_cursor()
ret = model[path][0]
dlg.hide()
return ret
def _toolbuttons_set_active(self, group, **kwargs):
buttons = getattr(self, "%s_status_buttons" % group)
if 'all' in kwargs:
status = kwargs['all']
for button in buttons:
buttons[button].set_sensitive(status)
else:
for button in kwargs:
buttons[button].set_sensitive(kwargs[button])
def jack_is_started(self, *args, **kwargs):
while True:
try:
return LadiManagerGtk.jack_is_started(self, *args, **kwargs)
except:
time.sleep(0.5)
continue
def ladish_toolbuttons_set_active(self, **kwargs): self._toolbuttons_set_active('ladish', **kwargs)
def jack_toolbuttons_set_active(self, **kwargs): self._toolbuttons_set_active('jack', **kwargs)
def a2j_toolbuttons_set_active(self, **kwargs): self._toolbuttons_set_active('a2j', **kwargs)
def ladish_status_buttons_update(self):
buttons = self.ladish_status_buttons
# Setup ladish controls
if self.ladish_is_available():
# Buttons "rename" and "unload"
if self.studio_is_loaded():
self.ladish_toolbuttons_set_active(unload=True, rename=True)
# Buttons "start" and "stop"
if self.studio_is_started():
self.ladish_toolbuttons_set_active(start=False, stop=True, save=True)
else:
self.ladish_toolbuttons_set_active(start=True, stop=False, save=False)
else:
self.ladish_toolbuttons_set_active(start=True,
stop=False,
save=False,
unload=False,
rename=False)
else:
self.ladish_toolbuttons_set_active(all=False)
def jack_status_buttons_update(self):
if not self.jack_is_available():
return
buttons = self.jack_status_buttons
ladish_available = self.ladish_is_available()
jack_started = self.jack_is_started()
if jack_started:
self.jack_toolbuttons_set_active(jack_start=False,
jack_stop=(not ladish_available),
jack_reset_xruns=True,
jack_reactivate=True)
else:
self.jack_toolbuttons_set_active(jack_start=True,
jack_stop=False,
jack_reset_xruns=False,
jack_reactivate=True)
def a2j_status_buttons_update(self):
if not self.a2j_is_available():
self.a2j_toolbuttons_set_active(all=False)
return
buttons = self.a2j_status_buttons
ladish_available = self.ladish_is_available()
a2j_started = self.a2j_is_started()
if not ladish_available:
if a2j_started:
self.a2j_toolbuttons_set_active(a2j_start=False,
a2j_stop=True,
a2j_reactivate=True)
else:
self.a2j_toolbuttons_set_active(a2j_start=True,
a2j_stop=False,
a2j_reactivate=True)
else:
self.a2j_toolbuttons_set_active(a2j_start=False,
a2j_stop=False,
a2j_reactivate=True)
def update_status_buttons(self):
# Update widgets
self.ladish_status_buttons_update()
self.jack_status_buttons_update()
self.a2j_status_buttons_update()
# Update status label and window icon
if self.jack_is_started():
self.window_main.set_icon_name("ladi-started")
if self.jack_is_realtime():
status_text = "RT | "
else:
status_text = ""
# Get DSP Load
status_text += str (round (float (self.jack_get_load()),1)) + "% | "
# Get Xruns
status_text += str (self.jack_get_xruns())
# Set a started status
self.status_label.set_label (status_text)
else:
self.window_main.set_icon_name("ladi-stopped")
self.status_label.set_label(_('<i>Stopped</i>'))
def update(self, *args, **kwargs):
self.update_status_buttons()
LadiManagerGtk.update(self, *args, **kwargs)
return True
def _set_starting_status(self):
self.window_main.set_icon_name("ladi-starting")
def action_ladish_new(self, action, *args):
self.studio_new()
def action_ladish_start(self, action, *args):
if self.studio_is_loaded():
if not self.studio_is_started():
self._set_starting_status()
self.studio_start()
self.update_status_buttons()
else:
self._set_starting_status()
self.jack_start()
self.update_status_buttons()
def action_ladish_save(self, action, *args):
self.studio_save()
def action_ladish_stop(self, action, *args):
if self.jack_is_started() and self.studio_is_started():
self.studio_stop()
self.update_status_buttons()
def action_ladish_rename(self, action, *args):
self.studio_rename()
self.update_status_buttons()
def action_ladish_load(self, action, *args):
selection = self._run_select_studio_dialog(_('Load studio'))
if selection:
self.studio_load(studio=selection)
return selection
def action_ladish_delete(self, action, *args):
selection = self._run_select_studio_dialog(_('Delete studio'))
if selection:
LadiManager.studio_delete(self, studio=selection)
return selection
def action_ladish_unload(self, action, *args):
while True:
try:
if self.studio_is_loaded():
self.studio_unload()
self.update_status_buttons()
break
except:
time.sleep(0.5)
continue
def action_ladish_reactivate(self, action, *args):
self.ladish_reactivate()
def action_jack_start(self, action, *args):
self._set_starting_status()
self.jack_start()
def action_jack_stop(self, action, *args):
self.jack_stop()
def action_jack_reset_xruns(self, action, *args):
self.jack_reset_xruns()
def action_jack_reactivate(self, action, *args):
self.jack_reactivate()
def action_a2j_start(self, action, *args):
self.a2j_start()
def action_a2j_stop(self, action, *args):
self.a2j_stop()
def action_a2j_reactivate(self, action, *args):
self.a2j_reactivate()
def action_launcher_launch(self, action, *args):
self.launcher_exec(command=self._launcher_which(action.get_name()))
def __init__(self):
# Initialize app
LadiApp.__init__(self)
# Handle the configuration
self.global_config = LadiConfiguration(self.appname, self._default_config)
self.config_dict = self.global_config.get_config_section (self.appname)
autostart = bool(eval(self.config_dict['autostart']))
LadiManagerGtk.__init__(self, autostart)
# Handle signals
self.connect_signals_quit()
# Build the UI
builder = Gtk.Builder()
ui_path = find_data_file("ladi-player.ui")
builder.add_from_file(ui_path)
sys.stderr.write( _("Loading interface from %s\n") % ui_path)
sys.stderr.flush()
# Retrieve objects
self.window_main = builder.get_object("window_main")
actiongroup_ladish = builder.get_object("actiongroup_ladish")
actiongroup_jack = builder.get_object("actiongroup_jack")
actiongroup_a2j = builder.get_object("actiongroup_a2j")
actiongroup_launcher = builder.get_object("actiongroup_launcher")
self.status_label = builder.get_object('toolbutton_label_status')
# Setup status buttons
self.ladish_status_buttons = ladish_status_buttons = {}
self.jack_status_buttons = jack_status_buttons = {}
self.a2j_status_buttons = a2j_status_buttons = {}
self.launcher_status_buttons = launcher_status_buttons = {}
for action in actiongroup_ladish.list_actions():
ladish_status_buttons[action.get_name()] = action
for action in actiongroup_jack.list_actions():
jack_status_buttons[action.get_name()] = action
for action in actiongroup_a2j.list_actions():
a2j_status_buttons[action.get_name()] = action
for action in actiongroup_launcher.list_actions():
launcher_status_buttons[action.get_name()] = action
# Remove launchers for unavailable commands
for command in launcher_status_buttons:
if not self._launcher_which(command):
launcher_status_buttons[command].set_active(False)
# Accelerators
# accelgroup = builder.get_object("accelgroup1")
# action = actiongroup_launcher.get_action("gladish")
# action.set_accel_group(accelgroup)
# action.set_accel_path("menu_studio")
# Get the initial status
self.update ()
# Add the auto update callback
self.auto_updater = timeout_add (250, self.update, None)
builder.connect_signals(self)
def run(self):
self.window_main.show_all()
Gtk.main()
if __name__ == "__main__":
parser = argparse.ArgumentParser(description=_('graphical front-end that allows users to start, stop and '
'monitor JACK, as well as start some JACK related applications.'),
epilog=_('This program is part of the LADITools suite.'))
parser.add_argument('--version', action='version', version="%(prog)s " + get_version_string())
parser.parse_args()
Gtk.init(None)
LadiPlayer().run()
sys.exit(0)
|