Merge branch 'matthiasc/for-main' into 'main'

gdk: Improve logging for backends

Closes #5704

See merge request GNOME/gtk!5737
This commit is contained in:
Matthias Clasen 2023-03-28 10:19:31 +00:00
commit db9883584d
3 changed files with 37 additions and 27 deletions

View File

@ -60,7 +60,11 @@ GdkDebugFlags gdk_display_get_debug_flags (GdkDisplay *display);
void gdk_display_set_debug_flags (GdkDisplay *display,
GdkDebugFlags flags);
#ifdef GLIB_USING_SYSTEM_PRINTF
#define gdk_debug_message(format, ...) fprintf (stderr, format "\n", ##__VA_ARGS__)
#else
#define gdk_debug_message(format, ...) g_fprintf (stderr, format "\n", ##__VA_ARGS__)
#endif
#ifdef G_ENABLE_DEBUG

View File

@ -410,12 +410,19 @@ gdk_display_manager_open_display (GdkDisplayManager *manager,
{
const char *backend = backends[i];
gboolean any = g_str_equal (backend, "*");
gboolean found = FALSE;
if (!allow_any && !any && !strstr (allowed_backends, backend))
continue;
{
GDK_DEBUG (MISC, "Skipping %s backend", backend);
continue;
}
for (j = 0; gdk_backends[j].name != NULL; j++)
{
if (g_str_equal (backend, gdk_backends[j].name))
found = TRUE;
if ((any && allow_any) ||
(any && strstr (allowed_backends, gdk_backends[j].name)) ||
g_str_equal (backend, gdk_backends[j].name))
@ -423,9 +430,15 @@ gdk_display_manager_open_display (GdkDisplayManager *manager,
GDK_DEBUG (MISC, "Trying %s backend", gdk_backends[j].name);
display = gdk_backends[j].open_display (name);
if (display)
break;
{
GDK_DEBUG (MISC, "Using %s display %s", gdk_backends[j].name, gdk_display_get_name (display));
break;
}
}
}
if (!found && !display)
g_warning ("No such backend: %s", backend);
}
g_strfreev (backends);

View File

@ -634,34 +634,29 @@ gtk_init_check (void)
* gtk_init:
*
* Call this function before using any other GTK functions in your GUI
* applications. It will initialize everything needed to operate the
* applications. It will initialize everything needed to operate the
* toolkit.
*
* If you are using `GtkApplication`, you don't have to call gtk_init()
* or gtk_init_check(); the `GApplication::startup` handler
* does it for you.
* If you are using `GtkApplication`, you don't have to call this
* function; the `GApplication::startup` handler does it for you.
*
* This function will terminate your program if it was unable to
* initialize the windowing system for some reason. If you want
* your program to fall back to a textual interface you want to
* call gtk_init_check() instead.
* your program to fall back to a textual interface, call
* [func@Gtk.init_check] instead.
*
* GTK calls `signal (SIGPIPE, SIG_IGN)`
* during initialization, to ignore SIGPIPE signals, since these are
* almost never wanted in graphical applications. If you do need to
* handle SIGPIPE for some reason, reset the handler after gtk_init(),
* but notice that other libraries (e.g. libdbus or gvfs) might do
* similar things.
* GTK calls `signal (SIGPIPE, SIG_IGN)` during initialization, to ignore
* SIGPIPE signals, since these are almost never wanted in graphical
* applications. If you do need to handle SIGPIPE for some reason, reset
* the handler after gtk_init(), but notice that other libraries (e.g.
* libdbus or gvfs) might do similar things.
*/
void
gtk_init (void)
{
if (!gtk_init_check ())
{
const char *display_name_arg;
display_name_arg = getenv ("DISPLAY");
g_warning ("cannot open display: %s", display_name_arg ? display_name_arg : "");
g_warning ("Failed to open display");
exit (1);
}
}
@ -731,8 +726,9 @@ gtk_init_check_abi_check (int num_checks, size_t sizeof_GtkWindow, size_t sizeof
/**
* gtk_is_initialized:
*
* Use this function to check if GTK has been initialized with gtk_init()
* or gtk_init_check().
* Use this function to check if GTK has been initialized.
*
* See [func@Gtk.init].
*
* Returns: the initialization status
*/
@ -769,12 +765,11 @@ gtk_is_initialized (void)
* update_locale (const char *new_locale)
* {
* setlocale (LC_ALL, new_locale);
* GtkTextDirection direction = gtk_get_locale_direction ();
* gtk_widget_set_default_direction (direction);
* gtk_widget_set_default_direction (gtk_get_locale_direction ());
* }
* ]|
*
* Returns: the `GtkTextDirection` of the current locale
* Returns: the direction of the current locale
*/
GtkTextDirection
gtk_get_locale_direction (void)
@ -825,12 +820,10 @@ gtk_get_locale_direction (void)
* locale. It determines, for example, whether GTK uses
* the right-to-left or left-to-right text direction.
*
* This function is equivalent to
* [func@Pango.Language.get_default].
* This function is equivalent to [func@Pango.Language.get_default].
* See that function for details.
*
* Returns: (transfer none): the default language as a
* `PangoLanguage`
* Returns: (transfer none): the default language
*/
PangoLanguage *
gtk_get_default_language (void)