示例#1
0
文件: window.py 项目: fabianod/UrTSB
    def on_tab_change(self, notebook, page, page_num):
        """
        Callback method handling tab changes.
        
        @param notebook - the notebook instance
        @param page - notebookpage 
        @param page_num - number of the current page 
        
        """
        #load favorites and recent servers directly if switched to
        #these tabs
        gc = GuiController()
        if 1 == page_num:  #favorites
            #gc.loadFavorites(self.favoritestab)
            gc.executeFavoritesLoading(self.favoritestab)
            self.favoritestab.filter.lock()
        if 2 == page_num:  #recent server
            #gc.loadRecentServer(self.recenttab)
            gc.executeRecentServersLoading(self.recenttab)
            self.recenttab.filter.lock()
        if 3 == page_num:  #buddies tab
            fm = FileManager()
            config = fm.getConfiguration()
            execute = fm.value_as_boolean(config[cfgkey.OPT_BUDDYSEARCH])
            if self.first_switch and execute:
                gc.execute_buddies_loading(self.buddiestab, execute=True)
            else:
                gc.execute_buddies_loading(self.buddiestab)

        self.first_switch = False
示例#2
0
 def on_tab_change(self, notebook, page, page_num):
     """
     Callback method handling tab changes.
     
     @param notebook - the notebook instance
     @param page - notebookpage 
     @param page_num - number of the current page 
     
     """
     #load favorites and recent servers directly if switched to
     #these tabs 
     gc = GuiController()
     if 1 == page_num: #favorites
         #gc.loadFavorites(self.favoritestab)
         gc.executeFavoritesLoading(self.favoritestab)
         self.favoritestab.filter.lock()
     if 2 == page_num: #recent server
         #gc.loadRecentServer(self.recenttab)
         gc.executeRecentServersLoading(self.recenttab)
         self.recenttab.filter.lock()
     if 3 == page_num: #buddies tab
         fm = FileManager()
         config = fm.getConfiguration()
         execute = fm.value_as_boolean(config[cfgkey.OPT_BUDDYSEARCH])
         if self.first_switch and execute:
             gc.execute_buddies_loading(self.buddiestab, execute=True)
         else:
             gc.execute_buddies_loading(self.buddiestab)
              
     self.first_switch = False
