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): |
159 | 159 | self.p_duration = gst.CLOCK_TIME_NONE |
160 | 160 | |
161 | 161 | self.bin = gtk.HBox() |
| 162 | self._empty_widget = gtk.Label("") |
| 163 | self._empty_widget.show() |
162 | 164 | self.videowidget = VideoWidget() |
163 | | self.bin.add(self.videowidget) |
| 165 | self._switch_canvas(show_video=False) |
164 | 166 | self.set_canvas(self.bin) |
165 | 167 | self.show_all() |
166 | 168 | #From ImageViewer Activity |
… |
… |
class JukeboxActivity(activity.Activity): |
173 | 175 | self.uri = handle.uri |
174 | 176 | gobject.idle_add(self._start, self.uri) |
175 | 177 | |
| 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 | |
176 | 194 | def open_button_clicked_cb(self, widget): |
177 | 195 | """ To open the dialog to select a new file""" |
178 | 196 | #self.player.seek(0L) |
… |
… |
class JukeboxActivity(activity.Activity): |
213 | 231 | if direction == "prev" and self.currentplaying > 0: |
214 | 232 | self.currentplaying -= 1 |
215 | 233 | self.player.stop() |
| 234 | self._switch_canvas(show_video=True) |
216 | 235 | self.player = GstPlayer(self.videowidget) |
217 | 236 | self.player.connect("error", self._player_error_cb) |
218 | 237 | self.player.connect("tag", self._player_new_tag_cb) |
… |
… |
class JukeboxActivity(activity.Activity): |
225 | 244 | elif direction == "next" and self.currentplaying < len(self.playlist) - 1: |
226 | 245 | self.currentplaying += 1 |
227 | 246 | self.player.stop() |
| 247 | self._switch_canvas(show_video=True) |
228 | 248 | self.player = GstPlayer(self.videowidget) |
229 | 249 | self.player.connect("error", self._player_error_cb) |
230 | 250 | self.player.connect("tag", self._player_new_tag_cb) |
… |
… |
class JukeboxActivity(activity.Activity): |
237 | 257 | else: |
238 | 258 | self.play_toggled() |
239 | 259 | self.player.stop() |
| 260 | self._switch_canvas(show_video=False) |
240 | 261 | self.player.set_uri(None) |
241 | 262 | self.check_if_next_prev() |
242 | 263 | |
… |
… |
class JukeboxActivity(activity.Activity): |
356 | 377 | if not self.player: |
357 | 378 | # lazy init the player so that videowidget is realized |
358 | 379 | # and has a valid widget allocation |
| 380 | self._switch_canvas(show_video=True) |
359 | 381 | self.player = GstPlayer(self.videowidget) |
360 | 382 | self.player.connect("eos", self._player_eos_cb) |
361 | 383 | self.player.connect("error", self._player_error_cb) |