From 6904c153d45840a2358151eefb32b5234fdbfb2a Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Wed, 3 Nov 2021 09:10:35 -0600 Subject: [PATCH] Display error if user has not provided a name for a filter upon creation --- doc/changelog.md | 1 + src/controller/filterController.py | 2 -- src/wxUI/dialogs/filterDialogs.py | 12 ++++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/doc/changelog.md b/doc/changelog.md index bb3ddd2f..e78fc5e0 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -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)) * 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)) +* 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 diff --git a/src/controller/filterController.py b/src/controller/filterController.py index f1262d19..79684801 100644 --- a/src/controller/filterController.py +++ b/src/controller/filterController.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals -from builtins import object import time import widgetUtils import application diff --git a/src/wxUI/dialogs/filterDialogs.py b/src/wxUI/dialogs/filterDialogs.py index bf7f45b2..53dc202a 100644 --- a/src/wxUI/dialogs/filterDialogs.py +++ b/src/wxUI/dialogs/filterDialogs.py @@ -1,10 +1,7 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import -from __future__ import unicode_literals -# -*- coding: utf-8 -*- -from . import baseDialog import wx import widgetUtils +from . import baseDialog from multiplatform_widgets import widgets class filterDialog(baseDialog.BaseWXDialog): @@ -19,6 +16,7 @@ class filterDialog(baseDialog.BaseWXDialog): dc = wx.WindowDC(self.title) dc.SetFont(self.title.GetFont()) self.title.SetSize(dc.GetTextExtent("0"*40)) + self.title.SetFocus() tsizer = wx.BoxSizer(wx.HORIZONTAL) tsizer.Add(label, 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) ok = wx.Button(panel, wx.ID_OK, _(u"OK")) ok.SetDefault() + ok.Bind(wx.EVT_BUTTON, self.validate_title) cancel = wx.Button(panel, wx.ID_CANCEL, _(u"Cancel")) btnsizer = wx.BoxSizer() 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]: 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): def __init__(self, *args, **kwargs):