summaryrefslogtreecommitdiff
path: root/src/Fl_Native_File_Chooser_GTK.cxx
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2020-01-22 18:44:49 +0100
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2020-01-22 18:44:49 +0100
commita47df744310de9fb8cc5d12c9685a3d4fa564110 (patch)
tree6eb66e2b229c810b8be5fc9353ed6a259054a2ee /src/Fl_Native_File_Chooser_GTK.cxx
parentbcc2f4c575df31561642cf192d33ee69ddfbd5e1 (diff)
Fix preservation of the caller's locale when running GTK dialogs.
There are now 2 kinds of GTK libraries (V2 and V3) and two dialogs the file chooser and the printer chooser.
Diffstat (limited to 'src/Fl_Native_File_Chooser_GTK.cxx')
-rw-r--r--src/Fl_Native_File_Chooser_GTK.cxx28
1 files changed, 1 insertions, 27 deletions
diff --git a/src/Fl_Native_File_Chooser_GTK.cxx b/src/Fl_Native_File_Chooser_GTK.cxx
index 575ab4c70..1bbdf003a 100644
--- a/src/Fl_Native_File_Chooser_GTK.cxx
+++ b/src/Fl_Native_File_Chooser_GTK.cxx
@@ -432,33 +432,7 @@ static void hidden_files_cb(GtkToggleButton *togglebutton, gpointer user_data)
int Fl_GTK_Native_File_Chooser_Driver::show()
{
- // The point here is that after running a GTK dialog, the calling program's current locale is modified.
- // To avoid that, we memorize the calling program's current locale, and the locale as modified
- // by GTK after the first dialog use. We restore the calling program's current locale
- // before returning, and we set the locale as modified by GTK before subsequent GTK dialog uses.
- static bool first = true;
- char *p;
- char *before = NULL;
- static char *gtk_wants = NULL;
- fl_open_display();
- // record in before the calling program's current locale
- p = setlocale(LC_ALL, NULL);
- if (p) before = strdup(p);
- if (gtk_wants) { // set the locale as GTK 'wants it'
- setlocale(LC_ALL, gtk_wants);
- }
- int retval = fl_gtk_chooser_wrapper(); // may change the locale
- if (first) {
- first = false;
- // record in gtk_wants the locale as modified by the GTK dialog
- p = setlocale(LC_ALL, NULL);
- if (p) gtk_wants = strdup(p);
- }
- if (before) {
- setlocale(LC_ALL, before); // restore calling program's current locale
- free(before);
- }
- return retval;
+ return fl_gtk_chooser_wrapper();
}
static char *extract_dir_from_path(const char *path)