core: Drop zenity show_dialog

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2370>
This commit is contained in:
Bilal Elmoussaoui 2022-04-19 16:17:22 +02:00
parent 4dee531b68
commit 97fc21adc1
2 changed files with 0 additions and 163 deletions

View File

@ -500,157 +500,6 @@ meta_external_binding_name_for_action (guint keybinding_action)
return g_strdup_printf ("external-grab-%u", keybinding_action); return g_strdup_printf ("external-grab-%u", keybinding_action);
} }
/* 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);
}
static void
child_setup (gpointer user_data)
{
MetaDisplay *display = meta_get_display ();
MetaContext *context = meta_display_get_context (display);
meta_context_restore_rlimit_nofile (context, NULL);
}
/**
* meta_show_dialog: (skip)
* @type: type of dialog
* @message: message
* @timeout: timeout
* @display: display
* @ok_text: text for Ok button
* @cancel_text: text for Cancel button
* @icon_name: icon name
* @transient_for: window XID of parent
* @columns: columns
* @entries: entries
*
*/
GPid
meta_show_dialog (const char *type,
const char *message,
const char *timeout,
const char *display,
const char *ok_text,
const char *cancel_text,
const char *icon_name,
const int transient_for,
GSList *columns,
GSList *entries)
{
GError *error = NULL;
GSList *tmp;
GPid child_pid;
GPtrArray *args;
args = g_ptr_array_new ();
append_argument (args, "zenity");
append_argument (args, type);
if (display)
{
append_argument (args, "--display");
append_argument (args, display);
}
append_argument (args, "--class");
append_argument (args, "mutter-dialog");
append_argument (args, "--title");
append_argument (args, "");
append_argument (args, "--text");
append_argument (args, message);
if (timeout)
{
append_argument (args, "--timeout");
append_argument (args, timeout);
}
if (ok_text)
{
append_argument (args, "--ok-label");
append_argument (args, ok_text);
}
if (cancel_text)
{
append_argument (args, "--cancel-label");
append_argument (args, cancel_text);
}
if (icon_name)
{
append_argument (args, "--icon-name");
append_argument (args, icon_name);
}
tmp = columns;
while (tmp)
{
append_argument (args, "--column");
append_argument (args, tmp->data);
tmp = tmp->next;
}
tmp = entries;
while (tmp)
{
append_argument (args, tmp->data);
tmp = tmp->next;
}
if (transient_for)
{
gchar *env = g_strdup_printf("%d", transient_for);
setenv ("WINDOWID", env, 1);
g_free (env);
append_argument (args, "--modal");
}
g_ptr_array_add (args, NULL); /* NULL-terminate */
g_spawn_async (
"/",
(gchar**) args->pdata,
NULL,
G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
child_setup, NULL,
&child_pid,
&error
);
if (transient_for)
unsetenv ("WINDOWID");
g_ptr_array_free (args, TRUE);
if (error)
{
meta_warning ("%s", error->message);
g_error_free (error);
}
return child_pid;
}
MetaLocaleDirection MetaLocaleDirection
meta_get_locale_direction (void) meta_get_locale_direction (void)
{ {

View File

@ -153,18 +153,6 @@ char* meta_external_binding_name_for_action (guint keybinding_action);
META_EXPORT META_EXPORT
char* meta_g_utf8_strndup (const gchar *src, gsize n); char* meta_g_utf8_strndup (const gchar *src, gsize n);
META_EXPORT
GPid meta_show_dialog (const char *type,
const char *message,
const char *timeout,
const char *display,
const char *ok_text,
const char *cancel_text,
const char *icon_name,
const int transient_for,
GSList *columns,
GSList *entries);
/* To disable verbose mode, we make these functions into no-ops */ /* To disable verbose mode, we make these functions into no-ops */
#ifdef WITH_VERBOSE_MODE #ifdef WITH_VERBOSE_MODE