summaryrefslogtreecommitdiffstats
path: root/windows.c
AgeCommit message (Collapse)Author
2012-10-05Added unicode support for the configuration entries on WindowsGravatar Lubomir I. Ivanov
windows.c: Windows's registry (which is technically a filesystem) uses UTF-16 for its "keys". This forces us to convert each of our UTF-8 (GLib, GTK) configuration entries if we want to store special characters. To do that we use the RegQueryValueExW() and do some conversation around the function call itself. The opposite happens when we require a UTF-16 value to be read from the registry and converted to UTF-8 in subsurface_set_conf(). An addition to this patch is a somehow expandable buffer in windows.c: subsurface_get_conf(). We increase the size of the buffer in chunks of 64 bytes, until RegQueryValueExW() is able to write to it (as suggested by the WINAPI documentation). Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-04Provide a method to use unicode command line arguments on WindowsGravatar Lubomir I. Ivanov
For unicode command line characters Windows uses UTF-16, while Glib and GTK use UTF-8. To solve that we retrieve the command line via __wgetmainargs() and use g_utf16_to_utf8() to convert each argument. The used method should support wildcards passed as arguments (e.g. *.xml). Two new, OS abstracted functions appear in linux.c (NOP), macos.c (NOP), windows.c: subsurface_command_line_init(...) subsurface_command_line_exit(...) which are being called in main() Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-17Once again improve existing filename handlingGravatar Dirk Hohndel
Several potential problems. - we could end up dereferencing exiting_filename when it was NULL - we could free the default_filename by mistake - subsurface_default_filename always needs to return a copy of it - closing the existing file before opening a new one repopulated the existing_filename with the default filename - preventing the opened file to become the new existing filename Also, make existing filename a const char * and make file_open have the same sensible default folder behavior as the other file related functions. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-09First cut of adding a default file nameGravatar Dirk Hohndel
The default file name is OS specific and tries to follow the customs on each of the OSs. It can be configured through the preferences dialog. On MacOS we get a strange warning which appears to be a well documented Gtk bug on MacOS. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-05-05set subsurface_flush_conf() to no-op in wondows.cGravatar Lubomir I. Ivanov
flushing the entire registry is not required on windows. simply closing the registry key when done would suffice. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-05-02Don't close config file when changing preferencesGravatar Linus Torvalds
On Linux and MacOS the subsurface_close_conf() doesn't really close the config file (it flushes writes on MacOS), but on Windows it does actually close the registry hkey. Which is bad, if you change the settings multiple times - we assume that the config file is open the whole time. So add a "subsurface_flush_conf()" function, and call *that* when changing configuration parameters. And call the close function only at the very end. Alternatively, maybe we should just open the config file separately every time. I don't much care, maybe somebody else does. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-01-03Even more Mac-i-nessGravatar Dirk Hohndel
Move the About and Preferences menu item to the App menu. Switch the accelerator key to be Meta (i.e., Command) instead of Control This required a bit of restructuring of the code, but it's all for a good cause. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-01-01Turn subsurface into a real Mac applicationGravatar Dirk Hohndel
To do this a few things needed to move into the os specific files, but the overall change is fairly small and the difference on the Mac is amazing. Subsurface now becomes a Mac app with Mac toolbar and useful default fonts. Changed the CFBundleIdentifier to be the reverse DNS of the subsurface site (sadly, 'torvalds' is not yet a TLD). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-12-28Make icon file name OS helper functionGravatar Dirk Hohndel
This way we can load the correct icon on the Mac without ugly hacks in the OS independent code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-12-14Return is not a functionGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-12-13Add reasonable default device names for divecomputer importGravatar Dirk Hohndel
So far we hard coded /dev/ttyUSB0 - which is a good starting point in Linux but not so useful on Windows or MacOS. This was now moved into one of our OS helper functions with (somewhat) reasonable defaults. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-25Add more typecasts for Windows`Gravatar Dirk Hohndel
This is based on an older patch by Lubomir I. Ivanov <neolit123@gmail.com> which no longer applies due to the refactoring of the registry setting code. It takes care of all of the casts between actual C types and the Windows specific types that the Windows API functions expect. It also adds some comments to the overloading of "value" in our subsurface_set_conf function. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-25Fix the Windows preferences supportGravatar Dirk Hohndel
Now that I can test Windows binaries again, the bugs were rather easy to spot. Because of the different flow of the opening, writing and closing of the registry key my first attempt got things wrong - we simply always create the key with all access rights; if it exists Windows will just open it for us. The second bug was a cut'n'paste error. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-24Improve cross compile support and fix windows.cGravatar Dirk Hohndel
This should make the Makefile much more robust when cross compiling. The windows.c code is now compile tested but not functionally tested. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-24Split reading/writing preferences into OS specific filesGravatar Dirk Hohndel
This adds tested code for Linux and Mac OS, implementing the api that Linus suggested. The Windows code was moved into its own file, but hasn't even been compile tested, yet. In order to have just one interface to set or get a preference value we encode TRUE as (void *) 1 and FALSE as NULL. This works consistently on all platforms and regardless of whether we have 32 or 64 bit. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>