Commit 8f4944f5bd2fe094f20087185b405d47588d3eb3

Authored by Perry Werneck
1 parent 88935859
Exists in v5.2

Updating model and oversize info just after the host settings dialog for

compatibility with the new dialog.
src/include/pw3270.h
@@ -60,6 +60,7 @@ @@ -60,6 +60,7 @@
60 LIB3270_EXPORT gboolean pw3270_set_toggle_by_name(GtkWidget *widget, const gchar *name, gboolean flag); 60 LIB3270_EXPORT gboolean pw3270_set_toggle_by_name(GtkWidget *widget, const gchar *name, gboolean flag);
61 LIB3270_EXPORT H3270 * pw3270_get_session(GtkWidget *widget); 61 LIB3270_EXPORT H3270 * pw3270_get_session(GtkWidget *widget);
62 LIB3270_EXPORT GtkWidget * pw3270_get_terminal_widget(GtkWidget *widget); 62 LIB3270_EXPORT GtkWidget * pw3270_get_terminal_widget(GtkWidget *widget);
  63 + LIB3270_EXPORT const gchar * pw3270_get_oversize(GtkWidget *widget);
63 64
64 LIB3270_EXPORT GtkWidget * pw3270_get_toplevel(void); 65 LIB3270_EXPORT GtkWidget * pw3270_get_toplevel(void);
65 66
@@ -72,7 +73,6 @@ @@ -72,7 +73,6 @@
72 LIB3270_EXPORT void pw3270_set_host_type(GtkWidget *widget, const gchar *name); 73 LIB3270_EXPORT void pw3270_set_host_type(GtkWidget *widget, const gchar *name);
73 LIB3270_EXPORT int pw3270_set_session_color_type(GtkWidget *widget, unsigned short color_type); 74 LIB3270_EXPORT int pw3270_set_session_color_type(GtkWidget *widget, unsigned short color_type);
74 75
75 -// LIB3270_EXPORT gchar * pw3270_get_filename(GtkWidget *widget, const gchar *group, const gchar *key, GtkFileFilter **filter, const gchar *title);  
76 76
77 LIB3270_EXPORT gchar * pw3270_get_string(GtkWidget *widget, const gchar *group, const gchar *key, const gchar *def); 77 LIB3270_EXPORT gchar * pw3270_get_string(GtkWidget *widget, const gchar *group, const gchar *key, const gchar *def);
78 LIB3270_EXPORT void pw3270_set_string(GtkWidget *widget, const gchar *group, const gchar *key, const gchar *val); 78 LIB3270_EXPORT void pw3270_set_string(GtkWidget *widget, const gchar *group, const gchar *key, const gchar *val);
src/pw3270/common/config.c
@@ -470,10 +470,33 @@ static void set_string(const gchar *group, const gchar *key, const gchar *fmt, v @@ -470,10 +470,33 @@ static void set_string(const gchar *group, const gchar *key, const gchar *fmt, v
470 470
471 void set_string_to_config(const gchar *group, const gchar *key, const gchar *fmt, ...) 471 void set_string_to_config(const gchar *group, const gchar *key, const gchar *fmt, ...)
472 { 472 {
473 - va_list args;  
474 - va_start(args, fmt);  
475 - set_string(group,key,fmt,args);  
476 - va_end(args); 473 + if(fmt)
  474 + {
  475 + va_list args;
  476 + va_start(args, fmt);
  477 + set_string(group,key,fmt,args);
  478 + va_end(args);
  479 + }
  480 + else if(g_key_file_has_key(program_config,group,key,NULL))
  481 + {
  482 +#ifdef ENABLE_WINDOWS_REGISTRY
  483 +
  484 + gchar * path = g_strdup_printf("%s\\%s\\%s",registry_path,g_get_application_name(),group);
  485 + HKEY hKey;
  486 + DWORD disp;
  487 +
  488 + if(RegOpenKeyEx(HKEY_CURRENT_USER, path, 0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)
  489 + {
  490 + RegDeleteKey(hKey,key);
  491 + RegCloseKey(hKey);
  492 + }
  493 +
  494 + g_free(path);
  495 +
  496 +#else
  497 + g_key_file_remove_key(program_config,group,key,NULL);
  498 +#endif
  499 + }
477 } 500 }
478 501
479 void set_boolean_to_config(const gchar *group, const gchar *key, gboolean val) 502 void set_boolean_to_config(const gchar *group, const gchar *key, gboolean val)
src/pw3270/hostdialog.c
@@ -46,5 +46,9 @@ @@ -46,5 +46,9 @@
46 46
47 v3270_select_host(widget); 47 v3270_select_host(widget);
48 48
  49 + set_string_to_config("terminal","oversize",pw3270_get_oversize(gtk_widget_get_toplevel(widget)));
  50 + set_integer_to_config("terminal","model_number",lib3270_get_model_number(hSession));
  51 + set_string_to_config("terminal","model_name","%s",lib3270_get_model_name(hSession));
  52 +
49 } 53 }
50 54
src/pw3270/main.c
@@ -492,7 +492,15 @@ int main(int argc, char *argv[]) @@ -492,7 +492,15 @@ int main(int argc, char *argv[])
492 pw3270_set_session_name(toplevel,session_name); 492 pw3270_set_session_name(toplevel,session_name);
493 493
494 if(oversize) 494 if(oversize)
  495 + {
495 pw3270_set_oversize(toplevel,oversize); 496 pw3270_set_oversize(toplevel,oversize);
  497 + }
  498 + else
  499 + {
  500 + g_autofree gchar * ovsz = pw3270_get_string(toplevel,"terminal","oversize","");
  501 + if(ovsz && *ovsz)
  502 + pw3270_set_oversize(toplevel,oversize);
  503 + }
496 504
497 #ifdef _WIN32 505 #ifdef _WIN32
498 pw3270_set_string(toplevel,"application","session",session_name); 506 pw3270_set_string(toplevel,"application","session",session_name);
src/pw3270/window.c
@@ -413,6 +413,12 @@ static GtkWidget * trace_window = NULL; @@ -413,6 +413,12 @@ static GtkWidget * trace_window = NULL;
413 lib3270_set_oversize(pw3270_get_session(widget),oversize); 413 lib3270_set_oversize(pw3270_get_session(widget),oversize);
414 } 414 }
415 415
  416 + LIB3270_EXPORT const gchar * pw3270_get_oversize(GtkWidget *widget)
  417 + {
  418 + g_return_val_if_fail(GTK_IS_PW3270(widget),"");
  419 + return (const gchar *) lib3270_get_oversize(pw3270_get_session(widget));
  420 + }
  421 +
