* Fixing Window / App title stuff
authorEd Page <eopage@byu.net>
Tue, 4 May 2010 03:38:21 +0000 (22:38 -0500)
committerEd Page <eopage@byu.net>
Wed, 5 May 2010 03:31:17 +0000 (22:31 -0500)
* Fixing spacing on the radio window
* Added the mini-presenter to the radio window

src/hildonize.py
src/imagestore.py
src/mormonchannel_gtk.py
src/presenter.py
src/windows.py

index 77d585a..34488b7 100644 (file)
@@ -47,12 +47,12 @@ except AttributeError:
        get_app_class = _null_get_app_class
 
 
        get_app_class = _null_get_app_class
 
 
-def _hildon_set_application_title(window, title):
-       pass
+def _hildon_set_application_title(title):
+       gtk.set_application_name(title)
 
 
 
 
-def _null_set_application_title(window, title):
-       window.set_title(title)
+def _null_set_application_title(title):
+       pass
 
 
 if IS_HILDON_SUPPORTED:
 
 
 if IS_HILDON_SUPPORTED:
index 092efd0..2a13cdb 100644 (file)
@@ -32,21 +32,26 @@ class ImageStore(object):
                self._storePath = storePath
                self._cachePath = cachePath
 
                self._storePath = storePath
                self._cachePath = cachePath
 
-       def get_surface_from_store(self, image):
-               path = os.path.join(self._storePath, image)
+       def get_surface_from_store(self, imageName):
+               path = os.path.join(self._storePath, imageName)
                image = cairo.ImageSurface.create_from_png(path)
                return image
 
                image = cairo.ImageSurface.create_from_png(path)
                return image
 
-       def get_image_from_store(self, image):
-               path = os.path.join(self._storePath, image)
+       def get_image_from_store(self, imageName):
+               path = os.path.join(self._storePath, imageName)
                image = gtk.Image()
                image.set_from_file(path)
                return image
 
                image = gtk.Image()
                image.set_from_file(path)
                return image
 
-       def get_pixbuf_from_store(self, image):
-               path = os.path.join(self._storePath, image)
+       def set_image_from_store(self, image, imageName):
+               path = os.path.join(self._storePath, imageName)
+               image.set_from_file(path)
+               return image
+
+       def get_pixbuf_from_store(self, imageName):
+               path = os.path.join(self._storePath, imageName)
                return gtk.gdk.pixbuf_new_from_file(path)
 
                return gtk.gdk.pixbuf_new_from_file(path)
 
-       def get_pixbuf_animation_from_store(self, image):
-               path = os.path.join(self._storePath, image)
+       def get_pixbuf_animation_from_store(self, imageName):
+               path = os.path.join(self._storePath, imageName)
                return gtk.gdk.PixbufAnimation(path)
                return gtk.gdk.PixbufAnimation(path)
index 0ddff73..8ac8d4c 100755 (executable)
@@ -119,8 +119,7 @@ class MormonChannelProgram(hildonize.get_app_class()):
 
 
 def run():
 
 
 def run():
-       if hildonize.IS_HILDON_SUPPORTED:
-               gtk.set_application_name(constants.__pretty_app_name__)
+       hildonize.set_application_title(constants.__pretty_app_name__)
        app = MormonChannelProgram()
        if not PROFILE_STARTUP:
                gtk.main()
        app = MormonChannelProgram()
        if not PROFILE_STARTUP:
                gtk.main()
index 335d118..2d8f153 100644 (file)
@@ -299,3 +299,39 @@ class StreamPresenter(object):
                        backHeight - self._buttonImage.get_height() + 5,
                )
                cairoContext.paint()
                        backHeight - self._buttonImage.get_height() + 5,
                )
                cairoContext.paint()
