Commit d9e7e822ee18f0b15acc0fe5e33a1371f665afa7
1 parent
7a0157ef
Exists in
master
and in
1 other branch
Windows native file dialog is hanging sometimes, replacing it.
Showing
9 changed files
with
365 additions
and
143 deletions
Show diff stats
Makefile.in
| ... | ... | @@ -35,6 +35,7 @@ SOURCES= \ |
| 35 | 35 | $(wildcard src/filetransfer/*.c) \ |
| 36 | 36 | $(wildcard src/trace/*.c) \ |
| 37 | 37 | $(wildcard src/dialogs/*.c) \ |
| 38 | + $(wildcard src/dialogs/@OSNAME@/*.c) \ | |
| 38 | 39 | $(wildcard src/dialogs/print/*.c) |
| 39 | 40 | |
| 40 | 41 | TEST_SOURCES= \ |
| ... | ... | @@ -58,6 +59,7 @@ VALGRIND=@VALGRIND@ |
| 58 | 59 | GENMARSHAL=@GENMARSHAL@ |
| 59 | 60 | CONVERT=@CONVERT@ |
| 60 | 61 | OPTIPNG=@OPTIPNG@ |
| 62 | +ZIP=@ZIP@ | |
| 61 | 63 | |
| 62 | 64 | #---[ Paths ]---------------------------------------------------------------------------- |
| 63 | 65 | |
| ... | ... | @@ -455,6 +457,16 @@ $(BINDBG)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@: \ |
| 455 | 457 | $(OBJDIR)/marshal/v3270ft.o \ |
| 456 | 458 | $(LIBS) |
| 457 | 459 | |
| 460 | +zip-debug: \ | |
| 461 | + $(LIBNAME)-debug-@PACKAGE_VERSION@-@host_cpu@.zip | |
| 462 | + | |
| 463 | +$(LIBNAME)-debug-@PACKAGE_VERSION@-@host_cpu@.zip: \ | |
| 464 | + $(BINDBG)/$(LIBNAME)@EXEEXT@ \ | |
| 465 | + $(BINDBG)/$(LIBNAME)@DLLEXT@.@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@ | |
| 466 | + | |
| 467 | + @$(ZIP) -9 -j $@ $^ | |
| 468 | + | |
| 469 | + | |
| 458 | 470 | #---[ Clean Targets ]-------------------------------------------------------------------- |
| 459 | 471 | |
| 460 | 472 | clean: \ | ... | ... |
configure.ac
| ... | ... | @@ -0,0 +1,134 @@ |
| 1 | +/* | |
| 2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
| 3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
| 4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob | |
| 5 | + * o nome G3270. | |
| 6 | + * | |
| 7 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
| 8 | + * | |
| 9 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
| 10 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
| 11 | + * Free Software Foundation. | |
| 12 | + * | |
| 13 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
| 14 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
| 15 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
| 16 | + * obter mais detalhes. | |
| 17 | + * | |
| 18 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
| 19 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
| 20 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 21 | + * | |
| 22 | + * Este programa está nomeado como - possui - linhas de código. | |
| 23 | + * | |
| 24 | + * Contatos: | |
| 25 | + * | |
| 26 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 27 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
| 28 | + * | |
| 29 | + */ | |
| 30 | + | |
| 31 | +#include "../private.h" | |
| 32 | +#include <stdarg.h> | |
| 33 | + | |
| 34 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
| 35 | + | |
| 36 | +gchar * v3270_select_file(GtkWidget *widget, const gchar *title, const gchar *button, GtkFileChooserAction action, const gchar *filename, const gchar *filter, ...) | |
| 37 | +{ | |
| 38 | + gchar *rc = NULL; | |
| 39 | + | |
| 40 | +#if GTK_CHECK_VERSION(3,20,0) | |
| 41 | + | |
| 42 | + GtkFileChooserNative *native = | |
| 43 | + gtk_file_chooser_native_new | |
| 44 | + ( | |
| 45 | + title, | |
| 46 | + GTK_WINDOW(gtk_widget_get_toplevel(widget)), | |
| 47 | + action, | |
| 48 | + button, | |
| 49 | + _( "_Cancel" ) | |
| 50 | + ); | |
| 51 | + | |
| 52 | + | |
| 53 | + // Setup filename | |
| 54 | + if(filename && *filename) | |
| 55 | + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(native),filename); | |
| 56 | + | |
| 57 | + // Setup filters | |
| 58 | + va_list args; | |
| 59 | + va_start (args, filter); | |
| 60 | + while(filter) | |
| 61 | + { | |
| 62 | + const gchar * name = va_arg(args, const gchar *); | |
| 63 | + if(!name) | |
| 64 | + break; | |
| 65 | + | |
| 66 | + const gchar * pattern = va_arg(args, const gchar *); | |
| 67 | + if(!pattern) | |
| 68 | + break; | |
| 69 | + | |
| 70 | + GtkFileFilter *filter = gtk_file_filter_new(); | |
| 71 | + gtk_file_filter_set_name(filter,name); | |
| 72 | + gtk_file_filter_add_pattern(filter, pattern); | |
| 73 | + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(native), filter); | |
| 74 | + | |
| 75 | + } | |
| 76 | + va_end(args); | |
| 77 | + | |
| 78 | + // Run dialog | |
| 79 | + if(gtk_native_dialog_run(GTK_NATIVE_DIALOG (native)) == GTK_RESPONSE_ACCEPT) { | |
| 80 | + rc = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(native)); | |
| 81 | + } | |
| 82 | + | |
| 83 | + g_object_unref(native); | |
| 84 | + | |
| 85 | +#else | |
| 86 | + | |
| 87 | + GtkWidget * chooser = | |
| 88 | + gtk_file_chooser_dialog_new | |
| 89 | + ( | |
| 90 | + title, | |
| 91 | + GTK_WINDOW(gtk_widget_get_toplevel(widget)), | |
| 92 | + action, | |
| 93 | + _("_Cancel" ), GTK_RESPONSE_CANCEL, | |
| 94 | + button, GTK_RESPONSE_ACCEPT, | |
| 95 | + NULL | |
| 96 | + ); | |
| 97 | + | |
| 98 | + if(filename && *filename) | |
| 99 | + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(chooser),filename); | |
| 100 | + | |
| 101 | + // Setup filters | |
| 102 | + va_list args; | |
| 103 | + va_start (args, filter); | |
| 104 | + while(filter) | |
| 105 | + { | |
| 106 | + const gchar * name = va_arg(args, const gchar *); | |
| 107 | + if(!name) | |
| 108 | + break; | |
| 109 | + | |
| 110 | + const gchar * pattern = va_arg(args, const gchar *); | |
| 111 | + if(!pattern) | |
| 112 | + break; | |
| 113 | + | |
| 114 | + GtkFileFilter *filter = gtk_file_filter_new(); | |
| 115 | + gtk_file_filter_set_name(filter,name); | |
| 116 | + gtk_file_filter_add_pattern(filter, pattern); | |
| 117 | + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(chooser), filter); | |
| 118 | + | |
| 119 | + } | |
| 120 | + va_end(args); | |
| 121 | + | |
| 122 | + if(gtk_dialog_run(GTK_DIALOG(chooser)) == GTK_RESPONSE_ACCEPT) { | |
| 123 | + rc = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser)); | |
| 124 | + } | |
| 125 | + | |
| 126 | + gtk_widget_destroy(chooser); | |
| 127 | + | |
| 128 | + | |
| 129 | +#endif // GTK 3.20 | |
| 130 | + | |
| 131 | + return rc; | |
| 132 | + | |
| 133 | +} | |
| 134 | + | ... | ... |
src/dialogs/select.c
| ... | ... | @@ -1,134 +0,0 @@ |
| 1 | -/* | |
| 2 | - * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
| 3 | - * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
| 4 | - * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob | |
| 5 | - * o nome G3270. | |
| 6 | - * | |
| 7 | - * Copyright (C) <2008> <Banco do Brasil S.A.> | |
| 8 | - * | |
| 9 | - * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
| 10 | - * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
| 11 | - * Free Software Foundation. | |
| 12 | - * | |
| 13 | - * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
| 14 | - * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
| 15 | - * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
| 16 | - * obter mais detalhes. | |
| 17 | - * | |
| 18 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
| 19 | - * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
| 20 | - * St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 21 | - * | |
| 22 | - * Este programa está nomeado como - possui - linhas de código. | |
| 23 | - * | |
| 24 | - * Contatos: | |
| 25 | - * | |
| 26 | - * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 27 | - * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
| 28 | - * | |
| 29 | - */ | |
| 30 | - | |
| 31 | -#include "private.h" | |
| 32 | -#include <stdarg.h> | |
| 33 | - | |
| 34 | -/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
| 35 | - | |
| 36 | -gchar * v3270_select_file(GtkWidget *widget, const gchar *title, const gchar *button, GtkFileChooserAction action, const gchar *filename, const gchar *filter, ...) | |
| 37 | -{ | |
| 38 | - gchar *rc = NULL; | |
| 39 | - | |
| 40 | -#if GTK_CHECK_VERSION(3,20,0) | |
| 41 | - | |
| 42 | - GtkFileChooserNative *native = | |
| 43 | - gtk_file_chooser_native_new | |
| 44 | - ( | |
| 45 | - title, | |
| 46 | - GTK_WINDOW(gtk_widget_get_toplevel(widget)), | |
| 47 | - action, | |
| 48 | - button, | |
| 49 | - _( "_Cancel" ) | |
| 50 | - ); | |
| 51 | - | |
| 52 | - | |
| 53 | - // Setup filename | |
| 54 | - if(filename && *filename) | |
| 55 | - gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(native),filename); | |
| 56 | - | |
| 57 | - // Setup filters | |
| 58 | - va_list args; | |
| 59 | - va_start (args, filter); | |
| 60 | - while(filter) | |
| 61 | - { | |
| 62 | - const gchar * name = va_arg(args, const gchar *); | |
| 63 | - if(!name) | |
| 64 | - break; | |
| 65 | - | |
| 66 | - const gchar * pattern = va_arg(args, const gchar *); | |
| 67 | - if(!pattern) | |
| 68 | - break; | |
| 69 | - | |
| 70 | - GtkFileFilter *filter = gtk_file_filter_new(); | |
| 71 | - gtk_file_filter_set_name(filter,name); | |
| 72 | - gtk_file_filter_add_pattern(filter, pattern); | |
| 73 | - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(native), filter); | |
| 74 | - | |
| 75 | - } | |
| 76 | - va_end(args); | |
| 77 | - | |
| 78 | - // Run dialog | |
| 79 | - if(gtk_native_dialog_run(GTK_NATIVE_DIALOG (native)) == GTK_RESPONSE_ACCEPT) { | |
| 80 | - rc = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(native)); | |
| 81 | - } | |
| 82 | - | |
| 83 | - g_object_unref(native); | |
| 84 | - | |
| 85 | -#else | |
| 86 | - | |
| 87 | - GtkWidget * chooser = | |
| 88 | - gtk_file_chooser_dialog_new | |
| 89 | - ( | |
| 90 | - title, | |
| 91 | - GTK_WINDOW(gtk_widget_get_toplevel(widget)), | |
| 92 | - action, | |
| 93 | - _("_Cancel" ), GTK_RESPONSE_CANCEL, | |
| 94 | - button, GTK_RESPONSE_ACCEPT, | |
| 95 | - NULL | |
| 96 | - ); | |
| 97 | - | |
| 98 | - if(filename && *filename) | |
| 99 | - gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(chooser),filename); | |
| 100 | - | |
| 101 | - // Setup filters | |
| 102 | - va_list args; | |
| 103 | - va_start (args, filter); | |
| 104 | - while(filter) | |
| 105 | - { | |
| 106 | - const gchar * name = va_arg(args, const gchar *); | |
| 107 | - if(!name) | |
| 108 | - break; | |
| 109 | - | |
| 110 | - const gchar * pattern = va_arg(args, const gchar *); | |
| 111 | - if(!pattern) | |
| 112 | - break; | |
| 113 | - | |
| 114 | - GtkFileFilter *filter = gtk_file_filter_new(); | |
| 115 | - gtk_file_filter_set_name(filter,name); | |
| 116 | - gtk_file_filter_add_pattern(filter, pattern); | |
| 117 | - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(chooser), filter); | |
| 118 | - | |
| 119 | - } | |
| 120 | - va_end(args); | |
| 121 | - | |
| 122 | - if(gtk_dialog_run(GTK_DIALOG(chooser)) == GTK_RESPONSE_ACCEPT) { | |
| 123 | - rc = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser)); | |
| 124 | - } | |
| 125 | - | |
| 126 | - gtk_widget_destroy(chooser); | |
| 127 | - | |
| 128 | - | |
| 129 | -#endif // GTK 3.20 | |
| 130 | - | |
| 131 | - return rc; | |
| 132 | - | |
| 133 | -} | |
| 134 | - |
| ... | ... | @@ -0,0 +1,197 @@ |
| 1 | +/* | |
| 2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
| 3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
| 4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob | |
| 5 | + * o nome G3270. | |
| 6 | + * | |
| 7 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
| 8 | + * | |
| 9 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
| 10 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
| 11 | + * Free Software Foundation. | |
| 12 | + * | |
| 13 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
| 14 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
| 15 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
| 16 | + * obter mais detalhes. | |
| 17 | + * | |
| 18 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
| 19 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
| 20 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 21 | + * | |
| 22 | + * Este programa está nomeado como - possui - linhas de código. | |
| 23 | + * | |
| 24 | + * Contatos: | |
| 25 | + * | |
| 26 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
| 27 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
| 28 | + * | |
| 29 | + */ | |
| 30 | + | |
| 31 | +#include "../private.h" | |
| 32 | +#include <stdarg.h> | |
| 33 | +#include <gdk/gdkwin32.h> | |
| 34 | +#include <lib3270/log.h> | |
| 35 | + | |
| 36 | +/*--[ Globals ]--------------------------------------------------------------------------------------*/ | |
| 37 | + | |
| 38 | +struct FileSelector | |
| 39 | +{ | |
| 40 | + OPENFILENAME ofn; | |
| 41 | + char szName[260]; ///< @brief buffer for file name. | |
| 42 | + int mode; | |
| 43 | + BOOL ok; | |
| 44 | +}; | |
| 45 | + | |
| 46 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
| 47 | + | |
| 48 | +/* | |
| 49 | +static gpointer win32_select_file(struct FileSelector *fl) | |
| 50 | +{ | |
| 51 | + debug("%s: start",__FUNCTION__); | |
| 52 | + if(fl->mode == 1) | |
| 53 | + { | |
| 54 | + fl->ok = GetSaveFileName(&fl->ofn); | |
| 55 | + } | |
| 56 | + else | |
| 57 | + { | |
| 58 | + fl->ok = GetOpenFileName(&fl->ofn); | |
| 59 | + } | |
| 60 | + debug("%s: end",__FUNCTION__); | |
| 61 | + | |
| 62 | + fl->mode = 3; | |
| 63 | + | |
| 64 | + return 0; | |
| 65 | +} | |
| 66 | + | |
| 67 | + | |
| 68 | +gchar * v3270_select_file(GtkWidget *widget, const gchar *title, const gchar *button, GtkFileChooserAction action, const gchar *filename, const gchar *filter, ...) | |
| 69 | +{ | |
| 70 | + gchar *rc = NULL; | |
| 71 | + | |
| 72 | + // Get parent windows | |
| 73 | + GdkWindow * win = gtk_widget_get_window(gtk_widget_get_toplevel(widget)); | |
| 74 | + | |
| 75 | + // Setup win32 file selection parameters | |
| 76 | + struct FileSelector fl; | |
| 77 | + | |
| 78 | + memset(&fl, 0, sizeof(fl)); | |
| 79 | + fl.ofn.lStructSize = sizeof(fl.ofn); | |
| 80 | + fl.ofn.hwndOwner = GDK_WINDOW_HWND(win); | |
| 81 | + fl.ofn.lpstrFile = fl.szName; | |
| 82 | + | |
| 83 | + // Set lpstrFile[0] to '\0' so that GetOpenFileName does not | |
| 84 | + // use the contents of szFile to initialize itself. | |
| 85 | + fl.ofn.lpstrFile[0] = '\0'; | |
| 86 | + | |
| 87 | + fl.ofn.lpstrFilter = "All\0*.*\0Text\0*.TXT\0"; | |
| 88 | + fl.ofn.nFilterIndex = 1; | |
| 89 | + fl.ofn.lpstrInitialDir = NULL; | |
| 90 | + | |
| 91 | + fl.ofn.nMaxFileTitle = strlen(title); | |
| 92 | + fl.ofn.lpstrFileTitle = (char *) title; | |
| 93 | + | |
| 94 | + // Guarda o valor atual | |
| 95 | + fl.ofn.nMaxFile = sizeof(fl.szName); | |
| 96 | + strncpy(fl.szName, filename, fl.ofn.nMaxFile-1); | |
| 97 | + | |
| 98 | + // Obtêm o tipo de diálogo. | |
| 99 | + switch(action) { | |
| 100 | + case GTK_FILE_CHOOSER_ACTION_OPEN: // Indicates open mode. The file chooser will only let the user pick an existing file. | |
| 101 | + // Enviar arquivo | |
| 102 | + // https://msdn.microsoft.com/en-us/library/windows/desktop/ms646928(v=vs.85).aspx | |
| 103 | + fl.ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; | |
| 104 | + | |
| 105 | + fl.mode = 0; | |
| 106 | + break; | |
| 107 | + | |
| 108 | + case GTK_FILE_CHOOSER_ACTION_SAVE: // Indicates save mode. The file chooser will let the user pick an existing file, or type in a new filename. | |
| 109 | + // Receber arquivo | |
| 110 | + // https://msdn.microsoft.com/en-us/library/windows/desktop/ms646839(v=vs.85).aspx | |
| 111 | + // https://msdn.microsoft.com/en-us/library/windows/desktop/ms646829(v=vs.85).aspx#open_file | |
| 112 | + fl.ofn.Flags = OFN_OVERWRITEPROMPT; | |
| 113 | + | |
| 114 | + fl.mode = 1; | |
| 115 | + break; | |
| 116 | + | |
| 117 | + case GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER: // Indicates an Open mode for selecting folders. The file chooser will let the user pick an existing folder. | |
| 118 | + fl.mode = 3; | |
| 119 | + break; | |
| 120 | + | |
| 121 | + case GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER: //Indicates a mode for creating a new folder. The file chooser will let the user name an existing or new folder. | |
| 122 | + fl.mode = 3; | |
| 123 | + break; | |
| 124 | + | |
| 125 | + default: | |
| 126 | + return NULL; | |
| 127 | + | |
| 128 | + } | |
| 129 | + | |
| 130 | + GThread * thd = g_thread_new("SelectFileDialog",(GThreadFunc) win32_select_file, &fl); | |
| 131 | + | |
| 132 | + gtk_widget_set_sensitive(GTK_WIDGET(widget),FALSE); | |
| 133 | + debug("%s: Keeping main loop alive",__FUNCTION__); | |
| 134 | + while(fl.mode != 3) { | |
| 135 | + gtk_main_iteration(); | |
| 136 | + } | |
| 137 | + gtk_widget_set_sensitive(GTK_WIDGET(widget),TRUE); | |
| 138 | + | |
| 139 | + debug("%s: Waiting for service thread", __FUNCTION__); | |
| 140 | + g_thread_join(thd); | |
| 141 | + debug("%s: Service thread ends", __FUNCTION__); | |
| 142 | + | |
| 143 | + return rc; | |
| 144 | +} | |
| 145 | +*/ | |
| 146 | + | |
| 147 | +gchar * v3270_select_file(GtkWidget *widget, const gchar *title, const gchar *button, GtkFileChooserAction action, const gchar *filename, const gchar *filter, ...) | |
| 148 | +{ | |
| 149 | + gchar *rc = NULL; | |
| 150 | + | |
| 151 | + GtkWidget * chooser = | |
| 152 | + gtk_file_chooser_dialog_new | |
| 153 | + ( | |
| 154 | + title, | |
| 155 | + GTK_WINDOW(gtk_widget_get_toplevel(widget)), | |
| 156 | + action, | |
| 157 | + _("_Cancel" ), GTK_RESPONSE_CANCEL, | |
| 158 | + button, GTK_RESPONSE_ACCEPT, | |
| 159 | + NULL | |
| 160 | + ); | |
| 161 | + | |
| 162 | + if(filename && *filename) | |
| 163 | + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(chooser),filename); | |
| 164 | + | |
| 165 | + // Setup filters | |
| 166 | + /* | |
| 167 | + va_list args; | |
| 168 | + va_start (args, filter); | |
| 169 | + while(filter) | |
| 170 | + { | |
| 171 | + const gchar * name = va_arg(args, const gchar *); | |
| 172 | + if(!name) | |
| 173 | + break; | |
| 174 | + | |
| 175 | + const gchar * pattern = va_arg(args, const gchar *); | |
| 176 | + if(!pattern) | |
| 177 | + break; | |
| 178 | + | |
| 179 | + GtkFileFilter *filter = gtk_file_filter_new(); | |
| 180 | + gtk_file_filter_set_name(filter,name); | |
| 181 | + gtk_file_filter_add_pattern(filter, pattern); | |
| 182 | + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(chooser), filter); | |
| 183 | + | |
| 184 | + } | |
| 185 | + va_end(args); | |
| 186 | + */ | |
| 187 | + | |
| 188 | + if(gtk_dialog_run(GTK_DIALOG(chooser)) == GTK_RESPONSE_ACCEPT) { | |
| 189 | + rc = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser)); | |
| 190 | + } | |
| 191 | + | |
| 192 | + gtk_widget_destroy(chooser); | |
| 193 | + | |
| 194 | + return rc; | |
| 195 | + | |
| 196 | +} | |
| 197 | + | ... | ... |
src/filetransfer/v3270ft.c
| ... | ... | @@ -299,6 +299,8 @@ static void select_local_file(GtkButton G_GNUC_UNUSED(*button), v3270ft *dialog) |
| 299 | 299 | static void icon_press(G_GNUC_UNUSED GtkEntry *entry, G_GNUC_UNUSED GtkEntryIconPosition icon_pos, G_GNUC_UNUSED GdkEvent *event, v3270ft *dialog) { |
| 300 | 300 | #endif // WIN32 |
| 301 | 301 | |
| 302 | + debug("%s",__FUNCTION__); | |
| 303 | + | |
| 302 | 304 | gchar *filename = v3270_select_file( |
| 303 | 305 | GTK_WIDGET(dialog), |
| 304 | 306 | _("Select local file"), |
| ... | ... | @@ -706,7 +708,11 @@ static void v3270ft_init(v3270ft *dialog) { |
| 706 | 708 | * |
| 707 | 709 | * Returns: a new #v3270ft. |
| 708 | 710 | */ |
| 709 | -LIB3270_EXPORT GtkWidget * v3270ft_new(void) { | |
| 710 | - return GTK_WIDGET(g_object_new(GTK_TYPE_V3270FT, "use-header-bar", (gint) 1, NULL)); | |
| 711 | +LIB3270_EXPORT GtkWidget * v3270ft_new(GtkWidget *parent) { | |
| 712 | + | |
| 713 | + GtkWidget * dialog = GTK_WIDGET(g_object_new(GTK_TYPE_V3270FT, "use-header-bar", (gint) 1, NULL)); | |
| 714 | + gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(gtk_widget_get_toplevel(parent))); | |
| 715 | + | |
| 716 | + return dialog; | |
| 711 | 717 | } |
| 712 | 718 | ... | ... |
src/include/v3270/filetransfer.h
| ... | ... | @@ -52,7 +52,7 @@ |
| 52 | 52 | typedef struct _v3270ftClass v3270ftClass; |
| 53 | 53 | |
| 54 | 54 | |
| 55 | - GtkWidget * v3270ft_new(void); | |
| 55 | + GtkWidget * v3270ft_new(GtkWidget *dialog); | |
| 56 | 56 | GType v3270ft_get_type(void); |
| 57 | 57 | void v3270ft_set_options(GtkWidget *widget, LIB3270_FT_OPTION opt); |
| 58 | 58 | LIB3270_FT_OPTION v3270ft_get_options(GtkWidget *widget); | ... | ... |
src/testprogram/testprogram.c
| ... | ... | @@ -148,7 +148,7 @@ static void disconnect_clicked(GtkButton G_GNUC_UNUSED(*button), GtkWidget *term |
| 148 | 148 | lib3270_disconnect(v3270_get_session(terminal)); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | -static void ft_clicked(GtkButton G_GNUC_UNUSED(*button), GtkWidget *terminal) | |
| 151 | +static void ft_clicked(GtkButton *button, GtkWidget *terminal) | |
| 152 | 152 | { |
| 153 | 153 | /* |
| 154 | 154 | GtkWidget * dialog = v3270_dialog_new(terminal, _("test"), _("test")); |
| ... | ... | @@ -194,7 +194,7 @@ static void ft_clicked(GtkButton G_GNUC_UNUSED(*button), GtkWidget *terminal) |
| 194 | 194 | // |
| 195 | 195 | // V5.1 dialog |
| 196 | 196 | // |
| 197 | - GtkWidget *dialog = v3270ft_new(); | |
| 197 | + GtkWidget *dialog = v3270ft_new(button); | |
| 198 | 198 | |
| 199 | 199 | /* |
| 200 | 200 | // |
| ... | ... | @@ -382,6 +382,9 @@ int main (int argc, char **argv) { |
| 382 | 382 | g_object_unref (app); |
| 383 | 383 | |
| 384 | 384 | g_message("rc=%d",status); |
| 385 | - return status; | |
| 385 | + | |
| 386 | + return 0; | |
| 387 | + | |
| 386 | 388 | } |
| 387 | 389 | |
| 390 | + | ... | ... |
v3270.cbp
| ... | ... | @@ -58,6 +58,9 @@ |
| 58 | 58 | <Unit filename="src/dialogs/hostselect.c"> |
| 59 | 59 | <Option compilerVar="CC" /> |
| 60 | 60 | </Unit> |
| 61 | + <Unit filename="src/dialogs/linux/select.c"> | |
| 62 | + <Option compilerVar="CC" /> | |
| 63 | + </Unit> | |
| 61 | 64 | <Unit filename="src/dialogs/print/begin.c"> |
| 62 | 65 | <Option compilerVar="CC" /> |
| 63 | 66 | </Unit> |
| ... | ... | @@ -72,9 +75,6 @@ |
| 72 | 75 | <Unit filename="src/dialogs/security.c"> |
| 73 | 76 | <Option compilerVar="CC" /> |
| 74 | 77 | </Unit> |
| 75 | - <Unit filename="src/dialogs/select.c"> | |
| 76 | - <Option compilerVar="CC" /> | |
| 77 | - </Unit> | |
| 78 | 78 | <Unit filename="src/dialogs/settingsdialog.c"> |
| 79 | 79 | <Option compilerVar="CC" /> |
| 80 | 80 | </Unit> |
| ... | ... | @@ -84,6 +84,9 @@ |
| 84 | 84 | <Unit filename="src/dialogs/transfer.c"> |
| 85 | 85 | <Option compilerVar="CC" /> |
| 86 | 86 | </Unit> |
| 87 | + <Unit filename="src/dialogs/windows/select.c"> | |
| 88 | + <Option compilerVar="CC" /> | |
| 89 | + </Unit> | |
| 87 | 90 | <Unit filename="src/filetransfer/activity.c"> |
| 88 | 91 | <Option compilerVar="CC" /> |
| 89 | 92 | </Unit> | ... | ... |