From 3d4be85f3521869f2703d9efb6b25c78ef90adea Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 13 Sep 2012 10:53:30 -0700 Subject: Prevent the preferences dialog from getting focus with file selector open The idea is based on Lubomir's code but the implementation is radically different. Instead of having the preferences dialog be referenced by a global variable we simply look up the appropriate ancestor of the current widget. Inspired-by: "Lubomir I. Ivanov" Signed-off-by: Dirk Hohndel --- gtk-gui.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'gtk-gui.c') diff --git a/gtk-gui.c b/gtk-gui.c index 5c8d960b2..d41ea07d6 100644 --- a/gtk-gui.c +++ b/gtk-gui.c @@ -493,7 +493,7 @@ static void event_toggle(GtkWidget *w, gpointer _data) static void pick_default_file(GtkWidget *w, GtkButton *button) { - GtkWidget *fs_dialog; + GtkWidget *fs_dialog, *preferences; const char *current_default; char *current_def_file, *current_def_dir; GtkFileFilter *filter; @@ -505,6 +505,9 @@ static void pick_default_file(GtkWidget *w, GtkButton *button) GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); + preferences = gtk_widget_get_ancestor(w, GTK_TYPE_DIALOG); + gtk_window_set_accept_focus(GTK_WINDOW(preferences), FALSE); + current_default = subsurface_default_filename(); current_def_dir = path_and_file(current_default, ¤t_def_file); @@ -537,6 +540,7 @@ static void pick_default_file(GtkWidget *w, GtkButton *button) free(current_def_dir); free(current_def_file); gtk_widget_destroy(fs_dialog); + gtk_window_set_accept_focus(GTK_WINDOW(preferences), TRUE); } static void preferences_dialog(GtkWidget *w, gpointer data) -- cgit v1.2.3-70-g09d2