X-Git-Url: http://git.tdb.fi/?p=ext%2Fsubsurface.git;a=blobdiff_plain;f=windows.c;h=29ef6122e50044a160640d22da81df053ebe22d9;hp=b8eafb6de9338ea7228bae4e99b400a940676319;hb=HEAD;hpb=d2654d4951a01efd36f4189aeb02a791f20fa94d diff --git a/windows.c b/windows.c index b8eafb6..29ef612 100644 --- a/windows.c +++ b/windows.c @@ -2,6 +2,7 @@ /* implements Windows specific functions */ #include "display-gtk.h" #include +#define DIVELIST_DEFAULT_FONT "Sans 8" static HKEY hkey; @@ -11,8 +12,8 @@ static int get_from_registry(HKEY hkey, const char *key) DWORD len = 4; LONG success; - success = RegQueryValueEx(hkey, TEXT(key), NULL, NULL, - (LPBYTE) &value, &len ); + success = RegQueryValueEx(hkey, (LPCTSTR)TEXT(key), NULL, NULL, + (LPBYTE) &value, (LPDWORD)&len ); if (success != ERROR_SUCCESS) return FALSE; /* that's what happens the first time we start */ return value; @@ -22,7 +23,7 @@ void subsurface_open_conf(void) { LONG success; - success = RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Software\\subsurface"), + success = RegCreateKeyEx(HKEY_CURRENT_USER, (LPCTSTR)TEXT("Software\\subsurface"), 0L, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, NULL); if (success != ERROR_SUCCESS) @@ -31,13 +32,19 @@ void subsurface_open_conf(void) void subsurface_set_conf(char *name, pref_type_t type, const void *value) { + /* since we are using the pointer 'value' as both an actual + * pointer to the string setting and as a way to pass the + * numbers 0 and 1 to this function for booleans, one of the + * calls to RegSetValueEx needs to pass &value (when we want + * to pass the boolean value), the other one passes value (the + * address of the string. */ switch (type) { case PREF_BOOL: /* we simply store the value as DWORD */ - RegSetValueEx(hkey, TEXT(name), 0, REG_DWORD, &value, 4); + RegSetValueEx(hkey, (LPCTSTR)TEXT(name), 0, REG_DWORD, (const BYTE *)&value, 4); break; case PREF_STRING: - RegSetValueEx(hkey, TEXT(name), 0, REG_SZ, value, strlen(value)); + RegSetValueEx(hkey, (LPCTSTR)TEXT(name), 0, REG_SZ, (const BYTE *)value, strlen(value)); } } @@ -53,7 +60,7 @@ const void *subsurface_get_conf(char *name, pref_type_t type) case PREF_STRING: string = malloc(80); len = 80; - success = RegQueryValueEx(hkey, TEXT(name), NULL, NULL, + success = RegQueryValueEx(hkey, (LPCTSTR)TEXT(name), NULL, NULL, (LPBYTE) string, (LPDWORD)&len ); if (success != ERROR_SUCCESS) { /* that's what happens the first time we start - just return NULL */ @@ -66,9 +73,30 @@ const void *subsurface_get_conf(char *name, pref_type_t type) return NULL; } +void subsurface_flush_conf(void) +{ + /* this is a no-op */ +} + void subsurface_close_conf(void) { - if (RegFlushKey(hkey) != ERROR_SUCCESS) - printf("RegFlushKey failed \n"); RegCloseKey(hkey); } + +const char *subsurface_USB_name() +{ + return "COM3"; +} + +const char *subsurface_icon_name() +{ + return "subsurface.ico"; +} + +void subsurface_ui_setup(GtkSettings *settings, GtkWidget *menubar, + GtkWidget *vbox, GtkUIManager *ui_manager) +{ + if (!divelist_font) + divelist_font = DIVELIST_DEFAULT_FONT; + gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0); +}