X-Git-Url: http://git.maemo.org/git/?p=watersofshiloah;a=blobdiff_plain;f=src%2Fmormonchannel_gtk.py;h=8565ebcc96fe82f9c663d6deb37ad6301d61493e;hp=f3763d41e33f423897a52aa93f6a1c171b2459f1;hb=f9f19fa907ef159a5275939170d696ff316f68d3;hpb=e4c7b74a3a90c9af549350d01e748be2eae04827 diff --git a/src/mormonchannel_gtk.py b/src/mormonchannel_gtk.py index f3763d4..8565ebc 100755 --- a/src/mormonchannel_gtk.py +++ b/src/mormonchannel_gtk.py @@ -2,20 +2,25 @@ # -*- coding: utf-8 -*- """ -@todo Restructure so there is a windows/ folder with a file per source -@todo Add additional sources -@todo Track recent -@todo Presenter browsing when not active -@todo Audio seek bar -@todo Persisted Pause -@todo Favorites +@todo Add python-support support, http://svn.debian.org/viewsvn/collab-maint/deb-maint/python-support/trunk/README +@todo Need to confirm id's are persistent (not just for todos but broken behavior on transition) + @todo Track recent + @todo Persisted Pause + @todo Favorites @todo Sleep timer -@todo Reverse order option. Toggle between playing ascending/descending chronological order @todo Podcast integration + @todo Default with BYU Devotionals, http://speeches.byu.edu/?act=help&page=podcast + @todo Mormon Messages +@todo Reverse order option. Toggle between playing ascending/descending chronological order +@todo Jump to website +@todo Offline mode +@todo Re-use windows for better performance +@todo Make radio program updates only happen when the app has focus to reduce CPU wakes """ from __future__ import with_statement +import os import gc import logging import ConfigParser @@ -48,10 +53,13 @@ class MormonChannelProgram(hildonize.get_app_class()): def __init__(self): super(MormonChannelProgram, self).__init__() - self._store = imagestore.ImageStore("../data", "../data") + currentPath = os.path.abspath(__file__) + storePath = os.path.join(os.path.split(os.path.dirname(currentPath))[0], "data") + self._store = imagestore.ImageStore(storePath, constants._cache_path_) self._index = stream_index.AudioIndex() self._player = player.Player(self._index) + self._store.start() self._index.start() try: if not hildonize.IS_HILDON_SUPPORTED: @@ -66,12 +74,14 @@ class MormonChannelProgram(hildonize.get_app_class()): self._osso_c = None self._deviceState = None - self._sourceSelector = windows.SourceSelector(self._player, self._store, self._index) + self._sourceSelector = windows.source.SourceSelector(self, self._player, self._store, self._index) self._sourceSelector.window.connect("destroy", self._on_destroy) + self._sourceSelector.window.set_default_size(400, 800) self._sourceSelector.show() self._load_settings() except: self._index.stop() + self._store.stop() raise def _save_settings(self): @@ -103,38 +113,42 @@ class MormonChannelProgram(hildonize.get_app_class()): @misc_utils.log_exception(_moduleLogger) def _on_destroy(self, widget = None, data = None): - self.quit() + try: + self.quit() + finally: + gtk.main_quit() def quit(self): try: self._save_settings() + except Exception: + _moduleLogger.exception("Error saving settigns") + try: + self._player.stop() + except Exception: + _moduleLogger.exception("Error stopping player") + try: self._index.stop() + except Exception: + _moduleLogger.exception("Error stopping index") + try: + self._store.stop() + except Exception: + _moduleLogger.exception("Error stopping store") - try: - self._deviceState.close() - except AttributeError: - pass # Either None or close was removed (in Fremantle) - try: - self._osso_c.close() - except AttributeError: - pass # Either None or close was removed (in Fremantle) - finally: - gtk.main_quit() - - @misc_utils.log_exception(_moduleLogger) - def _on_show_about(self, widget = None, data = None): - dialog = gtk.AboutDialog() - dialog.set_position(gtk.WIN_POS_CENTER) - dialog.set_name(constants.__pretty_app_name__) - dialog.set_version(constants.__version__) - dialog.set_copyright("") - dialog.set_website("") - comments = "Mormon Radio and Audiobook Player" - dialog.set_comments(comments) - dialog.set_authors(["Ed Page "]) - dialog.run() - dialog.destroy() + try: + self._deviceState.close() + except AttributeError: + pass # Either None or close was removed (in Fremantle) + except Exception: + _moduleLogger.exception("Error closing device state") + try: + self._osso_c.close() + except AttributeError: + pass # Either None or close was removed (in Fremantle) + except Exception: + _moduleLogger.exception("Error closing osso state") def run(): @@ -142,7 +156,9 @@ def run(): gtk.gdk.threads_init() l = dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) - hildonize.set_application_title(constants.__pretty_app_name__) + # HACK Playback while silent on Maemo 5 + hildonize.set_application_name("FMRadio") + app = MormonChannelProgram() if not PROFILE_STARTUP: try: @@ -150,6 +166,8 @@ def run(): except KeyboardInterrupt: app.quit() raise + else: + app.quit() if __name__ == "__main__":