......@@ -8,6 +8,7 @@
* For users with multiple soundcards, there is a new tab in the preferences dialogue of Socializer, called sound. From there, you can define which soundcard will be used for input and output.
* it is possible to select the language used in socializer from the preferences dialog. When changing the language, the application must be restarted for the changes to take effect.
* A new option, called open in vk.com, has been added in the context menu for almost all objects (items in home timeline, walls, documents, people, group topics and in buffers for conversations). This option will open the selected item in the VK website.
* when opening the list of friends added by an user, you can display the context menu from an item on the list and view the user profile, open it in VK.com among other actions.
* Improvements in conversation buffers:
* it is possible to retrieve more items for conversation buffers. Due to API limitations, it is possible to load up to the last 600 messages for every conversation. Take into account that the process of loading more items takes some time. You will hear a message when the process is done.
* It is possible to delete entire conversations from the buffer's tree, by using the menu key and selecting "delete conversation". The conversation will be removed from VK.
......@@ -355,7 +355,7 @@ class baseBuffer(object):
if "type" in post and post["type"] == "audio":
a = presenters.displayAudioPresenter(session=self.session, postObject=post["audio"]["items"], interactor=interactors.displayAudioInteractor(), view=views.displayAudio())
elif "type" in post and post["type"] == "friend":
pub.sendMessage("open-post", post_object=post, controller_="displayFriendship")
pub.sendMessage("open-post", post_object=post, controller_="displayFriendship", vars=dict(caption=_("{user1_nom} added the following friends")))
pub.sendMessage("open-post", post_object=post, controller_="displayPost")
......@@ -327,12 +327,12 @@ class Controller(object):
log.debug("downloading %s URL to %s filename" % (url, filename,))
call_threaded(utils.download_file, url, filename, self.window)
def view_post(self, post_object, controller_):
def view_post(self, post_object, controller_, vars=dict()):
""" Display the passed post in the passed post presenter.
@ post_object dict: A post representation returned by the VK api. The fields present in this dict are different depending on the presenter used to render it.
@controller_ string: Name of the post controller, this name will be used for calling interactors, views and presenters. For example, displayPost, displayAudio, etc.
p = getattr(presenters, controller_+"Presenter")(session=self.session, postObject=post_object, interactor=getattr(interactors, controller_+"Interactor")(), view=getattr(views, controller_)())
p = getattr(presenters, controller_+"Presenter")(session=self.session, postObject=post_object, interactor=getattr(interactors, controller_+"Interactor")(), view=getattr(views, controller_)(), **vars)
def update_status_bar(self, status):
""" Update the status bar present in the main Window.
......@@ -50,6 +50,8 @@ class displayPostInteractor(base.baseInteractor):
widgetUtils.connect_event(self.view.like, widgetUtils.BUTTON_PRESSED, self.on_like)
widgetUtils.connect_event(self.view.comment, widgetUtils.BUTTON_PRESSED, self.on_add_comment)
widgetUtils.connect_event(self.view.tools, widgetUtils.BUTTON_PRESSED, self.on_show_tools_menu)
if hasattr(self.view, "likes"):
widgetUtils.connect_event(self.view.likes, widgetUtils.BUTTON_PRESSED, self.on_show_likes_menu)
if hasattr(self.view, "repost"):
widgetUtils.connect_event(self.view.repost, widgetUtils.BUTTON_PRESSED, self.on_repost)
self.view.comments.list.Bind(wx.EVT_LIST_ITEM_FOCUSED, self.on_focus)
......@@ -134,6 +136,9 @@ class displayPostInteractor(base.baseInteractor):
comment = self.view.comments.get_selected()
def on_show_likes_menu(self, *args, **kwargs):
class displayAudioInteractor(base.baseInteractor):
def set(self, control, value):
......@@ -224,11 +229,30 @@ class displayFriendshipInteractor(base.baseInteractor):
for i in items:
getattr(self.view, control).insert_item(False, *[i])
def install(self, *args, **kwargs):
super(displayFriendshipInteractor, self).install(*args, **kwargs)
pub.subscribe(self.add_items, self.modulename+"_add_items")
self.view.friends.list.Bind(wx.EVT_CONTEXT_MENU, self.on_context_menu)
def uninstall(self):
super(displayFriendshipInteractor, self).uninstall()
pub.unsubscribe(self.add_items, self.modulename+"_add_items")
\ No newline at end of file
pub.unsubscribe(self.add_items, self.modulename+"_add_items")
def on_context_menu(self, *args, **kwargs):
item = self.view.friends.get_selected()
if item < 0:
menu = menus.peopleMenu(False, False, True)
widgetUtils.connect_event(menu, widgetUtils.MENU, self.on_view_profile, menuitem=menu.view_profile)
widgetUtils.connect_event(menu, widgetUtils.MENU, self.on_open_in_browser, menuitem=menu.open_in_browser)
# Generally message sending is blocked.
self.view.PopupMenu(menu, self.view.friends.list.GetPosition())
def on_view_profile(self, *args, **kwargs):
item = self.view.friends.get_selected()
def on_open_in_browser(self, *args, **kwargs):
item = self.view.friends.get_selected()
\ No newline at end of file
......@@ -417,6 +417,14 @@ class displayPostPresenter(base.basePresenter):
self.send_message("clean_list", list="comments")
def show_likes(self):
""" show likes for the specified post."""
data = dict(type="post", owner_id=self.post[self.user_identifier], item_id=self.post["id"], extended=True, count=1000, skip_own=True)
result = self.session.vk.client.likes.getList(**data)
if result["count"] > 0:
post = {"source_id": self.post[self.user_identifier], "friends": {"items": result["items"]}}
pub.sendMessage("open-post", post_object=post, controller_="displayFriendship", vars=dict(caption=_("people who liked this")))
class displayCommentPresenter(displayPostPresenter):
def __init__(self, session, postObject, view, interactor):
......@@ -780,20 +788,43 @@ class displayAudioPresenter(base.basePresenter):
class displayFriendshipPresenter(base.basePresenter):
def __init__(self, session, postObject, view, interactor):
def __init__(self, session, postObject, view, interactor, caption=""):
self.session = session
self.post = postObject
super(displayFriendshipPresenter, self).__init__(view=view, interactor=interactor, modulename="display_friendship")
list_of_friends = self.get_friend_names()
from_ = self.session.get_user(self.post["source_id"])
title = _("{user1_nom} added the following friends").format(**from_)
title = caption.format(**from_)
self.send_message("set_title", value=title)
def get_friend_names(self):
self.friends = self.post["friends"]["items"]
return [self.session.get_user(i["user_id"])["user1_nom"] for i in self.friends]
friends = list()
for i in self.friends:
if "user_id" in i:
return friends
def set_friends_list(self, friendslist):
self.send_message("add_items", control="friends", items=friendslist)
\ No newline at end of file
self.send_message("add_items", control="friends", items=friendslist)
def view_profile(self, item):
user = self.friends[item]
if "user_id" in user:
id = user["user_id"]
id = user["id"]
pub.sendMessage("user-profile", person=id)
def open_in_browser(self, item):
user = self.friends[item]
if "user_id" in user:
id = user["user_id"]
id = user["id"]
url = "https://vk.com/id{user_id}".format(user_id=id)
\ No newline at end of file
......@@ -32,7 +32,7 @@ class audioMenu(wx.Menu):
# self.open_in_browser = self.Append(wx.NewId(), _("Open in vk.com"))
class peopleMenu(wx.Menu):
def __init__(self, is_request=False, is_subscriber=False, *args, **kwargs):
def __init__(self, is_request=False, is_subscriber=False, not_friend=False, *args, **kwargs):
super(peopleMenu, self).__init__(*args, **kwargs)
if is_request:
......@@ -41,8 +41,9 @@ class peopleMenu(wx.Menu):
self.view_profile = self.Append(wx.NewId(), _("View profile"))
self.message = self.Append(wx.NewId(), _("Send a message"))
self.timeline = self.Append(wx.NewId(), _("Open timeline"))
self.common_friends = self.Append(wx.NewId(), _("View friends in common"))
if is_request == False and is_subscriber == False:
if not_friend == False:
self.common_friends = self.Append(wx.NewId(), _("View friends in common"))
if is_request == False and is_subscriber == False and not_friend == False:
self.decline = self.Append(wx.NewId(), _("Remove from friends"))
self.open_in_browser = self.Append(wx.NewId(), _("Open in vk.com"))