Viewing file: soundcard.py (30.76 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
## soundcard.py - Contains the UI code needed for system-config-soundcard ## Copyright (C) 2002, 2003 Red Hat, Inc. ## Copyright (C) 2002, 2003 Brent Fox <bfox@redhat.com> ## Copyright (C) 2004, 2005 Bastien Nocera <hadess@hadess.net>
## 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 2 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, write to the Free Software ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import string import gtk import gobject import string import sys import os import time import commands sys.path.append('/usr/share/system-config-soundcard/') import soundcardBackend
## ## I18N ## from rhpl.translate import _, N_ import rhpl.translate as translate translate.textdomain ("system-config-soundcard")
DETECTION_KUDZU = "kudzu" DETECTION_PROC = "proc" DETECTION_HAL = "hal"
## ## Loading image from file ## def load_image(file, file_back): pix = None try: pix = gtk.gdk.pixbuf_new_from_file(file) except: try: pix = gtk.gdk.pixbuf_new_from_file(file_back) except: pass
image = gtk.Image() if pix: image.set_from_pixbuf(pix)
return image
## ## Icon for windows ##
iconPixbuf = None try: iconPixbuf = gtk.gdk.pixbuf_new_from_file("/usr/share/system-config-soundcard/pixmaps/system-config-soundcard.png") except: pass
class childWindow: #You must specify a runPriority for the order in which you wish your module to run runPriority = 64 moduleName = _("Soundcard Detection") commentTag = _("Auto-detect and configure soundcard") def destroy(self, *args): if self.play_sound_card_index != None : self.soundcardBackend.stopTestSound(self.play_sound_card_index) self.play_sound_card_index = None gtk.main_quit() def __init__(self, doDebug=None, backend=None): self.mainWindow = None
self.card_list = None self.doDebug = doDebug
if backend == None: self.soundcardBackend = soundcardBackend.soundcardBackend() else: self.soundcardBackend = backend
# Last slide in notebook self.last_slide = None
# Sound question self.question = False # play test sound repeatedly self.repeat = False # State variable # 0 - don't play # 1 - let's play self.play_sound = False # Last tested card self.play_sound_card_index = None # Stop button pressed self.play_sound_stop = False # tun callback self.timer = gtk.timeout_add (100, self.checkStatus, self)
def checkStatus(self, obj): page_num = self.notebook_cardlist.get_current_page() if page_num == -1: return True card_index = self.notebook_card_indexes[page_num] status = self.soundcardBackend.checkTestSound(card_index) if self.doDebug: print "checkStatus - status", status # notebook switch - stop sound #page = self.notebook_cardlist.get_nth_page(page_num) if self.last_slide != page_num: self.last_slide = page_num self.play_sound_stop = True # sound finished - stop sound if (status[1] and not self.repeat): self.play_sound_stop = True self.question = True
# request for stoping sound if self.play_sound_stop: self.play_sound_stop = False self.play_sound = False if self.play_sound: if self.doDebug: print "Play sound" if(status[0]): return True self.playLabelSet(True, page_num) self.soundcardBackend.playTestSound(card_index) self.play_sound_card_index = card_index return True
if not self.play_sound: if self.doDebug: print "Stop sound"
self.playLabelSet(False, page_num)
if status[0]: self.soundcardBackend.stopTestSound(self.play_sound_card_index) self.play_sound_card_index = None if self.question: self.soundQuestion() self.question = False
return True def getRepeat(self): return self.repeat
def setRepeat(self, widget): self.repeat = widget.get_active(); for rbutton in self.notebook_card_repeats: rbutton.set_active(self.repeat) def cancelClicked(self, *args): self.mainWindow.destroy() self.destroy()
def okayClicked(self, *args): self.applyChanges() self.mainWindow.destroy() self.destroy() def changeHW(self, widget, data=None): self.soundcardBackend.setHardwareDevice(widget.get_active()) def applyChanges(self, *args): self.soundcardBackend.writeConfig()
def playLabelSet(self, state, page): if state: self.notebook_card_labels[page].set_text(_("--- Playing ---")) else: self.notebook_card_labels[page].set_text(_("--- Stopped ---"))
def playButtonClicked(self, button, card_index): self.play_sound = True
def stopButtonClicked(self, button, card_index): self.play_sound_stop = True
def volumeChanged(self, adj, card_index): self.soundcardBackend.setVolume(card_index, adj.value) def soundQuestion(self): text = (_("Did you hear the sample sound?")) dlg = gtk.MessageDialog(self.mainWindow, 0, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO,text)
dlg.set_title("") dlg.set_default_size(100, 100) dlg.set_position (gtk.WIN_POS_CENTER_ON_PARENT) dlg.set_border_width(2) dlg.set_modal(True) rc = dlg.run() dlg.destroy()
if rc == gtk.RESPONSE_NO: self.soundcardBackend.writeLog() #Oh well, they couldn't hear the sound. Notify the user and then quit. We did our best self.showErrorDialog(_("Automatic detection of the sound card did not work. " \ "This audio device will not be available on the system.\n\n" \ "You can create %s, %s on the System tab and " \ "file a new bug\nat http://bugzilla.redhat.com.\n\nPlease click " \ "OK to continue.") % ("/root/scsconfig.log", "/root/scsrun.log"))
def writeUnloadReload(self, selectedItem, module): self.soundcardBackend.writeFile(selectedItem) self.soundcardBackend.unloadModules() result = self.soundcardBackend.loadModules()
if result != 0: #Loading the module failed. Notify the user that things are broken self.showErrorDialog(_("The %s driver could not be loaded." % module)) else: self.soundcardBackend.setVolume()
def create_frame(self, widget, border = 5, label = None, shadow = gtk.SHADOW_NONE): frame = gtk.Frame(label) frame.set_border_width(border) frame.set_shadow_type(shadow) frame.add(widget) frame.show_all() return frame def change_selected_card(self, noteboook, page, page_num): print "self:", self print "noteboook:", noteboook print "page:", page print "page_num:", page_num return 0 def create_test_page_fill(self, card): table = gtk.Table(2, 3) table.set_border_width(6) table.set_col_spacings(10) table.set_row_spacings(4)
maker_label = gtk.Label("") maker_label2 = gtk.Label("")
if card.maker != None: maker_label.set_markup("<span><b>" "%s</b></span>" % _("Vendor:")) maker_label.set_alignment(0.0, 0.5) maker_label2 = gtk.Label(card.maker) maker_label2.set_alignment(0.0, 0.5) elif card.type != None: maker_label.set_markup("<span><b>" "%s</b></span>" % _("Card:")) maker_label.set_alignment(0.0, 0.5) maker_label2 = gtk.Label(card.type) maker_label2.set_alignment(0.0, 0.5)
model_label = gtk.Label("") model_label.set_markup("<span><b>" "%s</b></span>" % _("Model:")) model_label.set_alignment(0.0, 0.5)
model_label2 = gtk.Label(card.model) model_label2.set_alignment(0.0, 0.5)
module_label = gtk.Label("") module_label.set_markup("<span><b>" "%s</b></span>" % _("Module:")) module_label.set_alignment(0.0, 0.5)
module_label2 = gtk.Label(_(card.driver)) module_label2.set_alignment(0.0, 0.5)
align = gtk.Alignment(0.0, 0.0, 1.0, 1.0)
table.attach(maker_label, 0, 1, 0, 1, gtk.FILL, gtk.FILL) table.attach(maker_label2, 1, 2, 0, 1, gtk.FILL, gtk.FILL) table.attach(model_label, 0, 1, 1, 2, gtk.FILL, gtk.FILL) table.attach(model_label2, 1, 2, 1, 2, gtk.FILL, gtk.FILL) table.attach(module_label, 0, 1, 2, 3, gtk.FILL, gtk.FILL) table.attach(module_label2, 1, 2, 2, 3, gtk.FILL, gtk.FILL) description = self.create_frame(table, 0, _("Selected card"), gtk.SHADOW_ETCHED_IN)
#Create box that contains volume slider #Image with zero volume image_volume_zero = load_image("../pixmaps/stock-volume-zero.png", "/usr/share/system-config-soundcard/pixmaps/stock-volume-zero.png") # Volume slider adj1 = gtk.Adjustment(self.soundcardBackend.getVolume(card.index), 45, 100, 1, 1, 1) adj1.connect("value_changed", self.volumeChanged, card.index) volume = gtk.HScale(adj1) volume.set_update_policy(gtk.UPDATE_CONTINUOUS) volume.set_draw_value(False) # Image with max-volume image_volume_max = load_image("../pixmaps/stock-volume-max.png", "/usr/share/system-config-soundcard/pixmaps/stock-volume-max.png")
volumeBox = gtk.HBox(False, 5) volumeBox.pack_start(image_volume_zero,False) volumeBox.pack_start(volume) volumeBox.pack_end(image_volume_max,False)
# Control box with Play/Stop/repeat button and status
# Create a check-box for repeat rbutton = gtk.CheckButton(_("Repeat")) rbutton.set_active(self.getRepeat()) rbutton.connect("toggled", self.setRepeat)
# Create a play button image1 = load_image("../pixmaps/stock-media-play.png", "/usr/share/system-config-soundcard/pixmaps/stock-media-play.png") play_button = gtk.Button() play_button.add(image1) play_button.connect("clicked", self.playButtonClicked, card.index) # Create a stop button image2 = load_image("../pixmaps/stock-media-stop.png", "/usr/share/system-config-soundcard/pixmaps/stock-media-stop.png") stop_button = gtk.Button() stop_button.add(image2) stop_button.connect("clicked", self.stopButtonClicked, card.index)
# Label with status play_label = gtk.Label() play_label.set_text(_("--- Stopped ---"))
controlBox = gtk.HBox(False, 8) controlBox.pack_start(play_button,False) controlBox.pack_start(stop_button,False) controlBox.pack_start(play_label) controlBox.pack_end(rbutton,False) controlBox = self.create_frame(self.create_frame(controlBox), 0, \ _("Sound test"), gtk.SHADOW_ETCHED_IN) volumeBox = self.create_frame(self.create_frame(volumeBox), 0, \ _("Volume settings"), gtk.SHADOW_ETCHED_IN) deviceBox = self.create_frame(self.create_frame(self.create_sub_device_menu_create( \ _("PCM device"), self.test_device_menu_handler,card.index,card.test_sound_device)), 0, \ _("Device settings"), gtk.SHADOW_ETCHED_IN)
tmp = gtk.VBox(False, 8) tmp.add(description) tmp.add(controlBox) tmp.add(volumeBox) tmp.add(deviceBox) tmp.show_all() return tmp, play_label, rbutton
def create_test_page(self, firsboot = False):
# Entire page self.toplevel = gtk.VBox() self.toplevel.set_spacing(10) # A box with icon and description... self.icon_box = gtk.HBox() self.icon_box.set_spacing(5) #Add icon to the top frame if not firsboot: self.icon = load_image("../pixmaps/system-config-soundcard.png", "/usr/share/system-config-soundcard/pixmaps/system-config-soundcard.png") self.icon_box.pack_start(self.icon, False)
#Add label cardNum = self.soundcardBackend.getCardNum() if cardNum == 0: self.label = gtk.Label(_("No soundcards were detected.")) else: if cardNum == 1: self.label = gtk.Label(_("The following audio device was detected.")) else: self.label = gtk.Label(_("The following audio devices were detected.")) self.icon_box.pack_start(self.label, False)
# add icon-box to page self.toplevel.pack_start(self.icon_box, False)
self.notebook_card_indexes = [] self.notebook_card_labels = [] self.notebook_card_repeats = [] self.notebook_cardlist = gtk.Notebook() self.notebook_cardlist.set_tab_pos(gtk.POS_LEFT) #self.notebook_cardlist.connect("switch-page", self.change_selected_card)
if cardNum == 0: label = gtk.Label("") else: cardList = self.soundcardBackend.getCardArray() for card in cardList: if not card.active: continue;
page, label, repeat_button = self.create_test_page_fill(card) page = self.create_frame(page, 10) self.notebook_cardlist.append_page(page, gtk.Label(card.getDescription()))
self.notebook_card_indexes.append(card.index) self.notebook_card_labels.append(label) self.notebook_card_repeats.append(repeat_button)
self.toplevel.pack_start(self.notebook_cardlist, False) self.notebook_cardlist.set_current_page(0)
if cardNum == 1: self.notebook_cardlist.set_show_tabs(False) self.notebook_cardlist.set_show_border(False) return self.toplevel
def create_sub_device_menu_refresh(self, device_menu_handler, card_index, default_device):
#print "create_sub_device_menu_refresh, device = %d" % default_device
list = gtk.Menu() device_list = self.soundcardBackend.getCardDevices(card_index) selected = 0 if device_list != [] : order = 0 for device in device_list: menu_item = gtk.MenuItem(device[1]) menu_item.connect_object("activate",device_menu_handler,device[0]) list.append(menu_item)
if(device[0] == default_device): selected = order else: order += 1
list.set_active(selected) self.sub_device_menu.set_menu(list) self.sub_device_menu.show_all()
def create_sub_device_menu_create(self, label, device_menu_handler, card_index, default_device):
self.sub_device_menu = gtk.OptionMenu() self.create_sub_device_menu_refresh(device_menu_handler, card_index, default_device) tmpBox = gtk.HBox(False, 8) tmpBox.pack_start(gtk.Label(label), False) tmpBox.pack_start(self.sub_device_menu, True) return tmpBox
def default_device_menu_handler(self, data): #print "Default device %d" % data card_index = self.soundcardBackend.getDefaultCard() self.soundcardBackend.setCardDefaultDevice(card_index, data)
def test_device_menu_handler(self, data): #print "Test device %d" % data page_num = self.notebook_cardlist.get_current_page() card_index = self.notebook_card_indexes[page_num] self.soundcardBackend.setCardTestDevice(card_index, data)
def create_combo_box(self, label):
Menu = gtk.OptionMenu()
tmpBox = gtk.HBox(False, 8) tmpBox.pack_start(gtk.Label(label), False) tmpBox.pack_start(Menu, True)
return tmpBox
def create_combo_box_cardlist_refresh(self, menu_handler, selected_card): list = gtk.Menu()
cardList = self.soundcardBackend.getCardArray() selected = 0 for card in cardList: if card.active: menuItem = gtk.MenuItem(("%s %s") % (card.maker, card.model)) else: menuItem = gtk.MenuItem(_(" - ")) menuItem.connect_object("activate", menu_handler,card.index) list.append(menuItem)
list.set_active(selected_card) self.card_combo_menu.set_menu(list) self.card_combo_menu.show_all()
def create_combo_box_cardlist_create(self, label, menu_handler, selected_card):
self.card_combo_menu = gtk.OptionMenu() self.create_combo_box_cardlist_refresh(menu_handler, selected_card)
tmpBox = gtk.HBox(False, 8) tmpBox.pack_start(gtk.Label(label), False) tmpBox.pack_start(self.card_combo_menu, True)
return tmpBox def create_combo_box_cardlist_handler(self, data): #print "Default card %d" % data self.soundcardBackend.setDefaultCard(data) #print self.soundcardBackend.getCardDefaultDevice(data) #print "card %d device %d" % (data, self.soundcardBackend.getDefaultCardDevice(data)) self.create_sub_device_menu_refresh(self.default_device_menu_handler, data, \ self.soundcardBackend.getCardDefaultDevice(data))
def create_settings_page_card_list_callback(self, treeview): #print "Zmena" treeselection = treeview.get_selection() model, iter = treeselection.get_selected() store = treeview.get_model() val0 = store.get_value(iter,0) val1 = store.get_value(iter,1) #print val0 #print val1 return
# nacist hodnotu indexu zvukovky (co je vybrana) # zvysit/snizit jeji indexu # podivat se na okolni karty a podle toho ji zaradit def switch_store_find(self, store, index): iter = store.get_iter_first() while iter: akt_index = store.get_value(iter, 0) if akt_index == index: return iter iter = store.iter_next(iter) return None def switch_store_set_index(self, store, iter, direction): store.set_value(iter, 0, store.get_value(iter, 0) + direction) return def switch_store_swap_index(self, store, new_iter, old_iter): new = store.get_value(new_iter, 0) old = store.get_value(old_iter, 0) store.set_value(old_iter, 0, new) store.set_value(new_iter, 0, old) store.swap(old_iter, new_iter) return def switch_store(self, store, index, direction): old_iter = self.switch_store_find(store, index) new_iter = self.switch_store_find(store, index + direction)
if new_iter == None: self.switch_store_set_index(store, old_iter, direction) else: self.switch_store_swap_index(store, old_iter, new_iter) return def create_settings_page_card_list_button(self, button, direction): treeselection = self.card_list.get_selection() model, iter = treeselection.get_selected() if(iter != None): store = self.card_list.get_model() index = store.get_value(iter, 0) new_index = index + direction if self.soundcardBackend.isCardIndexValid(new_index): #print "Old position %d" % index #print "New position %d" % (index + direction) self.soundcardBackend.setCardIndexAndReOrder(index, direction) self.switch_store(store, index, direction)
# re-order list of default cards self.create_combo_box_cardlist_refresh(self.create_combo_box_cardlist_handler,\ self.soundcardBackend.getDefaultCard())
#self.soundcardBackend.dumpCards() #self.soundcardBackend.soundConfig.dump() self.soundcardBackend.cardIndexChanged()
return def create_settings_page(self):
default_card = self.soundcardBackend.getDefaultCard()
tmpBox1 = self.create_combo_box_cardlist_create(_("Default audio card:"), \ self.create_combo_box_cardlist_handler, default_card) tmpBox2 = self.create_sub_device_menu_create(_("Default PCM device:"), \ self.default_device_menu_handler, default_card, \ self.soundcardBackend.getCardDefaultDevice(default_card))
defaultBox = gtk.VBox(True, 5) defaultBox.pack_start(tmpBox1, False, False) defaultBox.pack_start(tmpBox2, False, False) defaultBox.show_all() defaultBox = self.create_frame(self.create_frame(defaultBox,8),0,_("Default audio devices"),gtk.SHADOW_ETCHED_IN)
settingsBox = gtk.VBox(False, 8) settingsBox.pack_start(defaultBox, False, False) configBox = gtk.VBox(False, 0)
#Create a check-box for hw/sw config button = gtk.CheckButton(_("Disable specific card configuration")) button.set_active(self.soundcardBackend.getHardwareDevice()) button.connect("toggled", self.changeHW) configBox.pack_start(button) configBox.show_all()
configBox = self.create_frame(self.create_frame(configBox,8),0,_("ALSA plugins"),gtk.SHADOW_ETCHED_IN) settingsBox.pack_start(configBox, False, False) # card order cardBox = gtk.HBox(False, 5) liststore = gtk.ListStore(int, str) cardList = self.soundcardBackend.getCardArray() for card in cardList: if card.active: liststore.append([card.index, card.getName()])
self.card_list = gtk.TreeView(liststore) cell = gtk.CellRendererText()
tvcolumn = gtk.TreeViewColumn(_("Index")) tvcolumn.pack_start(cell, True) tvcolumn.set_attributes(cell, text=0) self.card_list.append_column(tvcolumn) tvcolumn1 = gtk.TreeViewColumn(_("Card")) cell1 = gtk.CellRendererText() tvcolumn1.pack_start(cell1, True) tvcolumn1.set_attributes(cell1, text=1) self.card_list.append_column(tvcolumn1) #tvcolumn.set_sort_column_id(0) #treeview.set_search_column(0) self.card_list.set_reorderable(False) self.card_list.connect("cursor-changed", self.create_settings_page_card_list_callback)
cardBox.pack_start(self.card_list, True, True) # Reorder buttons buttonBox = gtk.VBox(False, 5) up_button = gtk.Button(_("Move Up"), gtk.STOCK_GO_UP) up_button.connect("clicked", self.create_settings_page_card_list_button,-1) down_button = gtk.Button(_("Move Down"), gtk.STOCK_GO_DOWN) down_button.connect("clicked", self.create_settings_page_card_list_button,1) buttonBox.pack_end(down_button,False,False) buttonBox.pack_end(up_button,False,False) cardBox.pack_start(buttonBox, False, False)
cardBox.show_all() cardBox = self.create_frame(self.create_frame(cardBox,8),0,_("Audio cards order"),gtk.SHADOW_ETCHED_IN)
settingsBox.pack_start(cardBox, False, False) return settingsBox
def create_system_page_modules_reload(self, widget): self.soundcardBackend.reloadModules() def create_system_page(self): table = gtk.Table(2, 3) table.set_border_width(6) table.set_col_spacings(10) table.set_row_spacings(4)
maker_label = gtk.Label("") maker_label.set_markup("<span><b>" "%s</b></span>" % _("ALSA Driver version:")) maker_label.set_alignment(0.0, 0.5) maker_label2 = gtk.Label(self.soundcardBackend.getDriverVersion()) maker_label2.set_alignment(0.0, 0.5)
model_label = gtk.Label("") model_label.set_markup("<span><b>" "%s</b></span>" % _("ALSA Lib package(s):")) model_label.set_alignment(0.0, 0.5)
model_label2 = gtk.Label(self.soundcardBackend.getLibVersion()) model_label2.set_alignment(0.0, 0.5)
module_label = gtk.Label("") module_label.set_markup("<span><b>" "%s</b></span>" % _("ALSA Utils package(s):")) module_label.set_alignment(0.0, 0.5)
module_label2 = gtk.Label(self.soundcardBackend.getUtilsVersion()) module_label2.set_alignment(0.0, 0.5)
align = gtk.Alignment(0.0, 0.0, 1.0, 1.0)
table.attach(maker_label, 0, 1, 0, 1, gtk.FILL, gtk.FILL) table.attach(maker_label2, 1, 2, 0, 1, gtk.FILL, gtk.FILL) table.attach(model_label, 0, 1, 1, 2, gtk.FILL, gtk.FILL) table.attach(model_label2, 1, 2, 1, 2, gtk.FILL, gtk.FILL) table.attach(module_label, 0, 1, 2, 3, gtk.FILL, gtk.FILL) table.attach(module_label2, 1, 2, 2, 3, gtk.FILL, gtk.FILL) infoBox = gtk.VBox(False, 8) alsaBox = self.create_frame(self.create_frame(table,8),0,_("ALSA sound system information"),gtk.SHADOW_ETCHED_IN) infoBox.pack_start(alsaBox,False,False)
report_button = gtk.Button(_("Generate sound log file %s") % "/root/scsconfig.log") report_button.connect("clicked", self.soundcardBackend.writeLog) reportBox = self.create_frame(self.create_frame(report_button,8),0,_("Report"),gtk.SHADOW_ETCHED_IN) infoBox.pack_start(reportBox,False,False)
reload_button = gtk.Button(_("Reload audio drivers")) reload_button.connect("clicked", self.create_system_page_modules_reload)
detectionBox = gtk.HBox(False, 8) detectionBox.pack_start(reload_button, True, True) detectionBox = self.create_frame(self.create_frame(detectionBox,8),0,_("Drivers"),gtk.SHADOW_ETCHED_IN) infoBox.pack_start(detectionBox, False, False)
return infoBox
def refresh_notebook(self): self.notebook.remove_page(0) self.notebook.remove_page(0) self.notebook.prepend_page(self.create_frame(self.create_settings_page()), gtk.Label(_("Settings"))) self.notebook.prepend_page(self.create_frame(self.create_test_page()), gtk.Label(_("Sound test"))) self.notebook.show_all()
def launch(self): print "Running from first-boot..." self.mainVBox = gtk.VBox() self.internalVBox = gtk.VBox(False, 10) self.internalVBox.set_border_width(10)
eventBox = gtk.EventBox() eventBox.add(self.icon_box) eventBox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse ("#cc0000"))
self.icon_box.pack_start(self.icon, False, True) self.icon_box.pack_start(self.title) self.mainVBox.pack_start(eventBox, False) self.msg_label.set_size_request(500, -1) self.internalVBox.pack_start(self.msg_label, False) self.mainVBox.pack_start(self.internalVBox, True) return self.mainVBox, eventBox
def stand_alone(self):
print "Running from command-line..." self.mainWindow = gtk.Dialog() self.mainWindow.vbox.set_spacing(5) self.mainWindow.connect("destroy", self.destroy) self.mainWindow.set_title(_("Audio configuration")) self.mainWindow.set_border_width(10) self.mainWindow.set_position(gtk.WIN_POS_CENTER) self.mainWindow.set_icon(iconPixbuf) self.applyButton = self.mainWindow.add_button('gtk-apply', 0) self.applyButton.connect("clicked", self.applyChanges) self.okButton = self.mainWindow.add_button('gtk-ok', 0) self.okButton.connect("clicked", self.okayClicked) self.cancelButton = self.mainWindow.add_button('gtk-cancel', 0) self.cancelButton.connect("clicked", self.cancelClicked) # Create main page self.notebook = gtk.Notebook() self.notebook.append_page(self.create_frame(self.create_test_page()), gtk.Label(_("Sound test"))) self.notebook.append_page(self.create_frame(self.create_settings_page()), gtk.Label(_("Settings"))) self.notebook.append_page(self.create_frame(self.create_system_page()), gtk.Label(_("System"))) self.notebook.set_current_page(0) #Remove the hsep from the dialog. It's ugly hsep = self.mainWindow.get_children()[0].get_children()[0] self.mainWindow.get_children()[0].remove(hsep) self.mainWindow.vbox.pack_start(self.notebook) self.mainWindow.show_all() gtk.main()
def showErrorDialog(self, text): dlg = gtk.MessageDialog(self.mainWindow, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, text)
dlg.set_title(_("Error")) dlg.set_default_size(100, 100) dlg.set_position (gtk.WIN_POS_CENTER_ON_PARENT) dlg.set_border_width(2) dlg.set_modal(True) rc = dlg.run() dlg.destroy() return def showInfoDialog(self, text): dlg = gtk.MessageDialog(self.mainWindow, 0, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, text)
dlg.set_title(_("Information")) dlg.set_default_size(100, 100) dlg.set_position (gtk.WIN_POS_CENTER_ON_PARENT) dlg.set_border_width(2) dlg.set_modal(True) rc = dlg.run() dlg.destroy() return
def getSoundcardBox(self): box = gtk.HBox() box.pack_start(self.create_test_page(True), True, False) return box
|