Implemented buffed removal. Only works with audio searches at the moment

This commit is contained in:
Manuel Cortez 2016-03-27 00:11:52 -06:00
parent 6914756719
commit 6a3ddaa489
4 changed files with 39 additions and 13 deletions

View File

@ -5,10 +5,12 @@ import messages
import utils
import posts
import player
import output
from wxUI.tabs import home
from pubsub import pub
from sessionmanager import session
from mysc.thread_utils import call_threaded
from wxUI import commonMessages
class baseBuffer(object):
""" a basic representation of a buffer. Other buffers should be derived from this class"""
@ -117,6 +119,8 @@ class baseBuffer(object):
def pause_audio(self, *args, **kwargs):
player.player.pause()
def remove_buffer(self): return False
class feedBuffer(baseBuffer):
def get_items(self, show_nextpage=False):
@ -161,6 +165,19 @@ class audioBuffer(feedBuffer):
audios = [i for i in self.session.db[self.name]["items"][selected:]]
pub.sendMessage("play-audios", audios=audios)
def remove_buffer(self):
if "me_audio" == self.name or "popular_audio" == self.name or "recommended_audio" == self.name:
output.speak(_(u"This buffer can't be deleted"))
return False
else:
dlg = commonMessages.remove_buffer()
if dlg == widgetUtils.YES:
self.session.db.pop(self.name)
return True
else:
return False
class empty(object):
def __init__(self, name=None, parent=None, *args, **kwargs):
@ -172,3 +189,5 @@ class empty(object):
def update(self, *args, **kwargs):
pass
def remove_buffer(self): return False

View File

@ -78,6 +78,7 @@ class Controller(object):
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.check_for_updates, menuitem=self.window.check_for_updates)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.window.about_dialog, menuitem=self.window.about)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.search_audios, menuitem=self.window.search_audios)
widgetUtils.connect_event(self.window, widgetUtils.MENU,self.remove_buffer, menuitem=self.window.remove_buffer_)
def disconnect_events(self):
pub.unsubscribe(self.in_post, "posted")
@ -153,3 +154,13 @@ class Controller(object):
def update_status_bar(self, status):
self.window.change_status(status)
def remove_buffer(self, *args, **kwargs):
buffer = self.get_current_buffer()
buff = self.window.search(buffer.name)
answer = buffer.remove_buffer()
if answer == False:
return
self.window.remove_buffer(buff)
self.buffers.remove(buffer)
del buffer

View File

@ -7,3 +7,6 @@ def no_data_entered():
def no_update_available():
return wx.MessageDialog(None, _(u"Your {0} version is up to date").format(application.name,), _(u"Update"), style=wx.OK).ShowModal()
def remove_buffer():
return wx.MessageDialog(None, _(u"Do you really want to dismiss this buffer?"), _(u"Attention"), style=wx.ICON_QUESTION|wx.YES_NO).ShowModal()

View File

@ -12,6 +12,7 @@ class mainWindow(wx.Frame):
self.update_buffer = buffer.Append(wx.NewId(), _(u"Update current buffer"))
self.load_previous_items = buffer.Append(wx.NewId(), _(u"Load previous items"))
self.load_previous_items.Enable(False)
self.remove_buffer_ = buffer.Append(wx.NewId(), _(u"&Remove buffer"))
mb.Append(buffer, _(u"Buffer"))
help_ = wx.Menu()
self.about = help_.Append(wx.NewId(), _(u"About {0}").format(application.name,))
@ -84,13 +85,5 @@ class mainWindow(wx.Frame):
info.AddDeveloper(application.author)
wx.AboutBox(info)
def about_dialog(self, *args, **kwargs):
info = wx.AboutDialogInfo()
info.SetName(application.name)
info.SetVersion(application.version)
info.SetDescription(application.description)
info.SetCopyright(application.copyright)
# info.SetTranslators(application.translators)
# info.SetLicence(application.licence)
info.AddDeveloper(application.author)
wx.AboutBox(info)
def remove_buffer(self, pos):
self.tb.DeletePage(pos)