Installation script and instruction
[jack_freewheel_button.git] / jack_freewheel_button
blobddd7cf1f470769640ee07ea6d7b2d3cfcbf5557e
1 #!/usr/bin/python
3 # JACK FreeWheel button
5 # Copyright (C) 2010 Nikita Zlobin <cook60020tmp@mail.ru>
7 #*************************************************************************
8 # This file implements dialogs that are not implemented in dedicated files
9 #*************************************************************************
11 # LADI Session Handler 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 2 of the License, or
14 # (at your option) any later version.
16 # LADI Session Handler 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.
21 # You should have received a copy of the GNU General Public License
22 # along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
23 # or write to the Free Software Foundation, Inc.,
24 # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
27 import glib
28 import gtk
29 import jack
31 fw_on = "<b>ON</b>"
32 fw_off = "<b>OFF</b>"
33 fw_slave = "<b>ON</b> <small>SLAVE</small>"
34 text_generic = "<small>FREE WHEEL</small>"
36 jclient_name = "jack_freewheel_button"
38 def on_button_toggled(button):
39 label = button.get_children()[0]
40 if button.get_active():
41 b_label.set_label(text_generic+"\n"+fw_on)
42 jack.set_freewheel(1)
44 global blink_state
45 blink_state = True
46 blink_toggle()
47 else:
48 b_label.set_label(text_generic+"\n"+fw_off)
49 # Return default colors
50 button.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('darkgreen'))
51 button.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.color_parse('darkgreen'))
52 button.modify_bg(gtk.STATE_ACTIVE, gtk.gdk.color_parse('darkgreen'))
53 b_label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse('lightgreen'))
55 button.set_sensitive(True)
56 jack.set_freewheel(0)
58 def check_freewheel():
59 if jack.get_freewheel() > 0:
60 if button.get_active() == False:
61 button.set_active(True)
62 button.set_sensitive(False)
63 b_label.set_label(text_generic+"\n"+fw_slave)
64 b_label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse('pink'))
65 else:
66 button.set_active(False)
68 return True
70 def blink_toggle():
71 if not button.get_active():
72 return True
74 global blink_state
75 if blink_state:
76 button.modify_bg(gtk.STATE_ACTIVE, gtk.gdk.color_parse('brown'))
77 button.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.color_parse('brown'))
78 b_label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse('pink'))
79 blink_state = False
80 else:
81 button.modify_bg(gtk.STATE_ACTIVE, gtk.gdk.color_parse('darkorange'))
82 button.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.color_parse('darkorange'))
83 b_label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse('lightyellow'))
84 blink_state = True
85 return True
87 # Create objects
88 window = gtk.Window()
89 window.set_title("JACK time wheel control")
90 window.set_resizable(False)
91 window.set_decorated(False)
93 button = gtk.ToggleButton()
94 button.set_active(False)
95 button.set_label(text_generic+"\n"+fw_off)
97 b_label = button.get_children()[0]
98 b_label.set_justify(gtk.JUSTIFY_CENTER)
99 b_label.set_use_markup(True)
101 blink_state = False
103 # Connections
104 window.connect("delete-event", gtk.main_quit);
105 button.connect("toggled", on_button_toggled);
106 window.add(button)
108 # Colors
109 button.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('darkgreen'))
110 button.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.color_parse('darkgreen'))
111 button.modify_bg(gtk.STATE_ACTIVE, gtk.gdk.color_parse('darkgreen'))
112 button.modify_bg(gtk.STATE_INSENSITIVE, gtk.gdk.color_parse('darkred'))
113 b_label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse('lightgreen'))
115 # JACK
116 jack.attach(jclient_name)
117 jack.activate()
118 glib.timeout_add(300, check_freewheel)
119 glib.timeout_add(700, blink_toggle)
121 window.show_all()
123 gtk.main()
125 jack.deactivate()
126 jack.detach()