Ticket #3125: 0001-Show-and-hide-video-in-the-canvas.patch

File 0001-Show-and-hide-video-in-the-canvas.patch, 3.4 KB (added by manuq, 13 years ago)
  • jukeboxactivity.py

    From 0ab695a69ca25ca4632594b886f424a886c744ca Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org>
    Date: Sun, 2 Oct 2011 22:01:18 -0300
    Subject: [PATCH] Show and hide video in the canvas.
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    This fixes bug #3125 .
    
    Signed-off-by: Manuel Quiñones <manuq@laptop.org>
    ---
     jukeboxactivity.py |   24 +++++++++++++++++++++++-
     1 files changed, 23 insertions(+), 1 deletions(-)
    
    diff --git a/jukeboxactivity.py b/jukeboxactivity.py
    index 0ba3f4c..2d63cc3 100644
    a b class JukeboxActivity(activity.Activity): 
    159159        self.p_duration = gst.CLOCK_TIME_NONE
    160160
    161161        self.bin = gtk.HBox()
     162        self._empty_widget = gtk.Label("")
     163        self._empty_widget.show()
    162164        self.videowidget = VideoWidget()
    163         self.bin.add(self.videowidget)
     165        self._switch_canvas(show_video=False)
    164166        self.set_canvas(self.bin)
    165167        self.show_all()
    166168        #From ImageViewer Activity
    class JukeboxActivity(activity.Activity): 
    173175            self.uri = handle.uri
    174176            gobject.idle_add(self._start, self.uri)
    175177           
     178    def _switch_canvas(self, show_video):
     179        """Show or hide the video visualization in the canvas.
     180
     181        When hidden, the canvas is filled with an empty widget to
     182        ensure redrawing.
     183
     184        """
     185        if show_video:
     186            self.bin.remove(self._empty_widget)
     187            self.bin.add(self.videowidget)
     188        else:
     189            self.bin.add(self._empty_widget)
     190            self.bin.remove(self.videowidget)
     191        self.bin.queue_draw()
     192
     193
    176194    def open_button_clicked_cb(self, widget):
    177195        """ To open the dialog to select a new file"""
    178196        #self.player.seek(0L)
    class JukeboxActivity(activity.Activity): 
    213231        if direction == "prev" and self.currentplaying  > 0:
    214232            self.currentplaying -= 1
    215233            self.player.stop()
     234            self._switch_canvas(show_video=True)
    216235            self.player = GstPlayer(self.videowidget)
    217236            self.player.connect("error", self._player_error_cb)
    218237            self.player.connect("tag", self._player_new_tag_cb)
    class JukeboxActivity(activity.Activity): 
    225244        elif direction == "next" and self.currentplaying  < len(self.playlist) - 1:
    226245            self.currentplaying += 1
    227246            self.player.stop()
     247            self._switch_canvas(show_video=True)
    228248            self.player = GstPlayer(self.videowidget)
    229249            self.player.connect("error", self._player_error_cb)
    230250            self.player.connect("tag", self._player_new_tag_cb)
    class JukeboxActivity(activity.Activity): 
    237257        else:
    238258            self.play_toggled()
    239259            self.player.stop()
     260            self._switch_canvas(show_video=False)
    240261            self.player.set_uri(None)
    241262        self.check_if_next_prev()
    242263
    class JukeboxActivity(activity.Activity): 
    356377        if not self.player:
    357378            # lazy init the player so that videowidget is realized
    358379            # and has a valid widget allocation
     380            self._switch_canvas(show_video=True)
    359381            self.player = GstPlayer(self.videowidget)
    360382            self.player.connect("eos", self._player_eos_cb)
    361383            self.player.connect("error", self._player_error_cb)