示例#3
0
 def __init__(self, server, type):
     """
     Constructor
     
     @param server - the server which needs a password
     @param type - value of PassDialogType to specify the type of the dialog
                   two possible values:
                      - SERVER_PASSWOR - enter password for private password
                      - PRIV_SLOT_PASSWORD - enter password for private slots
     """
     gtk.Dialog.__init__(self, 'Server needs a password to connect!', None,\
                           gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
     
     self.server = server
     self.diag_type = type
     #buttons
     okbutton = gtk.Button('OK')
     cancelbutton = gtk.Button('Cancel')
     
     okbutton.connect("clicked", self.on_ok_clicked)
     cancelbutton.connect("clicked", self.on_cancel_clicked)
     
     
     self.action_area.pack_start(cancelbutton, False, False)
     self.action_area.pack_start(okbutton, False, False)
     
     #content area
     desc_label = gtk.Label('Enter Password')
     if PassDialogType.SERVER_PASSWORD == self.diag_type:
         desc_label.set_text('The server you are trying to connect needs a '\
                             +'password')
     elif PassDialogType.PRIV_SLOT_PASSWORD == self.diag_type:
         desc_label.set_text('The server is full. In order to use a private'\
                         + 'slot please enter the private slot password')
     namelabel = gtk.Label('Servername: ' + server.getName())
     addresslabel = gtk.Label('Serveraddress: ' + server.getaddress())
     self.passentry = gtk.Entry()
     self.passentry.set_visibility(False)
     self.passentry.set_text(server.getPassword())
     self.remembercheckbutton = gtk.CheckButton('remember password')
     
     self.vbox.pack_start(desc_label, False, False)
     self.vbox.pack_start(namelabel, False, False)
     self.vbox.pack_start(addresslabel, False, False)
     self.vbox.pack_start(self.passentry, False, False)
     self.vbox.pack_start(self.remembercheckbutton, False, False)
     
     fm = FileManager()
     config = fm.getConfiguration()
     save_password = config[cfgkey.OPT_SAVE_PW]
     if 'True' == save_password:
         self.remembercheckbutton.set_active(True)
     else:
         self.remembercheckbutton.set_active(False)
     
     self.show_all()
示例#4
0
    def __init__(self, server, type):
        """
        Constructor
        
        @param server - the server which needs a password
        @param type - value of PassDialogType to specify the type of the dialog
                      two possible values:
                         - SERVER_PASSWOR - enter password for private password
                         - PRIV_SLOT_PASSWORD - enter password for private slots
        """
        gtk.Dialog.__init__(self, 'Server needs a password to connect!', None,\
                              gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)

        self.server = server
        self.diag_type = type
        #buttons
        okbutton = gtk.Button('OK')
        cancelbutton = gtk.Button('Cancel')

        okbutton.connect("clicked", self.on_ok_clicked)
        cancelbutton.connect("clicked", self.on_cancel_clicked)

        self.action_area.pack_start(cancelbutton, False, False)
        self.action_area.pack_start(okbutton, False, False)

        #content area
        desc_label = gtk.Label('Enter Password')
        if PassDialogType.SERVER_PASSWORD == self.diag_type:
            desc_label.set_text('The server you are trying to connect needs a '\
                                +'password')
        elif PassDialogType.PRIV_SLOT_PASSWORD == self.diag_type:
            desc_label.set_text('The server is full. In order to use a private'\
                            + 'slot please enter the private slot password')
        namelabel = gtk.Label('Servername: ' + server.getName())
        addresslabel = gtk.Label('Serveraddress: ' + server.getaddress())
        self.passentry = gtk.Entry()
        self.passentry.set_visibility(False)
        self.passentry.set_text(server.getPassword())
        self.remembercheckbutton = gtk.CheckButton('remember password')

        self.vbox.pack_start(desc_label, False, False)
        self.vbox.pack_start(namelabel, False, False)
        self.vbox.pack_start(addresslabel, False, False)
        self.vbox.pack_start(self.passentry, False, False)
        self.vbox.pack_start(self.remembercheckbutton, False, False)

        fm = FileManager()
        config = fm.getConfiguration()
        save_password = config[cfgkey.OPT_SAVE_PW]
        if 'True' == save_password:
            self.remembercheckbutton.set_active(True)
        else:
            self.remembercheckbutton.set_active(False)

        self.show_all()
示例#5
0
文件: window.py 项目: fabianod/UrTSB
 def on_window_state_changed(self, window, event):
     """
     Callback of the def "window-state-event"
     Needed to handle maximize/demaximize of the window
     """
     fm = FileManager()
     window_sizing = fm.get_window_sizing()
     if event.new_window_state & gtk.gdk.WINDOW_STATE_MAXIMIZED:
         Log.log.debug('UrTSB Window maximized')
         window_sizing.maximized = True
     else:
         Log.log.debug('UrTSB Window not maximized')
         window_sizing.maximized = False
示例#6
0
 def on_window_state_changed(self, window, event):
     """
     Callback of the def "window-state-event"
     Needed to handle maximize/demaximize of the window
     """
     fm = FileManager()
     window_sizing = fm.get_window_sizing()
     if event.new_window_state & gtk.gdk.WINDOW_STATE_MAXIMIZED:
         Log.log.debug('UrTSB Window maximized')
         window_sizing.maximized = True
     else:
         Log.log.debug('UrTSB Window not maximized')
         window_sizing.maximized = False
示例#7
0
    def on_search_buddies_clicked(self, widget):
        """
        Callback of the search buddies button
        """
        self.lock()

        fm = FileManager()

        #create a filter object
        filter = Filter(FilterType.BUDDY_FILTER, self.parenttab)
        filter.playerlist = fm.get_buddies()
        self.parenttab.set_all_buddies_to_offline()
        gc = GuiController()
        gc.executeMasterServerQuery(filter, self.parenttab)
示例#8
0
 def on_search_buddies_clicked(self, widget):
     """
     Callback of the search buddies button
     """
     self.lock()
     
     fm = FileManager()
     
     #create a filter object
     filter = Filter(FilterType.BUDDY_FILTER, self.parenttab)
     filter.playerlist = fm.get_buddies()
     self.parenttab.set_all_buddies_to_offline()
     gc = GuiController()
     gc.executeMasterServerQuery(filter, self.parenttab) 
示例#9
0
 def setServerdetails(self, server):
     """
     Updates the embedded serverdetails element 
     """
     self.playerlist.clear()
     
     for player in server.getPlayerList():
         self.playerlist.addPlayer(player)
         
     self.detailsbox.setServerDetails(server) 
     # update row in list
     # but only if the corresponding option is True
     fm = FileManager()
     config = fm.getConfiguration()
     if 'True' == config[cfgkey.OPT_UPDATE_SL_ROW]: 
         self.serverlist.update_selected_row(server)
示例#10
0
文件: window.py 项目: fabianod/UrTSB
    def do_configure_event(self, event):
        """
        overrides the default do_configure_event method
        handles window move and resize and stores this information
        """
        fm = FileManager()
        window_sizing = fm.get_window_sizing()
        window_sizing.width = event.width
        window_sizing.height = event.height
        window_sizing.x = event.x
        window_sizing.y = event.y

        Log.log.debug('Window: size = ' + str(window_sizing.width) + 'x' +
                      str(window_sizing.height) + '  position = ' +
                      str(window_sizing.x) + ', ' + str(window_sizing.y))

        gtk.Window.do_configure_event(self, event)
示例#11
0
 def do_configure_event(self, event):
     """
     overrides the default do_configure_event method
     handles window move and resize and stores this information
     """
     fm = FileManager()
     window_sizing = fm.get_window_sizing()
     window_sizing.width = event.width
     window_sizing.height = event.height
     window_sizing.x = event.x
     window_sizing.y = event.y
     
     Log.log.debug('Window: size = ' + str(window_sizing.width) + 'x' +
                   str(window_sizing.height) + '  position = ' +
                   str(window_sizing.x) + ', ' + str(window_sizing.y))
     
     gtk.Window.do_configure_event(self, event)
示例#12
0
    def __init__(self, server):
        """
        Constructor
        
        @param server - the server which needs a password
        """
        gtk.Dialog.__init__(self, 'RCON Password needed!', None,\
                              gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)

        self.server = server
        #buttons
        okbutton = gtk.Button('OK')
        cancelbutton = gtk.Button('Cancel')

        okbutton.connect("clicked", self.on_ok_clicked)
        cancelbutton.connect("clicked", self.on_cancel_clicked)

        self.action_area.pack_start(cancelbutton, False, False)
        self.action_area.pack_start(okbutton, False, False)

        #content area
        desc_label = gtk.Label('Please enter the RCON password for:')
        namelabel = gtk.Label('Servername: ' + server.getName())
        addresslabel = gtk.Label('Serveraddress: ' + server.getaddress())
        self.passentry = gtk.Entry()
        self.passentry.set_visibility(False)
        self.passentry.set_text('')
        self.remembercheckbutton = gtk.CheckButton('remember password')
        self.remembercheckbutton.set_active(False)

        self.vbox.pack_start(desc_label, False, False)
        self.vbox.pack_start(namelabel, False, False)
        self.vbox.pack_start(addresslabel, False, False)
        self.vbox.pack_start(self.passentry, False, False)
        self.vbox.pack_start(self.remembercheckbutton, False, False)

        #check if there is a stored rcon pw for the server
        fm = FileManager()
        rconpws = fm.get_rcon_passwords()
        if server.getaddress() in rconpws:
            pw = rconpws[server.getaddress()]

            self.passentry.set_text(pw)
            self.remembercheckbutton.set_active(True)

        self.show_all()
示例#13
0
    def on_ok_clicked(self, widget):
        """
            Callback of the OK button
            """
        #get the entered password
        self.server.rconpass = self.passentry.get_text()

        #store the password if checkbox is active
        if self.remembercheckbutton.get_active():
            fm = FileManager()
            rconpws = fm.get_rcon_passwords()
            rconpws[self.server.getaddress()] = self.server.rconpass
            fm.save_rcon_passwords()

        #display the rcon window
        rconwin = RconWindow(self.server)
        rconwin.show_now()
        self.destroy()
示例#14
0
    def on_save_clicked(self, widget):
        """
        Callback of the save button
        """

        fm = FileManager()
        config = fm.getConfiguration()
        config[cfgkey.URT_EXE] = self.exe_entry.get_text()
        config[cfgkey.URT_EXE_PATH] = self.path_entry.get_text()
        config[cfgkey.URT_EXE_PARAMS] = self.addcmd_entry.get_text()

        defaulttab = 0
        if self.srvlist_radio.get_active():
            defaulttab = 0
        elif self.favlist_radio.get_active():
            defaulttab = 1
        elif self.reclist_radio.get_active():
            defaulttab = 2
        elif self.buddies_radio.get_active():
            defaulttab = 3

        config[cfgkey.OPT_DEFAULT_TAB] = defaulttab

        if self.filter_basic_radio.get_active():
            config[cfgkey.OPT_FILTER] = cfgvalues.BASIC_FILTER
        elif self.filter_advanced_radio.get_active():
            config[cfgkey.OPT_FILTER] = cfgvalues.ADVANCED_FILTER
        else:  # fallback
            config[cfgkey.OPT_FILTER] = cfgvalues.BASIC_FILTER

        config[cfgkey.OPT_BUDDYSEARCH] = fm.value_from_boolean(self.checkbox_buddysearch.get_active())

        # refresh the serverlist tab to make changes to the filter available
        # without restart
        window = self.parent.parent.parent
        notebook = window.notebook
        notebook.remove_page(0)
        window.serverlisttab = ServerTab()
        srvlabel = gtk.Label("Serverlist")
        notebook.insert_page(window.serverlisttab, srvlabel, 0)

        fm.saveConfiguration()
示例#15
0
    def set_defaults(self):
        """
        Set ui input element values to the values read from configuration
        """
        fm = FileManager()
        config = fm.getConfiguration()

        self.exe_entry.set_text(config[cfgkey.URT_EXE])
        self.path_entry.set_text(config[cfgkey.URT_EXE_PATH])
        self.addcmd_entry.set_text(config[cfgkey.URT_EXE_PARAMS])

        defaulttab = int(config[cfgkey.OPT_DEFAULT_TAB])
        if 0 == defaulttab:
            self.srvlist_radio.set_active(True)
            self.checkbox_buddysearch.set_sensitive(False)
            self.checkbox_buddysearch.set_active(False)
        elif 1 == defaulttab:
            self.favlist_radio.set_active(True)
            self.checkbox_buddysearch.set_sensitive(False)
            self.checkbox_buddysearch.set_active(False)
        elif 2 == defaulttab:
            self.reclist_radio.set_active(True)
            self.checkbox_buddysearch.set_sensitive(False)
            self.checkbox_buddysearch.set_active(False)
        elif 3 == defaulttab:
            self.buddies_radio.set_active(True)
            self.checkbox_buddysearch.set_sensitive(True)
            self.checkbox_buddysearch.set_active(fm.value_as_boolean(\
                                                config[cfgkey.OPT_BUDDYSEARCH]))
        else:
            self.srvlist_radio.set_active(True)

        if cfgvalues.BASIC_FILTER == config[cfgkey.OPT_FILTER]:
            self.filter_basic_radio.set_active(True)
            self.filter_advanced_radio.set_active(False)
        elif cfgvalues.ADVANCED_FILTER == config[cfgkey.OPT_FILTER]:
            self.filter_basic_radio.set_active(False)
            self.filter_advanced_radio.set_active(True)
        else:  #fallback to basic
            self.filter_basic_radio.set_active(True)
            self.filter_advanced_radio.set_active(False)
示例#16
0
    def set_defaults(self):
        """
        Set ui input element values to the values read from configuration
        """
        fm = FileManager()
        config = fm.getConfiguration()

        self.exe_entry.set_text(config[cfgkey.URT_EXE])
        self.path_entry.set_text(config[cfgkey.URT_EXE_PATH])
        self.addcmd_entry.set_text(config[cfgkey.URT_EXE_PARAMS])

        defaulttab = int(config[cfgkey.OPT_DEFAULT_TAB])
        if 0 == defaulttab:
            self.srvlist_radio.set_active(True)
            self.checkbox_buddysearch.set_sensitive(False)
            self.checkbox_buddysearch.set_active(False)
        elif 1 == defaulttab:
            self.favlist_radio.set_active(True)
            self.checkbox_buddysearch.set_sensitive(False)
            self.checkbox_buddysearch.set_active(False)
        elif 2 == defaulttab:
            self.reclist_radio.set_active(True)
            self.checkbox_buddysearch.set_sensitive(False)
            self.checkbox_buddysearch.set_active(False)
        elif 3 == defaulttab:
            self.buddies_radio.set_active(True)
            self.checkbox_buddysearch.set_sensitive(True)
            self.checkbox_buddysearch.set_active(fm.value_as_boolean(config[cfgkey.OPT_BUDDYSEARCH]))
        else:
            self.srvlist_radio.set_active(True)

        if cfgvalues.BASIC_FILTER == config[cfgkey.OPT_FILTER]:
            self.filter_basic_radio.set_active(True)
            self.filter_advanced_radio.set_active(False)
        elif cfgvalues.ADVANCED_FILTER == config[cfgkey.OPT_FILTER]:
            self.filter_basic_radio.set_active(False)
            self.filter_advanced_radio.set_active(True)
        else:  # fallback to basic
            self.filter_basic_radio.set_active(True)
            self.filter_advanced_radio.set_active(False)
示例#17
0
    def on_save_clicked(self, widget):
        """
        Callback of the save button
        """

        fm = FileManager()
        config = fm.getConfiguration()
        config[cfgkey.URT_EXE] = self.exe_entry.get_text()
        config[cfgkey.URT_EXE_PATH] = self.path_entry.get_text()
        config[cfgkey.URT_EXE_PARAMS] = self.addcmd_entry.get_text()

        defaulttab = 0
        if self.srvlist_radio.get_active():
            defaulttab = 0
        elif self.favlist_radio.get_active():
            defaulttab = 1
        elif self.reclist_radio.get_active():
            defaulttab = 2
        elif self.buddies_radio.get_active():
            defaulttab = 3

        config[cfgkey.OPT_DEFAULT_TAB] = defaulttab

        if self.filter_basic_radio.get_active():
            config[cfgkey.OPT_FILTER] = cfgvalues.BASIC_FILTER
        elif self.filter_advanced_radio.get_active():
            config[cfgkey.OPT_FILTER] = cfgvalues.ADVANCED_FILTER
        else:  #fallback
            config[cfgkey.OPT_FILTER] = cfgvalues.BASIC_FILTER


        config[cfgkey.OPT_BUDDYSEARCH] =\
                   fm.value_from_boolean(self.checkbox_buddysearch.get_active())

        #refresh the serverlist tab to make changes to the filter available
        #without restart
        window = self.parent.parent.parent
        notebook = window.notebook
        notebook.remove_page(0)
        window.serverlisttab = ServerTab()
        srvlabel = gtk.Label('Serverlist')
        notebook.insert_page(window.serverlisttab, srvlabel, 0)

        fm.saveConfiguration()
示例#18
0
文件: window.py 项目: fabianod/UrTSB
    def __init__(self):
        """
        Constructor. Creating and inititializing the main window of UrTSB.
        """
        gtk.Window.__init__(self)
        Window.instance = self

        #window creation and basic window settings
        fm = FileManager()
        window_sizing = fm.get_window_sizing()

        gc = GuiController()
        self.set_title(gc.appname + ' v.' + gc.appver + ' - ' + gc.appdesc)
        self.set_icon_from_file(Globals.icon_dir + '/logo.png')

        if window_sizing.maximized:
            self.maximize()
        else:
            self.unmaximize()
        self.set_default_size(window_sizing.width, window_sizing.height)
        if None == window_sizing.x and None == window_sizing.y:
            self.set_position(gtk.WIN_POS_CENTER)
        else:
            self.move(window_sizing.x, window_sizing.y)
        self.connect('destroy', gtk.main_quit)

        # add a VBox that will contain the main notebookpane and a statusbar
        mainbox = gtk.VBox()
        self.add(mainbox)

        # the notebook - tabs will be serverlist, favorites,
        # recent servers and settings
        self.notebook = gtk.Notebook()
        self.notebook.set_border_width(2)
        mainbox.pack_start(self.notebook)
        self.notebook.connect('switch-page', self.on_tab_change)

        # add the serverlist tab
        self.serverlisttab = ServerTab()
        srvlabel = gtk.Label('Serverlist')
        self.notebook.append_page(self.serverlisttab, srvlabel)

        # add the favorites tab
        self.favoritestab = FavoritesTab()
        favlabel = gtk.Label('Favorites')
        self.notebook.append_page(self.favoritestab, favlabel)

        # add the recently played tab
        self.recenttab = RecentTab()
        recentlabel = gtk.Label('Recently Played')
        self.notebook.append_page(self.recenttab, recentlabel)

        # add the buddies tab
        self.buddiestab = BuddiesTab()
        buddieslabel = gtk.Label('Buddies')
        self.notebook.append_page(self.buddiestab, buddieslabel)

        # add the settings tab
        self.settingsstab = SettingsTab()
        settingslabel = gtk.Label('Settings')
        self.notebook.append_page(self.settingsstab, settingslabel)

        #set default tab
        fm = FileManager()
        config = fm.getConfiguration()
        defaulttab = int(config[cfgkey.OPT_DEFAULT_TAB])
        #this variable is used to dertermine if the tabswitch is the first
        #after application start
        self.first_switch = True

        self.notebook.set_current_page(defaulttab)

        #connect key press event to be able to create keyboard shortcuts
        self.connect('key-press-event', self.on_key_pressed_event)

        #connect window-state-event to handle maximize/demaximize
        self.connect('window-state-event', self.on_window_state_changed)

        self.show_all()
示例#19
0
    def initialize_from_stored_filter_settings(self):
        """
        Uses the stored filter settings provided by the FileManager to
        initialize the values of the filter
        """
        fm = FileManager()
        sf = fm.get_remembered_filter_parameters()

        self.show_empty = fm.value_as_boolean(sf[filterkey.QRY_SHOW_EMPTY])
        self.show_full = fm.value_as_boolean(sf[filterkey.QRY_SHOW_FULL])

        self.hide_non_responsive = fm.value_as_boolean(sf[filterkey.\
                                                             FLT_HIDE_NON_RESP])
        self.hide_passworded = fm.value_as_boolean(sf[filterkey.\
                                                           FLT_HIDE_PASSWORDED])

        self.min_players = int(sf[filterkey.FLT_MIN_PLAYERS])
        self.max_players = int(sf[filterkey.FLT_MAX_PLAYERS])

        self.gametype_bomb = fm.value_as_boolean(sf[filterkey.GT_BOMB])
        self.gametype_ts = fm.value_as_boolean(sf[filterkey.GT_TS])
        self.gametype_ctf = fm.value_as_boolean(sf[filterkey.GT_CTF])
        self.gametype_tdm = fm.value_as_boolean(sf[filterkey.GT_TDM])
        self.gametype_cah = fm.value_as_boolean(sf[filterkey.GT_CAH])
        self.gametype_ftl = fm.value_as_boolean(sf[filterkey.GT_FTL])
        self.gametype_ffa = fm.value_as_boolean(sf[filterkey.GT_FFA])

        if filterkey.FLT_MAP_NAME in sf:
            self.map_name = sf[filterkey.FLT_MAP_NAME]

        if filterkey.FLT_SERVER_NAME in sf:
            self.server_name = sf[filterkey.FLT_SERVER_NAME]

        if filterkey.FLT_GEAR in sf:
            self.gear_filter_type = sf[filterkey.FLT_GEAR]

        if filterkey.FLT_GEAR_LIST in sf:
            self.gear_value_list = sf[filterkey.FLT_GEAR_LIST]

        if filterkey.FLT_VAR_LIST in sf:
            self.server_var_list = sf[filterkey.FLT_VAR_LIST]
示例#20
0
 def __init__(self):
     """
     Constructor
     """
     gtk.VBox.__init__(self)
     
     fm = FileManager()
     config = fm.getConfiguration()
     
     if cfgvalues.BASIC_FILTER == config[cfgkey.OPT_FILTER]:        
         self.filter = ServerListFilter(self)
     else:
         self.filter = AdvancedFilter(self)
     self.filter.show()
     
     self.pack_start(self.filter, False, False)
     
    
     
     # top pane area 
     paned = gtk.VPaned() 
     paned.show()
     self.pack_start(paned)   
     
     # bottom add a statusbar
     self.statusbar = StatusBar(self)
     self.pack_start(self.statusbar, False, False)
     
     
     # serverlist window
     self.serverlist = ServerList(self)
     paned.pack1(self.serverlist, True, False)
     #paned.add1(self.serverlist)
     
     
     # bottom panearea
     bottompane = gtk.HPaned()
     paned.pack2(bottompane, True, False)
     #paned.add2(bottompane)
     
     #left box
     self.playerlist = PlayerList()
     bottompane.pack1(self.playerlist, False, False)
     
     
     
     #right box
     self.detailsbox = ServerDetailBox()
     vbox = gtk.VBox()
     
     
     bottompane.pack2(vbox, True, False)
     
   
     buttonbox = gtk.HBox()
     
     #self.detailsbox.pack_start(buttonbox, False, False)
     vbox.pack_start(buttonbox, False, False)
     vbox.pack_start(self.detailsbox)
     
     
     refresh_button = gtk.Button('Refresh')
     refreshimage = gtk.Image()
     refreshimage.set_from_stock(gtk.STOCK_REFRESH, gtk.ICON_SIZE_BUTTON)
     refresh_button.set_image(refreshimage)
     
     connect_button = gtk.Button('Connect')
     connectimage = gtk.Image()
     connectimage.set_from_stock(gtk.STOCK_CONNECT, gtk.ICON_SIZE_BUTTON)
     connect_button.set_image(connectimage)
     
     addfav_button = gtk.Button('Add to Favorites')
     favimage = gtk.Image()
     favimage.set_from_stock(gtk.STOCK_ADD, gtk.ICON_SIZE_BUTTON)
     addfav_button.set_image(favimage)
     
     
     buttonbox.pack_start(refresh_button, True, True)
     buttonbox.pack_start(connect_button, True, True)
     buttonbox.pack_start(addfav_button, True, True)
     refresh_button.connect("clicked", self.onRefreshButtonClicked)
     addfav_button.connect("clicked", self.onAddFavButtonClicked)
     connect_button.connect("clicked", self.connect_button_clicked)
     
     self.show_all()
示例#21
0
    def save_filter(self):
        """
        writes the current filter/query params to the filter dict
        """
        fm = FileManager()
        filter = fm.get_remembered_filter_parameters()
        if not filter:
            # TODO: clean up this dirty hack ;)
            fm.filter = {}
            filter = fm.filter

        #process gametypes
        value = fm.value_from_boolean(self.gametypes.\
                                        checkbox_show_gametype_all.get_active())
        filter[filterkey.GT_ALL] = value

        value = fm.value_from_boolean(self.gametypes.\
                                       checkbox_show_gametype_bomb.get_active())
        filter[filterkey.GT_BOMB] = value

        value = fm.value_from_boolean(self.gametypes.\
                                   checkbox_show_gametype_survivor.get_active())
        filter[filterkey.GT_TS] = value

        value = fm.value_from_boolean(self.gametypes.\
                                        checkbox_show_gametype_ctf.get_active())
        filter[filterkey.GT_CTF] = value

        value = fm.value_from_boolean(self.gametypes.\
                                        checkbox_show_gametype_tdm.get_active())
        filter[filterkey.GT_TDM] = value

        value = fm.value_from_boolean(self.gametypes.\
                                        checkbox_show_gametype_cah.get_active())
        filter[filterkey.GT_CAH] = value

        value = fm.value_from_boolean(self.gametypes.\
                                        checkbox_show_gametype_ftl.get_active())
        filter[filterkey.GT_FTL] = value

        value = fm.value_from_boolean(self.gametypes.\
                                        checkbox_show_gametype_ffa.get_active())
        filter[filterkey.GT_FFA] = value

        #other filters
        filter[filterkey.FLT_MIN_PLAYERS] = self.\
                                               minplayerentry.get_value_as_int()
        filter[filterkey.FLT_MAX_PLAYERS] = self.\
                                               maxplayerentry.get_value_as_int()

        value = fm.value_from_boolean(self.\
                                      checkbox_hide_non_responsive.get_active())
        filter[filterkey.FLT_HIDE_NON_RESP] = value

        value = fm.value_from_boolean(self.\
                                          checkbox_hide_passworded.get_active())
        filter[filterkey.FLT_HIDE_PASSWORDED] = value

        #query params
        value = fm.value_from_boolean(self.checkbox_showfull.get_active())
        filter[filterkey.QRY_SHOW_FULL] = value

        value = fm.value_from_boolean(self.checkbox_showempty.get_active())
        filter[filterkey.QRY_SHOW_EMPTY] = value

        #write to file
        t = Thread(target=fm.save_filter_to_remember)
        t.setDaemon(True)
        t.start()
示例#22
0
    def set_default_values(self, reset):
        """
        Set default values to all input elements of the filter.
        Differs between application defaults and the values that are stored
        in a file to remember user choices.
        
        @param reset - boolean: if True use application defaults, otherwise load
                       values from file. 
       
        """

        fm = FileManager()
        stored_filter = fm.get_remembered_filter_parameters()

        if reset or None == stored_filter:  #reset to application defaults
            self.gametypes.checkbox_show_gametype_all.set_active(True)
            # emits the 'toggled' signal
            self.gametypes.checkbox_show_gametype_all.toggled()

            self.checkbox_hide_non_responsive.set_active(True)
            self.checkbox_hide_passworded.set_active(True)

            #defaults for min and maxplayer spinbuttons
            self.minplayerentry.set_value(0)
            self.maxplayerentry.set_value(99)

            self.checkbox_showfull.set_active(False)
            self.checkbox_showempty.set_active(False)
        else:  #reset to stored values

            #gametypes
            value = fm.value_as_boolean(stored_filter[filterkey.GT_ALL])
            self.gametypes.checkbox_show_gametype_all.set_active(True)

            value = fm.value_as_boolean(stored_filter[filterkey.GT_BOMB])
            self.gametypes.checkbox_show_gametype_bomb.set_active(value)

            value = fm.value_as_boolean(stored_filter[filterkey.GT_TS])
            self.gametypes.checkbox_show_gametype_survivor.set_active(value)

            value = fm.value_as_boolean(stored_filter[filterkey.GT_CTF])
            self.gametypes.checkbox_show_gametype_ctf.set_active(value)

            value = fm.value_as_boolean(stored_filter[filterkey.GT_TDM])
            self.gametypes.checkbox_show_gametype_tdm.set_active(value)

            value = fm.value_as_boolean(stored_filter[filterkey.GT_CAH])
            self.gametypes.checkbox_show_gametype_cah.set_active(value)

            value = fm.value_as_boolean(stored_filter[filterkey.GT_FTL])
            self.gametypes.checkbox_show_gametype_ftl.set_active(value)

            value = fm.value_as_boolean(stored_filter[filterkey.GT_FFA])
            self.gametypes.checkbox_show_gametype_ffa.set_active(value)

            #other filters:
            #defaults for min and maxplayer spinbuttons
            value = int(stored_filter[filterkey.FLT_MIN_PLAYERS])
            self.minplayerentry.set_value(value)

            value = int(stored_filter[filterkey.FLT_MAX_PLAYERS])
            self.maxplayerentry.set_value(value)

            value = fm.value_as_boolean(stored_filter[filterkey.\
                                                             FLT_HIDE_NON_RESP])
            self.checkbox_hide_non_responsive.set_active(value)

            value = fm.value_as_boolean(stored_filter[filterkey.\
                                                           FLT_HIDE_PASSWORDED])
            self.checkbox_hide_passworded.set_active(value)

            #query params
            value = fm.value_as_boolean(stored_filter[filterkey.QRY_SHOW_FULL])
            self.checkbox_showfull.set_active(value)

            value = fm.value_as_boolean(
                stored_filter[filterkey.QRY_SHOW_EMPTY])
            self.checkbox_showempty.set_active(value)
示例#23
0
    def save_filter(self):
        """
        writes the current filter/query params to the filter dict
        """
        fm = FileManager()
        filter = fm.get_remembered_filter_parameters()
        if not filter:
            # TODO: clean up this dirty hack ;)
            fm.filter = {}
            filter = fm.filter

        #process gametypes
        value = fm.value_from_boolean(self.gametypesfilter.\
                                        checkbox_show_gametype_all.get_active())
        filter[filterkey.GT_ALL] = value

        value = fm.value_from_boolean(self.gametypesfilter.\
                                       checkbox_show_gametype_bomb.get_active())
        filter[filterkey.GT_BOMB] = value

        value = fm.value_from_boolean(self.gametypesfilter.\
                                   checkbox_show_gametype_survivor.get_active())
        filter[filterkey.GT_TS] = value

        value = fm.value_from_boolean(self.gametypesfilter.\
                                        checkbox_show_gametype_ctf.get_active())
        filter[filterkey.GT_CTF] = value

        value = fm.value_from_boolean(self.gametypesfilter.\
                                        checkbox_show_gametype_tdm.get_active())
        filter[filterkey.GT_TDM] = value

        value = fm.value_from_boolean(self.gametypesfilter.\
                                        checkbox_show_gametype_cah.get_active())
        filter[filterkey.GT_CAH] = value

        value = fm.value_from_boolean(self.gametypesfilter.\
                                        checkbox_show_gametype_ftl.get_active())
        filter[filterkey.GT_FTL] = value

        value = fm.value_from_boolean(self.gametypesfilter.\
                                        checkbox_show_gametype_ffa.get_active())
        filter[filterkey.GT_FFA] = value

        #other filters
        filter[filterkey.FLT_MIN_PLAYERS] = self.\
                                               minplayerentry.get_value_as_int()
        filter[filterkey.FLT_MAX_PLAYERS] = self.\
                                               maxplayerentry.get_value_as_int()

        value = fm.value_from_boolean(self.\
                                      checkbox_hide_non_responsive.get_active())
        filter[filterkey.FLT_HIDE_NON_RESP] = value

        value = fm.value_from_boolean(self.\
                                          checkbox_hide_passworded.get_active())
        filter[filterkey.FLT_HIDE_PASSWORDED] = value

        #mapname and servername filter
        filter[filterkey.FLT_MAP_NAME] = self.mapnameentry.get_text()
        filter[filterkey.FLT_SERVER_NAME] = self.servernameentry.get_text()

        #query params
        value = fm.value_from_boolean(self.checkbox_showfull.get_active())
        filter[filterkey.QRY_SHOW_FULL] = value

        value = fm.value_from_boolean(self.checkbox_showempty.get_active())
        filter[filterkey.QRY_SHOW_EMPTY] = value

        if self.radio_gear_disable.get_active():
            filter[filterkey.FLT_GEAR] = cfgvalues.DISABLED
        elif self.radio_gear_include.get_active():
            filter[filterkey.FLT_GEAR] = cfgvalues.INCLUDE
        elif self.radio_gear_exclude.get_active():
            filter[filterkey.FLT_GEAR] = cfgvalues.EXCLUDE

        #iterate over gearliststore to create a list of geavalues
        iter = self.gearliststore.iter_children(None)
        gearvalues = []  #empty list
        while iter:
            value = self.gearliststore.get_value(iter, 0)
            gearvalues.append(value)
            iter = self.gearliststore.iter_next(iter)
        filter[filterkey.FLT_GEAR_LIST] = gearvalues

        #iterate over varliststore to create the list of filter vars
        iter = self.cvarliststore.iter_children(None)
        varlist = []
        while iter:
            varfilter = self.cvarliststore.get_value(iter, 3)
            varlist.append(varfilter)
            iter = self.cvarliststore.iter_next(iter)
        filter[filterkey.FLT_VAR_LIST] = varlist

        #write to file
        t = Thread(target=fm.save_filter_to_remember)
        t.setDaemon(True)
        t.start()
示例#24
0
    def set_default_values(self, reset):
        """
        Set default values to all input elements of the filter.
        Differs between application defaults and the values that are stored
        in a file to remember user choices.
        
        @param reset - boolean: if True use application defaults, otherwise load
                       values from file. 
       
        """

        self.gearliststore.clear()
        self.cvarliststore.clear()

        fm = FileManager()
        stored_filter = fm.get_remembered_filter_parameters()

        #gearcheckbox is not stored, only the listview
        #initialize with all checked
        self.checkbox_grenades.set_active(True)
        self.checkbox_snipers.set_active(True)
        self.checkbox_spas.set_active(True)
        self.checkbox_pistols.set_active(True)
        self.checkbox_automatics.set_active(True)
        self.checkbox_negev.set_active(True)

        if reset or None == stored_filter:  #reset to application defaults
            self.gametypesfilter.checkbox_show_gametype_all.set_active(True)
            # emits the 'toggled' signal
            self.gametypesfilter.checkbox_show_gametype_all.toggled()

            self.checkbox_hide_non_responsive.set_active(True)
            self.checkbox_hide_passworded.set_active(True)

            #defaults for min and maxplayer spinbuttons
            self.minplayerentry.set_value(0)
            self.maxplayerentry.set_value(99)

            self.checkbox_showfull.set_active(False)
            self.checkbox_showempty.set_active(False)

            self.mapnameentry.set_text('')
            self.servernameentry.set_text('')
        else:  #reset to stored values

            #gametypes
            value = fm.value_as_boolean(stored_filter[filterkey.GT_ALL])
            self.gametypesfilter.checkbox_show_gametype_all.set_active(True)

            value = fm.value_as_boolean(stored_filter[filterkey.GT_BOMB])
            self.gametypesfilter.checkbox_show_gametype_bomb.set_active(value)

            value = fm.value_as_boolean(stored_filter[filterkey.GT_TS])
            self.gametypesfilter.checkbox_show_gametype_survivor.set_active(
                value)

            value = fm.value_as_boolean(stored_filter[filterkey.GT_CTF])
            self.gametypesfilter.checkbox_show_gametype_ctf.set_active(value)

            value = fm.value_as_boolean(stored_filter[filterkey.GT_TDM])
            self.gametypesfilter.checkbox_show_gametype_tdm.set_active(value)

            value = fm.value_as_boolean(stored_filter[filterkey.GT_CAH])
            self.gametypesfilter.checkbox_show_gametype_cah.set_active(value)

            value = fm.value_as_boolean(stored_filter[filterkey.GT_FTL])
            self.gametypesfilter.checkbox_show_gametype_ftl.set_active(value)

            value = fm.value_as_boolean(stored_filter[filterkey.GT_FFA])
            self.gametypesfilter.checkbox_show_gametype_ffa.set_active(value)

            #other filters:
            #defaults for min and maxplayer spinbuttons
            value = int(stored_filter[filterkey.FLT_MIN_PLAYERS])
            self.minplayerentry.set_value(value)

            value = int(stored_filter[filterkey.FLT_MAX_PLAYERS])
            self.maxplayerentry.set_value(value)

            if filterkey.FLT_MAP_NAME in stored_filter:
                self.mapnameentry.set_text(stored_filter[filterkey.\
                                                                  FLT_MAP_NAME])
            if filterkey.FLT_SERVER_NAME in stored_filter:
                self.servernameentry.set_text(stored_filter[filterkey.\
                                                               FLT_SERVER_NAME])

            value = fm.value_as_boolean(stored_filter[filterkey.\
                                                             FLT_HIDE_NON_RESP])
            self.checkbox_hide_non_responsive.set_active(value)

            value = fm.value_as_boolean(stored_filter[filterkey.\
                                                           FLT_HIDE_PASSWORDED])
            self.checkbox_hide_passworded.set_active(value)

            #query params
            value = fm.value_as_boolean(stored_filter[filterkey.QRY_SHOW_FULL])
            self.checkbox_showfull.set_active(value)

            value = fm.value_as_boolean(
                stored_filter[filterkey.QRY_SHOW_EMPTY])
            self.checkbox_showempty.set_active(value)

            #the gearvalue list
            if filterkey.FLT_GEAR in stored_filter:
                value = stored_filter[filterkey.FLT_GEAR]
                if cfgvalues.DISABLED == value:
                    self.radio_gear_disable.set_active(True)
                    self.radio_gear_exclude.set_active(False)
                    self.radio_gear_include.set_active(False)
                elif cfgvalues.INCLUDE == value:
                    self.radio_gear_disable.set_active(False)
                    self.radio_gear_exclude.set_active(False)
                    self.radio_gear_include.set_active(True)
                elif cfgvalues.EXCLUDE == value:
                    self.radio_gear_disable.set_active(False)
                    self.radio_gear_exclude.set_active(True)
                    self.radio_gear_include.set_active(False)

            if filterkey.FLT_GEAR_LIST in stored_filter:
                for value in stored_filter[filterkey.FLT_GEAR_LIST]:
                    self.gearliststore.append([value])

            if filterkey.FLT_VAR_LIST in stored_filter:
                for value in stored_filter[filterkey.FLT_VAR_LIST]:
                    self.cvarliststore.append([value[0], value[1], \
                                               value[2], value])
示例#25
0
 def __init__(self):
     """
     Constructor. Creating and inititializing the main window of UrTSB.
     """
     gtk.Window.__init__(self)
     Window.instance = self
     
     #window creation and basic window settings
     fm = FileManager()
     window_sizing = fm.get_window_sizing()
     
     gc = GuiController()
     self.set_title(gc.appname + ' v.' + gc.appver + ' - ' + gc.appdesc)
     self.set_icon_from_file(Globals.icon_dir +'/logo.png')
     
     if window_sizing.maximized:
         self.maximize()
     else:
         self.unmaximize()
     self.set_default_size(window_sizing.width, window_sizing.height)
     if None == window_sizing.x and None == window_sizing.y:
         self.set_position(gtk.WIN_POS_CENTER)
     else:
         self.move(window_sizing.x, window_sizing.y)
     self.connect('destroy', gtk.main_quit)
       
       
     # add a VBox that will contain the main notebookpane and a statusbar  
     mainbox = gtk.VBox()  
     self.add(mainbox)  
      
     # the notebook - tabs will be serverlist, favorites,
     # recent servers and settings 
     self.notebook= gtk.Notebook()
     self.notebook.set_border_width(2)
     mainbox.pack_start(self.notebook)
     self.notebook.connect('switch-page', self.on_tab_change)
     
     
     # add the serverlist tab
     self.serverlisttab = ServerTab()
     srvlabel = gtk.Label('Serverlist')        
     self.notebook.append_page(self.serverlisttab, srvlabel)
     
     # add the favorites tab
     self.favoritestab = FavoritesTab()
     favlabel = gtk.Label('Favorites')        
     self.notebook.append_page(self.favoritestab, favlabel)
     
     # add the recently played tab
     self.recenttab = RecentTab()
     recentlabel = gtk.Label('Recently Played')        
     self.notebook.append_page(self.recenttab, recentlabel)
     
     # add the buddies tab
     self.buddiestab = BuddiesTab()
     buddieslabel = gtk.Label('Buddies')
     self.notebook.append_page(self.buddiestab, buddieslabel)
     
     # add the settings tab
     self.settingsstab = SettingsTab()
     settingslabel = gtk.Label('Settings')        
     self.notebook.append_page(self.settingsstab, settingslabel)
     
     #set default tab
     fm = FileManager()
     config = fm.getConfiguration()
     defaulttab = int(config[cfgkey.OPT_DEFAULT_TAB])
     #this variable is used to dertermine if the tabswitch is the first
     #after application start 
     self.first_switch = True
     
     self.notebook.set_current_page(defaulttab)
     
     #connect key press event to be able to create keyboard shortcuts
     self.connect('key-press-event', self.on_key_pressed_event)
    
     #connect window-state-event to handle maximize/demaximize
     self.connect('window-state-event', self.on_window_state_changed)
     
     self.show_all()
示例#26
0
文件: urtsb.py 项目: fabianod/UrTSB
   
    gobject.threads_init() # enable threads for gtk
    
    #init global definitions:
    Globals.initialize(determine_path())
    
    #init logging
    Log(loglevel)
    
    if sys.platform == 'win32':
        #apply gtk style for win32 (wimp theme)
        gtkrcpath = os.path.normpath(os.path.join(Globals.resource_dir, \
                                                               'win_gtk/gtkrc'))
        gtk.rc_parse(gtkrcpath)
    
    window = Window() # create the urtsb window
    guicontroller = GuiController() # initialize the gui controller
    guicontroller.setWindow(window)  
       
    gtk.main() # run the gtk main loop
    
    #on exit save the window size informations
    Log.log.info('Exiting....')
    fm = FileManager()
    Log.log.debug('Saving window size informations')
    fm.save_window_sizing()
    
if __name__ == "__main__":
    start()

示例#27
0
 def save_filter(self):
     """
     writes the current filter/query params to the filter dict
     """
     fm = FileManager()
     filter = fm.get_remembered_filter_parameters()
     if not filter: 
         # TODO: clean up this dirty hack ;)
         fm.filter = {}
         filter = fm.filter
     
     #process gametypes
     value = fm.value_from_boolean(self.gametypesfilter.\
                                     checkbox_show_gametype_all.get_active())
     filter[filterkey.GT_ALL] = value
     
     value = fm.value_from_boolean(self.gametypesfilter.\
                                    checkbox_show_gametype_bomb.get_active())
     filter[filterkey.GT_BOMB] = value
     
     value = fm.value_from_boolean(self.gametypesfilter.\
                                checkbox_show_gametype_survivor.get_active())
     filter[filterkey.GT_TS] = value
     
     value = fm.value_from_boolean(self.gametypesfilter.\
                                     checkbox_show_gametype_ctf.get_active())
     filter[filterkey.GT_CTF] = value
     
     value = fm.value_from_boolean(self.gametypesfilter.\
                                     checkbox_show_gametype_tdm.get_active())
     filter[filterkey.GT_TDM] = value
     
     value = fm.value_from_boolean(self.gametypesfilter.\
                                     checkbox_show_gametype_cah.get_active())
     filter[filterkey.GT_CAH] = value
     
     value = fm.value_from_boolean(self.gametypesfilter.\
                                     checkbox_show_gametype_ftl.get_active())
     filter[filterkey.GT_FTL] = value
     
     value = fm.value_from_boolean(self.gametypesfilter.\
                                     checkbox_show_gametype_ffa.get_active())
     filter[filterkey.GT_FFA] = value
     
     #other filters
     filter[filterkey.FLT_MIN_PLAYERS] = self.\
                                            minplayerentry.get_value_as_int()
     filter[filterkey.FLT_MAX_PLAYERS] = self.\
                                            maxplayerentry.get_value_as_int()
     
     value = fm.value_from_boolean(self.\
                                   checkbox_hide_non_responsive.get_active())
     filter[filterkey.FLT_HIDE_NON_RESP] = value
     
     value = fm.value_from_boolean(self.\
                                       checkbox_hide_passworded.get_active())
     filter[filterkey.FLT_HIDE_PASSWORDED] = value
     
     #mapname and servername filter
     filter[filterkey.FLT_MAP_NAME] = self.mapnameentry.get_text()
     filter[filterkey.FLT_SERVER_NAME] = self.servernameentry.get_text()        
     
     #query params
     value = fm.value_from_boolean(self.checkbox_showfull.get_active())
     filter[filterkey.QRY_SHOW_FULL] = value
     
     value = fm.value_from_boolean(self.checkbox_showempty.get_active())
     filter[filterkey.QRY_SHOW_EMPTY] = value
     
     if self.radio_gear_disable.get_active():
         filter[filterkey.FLT_GEAR] = cfgvalues.DISABLED
     elif self.radio_gear_include.get_active():
         filter[filterkey.FLT_GEAR] = cfgvalues.INCLUDE
     elif self.radio_gear_exclude.get_active():
         filter[filterkey.FLT_GEAR] = cfgvalues.EXCLUDE
     
     #iterate over gearliststore to create a list of geavalues 
     iter = self.gearliststore.iter_children(None)
     gearvalues = [] #empty list
     while iter:
         value = self.gearliststore.get_value(iter, 0)
         gearvalues.append(value)
         iter = self.gearliststore.iter_next(iter)
     filter[filterkey.FLT_GEAR_LIST] = gearvalues
            
     #iterate over varliststore to create the list of filter vars
     iter = self.cvarliststore.iter_children(None)
     varlist = []
     while iter:
         varfilter = self.cvarliststore.get_value(iter, 3)
         varlist.append(varfilter)
         iter = self.cvarliststore.iter_next(iter)
     filter[filterkey.FLT_VAR_LIST] = varlist
     
     #write to file
     t = Thread(target=fm.save_filter_to_remember)
     t.setDaemon(True)
     t.start()
示例#28
0
 def set_default_values(self, reset):
     """
     Set default values to all input elements of the filter.
     Differs between application defaults and the values that are stored
     in a file to remember user choices.
     
     @param reset - boolean: if True use application defaults, otherwise load
                    values from file. 
    
     """
     
     self.gearliststore.clear()
     self.cvarliststore.clear()
     
     fm = FileManager()
     stored_filter = fm.get_remembered_filter_parameters()
     
     #gearcheckbox is not stored, only the listview
     #initialize with all checked
     self.checkbox_grenades.set_active(True)
     self.checkbox_snipers.set_active(True)
     self.checkbox_spas.set_active(True)
     self.checkbox_pistols.set_active(True)
     self.checkbox_automatics.set_active(True)
     self.checkbox_negev.set_active(True)
     
     
     if reset or None == stored_filter: #reset to application defaults            
         self.gametypesfilter.checkbox_show_gametype_all.set_active(True)
         # emits the 'toggled' signal
         self.gametypesfilter.checkbox_show_gametype_all.toggled() 
         
         self.checkbox_hide_non_responsive.set_active(True)
         self.checkbox_hide_passworded.set_active(True)
         
         #defaults for min and maxplayer spinbuttons
         self.minplayerentry.set_value(0)
         self.maxplayerentry.set_value(99)
         
         self.checkbox_showfull.set_active(False)
         self.checkbox_showempty.set_active(False)
         
         self.mapnameentry.set_text('')
         self.servernameentry.set_text('')
     else: #reset to stored values
         
         #gametypes
         value = fm.value_as_boolean(stored_filter[filterkey.GT_ALL])
         self.gametypesfilter.checkbox_show_gametype_all.set_active(True)
         
         value = fm.value_as_boolean(stored_filter[filterkey.GT_BOMB])
         self.gametypesfilter.checkbox_show_gametype_bomb.set_active(value)
         
         value = fm.value_as_boolean(stored_filter[filterkey.GT_TS])
         self.gametypesfilter.checkbox_show_gametype_survivor.set_active(value)
         
         value = fm.value_as_boolean(stored_filter[filterkey.GT_CTF])
         self.gametypesfilter.checkbox_show_gametype_ctf.set_active(value)
         
         value = fm.value_as_boolean(stored_filter[filterkey.GT_TDM])
         self.gametypesfilter.checkbox_show_gametype_tdm.set_active(value)
         
         value = fm.value_as_boolean(stored_filter[filterkey.GT_CAH])
         self.gametypesfilter.checkbox_show_gametype_cah.set_active(value)
         
         value = fm.value_as_boolean(stored_filter[filterkey.GT_FTL])
         self.gametypesfilter.checkbox_show_gametype_ftl.set_active(value)
         
         value = fm.value_as_boolean(stored_filter[filterkey.GT_FFA])
         self.gametypesfilter.checkbox_show_gametype_ffa.set_active(value)
         
         #other filters:
         #defaults for min and maxplayer spinbuttons
         value = int(stored_filter[filterkey.FLT_MIN_PLAYERS])
         self.minplayerentry.set_value(value)
         
         value = int(stored_filter[filterkey.FLT_MAX_PLAYERS])
         self.maxplayerentry.set_value(value)
         
         if filterkey.FLT_MAP_NAME in stored_filter:
             self.mapnameentry.set_text(stored_filter[filterkey.\
                                                               FLT_MAP_NAME])
         if filterkey.FLT_SERVER_NAME in stored_filter:
             self.servernameentry.set_text(stored_filter[filterkey.\
                                                            FLT_SERVER_NAME])
         
         value = fm.value_as_boolean(stored_filter[filterkey.\
                                                          FLT_HIDE_NON_RESP])
         self.checkbox_hide_non_responsive.set_active(value)
         
         value = fm.value_as_boolean(stored_filter[filterkey.\
                                                        FLT_HIDE_PASSWORDED])
         self.checkbox_hide_passworded.set_active(value)
         
         #query params
         value = fm.value_as_boolean(stored_filter[filterkey.QRY_SHOW_FULL])
         self.checkbox_showfull.set_active(value)
         
         value = fm.value_as_boolean(stored_filter[filterkey.QRY_SHOW_EMPTY])
         self.checkbox_showempty.set_active(value)
         
         #the gearvalue list
         if filterkey.FLT_GEAR in stored_filter:
             value = stored_filter[filterkey.FLT_GEAR]
             if cfgvalues.DISABLED == value:
                 self.radio_gear_disable.set_active(True)
                 self.radio_gear_exclude.set_active(False)
                 self.radio_gear_include.set_active(False)
             elif cfgvalues.INCLUDE == value:
                 self.radio_gear_disable.set_active(False)
                 self.radio_gear_exclude.set_active(False)
                 self.radio_gear_include.set_active(True)
             elif cfgvalues.EXCLUDE == value:
                 self.radio_gear_disable.set_active(False)
                 self.radio_gear_exclude.set_active(True)
                 self.radio_gear_include.set_active(False)
         
         if filterkey.FLT_GEAR_LIST in stored_filter:
             for value in stored_filter[filterkey.FLT_GEAR_LIST]:
                 self.gearliststore.append([value])
                 
         if filterkey.FLT_VAR_LIST in stored_filter:
             for value in stored_filter[filterkey.FLT_VAR_LIST]:
                 self.cvarliststore.append([value[0], value[1], \
                                            value[2], value])
示例#29
0
 def set_default_values(self, reset):
     """
     Set default values to all input elements of the filter.
     Differs between application defaults and the values that are stored
     in a file to remember user choices.
     
     @param reset - boolean: if True use application defaults, otherwise load
                    values from file. 
    
     """
     
     fm = FileManager()
     stored_filter = fm.get_remembered_filter_parameters()
     
     if reset or None == stored_filter: #reset to application defaults            
         self.gametypes.checkbox_show_gametype_all.set_active(True)
         # emits the 'toggled' signal
         self.gametypes.checkbox_show_gametype_all.toggled() 
         
         self.checkbox_hide_non_responsive.set_active(True)
         self.checkbox_hide_passworded.set_active(True)
         
         #defaults for min and maxplayer spinbuttons
         self.minplayerentry.set_value(0)
         self.maxplayerentry.set_value(99)
         
         self.checkbox_showfull.set_active(False)
         self.checkbox_showempty.set_active(False)
     else: #reset to stored values
         
         #gametypes
         value = fm.value_as_boolean(stored_filter[filterkey.GT_ALL])
         self.gametypes.checkbox_show_gametype_all.set_active(True)
         
         value = fm.value_as_boolean(stored_filter[filterkey.GT_BOMB])
         self.gametypes.checkbox_show_gametype_bomb.set_active(value)
         
         value = fm.value_as_boolean(stored_filter[filterkey.GT_TS])
         self.gametypes.checkbox_show_gametype_survivor.set_active(value)
         
         value = fm.value_as_boolean(stored_filter[filterkey.GT_CTF])
         self.gametypes.checkbox_show_gametype_ctf.set_active(value)
         
         value = fm.value_as_boolean(stored_filter[filterkey.GT_TDM])
         self.gametypes.checkbox_show_gametype_tdm.set_active(value)
         
         value = fm.value_as_boolean(stored_filter[filterkey.GT_CAH])
         self.gametypes.checkbox_show_gametype_cah.set_active(value)
         
         value = fm.value_as_boolean(stored_filter[filterkey.GT_FTL])
         self.gametypes.checkbox_show_gametype_ftl.set_active(value)
         
         value = fm.value_as_boolean(stored_filter[filterkey.GT_FFA])
         self.gametypes.checkbox_show_gametype_ffa.set_active(value)
         
         #other filters:
         #defaults for min and maxplayer spinbuttons
         value = int(stored_filter[filterkey.FLT_MIN_PLAYERS])
         self.minplayerentry.set_value(value)
         
         value = int(stored_filter[filterkey.FLT_MAX_PLAYERS])
         self.maxplayerentry.set_value(value)
         
         value = fm.value_as_boolean(stored_filter[filterkey.\
                                                          FLT_HIDE_NON_RESP])
         self.checkbox_hide_non_responsive.set_active(value)
         
         value = fm.value_as_boolean(stored_filter[filterkey.\
                                                        FLT_HIDE_PASSWORDED])
         self.checkbox_hide_passworded.set_active(value)
         
         #query params
         value = fm.value_as_boolean(stored_filter[filterkey.QRY_SHOW_FULL])
         self.checkbox_showfull.set_active(value)
         
         value = fm.value_as_boolean(stored_filter[filterkey.QRY_SHOW_EMPTY])
         self.checkbox_showempty.set_active(value)
示例#30
0
 def save_filter(self):
     """
     writes the current filter/query params to the filter dict
     """
     fm = FileManager()
     filter = fm.get_remembered_filter_parameters()
     if not filter: 
         # TODO: clean up this dirty hack ;)
         fm.filter = {}
         filter = fm.filter
     
     #process gametypes
     value = fm.value_from_boolean(self.gametypes.\
                                     checkbox_show_gametype_all.get_active())
     filter[filterkey.GT_ALL] = value
     
     value = fm.value_from_boolean(self.gametypes.\
                                    checkbox_show_gametype_bomb.get_active())
     filter[filterkey.GT_BOMB] = value
     
     value = fm.value_from_boolean(self.gametypes.\
                                checkbox_show_gametype_survivor.get_active())
     filter[filterkey.GT_TS] = value
     
     value = fm.value_from_boolean(self.gametypes.\
                                     checkbox_show_gametype_ctf.get_active())
     filter[filterkey.GT_CTF] = value
     
     value = fm.value_from_boolean(self.gametypes.\
                                     checkbox_show_gametype_tdm.get_active())
     filter[filterkey.GT_TDM] = value
     
     value = fm.value_from_boolean(self.gametypes.\
                                     checkbox_show_gametype_cah.get_active())
     filter[filterkey.GT_CAH] = value
     
     value = fm.value_from_boolean(self.gametypes.\
                                     checkbox_show_gametype_ftl.get_active())
     filter[filterkey.GT_FTL] = value
     
     value = fm.value_from_boolean(self.gametypes.\
                                     checkbox_show_gametype_ffa.get_active())
     filter[filterkey.GT_FFA] = value
     
     #other filters
     filter[filterkey.FLT_MIN_PLAYERS] = self.\
                                            minplayerentry.get_value_as_int()
     filter[filterkey.FLT_MAX_PLAYERS] = self.\
                                            maxplayerentry.get_value_as_int()
     
     value = fm.value_from_boolean(self.\
                                   checkbox_hide_non_responsive.get_active())
     filter[filterkey.FLT_HIDE_NON_RESP] = value
     
     value = fm.value_from_boolean(self.\
                                       checkbox_hide_passworded.get_active())
     filter[filterkey.FLT_HIDE_PASSWORDED] = value
     
     #query params
     value = fm.value_from_boolean(self.checkbox_showfull.get_active())
     filter[filterkey.QRY_SHOW_FULL] = value
     
     value = fm.value_from_boolean(self.checkbox_showempty.get_active())
     filter[filterkey.QRY_SHOW_EMPTY] = value
     
     
     #write to file
     t = Thread(target=fm.save_filter_to_remember)
     t.setDaemon(True)
     t.start()