diff --git a/changelog.md b/changelog.md index b73101e..757d890 100644 --- a/changelog.md +++ b/changelog.md @@ -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. diff --git a/src/interactors/postDisplayer.py b/src/interactors/postDisplayer.py index decbdba..df5dae6 100644 --- a/src/interactors/postDisplayer.py +++ b/src/interactors/postDisplayer.py @@ -224,11 +224,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: + return + 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. + menu.message.Enable(False) + self.view.PopupMenu(menu, self.view.friends.list.GetPosition()) + + def on_view_profile(self, *args, **kwargs): + item = self.view.friends.get_selected() + self.presenter.view_profile(item) + + def on_open_in_browser(self, *args, **kwargs): + item = self.view.friends.get_selected() + self.presenter.open_in_browser(item) \ No newline at end of file diff --git a/src/presenters/postDisplayer.py b/src/presenters/postDisplayer.py index 4185136..0ead52b 100644 --- a/src/presenters/postDisplayer.py +++ b/src/presenters/postDisplayer.py @@ -780,13 +780,13 @@ class displayAudioPresenter(base.basePresenter): class displayFriendshipPresenter(base.basePresenter): - def __init__(self, session, postObject, view, interactor): + def __init__(self, session, postObject, view, interactor, caption=_("{user1_nom} added the following friends")): 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) self.set_friends_list(list_of_friends) self.run() @@ -796,4 +796,13 @@ class displayFriendshipPresenter(base.basePresenter): return [self.session.get_user(i["user_id"])["user1_nom"] for i in self.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] + pub.sendMessage("user-profile", person=user["user_id"]) + + def open_in_browser(self, item): + user = self.friends[item] + url = "https://vk.com/id{user_id}".format(user_id=user["user_id"]) + webbrowser.open_new_tab(url) \ No newline at end of file diff --git a/src/wxUI/menus.py b/src/wxUI/menus.py index 61b0edb..9dd52bf 100644 --- a/src/wxUI/menus.py +++ b/src/wxUI/menus.py @@ -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: self.create_request_items() @@ -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"))