Commit 9030be47b325d16fbf3f8e2616699ec28984b55e

Authored by Perry Werneck
1 parent 2f6b2493
Exists in master and in 1 other branch develop

fixing save to registry feature.

.vscode/c_cpp_properties.json
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 { 3 {
4 "name": "Win32", 4 "name": "Win32",
5 "includePath": [ 5 "includePath": [
6 - "${workspaceFolder}/**" 6 + "${workspaceFolder}/src/include"
7 ], 7 ],
8 "defines": [ 8 "defines": [
9 "_DEBUG", 9 "_DEBUG",
src/terminal/windows/registry.c
@@ -32,6 +32,7 @@ @@ -32,6 +32,7 @@
32 #include <terminal.h> 32 #include <terminal.h>
33 #include <internals.h> 33 #include <internals.h>
34 #include <v3270/settings.h> 34 #include <v3270/settings.h>
  35 + #include <lib3270/log.h>
35 #include <lib3270/toggle.h> 36 #include <lib3270/toggle.h>
36 #include <lib3270/log.h> 37 #include <lib3270/log.h>
37 #include <lib3270/trace.h> 38 #include <lib3270/trace.h>
@@ -60,7 +61,7 @@ @@ -60,7 +61,7 @@
60 } 61 }
61 else 62 else
62 { 63 {
63 - RegDeleteKey(hKey,name); 64 + RegDeleteValue(hKey,name);
64 } 65 }
65 } 66 }
66 break; 67 break;
@@ -76,7 +77,7 @@ @@ -76,7 +77,7 @@
76 } 77 }
77 else 78 else
78 { 79 {
79 - RegDeleteKey(hKey,name); 80 + RegDeleteValue(hKey,name);
80 } 81 }
81 } 82 }
82 break; 83 break;
@@ -92,7 +93,7 @@ @@ -92,7 +93,7 @@
92 } 93 }
93 else 94 else
94 { 95 {
95 - RegDeleteKey(hKey,name); 96 + RegDeleteValue(hKey,name);
96 } 97 }
97 98
98 } 99 }
@@ -109,7 +110,7 @@ @@ -109,7 +110,7 @@
109 } 110 }
110 else 111 else
111 { 112 {
112 - RegDeleteKey(hKey,name); 113 + RegDeleteValue(hKey,name);
113 } 114 }
114 115
115 } 116 }
src/testprogram/testprogram.c
@@ -65,6 +65,35 @@ @@ -65,6 +65,35 @@
65 } 65 }
66 */ 66 */
67 67
  68 +#ifdef _WIN32
  69 +
  70 + static int get_registry(HKEY *hKey,REGSAM samDesired)
  71 + {
  72 + DWORD disp;
  73 +
  74 + if(RegCreateKeyEx(HKEY_CURRENT_USER,"software\\v3270",0,NULL,REG_OPTION_NON_VOLATILE,samDesired,NULL,hKey,&disp) != ERROR_SUCCESS)
  75 + {
  76 + g_warning("Can't open registry");
  77 + return -1;
  78 + }
  79 +
  80 + return 0;
  81 +
  82 + }
  83 +
  84 + static void save_settings(GtkWidget *terminal, GtkWidget *window)
  85 + {
  86 + HKEY hKey = 0;
  87 +
  88 + if(get_registry(&hKey,KEY_SET_VALUE))
  89 + return;
  90 +
  91 + v3270_to_registry(terminal,hKey,"terminal");
  92 + RegCloseKey(hKey);
  93 + }
  94 +
  95 +#else
  96 +
68 static GKeyFile * get_key_file() 97 static GKeyFile * get_key_file()
69 { 98 {
70 GKeyFile * key_file = g_key_file_new(); 99 GKeyFile * key_file = g_key_file_new();
@@ -81,8 +110,12 @@ @@ -81,8 +110,12 @@
81 g_key_file_save_to_file(key_file,"terminal.conf",NULL); 110 g_key_file_save_to_file(key_file,"terminal.conf",NULL);
82 g_key_file_free(key_file); 111 g_key_file_free(key_file);
83 112
  113 +
84 } 114 }
85 115
  116 +#endif // _WIN32
  117 +
  118 +
86 static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) { 119 static void activate(GtkApplication* app, G_GNUC_UNUSED gpointer user_data) {
87 120
88 GtkWidget * window = gtk_application_window_new(app); 121 GtkWidget * window = gtk_application_window_new(app);
@@ -108,10 +141,14 @@ @@ -108,10 +141,14 @@
108 #endif // _WIN32 141 #endif // _WIN32
109 142
110 // Load settings before connecting the signals. 143 // Load settings before connecting the signals.
  144 +#ifdef _WIN32
  145 +
  146 +#else
111 debug("%s: Loading settings...",__FUNCTION__); 147 debug("%s: Loading settings...",__FUNCTION__);
112 GKeyFile * key_file = get_key_file(); 148 GKeyFile * key_file = get_key_file();
113 v3270_load_key_file(terminal,key_file,"terminal"); 149 v3270_load_key_file(terminal,key_file,"terminal");
114 g_key_file_free(key_file); 150 g_key_file_free(key_file);
  151 +#endif // _WIN32
115 152
116 } 153 }
117 154