Commit c5d7871e authored by Matthias Clasen's avatar Matthias Clasen

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.
parent 97ebaee0
......@@ -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
......
......@@ -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
......
......@@ -288,6 +288,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)
{
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment