def on_del(self, evt): """a custom attribute has been modified""" # update data index = self.f_filters_list.FindItem(0, self.f_key_value.GetValue()) if index != -1 and self.f_filters_list.DeleteItem(index): get_filter_facade().del_repository(self.f_key_value.GetValue()) self.do_modified(True)
def on_add(self, evt): """a custom attribute has been modified""" try: # update cache, facade will refresh window (through FilterView) filter_value = FilterValue(value=self.p_filter_value.GetValue(), activate=True) get_filter_facade().add_custom_attributes(self.p_key_value.GetValue(), filter_value) self.do_modified(True) except Exception: self._regex_not_valid("attribute", self.p_filter_value.GetValue())
def set_page(self): document = get_filter_facade().get_document() last_added = document.get_last_downloaded_desc() if last_added: peer_match = get_filter_facade().get_peer(last_added.get_id()) if peer_match.has_match(): self.matched_panel.set_matches(peer_match) self.matched_panel.set_tab(peer_match.peer_desc) if get_filter_facade().is_activated(): self.Show() document.reset_last_downloaded_desc()
def on_import(self, evt): """match current filter with given profile""" dlg = wx.FileDialog( self, message="Match profile ...", defaultDir=get_prefs("profile_dir"), defaultFile="", wildcard="Solipsis file (*.prf)|*.prf", style=wx.OPEN) if dlg.ShowModal() == wx.ID_OK: path = dlg.GetPath()[:-4] loader = FileDocument() loader.load(path + PROFILE_EXT) get_facade().fill_data(loader.get_pseudo(), loader) get_filter_facade().fill_data(loader.get_pseudo(), loader)
def on_import(self, evt): """match current filter with given profile""" dlg = wx.FileDialog( self, message="Match profile ...", defaultDir=PROFILE_DIR, defaultFile="", wildcard="Solipsis file (*.prf)|*.prf", style=wx.OPEN) if dlg.ShowModal() == wx.ID_OK: path = dlg.GetPath()[:-4] loader = FileDocument(path) loader.load() pseudo = loader.pseudo get_facade().fill_data((pseudo, loader)) get_filter_facade().fill_data((pseudo, loader))
def on_add(self, evt): """a custom attribute has been modified""" try: # update cache, facade will refresh window (through FilterView) filter_value = FilterValue(value=self.f_filter_value.GetValue(), activate=True) get_filter_facade().add_repository(self.f_key_value.GetValue(), filter_value) self.do_modified(True) except Exception: import traceback traceback.print_exc() dlg = wx.MessageDialog(self, """Regular expression '%s' not valid. See Info > Help for more information"""% self.f_filter_value.GetValue(), "Error on %s"% self.f_key_value.GetValue(), wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy()
def on_check_pseudo(self, evt): """activate field and notify facade""" try: filter_value = FilterValue(value=self.pseudo_value.GetValue(), activate=self.pseudo_checkbox.IsChecked()) if get_filter_facade().change_pseudo(filter_value) != False: self.do_modified(True) except Exception, err: self._regex_not_valid("pseudo", self.pseudo_value.GetValue())
def on_check_email(self, evt): """activate field and notify facade""" try: filter_value = FilterValue(value=self.email_value.GetValue(), activate=self.email_checkbox.IsChecked()) if get_filter_facade().change_email(filter_value) != False: self.do_modified(True) except Exception: self._regex_not_valid("email", self.email_value.GetValue()) evt.Skip()
def Disable(self): """It is called when the user chooses to disable the service.""" # ask for saving (ca not simply call Close() on editor frame # method because of multithreading and the frame is destroyed # before the user actually answer to the popup if self.editor_frame.modified: self.editor_frame.do_modified(False) dlg = wx.MessageDialog( self.editor_frame, 'Your profile has been modified. Do you want to save it?', 'Saving Profile', wx.YES_NO | wx.ICON_INFORMATION) if dlg.ShowModal() == wx.ID_YES: get_facade().save() if self.filter_frame.modified: self.filter_frame.do_modified(False) dlg = wx.MessageDialog( self.editor_frame, 'Your filters have been modified. Do you want to save them?', 'Saving Filters', wx.YES_NO | wx.ICON_INFORMATION) if dlg.ShowModal() == wx.ID_YES: get_filter_facade().save() self.activate(False)
def on_activate(self, evt): """activate service""" print self.activate_item.IsChecked() and "Activating..." \ or "Disactivated" get_filter_facade()._activated = self.activate_item.IsChecked()
def on_change_facade(self): """called when user changes identity (facade chanegd)""" get_filter_facade()._activated = self.activate_item.IsChecked()
def on_save(self, evt): """save .prf""" self.do_modified(False) get_filter_facade()._desc.save(doc_extension=FILTER_EXT)
def on_save(self, evt): """save .prf""" self.do_modified(False) get_filter_facade().save()
def _on_profile_complete(self, document, peer_id): """callback when autoloading of profile successful""" get_facade().set_data((peer_id, document)) get_facade().set_connected((peer_id, True)) get_filter_facade().fill_data((peer_id, document))
def filter_profile(self, deferred=None): """display profile once loaded""" if self.filter_frame: self.filter_frame.Show() if not deferred is None: deferred.callback(str(get_filter_facade()._desc))