From f2fab29cb77632e6826c07f53528ad7e9c047936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Cort=C3=A9z?= Date: Fri, 5 Dec 2014 17:05:29 -0600 Subject: [PATCH] Trending topics improvements --- src/Conf.defaults | 3 ++- src/gui/buffers/trends.py | 22 ++++++++-------------- src/gui/main.py | 12 ++++++++++-- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/Conf.defaults b/src/Conf.defaults index a7bf66f9..ed13d5cb 100644 --- a/src/Conf.defaults +++ b/src/Conf.defaults @@ -90,4 +90,5 @@ edit_keystrokes = string(default="control+win+k") view_user_lists = string(default="control+win+l") get_more_items = string(default="alt+win+pageup") reverse_geocode = string(default="control+win+g") -view_reverse_geocode = string(default="control+win+shift+g") \ No newline at end of file +view_reverse_geocode = string(default="control+win+shift+g") +get_trending_topics = string(default="control+win+t") \ No newline at end of file diff --git a/src/gui/buffers/trends.py b/src/gui/buffers/trends.py index 967088e7..e959ae62 100644 --- a/src/gui/buffers/trends.py +++ b/src/gui/buffers/trends.py @@ -85,8 +85,11 @@ class trendsPanel(wx.Panel): def start_streams(self): data = self.twitter.twitter.get_place_trends(id=self.argumento) + if not hasattr(self, "name"): + self.name = data[0]["locations"][0]["name"] self.trends = data[0]["trends"] - sound.player.play(self.sound) + # We need to get the trends sound, so the next line is commented. +# sound.player.play(self.sound) return len(self.trends) def get_more_items(self): @@ -94,20 +97,11 @@ class trendsPanel(wx.Panel): def put_items(self, num): selected_item = self.list.get_selected() - if self.list.get_count() == 0: - for i in self.trends: - tweet = self.compose_function(i) - self.list.insert_item(False, *tweet) + self.list.clear() + for i in self.trends: + tweet = self.compose_function(i) + self.list.insert_item(False, *tweet) self.set_list_position() - elif self.list.get_count() > 0: - if config.main["general"]["reverse_timelines"] == False: - for i in self.trends: - tweet = self.compose_function(i) - self.list.insert_item(False, *tweet) - else: - for i in self.trends: - tweet = self.compose_function(i) - self.list.insert_item(True, *tweet) self.list.select_item(selected_item) def post_status(self, ev=None): diff --git a/src/gui/main.py b/src/gui/main.py index c42a159c..3f2cc293 100644 --- a/src/gui/main.py +++ b/src/gui/main.py @@ -319,6 +319,13 @@ class mainFrame(wx.Frame): self.db.settings["buffers"].append(i+"favs") self.fav_stream = RepeatingTimer(180, self.get_fav_buffers) self.fav_stream.start() + for i in config.main["other_buffers"]["trending_topic_buffers"]: + buff = buffers.trendsPanel(self.nb, self, "%s_tt" % (i,), argumento=i, sound="trendd_updated.ogg") + timer = RepeatingTimer(300, buff.start_streams) + timer.start() + num = buff.start_streams() + buff.put_items(num) + self.nb.InsertSubPage(self.db.settings["buffers"].index(self.db.settings["user_name"]), buff, _(u"Trending topics for %s") % (buff.name,)) self.sizer.Add(self.nb, 0, wx.ALL, 5) panel.SetSizer(self.sizer) self.SetClientSize(self.sizer.CalcMin()) @@ -1026,11 +1033,12 @@ class mainFrame(wx.Frame): woeid = trendingDialog.countries[trendingDialog.location.GetStringSelection()] elif trendingDialog.city.GetValue() == True: woeid = trendingDialog.cities[trendingDialog.location.GetStringSelection()] - buff = buffers.trendsPanel(self.nb, self, "%s_tt" % (woeid,), argumento=woeid, sound="tweet_timeline.ogg") + buff = buffers.trendsPanel(self.nb, self, "%s_tt" % (woeid,), argumento=woeid, sound="trend_updated.ogg") self.nb.InsertSubPage(self.db.settings["buffers"].index(self.db.settings["user_name"]), buff, _(u"Trending topics for %s") % (trendingDialog.location.GetStringSelection(),)) - timer = RepeatingTimer(180, buff.start_streams) + timer = RepeatingTimer(300, buff.start_streams) timer.start() num = buff.start_streams() + config.main["other_buffers"]["trending_topic_buffers"].append(woeid) buff.put_items(num) ### Close App