mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-23 03:38:08 -06:00
Saves filter config in settings #102
This commit is contained in:
parent
094325cbf0
commit
c2413489e5
@ -43,3 +43,5 @@ spelling_language = string(default="")
|
|||||||
save_followers_in_autocompletion_db = boolean(default=False)
|
save_followers_in_autocompletion_db = boolean(default=False)
|
||||||
save_friends_in_autocompletion_db = boolean(default=False)
|
save_friends_in_autocompletion_db = boolean(default=False)
|
||||||
ocr_language = string(default="")
|
ocr_language = string(default="")
|
||||||
|
|
||||||
|
[filters]
|
||||||
|
@ -1,8 +1,30 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
import time
|
||||||
|
import widgetUtils
|
||||||
import application
|
import application
|
||||||
from wxUI.dialogs import filterDialogs
|
from wxUI.dialogs import filterDialogs
|
||||||
|
|
||||||
class filter(object):
|
class filter(object):
|
||||||
def __init__(self):
|
def __init__(self, buffer):
|
||||||
|
self.buffer = buffer
|
||||||
self.dialog = filterDialogs.filterDialog(languages=[i["name"] for i in application.supported_languages])
|
self.dialog = filterDialogs.filterDialog(languages=[i["name"] for i in application.supported_languages])
|
||||||
self.dialog.get_response()
|
if self.dialog.get_response() == widgetUtils.OK:
|
||||||
|
contains = self.dialog.get("contains")
|
||||||
|
term = self.dialog.get("term")
|
||||||
|
regexp = self.dialog.get("regexp")
|
||||||
|
load_language = self.dialog.get("load_language")
|
||||||
|
ignore_language = self.dialog.get("ignore_language")
|
||||||
|
lang_option = None
|
||||||
|
if ignore_language:
|
||||||
|
lang_option = False
|
||||||
|
elif load_language:
|
||||||
|
lang_option = True
|
||||||
|
langs = self.dialog.get_selected_langs()
|
||||||
|
langcodes = []
|
||||||
|
for i in application.supported_languages:
|
||||||
|
if i["name"] in langs:
|
||||||
|
langcodes.append(i["code"])
|
||||||
|
d = dict(in_buffer=self.buffer.name, word=term, regexp=regexp, in_lang=lang_option, languages=langcodes, if_word_exists=contains)
|
||||||
|
filter_title = "filter_{0}".format(str(time.time()))
|
||||||
|
self.buffer.session.settings["filters"][filter_title] = d
|
||||||
|
self.buffer.session.settings.write()
|
@ -490,7 +490,7 @@ class Controller(object):
|
|||||||
if not hasattr(page.buffer, "list"):
|
if not hasattr(page.buffer, "list"):
|
||||||
output.speak(_(u"No session is currently in focus. Focus a session with the next or previous session shortcut."), True)
|
output.speak(_(u"No session is currently in focus. Focus a session with the next or previous session shortcut."), True)
|
||||||
return
|
return
|
||||||
new_filter = filterController.filter()
|
new_filter = filterController.filter(page)
|
||||||
|
|
||||||
def seekLeft(self, *args, **kwargs):
|
def seekLeft(self, *args, **kwargs):
|
||||||
try:
|
try:
|
||||||
|
@ -79,5 +79,5 @@ class filterDialog(baseDialog.BaseWXDialog):
|
|||||||
self.langs.Delete(n)
|
self.langs.Delete(n)
|
||||||
self.indexes.remove(v)
|
self.indexes.remove(v)
|
||||||
|
|
||||||
def get_all_langs(self):
|
def get_selected_langs(self):
|
||||||
return self.indexes
|
return self.indexes
|
||||||
|
Loading…
Reference in New Issue
Block a user