Change preferences sub-dialogs to be modal
This solves the issue where the parent dialog is closed and then the child dialog is used. This is however only a partial fix: - Many other dialogs throughout the codebase do not currently have parent windows and need to be refactored. - Not all window managers respect modal so users can still trigger bugs. We can be more defensive against this but it requires more refactoring. Closes #2686
This commit is contained in:
parent
dd167b4c83
commit
13b6a40b9c
@ -141,6 +141,7 @@ void fe_get_int (char *prompt, int def, void *callback, void *ud);
|
||||
#define FRF_NOASKOVERWRITE 32 /* don't ask to overwrite existing files */
|
||||
#define FRF_EXTENSIONS 64 /* specify file extensions to be displayed */
|
||||
#define FRF_MIMETYPES 128 /* specify file mimetypes to be displayed */
|
||||
#define FRF_MODAL 256 /* dialog should be modal to parent */
|
||||
void fe_get_file (const char *title, char *initial,
|
||||
void (*callback) (void *userdata, char *file), void *userdata,
|
||||
int flags);
|
||||
|
@ -512,7 +512,7 @@ chanlist_save (GtkWidget * wid, server *serv)
|
||||
GtkTreeModel *model = GET_MODEL (serv);
|
||||
|
||||
if (gtk_tree_model_get_iter_first (model, &iter))
|
||||
gtkutil_file_req (_("Select an output filename"), chanlist_filereq_done,
|
||||
gtkutil_file_req (NULL, _("Select an output filename"), chanlist_filereq_done,
|
||||
serv, NULL, NULL, FRF_WRITE);
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ fe_dcc_send_filereq (struct session *sess, char *nick, int maxcps, int passive)
|
||||
mdc->maxcps = maxcps;
|
||||
mdc->passive = passive;
|
||||
|
||||
gtkutil_file_req (tbuf, dcc_send_filereq_file, mdc, prefs.hex_dcc_dir, NULL, FRF_MULTIPLE|FRF_FILTERISINITIAL);
|
||||
gtkutil_file_req (NULL, tbuf, dcc_send_filereq_file, mdc, prefs.hex_dcc_dir, NULL, FRF_MULTIPLE|FRF_FILTERISINITIAL);
|
||||
|
||||
g_free (tbuf);
|
||||
}
|
||||
|
@ -903,7 +903,7 @@ fe_confirm (const char *message, void (*yesproc)(void *), void (*noproc)(void *)
|
||||
if (dcc->file)
|
||||
{
|
||||
char *filepath = g_build_filename (prefs.hex_dcc_dir, dcc->file, NULL);
|
||||
gtkutil_file_req (message, dcc_saveas_cb, ud, filepath, NULL,
|
||||
gtkutil_file_req (NULL, message, dcc_saveas_cb, ud, filepath, NULL,
|
||||
FRF_WRITE|FRF_NOASKOVERWRITE|FRF_FILTERISINITIAL);
|
||||
g_free (filepath);
|
||||
}
|
||||
@ -1216,7 +1216,7 @@ fe_get_file (const char *title, char *initial,
|
||||
{
|
||||
/* OK: Call callback once per file, then once more with file=NULL. */
|
||||
/* CANCEL: Call callback once with file=NULL. */
|
||||
gtkutil_file_req (title, callback, userdata, initial, NULL, flags | FRF_FILTERISINITIAL);
|
||||
gtkutil_file_req (NULL, title, callback, userdata, initial, NULL, flags | FRF_FILTERISINITIAL);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -190,7 +190,7 @@ gtkutil_file_req_response (GtkWidget *dialog, gint res, struct file_req *freq)
|
||||
}
|
||||
|
||||
void
|
||||
gtkutil_file_req (const char *title, void *callback, void *userdata, char *filter, char *extensions,
|
||||
gtkutil_file_req (GtkWindow *parent, const char *title, void *callback, void *userdata, char *filter, char *extensions,
|
||||
int flags)
|
||||
{
|
||||
struct file_req *freq;
|
||||
@ -269,6 +269,16 @@ gtkutil_file_req (const char *title, void *callback, void *userdata, char *filte
|
||||
G_CALLBACK (gtkutil_file_req_response), freq);
|
||||
g_signal_connect (G_OBJECT (dialog), "destroy",
|
||||
G_CALLBACK (gtkutil_file_req_destroy), (gpointer) freq);
|
||||
|
||||
if (parent)
|
||||
gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
|
||||
|
||||
if (flags & FRF_MODAL)
|
||||
{
|
||||
g_assert (parent);
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
}
|
||||
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
typedef void (*filereqcallback) (void *, char *file);
|
||||
|
||||
void gtkutil_file_req (const char *title, void *callback, void *userdata, char *filter, char *extensions, int flags);
|
||||
void gtkutil_file_req (GtkWindow *parent, const char *title, void *callback, void *userdata, char *filter, char *extensions, int flags);
|
||||
void gtkutil_destroy (GtkWidget * igad, GtkWidget * dgad);
|
||||
void gtkutil_destroy_on_esc (GtkWidget *win);
|
||||
GtkWidget *gtkutil_button (GtkWidget *box, char *stock, char *tip, void *callback,
|
||||
|
@ -1362,7 +1362,7 @@ savebuffer_req_done (session *sess, char *file)
|
||||
static void
|
||||
menu_savebuffer (GtkWidget * wid, gpointer none)
|
||||
{
|
||||
gtkutil_file_req (_("Select an output filename"), savebuffer_req_done,
|
||||
gtkutil_file_req (NULL, _("Select an output filename"), savebuffer_req_done,
|
||||
current_sess, NULL, NULL, FRF_WRITE);
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ plugingui_load (void)
|
||||
{
|
||||
char *sub_dir = g_build_filename (get_xdir(), "addons", NULL);
|
||||
|
||||
gtkutil_file_req (_("Select a Plugin or Script to load"), plugingui_load_cb, current_sess,
|
||||
gtkutil_file_req (NULL, _("Select a Plugin or Script to load"), plugingui_load_cb, current_sess,
|
||||
sub_dir, "*."PLUGIN_SUFFIX";*.lua;*.pl;*.py;*.tcl;*.js", FRF_FILTERISINITIAL|FRF_EXTENSIONS);
|
||||
|
||||
g_free (sub_dir);
|
||||
|
@ -77,7 +77,7 @@ rawlog_clearbutton (GtkWidget * wid, server *serv)
|
||||
static int
|
||||
rawlog_savebutton (GtkWidget * wid, server *serv)
|
||||
{
|
||||
gtkutil_file_req (_("Save As..."), rawlog_save, serv, NULL, NULL, FRF_WRITE);
|
||||
gtkutil_file_req (NULL, _("Save As..."), rawlog_save, serv, NULL, NULL, FRF_WRITE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,7 @@ GtkStyle *create_input_style (GtkStyle *);
|
||||
|
||||
#define LABEL_INDENT 12
|
||||
|
||||
static GtkWidget *setup_window = NULL;
|
||||
static int last_selected_page = 0;
|
||||
static int last_selected_row = 0; /* sound row */
|
||||
static gboolean color_change;
|
||||
@ -1105,8 +1106,8 @@ setup_browsefile_cb (GtkWidget *button, GtkWidget *entry)
|
||||
filter = "image/*";
|
||||
filter_type = FRF_MIMETYPES;
|
||||
#endif
|
||||
gtkutil_file_req (_("Select an Image File"), setup_filereq_cb,
|
||||
entry, NULL, filter, filter_type|FRF_RECENTLYUSED);
|
||||
gtkutil_file_req (GTK_WINDOW (setup_window), _("Select an Image File"), setup_filereq_cb,
|
||||
entry, NULL, filter, filter_type|FRF_RECENTLYUSED|FRF_MODAL);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1141,7 +1142,7 @@ setup_fontsel_cancel (GtkWidget *button, GtkFontSelectionDialog *dialog)
|
||||
static void
|
||||
setup_browsefolder_cb (GtkWidget *button, GtkEntry *entry)
|
||||
{
|
||||
gtkutil_file_req (_("Select Download Folder"), setup_filereq_cb, entry, (char*)gtk_entry_get_text (entry), NULL, FRF_CHOOSEFOLDER);
|
||||
gtkutil_file_req (GTK_WINDOW (setup_window), _("Select Download Folder"), setup_filereq_cb, entry, (char*)gtk_entry_get_text (entry), NULL, FRF_CHOOSEFOLDER|FRF_MODAL);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1154,6 +1155,9 @@ setup_browsefont_cb (GtkWidget *button, GtkWidget *entry)
|
||||
dialog = (GtkFontSelectionDialog *) gtk_font_selection_dialog_new (_("Select font"));
|
||||
font_dialog = (GtkWidget *)dialog; /* global var */
|
||||
|
||||
gtk_window_set_transient_for (GTK_WINDOW (font_dialog), GTK_WINDOW (setup_window));
|
||||
gtk_window_set_modal (GTK_WINDOW (font_dialog), TRUE);
|
||||
|
||||
sel = (GtkFontSelection *) gtk_font_selection_dialog_get_font_selection (dialog);
|
||||
|
||||
if (gtk_entry_get_text (GTK_ENTRY (entry))[0])
|
||||
@ -1457,6 +1461,8 @@ setup_color_cb (GtkWidget *button, gpointer userdata)
|
||||
g_object_set_data (G_OBJECT (ok_button), "b", button);
|
||||
gtk_widget_set_sensitive (help_button, FALSE);
|
||||
gtk_color_selection_set_current_color (GTK_COLOR_SELECTION (gtk_color_selection_dialog_get_color_selection (cdialog)), color);
|
||||
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (setup_window));
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
g_object_unref (cancel_button);
|
||||
@ -1711,8 +1717,8 @@ setup_snd_browse_cb (GtkWidget *button, GtkEntry *entry)
|
||||
filter_type = FRF_MIMETYPES;
|
||||
#endif
|
||||
|
||||
gtkutil_file_req (_("Select a sound file"), setup_snd_filereq_cb, entry,
|
||||
sounds_dir, filter, FRF_FILTERISINITIAL|filter_type);
|
||||
gtkutil_file_req (GTK_WINDOW (setup_window), _("Select a sound file"), setup_snd_filereq_cb, entry,
|
||||
sounds_dir, filter, FRF_MODAL|FRF_FILTERISINITIAL|filter_type);
|
||||
g_free (sounds_dir);
|
||||
}
|
||||
|
||||
@ -2336,8 +2342,6 @@ setup_close_cb (GtkWidget *win, GtkWidget **swin)
|
||||
void
|
||||
setup_open (void)
|
||||
{
|
||||
static GtkWidget *setup_window = NULL;
|
||||
|
||||
if (setup_window)
|
||||
{
|
||||
gtk_window_present (GTK_WINDOW (setup_window));
|
||||
|
@ -282,7 +282,7 @@ pevent_save_cb (GtkWidget * wid, void *data)
|
||||
{
|
||||
if (data)
|
||||
{
|
||||
gtkutil_file_req (_("Print Texts File"), pevent_save_req_cb, NULL,
|
||||
gtkutil_file_req (NULL, _("Print Texts File"), pevent_save_req_cb, NULL,
|
||||
NULL, NULL, FRF_WRITE);
|
||||
return;
|
||||
}
|
||||
@ -304,7 +304,7 @@ pevent_load_req_cb (void *arg1, char *file)
|
||||
static void
|
||||
pevent_load_cb (GtkWidget * wid, void *data)
|
||||
{
|
||||
gtkutil_file_req (_("Print Texts File"), pevent_load_req_cb, NULL, NULL, NULL, 0);
|
||||
gtkutil_file_req (NULL, _("Print Texts File"), pevent_load_req_cb, NULL, NULL, NULL, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -145,7 +145,7 @@ url_save_callback (void *arg1, char *file)
|
||||
static void
|
||||
url_button_save (void)
|
||||
{
|
||||
gtkutil_file_req (_("Select an output filename"),
|
||||
gtkutil_file_req (NULL, _("Select an output filename"),
|
||||
url_save_callback, NULL, NULL, NULL, FRF_WRITE);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user