]> git.sesse.net Git - mlt/blob - src/modules/gtk2/consumer_gtk2.c
Big modification - switch to macros for parent class access
[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 program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program 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
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  */
20
21 #include "consumer_gtk2.h"
22
23 #include <stdlib.h>
24 #include <framework/mlt_consumer.h>
25 #include <framework/mlt_factory.h>
26 #include <gdk/gdk.h>
27 #include <gdk/gdkx.h>
28
29 mlt_consumer consumer_gtk2_preview_init( GtkWidget *widget )
30 {
31         // Create an sdl preview consumer
32         mlt_consumer consumer = NULL;
33
34         // This is a nasty little hack which is required by SDL
35         if ( widget != NULL )
36         {
37         Window xwin = GDK_WINDOW_XWINDOW( widget->window );
38         char windowhack[ 32 ];
39         sprintf( windowhack, "%ld", xwin );
40         setenv( "SDL_WINDOWID", windowhack, 1 );
41         }
42
43         // Create an sdl preview consumer
44         consumer = mlt_factory_consumer( "sdl_preview", NULL );
45
46         // Now assign the lock/unlock callbacks
47         if ( consumer != NULL )
48         {
49                 mlt_properties properties = MLT_CONSUMER_PROPERTIES( consumer );
50                 mlt_properties_set_int( properties, "app_locked", 1 );
51                 mlt_properties_set_data( properties, "app_lock", gdk_threads_enter, 0, NULL, NULL );
52                 mlt_properties_set_data( properties, "app_unlock", gdk_threads_leave, 0, NULL, NULL );
53         }
54
55         return consumer;
56 }