Commit 51e901274eaa8743c6429a66bced000a8ef98c84
1 parent
f8c68834
Exists in
v5.2
Fixing save settings file.
Showing
5 changed files
with
31 additions
and
23 deletions
Show diff stats
src/pw3270/common.h
@@ -58,8 +58,9 @@ | @@ -58,8 +58,9 @@ | ||
58 | 58 | ||
59 | // Configuration | 59 | // Configuration |
60 | LIB3270_EXPORT void pw3270_session_config_load(const gchar *filename); | 60 | LIB3270_EXPORT void pw3270_session_config_load(const gchar *filename); |
61 | + LIB3270_EXPORT void pw3270_session_config_save(); | ||
61 | LIB3270_EXPORT void pw3270_session_config_free(void); | 62 | LIB3270_EXPORT void pw3270_session_config_free(void); |
62 | - LIB3270_EXPORT GKeyFile * pw3270_session_config_get(void); | 63 | + LIB3270_EXPORT GKeyFile * pw3270_session_config_get(gboolean create); |
63 | 64 | ||
64 | gchar * get_string_from_config(const gchar *group, const gchar *key, const gchar *def); | 65 | gchar * get_string_from_config(const gchar *group, const gchar *key, const gchar *def); |
65 | gboolean get_boolean_from_config(const gchar *group, const gchar *key, gboolean def); | 66 | gboolean get_boolean_from_config(const gchar *group, const gchar *key, gboolean def); |
src/pw3270/linux/config.c
@@ -265,9 +265,8 @@ void set_integer_to_config(const gchar *group, const gchar *key, gint val) | @@ -265,9 +265,8 @@ void set_integer_to_config(const gchar *group, const gchar *key, gint val) | ||
265 | 265 | ||
266 | } | 266 | } |
267 | 267 | ||
268 | -void pw3270_session_config_free(void) | 268 | +void pw3270_session_config_save() |
269 | { | 269 | { |
270 | - | ||
271 | if(!keyfile) | 270 | if(!keyfile) |
272 | return; | 271 | return; |
273 | 272 | ||
@@ -301,9 +300,13 @@ void pw3270_session_config_free(void) | @@ -301,9 +300,13 @@ void pw3270_session_config_free(void) | ||
301 | 300 | ||
302 | } | 301 | } |
303 | 302 | ||
303 | +} | ||
304 | + | ||
305 | +void pw3270_session_config_free(void) | ||
306 | +{ | ||
307 | + pw3270_session_config_save(); | ||
304 | g_key_file_free(keyfile); | 308 | g_key_file_free(keyfile); |
305 | keyfile = NULL; | 309 | keyfile = NULL; |
306 | - | ||
307 | } | 310 | } |
308 | 311 | ||
309 | gchar * build_data_filename(const gchar *first_element, ...) | 312 | gchar * build_data_filename(const gchar *first_element, ...) |
@@ -361,9 +364,9 @@ gchar * filename_from_va(const gchar *first_element, va_list args) | @@ -361,9 +364,9 @@ gchar * filename_from_va(const gchar *first_element, va_list args) | ||
361 | return g_build_filename(".",suffix,NULL); | 364 | return g_build_filename(".",suffix,NULL); |
362 | } | 365 | } |
363 | 366 | ||
364 | -GKeyFile * pw3270_session_config_get(void) | 367 | +GKeyFile * pw3270_session_config_get(gboolean create) |
365 | { | 368 | { |
366 | - if(!keyfile) | 369 | + if(!keyfile && create) |
367 | pw3270_session_config_load(NULL); | 370 | pw3270_session_config_load(NULL); |
368 | return keyfile; | 371 | return keyfile; |
369 | } | 372 | } |
@@ -383,7 +386,7 @@ GKeyFile * pw3270_session_config_get(void) | @@ -383,7 +386,7 @@ GKeyFile * pw3270_session_config_get(void) | ||
383 | void save_window_state_to_config(const gchar *group, const gchar *key, GdkWindowState CurrentState) | 386 | void save_window_state_to_config(const gchar *group, const gchar *key, GdkWindowState CurrentState) |
384 | { | 387 | { |
385 | int f; | 388 | int f; |
386 | - GKeyFile * conf = pw3270_session_config_get(); | 389 | + GKeyFile * conf = pw3270_session_config_get(TRUE); |
387 | gchar * id = g_strconcat(group,".",key,NULL); | 390 | gchar * id = g_strconcat(group,".",key,NULL); |
388 | 391 | ||
389 | for(f=0;f<G_N_ELEMENTS(WindowState);f++) | 392 | for(f=0;f<G_N_ELEMENTS(WindowState);f++) |
@@ -396,7 +399,7 @@ void save_window_state_to_config(const gchar *group, const gchar *key, GdkWindow | @@ -396,7 +399,7 @@ void save_window_state_to_config(const gchar *group, const gchar *key, GdkWindow | ||
396 | void save_window_size_to_config(const gchar *group, const gchar *key, GtkWidget *hwnd) | 399 | void save_window_size_to_config(const gchar *group, const gchar *key, GtkWidget *hwnd) |
397 | { | 400 | { |
398 | int pos[2]; | 401 | int pos[2]; |
399 | - GKeyFile * conf = pw3270_session_config_get(); | 402 | + GKeyFile * conf = pw3270_session_config_get(TRUE); |
400 | gchar * id = g_strconcat(group,".",key,NULL); | 403 | gchar * id = g_strconcat(group,".",key,NULL); |
401 | 404 | ||
402 | gtk_window_get_size(GTK_WINDOW(hwnd),&pos[0],&pos[1]); | 405 | gtk_window_get_size(GTK_WINDOW(hwnd),&pos[0],&pos[1]); |
@@ -409,7 +412,7 @@ void save_window_size_to_config(const gchar *group, const gchar *key, GtkWidget | @@ -409,7 +412,7 @@ void save_window_size_to_config(const gchar *group, const gchar *key, GtkWidget | ||
409 | void restore_window_from_config(const gchar *group, const gchar *key, GtkWidget *hwnd) | 412 | void restore_window_from_config(const gchar *group, const gchar *key, GtkWidget *hwnd) |
410 | { | 413 | { |
411 | gchar * id = g_strconcat(group,".",key,NULL); | 414 | gchar * id = g_strconcat(group,".",key,NULL); |
412 | - GKeyFile * conf = pw3270_session_config_get(); | 415 | + GKeyFile * conf = pw3270_session_config_get(TRUE); |
413 | 416 | ||
414 | if(g_key_file_has_key(conf,id,"size",NULL)) | 417 | if(g_key_file_has_key(conf,id,"size",NULL)) |
415 | { | 418 | { |
src/pw3270/linux/print.c
@@ -48,7 +48,7 @@ | @@ -48,7 +48,7 @@ | ||
48 | g_message("Loading print settings"); | 48 | g_message("Loading print settings"); |
49 | 49 | ||
50 | // Load page and print settings | 50 | // Load page and print settings |
51 | - GKeyFile * conf = pw3270_session_config_get(); | 51 | + GKeyFile * conf = pw3270_session_config_get(TRUE); |
52 | GError * err = NULL; | 52 | GError * err = NULL; |
53 | 53 | ||
54 | debug("print_settings=%s",g_key_file_has_group(conf,"print_settings") ? "TRUE" : "FALSE"); | 54 | debug("print_settings=%s",g_key_file_has_group(conf,"print_settings") ? "TRUE" : "FALSE"); |
@@ -128,7 +128,7 @@ | @@ -128,7 +128,7 @@ | ||
128 | trace("%s(%p)",__FUNCTION__,operation); | 128 | trace("%s(%p)",__FUNCTION__,operation); |
129 | g_message("Saving print settings"); | 129 | g_message("Saving print settings"); |
130 | 130 | ||
131 | - GKeyFile * conf = pw3270_session_config_get(); | 131 | + GKeyFile * conf = pw3270_session_config_get(TRUE); |
132 | gtk_print_settings_to_key_file(settings,conf,"print_settings"); | 132 | gtk_print_settings_to_key_file(settings,conf,"print_settings"); |
133 | gtk_page_setup_to_key_file(pgsetup,conf,"page_setup"); | 133 | gtk_page_setup_to_key_file(pgsetup,conf,"page_setup"); |
134 | gtk_paper_size_to_key_file(papersize,conf,"paper_size"); | 134 | gtk_paper_size_to_key_file(papersize,conf,"paper_size"); |
src/pw3270/main.c
@@ -487,7 +487,7 @@ int main(int argc, char *argv[]) | @@ -487,7 +487,7 @@ int main(int argc, char *argv[]) | ||
487 | pw3270_session_config_load(argv[ix]); | 487 | pw3270_session_config_load(argv[ix]); |
488 | } | 488 | } |
489 | 489 | ||
490 | - pw3270_session_config_get(); | 490 | + pw3270_session_config_get(TRUE); |
491 | 491 | ||
492 | } | 492 | } |
493 | 493 |
src/pw3270/window.c
@@ -406,21 +406,25 @@ static GtkWidget * trace_window = NULL; | @@ -406,21 +406,25 @@ static GtkWidget * trace_window = NULL; | ||
406 | { | 406 | { |
407 | debug("%s",__FUNCTION__); | 407 | debug("%s",__FUNCTION__); |
408 | 408 | ||
409 | -#ifdef ENABLE_WINDOWS_REGISTRY | 409 | + GKeyFile * keyfile = pw3270_session_config_get(FALSE); |
410 | 410 | ||
411 | - HKEY hKey; | ||
412 | - | ||
413 | - if(get_registry_handle(NULL, &hKey, KEY_SET_VALUE)) | 411 | + if(keyfile) |
414 | { | 412 | { |
415 | - v3270_to_registry(widget, hKey, "terminal"); | ||
416 | - RegCloseKey(hKey); | 413 | + v3270_to_key_file(widget, keyfile, "terminal"); |
414 | + pw3270_session_config_save(); | ||
417 | } | 415 | } |
416 | +#ifdef _WIN32 | ||
417 | + else | ||
418 | + { | ||
419 | + HKEY hKey; | ||
418 | 420 | ||
419 | -#else | ||
420 | - | ||
421 | - v3270_to_key_file(widget, pw3270_session_config_get(), "terminal"); | ||
422 | - | ||
423 | -#endif // _WIN32 | 421 | + if(get_registry_handle(NULL, &hKey, KEY_SET_VALUE)) |
422 | + { | ||
423 | + v3270_to_registry(widget, hKey, "terminal"); | ||
424 | + RegCloseKey(hKey); | ||
425 | + } | ||
426 | + } | ||
427 | +#endif | ||
424 | 428 | ||
425 | } | 429 | } |
426 | 430 |