[gnome-initial-setup/wip/pwithnall/misc-fixes: 34/70] keyboard: manually pass locale to gkbd-keyboard-display
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup/wip/pwithnall/misc-fixes: 34/70] keyboard: manually pass locale to gkbd-keyboard-display
- Date: Fri, 11 Sep 2020 13:29:13 +0000 (UTC)
commit 53fd682f7be5ab79935c16a327d53fc5fa94134a
Author: Alessandro Puccetti <alessandro kinvolk io>
Date: Tue Jun 13 11:52:30 2017 +0200
keyboard: manually pass locale to gkbd-keyboard-display
(Ported to use cc_common_language_get_current_language() instead of
setlocale() in the 3.34 rebase.)
(Rebase 3.38: This could potentially be dropped in future if we update
cc-input-chooser.c from gnome-control-center; it’s copy/paste code.)
https://phabricator.endlessm.com/T17304
.../pages/keyboard/cc-input-chooser.c | 48 ++++++++++++++++++++--
1 file changed, 44 insertions(+), 4 deletions(-)
---
diff --git a/gnome-initial-setup/pages/keyboard/cc-input-chooser.c
b/gnome-initial-setup/pages/keyboard/cc-input-chooser.c
index 0d68dfb2..5f5d40df 100644
--- a/gnome-initial-setup/pages/keyboard/cc-input-chooser.c
+++ b/gnome-initial-setup/pages/keyboard/cc-input-chooser.c
@@ -46,6 +46,8 @@
#define MIN_ROWS 5
+#define GKBD_KEYBOARD_DISPLAY_CMD "/usr/bin/gkbd-keyboard-display"
+
struct _CcInputChooserPrivate
{
GtkWidget *filter_entry;
@@ -169,6 +171,16 @@ preview_cb (GtkLabel *label,
const gchar *layout;
const gchar *variant;
gchar *commandline;
+ gint argc;
+ gchar **argv = NULL;
+ gchar **env;
+ GError *error = NULL;
+ GPid pid;
+
+ g_autofree gchar *lc_msg = cc_common_language_get_current_language ();
+
+ env = g_get_environ ();
+ env = g_environ_setenv (env, "LC_MESSAGES", lc_msg, TRUE);
row = gtk_widget_get_parent (GTK_WIDGET (label));
widget = get_input_widget (row);
@@ -177,12 +189,40 @@ preview_cb (GtkLabel *label,
return TRUE;
if (variant[0])
- commandline = g_strdup_printf ("gkbd-keyboard-display -l \"%s\t%s\"", layout, variant);
+ commandline = g_strdup_printf (GKBD_KEYBOARD_DISPLAY_CMD" -l \"%s\t%s\"", layout, variant);
else
- commandline = g_strdup_printf ("gkbd-keyboard-display -l %s", layout);
- g_spawn_command_line_async (commandline, NULL);
- g_free (commandline);
+ commandline = g_strdup_printf (GKBD_KEYBOARD_DISPLAY_CMD" -l %s", layout);
+ g_shell_parse_argv (commandline,
+ &argc,
+ &argv,
+ &error);
+
+ if (error) {
+ g_critical ("Error parsing gkbd-keyboard-display command: %s", error->message);
+ g_clear_error (&error);
+ goto out;
+ }
+
+ g_spawn_async (NULL,
+ argv,
+ env,
+ G_SPAWN_DEFAULT,
+ NULL,
+ NULL,
+ &pid,
+ &error);
+
+ if (error) {
+ g_critical ("Error running gkbd-keyboard-display: %s", error->message);
+ g_clear_error (&error);
+ goto out;
+ }
+
+out:
+ g_strfreev (env);
+ g_strfreev (argv);
+ g_free (commandline);
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]