[pitivi/ges: 112/287] Automatically set the size of the Media Library previewer



commit 39f271f0ed595b10832d949a9effafd959b0ab55
Author: Jean-FranÃois Fortin Tam <nekohayo gmail com>
Date:   Sat Dec 24 01:01:50 2011 -0500

    Automatically set the size of the Media Library previewer

 pitivi/ui/filechooserpreview.py |    2 ++
 pitivi/ui/mainwindow.py         |   23 ++++++++++++++++++++---
 2 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/pitivi/ui/filechooserpreview.py b/pitivi/ui/filechooserpreview.py
index 6935a99..c1c0bae 100644
--- a/pitivi/ui/filechooserpreview.py
+++ b/pitivi/ui/filechooserpreview.py
@@ -136,6 +136,8 @@ class PreviewWidget(gtk.VBox, Loggable):
 
     def setMinimal(self):
         self.remove(self.l_tags)
+        self.b_zoom_in.hide()
+        self.b_zoom_out.hide()
         self.set_child_packing(self.preview_video, True, True, 0, gtk.PACK_START)
 
     def add_preview_request(self, dialogbox):
diff --git a/pitivi/ui/mainwindow.py b/pitivi/ui/mainwindow.py
index de05127..eb5bcf3 100644
--- a/pitivi/ui/mainwindow.py
+++ b/pitivi/ui/mainwindow.py
@@ -1078,14 +1078,31 @@ class PitiviMainWindow(gtk.Window, Loggable):
 
     def _viewUri(self, path):
         preview_window = gtk.Window()
+        preview_window.set_title(_("Preview - click outside to close"))
         preview_window.set_transient_for(self)
-        preview_window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
         preview_window.connect("focus-out-event", self._leavePreviewCb)
         previewer = PreviewWidget(self)
         preview_window.add(previewer)
-        preview_window.show_all()
-        previewer.setMinimal()
+
+        preview_window.show_all()  # Needed for PreviewWidget to do its magic
+        preview_window.hide()  # Hack to allow setting the window position
         previewer.previewUri(path)
+        previewer.setMinimal()
+        info = self.project.sources.getInfoFromUri(path)
+        try:
+            image_width = info.get_video_streams()[0].get_width()
+            image_height = info.get_video_streams()[0].get_height()
+            controls_height = previewer.bbox.size_request()[1]
+            preview_window.resize(image_width, image_height + controls_height)
+        except:
+            # There is no video/image stream. This is an audio file.
+            # Resize to the minimum and let the window manager deal with it
+            preview_window.resize(1, 1)
+        # Setting the position of the window only works if it's currently hidden
+        # otherwise, after the resize the position will not be readjusted
+        preview_window.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
+        preview_window.show()
+
         previewer.play()
 
     def _timelineSeekRelativeCb(self, unused_seeker, time):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]