Commit 7bbfffa485adc7687a075d7769a7f36cefc5c657

Authored by Perry Werneck
1 parent 379bb4a9
Exists in master and in 1 other branch develop

Implementing "save to registry" feature.

src/include/v3270/settings.h
... ... @@ -49,9 +49,9 @@
49 49  
50 50 #ifdef _WIN32
51 51  
52   - LIB3270_EXPORT gboolean v3270_load_registry(GtkWidget *widget, HKEY *hKey, const gchar *group_name);
  52 + LIB3270_EXPORT gboolean v3270_load_registry(GtkWidget *widget, HKEY hKey, const gchar *group_name);
53 53  
54   - LIB3270_EXPORT void v3270_to_registry(GtkWidget *widget, HKEY *hKey, const gchar *group_name);
  54 + LIB3270_EXPORT void v3270_to_registry(GtkWidget *widget, HKEY hKey, const gchar *group_name);
55 55  
56 56 #endif // _WIN32
57 57  
... ...
src/terminal/windows/registry.c
... ... @@ -128,21 +128,39 @@
128 128 {
129 129 const gchar * name = g_param_spec_get_name(pspec);
130 130  
  131 + BYTE data[4097];
  132 + unsigned long datatype;
  133 + unsigned long datalen = 4096;
  134 +
  135 + memset(data,0,sizeof(data));
  136 +
  137 + if(RegQueryValueExA(hKey,name,NULL,&datatype,data,&datalen) != ERROR_SUCCESS)
  138 + return;
  139 +
131 140 GValue value = G_VALUE_INIT;
132 141 g_value_init(&value, pspec->value_type);
  142 + g_object_get_property(G_OBJECT(widget),name,&value);
133 143  
134 144 switch(pspec->value_type)
135 145 {
136 146 case G_TYPE_STRING:
  147 + if(datatype == REG_SZ)
  148 + g_value_set_string(&value, (const gchar *) data);
137 149 break;
138 150  
139 151 case G_TYPE_BOOLEAN:
  152 + if(datatype == REG_DWORD)
  153 + g_value_set_boolean(&value, * ((DWORD *) data) == 0 ? FALSE : TRUE);
140 154 break;
141 155  
142 156 case G_TYPE_INT:
  157 + if(datatype == REG_DWORD)
  158 + g_value_set_int(&value, (gint) * ((DWORD *) data));
143 159 break;
144 160  
145 161 case G_TYPE_UINT:
  162 + if(datatype == REG_DWORD)
  163 + g_value_set_uint(&value, (guint) * ((DWORD *) data));
146 164 break;
147 165  
148 166 default:
... ... @@ -158,7 +176,7 @@
158 176 }
159 177  
160 178 /// @brief Reads the terminal settings from the group group_name in registry.
161   - LIB3270_EXPORT void v3270_to_registry(GtkWidget *widget, HKEY *hParent, const gchar *group_name)
  179 + LIB3270_EXPORT void v3270_to_registry(GtkWidget *widget, HKEY hParent, const gchar *group_name)
162 180 {
163 181 g_return_if_fail(GTK_IS_V3270(widget));
164 182  
... ... @@ -209,7 +227,7 @@
209 227 }
210 228  
211 229 /// @brief This function adds the terminal settings from widget to windows registry.
212   - LIB3270_EXPORT gboolean v3270_load_registry(GtkWidget *widget, HKEY *hParent, const gchar *group_name)
  230 + LIB3270_EXPORT gboolean v3270_load_registry(GtkWidget *widget, HKEY hParent, const gchar *group_name)
213 231 {
214 232 g_return_val_if_fail(GTK_IS_V3270(widget),FALSE);
215 233  
... ...