Fixing bunches of issues with the presenter
authorEd Page <eopage@byu.net>
Fri, 14 May 2010 02:16:53 +0000 (21:16 -0500)
committerEd Page <eopage@byu.net>
Fri, 14 May 2010 02:16:53 +0000 (21:16 -0500)
src/mormonchannel_gtk.py
src/player.py
src/presenter.py
src/stream_index.py
src/windows.py

index 74f89ed..fec2469 100755 (executable)
@@ -4,13 +4,12 @@
 """
 @todo Restructure so there is a windows/ folder with a file per source
 @todo Add additional sources
-@bug Fix presenter display
 @todo Track recent
-@todo Favorites
 @todo Sequential playback
 @todo Enable Call Monitor
 @todo Audio seek bar
 @todo Persisted Pause
+@todo Favorites
 @todo Reverse order option.  Toggle between playing ascending/descending chronological order
 @todo Podcast integration
 """
@@ -53,7 +52,6 @@ class MormonChannelProgram(hildonize.get_app_class()):
 
                self._index.start()
                try:
-
                        if not hildonize.IS_HILDON_SUPPORTED:
                                _moduleLogger.info("No hildonization support")
 
index 9288470..61ebf5c 100644 (file)
@@ -37,6 +37,7 @@ class Player(gobject.GObject):
                gobject.GObject.__init__(self)
                self._index = index
                self._node = None
+
                self._stream = stream.GSTStream()
                self._stream.connect("state-change", self._on_stream_state)
                self._stream.connect("eof", self._on_stream_eof)
index 9b8e07a..9f336a1 100644 (file)
@@ -131,6 +131,7 @@ class StreamPresenter(object):
                self._subtitle = ""
                self._buttonImage = None
                self._imageName = ""
+               self._dims = 0, 0
 
        @property
        def toplevel(self):
@@ -144,10 +145,7 @@ class StreamPresenter(object):
                else:
                        raise NotImplementedError(orientation)
 
-               cairoContext = self._image.window.cairo_create()
-               if not self._isPortrait:
-                       cairoContext.transform(cairo.Matrix(0, 1, 1, 0, 0, 0))
-               self._draw_presenter(cairoContext)
+               self._image.queue_draw()
 
        def set_state(self, stateImage):
                if stateImage == self._imageName:
@@ -155,13 +153,12 @@ class StreamPresenter(object):
                self._imageName = stateImage
                self._buttonImage = self._store.get_surface_from_store(stateImage)
 
-               cairoContext = self._image.window.cairo_create()
-               if not self._isPortrait:
-                       cairoContext.transform(cairo.Matrix(0, 1, 1, 0, 0, 0))
-               self._draw_presenter(cairoContext)
+               self._image.queue_draw()
 
        def set_context(self, backgroundImage, title, subtitle):
                self._backgroundImage = self._store.get_surface_from_store(backgroundImage)
+               self._title = title
+               self._subtitle = subtitle
 
                if self._isPortrait:
                        backWidth = self._backgroundImage.get_width()
@@ -171,10 +168,7 @@ class StreamPresenter(object):
                        backWidth = self._backgroundImage.get_height()
                self._image.set_size_request(backWidth, backHeight)
 
-               cairoContext = self._image.window.cairo_create()
-               if not self._isPortrait:
-                       cairoContext.transform(cairo.Matrix(0, 1, 1, 0, 0, 0))
-               self._draw_presenter(cairoContext)
+               self._image.queue_draw()
 
        @misc_utils.log_exception(_moduleLogger)
        def _on_expose(self, widget, event):
@@ -184,8 +178,12 @@ class StreamPresenter(object):
                self._draw_presenter(cairoContext)
 
        def _draw_presenter(self, cairoContext):
-               # Blank things
                rect = self._image.get_allocation()
+               self._dims = rect.width, rect.height
+               startContent = 30, self._dims[1] - 125
+               endContent = self._dims[0] - 30,  self._dims[1] - 5
+
+               # Blank things
                cairoContext.rectangle(
                        0,
                        0,
@@ -194,7 +192,6 @@ class StreamPresenter(object):
                )
                cairoContext.set_source_rgb(0, 0, 0)
                cairoContext.fill()
-               cairoContext.paint()
 
                # Draw Background
                if self._backgroundImage is not None:
@@ -205,25 +202,32 @@ class StreamPresenter(object):
                        )
                        cairoContext.paint()
 
