From 42aea45a41e70ae2df1f09dafa3f4698aac9de23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Cort=C3=A9z?= Date: Sat, 7 Feb 2015 13:55:52 -0600 Subject: [PATCH] A bug exiting TWBlue on GUI mode --- src/controller/buffersController.py | 17 ++++++++++++----- src/controller/mainController.py | 1 + src/wxUI/dialogs/userActions.py | 26 +++++++++++++++----------- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/controller/buffersController.py b/src/controller/buffersController.py index bbd89e5f..8b25f45f 100644 --- a/src/controller/buffersController.py +++ b/src/controller/buffersController.py @@ -414,7 +414,6 @@ class peopleBufferController(baseBufferController): def onFocus(self, ev): pass - @_tweets_exist def get_message(self): return " ".join(self.compose_function(self.get_tweet(), self.session.db, self.session.settings["general"]["relative_times"])) @@ -490,7 +489,10 @@ class searchBufferController(baseBufferController): log.debug("Starting stream for %s buffer, %s account and %s type" % (self.name, self.account, self.type)) log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs)) log.debug("Function: %s" % (self.function,)) - val = getattr(self.session.twitter.twitter, self.function)(*self.args, **self.kwargs) + try: + val = getattr(self.session.twitter.twitter, self.function)(*self.args, **self.kwargs) + except: + return None number_of_items = self.session.order_buffer(self.name, val["statuses"]) log.debug("Number of items retrieved: %d" % (number_of_items,)) self.put_items_on_list(number_of_items) @@ -509,7 +511,10 @@ class searchPeopleBufferController(searchBufferController): log.debug("starting stream for %s buffer, %s account and %s type" % (self.name, self.account, self.type)) log.debug("args: %s, kwargs: %s" % (self.args, self.kwargs)) log.debug("Function: %s" % (self.function,)) - val = getattr(self.session.twitter.twitter, self.function)(*self.args, **self.kwargs) + try: + val = getattr(self.session.twitter.twitter, self.function)(*self.args, **self.kwargs) + except: + return number_of_items = self.session.order_buffer(self.name, val) log.debug("Number of items retrieved: %d" % (number_of_items,)) self.put_items_on_list(number_of_items) @@ -535,7 +540,10 @@ class trendsBufferController(bufferController): self.get_formatted_message = self.get_message def start_stream(self): - data = self.session.twitter.twitter.get_place_trends(id=self.trendsFor) + try: + data = self.session.twitter.twitter.get_place_trends(id=self.trendsFor) + except: + return if not hasattr(self, "name_"): self.name_ = data[0]["locations"][0]["name"] self.trends = data[0]["trends"] @@ -561,7 +569,6 @@ class trendsBufferController(bufferController): # widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.direct_message, self.buffer.dm) # widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.reply, self.buffer.reply) - @_tweets_exist def get_message(self): return self.compose_function(self.trends[self.buffer.list.get_selected()])[0] diff --git a/src/controller/mainController.py b/src/controller/mainController.py index 8a2d032a..12ec9781 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -102,6 +102,7 @@ class Controller(object): widgetUtils.connect_event(self.view, widgetUtils.MENU, self.accountConfiguration, menuitem=self.view.account_settings) widgetUtils.connect_event(self.view, widgetUtils.MENU, self.configuration, menuitem=self.view.prefs) widgetUtils.connect_event(self.view, widgetUtils.MENU, self.exit, menuitem=self.view.close) + widgetUtils.connect_event(self.view, widgetUtils.CLOSE_EVENT, self.exit) if widgetUtils.toolkit == "wx": log.debug("Binding the exit function...") widgetUtils.connectExitFunction(self.exit_) diff --git a/src/wxUI/dialogs/userActions.py b/src/wxUI/dialogs/userActions.py index 39c427fc..2f9f6dc1 100644 --- a/src/wxUI/dialogs/userActions.py +++ b/src/wxUI/dialogs/userActions.py @@ -7,9 +7,11 @@ class UserActionsDialog(wx.Dialog): panel = wx.Panel(self) userSizer = wx.BoxSizer() self.SetTitle(_(u"Action")) + userLabel = wx.StaticText(panel, -1, _(u"User")) self.cb = wx.ComboBox(panel, -1, choices=users, value=users[0]) self.cb.SetFocus() - userSizer.Add(self.cb) + userSizer.Add(userLabel, 0, wx.ALL, 5) + userSizer.Add(self.cb, 0, wx.ALL, 5) actionSizer = wx.BoxSizer(wx.VERTICAL) label2 = wx.StaticText(panel, -1, _(u"Action")) self.follow = wx.RadioButton(panel, -1, _(u"Follow"), style=wx.RB_GROUP) @@ -21,15 +23,17 @@ class UserActionsDialog(wx.Dialog): self.reportSpam = wx.RadioButton(panel, -1, _(u"Report as spam")) self.ignore_client = wx.RadioButton(panel, -1, _(u"Ignore tweets from this client")) self.setup_default(default) - actionSizer.Add(label2) - actionSizer.Add(self.follow) - actionSizer.Add(self.unfollow) - actionSizer.Add(self.mute) - actionSizer.Add(self.unmute) - actionSizer.Add(self.block) - actionSizer.Add(self.unblock) - actionSizer.Add(self.reportSpam) - actionSizer.Add(self.ignore_client) + hSizer = wx.BoxSizer(wx.HORIZONTAL) + hSizer.Add(label2, 0, wx.ALL, 5) + actionSizer.Add(self.follow, 0, wx.ALL, 5) + actionSizer.Add(self.unfollow, 0, wx.ALL, 5) + actionSizer.Add(self.mute, 0, wx.ALL, 5) + actionSizer.Add(self.unmute, 0, wx.ALL, 5) + actionSizer.Add(self.block, 0, wx.ALL, 5) + actionSizer.Add(self.unblock, 0, wx.ALL, 5) + actionSizer.Add(self.reportSpam, 0, wx.ALL, 5) + actionSizer.Add(self.ignore_client, 0, wx.ALL, 5) + hSizer.Add(actionSizer, 0, wx.ALL, 5) sizer = wx.BoxSizer(wx.VERTICAL) ok = wx.Button(panel, wx.ID_OK, _(u"OK")) ok.SetDefault() @@ -38,7 +42,7 @@ class UserActionsDialog(wx.Dialog): btnsizer.Add(ok) btnsizer.Add(cancel) sizer.Add(userSizer) - sizer.Add(actionSizer) + sizer.Add(hSizer, 0, wx.ALL, 5) sizer.Add(btnsizer) panel.SetSizer(sizer)