Added title for filters #102

This commit is contained in:
Manuel Cortez 2017-11-23 17:42:26 -06:00
parent 2d9124c336
commit 8836cb2bda
3 changed files with 16 additions and 2 deletions

View File

@ -10,6 +10,7 @@ class filter(object):
self.buffer = 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])
if self.dialog.get_response() == widgetUtils.OK: if self.dialog.get_response() == widgetUtils.OK:
title = self.dialog.get("title")
contains = self.dialog.get("contains") contains = self.dialog.get("contains")
term = self.dialog.get("term") term = self.dialog.get("term")
regexp = self.dialog.get("regexp") regexp = self.dialog.get("regexp")
@ -26,8 +27,9 @@ class filter(object):
if i["name"] in langs: if i["name"] in langs:
langcodes.append(i["code"]) 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) 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())) if self.buffer.session.settings["filters"].has_key(title):
self.buffer.session.settings["filters"][filter_title] = d return commonMessageDialogs.existing_filter()
self.buffer.session.settings["filters"][title] = d
self.buffer.session.settings.write() self.buffer.session.settings.write()
class filterManager(object): class filterManager(object):

View File

@ -83,3 +83,6 @@ def suspended_user():
def delete_filter(): def delete_filter():
return wx.MessageDialog(None, _(u"Do you really want to delete this filter?"), _(u"Attention"), style=wx.ICON_QUESTION|wx.YES_NO).ShowModal() return wx.MessageDialog(None, _(u"Do you really want to delete this filter?"), _(u"Attention"), style=wx.ICON_QUESTION|wx.YES_NO).ShowModal()
def existing_filter():
return wx.MessageDialog(None, _(u"This filter already exists. Please use a different title"), _(u"Error"), wx.OK).ShowModal()

View File

@ -11,6 +11,15 @@ class filterDialog(baseDialog.BaseWXDialog):
panel = wx.Panel(self) panel = wx.Panel(self)
sizer = wx.BoxSizer(wx.VERTICAL) sizer = wx.BoxSizer(wx.VERTICAL)
self.SetTitle(_(u"Create a filter for this buffer")) self.SetTitle(_(u"Create a filter for this buffer"))
label = wx.StaticText(panel, wx.NewId(), _(u"Filter title"))
self.title = wx.TextCtrl(panel, -1, value)
dc = wx.WindowDC(self.title)
dc.SetFont(self.title.GetFont())
self.title.SetSize(dc.GetTextExtent("0"*40))
tsizer = wx.BoxSizer(wx.HORIZONTAL)
tsizer.Add(label, 0, wx.ALL, 5)
tsizer.Add(self.title, 0, wx.ALL, 5)
sizer.Add(tsizer, 0, wx.ALL, 5)
staticbox = wx.StaticBox(panel, label=_(u"Filter by word")) staticbox = wx.StaticBox(panel, label=_(u"Filter by word"))
self.contains = wx.RadioButton(panel, -1, _(u"Ignore tweets wich contain the following word"), style=wx.RB_GROUP) self.contains = wx.RadioButton(panel, -1, _(u"Ignore tweets wich contain the following word"), style=wx.RB_GROUP)
self.doesnt_contain = wx.RadioButton(panel, -1, _(u"Ignore tweets without the following word")) self.doesnt_contain = wx.RadioButton(panel, -1, _(u"Ignore tweets without the following word"))