aboutsummaryrefslogtreecommitdiffstats
path: root/windows.c
AgeCommit message (Collapse)Author
2014-11-13windows.c: small cleaup in the wrapper functionsGravatar Lubomir I. Ivanov
- use an already defined 'ret' value if available - don't put free() calls in NULL check branches (saves a line) Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-13Add subsurface_access()Gravatar Lubomir I. Ivanov
For our usage the method will acept UTF-8 paths, which are converted to UTF-16 on Win32. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-27Default font: more fine tuningGravatar Dirk Hohndel
In order to get rid of the old default font on Windows (Calibri) we are going to near ridiculous length. The reason for this is that we in the past always saved the default font in the settings (how stupid was that!) and so now even with a new default font in place, since there is an explicit font in the settings we take that instead of the default. Instead of requiring our existing users to use a registry cleaner to get the correct default font on Windows 7 and later (the VAST majority of our Windows users at this stage), we simply explicitly ignore that old default font. There is one very nasty side effect. A user cannot set Calibri as their font of choice on Windows 7 or later (because we always force them back onto Segoe). Given how much nicer Segoe looks I think this is an acceptable flaw - let's hope this doesn't come back to bite me in the future. At the same time this changes the default font size handling. We try to get the default font size of the OS so the app looks "right". This seems to not give me the expected result on Linux with KDE, but maybe I'm doing it wrong? Looks good when testing on Windows. See #712 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-22Use the Windows default font on Windows 7 and 8/8.1Gravatar Dirk Hohndel
It contains the characters we need and will make the application look more "native". See #712 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-09windows.c: prevent a warning due to #define _WIN32_WINNT...Gravatar Lubomir I. Ivanov
mingw 4.8.2 complains: warning: "_WIN32_WINNT" redefined 0x500 suits our needs windows.c wise. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-19Download from dive computer: Fix the broken selection of devicesGravatar Dirk Hohndel
The old code was completely bogus - it's confused about what the variable 'i' is counting. This also let's us select the Uemis mount point by default if that's the only valid "device" that we found. Compile tested on Windows, untested on Mac. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-19Divecomputer download: try to offer only those devices that make senseGravatar Dirk Hohndel
If the user selects a Uemis divecomputer, don't show serial devices. If the user selects a serial divecomputer, don't show the Uemis filesystem. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-19Change the default font on Windows to CalibriGravatar Gehad
Changing the default font on Windows to Calibri instead of Sans to fix the subscript issue. Fixes #461 Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-14git-save: improve commit authorship dataGravatar Linus Torvalds
We used to always just commit as "subsurface@hohndel.org" because libgit-19 doesn't have the interfaces to do user name lookup. This does better if you have libgit-20, using "git_signature_default()" to get the actual user that does the saving. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-02windows.c: prevent an unused warningGravatar Lubomir I. Ivanov
When building with WIN32_CONSOLE_APP (or CONFIG += console) we need to fake-use console_desc or a warning will pop out. __attribute__((unused)) is available, but is GCC only. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-25Add optional Win32 console allocationGravatar Lubomir I. Ivanov
This patch adds the optional --win32console command line option. It does nothing on OSx and Linux, while is only useable on Win32. On Win32 if the application was built as GUI (not console), there is no way to view stdout and stderr. With windows.c's subsurface_console_init() we are able to either redirect stdout and stderr to the terminal from which subsurface.exe was started (always happens; --win32console does nothing in this case) or if --win32console is explicitly added to a shortcut, create a dedicated console window and monitor the output there. if set, WIN32_CONSOLE_APP is a condition that will make the subsurface_console_init() and subsurface_console_exit() functions NOP on Windows. The definition will be created if the user passes 'CONFIG += console' to qmake. Fixes #436 Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-21Fix system default font handlingGravatar Anton Lundin
We didn't care about system default fonts and sizes, we just used the Qt default font. Due to how QFont is constructed, there was need to split font and font size. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-27Massive automated whitespace cleanupGravatar Dirk Hohndel
I know everyone will hate it. Go ahead. Complain. Call me names. At least now things are consistent and reproducible. If you want changes, have your complaint come with a patch to scripts/whitespace.pl so that we can automate it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-16Rename old 'xml' file as 'bak' file when savingGravatar Linus Torvalds
If you use the standard naming convention and end your subsurface filename in ".xml", we will now save away any previous xml file as a "bak" file before writing a new one. This can be useful for: - recovering from mistakes that deleted old dives - seeing what changed (ie you can do things like "diff -u xyz.bak xyz.xml") after doing some operation and saving the result. However, this does only a single level of backups - if you save twice, you will obviously have lost the original. I'd strongly encourage some external backup system in addition to this very simplistic backup. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-08windows.c: Fix possible assert when passing NULL to *open()Gravatar Lubomir I. Ivanov
On Win32 subsurface_fopen() can reach an assert in windows.c: utf8_to_utf16(), if NULL is passed for 'path'. Let's return NULL/-1 for some of the *open() functions in there. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20Fix compilation with libzip < 0.10Gravatar Thiago Macieira
Signed-off-by: Thiago Macieira <thiago@macieira.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-19Files: add wrappers for certain open() methodsGravatar Lubomir I. Ivanov
Due to filepath encoding issues on win32 we need wrappers for: - open() - fopen() - opendir() - zip_open() (this is readonly on win32) Patch only declares/defines the wrappers in dive.h, windows.c, linux.c, macos.c. Suggestions-by: Thiago Macieira <thiago@macieira.org> Suggestions-by: Jef Driesen <jefdriesen@telenet.be> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-09windows.c: use the USERNAME enviroment variableGravatar Lubomir I. Ivanov
system_default_filename(): Use USERNAME, which should work for Windows XP and above. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-08main.cpp: remove usage of subsurface_command_line_*Gravatar Lubomir I. Ivanov
subsurface_command_line_* are now redundant as Qt should handle the command line argument parsing on Windows for which these functions where mainly used and where NOP for other OS. main.cpp also receives a couple of small changes to use: QCoreApplication::arguments() to obtain the list of expanded arguments and parse those instead. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-07Remove feature checkingGravatar Dirk Hohndel
We needed this in Gtk version as we were using a system font to show the stars and that was missing on some ancient Windows versions. With the Qt version we actually draw the stars so this has become obsolete. Suggested-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06Make Windows cross compile againGravatar Dirk Hohndel
But this is broken as the utf8/utf16 conversions in windows.c are gone without glib. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06Delete code and files that are no longer usedGravatar Dirk Hohndel
Most of this is Gtk related, some of it is helpers that we don't need anymore. I love the diffstat. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06Changes to make the glib-removal-hack branch build on MacOSXGravatar Henrik Brautaset Aronsen
Tested with the Homebrew packaging system Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-17Fix Windows compileGravatar Dirk Hohndel
When submitting commit 8f33b81de0f9 ("implement device probe in C"), Danilo explicitly asked me to make sure this compiles / works on Windows and Mac - and I promptly forgot to do so. Robert fixed the Mac build, this now at least compiles under Windows (but it's still untested). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-16implement device probe in CGravatar Danilo Cesar Lemes de Paula
It's an attempt to build auto-completion for the dive-computers based on unpublished code inside libdivecomputer[1] [1] - http://git.libdivecomputer.org/?p=libdivecomputer.git;a=commitdiff;h=d44053a99435fb9fc1f408fb3f1629a54c938afc Signed-off-by: Danilo Cesar Lemes de Paula <danilo.eu@gmail.com>
2013-05-03Matching build fixes for cross built WindowsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-01Match subsurface_get_conf* in windows/macos.c with linux.cGravatar Henrik Brautaset Aronsen
The signatures for subsurface_get_conf* in windows.c and macos.c was slightly different from those in linux.c, which broke the build (at least on Mac). Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-01Have some C++ file in the projectGravatar Alberto Mardegan
Rename gtk-gui.c to qt-gui.cpp, and make the necessary changes so that the project still builds. Signed-off-by: Alberto Mardegan <mardy@users.sourceforge.net>
2013-03-05windows.c: Use a zeroed buffer when retrieving the module pathGravatar Lubomir I. Ivanov
There is a small API note on GetModuleFileName(), which says: "Windows XP: The string is truncated to nSize characters and is not null-terminated." Which means that on XP it will be only safe if we pass a zeroed buffer to it, otherwise the next call to wcsrchr (which is a strchr for wchar_t) may not find a relative terminating \0 in the buffer, returning a wrong pointer and resulting in a corrupted string. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-05windows.c: Change the current process path to the module pathGravatar Lubomir I. Ivanov
When an executable is started on Windows, it has a "Working directory". This directory for a program shortcut stored on the Desktop can be different than the actual executable directory. This also applies if a shell extension is registered to that executable (in the case of Subsurface that could be a .DLD file). When another process simply "executes" a file with a certain extension (e.g. when you double click on a .DLD file), a method ShellExecute is called, which without explicit parameters sets the "Working directory" to the .DLD file directory. This can be a bit of a trouble if the executed module depends on relative paths (e.g. ./xslt, ./share). To solve that we obtain our module full path and filename using GetModuleFileName(), strip the filename from it (e.g. subsurface.exe) and then pass the resulted string to SetCurrentDirectory(), which updates the "Working directory". Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-02windows.c: Fix broken subsurface_unset_conf()Gravatar Lubomir I. Ivanov
windows.c has be revisited so many times, yet just now I've noticed that we aren't deleting/unsetting a configuration value ever. What has went strangely unnoticed is that subsurface_unset_conf() needs RegDeleteValue instead of RegDeleteKey. "keys" in the Windows registry are like folders which contain files (or "values"). So in this case we need to delete a "file" and not a "folder" using RegDeleteValue(). This ended up being a problem with the new prefs.c logic, where there is a check if a config value is the default value and then it will be unset/deleted. There was potential for a crash, where a NULL value can reach pango_font_description_from_string() for the divelist font. It also wasn't possible to change the divelist font back to the default font (e.g. Sans 8), once a different font was selected. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-01windows.c: use ANSI for subsurface_unset_conf()Gravatar Lubomir I. Ivanov
We may not write config variables with UTF-8 characters so the wchar_t conversation in subsurface_unset_conf() is not needed. This patch also attempts to improve subsurface_get_conf_bool() and subsurface_get_conf_int() or better consitentcy with the other OS files. For both functions return -1 if config key is not found. Previouosly there was a check for that in function get_from_registry(). Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-28windows.c: Added support for "int" configuration storageGravatar Lubomir I. Ivanov
This patch addes body to the functions subsurface_get_conf_int() and subsurface_set_conf_int(). It also makes some small changes: - subsurface_get_conf_bool() now uses subsurface_get_conf_int() - for retrieving DWORDS we would only need RegQueryValueEx, thus the wchar_t conversations aren't really needed, unless we start storing integers in keys with UTF-8 characters in the name. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-28Remember window sizeGravatar Amit Chaudhuri
This commit has gone through a few iterations and I trimmed it down to what I consider the "conservative minimum" - so this only stores window size, not window position. And in my mind that's the more relevant part, anyway. Have your window manager position the window at a "smart" spot on your screen... Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com> Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09Fixed some memory leaks in windows.c and main.cGravatar Lubomir I. Ivanov
windows.c:subsurface_gettext_domainpath(): - memory at pointer returned from g_win32_getlocale() should be released main.c:setup_system_prefs() - it seems all calls to <os_file>:system_default_filename() return a pre-allocated buffer, therefore we don't need to call strdup() on the result itself. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-30Massive cleanupGravatar Dirk Hohndel
Mostly coding style and whitespace changes plus making lots of functions static that have no need to be extern. This also helped find a bit of code that is actually no longer used. This should have absolutely no functional impact - all changes should be purely cosmetic. But it removes a bunch of lines of code and makes the rest easier to read. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-25Remove some unnecessary variable initializationsGravatar Dirk Hohndel
Not really bugs, just wasted. They clutter up the output of static analysis with cppcheck. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-25windows.c: Add unicode support in subsurface_launch_for_uri()Gravatar Lubomir I. Ivanov
subsurface_launch_for_uri() requires unicode support, using ShellExecuteW() and also the passed UTF-8 buffer has to be translated to UTF-16 beforehand. Once the ShellExecuteW() is done we release the UTF-16 allocation. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-15Added the OS dependent function subsurface_launch_for_uri()Gravatar Lubomir I. Ivanov
Opening URI addresses from Subsurface does not work on Windows using the latest GTK bundle from the Gnome website. The reason lies in GIO and GLib and how it obtains assigned applications for protocols and MIME types. While gtk_show_uri() should be viable for both linux.c and macos.c, in windows.c ShellExecute() is used, which provides proper support for the URI calls. subsurface_launch_for_uri() returns TRUE on success. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-11Add default filename and divelist font to prefs structureGravatar Linus Torvalds
.. and add the usual logic to not save the default values. This also simplifies the initial system-specific setup of both of these: since we have defaults for all the preferences that get set up at startup, we can just initialize those defaults to the system-specific fonts then and there. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-10Fix Windows buildGravatar Dirk Hohndel
Just making the code in the last commit (cross) compile on Windows. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-10Clean up preference saving codeGravatar Linus Torvalds
The old code (on purpose) didn't try to differentiate "nonexisting boolean configuration" with "existing boolean configuration set to false", which is problematic if we optimize the saving to not save default preferences at all. Which this does. So in addition to the logic to know about default preferences, this has to change the interfaces for the PREF_BOOL reading code so that you can tell the difference between "no value" and "false". And since the previous calling convention was an abomination of doing pointer casting and having case-statements for the config types, change that while at it. Both from a usage perspective *and* from a back-end perspective it is actually much simpler to just have different functions for the string vs boolean config read/write versions. The OSX versions in particular end up being one-liners. (The GConf library is a nightmare, and doesn't seem to have any way to know whether a boolean value exists or not, so you have to read it as a GConfVal and then turn it into a gboolean rather than just get the "oh, it didn't exist" as an error value). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-10Split up preference data structure definition into 'pref.h'Gravatar Linus Torvalds
.. and rename the badly named 'output_units/input_units' variables. We used to have this confusing thing where we had two different units (input vs output) that *look* like they are mirror images, but in fact "output_units" was the user units, and "input_units" are the XML parsing units. So this renames them to be clearer. "output_units" is now just "units" (it's the units a user would ever see), and "input_units" is now "xml_parsing_units" and set by the XML file parsers to reflect the units of the parsed file. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-31Show drive name after the drive letter on WindowsGravatar Dirk Hohndel
In the device selector when downloading from a divecomputer add the drive name that we have been looking for (so far that's only "UEMISSDA") to the drive letter - this should make it easier for people to figure out why there is a drive letter offered as an option. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-29windows.c: added device retrieval from subsurface_fill_device_list()Gravatar Lubomir I. Ivanov
subsurface_fill_device_list() now goes trough the list of registry entries in the SERIALCOMM key and adds all present values (such as COM1, COM2) to a GtkListStore. Once done the function compares all logic drive label to a static list of known DC labels, such a 'UEMISSDA', which is the only present one at the moment and adds any matching drive letters (e.g. C:\, H:\) to the list store as well. If no serial ports were added or no matching logical drives were found the function simply adds a default entry named "COM1". Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2012-10-27Improve the dive computer device selectionGravatar Dirk Hohndel
We try to identify devices that are connected and their matching device names (and mount paths in the case of the Uemis Zurich). Those are presented as a drop down menu to choose from. The user can still override this by simply entering a different device / path name. On Windows this is not functional. How do I find out which drive letter corresponds to the USB device named "UEMISSDA"? Similarly we need code that finds serial ports that are present. For now we once again default to COM3 (so this isn't a step back, but of course it's far from what we want). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-19Added a function to check if specific OS features are availableGravatar Lubomir I. Ivanov
linux.c, macos.c, windows.c now contain subsurface_os_feature_available() that can accept an enum type os_feature_t defined in dive.h. The function can be useful to check if a specific global feature is available on a certain OS version. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-18Find translation files on Linux after Subsurface was installedGravatar Dirk Hohndel
So far we only looked in the a local subdirectory, but once Subsurface has been installed, we don't need to change the search path for translation files anymore. Fixes #2 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-16Improved packaging for WindowsGravatar Dirk Hohndel
This commit adds an install-cross-windows target to the Makefile that creates a staging directory for us under packaging/windows that contains the required .mo files. This currently fails for the Norwegian translation because of the no_NO.UTF-8 vs nb issue - right now we just use the first component of our own localization filename to find the matching Windows localization and that fails. The subsurface.nsi file is updated accordingly and this now appears to create working installers with sane paths for the localization files. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-15Set locale under WindowsGravatar Dirk Hohndel
This is mostly a quick hack to be able to test localization under Windows. It seems to work fine under Windows 7 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>