added attach option for transient window
This commit is contained in:
parent
e6021b4a22
commit
009523d5da
@ -308,7 +308,7 @@ zenity_about (ZenityData *data)
|
|||||||
G_CALLBACK (zenity_zen_wisdom), NULL);
|
G_CALLBACK (zenity_zen_wisdom), NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
zenity_util_show_dialog (dialog);
|
zenity_util_show_dialog (dialog, data->attach);
|
||||||
gtk_main ();
|
gtk_main ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data)
|
|||||||
G_CALLBACK (zenity_calendar_double_click), data);
|
G_CALLBACK (zenity_calendar_double_click), data);
|
||||||
|
|
||||||
gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar);
|
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) {
|
if (data->timeout_delay > 0) {
|
||||||
g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog);
|
g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog);
|
||||||
|
@ -79,7 +79,7 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data)
|
|||||||
gtk_color_selection_set_has_palette (GTK_COLOR_SELECTION (colorsel),
|
gtk_color_selection_set_has_palette (GTK_COLOR_SELECTION (colorsel),
|
||||||
color_data->show_palette);
|
color_data->show_palette);
|
||||||
|
|
||||||
zenity_util_show_dialog (dialog);
|
zenity_util_show_dialog (dialog, data->attach);
|
||||||
|
|
||||||
if (data->timeout_delay > 0) {
|
if (data->timeout_delay > 0) {
|
||||||
g_timeout_add (data->timeout_delay * 1000,
|
g_timeout_add (data->timeout_delay * 1000,
|
||||||
|
@ -144,7 +144,7 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data)
|
|||||||
|
|
||||||
g_object_unref (builder);
|
g_object_unref (builder);
|
||||||
|
|
||||||
zenity_util_show_dialog (dialog);
|
zenity_util_show_dialog (dialog, data->attach);
|
||||||
|
|
||||||
if(data->timeout_delay > 0) {
|
if(data->timeout_delay > 0) {
|
||||||
g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog);
|
g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog);
|
||||||
|
@ -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) {
|
if(data->timeout_delay > 0) {
|
||||||
g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog);
|
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)
|
if (msg_data->no_wrap)
|
||||||
gtk_label_set_line_wrap (GTK_LABEL (text), FALSE);
|
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) {
|
if(data->timeout_delay > 0) {
|
||||||
g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL);
|
g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL);
|
||||||
|
12
src/option.c
12
src/option.c
@ -46,6 +46,7 @@ static gint zenity_general_timeout_delay;
|
|||||||
static gchar *zenity_general_ok_button;
|
static gchar *zenity_general_ok_button;
|
||||||
static gchar *zenity_general_cancel_button;
|
static gchar *zenity_general_cancel_button;
|
||||||
static gboolean zenity_general_modal;
|
static gboolean zenity_general_modal;
|
||||||
|
static gint zenity_general_attach;
|
||||||
|
|
||||||
/* Calendar Dialog Options */
|
/* Calendar Dialog Options */
|
||||||
static gboolean zenity_calendar_active;
|
static gboolean zenity_calendar_active;
|
||||||
@ -222,6 +223,15 @@ static GOptionEntry general_options[] = {
|
|||||||
N_("Set the modal hint"),
|
N_("Set the modal hint"),
|
||||||
NULL
|
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
|
NULL
|
||||||
}
|
}
|
||||||
@ -1350,6 +1360,7 @@ zenity_general_pre_callback (GOptionContext *context,
|
|||||||
zenity_general_dialog_no_markup = FALSE;
|
zenity_general_dialog_no_markup = FALSE;
|
||||||
zenity_general_timeout_delay = -1;
|
zenity_general_timeout_delay = -1;
|
||||||
zenity_general_modal = FALSE;
|
zenity_general_modal = FALSE;
|
||||||
|
zenity_general_attach = 0;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -1588,6 +1599,7 @@ zenity_general_post_callback (GOptionContext *context,
|
|||||||
results->data->ok_label = zenity_general_ok_button;
|
results->data->ok_label = zenity_general_ok_button;
|
||||||
results->data->cancel_label = zenity_general_cancel_button;
|
results->data->cancel_label = zenity_general_cancel_button;
|
||||||
results->data->modal = zenity_general_modal;
|
results->data->modal = zenity_general_modal;
|
||||||
|
results->data->attach = zenity_general_attach;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data
|
|||||||
G_CALLBACK (zenity_password_dialog_response),
|
G_CALLBACK (zenity_password_dialog_response),
|
||||||
password_data);
|
password_data);
|
||||||
gtk_widget_show_all(GTK_WIDGET(gtk_dialog_get_content_area(GTK_DIALOG(dialog))));
|
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) {
|
if (data->timeout_delay > 0) {
|
||||||
g_timeout_add (data->timeout_delay * 1000,
|
g_timeout_add (data->timeout_delay * 1000,
|
||||||
|
@ -302,7 +302,7 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data)
|
|||||||
if (no_cancel && auto_close)
|
if (no_cancel && auto_close)
|
||||||
gtk_widget_hide(GTK_WIDGET(ok_button));
|
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);
|
zenity_progress_read_info (progress_data);
|
||||||
|
|
||||||
if(data->timeout_delay > 0) {
|
if(data->timeout_delay > 0) {
|
||||||
|
@ -107,7 +107,7 @@ zenity_scale (ZenityData *data, ZenityScaleData *scale_data)
|
|||||||
if (scale_data->hide_value)
|
if (scale_data->hide_value)
|
||||||
gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
|
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) {
|
if(data->timeout_delay > 0) {
|
||||||
g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog);
|
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));
|
gtk_widget_show (GTK_WIDGET (web_kit));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
zenity_util_show_dialog (dialog);
|
zenity_util_show_dialog (dialog, data->attach);
|
||||||
|
|
||||||
g_object_unref (builder);
|
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_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) {
|
if(data->timeout_delay > 0) {
|
||||||
g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog);
|
g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog);
|
||||||
|
22
src/util.c
22
src/util.c
@ -39,10 +39,6 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "zenity.h"
|
#include "zenity.h"
|
||||||
|
|
||||||
#ifdef GDK_WINDOWING_X11
|
|
||||||
#include <gdk/gdkx.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ZENITY_OK_DEFAULT 0
|
#define ZENITY_OK_DEFAULT 0
|
||||||
#define ZENITY_CANCEL_DEFAULT 1
|
#define ZENITY_CANCEL_DEFAULT 1
|
||||||
#define ZENITY_ESC_DEFAULT 1
|
#define ZENITY_ESC_DEFAULT 1
|
||||||
@ -398,29 +394,27 @@ transient_get_xterm_toplevel (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_util_make_transient (GdkWindow *window)
|
zenity_util_make_transient (GdkWindow *window, Window parent)
|
||||||
{
|
{
|
||||||
Window xterm = transient_get_xterm_toplevel ();
|
Window parent_window = parent;
|
||||||
if (xterm != None) {
|
if (parent_window == 0)
|
||||||
GdkWindow *gdkxterm = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (), xterm);
|
parent_window = transient_get_xterm_toplevel ();
|
||||||
if (gdkxterm) {
|
if (parent_window != None) {
|
||||||
gdk_window_set_transient_for (window, gdkxterm);
|
XSetTransientForHint (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), GDK_WINDOW_XID(window), parent_window);
|
||||||
g_object_unref (G_OBJECT (gdkxterm));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* GDK_WINDOWING_X11 */
|
#endif /* GDK_WINDOWING_X11 */
|
||||||
|
|
||||||
void
|
void
|
||||||
zenity_util_show_dialog (GtkWidget *dialog)
|
zenity_util_show_dialog (GtkWidget *dialog, Window parent)
|
||||||
{
|
{
|
||||||
gtk_widget_realize (dialog);
|
gtk_widget_realize (dialog);
|
||||||
#ifdef GDK_WINDOWING_X11
|
#ifdef GDK_WINDOWING_X11
|
||||||
if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
|
if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
|
||||||
{
|
{
|
||||||
g_assert (gtk_widget_get_window(dialog));
|
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
|
#endif
|
||||||
gtk_widget_show (dialog);
|
gtk_widget_show (dialog);
|
||||||
|
@ -4,6 +4,10 @@
|
|||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include "zenity.h"
|
#include "zenity.h"
|
||||||
|
|
||||||
|
#ifdef GDK_WINDOWING_X11
|
||||||
|
#include <gdk/gdkx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define ZENITY_UI_FILE_FULLPATH ZENITY_DATADIR "/zenity.ui"
|
#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);
|
gint zenity_util_return_exit_code (ZenityExitCode value);
|
||||||
void zenity_util_exit_code_with_data (ZenityExitCode value,
|
void zenity_util_exit_code_with_data (ZenityExitCode value,
|
||||||
ZenityData *data);
|
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);
|
gboolean zenity_util_timeout_handle (gpointer data);
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ typedef struct {
|
|||||||
gint exit_code;
|
gint exit_code;
|
||||||
gint timeout_delay;
|
gint timeout_delay;
|
||||||
gboolean modal;
|
gboolean modal;
|
||||||
|
gint attach;
|
||||||
} ZenityData;
|
} ZenityData;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
Reference in New Issue
Block a user