diff --git a/changelog.md b/changelog.md index 084083f..682aaed 100644 --- a/changelog.md +++ b/changelog.md @@ -14,8 +14,8 @@ * Included a brief manual in the help menu. Currently available only in English. * Included a context menu in list items. Currently there are functions not available. Menu for chat buffers is not implemented yet. * Implemented audio album load (in the music buffer), creation (in the application menu) and deletion (in the application menu, too). -* audios can be moved to albums by pressing the menu key or doing a right click in the item, and selecting "move to album". Audios will be added to the album in the next update (there is a programmed update in 3 minutes), or you can update the buffer manually (from the buffer menu in the menu bar). This option will be available in audio buffers (searches or audio buffers). - +* audios can be moved to albums by pressing the menu key or doing a right click in the item, and selecting "move to album". Audios will be added to the album in the next update (there is a programmed update every 3 minutes), or you can update the buffer manually (from the buffer menu in the menu bar). This option will be available in audio buffers (searches or audio timelines). +* Albums will be empty at startup. In order to get the album's audios, you'll have to navigate to the album and press the button "load". It'll load the needed information for displaying and playing the added songs ## Changes on build 2016.05.25 diff --git a/src/controller/buffers.py b/src/controller/buffers.py index 208ed65..cf115a9 100644 --- a/src/controller/buffers.py +++ b/src/controller/buffers.py @@ -45,6 +45,7 @@ class baseBuffer(object): self.connect_events() self.user_key = "source_id" self.post_key = "post_id" + self.can_get_items = True def create_tab(self, parent): """ Creates the Wx panel.""" @@ -59,6 +60,7 @@ class baseBuffer(object): """ Retrieves items from the VK API. This function is called repeatedly by the main controller and users could call it implicitly as well with the update buffer option. show_nextpage boolean: If it's true, it will try to load previous results. """ + if self.can_get_items == False: return retrieved = True # Control variable for handling unauthorised/connection errors. try: num = getattr(self.session, "get_newsfeed")(show_nextpage=show_nextpage, name=self.name, *self.args, **self.kwargs) @@ -256,6 +258,7 @@ class baseBuffer(object): class feedBuffer(baseBuffer): def get_items(self, show_nextpage=False): + if self.can_get_items == False: return retrieved = True try: num = getattr(self.session, "get_page")(show_nextpage=show_nextpage, name=self.name, *self.args, **self.kwargs) @@ -386,6 +389,22 @@ class audioBuffer(feedBuffer): widgetUtils.connect_event(m, widgetUtils.MENU, self.add_to_library, menuitem=m.library) return m +class audioAlbum(audioBuffer): + + def create_tab(self, parent): + self.tab = home.audioAlbumTab(parent) + + def connect_events(self): + super(audioAlbum, self).connect_events() + widgetUtils.connect_event(self.tab.load, widgetUtils.BUTTON_PRESSED, self.load_album) + + def load_album(self, *args, **kwargs): + output.speak(_(u"Loading album...")) + self.can_get_items = True + self.tab.load.Enable(False) + wx.CallAfter(self.get_items) + + class empty(object): def __init__(self, name=None, parent=None, *args, **kwargs): @@ -417,6 +436,7 @@ class chatBuffer(baseBuffer): self.tab.set_focus_function(self.onFocus) def get_items(self, show_nextpage=False): + if self.can_get_items == False: return retrieved = True # Control variable for handling unauthorised/connection errors. try: num = getattr(self.session, "get_messages")(name=self.name, *self.args, **self.kwargs) diff --git a/src/controller/mainController.py b/src/controller/mainController.py index ae2d2a1..7e9c48f 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -362,14 +362,14 @@ class Controller(object): albums = self.session.vk.client.audio.getAlbums(owner_id=user_id) self.session.audio_albums = albums["items"] for i in albums["items"]: - buffer = buffers.audioBuffer(parent=self.window.tb, name="{0}_audio_album".format(i["id"],), composefunc="compose_audio", session=self.session, endpoint="get", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"], user_id=user_id, album_id=i["id"]) + buffer = buffers.audioAlbum(parent=self.window.tb, name="{0}_audio_album".format(i["id"],), composefunc="compose_audio", session=self.session, endpoint="get", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"], user_id=user_id, album_id=i["id"]) + buffer.can_get_items = False # Translators: {0} Will be replaced with an audio album's title. name_ = _(u"Album: {0}").format(i["title"],) self.buffers.append(buffer) self.window.insert_buffer(buffer.tab, name_, self.window.search("albums")) buffer.get_items() # inserts a pause of 1 second here, so we'll avoid errors 6 in VK. - time.sleep(0.4) def create_audio_album(self, *args, **kwargs): d = creation.audio_album() @@ -377,7 +377,8 @@ class Controller(object): response = self.session.vk.client.audio.addAlbum(title=d.get("title")) if response.has_key("album_id") == False: return album_id = response["album_id"] - buffer = buffers.audioBuffer(parent=self.window.tb, name="{0}_audio_album".format(album_id,), composefunc="compose_audio", session=self.session, endpoint="get", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"], user_id=self.session.user_id, album_id=album_id) + buffer = buffers.audioAlbum(parent=self.window.tb, name="{0}_audio_album".format(album_id,), composefunc="compose_audio", session=self.session, endpoint="get", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"], user_id=self.session.user_id, album_id=album_id) + buffer.can_get_items = False # Translators: {0} will be replaced with an audio album's title. name_ = _(u"Album: {0}").format(d.get("title"),) self.buffers.append(buffer) diff --git a/src/wxUI/tabs/home.py b/src/wxUI/tabs/home.py index fbb9b00..95bdd75 100644 --- a/src/wxUI/tabs/home.py +++ b/src/wxUI/tabs/home.py @@ -70,6 +70,18 @@ class audioTab(homeTab): self.postBox.Add(self.play, 0, wx.ALL, 5) self.postBox.Add(self.play_all, 0, wx.ALL, 5) +class audioAlbumTab(audioTab): + + def create_post_buttons(self): + self.load = wx.Button(self, wx.NewId(), _(u"Load album")) + self.post = wx.Button(self, -1, _(u"&Post")) + self.play = wx.Button(self, -1, _(u"P&lay")) + self.play_all = wx.Button(self, -1, _(u"Play &All")) + self.postBox = wx.BoxSizer(wx.HORIZONTAL) + self.postBox.Add(self.post, 0, wx.ALL, 5) + self.postBox.Add(self.play, 0, wx.ALL, 5) + self.postBox.Add(self.play_all, 0, wx.ALL, 5) + class notificationsTab(homeTab): def __init__(self, parent): super(notificationsTab, self).__init__(parent=parent)