Exemple #1
0
    def on_filter_checkbutton_changed(self, widget):
        if widget.get_active():
            # open list
            try:
                already_selected_terms = self.selected_terms
                d = MMSelectDialog('Terms', self.terms_list,
                                   already_selected_terms)
            except:
                d = MMSelectDialog('Terms', self.terms_list, None)

            if d.run() == gtk.RESPONSE_CANCEL:
                #logging.debug('User canceled terms selection dialog, unchecking filter checkbutton')
                widget.set_active(0)
            else:
                if d.return_id_list == []:
                    #logging.debug('User selected None, unchecking filter checkbutton')
                    widget.set_active(0)
                elif len(d.return_id_list) == len(self.terms_list):
                    #logging.debug("User selected all sources, selecting 'all'")
                    widget.set_active(0)
                else:
                    #logging.debug('User selected sources: %s' % ', '.join(d.return_id_list))
                    self.selected_terms = d.return_id_list
        else:
            # do nothing, checkbutton state is enough
            pass

        # refresh visualization
        self.cb_threshold_changed(None)
    def on_combobox_sources_changed(self, combobox):
        self.clear_results()
        model = combobox.get_model()
        index = combobox.get_active()
        self.search_options['allsources'] = model[index][0]
        if self.search_options['allsources'] == True:
            logging.debug('Selecting all sources')
        else:
            logging.debug('Selecting selected sources')

            try:
                already_selected_ids = self.search_options['selected_sources']
                d = MMSelectDialog('Sources',
                                   self.search_options['sources_list'],
                                   already_selected_ids)
            except:
                d = MMSelectDialog('Sources',
                                   self.search_options['sources_list'], None)

            if d.run() == gtk.RESPONSE_CANCEL:
                logging.debug('User canceled sources selection dialog')
                combobox.set_active(0)
            else:
                if d.return_id_list == []:
                    logging.debug('User selected None, selecting all sources')
                    combobox.set_active(0)
                elif len(d.return_id_list) == len(
                        self.search_options['sources_list']):
                    logging.debug("User selected all sources, selecting 'all'")
                    combobox.set_active(0)
                else:
                    logging.debug('User selected sources: %s' %
                                  ', '.join(d.return_id_list))
                    self.search_options['selected_sources'] = d.return_id_list