Commit 2fe58941 authored by Manuel Cortez's avatar Manuel Cortez

Added open in vk.com option in context menu for lots of items

parent 04f734be
Pipeline #259 passed with stages
in 3 minutes and 41 seconds
......@@ -5,8 +5,9 @@
* All spelling dictionaries are included by default for the following languages: Russian, English, German, French, italian, Polish, spanish and Turkish. Before, some dictionaries were missing and the spelling checker was failing.
* Improvements in the audio player module:
* When modifying volume of the playing audio, it will decrease or increase the volume by 2% instead of 5%.
* For users with multiple soundcards, there is a new tab in the preferences dialogue of Socializer, called sound. From there, you can define what soundcard will be used for input and output.
* 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.
* 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.
......
......@@ -224,10 +224,14 @@ class baseBuffer(object):
m.dislike.Enable(True)
if ("comments" in p) == False:
m.comment.Enable(False)
m.open_in_browser.Enable(False)
if "type" in p and p["type"] != "friend" and p["type"] != "audio" and p["type"] != "video" and p["type"] != "playlist":
m.open_in_browser.Enable(True)
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_post, menuitem=m.open)
widgetUtils.connect_event(m, widgetUtils.MENU, self.do_like, menuitem=m.like)
widgetUtils.connect_event(m, widgetUtils.MENU, self.do_dislike, menuitem=m.dislike)
widgetUtils.connect_event(m, widgetUtils.MENU, self.do_comment, menuitem=m.comment)
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_in_browser, menuitem=m.open_in_browser)
if hasattr(m, "view_profile"):
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_person_profile, menuitem=m.view_profile)
if hasattr(m, "delete"):
......@@ -383,6 +387,13 @@ class baseBuffer(object):
created_at = original_date.humanize(locale=languageHandler.curLang[:2])
self.tab.list.list.SetItem(self.tab.list.get_selected(), 2, created_at)
def open_in_browser(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
url = "https://vk.com/wall{user_id}_{post_id}".format(user_id=post["source_id"], post_id=post["post_id"])
webbrowser.open_new_tab(url)
class feedBuffer(baseBuffer):
""" This buffer represents an user's wall. It may be used either for the current user or someone else."""
......@@ -458,6 +469,13 @@ class feedBuffer(baseBuffer):
if hasattr(p, "text") or hasattr(p, "privacy"):
call_threaded(self.do_last, p=p, owner_id=owner_id)
def open_in_browser(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
url = "https://vk.com/wall{user_id}_{post_id}".format(user_id=post["from_id"], post_id=post["id"])
webbrowser.open_new_tab(url)
class communityBuffer(feedBuffer):
def create_tab(self, parent):
......@@ -504,6 +522,16 @@ class topicBuffer(feedBuffer):
return
a = presenters.displayTopicPresenter(session=self.session, postObject=post, group_id=self.kwargs["group_id"], interactor=interactors.displayPostInteractor(), view=views.displayTopic())
def open_in_browser(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
# In order to load the selected topic we firstly have to catch the group_id, which is present in self.kwargs
# After getting the group_id we should make it negative
group_id = self.kwargs["group_id"]*-1
url = "https://vk.com/topic{group_id}_{topic_id}".format(group_id=group_id, topic_id=post["id"])
webbrowser.open_new_tab(url)
class documentBuffer(feedBuffer):
can_get_items = False
......@@ -545,6 +573,7 @@ class documentBuffer(feedBuffer):
m = menus.documentMenu(added)
widgetUtils.connect_event(m, widgetUtils.MENU, self.add_remove_document, menuitem=m.action)
widgetUtils.connect_event(m, widgetUtils.MENU, self.download, menuitem=m.download)
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_in_browser, menuitem=m.open_in_browser)
return m
def add_remove_document(self, *args, **kwargs):
......@@ -571,6 +600,13 @@ class documentBuffer(feedBuffer):
if filepath != None:
pub.sendMessage("download-file", url=post["url"], filename=filepath)
def open_in_browser(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
url = "https://vk.com/doc{user_id}_{post_id}".format(user_id=post["owner_id"], post_id=post["id"])
webbrowser.open_new_tab(url)
class documentCommunityBuffer(documentBuffer):
can_get_items = True
......@@ -734,6 +770,13 @@ class audioBuffer(feedBuffer):
uploader = upload.VkUpload(self.session.vk.session_object)
call_threaded(uploader.audio, file, title=title, artist=artist)
def open_in_browser(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
url = "https://vk.com/audio{user_id}_{post_id}".format(user_id=post["owner_id"], post_id=post["id"])
webbrowser.open_new_tab(url)
class audioAlbum(audioBuffer):
""" this buffer was supposed to be used with audio albums
but is deprecated as VK removed its audio support for third party apps."""
......@@ -856,8 +899,6 @@ class videoBuffer(feedBuffer):
if p == None:
return
m = menus.audioMenu()
# widgetUtils.connect_event(m, widgetUtils.MENU, self.open_post, menuitem=m.open)
# widgetUtils.connect_event(m, widgetUtils.MENU, self.play_audio, menuitem=m.play)
widgetUtils.connect_event(m, widgetUtils.MENU, self.move_to_album, menuitem=m.move)
# if owner_id is the current user, the audio is added to the user's audios.
if p["owner_id"] == self.session.user_id:
......@@ -867,6 +908,13 @@ class videoBuffer(feedBuffer):
widgetUtils.connect_event(m, widgetUtils.MENU, self.add_to_library, menuitem=m.library)
return m
def open_in_browser(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
url = "https://vk.com/video{user_id}_{video_id}".format(user_id=post["owner_id"], video_id=post["id"])
webbrowser.open_new_tab(url)
class videoAlbum(videoBuffer):
def create_tab(self, parent):
......@@ -1188,6 +1236,11 @@ class chatBuffer(baseBuffer):
else:
return False
def open_in_browser(self, *args, **kwargs):
peer_id = self.kwargs["peer_id"]
url = "https://vk.com/im?sel={peer_id}".format(peer_id=peer_id)
webbrowser.open_new_tab(url)
class peopleBuffer(feedBuffer):
def create_tab(self, parent):
......@@ -1243,12 +1296,13 @@ class peopleBuffer(feedBuffer):
else:
m = menus.peopleMenu(is_request=False)
widgetUtils.connect_event(m, widgetUtils.MENU, self.decline_friendship, menuitem=m.decline)
# It is not allowed to send messages to people who is not your friends, so let's disable it if we're in a pending or outgoing requests folder.
# It is not allowed to send messages to people who is not your friends, so let's disable it if we're in a pending or outgoing requests buffer.
if "friend_requests" in self.name:
m.message.Enable(False)
widgetUtils.connect_event(m, widgetUtils.MENU, self.new_chat, menuitem=m.message)
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_timeline, menuitem=m.timeline)
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_person_profile, menuitem=m.view_profile)
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_in_browser, menuitem=m.open_in_browser)
return m
def open_post(self, *args, **kwargs): pass
......@@ -1338,6 +1392,13 @@ class peopleBuffer(feedBuffer):
log.exception("Removing an user from online status manually... %r" % (i))
self.remove_person(i["id"])
def open_in_browser(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
url = "https://vk.com/id{user_id}".format(user_id=post["id"])
webbrowser.open_new_tab(url)
class requestsBuffer(peopleBuffer):
def get_items(self, show_nextpage=False):
......
......@@ -862,7 +862,7 @@ class Controller(object):
elif current_buffer.name.endswith("_messages"):
menu = menus.conversationBufferMenu()
widgetUtils.connect_event(menu, widgetUtils.MENU, self.delete_conversation, menuitem=menu.delete)
widgetUtils.connect_event(menu, widgetUtils.MENU, current_buffer.open_in_browser, menuitem=menu.open_in_browser)
if menu != None:
self.window.PopupMenu(menu, self.window.FindFocus().GetPosition())
# If there are no available menus, let's indicate it.
......
......@@ -8,43 +8,28 @@ class postMenu(wx.Menu):
def __init__(self, can_delete=False, *args, **kwargs):
super(postMenu, self).__init__(*args, **kwargs)
self.open = wx.MenuItem(self, wx.NewId(), _("Open"))
self.Append(self.open)
self.like = wx.MenuItem(self, wx.NewId(), _("Like"))
self.Append(self.like)
self.dislike = wx.MenuItem(self, wx.NewId(), _("Dislike"))
self.open = self.Append(wx.NewId(), _("Open"))
self.like = self.Append(wx.NewId(), _("Like"))
self.dislike = self.Append(wx.NewId(), _("Dislike"))
self.dislike.Enable(False)
self.Append(self.dislike)
self.comment = wx.MenuItem(self, wx.NewId(), _("Add comment"))
self.Append(self.comment)
self.comment = self.Append(wx.NewId(), _("Add comment"))
if can_delete:
self.delete = wx.MenuItem(self, wx.NewId(), _("Delete"))
self.Append(self.delete)
self.delete = self.Append(wx.NewId(), _("Delete"))
else:
self.post_in_wall = wx.MenuItem(self, wx.NewId(), _("Post to this profile"))
self.post_in_wall = self.Append(wx.NewId(), _("Post to this profile"))
self.post_in_wall.Enable(False)
self.Append(self.post_in_wall)
self.view_profile = wx.MenuItem(self, wx.NewId(), _("View user profile"))
self.Append(self.view_profile)
def create_specific_post_options(self):
self.update = wx.MenuItem(self, wx.NewId(), _("Update"))
self.Append(self.update)
self.delete = wx.MenuItem(self, wx.NewId(), _("Delete"))
self.Append(self.delete)
self.view_profile = self.Append(wx.NewId(), _("View user profile"))
self.open_in_browser = self.Append(wx.NewId(), _("Open in vk.com"))
class audioMenu(wx.Menu):
def __init__(self, *args, **kwargs):
super(audioMenu, self).__init__(*args, **kwargs)
self.open = wx.MenuItem(self, wx.NewId(), _("&Open"))
self.Append(self.open)
self.play = wx.MenuItem(self, wx.NewId(), _("&Play"))
self.Append(self.play)
self.library = wx.MenuItem(self, wx.NewId(), _("&Add to library"))
self.Append(self.library)
self.move = wx.MenuItem(self, wx.NewId(), _("Move to album"))
self.Append(self.move)
self.open = self.Append(wx.NewId(), _("&Open"))
self.play = self.Append(wx.NewId(), _("&Play"))
self.library = self.Append(wx.NewId(), _("&Add to library"))
self.move = self.Append(wx.NewId(), _("Move to album"))
# 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):
......@@ -53,67 +38,45 @@ class peopleMenu(wx.Menu):
self.create_request_items()
elif is_subscriber:
self.create_subscriber_items()
self.view_profile = wx.MenuItem(self, wx.NewId(), _("View profile"))
self.Append(self.view_profile)
self.message = wx.MenuItem(self, wx.NewId(), _("Send a message"))
self.Append(self.message)
self.timeline = wx.MenuItem(self, wx.NewId(), _("Open timeline"))
self.Append(self.timeline)
self.common_friends = wx.MenuItem(self, wx.NewId(), _("View friends in common"))
self.Append(self.common_friends)
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:
self.decline = wx.MenuItem(self, wx.NewId(), _("Remove from friends"))
self.Append(self.decline)
self.decline = self.Append(wx.NewId(), _("Remove from friends"))
self.open_in_browser = self.Append(wx.NewId(), _("Open in vk.com"))
def create_request_items(self):
self.accept = wx.MenuItem(self, wx.NewId(), _("Accept"))
self.Append(self.accept)
self.decline = wx.MenuItem(self, wx.NewId(), _("Decline"))
self.Append(self.decline)
self.keep_as_follower = wx.MenuItem(self, wx.NewId(), _("Keep as follower"))
self.Append(self.keep_as_follower)
self.accept = self.Append(wx.NewId(), _("Accept"))
self.decline = self.Append(wx.NewId(), _("Decline"))
self.keep_as_follower = self.Append(wx.NewId(), _("Keep as follower"))
def create_subscriber_items(self):
self.add = wx.MenuItem(self, wx.NewId(), _("Add to friends"))
self.Append(self.add)
self.add = self.Append(wx.NewId(), _("Add to friends"))
class documentMenu(wx.Menu):
def __init__(self, added=False, *args, **kwargs):
super(documentMenu, self).__init__(*args, **kwargs)
# self.view_info = self.Append(wx.NewId(), _("View information"))
self.download = self.Append(wx.NewId(), _("Download document"))
if added == True:
self.action = self.Append(wx.NewId(), _("Remove from my documents"))
else:
self.action = self.Append(wx.NewId(), _("Add to my documents"))
self.open_in_browser = self.Append(wx.NewId(), _("Open in vk.com"))
class commentMenu(wx.Menu):
def __init__(self, *args, **kwargs):
super(commentMenu, self).__init__(*args, **kwargs)
self.open = wx.MenuItem(self, wx.NewId(), _("Open"))
self.Append(self.open)
self.like = wx.MenuItem(self, wx.NewId(), _("Like"))
self.Append(self.like)
self.unlike = wx.MenuItem(self, -1, _("Unlike"))
self.Append(self.unlike)
def create_specific_comment_options(self):
self.delete = wx.MenuItem(self, wx.NewId(), _("Delete"))
self.Append(self.delete)
class notificationsMenu(wx.Menu):
def __init__(self):
super(notificationsMenu, self).__init__()
self.mark_as_read = wx.MenuItem(self, wx.NewId(), _("Mark as read"))
self.Append(self.mark_as_read)
self.open = self.Append(wx.NewId(), _("Open"))
self.like = self.Append(wx.NewId(), _("Like"))
self.dislike = self.Append(wx.NewId(), _("Dislike"))
self.open_in_browser = self.Append(wx.NewId(), _("Open in vk.com"))
class attachMenu(wx.Menu):
def __init__(self):
super(attachMenu, self).__init__()
self.upload = wx.MenuItem(self, wx.NewId(), _("Upload from computer"))
self.Append(self.upload)
self.add = wx.MenuItem(self, wx.NewId(), _("Add from VK"))
self.Append(self.add)
self.upload = self.Append(wx.NewId(), _("Upload from computer"))
self.add = self.Append(wx.NewId(), _("Add from VK"))
class communityBufferMenu(wx.Menu):
def __init__(self):
......@@ -125,8 +88,10 @@ class communityBufferMenu(wx.Menu):
self.load_videos = load.Append(wx.NewId(), _("Load videos"))
self.load_documents = load.Append(wx.NewId(), _("Load documents"))
self.Append(wx.NewId(), _("Load"), load)
self.open_in_browser = self.Append(wx.NewId(), _("Open in vk.com"))
class conversationBufferMenu(wx.Menu):
def __init__(self):
super(conversationBufferMenu, self).__init__()
self.delete = self.Append(wx.NewId(), _("Delete conversation"))
\ No newline at end of file
self.delete = self.Append(wx.NewId(), _("Delete conversation"))
self.open_in_browser = self.Append(wx.NewId(), _("Open in vk.com"))
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment