[gtk+] Add gdk_display_manager_peek
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Add gdk_display_manager_peek
- Date: Sat, 23 Mar 2013 23:43:16 +0000 (UTC)
commit c5d7871edae195b7d7f035ed46449b5e8fa5073f
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Mar 23 19:39:58 2013 -0400
Add gdk_display_manager_peek
Instead of failing with an error if no GDK backend is found like
gdk_display_manager_get(), the new peek function silently returns
NULL.
docs/reference/gdk/gdk3-sections.txt | 1 +
gdk/gdk.symbols | 1 +
gdk/gdkdisplaymanager.c | 29 +++++++++++++++++++++++------
gdk/gdkdisplaymanager.h | 2 ++
4 files changed, 27 insertions(+), 6 deletions(-)
---
diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt
index e409bbc..34069e4 100644
--- a/docs/reference/gdk/gdk3-sections.txt
+++ b/docs/reference/gdk/gdk3-sections.txt
@@ -171,6 +171,7 @@ GdkDisplayClass
<TITLE>GdkDisplayManager</TITLE>
GdkDisplayManager
gdk_display_manager_get
+gdk_display_manager_peek
gdk_display_manager_get_default_display
gdk_display_manager_set_default_display
gdk_display_manager_list_displays
diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols
index 6e30e9a..9eb67cc 100644
--- a/gdk/gdk.symbols
+++ b/gdk/gdk.symbols
@@ -101,6 +101,7 @@ gdk_display_is_closed
gdk_display_keyboard_ungrab
gdk_display_list_devices
gdk_display_manager_get
+gdk_display_manager_peek
gdk_display_manager_get_default_display
gdk_display_manager_get_type
gdk_display_manager_list_displays
diff --git a/gdk/gdkdisplaymanager.c b/gdk/gdkdisplaymanager.c
index b15aeb0..2d2e684 100644
--- a/gdk/gdkdisplaymanager.c
+++ b/gdk/gdkdisplaymanager.c
@@ -289,6 +289,29 @@ static GdkDisplayManager *manager = NULL;
GdkDisplayManager*
gdk_display_manager_get (void)
{
+ gdk_display_manager_peek ();
+
+ if (manager == NULL)
+ g_error ("No GDK backend found (%s)", allowed_backends);
+
+ return manager;
+}
+
+/**
+ * gdk_display_manager_peek:
+ *
+ * Gets the singleton #GdkDisplayManager object. If GDK could
+ * not be initialized, %NULL is returned.
+ *
+ * Returns: (transfer none): The global #GdkDisplayManager singleton,
+ * or %NULL if GDK could not be initialized. gdk_parse_args(),
+ * gdk_init(), or gdk_init_check() must have been called first
+ *
+ * Since: 3.10
+ */
+GdkDisplayManager *
+gdk_display_manager_peek (void)
+{
if (manager == NULL)
{
const gchar *backend_list;
@@ -369,13 +392,7 @@ gdk_display_manager_get (void)
}
#endif
}
-
g_strfreev (backends);
-
- if (manager == NULL)
- g_error ("No GDK backend found (%s)", allowed_backends);
-
- GDK_NOTE (MISC, if (manager) g_message ("Using %s", G_OBJECT_TYPE_NAME (manager)));
}
return manager;
diff --git a/gdk/gdkdisplaymanager.h b/gdk/gdkdisplaymanager.h
index 419b3f5..4392af0 100644
--- a/gdk/gdkdisplaymanager.h
+++ b/gdk/gdkdisplaymanager.h
@@ -43,6 +43,8 @@ G_BEGIN_DECLS
GType gdk_display_manager_get_type (void) G_GNUC_CONST;
GdkDisplayManager *gdk_display_manager_get (void);
+GDK_AVAILABLE_IN_3_10
+GdkDisplayManager *gdk_display_manager_peek (void);
GdkDisplay * gdk_display_manager_get_default_display (GdkDisplayManager *manager);
void gdk_display_manager_set_default_display (GdkDisplayManager *manager,
GdkDisplay *display);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]