diff --git a/pw3270.cbp b/pw3270.cbp
index 52bfda0..9233ee6 100644
--- a/pw3270.cbp
+++ b/pw3270.cbp
@@ -9,8 +9,8 @@
-
-
+
+
@@ -20,8 +20,8 @@
-
-
+
+
@@ -35,7 +35,7 @@
-
+
@@ -45,281 +45,282 @@
-
-
+
+
-
+
-
-
+
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
-
-
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
+
+
+
-
-
-
-
+
+
+
+
-
+
-
-
-
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
-
-
-
+
+
+
-
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
-
+
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
-
-
-
-
+
+
+
+
diff --git a/src/gtk/common/common.h.in b/src/gtk/common/common.h.in
index f63fa7f..af6981a 100644
--- a/src/gtk/common/common.h.in
+++ b/src/gtk/common/common.h.in
@@ -85,6 +85,9 @@
#ifdef WIN_REGISTRY_ENABLED
HKEY get_registry_handle(const gchar *first_element,REGSAM samDesired);
+ void registry_foreach(HKEY parent, const gchar *name,void (*cbk)(const gchar *key, const gchar *val, gpointer *user_data), gpointer *user_data);
+ void registry_set_double(HKEY hKey, const gchar *key, gdouble value);
+ gboolean registry_get_double(HKEY hKey, const gchar *key, gdouble *value);
#else
GKeyFile * get_application_keyfile(void);
#endif // WIN_REGISTRY_ENABLED
diff --git a/src/gtk/common/config.c b/src/gtk/common/config.c
index 768060a..30dfe4f 100644
--- a/src/gtk/common/config.c
+++ b/src/gtk/common/config.c
@@ -93,6 +93,7 @@ gchar * get_last_error_msg(void)
#endif // WIN32
#ifdef WIN_REGISTRY_ENABLED
+
static BOOL registry_open_key(const gchar *group, REGSAM samDesired, HKEY *hKey)
{
static HKEY predefined[] = { HKEY_CURRENT_USER, HKEY_USERS, HKEY_LOCAL_MACHINE };
@@ -144,6 +145,40 @@ gchar * get_last_error_msg(void)
}
}
+ void registry_set_double(HKEY hKey, const gchar *key, gdouble value)
+ {
+ // Reference: http://git.gnome.org/browse/glib/tree/glib/gkeyfile.c
+ gchar result[G_ASCII_DTOSTR_BUF_SIZE];
+ g_ascii_dtostr (result, sizeof (result), value);
+
+ RegSetValueEx(hKey,key,0,REG_SZ,(const BYTE *) result,strlen(result)+1);
+ }
+
+ gboolean registry_get_double(HKEY hKey, const gchar *key, gdouble *value)
+ {
+ GError * error = NULL;
+ BYTE data[4096];
+ unsigned long datatype;
+ unsigned long datalen = sizeof(data);
+ gchar * end_of_valid_d;
+
+ if(RegQueryValueExA(hKey,key,NULL,&datatype,data,&datalen) != ERROR_SUCCESS)
+ return FALSE;
+
+ data[datalen] = 0;
+
+ * value = g_ascii_strtod(data, &end_of_valid_d);
+
+ if(*end_of_valid_d != '\0' || end_of_valid_d == ((gchar *) data))
+ {
+ g_warning("Key %s on registry isnt a valid double value",key);
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+
+
#else
static gchar * search_for_ini(void)
@@ -307,7 +342,7 @@ gchar * get_last_error_msg(void)
memcpy(ret,data,datalen);
ret[datalen+1] = 0;
- trace("%s\\%s=\"%s\"",group,key,ret);
+// trace("%s\\%s=\"%s\"",group,key,ret);
}
else if(def)
{
diff --git a/src/gtk/print.c b/src/gtk/print.c
index 7f3700d..4cce1bd 100644
--- a/src/gtk/print.c
+++ b/src/gtk/print.c
@@ -134,21 +134,13 @@
#ifdef WIN32
#define save_string(h,k,v) save_settings(k,v,h)
+#define save_double(h,k,v) registry_set_double(h,k,v)
static void save_settings(const gchar *key, const gchar *value, HKEY hKey)
{
RegSetValueEx(hKey,key,0,REG_SZ,(const BYTE *) value,strlen(value)+1);
}
-static void save_double(HKEY hKey, const gchar *key, gdouble value)
-{
- // Reference: http://git.gnome.org/browse/glib/tree/glib/gkeyfile.c
- gchar result[G_ASCII_DTOSTR_BUF_SIZE];
- g_ascii_dtostr (result, sizeof (result), value);
- save_settings(key,result,hKey);
-}
-
-
/*
* From: http://git.gnome.org/browse/gtk+/tree/gtk/gtkpagesetup.c
* something like this should really be in gobject!
@@ -429,9 +421,24 @@ static gchar * enum_to_string(GType type, guint enum_value)
if(get_registry_handle("print",®istry,KEY_READ))
{
+ HKEY hKey;
+ DWORD disp;
+
registry_foreach(registry,"settings",update_settings,(gpointer) settings);
+ if(RegCreateKeyEx(registry,"pagesetup",0,NULL,REG_OPTION_NON_VOLATILE,KEY_READ,NULL,&hKey,&disp) == ERROR_SUCCESS)
+ {
+ gdouble val;
+
+ #define load_double(h,k,s) if(registry_get_double(h,k,&val)) s(setup, val,GTK_UNIT_MM);
+ load_double(hKey, "MarginTop", gtk_page_setup_set_top_margin );
+ load_double(hKey, "MarginBottom", gtk_page_setup_set_bottom_margin );
+ load_double(hKey, "MarginLeft", gtk_page_setup_set_left_margin );
+ load_double(hKey, "MarginRight", gtk_page_setup_set_right_margin );
+
+ RegCloseKey(hKey);
+ }
#warning Work in progress
--
libgit2 0.21.2