Added timeline creation from the context menu in people buffers

This commit is contained in:
Manuel Cortez 2019-05-29 17:51:37 -05:00
parent 8ec7fbb49e
commit 4810cbe138
3 changed files with 34 additions and 20 deletions

View File

@ -7,6 +7,7 @@
* Added "post in groups" feature. In order to do so, you need to load the posts for the group where you want to send something. Once loaded, go to the post button in the group's wall and select whether you want to post in the group's behalf or as yourself. * Added "post in groups" feature. In order to do so, you need to load the posts for the group where you want to send something. Once loaded, go to the post button in the group's wall and select whether you want to post in the group's behalf or as yourself.
* In all audio buffers, it is possible to select individual tracks to be played together. In order to do so, you need to press space to start the selection of items. When selected, the item will emit a sound to indicate the change. Press space in all items you want to select/unselect. When you're focusing an already selected item it will play a sound to indicate that it is already selected. Once you're done with your selection, pressing enter in the list of tracks will start the playback of the list of items you have selected. This is a very experimental feature. More actions can be supported based in this selection method if it proves to be useful. * In all audio buffers, it is possible to select individual tracks to be played together. In order to do so, you need to press space to start the selection of items. When selected, the item will emit a sound to indicate the change. Press space in all items you want to select/unselect. When you're focusing an already selected item it will play a sound to indicate that it is already selected. Once you're done with your selection, pressing enter in the list of tracks will start the playback of the list of items you have selected. This is a very experimental feature. More actions can be supported based in this selection method if it proves to be useful.
* In conversation buffers, it is possible to display and open wall posts sent as attachments in messages. * In conversation buffers, it is possible to display and open wall posts sent as attachments in messages.
* In people buffers, it is possible to create a new timeline by using the context menu while focusing an user. This method will create the buffer for the selected user, as opposed to creating the buffer from the menu bar, where you have to type the username or find it in a list.
### bugfixes ### bugfixes

View File

@ -19,6 +19,7 @@ from requests.exceptions import ReadTimeout, ConnectionError
from mutagen.id3 import ID3 from mutagen.id3 import ID3
from presenters import player from presenters import player
from wxUI.tabs import home from wxUI.tabs import home
from wxUI.dialogs import timeline
from sessionmanager import session, renderers, utils from sessionmanager import session, renderers, utils
from mysc.thread_utils import call_threaded from mysc.thread_utils import call_threaded
from wxUI import commonMessages, menus from wxUI import commonMessages, menus
@ -1366,7 +1367,14 @@ class peopleBuffer(feedBuffer):
self.tab.list.list.SetItem(self.tab.list.get_selected(), 1, online_status) self.tab.list.list.SetItem(self.tab.list.get_selected(), 1, online_status)
def open_timeline(self, *args, **kwargs): def open_timeline(self, *args, **kwargs):
pass user = self.get_post()
if user == None:
return
a = timeline.timelineDialog([self.session.get_user(user["id"])["user1_gen"]], show_selector=False)
if a.get_response() == widgetUtils.OK:
buffer_type = a.get_buffer_type()
user_id = user["id"]
pub.sendMessage("create-timeline", user_id=user_id, buffer_type=buffer_type)
def get_menu(self, *args, **kwargs): def get_menu(self, *args, **kwargs):
""" display menu for people buffers (friends and requests)""" """ display menu for people buffers (friends and requests)"""

View File

