glib: Add support for GNOME Console

GNOME Console (aka King’s Cross) is the default terminal emulator in GNOME 42.
Let’s make GLib aware of it so that apps relying on it (e.g. GNOME Shell)
can launch terminal apps like htop.

This is a downstream patch since GLib does not want to add any more
terminal emulators: https://gitlab.gnome.org/GNOME/glib/-/issues/2618

+59
+4
pkgs/development/libraries/glib/default.nix
··· 69 69 ./glib-appinfo-watch.patch 70 70 ./schema-override-variable.patch 71 71 72 + # Add support for the GNOME’s default terminal emulator. 73 + # https://gitlab.gnome.org/GNOME/glib/-/issues/2618 74 + ./gnome-console-support.patch 75 + 72 76 # GLib contains many binaries used for different purposes; 73 77 # we will install them to different outputs: 74 78 # 1. Tools for desktop environment ($bin)
+55
pkgs/development/libraries/glib/gnome-console-support.patch
··· 1 + diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c 2 + index 60d6debb2..a441bfec9 100644 3 + --- a/gio/gdesktopappinfo.c 4 + +++ b/gio/gdesktopappinfo.c 5 + @@ -2627,6 +2627,7 @@ prepend_terminal_to_vector (int *argc, 6 + int i, j; 7 + char **term_argv = NULL; 8 + int term_argc = 0; 9 + + gboolean pass_cmd_as_single_arg = FALSE; 10 + char *check; 11 + char **the_argv; 12 + 13 + @@ -2672,6 +2673,11 @@ prepend_terminal_to_vector (int *argc, 14 + } 15 + else 16 + { 17 + + if (check == NULL) { 18 + + check = g_find_program_in_path ("kgx"); 19 + + if (check != NULL) 20 + + pass_cmd_as_single_arg = TRUE; 21 + + } 22 + if (check == NULL) 23 + check = g_find_program_in_path ("tilix"); 24 + if (check == NULL) 25 + @@ -2697,14 +2703,27 @@ prepend_terminal_to_vector (int *argc, 26 + } 27 + } 28 + 29 + - real_argc = term_argc + *argc; 30 + + real_argc = term_argc + (pass_cmd_as_single_arg ? 1 : *argc); 31 + real_argv = g_new (char *, real_argc + 1); 32 + 33 + for (i = 0; i < term_argc; i++) 34 + real_argv[i] = term_argv[i]; 35 + 36 + - for (j = 0; j < *argc; j++, i++) 37 + - real_argv[i] = (char *)the_argv[j]; 38 + + if (pass_cmd_as_single_arg) { 39 + + char **quoted_argv = g_new (char *, *argc + 1); 40 + + 41 + + for (j = 0; j < *argc; j++) { 42 + + quoted_argv[j] = g_shell_quote (the_argv[j]); 43 + + g_free (the_argv[j]); 44 + + } 45 + + quoted_argv[j] = NULL; 46 + + 47 + + real_argv[i++] = g_strjoinv (" ", quoted_argv); 48 + + g_strfreev (quoted_argv); 49 + + } else { 50 + + for (j = 0; j < *argc; j++, i++) 51 + + real_argv[i] = (char *)the_argv[j]; 52 + + } 53 + 54 + real_argv[i] = NULL; 55 +