]> git.sesse.net Git - mlt/blob - src/modules/gtk2/consumer_gtk2.c
Merge pull request #6 from mcfrisk/coverity
[mlt] / src / modules / gtk2 / consumer_gtk2.c
1 /*
2  * consumer_gtk2.c -- A consumer for GTK2 apps
3  * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
4  * Author: Charles Yates
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include <stdlib.h>
22 #include <framework/mlt_consumer.h>
23 #include <framework/mlt_factory.h>
24 #include <gdk/gdk.h>
25 #ifdef WIN32
26 #include <gdk/gdkwin32.h>
27 #else
28 #include <gdk/gdkx.h>
29 #endif
30 #include <gtk/gtk.h>
31
32 mlt_consumer consumer_gtk2_preview_init( mlt_profile profile, GtkWidget *widget )
33 {
34         // Create an sdl preview consumer
35         mlt_consumer consumer = NULL;
36
37         // This is a nasty little hack which is required by SDL
38         if ( widget != NULL )
39         {
40 #ifdef WIN32
41                 HWND xwin = GDK_WINDOW_HWND( widget->window );
42 #else
43                 Window xwin = GDK_WINDOW_XWINDOW( widget->window );
44 #endif
45         char windowhack[ 32 ];
46         sprintf( windowhack, "%ld", (long) xwin );
47         setenv( "SDL_WINDOWID", windowhack, 1 );
48         }
49
50         // Create an sdl preview consumer
51         consumer = mlt_factory_consumer( profile, "sdl_preview", NULL );
52
53         // Now assign the lock/unlock callbacks
54         if ( consumer != NULL )
55         {
56                 mlt_properties properties = MLT_CONSUMER_PROPERTIES( consumer );
57                 mlt_properties_set_int( properties, "app_locked", 1 );
58                 mlt_properties_set_data( properties, "app_lock", gdk_threads_enter, 0, NULL, NULL );
59                 mlt_properties_set_data( properties, "app_unlock", gdk_threads_leave, 0, NULL, NULL );
60         }
61
62         return consumer;
63 }