Connected the exit function for cleaning stuff

This commit is contained in:
Manuel Cortez 2016-02-23 05:48:05 -06:00
parent 776c8338f3
commit 3e0941bb8f
2 changed files with 20 additions and 4 deletions

View File

@ -53,6 +53,7 @@ class baseBuffer(object):
msg = msg.replace(urls[0], "") msg = msg.replace(urls[0], "")
self.session.post_wall_status(message=msg, friends_only=privacy_opts, attachments=attachments) self.session.post_wall_status(message=msg, friends_only=privacy_opts, attachments=attachments)
pub.sendMessage("posted", buffer=self.name) pub.sendMessage("posted", buffer=self.name)
p.message.Destroy()
def connect_events(self): def connect_events(self):
widgetUtils.connect_event(self.tab.post, widgetUtils.BUTTON_PRESSED, self.post) widgetUtils.connect_event(self.tab.post, widgetUtils.BUTTON_PRESSED, self.post)
@ -89,6 +90,7 @@ class baseBuffer(object):
if post.has_key("type") and post["type"] == "audio": if post.has_key("type") and post["type"] == "audio":
a = posts.audio(self.session, post["audio"][1]) a = posts.audio(self.session, post["audio"][1])
a.dialog.get_response() a.dialog.get_response()
a.dialog.Destroy()
elif post.has_key("type") and post["type"] == "friend": elif post.has_key("type") and post["type"] == "friend":
pub.sendMessage("open-post", post_object=post, controller_="friendship") pub.sendMessage("open-post", post_object=post, controller_="friendship")
else: else:
@ -126,4 +128,4 @@ class audioBuffer(feedBuffer):
selected = self.tab.list.get_selected() selected = self.tab.list.get_selected()
a = posts.audio(self.session, self.session.db[self.name]["items"][selected]) a = posts.audio(self.session, self.session.db[self.name]["items"][selected])
a.dialog.get_response() a.dialog.get_response()
a.dialog.Destroy()

View File

@ -26,9 +26,9 @@ class Controller(object):
self.window = mainWindow.mainWindow() self.window = mainWindow.mainWindow()
self.window.change_status(_(u"Ready")) self.window.change_status(_(u"Ready"))
self.session = session.sessions[session.sessions.keys()[0]] self.session = session.sessions[session.sessions.keys()[0]]
# self.session.authorise()
self.create_controls() self.create_controls()
self.window.Show() self.window.Show()
self.connect_events()
def create_controls(self): def create_controls(self):
home = buffers.baseBuffer(parent=self.window.tb, name="home_timeline", session=self.session, composefunc="compose_new", endpoint="newsfeed", identifier="id") home = buffers.baseBuffer(parent=self.window.tb, name="home_timeline", session=self.session, composefunc="compose_new", endpoint="newsfeed", identifier="id")
@ -36,17 +36,25 @@ class Controller(object):
self.window.add_buffer(home.tab, _(u"Home")) self.window.add_buffer(home.tab, _(u"Home"))
self.repeatedUpdate = RepeatingTimer(180, self.update_all_buffers) self.repeatedUpdate = RepeatingTimer(180, self.update_all_buffers)
self.repeatedUpdate.start() self.repeatedUpdate.start()
feed = buffers.feedBuffer(parent=self.window.tb, name="me_feed", composefunc="compose_status", session=self.session, endpoint="get", parent_endpoint="wall", identifier="id") feed = buffers.feedBuffer(parent=self.window.tb, name="me_feed", composefunc="compose_status", session=self.session, endpoint="get", parent_endpoint="wall", identifier="id")
self.buffers.append(feed) self.buffers.append(feed)
self.window.add_buffer(feed.tab, _(u"My wall")) self.window.add_buffer(feed.tab, _(u"My wall"))
audio = buffers.audioBuffer(parent=self.window.tb, name="me_audio", composefunc="compose_audio", session=self.session, endpoint="get", parent_endpoint="audio", full_list=True, identifier="aid") audio = buffers.audioBuffer(parent=self.window.tb, name="me_audio", composefunc="compose_audio", session=self.session, endpoint="get", parent_endpoint="audio", full_list=True, identifier="aid")
self.buffers.append(audio) self.buffers.append(audio)
self.window.add_buffer(audio.tab, _(u"My audios")) self.window.add_buffer(audio.tab, _(u"My audios"))
def connect_events(self):
pub.subscribe(self.in_post, "posted") pub.subscribe(self.in_post, "posted")
pub.subscribe(self.download, "download-file") pub.subscribe(self.download, "download-file")
pub.subscribe(self.play_audio, "play-audio") pub.subscribe(self.play_audio, "play-audio")
pub.subscribe(self.view_post, "open-post") pub.subscribe(self.view_post, "open-post")
widgetUtils.connect_event(self.window, widgetUtils.CLOSE_EVENT, self.exit)
def disconnect_events(self):
pub.unsubscribe(self.in_post, "posted")
pub.unsubscribe(self.download, "download-file")
pub.unsubscribe(self.play_audio, "play-audio")
pub.unsubscribe(self.view_post, "open-post")
def login(self): def login(self):
self.window.change_status(_(u"Logging in VK")) self.window.change_status(_(u"Logging in VK"))
@ -80,3 +88,9 @@ class Controller(object):
print controller_ print controller_
p = getattr(posts, controller_)(self.session, post_object) p = getattr(posts, controller_)(self.session, post_object)
p.dialog.get_response() p.dialog.get_response()
p.dialog.Destroy()
def exit(self, *args, **kwargs):
self.disconnect_events()
self.window.Destroy()
# wx.GetApp().ExitMainloop()