def lash_check_events(lash_client): event = lash.lash_get_event(lash_client) while event: print repr(event) event_type = lash.lash_event_get_type(event) if event_type == lash.LASH_Quit: print("LASH ordered quit.") return False elif event_type == lash.LASH_Save_File: print("LASH ordered to save data in directory %s" % lash.lash_event_get_string(event)) lash.lash_send_event(lash_client, event) elif event_type == lash.LASH_Save_Data_Set: print("LASH ordered to save data") lash.lash_send_event(lash_client, event) elif event_type == lash.LASH_Restore_Data_Set: print("LASH ordered to restore data") lash.lash_event_destroy(event) elif event_type == lash.LASH_Restore_File: print("LASH ordered to restore data from directory %s" % lash.lash_event_get_string(event)) lash.lash_event_destroy(event) else: print("Got unhandled LASH event, type " + str(event_type)) lash.lash_event_destroy(event) return True event = lash.lash_get_event(lash_client) return True
def lash_check_events(lash_client): event = lash.lash_get_event(lash_client) while event: print repr(event) event_type = lash.lash_event_get_type(event) if event_type == lash.LASH_Quit: print "LASH ordered quit." return False elif event_type == lash.LASH_Save_File: print "LASH ordered to save data in directory %s" % lash.lash_event_get_string(event) lash.lash_send_event(lash_client, event) elif event_type == lash.LASH_Save_Data_Set: print "LASH ordered to save data" lash.lash_send_event(lash_client, event) elif event_type == lash.LASH_Restore_Data_Set: print "LASH ordered to restore data" lash.lash_event_destroy(event) elif event_type == lash.LASH_Restore_File: print "LASH ordered to restore data from directory %s" % lash.lash_event_get_string(event) lash.lash_event_destroy(event) else: print "Got unhandled LASH event, type " + str(event_type) lash.lash_event_destroy(event) return True event = lash.lash_get_event(lash_client) return True
def lash_check_events(self): if self.save: self.save = False if self.current_filename: print("saving on SIGUSR1 request") self.on_save_cb() print("save done") else: print("not saving because filename is not known") return True if not self.lash_client: return True while lash.lash_get_pending_event_count(self.lash_client): event = lash.lash_get_event(self.lash_client) #print repr(event) event_type = lash.lash_event_get_type(event) if event_type == lash.LASH_Quit: print("jack_mixer: LASH ordered quit.") Gtk.main_quit() return False elif event_type == lash.LASH_Save_File: directory = lash.lash_event_get_string(event) print("jack_mixer: LASH ordered to save data in directory %s" % directory) filename = directory + os.sep + "jack_mixer.xml" f = file(filename, "w") self.save_to_xml(f) f.close() lash.lash_send_event(self.lash_client, event) # we crash with double free elif event_type == lash.LASH_Restore_File: directory = lash.lash_event_get_string(event) print( "jack_mixer: LASH ordered to restore data from directory %s" % directory) filename = directory + os.sep + "jack_mixer.xml" f = file(filename, "r") self.load_from_xml(f, silence_errors=True) f.close() lash.lash_send_event(self.lash_client, event) else: print("jack_mixer: Got unhandled LASH event, type " + str(event_type)) return True #lash.lash_event_destroy(event) return True
def __init__(self, name, lash_client): self.mixer = jack_mixer_c.Mixer(name) if not self.mixer: return self.monitor_channel = self.mixer.add_output_channel( "Monitor", True, True) self.save = False if lash_client: # Send our client name to server lash_event = lash.lash_event_new_with_type(lash.LASH_Client_Name) lash.lash_event_set_string(lash_event, name) lash.lash_send_event(lash_client, lash_event) lash.lash_jack_client_name(lash_client, name) self.window = Gtk.Window(type=Gtk.WindowType.TOPLEVEL) if name != self.mixer.client_name(): self.window.set_title(name + " (" + self.mixer.client_name() + ")") else: self.window.set_title(name) self.window.set_icon_name('jack_mixer') self.gui_factory = gui.Factory(self.window, self.meter_scales, self.slider_scales) self.vbox_top = Gtk.VBox() self.window.add(self.vbox_top) self.menubar = Gtk.MenuBar() self.vbox_top.pack_start(self.menubar, False, True, 0) mixer_menu_item = Gtk.MenuItem.new_with_mnemonic("_Mixer") self.menubar.append(mixer_menu_item) edit_menu_item = Gtk.MenuItem.new_with_mnemonic('_Edit') self.menubar.append(edit_menu_item) help_menu_item = Gtk.MenuItem.new_with_mnemonic('_Help') self.menubar.append(help_menu_item) self.window.set_default_size(120, 300) mixer_menu = Gtk.Menu() mixer_menu_item.set_submenu(mixer_menu) add_input_channel = Gtk.MenuItem.new_with_mnemonic( 'New _Input Channel') mixer_menu.append(add_input_channel) add_input_channel.connect("activate", self.on_add_input_channel) add_output_channel = Gtk.MenuItem.new_with_mnemonic( 'New _Output Channel') mixer_menu.append(add_output_channel) add_output_channel.connect("activate", self.on_add_output_channel) mixer_menu.append(Gtk.SeparatorMenuItem()) open = Gtk.MenuItem.new_with_mnemonic('_Open') mixer_menu.append(open) open.connect('activate', self.on_open_cb) save = Gtk.MenuItem.new_with_mnemonic('_Save') mixer_menu.append(save) save.connect('activate', self.on_save_cb) save_as = Gtk.MenuItem.new_with_mnemonic('Save_As') mixer_menu.append(save_as) save_as.connect('activate', self.on_save_as_cb) mixer_menu.append(Gtk.SeparatorMenuItem()) quit = Gtk.MenuItem.new_with_mnemonic('_Quit') mixer_menu.append(quit) quit.connect('activate', self.on_quit_cb) edit_menu = Gtk.Menu() edit_menu_item.set_submenu(edit_menu) self.channel_edit_input_menu_item = Gtk.MenuItem.new_with_mnemonic( '_Edit Input Channel') edit_menu.append(self.channel_edit_input_menu_item) self.channel_edit_input_menu = Gtk.Menu() self.channel_edit_input_menu_item.set_submenu( self.channel_edit_input_menu) self.channel_edit_output_menu_item = Gtk.MenuItem.new_with_mnemonic( 'Edit _Output Channel') edit_menu.append(self.channel_edit_output_menu_item) self.channel_edit_output_menu = Gtk.Menu() self.channel_edit_output_menu_item.set_submenu( self.channel_edit_output_menu) self.channel_remove_input_menu_item = Gtk.MenuItem.new_with_mnemonic( 'Remove _Input Channel') edit_menu.append(self.channel_remove_input_menu_item) self.channel_remove_input_menu = Gtk.Menu() self.channel_remove_input_menu_item.set_submenu( self.channel_remove_input_menu) self.channel_remove_output_menu_item = Gtk.MenuItem.new_with_mnemonic( '_Remove Output Channel') edit_menu.append(self.channel_remove_output_menu_item) self.channel_remove_output_menu = Gtk.Menu() self.channel_remove_output_menu_item.set_submenu( self.channel_remove_output_menu) channel_remove_all_menu_item = Gtk.MenuItem.new_with_mnemonic('Clear') edit_menu.append(channel_remove_all_menu_item) channel_remove_all_menu_item.connect("activate", self.on_channels_clear) edit_menu.append(Gtk.SeparatorMenuItem()) preferences = Gtk.MenuItem.new_with_mnemonic('_Preferences') preferences.connect('activate', self.on_preferences_cb) edit_menu.append(preferences) help_menu = Gtk.Menu() help_menu_item.set_submenu(help_menu) about = Gtk.MenuItem.new_with_mnemonic('_About') help_menu.append(about) about.connect("activate", self.on_about) self.hbox_top = Gtk.HBox() self.vbox_top.pack_start(self.hbox_top, True, True, 0) self.scrolled_window = Gtk.ScrolledWindow() self.hbox_top.pack_start(self.scrolled_window, True, True, 0) self.hbox_inputs = Gtk.HBox() self.hbox_inputs.set_spacing(0) self.hbox_inputs.set_border_width(0) self.hbox_top.set_spacing(0) self.hbox_top.set_border_width(0) self.channels = [] self.output_channels = [] self.scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) self.scrolled_window.add(self.hbox_inputs) self.hbox_outputs = Gtk.HBox() self.hbox_outputs.set_spacing(0) self.hbox_outputs.set_border_width(0) frame = Gtk.Frame() self.hbox_outputs.pack_start(frame, False, True, 0) self.hbox_top.pack_start(self.hbox_outputs, False, True, 0) self.window.connect("destroy", Gtk.main_quit) self.window.connect('delete-event', self.on_delete_event) GLib.timeout_add(80, self.read_meters) self.lash_client = lash_client GLib.timeout_add(200, self.lash_check_events) GLib.timeout_add(50, self.midi_events_check)
def __init__(self, name, lash_client): self.mixer = jack_mixer_c.Mixer(name) if not self.mixer: return self.monitor_channel = self.mixer.add_output_channel( "Monitor", True, True) self.save = False if lash_client: # Send our client name to server lash_event = lash.lash_event_new_with_type(lash.LASH_Client_Name) lash.lash_event_set_string(lash_event, name) lash.lash_send_event(lash_client, lash_event) lash.lash_jack_client_name(lash_client, name) self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) if name != self.mixer.client_name(): self.window.set_title(name + " (" + self.mixer.client_name() + ")") else: self.window.set_title(name) self.window.set_icon_name('jack_mixer') self.gui_factory = gui.Factory(self.window, self.meter_scales, self.slider_scales) self.vbox_top = gtk.VBox() self.window.add(self.vbox_top) self.menubar = gtk.MenuBar() self.vbox_top.pack_start(self.menubar, False) mixer_menu_item = gtk.MenuItem("_Mixer") self.menubar.append(mixer_menu_item) edit_menu_item = gtk.MenuItem('_Edit') self.menubar.append(edit_menu_item) help_menu_item = gtk.MenuItem('_Help') self.menubar.append(help_menu_item) self.window.set_default_size(120, 300) mixer_menu = gtk.Menu() mixer_menu_item.set_submenu(mixer_menu) add_input_channel = gtk.ImageMenuItem('New _Input Channel') mixer_menu.append(add_input_channel) add_input_channel.connect("activate", self.on_add_input_channel) add_output_channel = gtk.ImageMenuItem('New _Output Channel') mixer_menu.append(add_output_channel) add_output_channel.connect("activate", self.on_add_output_channel) mixer_menu.append(gtk.SeparatorMenuItem()) open = gtk.ImageMenuItem(gtk.STOCK_OPEN) mixer_menu.append(open) open.connect('activate', self.on_open_cb) save = gtk.ImageMenuItem(gtk.STOCK_SAVE) mixer_menu.append(save) save.connect('activate', self.on_save_cb) save_as = gtk.ImageMenuItem(gtk.STOCK_SAVE_AS) mixer_menu.append(save_as) save_as.connect('activate', self.on_save_as_cb) mixer_menu.append(gtk.SeparatorMenuItem()) quit = gtk.ImageMenuItem(gtk.STOCK_QUIT) mixer_menu.append(quit) quit.connect('activate', self.on_quit_cb) edit_menu = gtk.Menu() edit_menu_item.set_submenu(edit_menu) self.channel_edit_input_menu_item = gtk.MenuItem('_Edit Input Channel') edit_menu.append(self.channel_edit_input_menu_item) self.channel_edit_input_menu = gtk.Menu() self.channel_edit_input_menu_item.set_submenu( self.channel_edit_input_menu) self.channel_edit_output_menu_item = gtk.MenuItem( 'Edit _Output Channel') edit_menu.append(self.channel_edit_output_menu_item) self.channel_edit_output_menu = gtk.Menu() self.channel_edit_output_menu_item.set_submenu( self.channel_edit_output_menu) self.channel_remove_input_menu_item = gtk.MenuItem( 'Remove _Input Channel') edit_menu.append(self.channel_remove_input_menu_item) self.channel_remove_input_menu = gtk.Menu() self.channel_remove_input_menu_item.set_submenu( self.channel_remove_input_menu) self.channel_remove_output_menu_item = gtk.MenuItem( '_Remove Output Channel') edit_menu.append(self.channel_remove_output_menu_item) self.channel_remove_output_menu = gtk.Menu() self.channel_remove_output_menu_item.set_submenu( self.channel_remove_output_menu) channel_remove_all_menu_item = gtk.ImageMenuItem(gtk.STOCK_CLEAR) edit_menu.append(channel_remove_all_menu_item) channel_remove_all_menu_item.connect("activate", self.on_channels_clear) edit_menu.append(gtk.SeparatorMenuItem()) preferences = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES) preferences.connect('activate', self.on_preferences_cb) edit_menu.append(preferences) help_menu = gtk.Menu() help_menu_item.set_submenu(help_menu) about = gtk.ImageMenuItem(gtk.STOCK_ABOUT) help_menu.append(about) about.connect("activate", self.on_about) self.hbox_top = gtk.HBox() self.vbox_top.pack_start(self.hbox_top, True) self.scrolled_window = gtk.ScrolledWindow() self.hbox_top.pack_start(self.scrolled_window, True) self.hbox_inputs = gtk.HBox() self.hbox_inputs.set_spacing(0) self.hbox_inputs.set_border_width(0) self.hbox_top.set_spacing(0) self.hbox_top.set_border_width(0) self.channels = [] self.output_channels = [] self.scrolled_window.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.scrolled_window.add_with_viewport(self.hbox_inputs) self.hbox_outputs = gtk.HBox() self.hbox_outputs.set_spacing(0) self.hbox_outputs.set_border_width(0) frame = gtk.Frame() self.hbox_outputs.pack_start(frame, False) self.hbox_top.pack_start(self.hbox_outputs, False) self.window.connect("destroy", gtk.main_quit) self.trayicon = TrayIcon(self) self.window.connect('delete-event', self.on_delete_event) gobject.timeout_add(80, self.read_meters) self.lash_client = lash_client gobject.timeout_add(200, self.lash_check_events) gobject.timeout_add(50, self.midi_events_check)
lash.lash_event_get_string(event)) lash.lash_event_destroy(event) else: print("Got unhandled LASH event, type " + str(event_type)) lash.lash_event_destroy(event) return True event = lash.lash_get_event(lash_client) return True # sys.argv is modified by this call lash_client = lash.init(sys.argv, "pylash test", lash.LASH_Config_Data_Set | lash.LASH_Terminal) if not lash_client: print("Cannot connect to LASH server") sys.exit(1) print("Successfully connected to LASH server at " + lash.lash_get_server_name(lash_client)) # Send our client name to server lash_event = lash.lash_event_new_with_type(lash.LASH_Client_Name) lash.lash_event_set_string(lash_event, "pylash test") lash.lash_send_event(lash_client, lash_event) # loop until we receive quit order from LASH server while lash_check_events(lash_client): time.sleep(1)
print "LASH ordered to restore data" lash.lash_event_destroy(event) elif event_type == lash.LASH_Restore_File: print "LASH ordered to restore data from directory %s" % lash.lash_event_get_string(event) lash.lash_event_destroy(event) else: print "Got unhandled LASH event, type " + str(event_type) lash.lash_event_destroy(event) return True event = lash.lash_get_event(lash_client) return True # sys.argv is modified by this call lash_client = lash.init(sys.argv, "pylash test", lash.LASH_Config_Data_Set | lash.LASH_Terminal) if not lash_client: print "Cannot connect to LASH server" sys.exit(1) print "Successfully connected to LASH server at " + lash.lash_get_server_name(lash_client) # Send our client name to server lash_event = lash.lash_event_new_with_type(lash.LASH_Client_Name) lash.lash_event_set_string(lash_event, "pylash test") lash.lash_send_event(lash_client, lash_event) # loop until we receive quit order from LASH server while lash_check_events(lash_client): time.sleep(1)