def configure(self, parent): """ Show the configuration window """ if self.cfgWin is None: self.cfgWin = gui.window.Window('AudioCD.ui', 'vbox1', __name__, MOD_L10N, 335, 270) self.cfgWin.getWidget('btn-ok').connect('clicked', self.onBtnOk) self.cfgWin.getWidget('btn-help').connect('clicked', self.onBtnHelp) self.cfgWin.getWidget('chk-useCDDB').connect('toggled', self.onUseCDDBToggled) self.cfgWin.getWidget('btn-clearCache').connect('clicked', self.onBtnClearCache) self.cfgWin.getWidget('btn-cancel').connect('clicked', lambda btn: self.cfgWin.hide()) # Set up the combo box combo = self.cfgWin.getWidget('combo-read-speed') txtRenderer = gtk.CellRendererText() combo.pack_start(txtRenderer, True) combo.add_attribute(txtRenderer, 'text', 0) combo.set_sensitive(True) txtRenderer.set_property('xpad', 6) # Setup the liststore store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_INT) combo.set_model(store) for speed in sorted(READ_SPEEDS.iterkeys()): store.append(('%ux' % speed, speed)) if not self.cfgWin.isVisible(): self.cfgWin.getWidget('btn-ok').grab_focus() self.cfgWin.getWidget('txt-device').set_text(prefs.get(__name__, 'device', PREFS_DFT_DEVICE)) self.cfgWin.getWidget('chk-useCDDB').set_active(prefs.get(__name__, 'use-cddb', PREFS_DFT_USE_CDDB)) self.cfgWin.getWidget('chk-useCache').set_sensitive(prefs.get(__name__, 'use-cddb', PREFS_DFT_USE_CDDB)) self.cfgWin.getWidget('chk-useCache').set_active(prefs.get(__name__, 'use-cache', PREFS_DFT_USE_CACHE)) self.cfgWin.getWidget('combo-read-speed').set_active(READ_SPEEDS[prefs.get(__name__, 'read-speed', PREFS_DFT_READ_SPEED)]) self.cfgWin.show()
def onModLoaded(self): """ The module has been loaded """ txtRdrLen = gtk.CellRendererText() columns = (('', [(gtk.CellRendererPixbuf(), gtk.gdk.Pixbuf), (txtRdrLen, gobject.TYPE_STRING), (gtk.CellRendererText(), gobject.TYPE_STRING)], True), (None, [(None, gobject.TYPE_PYOBJECT)], False)) self.tree = extTreeview.ExtTreeView(columns, True) self.popup = None self.cfgWin = None self.expName = MOD_L10N self.scrolled = gtk.ScrolledWindow() self.cacheDir = os.path.join(consts.dirCfg, MOD_INFO[modules.MODINFO_NAME]) # The album length is written in a smaller font, with a lighter color txtRdrLen.set_property('scale', 0.85) txtRdrLen.set_property('foreground-gdk', self.tree.get_style().text[gtk.STATE_INSENSITIVE]) # Explorer self.tree.setDNDSources([consts.DND_TARGETS[consts.DND_DAP_TRACKS]]) self.scrolled.add(self.tree) self.scrolled.set_shadow_type(gtk.SHADOW_IN) self.scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.scrolled.show() # GTK handlers self.tree.connect('drag-data-get', self.onDragDataGet) self.tree.connect('key-press-event', self.onKeyPressed) self.tree.connect('exttreeview-button-pressed', self.onButtonPressed) modules.postMsg(consts.MSG_CMD_EXPLORER_ADD, {'modName': MOD_L10N, 'expName': self.expName, 'icon': icons.cdromMenuIcon(), 'widget': self.scrolled}) # Hide the album length when not drawing the root node self.tree.get_column(0).set_cell_data_func(txtRdrLen, self.__drawAlbumLenCell) # CD-ROM drive read speed modules.postMsg(consts.MSG_CMD_SET_CD_SPEED, {'speed': prefs.get(__name__, 'read-speed', PREFS_DFT_READ_SPEED)})
def loadDisc(self): """ Read disc information and create the explorer tree accordingly """ import DiscID try: discInfo = DiscID.disc_id(DiscID.open(prefs.get(__name__, 'device', PREFS_DFT_DEVICE))) except Exception, err: if err[0] == 123: self.tree.replaceContent([(icons.cdromMenuIcon(), None, _('No disc found'), None)]) modules.postMsg(consts.MSG_CMD_EXPLORER_RENAME, {'modName': MOD_L10N, 'expName': self.expName, 'newExpName': MOD_L10N}) self.expName = MOD_L10N else: logger.error('[%s] Unable to read device\n\n%s' % (MOD_INFO[modules.MODINFO_NAME], traceback.format_exc())) return
def onModUnloaded(self): """ The module is going to be unloaded """ modules.postMsg(consts.MSG_CMD_EXPLORER_REMOVE, {'modName': MOD_L10N, 'expName': self.expName}) if not prefs.get(__name__, 'use-cache', PREFS_DFT_USE_CACHE): self.clearCache()