2 /* implements Windows specific functions */
3 #include "display-gtk.h"
5 #define DIVELIST_DEFAULT_FONT "Sans 8"
9 static int get_from_registry(HKEY hkey, const char *key)
15 success = RegQueryValueEx(hkey, (LPCTSTR)TEXT(key), NULL, NULL,
16 (LPBYTE) &value, (LPDWORD)&len );
17 if (success != ERROR_SUCCESS)
18 return FALSE; /* that's what happens the first time we start */
22 void subsurface_open_conf(void)
26 success = RegCreateKeyEx(HKEY_CURRENT_USER, (LPCTSTR)TEXT("Software\\subsurface"),
27 0L, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
29 if (success != ERROR_SUCCESS)
30 printf("CreateKey Software\\subsurface failed %ld\n", success);
33 void subsurface_set_conf(char *name, pref_type_t type, const void *value)
35 /* since we are using the pointer 'value' as both an actual
36 * pointer to the string setting and as a way to pass the
37 * numbers 0 and 1 to this function for booleans, one of the
38 * calls to RegSetValueEx needs to pass &value (when we want
39 * to pass the boolean value), the other one passes value (the
40 * address of the string. */
43 /* we simply store the value as DWORD */
44 RegSetValueEx(hkey, (LPCTSTR)TEXT(name), 0, REG_DWORD, (const BYTE *)&value, 4);
47 RegSetValueEx(hkey, (LPCTSTR)TEXT(name), 0, REG_SZ, (const BYTE *)value, strlen(value));
51 const void *subsurface_get_conf(char *name, pref_type_t type)
59 return get_from_registry(hkey, name) ? (void *) 1 : NULL;
63 success = RegQueryValueEx(hkey, (LPCTSTR)TEXT(name), NULL, NULL,
64 (LPBYTE) string, (LPDWORD)&len );
65 if (success != ERROR_SUCCESS) {
66 /* that's what happens the first time we start - just return NULL */
72 /* we shouldn't get here */
76 void subsurface_flush_conf(void)
81 void subsurface_close_conf(void)
86 const char *subsurface_USB_name()
91 const char *subsurface_icon_name()
93 return "subsurface.ico";
96 void subsurface_ui_setup(GtkSettings *settings, GtkWidget *menubar,
97 GtkWidget *vbox, GtkUIManager *ui_manager)
100 divelist_font = DIVELIST_DEFAULT_FONT;
101 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0);