util: Add an option to request dialogs being modal
As WMs cannot open windows themselves, Mutter uses zenity to open "Force Quit" dialogs for unresponsive windows; as those are strongly tied to the corresponding window, it makes sense to make them modal (in particular when attaching them to their parent). https://bugzilla.gnome.org/show_bug.cgi?id=684322
This commit is contained in:
parent
22b15e87d3
commit
0628bd3291
@ -67,6 +67,9 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data)
|
||||
if (data->width > -1 || data->height > -1)
|
||||
gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
|
||||
|
||||
if (data->modal)
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
|
||||
text = gtk_builder_get_object (builder, "zenity_calendar_text");
|
||||
|
||||
if (cal_data->dialog_text)
|
||||
|
@ -73,6 +73,9 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data)
|
||||
g_object_unref (G_OBJECT (button));
|
||||
}
|
||||
|
||||
if (data->modal)
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
|
||||
gtk_color_selection_set_has_palette (GTK_COLOR_SELECTION (colorsel),
|
||||
color_data->show_palette);
|
||||
|
||||
|
@ -81,6 +81,9 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data)
|
||||
if (data->width > -1 || data->height > -1)
|
||||
gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
|
||||
|
||||
if (data->modal)
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
|
||||
if (data->ok_label) {
|
||||
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_ok_button"));
|
||||
gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
|
||||
|
@ -67,6 +67,9 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data)
|
||||
|
||||
zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-file.png"));
|
||||
|
||||
if (data->modal)
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
|
||||
if (file_data->uri) {
|
||||
dir = g_path_get_dirname (file_data->uri);
|
||||
|
||||
|
@ -143,6 +143,9 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data)
|
||||
if (data->width > -1 || data->height > -1)
|
||||
gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
|
||||
|
||||
if (data->modal)
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
|
||||
if (msg_data->dialog_text) {
|
||||
if (msg_data->no_markup)
|
||||
gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text);
|
||||
|
12
src/option.c
12
src/option.c
@ -44,6 +44,7 @@ static gboolean zenity_general_dialog_no_markup;
|
||||
static gint zenity_general_timeout_delay;
|
||||
static gchar *zenity_general_ok_button;
|
||||
static gchar *zenity_general_cancel_button;
|
||||
static gboolean zenity_general_modal;
|
||||
|
||||
/* Calendar Dialog Options */
|
||||
static gboolean zenity_calendar_active;
|
||||
@ -210,6 +211,15 @@ static GOptionEntry general_options[] = {
|
||||
N_("Sets the label of the Cancel button"),
|
||||
N_("TEXT")
|
||||
},
|
||||
{
|
||||
"modal",
|
||||
'\0',
|
||||
G_OPTION_FLAG_NOALIAS,
|
||||
G_OPTION_ARG_NONE,
|
||||
&zenity_general_modal,
|
||||
N_("Set the modal hint"),
|
||||
NULL
|
||||
},
|
||||
{
|
||||
NULL
|
||||
}
|
||||
@ -1287,6 +1297,7 @@ zenity_general_pre_callback (GOptionContext *context,
|
||||
zenity_general_dialog_no_wrap = FALSE;
|
||||
zenity_general_dialog_no_markup = FALSE;
|
||||
zenity_general_timeout_delay = -1;
|
||||
zenity_general_modal = FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -1524,6 +1535,7 @@ zenity_general_post_callback (GOptionContext *context,
|
||||
results->data->timeout_delay = zenity_general_timeout_delay;
|
||||
results->data->ok_label = zenity_general_ok_button;
|
||||
results->data->cancel_label = zenity_general_cancel_button;
|
||||
results->data->modal = zenity_general_modal;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -134,6 +134,9 @@ void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data
|
||||
if (data->dialog_title)
|
||||
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
||||
|
||||
if (data->modal)
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
|
||||
g_signal_connect (G_OBJECT (dialog), "response",
|
||||
G_CALLBACK (zenity_password_dialog_response),
|
||||
password_data);
|
||||
|
@ -259,6 +259,9 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data)
|
||||
if (data->width > -1 || data->height > -1)
|
||||
gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
|
||||
|
||||
if (data->modal)
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
|
||||
if (data->ok_label) {
|
||||
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_progress_ok_button"));
|
||||
gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
|
||||
|
@ -76,6 +76,9 @@ zenity_scale (ZenityData *data, ZenityScaleData *scale_data)
|
||||
if (data->width > -1 || data->height > -1)
|
||||
gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
|
||||
|
||||
if (data->modal)
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
|
||||
if (data->ok_label) {
|
||||
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_ok_button"));
|
||||
gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
|
||||
|
@ -288,6 +288,9 @@ zenity_text (ZenityData *data, ZenityTextData *text_data)
|
||||
else
|
||||
gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 400);
|
||||
|
||||
if (data->modal)
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
|
||||
#ifdef HAVE_WEBKITGTK
|
||||
if(text_data->html) {
|
||||
web_kit = webkit_web_view_new();
|
||||
|
@ -383,6 +383,9 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
|
||||
if (data->dialog_title)
|
||||
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
||||
|
||||
if (data->modal)
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
|
||||
if (data->ok_label) {
|
||||
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_tree_ok_button"));
|
||||
gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
|
||||
|
@ -32,6 +32,7 @@ typedef struct {
|
||||
gint height;
|
||||
gint exit_code;
|
||||
gint timeout_delay;
|
||||
gboolean modal;
|
||||
} ZenityData;
|
||||
|
||||
typedef enum {
|
||||
|
Reference in New Issue
Block a user