diff options
-rw-r--r-- | src/about.c | 2 | ||||
-rw-r--r-- | src/calendar.c | 2 | ||||
-rw-r--r-- | src/color.c | 2 | ||||
-rw-r--r-- | src/entry.c | 2 | ||||
-rw-r--r-- | src/fileselection.c | 2 | ||||
-rw-r--r-- | src/msg.c | 2 | ||||
-rw-r--r-- | src/option.c | 12 | ||||
-rw-r--r-- | src/password.c | 2 | ||||
-rw-r--r-- | src/progress.c | 2 | ||||
-rw-r--r-- | src/scale.c | 2 | ||||
-rw-r--r-- | src/text.c | 2 | ||||
-rw-r--r-- | src/tree.c | 2 | ||||
-rw-r--r-- | src/util.c | 22 | ||||
-rw-r--r-- | src/util.h | 6 | ||||
-rw-r--r-- | src/zenity.h | 1 |
15 files changed, 37 insertions, 26 deletions
diff --git a/src/about.c b/src/about.c index 67c2474c..ab82068a 100644 --- a/src/about.c +++ b/src/about.c @@ -308,7 +308,7 @@ zenity_about (ZenityData *data) G_CALLBACK (zenity_zen_wisdom), NULL); #endif - zenity_util_show_dialog (dialog); + zenity_util_show_dialog (dialog, data->attach); gtk_main (); } diff --git a/src/calendar.c b/src/calendar.c index f2820014..e8967974 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -86,7 +86,7 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) G_CALLBACK (zenity_calendar_double_click), data); gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar); - zenity_util_show_dialog (dialog); + zenity_util_show_dialog (dialog, data->attach); if (data->timeout_delay > 0) { g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); diff --git a/src/color.c b/src/color.c index 791d76da..b6a6b121 100644 --- a/src/color.c +++ b/src/color.c @@ -79,7 +79,7 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) gtk_color_selection_set_has_palette (GTK_COLOR_SELECTION (colorsel), color_data->show_palette); - zenity_util_show_dialog (dialog); + zenity_util_show_dialog (dialog, data->attach); if (data->timeout_delay > 0) { g_timeout_add (data->timeout_delay * 1000, diff --git a/src/entry.c b/src/entry.c index da708e22..ca5e3752 100644 --- a/src/entry.c +++ b/src/entry.c @@ -144,7 +144,7 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) g_object_unref (builder); - zenity_util_show_dialog (dialog); + zenity_util_show_dialog (dialog, data->attach); if(data->timeout_delay > 0) { g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); diff --git a/src/fileselection.c b/src/fileselection.c index b4b0a65e..9edbb6ae 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -136,7 +136,7 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) } } - zenity_util_show_dialog (dialog); + zenity_util_show_dialog (dialog, data->attach); if(data->timeout_delay > 0) { g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); @@ -165,7 +165,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (msg_data->no_wrap) gtk_label_set_line_wrap (GTK_LABEL (text), FALSE); - zenity_util_show_dialog (dialog); + zenity_util_show_dialog (dialog, data->attach); if(data->timeout_delay > 0) { g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); diff --git a/src/option.c b/src/option.c index 2ca9f1d7..7658e8b4 100644 --- a/src/option.c +++ b/src/option.c @@ -46,6 +46,7 @@ static gint zenity_general_timeout_delay; static gchar *zenity_general_ok_button; static gchar *zenity_general_cancel_button; static gboolean zenity_general_modal; +static gint zenity_general_attach; /* Calendar Dialog Options */ static gboolean zenity_calendar_active; @@ -223,6 +224,15 @@ static GOptionEntry general_options[] = { NULL }, { + "attach", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_INT, + &zenity_general_attach, + N_("Set the parent window to attach to"), + N_("WINDOW") + }, + { NULL } }; @@ -1350,6 +1360,7 @@ zenity_general_pre_callback (GOptionContext *context, zenity_general_dialog_no_markup = FALSE; zenity_general_timeout_delay = -1; zenity_general_modal = FALSE; + zenity_general_attach = 0; return TRUE; } @@ -1588,6 +1599,7 @@ zenity_general_post_callback (GOptionContext *context, results->data->ok_label = zenity_general_ok_button; results->data->cancel_label = zenity_general_cancel_button; results->data->modal = zenity_general_modal; + results->data->attach = zenity_general_attach; return TRUE; } diff --git a/src/password.c b/src/password.c index 1582f956..915ea3d9 100644 --- a/src/password.c +++ b/src/password.c @@ -141,7 +141,7 @@ void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data G_CALLBACK (zenity_password_dialog_response), password_data); gtk_widget_show_all(GTK_WIDGET(gtk_dialog_get_content_area(GTK_DIALOG(dialog)))); - zenity_util_show_dialog (dialog); + zenity_util_show_dialog (dialog, data->attach); if (data->timeout_delay > 0) { g_timeout_add (data->timeout_delay * 1000, diff --git a/src/progress.c b/src/progress.c index 055699c0..cbffe08e 100644 --- a/src/progress.c +++ b/src/progress.c @@ -302,7 +302,7 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) if (no_cancel && auto_close) gtk_widget_hide(GTK_WIDGET(ok_button)); - zenity_util_show_dialog (dialog); + zenity_util_show_dialog (dialog, data->attach); zenity_progress_read_info (progress_data); if(data->timeout_delay > 0) { diff --git a/src/scale.c b/src/scale.c index a7f6d718..adcf67be 100644 --- a/src/scale.c +++ b/src/scale.c @@ -107,7 +107,7 @@ zenity_scale (ZenityData *data, ZenityScaleData *scale_data) if (scale_data->hide_value) gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE); - zenity_util_show_dialog (dialog); + zenity_util_show_dialog (dialog, data->attach); if(data->timeout_delay > 0) { g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); @@ -326,7 +326,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) gtk_widget_show (GTK_WIDGET (web_kit)); } #endif - zenity_util_show_dialog (dialog); + zenity_util_show_dialog (dialog, data->attach); g_object_unref (builder); @@ -562,7 +562,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) zenity_tree_fill_entries_from_stdin (GTK_TREE_VIEW (tree_view), n_columns, FALSE, tree_data->editable); } - zenity_util_show_dialog (dialog); + zenity_util_show_dialog (dialog, data->attach); if(data->timeout_delay > 0) { g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); @@ -39,10 +39,6 @@ #include "util.h" #include "zenity.h" -#ifdef GDK_WINDOWING_X11 -#include <gdk/gdkx.h> -#endif - #define ZENITY_OK_DEFAULT 0 #define ZENITY_CANCEL_DEFAULT 1 #define ZENITY_ESC_DEFAULT 1 @@ -398,29 +394,27 @@ transient_get_xterm_toplevel (void) } static void -zenity_util_make_transient (GdkWindow *window) +zenity_util_make_transient (GdkWindow *window, Window parent) { - Window xterm = transient_get_xterm_toplevel (); - if (xterm != None) { - GdkWindow *gdkxterm = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (), xterm); - if (gdkxterm) { - gdk_window_set_transient_for (window, gdkxterm); - g_object_unref (G_OBJECT (gdkxterm)); - } + Window parent_window = parent; + if (parent_window == 0) + parent_window = transient_get_xterm_toplevel (); + if (parent_window != None) { + XSetTransientForHint (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), GDK_WINDOW_XID(window), parent_window); } } #endif /* GDK_WINDOWING_X11 */ void -zenity_util_show_dialog (GtkWidget *dialog) +zenity_util_show_dialog (GtkWidget *dialog, Window parent) { gtk_widget_realize (dialog); #ifdef GDK_WINDOWING_X11 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) { g_assert (gtk_widget_get_window(dialog)); - zenity_util_make_transient (gtk_widget_get_window(dialog)); + zenity_util_make_transient (gtk_widget_get_window(dialog), parent); } #endif gtk_widget_show (dialog); @@ -4,6 +4,10 @@ #include <gtk/gtk.h> #include "zenity.h" +#ifdef GDK_WINDOWING_X11 +#include <gdk/gdkx.h> +#endif + G_BEGIN_DECLS #define ZENITY_UI_FILE_FULLPATH ZENITY_DATADIR "/zenity.ui" @@ -28,7 +32,7 @@ void zenity_util_show_help (GError **error); gint zenity_util_return_exit_code (ZenityExitCode value); void zenity_util_exit_code_with_data (ZenityExitCode value, ZenityData *data); -void zenity_util_show_dialog (GtkWidget *widget); +void zenity_util_show_dialog (GtkWidget *widget, Window parent); gboolean zenity_util_timeout_handle (gpointer data); diff --git a/src/zenity.h b/src/zenity.h index 7018800f..501109a4 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -33,6 +33,7 @@ typedef struct { gint exit_code; gint timeout_delay; gboolean modal; + gint attach; } ZenityData; typedef enum { |