[gimp] Add some #if GTK_CHECK_VERSION (2, 24, 0) for creating foreign window
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Add some #if GTK_CHECK_VERSION (2, 24, 0) for creating foreign window
- Date: Wed, 16 Feb 2011 21:52:25 +0000 (UTC)
commit 8333dfde7b1fa3150bf49e938c1f11c987b911d3
Author: Michael Natterer <mitch gimp org>
Date: Wed Feb 16 22:51:02 2011 +0100
Add some #if GTK_CHECK_VERSION (2, 24, 0) for creating foreign window
so we don't use deprecated API and make the gtk3 port simpler.
app/widgets/gimpwidgets-utils.c | 31 ++++++++++++++++++++++--
libgimp/gimpui.c | 49 +++++++++++++++++++++++++++++++--------
2 files changed, 67 insertions(+), 13 deletions(-)
---
diff --git a/app/widgets/gimpwidgets-utils.c b/app/widgets/gimpwidgets-utils.c
index 3fe934f..9a607db 100644
--- a/app/widgets/gimpwidgets-utils.c
+++ b/app/widgets/gimpwidgets-utils.c
@@ -865,6 +865,33 @@ gimp_window_transient_realized (GtkWidget *window,
}
/* similar to what we have in libgimp/gimpui.c */
+static GdkWindow *
+gimp_get_foreign_window (guint32 window)
+{
+#if GTK_CHECK_VERSION (2, 24, 0)
+
+#ifdef GDK_WINDOWING_X11
+ return gdk_x11_window_foreign_new_for_display (gdk_display_get_default (),
+ window);
+#endif
+
+#ifdef GDK_WINDOWING_WIN32
+ return gdk_win32_window_foreign_new_for_display (gdk_display_get_default (),
+ window);
+#endif
+
+#else /* ! GTK_CHECK_VERSION (2, 24, 0) */
+
+#ifndef GDK_NATIVE_WINDOW_POINTER
+ return gdk_window_foreign_new_for_display (gdk_display_get_default (),
+ window);
+#endif
+
+#endif /* GTK_CHECK_VERSION (2, 24, 0) */
+
+ return NULL;
+}
+
void
gimp_window_set_transient_for (GtkWindow *window,
guint32 parent_ID)
@@ -879,9 +906,7 @@ gimp_window_set_transient_for (GtkWindow *window,
#ifndef GDK_WINDOWING_WIN32
GdkWindow *parent;
- parent = gdk_window_foreign_new_for_display (gdk_display_get_default (),
- parent_ID);
-
+ parent = gimp_get_foreign_window (parent_ID);
if (! parent)
return;
diff --git a/libgimp/gimpui.c b/libgimp/gimpui.c
index 066b63d..2f5d0aa 100644
--- a/libgimp/gimpui.c
+++ b/libgimp/gimpui.c
@@ -20,6 +20,14 @@
#include <gtk/gtk.h>
+#ifdef GDK_WINDOWING_WIN32
+#include <gdk/gdkwin32.h>
+#endif
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h>
+#endif
+
#include "libgimpmodule/gimpmodule.h"
#include "gimp.h"
@@ -138,6 +146,33 @@ gimp_ui_init (const gchar *prog_name,
gimp_ui_initialized = TRUE;
}
+static GdkWindow *
+gimp_ui_get_foreign_window (guint32 window)
+{
+#if GTK_CHECK_VERSION (2, 24, 0)
+
+#ifdef GDK_WINDOWING_X11
+ return gdk_x11_window_foreign_new_for_display (gdk_display_get_default (),
+ window);
+#endif
+
+#ifdef GDK_WINDOWING_WIN32
+ return gdk_win32_window_foreign_new_for_display (gdk_display_get_default (),
+ window);
+#endif
+
+#else /* ! GTK_CHECK_VERSION (2, 24, 0) */
+
+#ifndef GDK_NATIVE_WINDOW_POINTER
+ return gdk_window_foreign_new_for_display (gdk_display_get_default (),
+ window);
+#endif
+
+#endif /* GTK_CHECK_VERSION (2, 24, 0) */
+
+ return NULL;
+}
+
/**
* gimp_ui_get_display_window:
* @gdisp_ID: a #GimpDisplay ID.
@@ -158,16 +193,13 @@ gimp_ui_init (const gchar *prog_name,
GdkWindow *
gimp_ui_get_display_window (guint32 gdisp_ID)
{
-#ifndef GDK_NATIVE_WINDOW_POINTER
- GdkNativeWindow window;
+ guint32 window;
g_return_val_if_fail (gimp_ui_initialized, NULL);
window = gimp_display_get_window_handle (gdisp_ID);
if (window)
- return gdk_window_foreign_new_for_display (gdk_display_get_default (),
- window);
-#endif
+ return gimp_ui_get_foreign_window (window);
return NULL;
}
@@ -191,16 +223,13 @@ gimp_ui_get_display_window (guint32 gdisp_ID)
GdkWindow *
gimp_ui_get_progress_window (void)
{
-#ifndef GDK_NATIVE_WINDOW_POINTER
- GdkNativeWindow window;
+ guint32 window;
g_return_val_if_fail (gimp_ui_initialized, NULL);
window = gimp_progress_get_window_handle ();
if (window)
- return gdk_window_foreign_new_for_display (gdk_display_get_default (),
- window);
-#endif
+ return gimp_ui_get_foreign_window (window);
return NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]