@ -297,6 +297,7 @@ class Controller(object):
pub.subscribe(self.create_buffer, "create_buffer") pub.subscribe(self.create_buffer, "create_buffer")
pub.subscribe(self.user_typing, "user-typing") pub.subscribe(self.user_typing, "user-typing")
pub.subscribe(self.get_chat, "order-sent-message") pub.subscribe(self.get_chat, "order-sent-message")
pub.subscribe(self.create_timeline, "create-timeline")
def disconnect_events(self): def disconnect_events(self):
log.debug("Disconnecting some events...") log.debug("Disconnecting some events...")
@ -308,6 +309,7 @@ class Controller(object):
pub.unsubscribe(self.user_online, "user-online") pub.unsubscribe(self.user_online, "user-online")
pub.unsubscribe(self.user_offline, "user-offline") pub.unsubscribe(self.user_offline, "user-offline")
pub.unsubscribe(self.notify, "notify") pub.unsubscribe(self.notify, "notify")
pub.subscribe(self.create_timeline, "create-timeline")
def in_post(self, buffer): def in_post(self, buffer):
""" This event is triggered whenever an user requires an update in their buffers. For example after sending a post successfully. """ This event is triggered whenever an user requires an update in their buffers. For example after sending a post successfully.
@ -518,6 +520,27 @@ class Controller(object):
rendered_message = renderers.render_message(message, self.session) rendered_message = renderers.render_message(message, self.session)
output.speak(rendered_message[0]) output.speak(rendered_message[0])
def create_timeline(self, user_id, buffer_type, user=""):
if user_id == "":
user_data = self.session.vk.client.utils.resolveScreenName(screen_name=user)
if type(user_data) == list:
commonMessages.no_user_exist()
return
user_id = user_data["object_id"]
if buffer_type == "audio":
buffer = buffers.audioBuffer(parent=self.window.tb, name="{0}_audio".format(user_id,), composefunc="render_audio", session=self.session, create_tab=False, endpoint="get", parent_endpoint="audio", owner_id=user_id)
user = self.session.get_user(user_id, key="user1")
name_ = _("{user1_nom}'s audios").format(**user)
elif buffer_type == "wall":
buffer = buffers.feedBuffer(parent=self.window.tb, name="{0}_feed".format(user_id,), composefunc="render_status", session=self.session, create_tab=False, endpoint="get", parent_endpoint="wall", extended=1, count=self.session.settings["buffers"]["count_for_wall_buffers"], owner_id=user_id)
user = self.session.get_user(user_id, key="user1")
name_ = _("{user1_nom}'s posts").format(**user)
elif buffer_type == "friends":
buffer = buffers.peopleBuffer(parent=self.window.tb, name="friends_{0}".format(user_id,), composefunc="render_person", session=self.session, create_tab=False, endpoint="get", parent_endpoint="friends", count=5000, fields="uid, first_name, last_name, last_seen", user_id=user_id)
user = self.session.get_user(user_id, key="user1")
name_ = _("{user1_nom}'s friends").format(**user)
wx.CallAfter(self.complete_buffer_creation, buffer=buffer, name_=name_, position=self.window.search("timelines"))
### GUI events ### GUI events
# These functions are connected to GUI elements such as menus, buttons and so on. # These functions are connected to GUI elements such as menus, buttons and so on.
def connect_gui_events(self): def connect_gui_events(self):
@ -657,25 +680,7 @@ class Controller(object):
for i in d: for i in d:
if i[1] == user: if i[1] == user:
user_id = i[0] user_id = i[0]
if user_id == "": pub.sendMessage("create-timeline", user_id=user_id, buffer_type=buffertype)
user_data = self.session.vk.client.utils.resolveScreenName(screen_name=user)
if type(user_data) == list:
commonMessages.no_user_exist()
return
user_id = user_data["object_id"]
if buffertype == "audio":
buffer = buffers.audioBuffer(parent=self.window.tb, name="{0}_audio".format(user_id,), composefunc="render_audio", session=self.session, create_tab=False, endpoint="get", parent_endpoint="audio", owner_id=user_id)
user = self.session.get_user(user_id, key="user1")
name_ = _("{user1_nom}'s audios").format(**user)
elif buffertype == "wall":
buffer = buffers.feedBuffer(parent=self.window.tb, name="{0}_feed".format(user_id,), composefunc="render_status", session=self.session, create_tab=False, endpoint="get", parent_endpoint="wall", extended=1, count=self.session.settings["buffers"]["count_for_wall_buffers"], owner_id=user_id)
user = self.session.get_user(user_id, key="user1")
name_ = _("{user1_nom}'s posts").format(**user)
elif buffertype == "friends":
buffer = buffers.peopleBuffer(parent=self.window.tb, name="friends_{0}".format(user_id,), composefunc="render_person", session=self.session, create_tab=False, endpoint="get", parent_endpoint="friends", count=5000, fields="uid, first_name, last_name, last_seen", user_id=user_id)
user = self.session.get_user(user_id, key="user1")
name_ = _("{user1_nom}'s friends").format(**user)
wx.CallAfter(self.complete_buffer_creation, buffer=buffer, name_=name_, position=self.window.search("timelines"))
def create_audio_album(self, *args, **kwargs): def create_audio_album(self, *args, **kwargs):
d = creation.audio_album() d = creation.audio_album()