mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-24 08:08:22 +00:00
mi-preview: reflow the overlay sync
We need to listen to preview-widget resizing to send an expose to the gst- overlay. Defer discovering until the ui has be realized.
This commit is contained in:
parent
c9cc3bbd9c
commit
8abadb14f9
3 changed files with 29 additions and 24 deletions
|
@ -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);
|
||||
|
||||
if (uri != null) {
|
||||
chooser.set_sensitive (false);
|
||||
Idle.add ( () => {
|
||||
info.discover (uri);
|
||||
return false;
|
||||
});
|
||||
} else {
|
||||
if (directory != null) {
|
||||
//chooser.set_current_folder (GLib.Environment.get_home_dir ());
|
||||
Idle.add ( () => {
|
||||
chooser.set_current_folder (directory);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
chooser.selection_changed.connect (on_update_preview);
|
||||
}
|
||||
|
||||
info = new Info ();
|
||||
paned.pack2 (info, true, true);
|
||||
|
||||
realize.connect ( () => {
|
||||
debug ("realized");
|
||||
if (uri != null) {
|
||||
chooser.set_sensitive (false);
|
||||
info.discover (uri);
|
||||
} else {
|
||||
if (directory != null) {
|
||||
//chooser.set_current_folder (GLib.Environment.get_home_dir ());
|
||||
chooser.set_current_folder (directory);
|
||||
}
|
||||
chooser.selection_changed.connect (on_update_preview);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// helper
|
||||
|
|
|
@ -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 ()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue