summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Müllner <fmuellner@gnome.org>2012-09-18 18:33:07 +0200
committerMatthias Clasen <mclasen@redhat.com>2012-09-25 18:46:12 -0400
commit0628bd3291aad936b6b553366600590cca360bfa (patch)
tree667b6e8ad8a92d9f57cea3cfc1a82f8ee39e15cf
parentUpdated Latvian translation (diff)
downloadzenity-0628bd3291aad936b6b553366600590cca360bfa.tar.gz
zenity-0628bd3291aad936b6b553366600590cca360bfa.tar.bz2
zenity-0628bd3291aad936b6b553366600590cca360bfa.zip
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
-rw-r--r--src/calendar.c3
-rw-r--r--src/color.c3
-rw-r--r--src/entry.c3
-rw-r--r--src/fileselection.c3
-rw-r--r--src/msg.c3
-rw-r--r--src/option.c12
-rw-r--r--src/password.c3
-rw-r--r--src/progress.c3
-rw-r--r--src/scale.c3
-rw-r--r--src/text.c3
-rw-r--r--src/tree.c3
-rw-r--r--src/zenity.h1
12 files changed, 43 insertions, 0 deletions
diff --git a/src/calendar.c b/src/calendar.c
index c62c1818..c0f7af13 100644
--- a/src/calendar.c
+++ b/src/calendar.c
@@ -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)
diff --git a/src/color.c b/src/color.c
index 4c9c1517..791d76da 100644
--- a/src/color.c
+++ b/src/color.c
@@ -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);
diff --git a/src/entry.c b/src/entry.c
index 2b92e59f..72f73b5c 100644
--- a/src/entry.c
+++ b/src/entry.c
@@ -80,6 +80,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"));
diff --git a/src/fileselection.c b/src/fileselection.c
index 349ff32d..cf82f028 100644
--- a/src/fileselection.c
+++ b/src/fileselection.c
@@ -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);
diff --git a/src/msg.c b/src/msg.c
index 667239b1..505f961c 100644
--- a/src/msg.c
+++ b/src/msg.c
@@ -142,6 +142,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)
diff --git a/src/option.c b/src/option.c
index ee0e9c28..ba4691d0 100644
--- a/src/option.c
+++ b/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;
@@ -211,6 +212,15 @@ static GOptionEntry general_options[] = {
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;
}
diff --git a/src/password.c b/src/password.c
index b656d8fc..1582f956 100644
--- a/src/password.c
+++ b/src/password.c
@@ -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);
diff --git a/src/progress.c b/src/progress.c
index 3e6f5a2c..fca31c82 100644
--- a/src/progress.c
+++ b/src/progress.c
@@ -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);
diff --git a/src/scale.c b/src/scale.c
index 11d95887..21f820eb 100644
--- a/src/scale.c
+++ b/src/scale.c
@@ -75,6 +75,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"));
diff --git a/src/text.c b/src/text.c
index 9c031cb9..0163c3c0 100644
--- a/src/text.c
+++ b/src/text.c
@@ -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();
diff --git a/src/tree.c b/src/tree.c
index 4234fc1a..c1a20d0f 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -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);
diff --git a/src/zenity.h b/src/zenity.h
index 30c497b1..2eec3aa6 100644
--- a/src/zenity.h
+++ b/src/zenity.h
@@ -32,6 +32,7 @@ typedef struct {
gint height;
gint exit_code;
gint timeout_delay;
+ gboolean modal;
} ZenityData;
typedef enum {
bgstack15