meta_show_dialog: fix encoding of command line arguments
Command line arguments are supposed to be in the locale encoding, not UTF-8, and Zenity decodes command line string command line arguments with this assumption using GOption. There was a half-hearted attempt to deal with this in delete.c, but it wasn't correct since it immediately mixed the window title, converted to the locale encoding with a UTF-8 message. https://bugzilla.gnome.org/show_bug.cgi?id=649114
This commit is contained in:
parent
d9007a08c9
commit
40f51114b5
@ -88,7 +88,15 @@ delete_ping_timeout_func (MetaDisplay *display,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
window_title = g_locale_from_utf8 (window->title, -1, NULL, NULL, NULL);
|
/* This is to get a bit better string if the title isn't representable
|
||||||
|
* in the locale encoding; actual conversion to UTF-8 is done inside
|
||||||
|
* meta_show_dialog */
|
||||||
|
tmp = g_locale_from_utf8 (window->title, -1, NULL, NULL, NULL);
|
||||||
|
if (tmp == NULL)
|
||||||
|
window_title = "???";
|
||||||
|
else
|
||||||
|
window_title = window->title;
|
||||||
|
g_free (tmp);
|
||||||
|
|
||||||
/* Translators: %s is a window title */
|
/* Translators: %s is a window title */
|
||||||
tmp = g_strdup_printf (_("<tt>%s</tt> is not responding."),
|
tmp = g_strdup_printf (_("<tt>%s</tt> is not responding."),
|
||||||
@ -99,8 +107,6 @@ delete_ping_timeout_func (MetaDisplay *display,
|
|||||||
_("You may choose to wait a short while for it to "
|
_("You may choose to wait a short while for it to "
|
||||||
"continue or force the application to quit entirely."));
|
"continue or force the application to quit entirely."));
|
||||||
|
|
||||||
g_free (window_title);
|
|
||||||
|
|
||||||
dialog_pid =
|
dialog_pid =
|
||||||
meta_show_dialog ("--question",
|
meta_show_dialog ("--question",
|
||||||
window_content, NULL,
|
window_content, NULL,
|
||||||
|
@ -584,6 +584,25 @@ meta_gravity_to_string (int gravity)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Command line arguments are passed in the locale encoding; in almost
|
||||||
|
* all cases, we'd hope that is UTF-8 and no conversion is necessary.
|
||||||
|
* If it's not UTF-8, then it's possible that the message isn't
|
||||||
|
* representable in the locale encoding.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
append_argument (GPtrArray *args,
|
||||||
|
const char *arg)
|
||||||
|
{
|
||||||
|
char *locale_arg = g_locale_from_utf8 (arg, -1, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
/* This is cheesy, but it's better to have a few ???'s in the dialog
|
||||||
|
* for an unresponsive application than no dialog at all appear */
|
||||||
|
if (!locale_arg)
|
||||||
|
locale_arg = g_strdup ("???");
|
||||||
|
|
||||||
|
g_ptr_array_add (args, locale_arg);
|
||||||
|
}
|
||||||
|
|
||||||
GPid
|
GPid
|
||||||
meta_show_dialog (const char *type,
|
meta_show_dialog (const char *type,
|
||||||
const char *message,
|
const char *message,
|
||||||
@ -597,59 +616,57 @@ meta_show_dialog (const char *type,
|
|||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
int i=0;
|
|
||||||
GPid child_pid;
|
GPid child_pid;
|
||||||
const char **argvl = g_malloc(sizeof (char*) *
|
GPtrArray *args;
|
||||||
(17 +
|
|
||||||
g_slist_length (columns)*2 +
|
|
||||||
g_slist_length (entries)));
|
|
||||||
|
|
||||||
argvl[i++] = "zenity";
|
args = g_ptr_array_new ();
|
||||||
argvl[i++] = type;
|
|
||||||
argvl[i++] = "--display";
|
append_argument (args, "zenity");
|
||||||
argvl[i++] = display;
|
append_argument (args, type);
|
||||||
argvl[i++] = "--class";
|
append_argument (args, "--display");
|
||||||
argvl[i++] = "mutter-dialog";
|
append_argument (args, display);
|
||||||
argvl[i++] = "--title";
|
append_argument (args, "--class");
|
||||||
|
append_argument (args, "mutter-dialog");
|
||||||
|
append_argument (args, "--title");
|
||||||
/* Translators: This is the title used on dialog boxes */
|
/* Translators: This is the title used on dialog boxes */
|
||||||
argvl[i++] = _("Mutter");
|
append_argument (args, _("Mutter"));
|
||||||
argvl[i++] = "--text";
|
append_argument (args, "--text");
|
||||||
argvl[i++] = message;
|
append_argument (args, message);
|
||||||
|
|
||||||
if (timeout)
|
if (timeout)
|
||||||
{
|
{
|
||||||
argvl[i++] = "--timeout";
|
append_argument (args, "--timeout");
|
||||||
argvl[i++] = timeout;
|
append_argument (args, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ok_text)
|
if (ok_text)
|
||||||
{
|
{
|
||||||
argvl[i++] = "--ok-label";
|
append_argument (args, "--ok-label");
|
||||||
argvl[i++] = ok_text;
|
append_argument (args, ok_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cancel_text)
|
if (cancel_text)
|
||||||
{
|
{
|
||||||
argvl[i++] = "--cancel-label";
|
append_argument (args, "--cancel-label");
|
||||||
argvl[i++] = cancel_text;
|
append_argument (args, cancel_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = columns;
|
tmp = columns;
|
||||||
while (tmp)
|
while (tmp)
|
||||||
{
|
{
|
||||||
argvl[i++] = "--column";
|
append_argument (args, "--column");
|
||||||
argvl[i++] = tmp->data;
|
append_argument (args, tmp->data);
|
||||||
tmp = tmp->next;
|
tmp = tmp->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = entries;
|
tmp = entries;
|
||||||
while (tmp)
|
while (tmp)
|
||||||
{
|
{
|
||||||
argvl[i++] = tmp->data;
|
append_argument (args, tmp->data);
|
||||||
tmp = tmp->next;
|
tmp = tmp->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
argvl[i] = NULL;
|
g_ptr_array_add (args, NULL); /* NULL-terminate */
|
||||||
|
|
||||||
if (transient_for)
|
if (transient_for)
|
||||||
{
|
{
|
||||||
@ -660,7 +677,7 @@ meta_show_dialog (const char *type,
|
|||||||
|
|
||||||
g_spawn_async (
|
g_spawn_async (
|
||||||
"/",
|
"/",
|
||||||
(gchar**) argvl, /* ugh */
|
(gchar**) args->pdata,
|
||||||
NULL,
|
NULL,
|
||||||
G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
|
G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
@ -671,7 +688,7 @@ meta_show_dialog (const char *type,
|
|||||||
if (transient_for)
|
if (transient_for)
|
||||||
unsetenv ("WINDOWID");
|
unsetenv ("WINDOWID");
|
||||||
|
|
||||||
g_free (argvl);
|
g_ptr_array_free (args, TRUE);
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user