def on_btnSaveFilter_clicked(self, *args): """save the current filter""" #save current filter filters.write_filter( self.current_filter, os.path.join(CONFIG_DIR, 'files', '%s-%s.ftr' % (self.emu_name, self.emu_list_idx))) self.filter_altered = False
def on_btnSaveFilter_clicked(self, *args): """save the current filter""" #save current filter filters.write_filter( self.current_filter, os.path.join( self.config_dir, 'files', '%s-%s.ftr' % (self.emu_name, self.emu_list_idx))) self.filter_altered = False
def set_menu(self, menu_level, heading=''): """setup options list to given menu""" #get menu heading if not supplied if heading == '': for v in self._menus.values(): for ml in v: if ml[1] == menu_level: heading = ml[0] #default heading if heading == '': heading = _('Options') #set labels self.lblHeading.set_text(heading) self.lblSettingHeading.set_text(_('Current Setting:')) self.lblSettingValue.set_text('') self.lsOptions = [] #which menu? self.current_menu = menu_level #hide stuff if necessary if menu_level == 'main': #hide "select platform" if only one emu in list if len(self.WinMain.emu_lists) == 1: self._menus[menu_level][0][0] = '**HIDE**' #hide "music" menu if not self.WinMain.music_enabled: self._menus[menu_level][5][0] = '**HIDE**' elif menu_level == 'exit': #hide shutdown & reboot menu if not dbus_imported: self._menus[menu_level][1][0] = '**HIDE**' self._menus[menu_level][2][0] = '**HIDE**' #show menu if menu_level == 'emu_list': #show all emulators self.lblSettingValue.set_text(self.WinMain.emu_ini.get('emulator_title')) for emu_title, emu_name, e in self.WinMain.emu_lists: self.lsOptions.append([emu_title, emu_name]) self.sclOptions.set_selected(0) elif menu_level == 'game_list': #show all game lists self.lblSettingValue.set_text(self.WinMain.current_list_ini.get('list_title')) for list_name, idx, cycle_list in self.WinMain.game_lists: self.lsOptions.append([list_name, idx]) self.sclOptions.set_selected(self.WinMain.current_list_idx) elif menu_level == 'add_to_list': #show "normal" game lists self.lblSettingValue.set_text(self.WinMain.current_list_ini.get('list_title')) for list_name, idx, cycle_list in self.WinMain.game_lists_normal: if list_name != self.WinMain.current_list_ini.get('list_title'): self.lsOptions.append([list_name, idx]) self.sclOptions.set_selected(0) elif menu_level == 'find': #find by letter [self.lsOptions.append([c, 'find:%s' % (c)]) for c in '%s%s' % (string.uppercase, string.digits)] elif menu_level == 'list_options': #show game list options menu self.sclOptions.set_selected(0) if self.WinMain.current_list_idx == 0: #list 0, so display "generate list" instead of "generate filtered list" self.lsOptions.append(self._menus[menu_level][0]) self.lsOptions.append(self._menus[menu_level][1]) self.lsOptions.append(self._menus[menu_level][3]) else: #all other lists [self.lsOptions.append(menu_item) for menu_item in self._menus[menu_level][:3]] elif menu_level == 'generate_list': #re-create initial filter self.lblHeading.set_text(_('Please Wait...')) self.lblSettingHeading.set_text(_('Generating new games list...')) self.do_events() filter_file = os.path.join( CONFIG_DIR, 'files', '%s-%s.ftr' % (self.WinMain.current_emu, self.WinMain.current_list_idx)) filters.create_initial_filter( self.WinMain.emu_ini.get('dat_file'), filter_file, os.path.join( CONFIG_DIR, 'files', '%s-0.lst' % (self.WinMain.current_emu)), self.WinMain.emu_ini) self.WinMain.load_list() self.WinMain.hide_window('options') elif menu_level == 'generate_ftr': #display filter categories menu self._display_clone_idx = int(self.WinMain.current_filter['filter_type']) self.sclOptions.set_selected(0) [self.lsOptions.append(menu_item) for menu_item in self._menus[menu_level]] elif menu_level.startswith('ftr:'): #display a specific filter menu... self.sclOptions.set_selected(0) #get title for mdesc, mcode in self._menus['generate_ftr']: if mcode == menu_level: title = mdesc break self.lblHeading.set_text(title) #display all items in filter for filt_item in self.WinMain.current_filter[menu_level[4:]].keys(): self.lsOptions.append([filt_item, filt_item]) self.lsOptions.sort() self.lsOptions.insert(0, [_('Show ALL'), 'all']) self.lsOptions.insert(1, [_('Show NONE'), 'none']) elif menu_level == 'generate_new_list': #generate new filtered games list self.lblHeading.set_text(_('Please Wait...')) self.lblSettingHeading.set_text(_('Generating new filtered games list...')) self.do_events() #save current filter filters.write_filter( self.WinMain.current_filter, os.path.join( CONFIG_DIR, 'files', '%s-%s.ftr' % (self.WinMain.current_emu, self.WinMain.current_list_idx))) #create list from the just saved filter filters.create_filtered_list( os.path.join( CONFIG_DIR, 'files', '%s-0.lst' % (self.WinMain.current_emu)), self.WinMain.current_filter, os.path.join( CONFIG_DIR, 'files', '%s-%s.lst' % (self.WinMain.current_emu, self.WinMain.current_list_idx))) self.WinMain.load_list() self.WinMain.hide_window('options') elif menu_level == 'music_dir': #display contents of current music dir #print "music dir=", self.WinMain.gstMusic.current_dir self.lblHeading.set_text(self.WinMain.gstMusic.current_dir) dir_files, music_files = self.get_music_files(self.WinMain.gstMusic.current_dir) self.sclOptions.set_selected(0) for df in dir_files: self.lsOptions.append([df, 'music_dir']) for mf in music_files: self.lsOptions.append([mf, 'music_track']) else: #show appropriate menu self.sclOptions.set_selected(0) #[self.lsOptions.append(menu_item) for menu_item in self._menus[menu_level]] [self.lsOptions.append(m) for m in self._menus[menu_level] if m[0] != '**HIDE**'] #update list widget self.sclOptions.ls = [l[0] for l in self.lsOptions] self.sclOptions.set_selected(self.sclOptions.get_selected())
def set_menu(self, menu_level, heading=''): """setup options list to given menu""" #get menu heading if not supplied if heading == '': for v in self._menus.values(): for ml in v: if ml[1] == menu_level: heading = ml[0] #default heading if heading == '': heading = _('Options') #set labels self.lblHeading.set_text(heading) self.lblSettingHeading.set_text(_('Current Setting:')) self.lblSettingValue.set_text('') self.lsOptions = [] #which menu? self.current_menu = menu_level #hide stuff if necessary if menu_level == 'main': #hide "select platform" if only one emu in list if len(self.WinMain.emu_lists) == 1: self._menus[menu_level][0][0] = '**HIDE**' #hide "music" menu if not self.WinMain.music_enabled: self._menus[menu_level][5][0] = '**HIDE**' elif menu_level == 'exit': #hide shutdown & reboot menu if not dbus_imported: self._menus[menu_level][1][0] = '**HIDE**' self._menus[menu_level][2][0] = '**HIDE**' #show menu if menu_level == 'emu_list': #show all emulators self.lblSettingValue.set_text( self.WinMain.emu_ini.get('emulator_title')) for emu_title, emu_name, e in self.WinMain.emu_lists: self.lsOptions.append([emu_title, emu_name]) self.sclOptions.set_selected(0) elif menu_level == 'game_list': #show all game lists self.lblSettingValue.set_text( self.WinMain.current_list_ini.get('list_title')) for list_name, idx, cycle_list in self.WinMain.game_lists: self.lsOptions.append([list_name, idx]) self.sclOptions.set_selected(self.WinMain.current_list_idx) elif menu_level == 'add_to_list': #show "normal" game lists self.lblSettingValue.set_text( self.WinMain.current_list_ini.get('list_title')) for list_name, idx, cycle_list in self.WinMain.game_lists_normal: if list_name != self.WinMain.current_list_ini.get( 'list_title'): self.lsOptions.append([list_name, idx]) self.sclOptions.set_selected(0) elif menu_level == 'find': #find by letter [ self.lsOptions.append([c, 'find:%s' % (c)]) for c in '%s%s' % (string.uppercase, string.digits) ] elif menu_level == 'list_options': #show game list options menu self.sclOptions.set_selected(0) if self.WinMain.current_list_idx == 0: #list 0, so display "generate list" instead of "generate filtered list" self.lsOptions.append(self._menus[menu_level][0]) self.lsOptions.append(self._menus[menu_level][1]) self.lsOptions.append(self._menus[menu_level][3]) else: #all other lists [ self.lsOptions.append(menu_item) for menu_item in self._menus[menu_level][:3] ] elif menu_level == 'generate_list': #re-create initial filter self.lblHeading.set_text(_('Please Wait...')) self.lblSettingHeading.set_text(_('Generating new games list...')) self.do_events() filter_file = os.path.join( CONFIG_DIR, 'files', '%s-%s.ftr' % (self.WinMain.current_emu, self.WinMain.current_list_idx)) filters.create_initial_filter( self.WinMain.emu_ini.get('dat_file'), filter_file, os.path.join(CONFIG_DIR, 'files', '%s-0.lst' % (self.WinMain.current_emu)), self.WinMain.emu_ini) self.WinMain.load_list() self.WinMain.hide_window('options') elif menu_level == 'generate_ftr': #display filter categories menu self._display_clone_idx = int( self.WinMain.current_filter['filter_type']) self.sclOptions.set_selected(0) [ self.lsOptions.append(menu_item) for menu_item in self._menus[menu_level] ] elif menu_level.startswith('ftr:'): #display a specific filter menu... self.sclOptions.set_selected(0) #get title for mdesc, mcode in self._menus['generate_ftr']: if mcode == menu_level: title = mdesc break self.lblHeading.set_text(title) #display all items in filter for filt_item in self.WinMain.current_filter[ menu_level[4:]].keys(): self.lsOptions.append([filt_item, filt_item]) self.lsOptions.sort() self.lsOptions.insert(0, [_('Show ALL'), 'all']) self.lsOptions.insert(1, [_('Show NONE'), 'none']) elif menu_level == 'generate_new_list': #generate new filtered games list self.lblHeading.set_text(_('Please Wait...')) self.lblSettingHeading.set_text( _('Generating new filtered games list...')) self.do_events() #save current filter filters.write_filter( self.WinMain.current_filter, os.path.join( CONFIG_DIR, 'files', '%s-%s.ftr' % (self.WinMain.current_emu, self.WinMain.current_list_idx))) #create list from the just saved filter filters.create_filtered_list( os.path.join(CONFIG_DIR, 'files', '%s-0.lst' % (self.WinMain.current_emu)), self.WinMain.current_filter, os.path.join( CONFIG_DIR, 'files', '%s-%s.lst' % (self.WinMain.current_emu, self.WinMain.current_list_idx))) self.WinMain.load_list() self.WinMain.hide_window('options') elif menu_level == 'music_dir': #display contents of current music dir #print "music dir=", self.WinMain.gstMusic.current_dir self.lblHeading.set_text(self.WinMain.gstMusic.current_dir) dir_files, music_files = self.get_music_files( self.WinMain.gstMusic.current_dir) self.sclOptions.set_selected(0) for df in dir_files: self.lsOptions.append([df, 'music_dir']) for mf in music_files: self.lsOptions.append([mf, 'music_track']) else: #show appropriate menu self.sclOptions.set_selected(0) #[self.lsOptions.append(menu_item) for menu_item in self._menus[menu_level]] [ self.lsOptions.append(m) for m in self._menus[menu_level] if m[0] != '**HIDE**' ] #update list widget self.sclOptions.ls = [l[0] for l in self.lsOptions] self.sclOptions.set_selected(self.sclOptions.get_selected())
def set_menu(self, menu_level, heading=""): """setup options list to given menu""" # get menu heading if not supplied if heading == "": for v in self._menus.values(): for ml in v: if ml[1] == menu_level: heading = ml[0] # default heading if heading == "": heading = _("Options") # set labels self.lblHeading.set_text(heading) self.lblSettingHeading.set_text(_("Current Setting:")) self.lblSettingValue.set_text("") self.lsOptions = [] # which menu? self.current_menu = menu_level # hide stuff if necessary if menu_level == "main": # hide "select platform" if only one emu in list if len(self.WinMain.emu_lists) == 1: self._menus[menu_level][0][0] = "**HIDE**" # hide "music" menu if not self.WinMain.music_enabled: self._menus[menu_level][5][0] = "**HIDE**" elif menu_level == "exit": # hide shutdown & reboot menu if not dbus_imported: self._menus[menu_level][1][0] = "**HIDE**" self._menus[menu_level][2][0] = "**HIDE**" # show menu if menu_level == "emu_list": # show all emulators self.lblSettingValue.set_text(self.WinMain.emu_ini.get("emulator_title")) for emu_title, emu_name in self.WinMain.emu_lists: self.lsOptions.append([emu_title, emu_name]) self.sclOptions.set_selected(0) elif menu_level == "game_list": # show all game lists self.lblSettingValue.set_text(self.WinMain.current_list_ini.get("list_title")) for list_name, idx, cycle_list in self.WinMain.game_lists: self.lsOptions.append([list_name, idx]) self.sclOptions.set_selected(self.WinMain.current_list_idx) elif menu_level == "add_to_list": # show "normal" game lists self.lblSettingValue.set_text(self.WinMain.current_list_ini.get("list_title")) for list_name, idx, cycle_list in self.WinMain.game_lists_normal: if list_name != self.WinMain.current_list_ini.get("list_title"): self.lsOptions.append([list_name, idx]) self.sclOptions.set_selected(0) elif menu_level == "find": # find by letter [self.lsOptions.append([c, "find:%s" % (c)]) for c in "%s%s" % (string.uppercase, string.digits)] elif menu_level == "list_options": # show game list options menu self.sclOptions.set_selected(0) if self.WinMain.current_list_idx == 0: # list 0, so display "generate list" instead of "generate filtered list" self.lsOptions.append(self._menus[menu_level][0]) self.lsOptions.append(self._menus[menu_level][1]) self.lsOptions.append(self._menus[menu_level][3]) else: # all other lists [self.lsOptions.append(menu_item) for menu_item in self._menus[menu_level][:3]] elif menu_level == "generate_list": # re-create initial filter self.lblHeading.set_text(_("Please Wait...")) self.lblSettingHeading.set_text(_("Generating new games list...")) self.do_events() filter_file = os.path.join( self.WinMain.config_dir, "files", "%s-%s.ftr" % (self.WinMain.current_emu, self.WinMain.current_list_idx), ) filters.create_initial_filter( self.WinMain.emu_ini.get("dat_file"), filter_file, os.path.join(self.WinMain.config_dir, "files", "%s-0.lst" % (self.WinMain.current_emu)), self.WinMain.emu_ini, ) self.WinMain.load_list() self.WinMain.hide_window("options") elif menu_level == "generate_ftr": # display filter categories menu self._display_clone_idx = int(self.WinMain.current_filter["filter_type"]) self.sclOptions.set_selected(0) [self.lsOptions.append(menu_item) for menu_item in self._menus[menu_level]] elif menu_level.startswith("ftr:"): # display a specific filter menu... self.sclOptions.set_selected(0) # get title for mdesc, mcode in self._menus["generate_ftr"]: if mcode == menu_level: title = mdesc break self.lblHeading.set_text(title) # display all items in filter for filt_item in self.WinMain.current_filter[menu_level[4:]].keys(): self.lsOptions.append([filt_item, filt_item]) self.lsOptions.sort() self.lsOptions.insert(0, [_("Show ALL"), "all"]) self.lsOptions.insert(1, [_("Show NONE"), "none"]) elif menu_level == "generate_new_list": # generate new filtered games list self.lblHeading.set_text(_("Please Wait...")) self.lblSettingHeading.set_text(_("Generating new filtered games list...")) self.do_events() # save current filter filters.write_filter( self.WinMain.current_filter, os.path.join( self.WinMain.config_dir, "files", "%s-%s.ftr" % (self.WinMain.current_emu, self.WinMain.current_list_idx), ), ) # create list from the just saved filter filters.create_filtered_list( os.path.join(self.WinMain.config_dir, "files", "%s-0.lst" % (self.WinMain.current_emu)), self.WinMain.current_filter, os.path.join( self.WinMain.config_dir, "files", "%s-%s.lst" % (self.WinMain.current_emu, self.WinMain.current_list_idx), ), ) self.WinMain.load_list() self.WinMain.hide_window("options") elif menu_level == "music_dir": # display contents of current music dir # print "music dir=", self.WinMain.gstMusic.current_dir self.lblHeading.set_text(self.WinMain.gstMusic.current_dir) dir_files, music_files = self.get_music_files(self.WinMain.gstMusic.current_dir) self.sclOptions.set_selected(0) for df in dir_files: self.lsOptions.append([df, "music_dir"]) for mf in music_files: self.lsOptions.append([mf, "music_track"]) else: # show appropriate menu self.sclOptions.set_selected(0) # [self.lsOptions.append(menu_item) for menu_item in self._menus[menu_level]] [self.lsOptions.append(m) for m in self._menus[menu_level] if m[0] != "**HIDE**"] # update list widget self.sclOptions.ls = [l[0] for l in self.lsOptions] self.sclOptions.set_selected(self.sclOptions.get_selected())