416 LIB3270_EXPORT void pw3270_set_host_type(GtkWidget *widget, const gchar *name) 422 LIB3270_EXPORT void pw3270_set_host_type(GtkWidget *widget, const gchar *name)
417 { 423 {
418 size_t f; 424 size_t f;
@@ -526,7 +532,7 @@ static GtkWidget * trace_window = NULL; @@ -526,7 +532,7 @@ static GtkWidget * trace_window = NULL;
526 int f; 532 int f;
527 533
528 trace("Widget %p changed to %s (id=%d)",widget,name,id); 534 trace("Widget %p changed to %s (id=%d)",widget,name,id);
529 - set_integer_to_config("terminal","model",id); 535 + set_integer_to_config("terminal","model_number",id);
530 set_string_to_config("terminal","model_name","%s",name); 536 set_string_to_config("terminal","model_name","%s",name);
531 537
532 id -= 2; 538 id -= 2;
@@ -752,7 +758,7 @@ static GtkWidget * trace_window = NULL; @@ -752,7 +758,7 @@ static GtkWidget * trace_window = NULL;
752 758
753 { 759 {
754 char str[2]; 760 char str[2];
755 - str[0] = get_integer_from_config("terminal","model",2)+'0'; 761 + str[0] = get_integer_from_config("terminal","model_number",2)+'0';
756 str[1] = 0; 762 str[1] = 0;
757 lib3270_set_model(host,str); 763 lib3270_set_model(host,str);
758 764