Fixed controler.

This commit is contained in:
Bill Dengler 2015-06-10 17:53:28 -04:00
parent 6232ec3b7c
commit 28e0edf2a5
3 changed files with 42 additions and 24 deletions

View File

@ -82,28 +82,6 @@ class bufferController(object):
sound.URLPlayer.stream.volume = self.session.settings["sound"]["volume"]
self.session.sound.play("volume_changed.ogg")
def interact(self):
if hasattr(sound.URLPlayer,'stream'):
return sound.URLPlayer.stop_audio(delete=True)
tweet = self.get_tweet()
url=None
urls = utils.find_urls(tweet)
if len(urls) == 1:
url=urls[0]
elif len(urls) > 1:
urls_list = dialogs.urlList.urlList()
urls_list.populate_list(urls)
if urls_list.get_response() == widgetUtils.OK:
url=urls_list.get_string()
if hasattr(urls_list, "destroy"): urls_list.destroy()
if url != None:
output.speak(_(u"Opening media..."), True)
if sound.URLPlayer.is_playable(url=url, play=True, volume=self.session.settings["sound"]["volume"]) == False:
return webbrowser.open_new_tab(url)
else:
output.speak(_(u"Not actionable."), True)
self.session.sound.play("error.ogg")
def start_stream(self):
pass

View File

@ -992,11 +992,43 @@ class Controller(object):
def interact(self):
"Select the best action for the currently focused tweet (audio, geocode, URL, etc)."
buffer = self.get_current_buffer()
buffer.interact()
if hasattr(sound.URLPlayer,'stream') and config.app['app-settings']['use_Codeofdusk_audio_handlers']:
return sound.URLPlayer.stop_audio(delete=True)
tweet = buffer.get_tweet()
if utils.is_geocoded(tweet) and config.app['app-settings']['use_Codeofdusk_audio_handlers'] and config.app['app-settings']['prefer_geocodes']:
return self.reverse_geocode()
url=None
urls = utils.find_urls(tweet)
if len(urls) == 1:
url=urls[0]
elif len(urls) > 1:
urls_list = dialogs.urlList.urlList()
urls_list.populate_list(urls)
if urls_list.get_response() == widgetUtils.OK:
url=urls_list.get_string()
if hasattr(urls_list, "destroy"): urls_list.destroy()
if url != None:
output.speak("Opening media...",True)
if config.app['app-settings']['use_Codeofdusk_audio_handlers']:
if sound.URLPlayer.is_playable(url=url,play=True,volume=buffer.session.settings["sound"]["volume"]) == False:
return webbrowser.open_new_tab(url)
else:
output.speak(_(u"Not actionable."), True)
buffer.session.sound.play("error.ogg")
def secondary_interact(self):
buffer = self.get_current_buffer()
tweet=buffer.get_tweet()
if utils.is_geocoded(tweet) and config.app['app-settings']['use_Codeofdusk_audio_handlers'] and config.app['app-settings']['prefer_geocodes']:
return self.view_reverse_geocode()
elif config.app['app-settings']['use_Codeofdusk_audio_handlers']:
return buffer.url()
else:
return buffer.audio()
def url(self, *args, **kwargs):
buffer = self.get_current_buffer()
buffer.url()
return buffer.url()
def audio(self, *args, **kwargs):
self.get_current_buffer().audio()

View File

@ -60,6 +60,9 @@ class globalSettingsController(object):
self.dialog.set_value("general", "use_invisible_shorcuts", config.app["app-settings"]["use_invisible_keyboard_shorcuts"])
self.dialog.set_value("general", "disable_sapi5", config.app["app-settings"]["voice_enabled"])
self.dialog.set_value("general", "hide_gui", config.app["app-settings"]["hide_gui"])
self.dialog.set_value("general", "use_slow_audio_algo", config.app["app-settings"]["use_slow_audio_algo"])
self.dialog.set_value("general", "use_codeofdusk_audio_handlers", config.app["app-settings"]["use_codeofdusk_audio_handlers"])
self.dialog.set_value("general", "prefer_geocodes", config.app["app-settings"]["prefer_geocodes"])
self.dialog.create_proxy()
self.dialog.set_value("proxy", "server", config.app["proxy"]["server"])
self.dialog.set_value("proxy", "port", config.app["proxy"]["port"])
@ -84,7 +87,12 @@ class globalSettingsController(object):
config.app["app-settings"]["hide_gui"] = self.dialog.get_value("general", "hide_gui")
config.app["app-settings"]["ask_at_exit"] = self.dialog.get_value("general", "ask_at_exit")
config.app["app-settings"]["play_ready_sound"] = self.dialog.get_value("general", "play_ready_sound")
config.app["app-settings"]["use_codeofdusk_audio_handlers"] = self.dialog.get_value("general", "use_codeofdusk_audio_handlers")
config.app["app-settings"]["prefer_geocodes"] = self.dialog.get_value("general", "prefer_geocodes")
config.app["app-settings"]["speak_ready_msg"] = self.dialog.get_value("general", "speak_ready_msg")
if config.app["app-settings"]["use_slow_audio_algo"] != self.dialog.get_value("general", "use_invisible_shorcuts"):
config.app["app-settings"]["use_slow_audio_algo"] = self.dialog.get_value("general", "use_invisible_shorcuts")
self.needs_restart=True
if config.app["proxy"]["server"] != self.dialog.get_value("proxy", "server") or config.app["proxy"]["port"] != self.dialog.get_value("proxy", "port") or config.app["proxy"]["user"] != self.dialog.get_value("proxy", "user") or config.app["proxy"]["password"] != self.dialog.get_value("proxy", "password"):
if self.is_started == True:
self.needs_restart = True