mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 01:20:42 -05:00
util: Guard against older zenity versions
Plenty of ugly here, but it works; revert when the zenity version we depend on stops being bleeding-edge (or we can assume a zenity version that does not error out on unknown options). https://bugzilla.gnome.org/show_bug.cgi?id=684306
This commit is contained in:
parent
ae1be578ba
commit
5eb72743dd
@ -555,6 +555,23 @@ meta_gravity_to_string (int gravity)
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
zenity_supports_option (const char *section, const char *option)
|
||||
{
|
||||
char *command, *out;
|
||||
gboolean rv;
|
||||
|
||||
command = g_strdup_printf ("zenity %s", section);
|
||||
g_spawn_command_line_sync (command, &out, NULL, NULL, NULL);
|
||||
|
||||
rv = (out && strstr (out, option));
|
||||
|
||||
g_free (command);
|
||||
g_free (out);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* 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
|
||||
@ -627,10 +644,15 @@ meta_show_dialog (const char *type,
|
||||
}
|
||||
|
||||
if (icon_name)
|
||||
{
|
||||
char *option = g_strdup_printf ("--help%s", type + 1);
|
||||
if (zenity_supports_option (option, "--icon-name"))
|
||||
{
|
||||
append_argument (args, "--icon-name");
|
||||
append_argument (args, icon_name);
|
||||
}
|
||||
g_free (option);
|
||||
}
|
||||
|
||||
tmp = columns;
|
||||
while (tmp)
|
||||
@ -653,6 +675,7 @@ meta_show_dialog (const char *type,
|
||||
setenv ("WINDOWID", env, 1);
|
||||
g_free (env);
|
||||
|
||||
if (zenity_supports_option ("--help-general", "--modal"))
|
||||
append_argument (args, "--modal");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user