Added posibility for search a term in trending topics

This commit is contained in:
Manuel Cortez 2015-09-29 09:37:04 -05:00
parent e71afeb10f
commit 22b1b0a149
4 changed files with 18 additions and 4 deletions

View File

@ -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)

View File

@ -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...")

View File

@ -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)

View File

@ -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"))