Display error if user has not provided a name for a filter upon creation

This commit is contained in:
Manuel Cortez 2021-11-03 09:10:35 -06:00
parent 8b06437cad
commit 6904c153d4
3 changed files with 9 additions and 6 deletions

View File

@ -7,6 +7,7 @@ TWBlue Changelog
* TWBlue should retrieve tweets from threads and conversations in a more reliable way. Tweets in the same thread (made by the same author) will be sorted correctly, although replies to the thread (made by different people) may not be ordered in the same way they are displayed in Twitter apps. ([#417](https://github.com/manuelcortez/TWBlue/issues/417)) * TWBlue should retrieve tweets from threads and conversations in a more reliable way. Tweets in the same thread (made by the same author) will be sorted correctly, although replies to the thread (made by different people) may not be ordered in the same way they are displayed in Twitter apps. ([#417](https://github.com/manuelcortez/TWBlue/issues/417))
* fixed a bug when clearing the direct messages buffer. ([#418](https://github.com/manuelcortez/TWBlue/issues/418)) * fixed a bug when clearing the direct messages buffer. ([#418](https://github.com/manuelcortez/TWBlue/issues/418))
* fixed an issue that was making TWBlue to show incorrectly titles for trending topic buffers upon startup. ([#421](https://github.com/manuelcortez/TWBlue/issues/421)) * fixed an issue that was making TWBlue to show incorrectly titles for trending topic buffers upon startup. ([#421](https://github.com/manuelcortez/TWBlue/issues/421))
* When creating a filter, TWBlue will show an error if user has not provided a name for the filter. Before, unnamed filters were a cause of config breaks in the application.
## Changes in Version 2021.10.30 ## Changes in Version 2021.10.30

View File

@ -1,6 +1,4 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import unicode_literals
from builtins import object
import time import time
import widgetUtils import widgetUtils
import application import application

View File

@ -1,10 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import unicode_literals
# -*- coding: utf-8 -*-
from . import baseDialog
import wx import wx
import widgetUtils import widgetUtils
from . import baseDialog
from multiplatform_widgets import widgets from multiplatform_widgets import widgets
class filterDialog(baseDialog.BaseWXDialog): class filterDialog(baseDialog.BaseWXDialog):
@ -19,6 +16,7 @@ class filterDialog(baseDialog.BaseWXDialog):
dc = wx.WindowDC(self.title) dc = wx.WindowDC(self.title)
dc.SetFont(self.title.GetFont()) dc.SetFont(self.title.GetFont())
self.title.SetSize(dc.GetTextExtent("0"*40)) self.title.SetSize(dc.GetTextExtent("0"*40))
self.title.SetFocus()
tsizer = wx.BoxSizer(wx.HORIZONTAL) tsizer = wx.BoxSizer(wx.HORIZONTAL)
tsizer.Add(label, 0, wx.ALL, 5) tsizer.Add(label, 0, wx.ALL, 5)
tsizer.Add(self.title, 0, wx.ALL, 5) tsizer.Add(self.title, 0, wx.ALL, 5)
@ -81,6 +79,7 @@ class filterDialog(baseDialog.BaseWXDialog):
sizer.Add(selectionSizer, 0, wx.ALL, 5) sizer.Add(selectionSizer, 0, wx.ALL, 5)
ok = wx.Button(panel, wx.ID_OK, _(u"OK")) ok = wx.Button(panel, wx.ID_OK, _(u"OK"))
ok.SetDefault() ok.SetDefault()
ok.Bind(wx.EVT_BUTTON, self.validate_title)
cancel = wx.Button(panel, wx.ID_CANCEL, _(u"Cancel")) cancel = wx.Button(panel, wx.ID_CANCEL, _(u"Cancel"))
btnsizer = wx.BoxSizer() btnsizer = wx.BoxSizer()
btnsizer.Add(ok, 0, wx.ALL, 5) btnsizer.Add(ok, 0, wx.ALL, 5)
@ -116,6 +115,11 @@ class filterDialog(baseDialog.BaseWXDialog):
for i in [self.cb, self.add, self.langs, self.remove]: for i in [self.cb, self.add, self.langs, self.remove]:
i.Show() i.Show()
def validate_title(self, *args, **kwargs):
if self.title.GetValue() == "" or self.title.GetValue() == None:
return wx.MessageDialog(self, _("You must define a name for the filter before creating it."), _("Missing filter name"), wx.ICON_ERROR).ShowModal()
self.EndModal(wx.ID_OK)
class filterManagerDialog(widgetUtils.BaseDialog): class filterManagerDialog(widgetUtils.BaseDialog):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):