Some posts and friendships are displayer by pressing return. This needs to be improved
This commit is contained in:
parent
df4f37b744
commit
068a67fbc8
@ -83,6 +83,16 @@ class baseBuffer(object):
|
|||||||
if post.has_key("type") and post["type"] == "audio":
|
if post.has_key("type") and post["type"] == "audio":
|
||||||
pub.sendMessage("play-audio", audio_object=post["audio"][1]["url"])
|
pub.sendMessage("play-audio", audio_object=post["audio"][1]["url"])
|
||||||
|
|
||||||
|
def open_post(self):
|
||||||
|
post = self.session.db[self.name]["items"][self.tab.list.get_selected()]
|
||||||
|
if post.has_key("type") and post["type"] == "audio":
|
||||||
|
a = posts.audio(self.session, post["audio"][1])
|
||||||
|
a.dialog.get_response()
|
||||||
|
elif post.has_key("type") and post["type"] == "friend":
|
||||||
|
pub.sendMessage("open-post", post_object=post, controller_="friendship")
|
||||||
|
else:
|
||||||
|
pub.sendMessage("open-post", post_object=post, controller_="postController")
|
||||||
|
|
||||||
class feedBuffer(baseBuffer):
|
class feedBuffer(baseBuffer):
|
||||||
|
|
||||||
def get_items(self, no_next=True):
|
def get_items(self, no_next=True):
|
||||||
|
@ -4,6 +4,7 @@ import widgetUtils
|
|||||||
import messages
|
import messages
|
||||||
import buffers
|
import buffers
|
||||||
import player
|
import player
|
||||||
|
import posts
|
||||||
from pubsub import pub
|
from pubsub import pub
|
||||||
from mysc.repeating_timer import RepeatingTimer
|
from mysc.repeating_timer import RepeatingTimer
|
||||||
from mysc.thread_utils import call_threaded
|
from mysc.thread_utils import call_threaded
|
||||||
@ -45,6 +46,7 @@ class Controller(object):
|
|||||||
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")
|
||||||
|
|
||||||
def login(self):
|
def login(self):
|
||||||
self.window.change_status(_(u"Logging in VK"))
|
self.window.change_status(_(u"Logging in VK"))
|
||||||
@ -73,3 +75,8 @@ class Controller(object):
|
|||||||
|
|
||||||
def play_audio(self, audio_object):
|
def play_audio(self, audio_object):
|
||||||
call_threaded(player.player.play, audio_object)
|
call_threaded(player.player.play, audio_object)
|
||||||
|
|
||||||
|
def view_post(self, post_object, controller_):
|
||||||
|
print controller_
|
||||||
|
p = getattr(posts, controller_)(self.session, post_object)
|
||||||
|
p.dialog.get_response()
|
@ -8,6 +8,7 @@ import output
|
|||||||
import wx
|
import wx
|
||||||
import webbrowser
|
import webbrowser
|
||||||
import utils
|
import utils
|
||||||
|
from sessionmanager import session # We'll use some functions from there
|
||||||
from pubsub import pub
|
from pubsub import pub
|
||||||
from wxUI.dialogs import postDialogs, urlList
|
from wxUI.dialogs import postDialogs, urlList
|
||||||
from extra import SpellChecker, translator
|
from extra import SpellChecker, translator
|
||||||
@ -21,34 +22,29 @@ class postController(object):
|
|||||||
self.post = postObject
|
self.post = postObject
|
||||||
self.dialog = postDialogs.post()
|
self.dialog = postDialogs.post()
|
||||||
self.dialog.comments.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.show_comment)
|
self.dialog.comments.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.show_comment)
|
||||||
from_ = self.session.get_user_name(self.post["from_id"])
|
|
||||||
# if self.post.has_key("owner_id"):
|
|
||||||
# to_ = [i["name"] for i in self.post["to"]["data"]]
|
|
||||||
# title = _(u"Post from {0} in {1}").format(from_, "".join(to_))
|
|
||||||
# else:
|
|
||||||
title = _(u"Post from {0}").format(from_,)
|
|
||||||
self.dialog.set_title(title)
|
|
||||||
message = story = u""
|
|
||||||
if self.post.has_key("message"):
|
|
||||||
message = self.post["message"]
|
|
||||||
if self.post.has_key("story"):
|
|
||||||
story = self.post["story"]
|
|
||||||
if self.post.has_key("name") and self.post.has_key("link"):
|
|
||||||
message += u". {0}, {1}".format(self.post["name"], self.post["link"])
|
|
||||||
if story != "":
|
|
||||||
final_msg = u"{0} \n\n{1}".format(story, message)
|
|
||||||
else:
|
|
||||||
final_msg = message
|
|
||||||
self.dialog.set_post(final_msg)
|
|
||||||
# widgetUtils.connect_event(self.message.spellcheck, widgetUtils.BUTTON_PRESSED, self.spellcheck)
|
# widgetUtils.connect_event(self.message.spellcheck, widgetUtils.BUTTON_PRESSED, self.spellcheck)
|
||||||
# widgetUtils.connect_event(self.message.translateButton, widgetUtils.BUTTON_PRESSED, self.translate)
|
# widgetUtils.connect_event(self.message.translateButton, widgetUtils.BUTTON_PRESSED, self.translate)
|
||||||
# self.text_processor()
|
|
||||||
widgetUtils.connect_event(self.dialog.like, widgetUtils.BUTTON_PRESSED, self.post_like)
|
widgetUtils.connect_event(self.dialog.like, widgetUtils.BUTTON_PRESSED, self.post_like)
|
||||||
widgetUtils.connect_event(self.dialog.comment, widgetUtils.BUTTON_PRESSED, self.add_comment)
|
widgetUtils.connect_event(self.dialog.comment, widgetUtils.BUTTON_PRESSED, self.add_comment)
|
||||||
widgetUtils.connect_event(self.dialog.tools, widgetUtils.BUTTON_PRESSED, self.show_tools_menu)
|
widgetUtils.connect_event(self.dialog.tools, widgetUtils.BUTTON_PRESSED, self.show_tools_menu)
|
||||||
self.dialog.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.show_menu, self.dialog.comments.list)
|
self.dialog.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.show_menu, self.dialog.comments.list)
|
||||||
self.dialog.Bind(wx.EVT_LIST_KEY_DOWN, self.show_menu_by_key, self.dialog.comments.list)
|
self.dialog.Bind(wx.EVT_LIST_KEY_DOWN, self.show_menu_by_key, self.dialog.comments.list)
|
||||||
call_threaded(self.load_all_components)
|
# call_threaded(self.load_all_components)
|
||||||
|
self.get_post_information()
|
||||||
|
|
||||||
|
def get_post_information(self):
|
||||||
|
if self.post.has_key("type"):
|
||||||
|
if self.post["type"] == "post":
|
||||||
|
from_ = self.session.get_user_name(self.post["source_id"])
|
||||||
|
title = _(u"Post from {0}").format(from_,)
|
||||||
|
self.dialog.set_title(title)
|
||||||
|
message = u""
|
||||||
|
if self.post.has_key("text"):
|
||||||
|
message = self.post["text"]
|
||||||
|
if self.post.has_key("attachment"):
|
||||||
|
print self.post["attachment"].keys()
|
||||||
|
message = message+session.add_attachment(self.post["attachment"])
|
||||||
|
self.dialog.set_post(message)
|
||||||
|
|
||||||
def load_all_components(self):
|
def load_all_components(self):
|
||||||
self.get_likes()
|
self.get_likes()
|
||||||
@ -220,3 +216,23 @@ class audio(postController):
|
|||||||
|
|
||||||
def play(self, *args, **kwargs):
|
def play(self, *args, **kwargs):
|
||||||
pub.sendMessage("play-audio", audio_object=self.post["url"])
|
pub.sendMessage("play-audio", audio_object=self.post["url"])
|
||||||
|
|
||||||
|
class friendship(object):
|
||||||
|
|
||||||
|
def __init__(self, session, post):
|
||||||
|
self.session = session
|
||||||
|
self.post = post
|
||||||
|
self.dialog = postDialogs.friendship()
|
||||||
|
list_of_friends = self.get_friend_names()
|
||||||
|
from_ = self.session.get_user_name(self.post["source_id"])
|
||||||
|
title = _(u"{0} added the following friends").format(from_,)
|
||||||
|
self.dialog.set_title(title)
|
||||||
|
self.set_friends_list(list_of_friends)
|
||||||
|
|
||||||
|
def get_friend_names(self):
|
||||||
|
self.friends = self.post["friends"][1:]
|
||||||
|
return [self.session.get_user_name(i["uid"]) for i in self.friends]
|
||||||
|
|
||||||
|
def set_friends_list(self, friendslist):
|
||||||
|
for i in friendslist:
|
||||||
|
self.dialog.friends.insert_item(False, *[i])
|
||||||
|
@ -144,4 +144,18 @@ class audio(widgetUtils.BaseDialog):
|
|||||||
saveFileDialog = wx.FileDialog(self, _(u"Save this file"), "", filename, _(u"Audio Files(*.mp3)|*.mp3"), wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
|
saveFileDialog = wx.FileDialog(self, _(u"Save this file"), "", filename, _(u"Audio Files(*.mp3)|*.mp3"), wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
|
||||||
if saveFileDialog.ShowModal() == wx.ID_OK:
|
if saveFileDialog.ShowModal() == wx.ID_OK:
|
||||||
return saveFileDialog.GetPath()
|
return saveFileDialog.GetPath()
|
||||||
saveFileDialog.Destroy()
|
saveFileDialog.Destroy()
|
||||||
|
|
||||||
|
class friendship(widgetUtils.BaseDialog):
|
||||||
|
def __init__(self):
|
||||||
|
super(friendship, self).__init__(parent=None)
|
||||||
|
panel = wx.Panel(self)
|
||||||
|
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||||
|
self.friends = widgetUtils.list(panel, [_(u"Friend")], style=wx.LC_REPORT)
|
||||||
|
sizer.Add(self.friends.list, 0, wx.ALL, 5)
|
||||||
|
close = wx.Button(panel, wx.ID_CANCEL)
|
||||||
|
btnbox = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
|
btnbox.Add(close, 0, wx.ALL, 5)
|
||||||
|
sizer.Add(btnbox, 0, wx.ALL, 5)
|
||||||
|
panel.SetSizer(sizer)
|
||||||
|
self.SetClientSize(sizer.CalcMin())
|
Loading…
Reference in New Issue
Block a user