Implemented buffed removal. Only works with audio searches at the moment
This commit is contained in:
parent
6914756719
commit
6a3ddaa489
@ -5,10 +5,12 @@ import messages
|
|||||||
import utils
|
import utils
|
||||||
import posts
|
import posts
|
||||||
import player
|
import player
|
||||||
|
import output
|
||||||
from wxUI.tabs import home
|
from wxUI.tabs import home
|
||||||
from pubsub import pub
|
from pubsub import pub
|
||||||
from sessionmanager import session
|
from sessionmanager import session
|
||||||
from mysc.thread_utils import call_threaded
|
from mysc.thread_utils import call_threaded
|
||||||
|
from wxUI import commonMessages
|
||||||
|
|
||||||
class baseBuffer(object):
|
class baseBuffer(object):
|
||||||
""" a basic representation of a buffer. Other buffers should be derived from this class"""
|
""" 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):
|
def pause_audio(self, *args, **kwargs):
|
||||||
player.player.pause()
|
player.player.pause()
|
||||||
|
|
||||||
|
def remove_buffer(self): return False
|
||||||
|
|
||||||
class feedBuffer(baseBuffer):
|
class feedBuffer(baseBuffer):
|
||||||
|
|
||||||
def get_items(self, show_nextpage=False):
|
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:]]
|
audios = [i for i in self.session.db[self.name]["items"][selected:]]
|
||||||
pub.sendMessage("play-audios", audios=audios)
|
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):
|
class empty(object):
|
||||||
|
|
||||||
def __init__(self, name=None, parent=None, *args, **kwargs):
|
def __init__(self, name=None, parent=None, *args, **kwargs):
|
||||||
@ -172,3 +189,5 @@ class empty(object):
|
|||||||
|
|
||||||
def update(self, *args, **kwargs):
|
def update(self, *args, **kwargs):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def remove_buffer(self): return False
|
||||||
|
@ -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.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.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.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):
|
def disconnect_events(self):
|
||||||
pub.unsubscribe(self.in_post, "posted")
|
pub.unsubscribe(self.in_post, "posted")
|
||||||
@ -153,3 +154,13 @@ class Controller(object):
|
|||||||
|
|
||||||
def update_status_bar(self, status):
|
def update_status_bar(self, status):
|
||||||
self.window.change_status(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
|
@ -7,3 +7,6 @@ def no_data_entered():
|
|||||||
|
|
||||||
def no_update_available():
|
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()
|
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()
|
@ -12,6 +12,7 @@ class mainWindow(wx.Frame):
|
|||||||
self.update_buffer = buffer.Append(wx.NewId(), _(u"Update current buffer"))
|
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 = buffer.Append(wx.NewId(), _(u"Load previous items"))
|
||||||
self.load_previous_items.Enable(False)
|
self.load_previous_items.Enable(False)
|
||||||
|
self.remove_buffer_ = buffer.Append(wx.NewId(), _(u"&Remove buffer"))
|
||||||
mb.Append(buffer, _(u"Buffer"))
|
mb.Append(buffer, _(u"Buffer"))
|
||||||
help_ = wx.Menu()
|
help_ = wx.Menu()
|
||||||
self.about = help_.Append(wx.NewId(), _(u"About {0}").format(application.name,))
|
self.about = help_.Append(wx.NewId(), _(u"About {0}").format(application.name,))
|
||||||
@ -84,13 +85,5 @@ class mainWindow(wx.Frame):
|
|||||||
info.AddDeveloper(application.author)
|
info.AddDeveloper(application.author)
|
||||||
wx.AboutBox(info)
|
wx.AboutBox(info)
|
||||||
|
|
||||||
def about_dialog(self, *args, **kwargs):
|
def remove_buffer(self, pos):
|
||||||
info = wx.AboutDialogInfo()
|
self.tb.DeletePage(pos)
|
||||||
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)
|
|
Loading…
Reference in New Issue
Block a user