Commit 75f87222a875d96d5599fd08f0d7f1e0f5e56cdc

Authored by Perry Werneck
1 parent b749aacb

Reactivating use of windows registry.

@@ -85,7 +85,7 @@ else @@ -85,7 +85,7 @@ else
85 fi 85 fi
86 86
87 case "$host" in 87 case "$host" in
88 - *-mingw32) 88 + *-mingw32|*-pc-msys)
89 89
90 EXEEXT=".exe" 90 EXEEXT=".exe"
91 DLLPREFIX="" 91 DLLPREFIX=""
@@ -106,6 +106,8 @@ case "$host" in @@ -106,6 +106,8 @@ case "$host" in
106 STATIC_LDFLAGS="-static-libstdc++ -static-libgcc -static" 106 STATIC_LDFLAGS="-static-libstdc++ -static-libgcc -static"
107 DLL_LDFLAGS="-shared -Wl,--add-stdcall-alias" 107 DLL_LDFLAGS="-shared -Wl,--add-stdcall-alias"
108 108
  109 + AC_DEFINE(ENABLE_WINDOWS_REGISTRY)
  110 +
109 AC_CONFIG_FILES(win/makeruntime.sh) 111 AC_CONFIG_FILES(win/makeruntime.sh)
110 AC_CONFIG_FILES(win/copydeps.sh) 112 AC_CONFIG_FILES(win/copydeps.sh)
111 AC_CONFIG_FILES(win/$PACKAGE_TARNAME.nsi) 113 AC_CONFIG_FILES(win/$PACKAGE_TARNAME.nsi)
@@ -239,7 +241,7 @@ AC_CHECK_HEADER(libintl.h, [ @@ -239,7 +241,7 @@ AC_CHECK_HEADER(libintl.h, [
239 AC_DEFINE(HAVE_LIBINTL, 1) 241 AC_DEFINE(HAVE_LIBINTL, 1)
240 242
241 case "$host" in 243 case "$host" in
242 - *-mingw32) 244 + *-mingw32|*-pc-msys)
243 INTL_LIBS="-lintl" 245 INTL_LIBS="-lintl"
244 ;; 246 ;;
245 247
@@ -376,7 +378,7 @@ AC_ARG_ENABLE([pic], @@ -376,7 +378,7 @@ AC_ARG_ENABLE([pic],
376 esac 378 esac
377 379
378 dnl case "$host" in 380 dnl case "$host" in
379 -dnl *-mingw32) 381 +dnl *-mingw32|*-pc-msys)
380 dnl app_cv_pic="no" 382 dnl app_cv_pic="no"
381 dnl ;; 383 dnl ;;
382 dnl 384 dnl
@@ -449,7 +451,7 @@ AC_ARG_WITH([inet-ntop], [AS_HELP_STRING([--with-inet-ntop], [Assume that inet_n @@ -449,7 +451,7 @@ AC_ARG_WITH([inet-ntop], [AS_HELP_STRING([--with-inet-ntop], [Assume that inet_n
449 if test "$app_cv_inet_ntop" == "auto"; then 451 if test "$app_cv_inet_ntop" == "auto"; then
450 452
451 case "$host" in 453 case "$host" in
452 - *-mingw32) 454 + *-mingw32|*-pc-msys)
453 app_cv_inet_ntop="yes" 455 app_cv_inet_ntop="yes"
454 ;; 456 ;;
455 457
src/include/config.h.in
@@ -53,8 +53,8 @@ @@ -53,8 +53,8 @@
53 #undef SSL_ENABLE_CRL_CHECK 53 #undef SSL_ENABLE_CRL_CHECK
54 54
55 #ifdef WIN32 55 #ifdef WIN32
56 - #undef HAVE_WIN_REGISTRY  
57 -#endif // HAVE_WIN_REGISTRY 56 + #undef ENABLE_WINDOWS_REGISTRY
  57 +#endif // ENABLE_WINDOWS_REGISTRY
58 58
59 #undef HAVE_GNOME 59 #undef HAVE_GNOME
60 60
src/pw3270/common/common.h
@@ -87,14 +87,14 @@ @@ -87,14 +87,14 @@
87 87
88 void restore_window_from_config(const gchar *group, const gchar *key, GtkWidget *hwnd); 88 void restore_window_from_config(const gchar *group, const gchar *key, GtkWidget *hwnd);
89 89
90 -#ifdef HAVE_WIN_REGISTRY 90 +#ifdef ENABLE_WINDOWS_REGISTRY
91 gboolean get_registry_handle(const gchar *group, HKEY *hKey, REGSAM samDesired); 91 gboolean get_registry_handle(const gchar *group, HKEY *hKey, REGSAM samDesired);
92 void registry_foreach(HKEY parent, const gchar *name,void (*cbk)(const gchar *key, const gchar *val, gpointer *user_data), gpointer *user_data); 92 void registry_foreach(HKEY parent, const gchar *name,void (*cbk)(const gchar *key, const gchar *val, gpointer *user_data), gpointer *user_data);
93 void registry_set_double(HKEY hKey, const gchar *key, gdouble value); 93 void registry_set_double(HKEY hKey, const gchar *key, gdouble value);
94 gboolean registry_get_double(HKEY hKey, const gchar *key, gdouble *value); 94 gboolean registry_get_double(HKEY hKey, const gchar *key, gdouble *value);
95 #else 95 #else
96 GKeyFile * get_application_keyfile(void); 96 GKeyFile * get_application_keyfile(void);
97 -#endif // HAVE_WIN_REGISTRY 97 +#endif // ENABLE_WINDOWS_REGISTRY
98 98
99 99
100 #endif 100 #endif
src/pw3270/common/config.c
@@ -43,7 +43,6 @@ @@ -43,7 +43,6 @@
43 #ifdef WIN32 43 #ifdef WIN32
44 44
45 #include <windows.h> 45 #include <windows.h>
46 - // #define HAVE_WIN_REGISTRY 1  
47 46
48 #ifndef KEY_WOW64_64KEY 47 #ifndef KEY_WOW64_64KEY
49 #define KEY_WOW64_64KEY 0x0100 48 #define KEY_WOW64_64KEY 0x0100
@@ -57,7 +56,7 @@ @@ -57,7 +56,7 @@
57 56
58 /*--[ Globals ]--------------------------------------------------------------------------------------*/ 57 /*--[ Globals ]--------------------------------------------------------------------------------------*/
59 58
60 -#ifdef HAVE_WIN_REGISTRY 59 +#ifdef ENABLE_WINDOWS_REGISTRY
61 60
62 static const gchar * registry_path = "SOFTWARE"; 61 static const gchar * registry_path = "SOFTWARE";
63 62
@@ -65,11 +64,11 @@ @@ -65,11 +64,11 @@
65 64
66 static GKeyFile * program_config = NULL; 65 static GKeyFile * program_config = NULL;
67 66
68 -#endif // HAVE_WIN_REGISTRY 67 +#endif // ENABLE_WINDOWS_REGISTRY
69 68
70 /*--[ Implement ]------------------------------------------------------------------------------------*/ 69 /*--[ Implement ]------------------------------------------------------------------------------------*/
71 70
72 -#ifdef HAVE_WIN_REGISTRY 71 +#ifdef ENABLE_WINDOWS_REGISTRY
73 72
74 enum REG_KEY 73 enum REG_KEY
75 { 74 {
@@ -270,11 +269,11 @@ @@ -270,11 +269,11 @@
270 return g_build_filename(g_get_user_config_dir(),name,NULL); 269 return g_build_filename(g_get_user_config_dir(),name,NULL);
271 270
272 } 271 }
273 -#endif // #ifdef HAVE_WIN_REGISTRY 272 +#endif // #ifdef ENABLE_WINDOWS_REGISTRY
274 273
275 gboolean get_boolean_from_config(const gchar *group, const gchar *key, gboolean def) 274 gboolean get_boolean_from_config(const gchar *group, const gchar *key, gboolean def)
276 { 275 {
277 -#ifdef HAVE_WIN_REGISTRY 276 +#ifdef ENABLE_WINDOWS_REGISTRY
278 gboolean ret = def; 277 gboolean ret = def;
279 HKEY hKey; 278 HKEY hKey;
280 279
@@ -308,14 +307,14 @@ @@ -308,14 +307,14 @@
308 else 307 else
309 return val; 308 return val;
310 } 309 }
311 -#endif // HAVE_WIN_REGISTRY 310 +#endif // ENABLE_WINDOWS_REGISTRY
312 311
313 return def; 312 return def;
314 } 313 }
315 314
316 gint get_integer_from_config(const gchar *group, const gchar *key, gint def) 315 gint get_integer_from_config(const gchar *group, const gchar *key, gint def)
317 { 316 {
318 -#ifdef HAVE_WIN_REGISTRY 317 +#ifdef ENABLE_WINDOWS_REGISTRY
319 318
320 HKEY key_handle; 319 HKEY key_handle;
321 320
@@ -351,7 +350,7 @@ @@ -351,7 +350,7 @@
351 else 350 else
352 return val; 351 return val;
353 } 352 }
354 -#endif // HAVE_WIN_REGISTRY 353 +#endif // ENABLE_WINDOWS_REGISTRY
355 354
356 return def; 355 return def;
357 } 356 }
@@ -359,7 +358,7 @@ @@ -359,7 +358,7 @@
359 358
360 gchar * get_string_from_config(const gchar *group, const gchar *key, const gchar *def) 359 gchar * get_string_from_config(const gchar *group, const gchar *key, const gchar *def)
361 { 360 {
362 -#ifdef HAVE_WIN_REGISTRY 361 +#ifdef ENABLE_WINDOWS_REGISTRY
363 362
364 HKEY key_handle; 363 HKEY key_handle;
365 unsigned long datalen = 4096; 364 unsigned long datalen = 4096;
@@ -406,12 +405,12 @@ @@ -406,12 +405,12 @@
406 405
407 return NULL; 406 return NULL;
408 407
409 -#endif // HAVE_WIN_REGISTRY 408 +#endif // ENABLE_WINDOWS_REGISTRY
410 } 409 }
411 410
412 void configuration_init(void) 411 void configuration_init(void)
413 { 412 {
414 -#ifndef HAVE_WIN_REGISTRY 413 +#ifndef ENABLE_WINDOWS_REGISTRY
415 gchar *filename = search_for_ini(); 414 gchar *filename = search_for_ini();
416 415
417 if(program_config) 416 if(program_config)
@@ -426,14 +425,14 @@ void configuration_init(void) @@ -426,14 +425,14 @@ void configuration_init(void)
426 g_free(filename); 425 g_free(filename);
427 } 426 }
428 427
429 -#endif // HAVE_WIN_REGISTRY 428 +#endif // ENABLE_WINDOWS_REGISTRY
430 } 429 }
431 430
432 static void set_string(const gchar *group, const gchar *key, const gchar *fmt, va_list args) 431 static void set_string(const gchar *group, const gchar *key, const gchar *fmt, va_list args)
433 { 432 {
434 gchar * value = g_strdup_vprintf(fmt,args); 433 gchar * value = g_strdup_vprintf(fmt,args);
435 434
436 -#ifdef HAVE_WIN_REGISTRY 435 +#ifdef ENABLE_WINDOWS_REGISTRY
437 436
438 gchar * path = g_strdup_printf("%s\\%s\\%s",registry_path,g_get_application_name(),group); 437 gchar * path = g_strdup_printf("%s\\%s\\%s",registry_path,g_get_application_name(),group);
439 HKEY hKey; 438 HKEY hKey;
@@ -466,7 +465,7 @@ void set_string_to_config(const gchar *group, const gchar *key, const gchar *fmt @@ -466,7 +465,7 @@ void set_string_to_config(const gchar *group, const gchar *key, const gchar *fmt
466 465
467 void set_boolean_to_config(const gchar *group, const gchar *key, gboolean val) 466 void set_boolean_to_config(const gchar *group, const gchar *key, gboolean val)
468 { 467 {
469 -#ifdef HAVE_WIN_REGISTRY 468 +#ifdef ENABLE_WINDOWS_REGISTRY
470 469
471 HKEY hKey; 470 HKEY hKey;
472 DWORD disp; 471 DWORD disp;
@@ -502,13 +501,13 @@ void set_boolean_to_config(const gchar *group, const gchar *key, gboolean val) @@ -502,13 +501,13 @@ void set_boolean_to_config(const gchar *group, const gchar *key, gboolean val)
502 if(program_config) 501 if(program_config)
503 g_key_file_set_boolean(program_config,group,key,val); 502 g_key_file_set_boolean(program_config,group,key,val);
504 503
505 -#endif // HAVE_WIN_REGISTRY 504 +#endif // ENABLE_WINDOWS_REGISTRY
506 505
507 } 506 }
508 507
509 void set_integer_to_config(const gchar *group, const gchar *key, gint val) 508 void set_integer_to_config(const gchar *group, const gchar *key, gint val)
510 { 509 {
511 -#ifdef HAVE_WIN_REGISTRY 510 +#ifdef ENABLE_WINDOWS_REGISTRY
512 511
513 HKEY hKey; 512 HKEY hKey;
514 DWORD disp; 513 DWORD disp;
@@ -544,13 +543,13 @@ void set_integer_to_config(const gchar *group, const gchar *key, gint val) @@ -544,13 +543,13 @@ void set_integer_to_config(const gchar *group, const gchar *key, gint val)
544 if(program_config) 543 if(program_config)
545 g_key_file_set_integer(program_config,group,key,val); 544 g_key_file_set_integer(program_config,group,key,val);
546 545
547 -#endif // HAVE_WIN_REGISTRY 546 +#endif // ENABLE_WINDOWS_REGISTRY
548 547
549 } 548 }
550 549
551 void configuration_deinit(void) 550 void configuration_deinit(void)
552 { 551 {
553 -#ifdef HAVE_WIN_REGISTRY 552 +#ifdef ENABLE_WINDOWS_REGISTRY
554 553
555 #else 554 #else
556 555
@@ -576,7 +575,7 @@ void configuration_deinit(void) @@ -576,7 +575,7 @@ void configuration_deinit(void)
576 g_key_file_free(program_config); 575 g_key_file_free(program_config);
577 program_config = NULL; 576 program_config = NULL;
578 577
579 -#endif // HAVE_WIN_REGISTRY 578 +#endif // ENABLE_WINDOWS_REGISTRY
580 } 579 }
581 580
582 gchar * build_data_filename(const gchar *first_element, ...) 581 gchar * build_data_filename(const gchar *first_element, ...)
@@ -606,7 +605,7 @@ gchar * filename_from_va(const gchar *first_element, va_list args) @@ -606,7 +605,7 @@ gchar * filename_from_va(const gchar *first_element, va_list args)
606 605
607 g_autofree gchar * suffix = g_string_free(result, FALSE); 606 g_autofree gchar * suffix = g_string_free(result, FALSE);
608 607
609 -#if defined( HAVE_WIN_REGISTRY ) 608 +#if defined( ENABLE_WINDOWS_REGISTRY )
610 for(p=0;p<G_N_ELEMENTS(appname) && !result;p++) 609 for(p=0;p<G_N_ELEMENTS(appname) && !result;p++)
611 { 610 {
612 g_autofree gchar * path = g_strconcat("Software\\",appname[p],NULL); 611 g_autofree gchar * path = g_strconcat("Software\\",appname[p],NULL);
@@ -639,7 +638,7 @@ gchar * filename_from_va(const gchar *first_element, va_list args) @@ -639,7 +638,7 @@ gchar * filename_from_va(const gchar *first_element, va_list args)
639 } 638 }
640 639
641 } 640 }
642 -#endif // HAVE_WIN_REGISTRY 641 +#endif // ENABLE_WINDOWS_REGISTRY
643 642
644 #ifdef _WIN32 643 #ifdef _WIN32
645 for(p=0;p<G_N_ELEMENTS(appname) && !result;p++) 644 for(p=0;p<G_N_ELEMENTS(appname) && !result;p++)
@@ -680,7 +679,7 @@ gchar * filename_from_va(const gchar *first_element, va_list args) @@ -680,7 +679,7 @@ gchar * filename_from_va(const gchar *first_element, va_list args)
680 return g_build_filename(".",suffix,NULL); 679 return g_build_filename(".",suffix,NULL);
681 } 680 }
682 681
683 -#ifdef HAVE_WIN_REGISTRY 682 +#ifdef ENABLE_WINDOWS_REGISTRY
684 gboolean get_registry_handle(const gchar *group, HKEY *hKey, REGSAM samDesired) 683 gboolean get_registry_handle(const gchar *group, HKEY *hKey, REGSAM samDesired)
685 { 684 {
686 gboolean ret; 685 gboolean ret;
@@ -703,7 +702,7 @@ GKeyFile * get_application_keyfile(void) @@ -703,7 +702,7 @@ GKeyFile * get_application_keyfile(void)
703 configuration_init(); 702 configuration_init();
704 return program_config; 703 return program_config;
705 } 704 }
706 -#endif // HAVE_WIN_REGISTRY 705 +#endif // ENABLE_WINDOWS_REGISTRY
707 706
708 static const struct _WindowState 707 static const struct _WindowState
709 { 708 {
@@ -719,7 +718,7 @@ GKeyFile * get_application_keyfile(void) @@ -719,7 +718,7 @@ GKeyFile * get_application_keyfile(void)
719 718
720 void save_window_state_to_config(const gchar *group, const gchar *key, GdkWindowState CurrentState) 719 void save_window_state_to_config(const gchar *group, const gchar *key, GdkWindowState CurrentState)
721 { 720 {
722 -#if defined( HAVE_WIN_REGISTRY ) 721 +#if defined( ENABLE_WINDOWS_REGISTRY )
723 722
724 gchar * path = g_strdup_printf("%s\\%s\\%s\\%s",registry_path,g_get_application_name(),group,key); 723 gchar * path = g_strdup_printf("%s\\%s\\%s\\%s",registry_path,g_get_application_name(),group,key);
725 724
@@ -751,12 +750,12 @@ void save_window_state_to_config(const gchar *group, const gchar *key, GdkWindow @@ -751,12 +750,12 @@ void save_window_state_to_config(const gchar *group, const gchar *key, GdkWindow
751 750
752 g_free(id); 751 g_free(id);
753 752
754 -#endif // HAVE_WIN_REGISTRY 753 +#endif // ENABLE_WINDOWS_REGISTRY
755 } 754 }
756 755
757 void save_window_size_to_config(const gchar *group, const gchar *key, GtkWidget *hwnd) 756 void save_window_size_to_config(const gchar *group, const gchar *key, GtkWidget *hwnd)
758 { 757 {
759 -#if defined( HAVE_WIN_REGISTRY ) 758 +#if defined( ENABLE_WINDOWS_REGISTRY )
760 759
761 gchar * path = g_strdup_printf("%s\\%s\\%s\\%s",registry_path,g_get_application_name(),group,key); 760 gchar * path = g_strdup_printf("%s\\%s\\%s\\%s",registry_path,g_get_application_name(),group,key);
762 761
@@ -786,10 +785,10 @@ void save_window_size_to_config(const gchar *group, const gchar *key, GtkWidget @@ -786,10 +785,10 @@ void save_window_size_to_config(const gchar *group, const gchar *key, GtkWidget
786 785
787 g_free(id); 786 g_free(id);
788 787
789 -#endif // HAVE_WIN_REGISTRY 788 +#endif // ENABLE_WINDOWS_REGISTRY
790 } 789 }
791 790
792 -#if defined( HAVE_WIN_REGISTRY ) 791 +#if defined( ENABLE_WINDOWS_REGISTRY )
793 static void restore_window_from_regkey(GtkWidget *hwnd, HKEY hKey, const gchar *path) 792 static void restore_window_from_regkey(GtkWidget *hwnd, HKEY hKey, const gchar *path)
794 { 793 {
795 int f; 794 int f;
@@ -835,11 +834,11 @@ static void restore_window_from_regkey(GtkWidget *hwnd, HKEY hKey, const gchar * @@ -835,11 +834,11 @@ static void restore_window_from_regkey(GtkWidget *hwnd, HKEY hKey, const gchar *
835 834
836 835
837 } 836 }
838 -#endif // HAVE_WIN_REGISTRY 837 +#endif // ENABLE_WINDOWS_REGISTRY
839 838
840 void restore_window_from_config(const gchar *group, const gchar *key, GtkWidget *hwnd) 839 void restore_window_from_config(const gchar *group, const gchar *key, GtkWidget *hwnd)
841 { 840 {
842 -#if defined( HAVE_WIN_REGISTRY ) 841 +#if defined( ENABLE_WINDOWS_REGISTRY )
843 842
844 gchar * path = g_strdup_printf("%s\\%s\\%s\\%s",registry_path,g_get_application_name(),group,key); 843 gchar * path = g_strdup_printf("%s\\%s\\%s\\%s",registry_path,g_get_application_name(),group,key);
845 HKEY hKey; 844 HKEY hKey;
@@ -885,7 +884,7 @@ void restore_window_from_config(const gchar *group, const gchar *key, GtkWidget @@ -885,7 +884,7 @@ void restore_window_from_config(const gchar *group, const gchar *key, GtkWidget
885 884
886 g_free(id); 885 g_free(id);
887 886
888 -#endif // HAVE_WIN_REGISTRY 887 +#endif // ENABLE_WINDOWS_REGISTRY
889 888
890 } 889 }
891 890
src/pw3270/print.c
@@ -272,7 +272,7 @@ static gchar * enum_to_string(GType type, guint enum_value) @@ -272,7 +272,7 @@ static gchar * enum_to_string(GType type, guint enum_value)
272 272
273 trace("Saving settings PrintSettings=%p page_setup=%p",settings,pgsetup); 273 trace("Saving settings PrintSettings=%p page_setup=%p",settings,pgsetup);
274 274
275 -#ifdef HAVE_WIN_REGISTRY 275 +#ifdef ENABLE_WINDOWS_REGISTRY
276 HKEY registry; 276 HKEY registry;
277 277
278 if(get_registry_handle("print",&registry,KEY_SET_VALUE)) 278 if(get_registry_handle("print",&registry,KEY_SET_VALUE))
@@ -625,7 +625,7 @@ static gchar * enum_to_string(GType type, guint enum_value) @@ -625,7 +625,7 @@ static gchar * enum_to_string(GType type, guint enum_value)
625 625
626 // Load page and print settings 626 // Load page and print settings
627 { 627 {
628 -#ifdef HAVE_WIN_REGISTRY 628 +#ifdef ENABLE_WINDOWS_REGISTRY
629 629
630 HKEY registry; 630 HKEY registry;
631 631
src/pw3270/window.c
@@ -95,6 +95,8 @@ @@ -95,6 +95,8 @@
95 NULL 95 NULL
96 }; 96 };
97 97
  98 +static GtkWidget * trace_window = NULL;
  99 +
98 /*--[ Implement ]------------------------------------------------------------------------------------*/ 100 /*--[ Implement ]------------------------------------------------------------------------------------*/
99 101
100 #if GTK_CHECK_VERSION(3,0,0) 102 #if GTK_CHECK_VERSION(3,0,0)
@@ -157,65 +159,7 @@ @@ -157,65 +159,7 @@
157 159
158 } 160 }
159 161
160 - /*  
161 - static void g_trace(H3270 *hSession, const char *fmt, va_list args)  
162 - {  
163 - gchar *ptr = g_strdup_vprintf(fmt,args);  
164 -  
165 - if(tracefile)  
166 - {  
167 - // Has trace file, use it  
168 - int err;  
169 -  
170 - FILE *out = fopen(tracefile,"a");  
171 - err = errno;  
172 -  
173 - if(!out)  
174 - {  
175 - // Error opening trace file, notify user and disable it  
176 - GtkWidget *popup = gtk_message_dialog_new_with_markup(  
177 - GTK_WINDOW(pw3270_get_toplevel()),  
178 - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,  
179 - GTK_MESSAGE_ERROR,GTK_BUTTONS_CLOSE,  
180 - _( "Can't save trace data to file %s" ),tracefile);  
181 -  
182 - gtk_window_set_title(GTK_WINDOW(popup),_("Can't open file"));  
183 -  
184 - gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(popup),"%s",strerror(err));  
185 -  
186 - gtk_dialog_run(GTK_DIALOG(popup));  
187 - gtk_widget_destroy(popup);  
188 -  
189 - tracefile = NULL;  
190 - }  
191 - else  
192 - {  
193 - fprintf(out,"%s",ptr);  
194 - fclose(out);  
195 - }  
196 - }  
197 - else  
198 - {  
199 - // No trace file, open standard window  
200 - gchar * utftext = g_convert_with_fallback(ptr,-1,"UTF-8",lib3270_get_display_charset(hSession),"?",NULL,NULL,NULL);  
201 -  
202 - if(!trace_window)  
203 - {  
204 - trace_window = v3270_trace_new_from_session(hSession);  
205 - v3270_trace_set_destroy_on_close(trace_window,TRUE);  
206 - g_signal_connect(trace_window, "destroy", G_CALLBACK(trace_window_destroy), hSession);  
207 - gtk_window_set_default_size(GTK_WINDOW(trace_window),590,430);  
208 - gtk_widget_show(trace_window);  
209 - }  
210 - v3270_trace_printf(trace_window,"%s",utftext);  
211 - g_free(utftext);  
212 - }  
213 -  
214 - g_free(ptr);  
215 - }  
216 - */  
217 -  
218 - static void trace_file(G_GNUC_UNUSED H3270 *hSession, void * userdata, const char *fmt, va_list args) 162 + static void trace_on_file(G_GNUC_UNUSED H3270 *hSession, void * userdata, const char *fmt, va_list args)
219 { 163 {
220 int err; 164 int err;
221 165
@@ -255,6 +199,9 @@ @@ -255,6 +199,9 @@
255 lib3270_set_toggle(hSession,LIB3270_TOGGLE_SCREEN_TRACE,0); 199 lib3270_set_toggle(hSession,LIB3270_TOGGLE_SCREEN_TRACE,0);
256 lib3270_set_toggle(hSession,LIB3270_TOGGLE_EVENT_TRACE,0); 200 lib3270_set_toggle(hSession,LIB3270_TOGGLE_EVENT_TRACE,0);
257 lib3270_set_toggle(hSession,LIB3270_TOGGLE_NETWORK_TRACE,0); 201 lib3270_set_toggle(hSession,LIB3270_TOGGLE_NETWORK_TRACE,0);
  202 +
  203 + trace_window = NULL;
  204 +
258 } 205 }
259 206
260 struct trace_data 207 struct trace_data
@@ -265,20 +212,21 @@ @@ -265,20 +212,21 @@
265 212
266 static gboolean bg_trace_window(struct trace_data *data) 213 static gboolean bg_trace_window(struct trace_data *data)
267 { 214 {
268 - GtkWidget * widget = v3270_trace_new_from_session(data->hSession,data->text); 215 + if(!trace_window)
  216 + trace_window = v3270_trace_new_from_session(data->hSession,data->text);
269 217
270 - v3270_trace_set_destroy_on_close(widget,TRUE); 218 + v3270_trace_set_destroy_on_close(trace_window,TRUE);
271 219
272 - g_signal_connect(widget, "destroy", G_CALLBACK(trace_window_destroy), data->hSession); 220 + g_signal_connect(trace_window, "destroy", G_CALLBACK(trace_window_destroy), data->hSession);
273 221
274 - gtk_widget_show_all(widget); 222 + gtk_widget_show_all(trace_window);
275 223
276 g_free(data->text); 224 g_free(data->text);
277 225
278 return FALSE; 226 return FALSE;
279 } 227 }
280 228
281 - static void trace_window(G_GNUC_UNUSED H3270 *hSession, G_GNUC_UNUSED void * userdata, const char *fmt, va_list args) 229 + static void trace_on_window(G_GNUC_UNUSED H3270 *hSession, G_GNUC_UNUSED void * userdata, const char *fmt, va_list args)
282 { 230 {
283 struct trace_data * data = g_new0(struct trace_data,1); 231 struct trace_data * data = g_new0(struct trace_data,1);
284 232
@@ -296,11 +244,11 @@ @@ -296,11 +244,11 @@
296 244
297 if(tracefile) 245 if(tracefile)
298 { 246 {
299 - lib3270_set_trace_handler(pw3270_get_session(widget),trace_file,(void *) widget); 247 + lib3270_set_trace_handler(pw3270_get_session(widget),trace_on_file,(void *) widget);
300 } 248 }
301 else 249 else
302 { 250 {
303 - lib3270_set_trace_handler(pw3270_get_session(widget),trace_window,(void *) widget); 251 + lib3270_set_trace_handler(pw3270_get_session(widget),trace_on_window,(void *) widget);
304 } 252 }
305 253
306 if(host) 254 if(host)