From 89e541be95a05ed1a46deeb735d956fa46db812e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Cort=C3=A9z?= Date: Tue, 17 Mar 2015 12:24:29 -0600 Subject: [PATCH] Open a search from the trending topics buffer is now possible --- src/controller/buffersController.py | 13 ++++++++----- src/controller/mainController.py | 18 ++++++------------ src/fixes/fix_arrow.py | 3 ++- src/wxUI/dialogs/search.py | 4 ++-- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/controller/buffersController.py b/src/controller/buffersController.py index b642ae69..f64e1ba2 100644 --- a/src/controller/buffersController.py +++ b/src/controller/buffersController.py @@ -50,10 +50,10 @@ class bufferController(object): event = None ev.Skip() if event != None: -# try: - getattr(self, event)() -# except AttributeError: - #pass + try: + getattr(self, event)() + except AttributeError: + pass def volume_down(self): if self.session.settings["sound"]["volume"] > 0.0: @@ -688,4 +688,7 @@ class trendsBufferController(bufferController): self.timer.cancel() return True elif dlg == widgetUtils.NO: - return False \ No newline at end of file + return False + + def url(self, *args, **kwargs): + self.searchfunction(value=self.get_message()) \ No newline at end of file diff --git a/src/controller/mainController.py b/src/controller/mainController.py index 8eb572cf..878b6e59 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -325,6 +325,7 @@ class Controller(object): for i in session.settings["other_buffers"]["trending_topic_buffers"]: buffer = buffersController.trendsBufferController(self.view.nb, "%s_tt" % (i,), session, session.db["user_name"], i) buffer.start_stream() + buffer.searchfunction = self.search self.buffers.append(buffer) self.view.insert_buffer(buffer.buffer, name=_(u"Trending topics for %s") % (buffer.name_), pos=self.view.search(session.db["user_name"], session.db["user_name"])) buffer.timer = RepeatingTimer(300, buffer.start_stream) @@ -363,10 +364,10 @@ class Controller(object): self.buffers.remove(buffer) del buffer - def search(self, *args, **kwargs): + def search(self, value="", *args, **kwargs): """ Searches words or users in twitter. This creates a new buffer containing the search results.""" log.debug("Creating a new search...") - dlg = dialogs.search.searchDialog() + dlg = dialogs.search.searchDialog(value) if dlg.get_response() == widgetUtils.OK: term = dlg.get("term") buffer = self.get_best_buffer() @@ -662,15 +663,6 @@ class Controller(object): self.view.Show() self.showing = True - def toggle_global_mute(self): - pass - - def toggle_mute(self): - pass - - def toggle_autoread(self): - pass - def get_trending_topics(self, *args, **kwargs): buff = self.get_best_buffer() trends = trendingTopics.trendingTopicsController(buff.session) @@ -678,6 +670,7 @@ class Controller(object): woeid = trends.get_woeid() if woeid in buff.session.settings["other_buffers"]["trending_topic_buffers"]: return buffer = buffersController.trendsBufferController(self.view.nb, "%s_tt" % (woeid,), buff.session, buff.account, woeid) + buffer.searchfunction = self.search self.buffers.append(buffer) self.view.insert_buffer(buffer.buffer, name=_(u"Trending topics for %s") % (trends.get_string()), pos=self.view.search(buff.session.db["user_name"], buff.session.db["user_name"])) buffer.start_stream() @@ -919,7 +912,8 @@ class Controller(object): pass def url(self, *args, **kwargs): - self.get_current_buffer().url() + buffer = self.get_current_buffer() + buffer.url() def audio(self, *args, **kwargs): self.get_current_buffer().audio() diff --git a/src/fixes/fix_arrow.py b/src/fixes/fix_arrow.py index 979d1fc9..c908fc07 100644 --- a/src/fixes/fix_arrow.py +++ b/src/fixes/fix_arrow.py @@ -4,7 +4,8 @@ from arrow.locales import Locale def fix(): ''' This function adds the Catala, Basque and galician locales to the list of locales supported in Arrow. - it also fixes capitalizations in names from turkish and arabian locales.''' + it also fixes capitalizations in names from turkish and arabian locales. + see https://github.com/crsmithdev/arrow/pull/207 for following the pull request.''' locales.CatalaLocale = CatalaLocale locales.GalicianLocale = GalicianLocale locales.BasqueLocale = BasqueLocale diff --git a/src/wxUI/dialogs/search.py b/src/wxUI/dialogs/search.py index c6c6a52c..81b54272 100644 --- a/src/wxUI/dialogs/search.py +++ b/src/wxUI/dialogs/search.py @@ -3,13 +3,13 @@ import baseDialog import wx class searchDialog(baseDialog.BaseWXDialog): - def __init__(self): + def __init__(self, value=""): super(searchDialog, self).__init__(None, -1) panel = wx.Panel(self) sizer = wx.BoxSizer(wx.VERTICAL) self.SetTitle(_(u"Search on Twitter")) label = wx.StaticText(panel, -1, _(u"Search")) - self.term = wx.TextCtrl(panel, -1,) + self.term = wx.TextCtrl(panel, -1, value) dc = wx.WindowDC(self.term) dc.SetFont(self.term.GetFont()) self.term.SetSize(dc.GetTextExtent("0"*40))