+
+
+class StreamMiniPresenter(object):
+
+       def __init__(self, player, store):
+               self._store = store
+               self._player = player
+               self._player.connect("state-change", self._on_player_state_change)
+
+               self._button = gtk.Image()
+               if self._player.state == "play":
+                       self._store.set_image_from_store(self._button, self._store.STORE_LOOKUP["play"])
+               else:
+                       self._store.set_image_from_store(self._button, self._store.STORE_LOOKUP["pause"])
+
+               self._eventBox = gtk.EventBox()
+               self._eventBox.add(self._button)
+               self._eventBox.connect("button_release_event", self._on_button_release)
+
+       @property
+       def toplevel(self):
+               return self._eventBox
+
+       @misc_utils.log_exception(_moduleLogger)
+       def _on_player_state_change(self, player, newState):
+               if self._player.state == "play":
+                       self._store.set_image_from_store(self._button, self._store.STORE_LOOKUP["play"])
+               else:
+                       self._store.set_image_from_store(self._button, self._store.STORE_LOOKUP["pause"])
+
+       @misc_utils.log_exception(_moduleLogger)
+       def _on_button_release(self, widget, event):
+               if self._player.state == "play":
+                       self._player.pause()
+               else:
+                       self._player.play()
index cbe1fcf..91f995b 100644 (file)
@@ -6,11 +6,11 @@ import gtk
 
 import constants
 import hildonize
 
 import constants
 import hildonize
-import gtk_toolbox
 import util.misc as misc_utils
 
 import banners
 import playcontrol
 import util.misc as misc_utils
 
 import banners
 import playcontrol
+import presenter
 
 
 _moduleLogger = logging.getLogger(__name__)
 
 
 _moduleLogger = logging.getLogger(__name__)
@@ -49,7 +49,6 @@ class BasicWindow(gobject.GObject):
                self._window.add(self._layout)
                self._window = hildonize.hildonize_window(self, self._window)
 
                self._window.add(self._layout)
                self._window = hildonize.hildonize_window(self, self._window)
 
-               hildonize.set_application_title(self._window, "%s" % constants.__pretty_app_name__)
                self._window.set_icon(self._store.get_pixbuf_from_store(self._store.STORE_LOOKUP["icon"]))
                self._window.connect("key-press-event", self._on_key_press)
                self._window.connect("window-state-event", self._on_window_state_change)
                self._window.set_icon(self._store.get_pixbuf_from_store(self._store.STORE_LOOKUP["icon"]))
                self._window.connect("key-press-event", self._on_key_press)
                self._window.connect("window-state-event", self._on_window_state_change)
@@ -155,6 +154,7 @@ class SourceSelector(BasicWindow):
                self._layout.pack_start(self._buttonLayout, True, True)
                self._layout.pack_start(self._playcontrol.toplevel, False, True)
 
                self._layout.pack_start(self._buttonLayout, True, True)
                self._layout.pack_start(self._playcontrol.toplevel, False, True)
 
+               self._window.set_title(constants.__pretty_app_name__)
                self._window.show_all()
                self._errorBanner.toplevel.hide()
                self._playcontrol.toplevel.hide()
                self._window.show_all()
                self._errorBanner.toplevel.hide()
                self._playcontrol.toplevel.hide()
@@ -191,13 +191,19 @@ class RadioView(BasicWindow):
                headerPath = self._store.STORE_LOOKUP["radio_header"]
                self._header = self._store.get_image_from_store(headerPath)
 
                headerPath = self._store.STORE_LOOKUP["radio_header"]
                self._header = self._store.get_image_from_store(headerPath)
 
-               self._radioLayout = gtk.VBox(True, 5)
-               self._radioLayout.set_property("border-width", 5)
+               self._treeView = gtk.TreeView()
+
+               self._presenter = presenter.StreamMiniPresenter(self._player, self._store)
+
+               self._radioLayout = gtk.VBox(False)
                self._radioLayout.pack_start(self._header, False, False)
                self._radioLayout.pack_start(self._header, False, False)
+               self._radioLayout.pack_start(self._treeView, True, True)
+               self._radioLayout.pack_start(self._presenter.toplevel, False, True)
 
                self._layout.pack_start(self._loadingBanner.toplevel, False, False)
                self._layout.pack_start(self._radioLayout, True, True)
 
 
                self._layout.pack_start(self._loadingBanner.toplevel, False, False)
                self._layout.pack_start(self._radioLayout, True, True)
 
+               self._window.set_title("Radio")
                self._window.show_all()
                self._errorBanner.toplevel.hide()
                self._loadingBanner.toplevel.hide()
                self._window.show_all()
                self._errorBanner.toplevel.hide()
                self._loadingBanner.toplevel.hide()