comparison pidgin/gtkmedia.c @ 28043:6e3c83e1057c

Make gtkmedia.c compilable on systems without X11 (as long as they're Win32)
author Stu Tomlinson <stu@nosnilmot.com>
date Tue, 28 Jul 2009 01:18:46 +0000
parents df9042312063
children 813f2eb3fdc8
comparison
equal deleted inserted replaced
28042:60aab59fb35a 28043:6e3c83e1057c
36 #include "gtkutils.h" 36 #include "gtkutils.h"
37 37
38 #ifdef USE_VV 38 #ifdef USE_VV
39 #include "media-gst.h" 39 #include "media-gst.h"
40 40
41 #ifdef _WIN32
42 #include <gdk/gdkwin32.h>
43 #endif
44
41 #include <gst/interfaces/xoverlay.h> 45 #include <gst/interfaces/xoverlay.h>
42 46
43 #define PIDGIN_TYPE_MEDIA (pidgin_media_get_type()) 47 #define PIDGIN_TYPE_MEDIA (pidgin_media_get_type())
44 #define PIDGIN_MEDIA(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PIDGIN_TYPE_MEDIA, PidginMedia)) 48 #define PIDGIN_MEDIA(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PIDGIN_TYPE_MEDIA, PidginMedia))
45 #define PIDGIN_MEDIA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PIDGIN_TYPE_MEDIA, PidginMediaClass)) 49 #define PIDGIN_MEDIA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PIDGIN_TYPE_MEDIA, PidginMediaClass))
211 purple_media_stream_info(media->priv->media, 215 purple_media_stream_info(media->priv->media,
212 PURPLE_MEDIA_INFO_HANGUP, NULL, NULL, TRUE); 216 PURPLE_MEDIA_INFO_HANGUP, NULL, NULL, TRUE);
213 return FALSE; 217 return FALSE;
214 } 218 }
215 219
220 #ifdef HAVE_X11
216 static int 221 static int
217 pidgin_x_error_handler(Display *display, XErrorEvent *event) 222 pidgin_x_error_handler(Display *display, XErrorEvent *event)
218 { 223 {
219 const gchar *error_type; 224 const gchar *error_type;
220 switch (event->error_code) { 225 switch (event->error_code) {
244 purple_debug_error("media", "A %s Xlib error has occurred. " 249 purple_debug_error("media", "A %s Xlib error has occurred. "
245 "The program would normally crash now.\n", 250 "The program would normally crash now.\n",
246 error_type); 251 error_type);
247 return 0; 252 return 0;
248 } 253 }
254 #endif
249 255
250 static void 256 static void
251 menu_hangup(gpointer data, guint action, GtkWidget *item) 257 menu_hangup(gpointer data, guint action, GtkWidget *item)
252 { 258 {
253 PidginMedia *gtkmedia = PIDGIN_MEDIA(data); 259 PidginMedia *gtkmedia = PIDGIN_MEDIA(data);
301 pidgin_media_init (PidginMedia *media) 307 pidgin_media_init (PidginMedia *media)
302 { 308 {
303 GtkWidget *vbox; 309 GtkWidget *vbox;
304 media->priv = PIDGIN_MEDIA_GET_PRIVATE(media); 310 media->priv = PIDGIN_MEDIA_GET_PRIVATE(media);
305 311
312 #ifdef HAVE_X11
306 XSetErrorHandler(pidgin_x_error_handler); 313 XSetErrorHandler(pidgin_x_error_handler);
314 #endif
307 315
308 vbox = gtk_vbox_new(FALSE, 0); 316 vbox = gtk_vbox_new(FALSE, 0);
309 gtk_container_add(GTK_CONTAINER(media), vbox); 317 gtk_container_add(GTK_CONTAINER(media), vbox);
310 318
311 media->priv->statusbar = gtk_statusbar_new(); 319 media->priv->statusbar = gtk_statusbar_new();
448 realize_cb_cb(PidginMediaRealizeData *data) 456 realize_cb_cb(PidginMediaRealizeData *data)
449 { 457 {
450 PidginMediaPrivate *priv = data->gtkmedia->priv; 458 PidginMediaPrivate *priv = data->gtkmedia->priv;
451 gulong window_id; 459 gulong window_id;
452 460
461 #ifdef _WIN32
462 if (data->participant == NULL)
463 window_id = GDK_WINDOW_HWND(priv->local_video->window);
464 else
465 window_id = GDK_WINDOW_HWND(priv->remote_video->window);
466 #elif defined(HAVE_X11)
453 if (data->participant == NULL) 467 if (data->participant == NULL)
454 window_id = GDK_WINDOW_XWINDOW(priv->local_video->window); 468 window_id = GDK_WINDOW_XWINDOW(priv->local_video->window);
455 else 469 else
456 window_id = GDK_WINDOW_XWINDOW(priv->remote_video->window); 470 window_id = GDK_WINDOW_XWINDOW(priv->remote_video->window);
471 #else
472 # error "Unsupported windowing system"
473 #endif
457 474
458 purple_media_set_output_window(priv->media, data->session_id, 475 purple_media_set_output_window(priv->media, data->session_id,
459 data->participant, window_id); 476 data->participant, window_id);
460 477
461 g_free(data->session_id); 478 g_free(data->session_id);