All pastes #257707 Raw Edit

Anonymous

public python v1 · immutable
#257707 ·published 2006-11-25 17:55 UTC
rendered paste body
####AlsaDevices.py#####def GetAlsaList(type):	"""Returns a dictionary containing ALSA device names and their correspoding ALSA ids (e.g. hw:0).	Keyword arguments:	type -- specifies the type of ALSA device we are looking for, playback or capture."""	#Get HAL Manager	bus = dbus.SystemBus()	object = bus.get_object("org.freedesktop.Hal", "/org/freedesktop/Hal/Manager")	manager = dbus.Interface(object, "org.freedesktop.Hal.Manager")		found = {}	#Find all alsa devices of the requested type	devices = manager.FindDeviceStringMatch("alsa.type", type)	#Add the ALSA default card to the list	found["Default"] = "default"	for device in devices:		#Iterate through all the ALSA devices found and insert them in to a dictionary		device_object = bus.get_object("org.freedesktop.Hal", device)		properties = device_object.GetAllProperties(dbus_interface="org.freedesktop.Hal.Device")		name = properties["alsa.device_id"]		cardnum = "hw:" + str(properties["alsa.card"]) #FIXME: This may cause problems with plughw devices		#Avoid duplicate entries		if cardnum not in found.values():			found[name] = cardnum			return found####PreferencesDialog.py####	def __init__(self, project, mainwindow, icon=None):		"""Keyword arguments:		project -- The jokosher project currently loaded.		mainwindow -- A reference to the main Jokosher window		icon -- The icon for the window manager to display for this window (optional)."""		self.project = project		self.mainwindow = mainwindow		#Initialize GTK resources from glade file		self.res = gtk.glade.XML(Globals.GLADE_PATH, "PreferencesDialog")		self.signals = {			"on_Setting_changed" : self.OnSettingChanged,			"on_Close_clicked" : self.OnClose,		}		self.res.signal_autoconnect(self.signals)		self.dlg = self.res.get_widget("PreferencesDialog")		self.dlg.set_icon(icon)		self.recordingFileFormat = self.res.get_widget("recordingFileFormat")		self.samplingRate = self.res.get_widget("samplingRate")		self.playingDevice = self.res.get_widget("playbackDevice")		self.radioWelcome = self.res.get_widget("startupWelcomeDialog")		self.radioLastProject = self.res.get_widget("startupLastProject")		self.radioNothing = self.res.get_widget("startupNothing")		#Find all ALSA devices 		self.playbacks = AlsaDevices.GetAlsaList("playback")		for playback in self.playbacks:			print playback			self.playingDevice.append_text(playback)