def __init__(self, label, items): super(MultiSearchFilter, self).__init__(label=label) self._title_label = Gtk.Label(label=label) self.pack_start(self._title_label, False, False, 0) self._combo = ProxyMultiCombo(width=400) self._combo.prefill(items) self._combo.connect('content-changed', self._on_combo__content_changed) self.pack_start(self._combo, False, False, 6) self.show_all()
class MultiSearchFilter(SearchFilter): """A multi object search filter, containing: - a label - a multicombo widget """ __gtype_name__ = 'MultiSearchFilter' def __init__(self, label, items): super(MultiSearchFilter, self).__init__(label=label) self._title_label = Gtk.Label(label=label) self.pack_start(self._title_label, False, False, 0) self._combo = ProxyMultiCombo(width=400) self._combo.prefill(items) self._combo.connect('content-changed', self._on_combo__content_changed) self.pack_start(self._combo, False, False, 6) self.show_all() # # SearchFilter # def set_label(self, label): super(MultiSearchFilter, self).set_label(label) self._title_label.set_text(label) def get_title_label(self): return self._title_label def get_state(self): return MultiQueryState(filter=self, values=self._combo.get_selection_data()) def set_state(self, values): self._combo.clear() self._combo.add_selection_by_data(values) def get_mode_combo(self): return None def get_description(self): return '%s: [%s]' % (', '.join(self._combo.get_selection_label()), ) # # Callbacks # def _on_combo__content_changed(self, combo): self.emit('changed')