From 22b1b0a1496bccaebf63e6a9384aea8b095089cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Cort=C3=A9z?= Date: Tue, 29 Sep 2015 09:37:04 -0500 Subject: [PATCH] Added posibility for search a term in trending topics --- src/controller/buffersController.py | 13 +++++++++---- src/controller/mainController.py | 5 +++++ src/wxUI/buffers/trends.py | 2 ++ src/wxUI/menus.py | 2 ++ 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/controller/buffersController.py b/src/controller/buffersController.py index b07d69d3..53befce1 100644 --- a/src/controller/buffersController.py +++ b/src/controller/buffersController.py @@ -908,6 +908,7 @@ class trendsBufferController(bufferController): self.buffer.name = name self.compose_function = self.compose_function_ self.get_formatted_message = self.get_message + self.reply = self.search_topic def start_stream(self): try: @@ -934,10 +935,12 @@ class trendsBufferController(bufferController): def bind_events(self): log.debug("Binding events...") self.buffer.list.list.Bind(wx.EVT_CHAR_HOOK, self.get_event) -# widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.post_tweet, self.buffer.tweet) + widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.post_tweet, self.buffer.tweet) + widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.tweet_about_this_trend, self.buffer.tweetTrendBtn) + # widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.retweet, self.buffer.retweet) # 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) + widgetUtils.connect_event(self.buffer, widgetUtils.BUTTON_PRESSED, self.search_topic, self.buffer.search_topic) widgetUtils.connect_event(self.buffer.list.list, wx.EVT_LIST_ITEM_RIGHT_CLICK, self.show_menu) widgetUtils.connect_event(self.buffer.list.list, wx.EVT_LIST_KEY_DOWN, self.show_menu_by_key) @@ -954,11 +957,13 @@ class trendsBufferController(bufferController): elif dlg == widgetUtils.NO: return False - def interact(self, *args, **kwargs): - self.searchfunction(value=self.get_message()) + def search_topic(self, *args, **kwargs): + topic = self.trends[self.buffer.list.get_selected()]["name"] + pub.sendMessage("search", term=topic) def show_menu(self, ev, pos=0, *args, **kwargs): menu = menus.trendsPanelMenu() + widgetUtils.connect_event(menu, widgetUtils.MENU, self.search_topic, menuitem=menu.search_topic) widgetUtils.connect_event(menu, widgetUtils.MENU, self.tweet_about_this_trend, menuitem=menu.tweetThisTrend) widgetUtils.connect_event(menu, widgetUtils.MENU, self.view, menuitem=menu.view) widgetUtils.connect_event(menu, widgetUtils.MENU, self.copy, menuitem=menu.copy) diff --git a/src/controller/mainController.py b/src/controller/mainController.py index 43d76098..c9ab53aa 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -129,6 +129,7 @@ class Controller(object): pub.subscribe(self.create_new_buffer, "create-new-buffer") pub.subscribe(self.restart_streams, "restart-streams") pub.subscribe(self.execute_action, "execute-action") + pub.subscribe(self.search_topic, "search") if system == "Windows": pub.subscribe(self.invisible_shorcuts_changed, "invisible-shorcuts-changed") widgetUtils.connect_event(self.view, widgetUtils.MENU, self.show_hide, menuitem=self.view.show_hide) @@ -395,6 +396,10 @@ class Controller(object): self.buffers.remove(buffer) del buffer + def search_topic(self, term): + self.search(value=term) + + def search(self, event=None, value="", *args, **kwargs): """ Searches words or users in twitter. This creates a new buffer containing the search results.""" log.debug("Creating a new search...") diff --git a/src/wxUI/buffers/trends.py b/src/wxUI/buffers/trends.py index f3a6b6f5..f055ce69 100644 --- a/src/wxUI/buffers/trends.py +++ b/src/wxUI/buffers/trends.py @@ -16,9 +16,11 @@ class trendsPanel(wx.Panel): self.create_list() self.tweet = wx.Button(self, -1, _(u"Tweet")) self.tweetTrendBtn = wx.Button(self, -1, _(u"Tweet about this trend")) + self.search_topic = wx.Button(self, -1, _(u"Search topic")) btnSizer = wx.BoxSizer(wx.HORIZONTAL) btnSizer.Add(self.tweet, 0, wx.ALL, 5) btnSizer.Add(self.tweetTrendBtn, 0, wx.ALL, 5) + btnSizer.Add(self.search_topic, 0, wx.ALL, 5) self.sizer.Add(btnSizer, 0, wx.ALL, 5) self.sizer.Add(self.list.list, 0, wx.ALL, 5) self.SetSizer(self.sizer) diff --git a/src/wxUI/menus.py b/src/wxUI/menus.py index fbad7540..da9ca997 100644 --- a/src/wxUI/menus.py +++ b/src/wxUI/menus.py @@ -87,6 +87,8 @@ class peoplePanelMenu(wx.Menu): class trendsPanelMenu(wx.Menu): def __init__(self): super(trendsPanelMenu, self).__init__() + self.search_topic = wx.MenuItem(self, wx.NewId(), _(u"Search topic")) + self.AppendItem(self.search_topic) self.tweetThisTrend = wx.MenuItem(self, wx.NewId(), _(u"&Tweet about this trend")) self.AppendItem(self.tweetThisTrend) self.view = wx.MenuItem(self, wx.NewId(), _(u"&Show item"))