diff --git a/src/controller/buffersController.py b/src/controller/buffersController.py index 7e098ffb..07c30aa6 100644 --- a/src/controller/buffersController.py +++ b/src/controller/buffersController.py @@ -185,9 +185,8 @@ class baseBufferController(bufferController): if self.buffer.list.get_count() == 0: for i in self.session.db[self.name]: tweet = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"]) - self.buffer.list.insert_item(False, *tweet) + self.buffer.list.insert_item(self.session.settings["general"]["reverse_timelines"], *tweet) self.buffer.set_position(self.session.settings["general"]["reverse_timelines"]) -# self.buffer.set_list_position() elif self.buffer.list.get_count() > 0: if self.session.settings["general"]["reverse_timelines"] == False: for i in self.session.db[self.name][:number_of_items]: @@ -460,8 +459,8 @@ class trendsBufferController(bufferController): def start_stream(self): data = self.session.twitter.twitter.get_place_trends(id=self.trendsFor) - if not hasattr(self, "name"): - self.name = data[0]["locations"][0]["name"] + if not hasattr(self, "name_"): + self.name_ = data[0]["locations"][0]["name"] self.trends = data[0]["trends"] self.put_items_on_the_list() self.session.sound.play(self.sound) @@ -472,7 +471,7 @@ class trendsBufferController(bufferController): for i in self.trends: tweet = self.compose_function(i) self.buffer.list.insert_item(False, *tweet) - self.buffer.list.select_item(selected_item) + self.buffer.set_position(self.session.settings["general"]["reverse_timelines"]) def compose_function_(self, trend): return [trend["name"]] diff --git a/src/controller/mainController.py b/src/controller/mainController.py index 33ed12de..60750f07 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -218,6 +218,13 @@ class Controller(object): self.view.insert_buffer(tl.buffer, name=_(u"Search for {}".format(i)), pos=self.view.search("searches", session.db["user_name"])) tl.timer = RepeatingTimer(180, tl.start_stream) tl.timer.start() + 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() + 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"])) + timer = RepeatingTimer(300, buffer.start_stream) + timer.start() def search(self, *args, **kwargs): log.debug("Creating a new search...") @@ -306,7 +313,12 @@ class Controller(object): def exit(self, *args, **kwargs): if config.app["app-settings"]["ask_at_exit"] == True: answer = commonMessageDialogs.exit_dialog() - if answer == widgetUtils.NO: return + if answer == widgetUtils.YES: + self.exit_() + else: + self.exit_() + + def exit_(self): log.debug("Exiting...") log.debug("Saving global configuration...") config.app.write() @@ -480,6 +492,7 @@ class Controller(object): trends = trendingTopics.trendingTopicsController(buff.session) if trends.dialog.get_response() == widgetUtils.OK: 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) 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"])) diff --git a/src/wxUI/buffers/trends.py b/src/wxUI/buffers/trends.py index 9eb70a65..f3a6b6f5 100644 --- a/src/wxUI/buffers/trends.py +++ b/src/wxUI/buffers/trends.py @@ -22,3 +22,10 @@ class trendsPanel(wx.Panel): self.sizer.Add(btnSizer, 0, wx.ALL, 5) self.sizer.Add(self.list.list, 0, wx.ALL, 5) self.SetSizer(self.sizer) + + def set_position(self, reversed=False): + if reversed == False: + self.list.select_item(self.list.get_count()-1) + else: + self.list.select_item(0) + \ No newline at end of file