Implemented basic audio searches
This commit is contained in:
parent
a2905c82d5
commit
2fe26beef9
@ -11,6 +11,7 @@ from mysc.repeating_timer import RepeatingTimer
|
||||
from mysc.thread_utils import call_threaded
|
||||
from sessionmanager import session
|
||||
from wxUI import (mainWindow, commonMessages)
|
||||
from wxUI.dialogs import search as searchDialogs
|
||||
from update import updater
|
||||
|
||||
class Controller(object):
|
||||
@ -75,6 +76,7 @@ class Controller(object):
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.update_buffer, menuitem=self.window.update_buffer)
|
||||
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)
|
||||
|
||||
def disconnect_events(self):
|
||||
pub.unsubscribe(self.in_post, "posted")
|
||||
@ -122,7 +124,7 @@ class Controller(object):
|
||||
def exit(self, *args, **kwargs):
|
||||
self.disconnect_events()
|
||||
self.window.Destroy()
|
||||
wx.GetApp().ExitMainloop()
|
||||
wx.GetApp().ExitMainLoop()
|
||||
|
||||
def update_buffer(self, *args, **kwargs):
|
||||
b = self.get_current_buffer()
|
||||
@ -132,3 +134,16 @@ class Controller(object):
|
||||
update = updater.do_update()
|
||||
if update == False:
|
||||
commonMessages.no_update_available()
|
||||
|
||||
def search_audios(self, *args, **kwargs):
|
||||
dlg = searchDialogs.searchAudioDialog()
|
||||
if dlg.get_response() == widgetUtils.OK:
|
||||
q = dlg.get("term").encode("utf-8")
|
||||
count = 300
|
||||
auto_complete = 1
|
||||
lyrics = 0
|
||||
performer_only = 0
|
||||
newbuff = buffers.audioBuffer(parent=self.window.tb, name=u"{0}_audiosearch".format(q.decode("utf-8"),), session=self.session, composefunc="compose_audio", parent_endpoint="audio", endpoint="search", q=q, count=count, auto_complete=auto_complete, lyrics=lyrics, performer_only=performer_only)
|
||||
self.buffers.append(newbuff)
|
||||
call_threaded(newbuff.get_items)
|
||||
self.window.insert_buffer(newbuff.tab, _(u"Search for {0}").format(q.decode("utf-8"),), self.window.search("audios"))
|
||||
|
@ -46,7 +46,7 @@ def stringify_values(dictionary):
|
||||
stringified_values_dict = {}
|
||||
for key, value in dictionary.items():
|
||||
if isinstance(value, Iterable) and not isinstance(value, STRING_TYPES):
|
||||
value = ','.join(map(str, value))
|
||||
value = u','.join(map(str, value))
|
||||
stringified_values_dict[key] = value
|
||||
return stringified_values_dict
|
||||
|
||||
|
26
src/wxUI/dialogs/search.py
Normal file
26
src/wxUI/dialogs/search.py
Normal file
@ -0,0 +1,26 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import widgetUtils
|
||||
import wx
|
||||
|
||||
class searchAudioDialog(widgetUtils.BaseDialog):
|
||||
def __init__(self, value=""):
|
||||
super(searchAudioDialog, self).__init__(None, -1)
|
||||
panel = wx.Panel(self)
|
||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
self.SetTitle(_(u"audio Search"))
|
||||
label = wx.StaticText(panel, -1, _(u"&Search"))
|
||||
self.term = wx.TextCtrl(panel, -1, value)
|
||||
dc = wx.WindowDC(self.term)
|
||||
dc.SetFont(self.term.GetFont())
|
||||
self.term.SetSize(dc.GetTextExtent("0"*40))
|
||||
sizer.Add(label, 0, wx.ALL, 5)
|
||||
sizer.Add(self.term, 0, wx.ALL, 5)
|
||||
ok = wx.Button(panel, wx.ID_OK, _(u"&OK"))
|
||||
ok.SetDefault()
|
||||
cancel = wx.Button(panel, wx.ID_CANCEL, _(u"&Close"))
|
||||
btnsizer = wx.BoxSizer()
|
||||
btnsizer.Add(ok, 0, wx.ALL, 5)
|
||||
btnsizer.Add(cancel, 0, wx.ALL, 5)
|
||||
sizer.Add(btnsizer, 0, wx.ALL, 5)
|
||||
panel.SetSizer(sizer)
|
||||
self.SetClientSize(sizer.CalcMin())
|
@ -6,6 +6,9 @@ class mainWindow(wx.Frame):
|
||||
def makeMenu(self):
|
||||
mb = wx.MenuBar()
|
||||
buffer = wx.Menu()
|
||||
self.new_buffer = wx.Menu()
|
||||
self.search_audios = self.new_buffer.Append(wx.NewId(), _(u"Audio"))
|
||||
buffer.AppendMenu(wx.NewId(), _(u"New buffer"), self.new_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.Enable(False)
|
||||
|
Loading…
Reference in New Issue
Block a user