[mutter] util: Guard against older zenity versions
- From: Florian MÃllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] util: Guard against older zenity versions
- Date: Wed, 19 Sep 2012 13:15:08 +0000 (UTC)
commit 5eb72743dd8fd2b34dda6b20ee7acaa3a24bbdb0
Author: Florian MÃllner <fmuellner gnome org>
Date: Wed Sep 19 14:29:06 2012 +0200
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
src/core/util.c | 29 ++++++++++++++++++++++++++---
1 files changed, 26 insertions(+), 3 deletions(-)
---
diff --git a/src/core/util.c b/src/core/util.c
index efb87aa..0ab87bb 100644
--- a/src/core/util.c
+++ b/src/core/util.c
@@ -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
@@ -628,8 +645,13 @@ meta_show_dialog (const char *type,
if (icon_name)
{
- append_argument (args, "--icon-name");
- append_argument (args, 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;
@@ -653,7 +675,8 @@ meta_show_dialog (const char *type,
setenv ("WINDOWID", env, 1);
g_free (env);
- append_argument (args, "--modal");
+ if (zenity_supports_option ("--help-general", "--modal"))
+ append_argument (args, "--modal");
}
g_ptr_array_add (args, NULL); /* NULL-terminate */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]