[gtk+] gdk: Implement GInitable on GdkDisplayManager
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gdk: Implement GInitable on GdkDisplayManager
- Date: Sat, 23 Mar 2013 04:48:02 +0000 (UTC)
commit 3a9de35a6cefddc09aaf000e523f3435a955a5e7
Author: Thomas Wood <thomas wood intel com>
Date: Fri Feb 22 16:41:12 2013 +0000
gdk: Implement GInitable on GdkDisplayManager
Add GInitable interface with a default implementation that always
succeeds. This allows backends to override the GInitable implementation
and add their own checks to determine if the backend can be loaded. If
a backend cannot be loaded, GDK can attempt to load the next available
backend.
Since backends may need to read any relevant options (such as the
display flag) to determine if they can be created successfully, this
patch also removes calls that attempt to create the display manager
before the options have been parsed.
https://bugzilla.gnome.org/show_bug.cgi?id=694465
gdk/gdk.c | 3 --
gdk/gdkdisplaymanager.c | 53 ++++++++++++++++++++++++++++++----------------
2 files changed, 34 insertions(+), 22 deletions(-)
---
diff --git a/gdk/gdk.c b/gdk/gdk.c
index 437ecf9..5d0dc1c 100644
--- a/gdk/gdk.c
+++ b/gdk/gdk.c
@@ -275,9 +275,6 @@ gdk_pre_parse_libgtk_only (void)
else if (g_str_equal (rendering_mode, "recording"))
_gdk_rendering_mode = GDK_RENDERING_MODE_RECORDING;
}
-
- /* Do any setup particular to the windowing system */
- gdk_display_manager_get ();
}
diff --git a/gdk/gdkdisplaymanager.c b/gdk/gdkdisplaymanager.c
index 0a0ee85..f470611 100644
--- a/gdk/gdkdisplaymanager.c
+++ b/gdk/gdkdisplaymanager.c
@@ -125,7 +125,24 @@ static void gdk_display_manager_get_property (GObject *object,
static guint signals[LAST_SIGNAL] = { 0 };
-G_DEFINE_TYPE (GdkDisplayManager, gdk_display_manager, G_TYPE_OBJECT)
+static void g_initable_iface_init (GInitableIface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (GdkDisplayManager, gdk_display_manager, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, g_initable_iface_init))
+
+static gboolean
+gdk_display_manager_initable_init (GInitable *initable,
+ GCancellable *cancellable,
+ GError **error)
+{
+ return TRUE;
+}
+
+static void
+g_initable_iface_init (GInitableIface *iface)
+{
+ iface->init = gdk_display_manager_initable_init;
+}
static void
gdk_display_manager_class_init (GdkDisplayManagerClass *klass)
@@ -236,33 +253,31 @@ gdk_display_manager_get (void)
backend = g_getenv ("GDK_BACKEND");
#ifdef GDK_WINDOWING_QUARTZ
if (backend == NULL || strcmp (backend, "quartz") == 0)
- manager = g_object_new (gdk_quartz_display_manager_get_type (), NULL);
- else
+ manager = g_initable_new (gdk_quartz_display_manager_get_type (), NULL, NULL, NULL);
#endif
#ifdef GDK_WINDOWING_WIN32
- if (backend == NULL || strcmp (backend, "win32") == 0)
- manager = g_object_new (gdk_win32_display_manager_get_type (), NULL);
- else
+ if (!manager && (backend == NULL || strcmp (backend, "win32") == 0))
+ manager = g_initable_new (gdk_win32_display_manager_get_type (), NULL, NULL, NULL);
#endif
#ifdef GDK_WINDOWING_X11
- if (backend == NULL || strcmp (backend, "x11") == 0)
- manager = g_object_new (gdk_x11_display_manager_get_type (), NULL);
- else
+ if (!manager && (backend == NULL || strcmp (backend, "x11") == 0))
+ manager = g_initable_new (gdk_x11_display_manager_get_type (), NULL, NULL, NULL);
#endif
#ifdef GDK_WINDOWING_WAYLAND
- if (backend == NULL || strcmp (backend, "wayland") == 0)
- manager = g_object_new (gdk_wayland_display_manager_get_type (), NULL);
- else
+ if (!manager && (backend == NULL || strcmp (backend, "wayland") == 0))
+ manager = g_initable_new (gdk_wayland_display_manager_get_type (), NULL, NULL, NULL);
#endif
#ifdef GDK_WINDOWING_BROADWAY
- if (backend == NULL || strcmp (backend, "broadway") == 0)
- manager = g_object_new (gdk_broadway_display_manager_get_type (), NULL);
- else
+ if (!manager && (backend == NULL || strcmp (backend, "broadway") == 0))
+ manager = g_initable_new (gdk_broadway_display_manager_get_type (), NULL, NULL, NULL);
#endif
- if (backend != NULL)
- g_error ("Unsupported GDK backend: %s", backend);
- else
- g_error ("No GDK backend found");
+ if (!manager)
+ {
+ if (backend != NULL)
+ g_error ("Unsupported GDK backend: %s", backend);
+ else
+ g_error ("No GDK backend found");
+ }
}
return manager;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]