Commit e133a2893964a94d9b1a0e7a7800fbef96e0ba74
1 parent
d5af298c
Exists in
master
and in
5 other branches
Incluindo opção para desabilitar o uso do registry windows
Showing
5 changed files
with
62 additions
and
36 deletions
Show diff stats
configure.ac
@@ -239,6 +239,23 @@ AC_ARG_ENABLE([pic], | @@ -239,6 +239,23 @@ AC_ARG_ENABLE([pic], | ||
239 | fi | 239 | fi |
240 | ]) | 240 | ]) |
241 | 241 | ||
242 | +AC_ARG_ENABLE([registry], | ||
243 | + [AS_HELP_STRING([--disable-registry], [disable configurations in windows registry])], | ||
244 | +[ | ||
245 | + app_cv_registry="$enableval" | ||
246 | +],[ | ||
247 | + case "$host" in | ||
248 | + *-mingw32) | ||
249 | + app_cv_registry="yes" | ||
250 | + ;; | ||
251 | + | ||
252 | + *) | ||
253 | + app_cv_registry="no" | ||
254 | + esac | ||
255 | + | ||
256 | +]) | ||
257 | + | ||
258 | + | ||
242 | if test "$app_cv_pic" == "yes"; then | 259 | if test "$app_cv_pic" == "yes"; then |
243 | DLL_CFLAGS="$DLL_CFLAGS -fPIC" | 260 | DLL_CFLAGS="$DLL_CFLAGS -fPIC" |
244 | fi | 261 | fi |
@@ -361,6 +378,9 @@ if test "$app_cv_rexx" == "yes"; then | @@ -361,6 +378,9 @@ if test "$app_cv_rexx" == "yes"; then | ||
361 | fi | 378 | fi |
362 | fi | 379 | fi |
363 | 380 | ||
381 | +if test "$app_cv_registry" == "yes"; then | ||
382 | + AC_DEFINE(HAVE_WIN_REGISTRY) | ||
383 | +fi | ||
364 | 384 | ||
365 | if test "$app_cv_rexx" == "yes"; then | 385 | if test "$app_cv_rexx" == "yes"; then |
366 | AC_DEFINE(HAVE_REXX) | 386 | AC_DEFINE(HAVE_REXX) |
src/include/lib3270/config.h.in
@@ -43,6 +43,10 @@ | @@ -43,6 +43,10 @@ | ||
43 | #undef HAVE_LIBINTL | 43 | #undef HAVE_LIBINTL |
44 | #undef HAVE_GETADDRINFO | 44 | #undef HAVE_GETADDRINFO |
45 | 45 | ||
46 | +#ifdef WIN32 | ||
47 | + #undef HAVE_WIN_REGISTRY | ||
48 | +#endif // HAVE_WIN_REGISTRY | ||
49 | + | ||
46 | #undef HAVE_GNOME | 50 | #undef HAVE_GNOME |
47 | 51 | ||
48 | #undef HAVE_GTKMAC | 52 | #undef HAVE_GTKMAC |
src/pw3270/common/common.h
@@ -39,7 +39,6 @@ | @@ -39,7 +39,6 @@ | ||
39 | #ifdef WIN32 | 39 | #ifdef WIN32 |
40 | 40 | ||
41 | #include <windows.h> | 41 | #include <windows.h> |
42 | - #define WIN_REGISTRY_ENABLED 1 | ||
43 | 42 | ||
44 | #ifndef KEY_WOW64_64KEY | 43 | #ifndef KEY_WOW64_64KEY |
45 | #define KEY_WOW64_64KEY 0x0100 | 44 | #define KEY_WOW64_64KEY 0x0100 |
@@ -88,14 +87,14 @@ | @@ -88,14 +87,14 @@ | ||
88 | 87 | ||
89 | 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); |
90 | 89 | ||
91 | -#ifdef WIN_REGISTRY_ENABLED | 90 | +#ifdef HAVE_WIN_REGISTRY |
92 | gboolean get_registry_handle(const gchar *group, HKEY *hKey, REGSAM samDesired); | 91 | gboolean get_registry_handle(const gchar *group, HKEY *hKey, REGSAM samDesired); |
93 | 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); |
94 | void registry_set_double(HKEY hKey, const gchar *key, gdouble value); | 93 | void registry_set_double(HKEY hKey, const gchar *key, gdouble value); |
95 | gboolean registry_get_double(HKEY hKey, const gchar *key, gdouble *value); | 94 | gboolean registry_get_double(HKEY hKey, const gchar *key, gdouble *value); |
96 | #else | 95 | #else |
97 | GKeyFile * get_application_keyfile(void); | 96 | GKeyFile * get_application_keyfile(void); |
98 | -#endif // WIN_REGISTRY_ENABLED | 97 | +#endif // HAVE_WIN_REGISTRY |
99 | 98 | ||
100 | 99 | ||
101 | #endif | 100 | #endif |
src/pw3270/common/config.c
@@ -37,7 +37,7 @@ | @@ -37,7 +37,7 @@ | ||
37 | #ifdef WIN32 | 37 | #ifdef WIN32 |
38 | 38 | ||
39 | #include <windows.h> | 39 | #include <windows.h> |
40 | - #define WIN_REGISTRY_ENABLED 1 | 40 | + // #define HAVE_WIN_REGISTRY 1 |
41 | 41 | ||
42 | #ifndef KEY_WOW64_64KEY | 42 | #ifndef KEY_WOW64_64KEY |
43 | #define KEY_WOW64_64KEY 0x0100 | 43 | #define KEY_WOW64_64KEY 0x0100 |
@@ -51,16 +51,16 @@ | @@ -51,16 +51,16 @@ | ||
51 | 51 | ||
52 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ | 52 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ |
53 | 53 | ||
54 | -#ifdef WIN_REGISTRY_ENABLED | 54 | +#ifdef HAVE_WIN_REGISTRY |
55 | 55 | ||
56 | - static const gchar *registry_path = "SOFTWARE"; | 56 | + static const gchar * registry_path = "SOFTWARE"; |
57 | 57 | ||
58 | #else | 58 | #else |
59 | 59 | ||
60 | static GKeyFile * program_config = NULL; | 60 | static GKeyFile * program_config = NULL; |
61 | static const gchar * mask = "%s" G_DIR_SEPARATOR_S "%s.conf"; | 61 | static const gchar * mask = "%s" G_DIR_SEPARATOR_S "%s.conf"; |
62 | 62 | ||
63 | -#endif // WIN_REGISTRY_ENABLED | 63 | +#endif // HAVE_WIN_REGISTRY |
64 | 64 | ||
65 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 65 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
66 | 66 | ||
@@ -94,7 +94,7 @@ gchar * get_last_error_msg(void) | @@ -94,7 +94,7 @@ gchar * get_last_error_msg(void) | ||
94 | #endif // WIN32 | 94 | #endif // WIN32 |
95 | */ | 95 | */ |
96 | 96 | ||
97 | -#ifdef WIN_REGISTRY_ENABLED | 97 | +#ifdef HAVE_WIN_REGISTRY |
98 | 98 | ||
99 | static BOOL registry_open_key(const gchar *group, REGSAM samDesired, HKEY *hKey) | 99 | static BOOL registry_open_key(const gchar *group, REGSAM samDesired, HKEY *hKey) |
100 | { | 100 | { |
@@ -236,11 +236,11 @@ gchar * get_last_error_msg(void) | @@ -236,11 +236,11 @@ gchar * get_last_error_msg(void) | ||
236 | 236 | ||
237 | return g_strdup_printf(mask,g_get_user_config_dir(),g_get_application_name()); | 237 | return g_strdup_printf(mask,g_get_user_config_dir(),g_get_application_name()); |
238 | } | 238 | } |
239 | -#endif // #ifdef WIN_REGISTRY_ENABLED | 239 | +#endif // #ifdef HAVE_WIN_REGISTRY |
240 | 240 | ||
241 | gboolean get_boolean_from_config(const gchar *group, const gchar *key, gboolean def) | 241 | gboolean get_boolean_from_config(const gchar *group, const gchar *key, gboolean def) |
242 | { | 242 | { |
243 | -#ifdef WIN_REGISTRY_ENABLED | 243 | +#ifdef HAVE_WIN_REGISTRY |
244 | 244 | ||
245 | HKEY key_handle; | 245 | HKEY key_handle; |
246 | 246 | ||
@@ -276,14 +276,14 @@ gchar * get_last_error_msg(void) | @@ -276,14 +276,14 @@ gchar * get_last_error_msg(void) | ||
276 | else | 276 | else |
277 | return val; | 277 | return val; |
278 | } | 278 | } |
279 | -#endif // WIN_REGISTRY_ENABLED | 279 | +#endif // HAVE_WIN_REGISTRY |
280 | 280 | ||
281 | return def; | 281 | return def; |
282 | } | 282 | } |
283 | 283 | ||
284 | gint get_integer_from_config(const gchar *group, const gchar *key, gint def) | 284 | gint get_integer_from_config(const gchar *group, const gchar *key, gint def) |
285 | { | 285 | { |
286 | -#ifdef WIN_REGISTRY_ENABLED | 286 | +#ifdef HAVE_WIN_REGISTRY |
287 | 287 | ||
288 | HKEY key_handle; | 288 | HKEY key_handle; |
289 | 289 | ||
@@ -319,7 +319,7 @@ gchar * get_last_error_msg(void) | @@ -319,7 +319,7 @@ gchar * get_last_error_msg(void) | ||
319 | else | 319 | else |
320 | return val; | 320 | return val; |
321 | } | 321 | } |
322 | -#endif // WIN_REGISTRY_ENABLED | 322 | +#endif // HAVE_WIN_REGISTRY |
323 | 323 | ||
324 | return def; | 324 | return def; |
325 | } | 325 | } |
@@ -327,7 +327,7 @@ gchar * get_last_error_msg(void) | @@ -327,7 +327,7 @@ gchar * get_last_error_msg(void) | ||
327 | 327 | ||
328 | gchar * get_string_from_config(const gchar *group, const gchar *key, const gchar *def) | 328 | gchar * get_string_from_config(const gchar *group, const gchar *key, const gchar *def) |
329 | { | 329 | { |
330 | -#ifdef WIN_REGISTRY_ENABLED | 330 | +#ifdef HAVE_WIN_REGISTRY |
331 | 331 | ||
332 | HKEY key_handle; | 332 | HKEY key_handle; |
333 | unsigned long datalen = 4096; | 333 | unsigned long datalen = 4096; |
@@ -375,12 +375,12 @@ gchar * get_last_error_msg(void) | @@ -375,12 +375,12 @@ gchar * get_last_error_msg(void) | ||
375 | 375 | ||
376 | return NULL; | 376 | return NULL; |
377 | 377 | ||
378 | -#endif // WIN_REGISTRY_ENABLED | 378 | +#endif // HAVE_WIN_REGISTRY |
379 | } | 379 | } |
380 | 380 | ||
381 | void configuration_init(void) | 381 | void configuration_init(void) |
382 | { | 382 | { |
383 | -#ifndef WIN_REGISTRY_ENABLED | 383 | +#ifndef HAVE_WIN_REGISTRY |
384 | gchar *filename = search_for_ini(); | 384 | gchar *filename = search_for_ini(); |
385 | 385 | ||
386 | if(program_config) | 386 | if(program_config) |
@@ -394,14 +394,14 @@ void configuration_init(void) | @@ -394,14 +394,14 @@ void configuration_init(void) | ||
394 | g_free(filename); | 394 | g_free(filename); |
395 | } | 395 | } |
396 | 396 | ||
397 | -#endif // WIN_REGISTRY_ENABLED | 397 | +#endif // HAVE_WIN_REGISTRY |
398 | } | 398 | } |
399 | 399 | ||
400 | static void set_string(const gchar *group, const gchar *key, const gchar *fmt, va_list args) | 400 | static void set_string(const gchar *group, const gchar *key, const gchar *fmt, va_list args) |
401 | { | 401 | { |
402 | gchar * value = g_strdup_vprintf(fmt,args); | 402 | gchar * value = g_strdup_vprintf(fmt,args); |
403 | 403 | ||
404 | -#ifdef WIN_REGISTRY_ENABLED | 404 | +#ifdef HAVE_WIN_REGISTRY |
405 | 405 | ||
406 | gchar * path = g_strdup_printf("%s\\%s\\%s",registry_path,g_get_application_name(),group); | 406 | gchar * path = g_strdup_printf("%s\\%s\\%s",registry_path,g_get_application_name(),group); |
407 | HKEY hKey; | 407 | HKEY hKey; |
@@ -434,7 +434,7 @@ void set_string_to_config(const gchar *group, const gchar *key, const gchar *fmt | @@ -434,7 +434,7 @@ void set_string_to_config(const gchar *group, const gchar *key, const gchar *fmt | ||
434 | 434 | ||
435 | void set_boolean_to_config(const gchar *group, const gchar *key, gboolean val) | 435 | void set_boolean_to_config(const gchar *group, const gchar *key, gboolean val) |
436 | { | 436 | { |
437 | -#ifdef WIN_REGISTRY_ENABLED | 437 | +#ifdef HAVE_WIN_REGISTRY |
438 | 438 | ||
439 | HKEY hKey; | 439 | HKEY hKey; |
440 | DWORD disp; | 440 | DWORD disp; |
@@ -470,13 +470,13 @@ void set_boolean_to_config(const gchar *group, const gchar *key, gboolean val) | @@ -470,13 +470,13 @@ void set_boolean_to_config(const gchar *group, const gchar *key, gboolean val) | ||
470 | if(program_config) | 470 | if(program_config) |
471 | g_key_file_set_boolean(program_config,group,key,val); | 471 | g_key_file_set_boolean(program_config,group,key,val); |
472 | 472 | ||
473 | -#endif // WIN_REGISTRY_ENABLED | 473 | +#endif // HAVE_WIN_REGISTRY |
474 | 474 | ||
475 | } | 475 | } |
476 | 476 | ||
477 | void set_integer_to_config(const gchar *group, const gchar *key, gint val) | 477 | void set_integer_to_config(const gchar *group, const gchar *key, gint val) |
478 | { | 478 | { |
479 | -#ifdef WIN_REGISTRY_ENABLED | 479 | +#ifdef HAVE_WIN_REGISTRY |
480 | 480 | ||
481 | HKEY hKey; | 481 | HKEY hKey; |
482 | DWORD disp; | 482 | DWORD disp; |
@@ -512,13 +512,13 @@ void set_integer_to_config(const gchar *group, const gchar *key, gint val) | @@ -512,13 +512,13 @@ void set_integer_to_config(const gchar *group, const gchar *key, gint val) | ||
512 | if(program_config) | 512 | if(program_config) |
513 | g_key_file_set_integer(program_config,group,key,val); | 513 | g_key_file_set_integer(program_config,group,key,val); |
514 | 514 | ||
515 | -#endif // WIN_REGISTRY_ENABLED | 515 | +#endif // HAVE_WIN_REGISTRY |
516 | 516 | ||
517 | } | 517 | } |
518 | 518 | ||
519 | void configuration_deinit(void) | 519 | void configuration_deinit(void) |
520 | { | 520 | { |
521 | -#ifdef WIN_REGISTRY_ENABLED | 521 | +#ifdef HAVE_WIN_REGISTRY |
522 | 522 | ||
523 | #else | 523 | #else |
524 | 524 | ||
@@ -546,7 +546,7 @@ void configuration_deinit(void) | @@ -546,7 +546,7 @@ void configuration_deinit(void) | ||
546 | g_key_file_free(program_config); | 546 | g_key_file_free(program_config); |
547 | program_config = NULL; | 547 | program_config = NULL; |
548 | 548 | ||
549 | -#endif // WIN_REGISTRY_ENABLED | 549 | +#endif // HAVE_WIN_REGISTRY |
550 | } | 550 | } |
551 | 551 | ||
552 | gchar * build_data_filename(const gchar *first_element, ...) | 552 | gchar * build_data_filename(const gchar *first_element, ...) |
@@ -570,7 +570,10 @@ gchar * filename_from_va(const gchar *first_element, va_list args) | @@ -570,7 +570,10 @@ gchar * filename_from_va(const gchar *first_element, va_list args) | ||
570 | if(datadir) | 570 | if(datadir) |
571 | result = g_string_new(datadir); | 571 | result = g_string_new(datadir); |
572 | 572 | ||
573 | -#if defined( WIN_REGISTRY_ENABLED ) | 573 | +#if defined( HAVE_WIN_REGISTRY ) |
574 | + | ||
575 | +#error aqui | ||
576 | + | ||
574 | if(!result) | 577 | if(!result) |
575 | { | 578 | { |
576 | // No predefined datadir, search registry | 579 | // No predefined datadir, search registry |
@@ -617,7 +620,7 @@ gchar * filename_from_va(const gchar *first_element, va_list args) | @@ -617,7 +620,7 @@ gchar * filename_from_va(const gchar *first_element, va_list args) | ||
617 | g_free(path); | 620 | g_free(path); |
618 | } | 621 | } |
619 | } | 622 | } |
620 | -#endif // WIN_REGISTRY_ENABLED | 623 | +#endif // HAVE_WIN_REGISTRY |
621 | 624 | ||
622 | 625 | ||
623 | if(!result) | 626 | if(!result) |
@@ -658,7 +661,7 @@ gchar * filename_from_va(const gchar *first_element, va_list args) | @@ -658,7 +661,7 @@ gchar * filename_from_va(const gchar *first_element, va_list args) | ||
658 | return g_string_free(result, FALSE); | 661 | return g_string_free(result, FALSE); |
659 | } | 662 | } |
660 | 663 | ||
661 | -#ifdef WIN_REGISTRY_ENABLED | 664 | +#ifdef HAVE_WIN_REGISTRY |
662 | gboolean get_registry_handle(const gchar *group, HKEY *hKey, REGSAM samDesired) | 665 | gboolean get_registry_handle(const gchar *group, HKEY *hKey, REGSAM samDesired) |
663 | { | 666 | { |
664 | gboolean ret; | 667 | gboolean ret; |
@@ -681,7 +684,7 @@ GKeyFile * get_application_keyfile(void) | @@ -681,7 +684,7 @@ GKeyFile * get_application_keyfile(void) | ||
681 | configuration_init(); | 684 | configuration_init(); |
682 | return program_config; | 685 | return program_config; |
683 | } | 686 | } |
684 | -#endif // WIN_REGISTRY_ENABLED | 687 | +#endif // HAVE_WIN_REGISTRY |
685 | 688 | ||
686 | static const struct _WindowState | 689 | static const struct _WindowState |
687 | { | 690 | { |
@@ -697,7 +700,7 @@ GKeyFile * get_application_keyfile(void) | @@ -697,7 +700,7 @@ GKeyFile * get_application_keyfile(void) | ||
697 | 700 | ||
698 | void save_window_state_to_config(const gchar *group, const gchar *key, GdkWindowState CurrentState) | 701 | void save_window_state_to_config(const gchar *group, const gchar *key, GdkWindowState CurrentState) |
699 | { | 702 | { |
700 | -#if defined( WIN_REGISTRY_ENABLED ) | 703 | +#if defined( HAVE_WIN_REGISTRY ) |
701 | 704 | ||
702 | gchar * path = g_strdup_printf("%s\\%s\\%s\\%s",registry_path,g_get_application_name(),group,key); | 705 | gchar * path = g_strdup_printf("%s\\%s\\%s\\%s",registry_path,g_get_application_name(),group,key); |
703 | 706 | ||
@@ -729,12 +732,12 @@ void save_window_state_to_config(const gchar *group, const gchar *key, GdkWindow | @@ -729,12 +732,12 @@ void save_window_state_to_config(const gchar *group, const gchar *key, GdkWindow | ||
729 | 732 | ||
730 | g_free(id); | 733 | g_free(id); |
731 | 734 | ||
732 | -#endif // WIN_REGISTRY_ENABLED | 735 | +#endif // HAVE_WIN_REGISTRY |
733 | } | 736 | } |
734 | 737 | ||
735 | void save_window_size_to_config(const gchar *group, const gchar *key, GtkWidget *hwnd) | 738 | void save_window_size_to_config(const gchar *group, const gchar *key, GtkWidget *hwnd) |
736 | { | 739 | { |
737 | -#if defined( WIN_REGISTRY_ENABLED ) | 740 | +#if defined( HAVE_WIN_REGISTRY ) |
738 | 741 | ||
739 | gchar * path = g_strdup_printf("%s\\%s\\%s\\%s",registry_path,g_get_application_name(),group,key); | 742 | gchar * path = g_strdup_printf("%s\\%s\\%s\\%s",registry_path,g_get_application_name(),group,key); |
740 | 743 | ||
@@ -764,12 +767,12 @@ void save_window_size_to_config(const gchar *group, const gchar *key, GtkWidget | @@ -764,12 +767,12 @@ void save_window_size_to_config(const gchar *group, const gchar *key, GtkWidget | ||
764 | 767 | ||
765 | g_free(id); | 768 | g_free(id); |
766 | 769 | ||
767 | -#endif // WIN_REGISTRY_ENABLED | 770 | +#endif // HAVE_WIN_REGISTRY |
768 | } | 771 | } |
769 | 772 | ||
770 | void restore_window_from_config(const gchar *group, const gchar *key, GtkWidget *hwnd) | 773 | void restore_window_from_config(const gchar *group, const gchar *key, GtkWidget *hwnd) |
771 | { | 774 | { |
772 | -#if defined( WIN_REGISTRY_ENABLED ) | 775 | +#if defined( HAVE_WIN_REGISTRY ) |
773 | 776 | ||
774 | gchar * path = g_strdup_printf("%s\\%s\\%s\\%s",registry_path,g_get_application_name(),group,key); | 777 | gchar * path = g_strdup_printf("%s\\%s\\%s\\%s",registry_path,g_get_application_name(),group,key); |
775 | HKEY hKey; | 778 | HKEY hKey; |
@@ -849,7 +852,7 @@ void restore_window_from_config(const gchar *group, const gchar *key, GtkWidget | @@ -849,7 +852,7 @@ void restore_window_from_config(const gchar *group, const gchar *key, GtkWidget | ||
849 | 852 | ||
850 | g_free(id); | 853 | g_free(id); |
851 | 854 | ||
852 | -#endif // WIN_REGISTRY_ENABLED | 855 | +#endif // HAVE_WIN_REGISTRY |
853 | 856 | ||
854 | } | 857 | } |
855 | 858 |
src/pw3270/print.c
@@ -258,7 +258,7 @@ static gchar * enum_to_string(GType type, guint enum_value) | @@ -258,7 +258,7 @@ static gchar * enum_to_string(GType type, guint enum_value) | ||
258 | 258 | ||
259 | trace("Saving settings PrintSettings=%p page_setup=%p",settings,pgsetup); | 259 | trace("Saving settings PrintSettings=%p page_setup=%p",settings,pgsetup); |
260 | 260 | ||
261 | -#ifdef WIN32 | 261 | +#ifdef HAVE_WIN_REGISTRY |
262 | HKEY registry; | 262 | HKEY registry; |
263 | 263 | ||
264 | if(get_registry_handle("print",®istry,KEY_SET_VALUE)) | 264 | if(get_registry_handle("print",®istry,KEY_SET_VALUE)) |
@@ -567,7 +567,7 @@ static gchar * enum_to_string(GType type, guint enum_value) | @@ -567,7 +567,7 @@ static gchar * enum_to_string(GType type, guint enum_value) | ||
567 | 567 | ||
568 | // Load page and print settings | 568 | // Load page and print settings |
569 | { | 569 | { |
570 | -#ifdef WIN32 | 570 | +#ifdef HAVE_WIN_REGISTRY |
571 | 571 | ||
572 | HKEY registry; | 572 | HKEY registry; |
573 | 573 |