+               # Control background
+               cairoContext.rectangle(
+                       startContent[0],
+                       startContent[1],
+                       endContent[0] - startContent[0],
+                       endContent[1] - startContent[1],
+               )
+               cairoContext.set_source_rgba(0.9, 0.9, 0.9, 0.75)
+               cairoContext.fill()
+
                # title
                if self._title or self._subtitle:
-                       backWidth = self._backgroundImage.get_width()
-                       backHeight = self._backgroundImage.get_height()
-
                        pangoContext = self._image.create_pango_context()
                        textLayout = pango.Layout(pangoContext)
 
                        textLayout.set_markup(self._subtitle)
                        textWidth, textHeight = textLayout.get_pixel_size()
-                       subtitleTextX = backWidth / 2 - textWidth / 2
-                       subtitleTextY = backHeight - textHeight - self._buttonImage.get_height()
+                       subtitleTextX = self._dims[0] / 2 - textWidth / 2
+                       subtitleTextY = self._dims[1] - textHeight - self._buttonImage.get_height() + 10
                        cairoContext.move_to(subtitleTextX, subtitleTextY)
                        cairoContext.set_source_rgb(0, 0, 0)
                        cairoContext.show_layout(textLayout)
 
                        textLayout.set_markup(self._title)
                        textWidth, textHeight = textLayout.get_pixel_size()
-                       textX = backWidth / 2 - textWidth / 2
+                       textX = self._dims[0] / 2 - textWidth / 2
                        textY = subtitleTextY - textHeight
                        cairoContext.move_to(textX, textY)
                        cairoContext.set_source_rgb(0, 0, 0)
@@ -234,13 +238,10 @@ class StreamPresenter(object):
        def _draw_state(self, cairoContext):
                if self._backgroundImage is None or self._buttonImage is None:
                        return
-               backWidth = self._backgroundImage.get_width()
-               backHeight = self._backgroundImage.get_height()
-
                cairoContext.set_source_surface(
                        self._buttonImage,
-                       backWidth / 2 - self._buttonImage.get_width() / 2,
-                       backHeight - self._buttonImage.get_height() + 5,
+                       self._dims[0] / 2 - self._buttonImage.get_width() / 2,
+                       self._dims[1] - self._buttonImage.get_height() + 5,
                )
                cairoContext.paint()
 
index 8e83769..8d5aae3 100644 (file)
@@ -368,7 +368,11 @@ class TalkNode(LeafNode):
 
        @property
        def subtitle(self):
-               return self._data["speaker"]
+               speaker = self._data["speaker"]
+               if speaker is not None:
+                       return speaker
+               else:
+                       return ""
 
        @property
        def uri(self):
index 6b53df4..3e3f50b 100644 (file)
@@ -855,12 +855,16 @@ class ConferenceTalkWindow(BasicWindow):
                self._node = node
 
                self.connect_auto(self._player, "state-change", self._on_player_state_change)
-               self.connect_auto(self._player, "title-change", self._on_player_title_change)
                self.connect_auto(self._player, "error", self._on_player_error)
 
                self._loadingBanner = banners.GenericBanner()
 
                self._presenter = presenter.StreamPresenter(self._store)
+               self._presenter.set_context(
+                       self._store.STORE_LOOKUP["conference_background"],
+                       self._node.title,
+                       self._node.subtitle,
+               )
                self._presenterNavigation = presenter.NavigationBox()
                self._presenterNavigation.toplevel.add(self._presenter.toplevel)
                self._presenterNavigation.connect("action", self._on_nav_action)
@@ -876,12 +880,6 @@ class ConferenceTalkWindow(BasicWindow):
                self._window.show_all()
                self._errorBanner.toplevel.hide()
                self._loadingBanner.toplevel.hide()
-
-               self._presenter.set_context(
-                       self._store.STORE_LOOKUP["conference_background"],
-                       self._player.title,
-                       self._player.subtitle,
-               )
                self._set_context(self._player.state)
 
        def jump_to(self, node):
@@ -920,17 +918,6 @@ class ConferenceTalkWindow(BasicWindow):
                self._set_context(newState)
 
        @misc_utils.log_exception(_moduleLogger)
-       def _on_player_title_change(self, player, node):
-               if node is not self._node or node is None:
-                       _moduleLogger.info("Player title magically changed to %s" % player.title)
-                       return
-               self._presenter.set_context(
-                       self._store.STORE_LOOKUP["conference_background"],
-                       self._player.title,
-                       self._player.subtitle,
-               )
-
-       @misc_utils.log_exception(_moduleLogger)
        def _on_player_error(self, player, err, debug):
                _moduleLogger.error("%r - %r" % (err, debug))