mi-preview: reflow the overlay sync
authorStefan Sauer <ensonic@users.sf.net>
Fri, 18 Oct 2013 21:33:50 +0000 (23:33 +0200)
committerStefan Sauer <ensonic@users.sf.net>
Sat, 19 Oct 2013 19:15:36 +0000 (21:15 +0200)
We need to listen to preview-widget resizing to send an expose to the gst-
overlay. Defer discovering until the ui has be realized.

mediainfo/src/mi-app.vala
mediainfo/src/mi-info.vala
mediainfo/src/mi-preview.vala

index 88dfdec..da4d156 100644 (file)
@@ -24,12 +24,12 @@ public class MediaInfo.App : Window
 {
   private FileChooserWidget chooser;
   private Info info;
+  private string directory = null;
+  private string uri = null;
 
   public App (string? directory_or_uri) {
     GLib.Object (type :  WindowType.TOPLEVEL);
     
-    string directory = null;
-    string uri = null;
     if (directory_or_uri != null) {
       if (FileUtils.test (directory_or_uri, FileTest.IS_DIR)) {
         directory = directory_or_uri;
@@ -63,26 +63,23 @@ public class MediaInfo.App : Window
     paned.pack1 (chooser, false, false);
 
     chooser.set_show_hidden (false);
+
+    info = new Info ();
+    paned.pack2 (info, true, true);
     
-    if (uri != null) {
-      chooser.set_sensitive (false);
-      Idle.add ( () => {
+    realize.connect ( () => {
+      debug ("realized");
+      if (uri != null) {
+        chooser.set_sensitive (false);
         info.discover (uri);
-        return false;
-      });
-    } else {
-      if (directory != null) {
-        //chooser.set_current_folder (GLib.Environment.get_home_dir ());
-        Idle.add ( () => {
+      } else {
+        if (directory != null) {
+          //chooser.set_current_folder (GLib.Environment.get_home_dir ());
           chooser.set_current_folder (directory);
-          return false;
-        });
+        }
+        chooser.selection_changed.connect (on_update_preview);
       }
-      chooser.selection_changed.connect (on_update_preview);
-    }
-
-    info = new Info ();
-    paned.pack2 (info, true, true);
+    });
   }
 
   // helper
index f624083..573d046 100644 (file)
@@ -41,6 +41,7 @@ public class MediaInfo.Info : Box
   // gstreamer objects
   private Discoverer dc;
   private Pipeline pb;
+  private Video.Overlay overlay;
   private bool have_video = false;
   private uint num_video_streams;
   private uint num_audio_streams;
@@ -163,6 +164,8 @@ public class MediaInfo.Info : Box
 
     // add widgets
     preview = new Preview ();
+    preview.add_events (Gdk.EventMask.STRUCTURE_MASK);
+    preview.configure_event.connect (on_preview_configured);
     pack_start (preview, false, false, 0);
 
     info_area = new ScrolledWindow (null, null);
@@ -273,8 +276,6 @@ public class MediaInfo.Info : Box
     
     // TODO: add message list widget
 
-    show_all ();
-
     // set up the gstreamer components
     try {
       dc = new Discoverer ((ClockTime)(Gst.SECOND * 10));
@@ -495,10 +496,16 @@ public class MediaInfo.Info : Box
   }
 
   // signal handlers
+  
+  private bool on_preview_configured (Gdk.EventConfigure event) {
+    if (overlay != null)
+      overlay.expose();
+    return false;
+  }  
 
   private void on_element_sync_message (Gst.Bus bus, Message message) {
     if (Gst.Video.is_video_overlay_prepare_window_handle_message (message)) {
-      Gst.Video.Overlay overlay = message.src as Gst.Video.Overlay;
+      overlay = message.src as Gst.Video.Overlay;
       overlay.set_window_handle ((uint *)Gdk.X11Window.get_xid (preview.get_window ()));
     }
   }
index 9cf4eac..8ceb093 100644 (file)
@@ -109,10 +109,11 @@ public class MediaInfo.Preview : DrawingArea {
   
   public override void size_allocate (Gtk.Allocation alloc) {
     base.size_allocate (alloc);
-
+    
     alloc_width = alloc.width;
     alloc_height = alloc.height;
-    debug ("alloc w,h: %d,%d", alloc_width, alloc_height);
+    debug ("alloc x,y: %d,%d  w,h: %d,%d", 
+        alloc.x, alloc.y, alloc_width, alloc_height);
   }
   
   public override bool draw (Cairo.Context cr) {