aboutsummaryrefslogtreecommitdiffstats
path: root/linux.c
AgeCommit message (Collapse)Author
2013-05-03Matching build fixes for cross built WindowsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-03Fix Linux build with newer tool chainGravatar Dirk Hohndel
No idea why this builds fine on Fedora 17. Reported-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-03Remove the majority of the Gtk related codeGravatar Dirk Hohndel
- rip all Gtk code from qt-gui.cpp - don't compile Gtk specific files - don't link against Gtk libraries - don't compile modules we don't use at all (yet) - use #if USE_GTK_UI on the remaining files to disable Gtk related parts - disable the non-functional Cochran support while I'm at it 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-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-02Rename subsurface.svg to subsurface-icon.svgGravatar Henrik Brautaset Aronsen
In preparation for a subsurface-icon.h, this should avoid confusion about whether "subsurface.h" is a core header file. Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
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-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-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-16Redoing the Mac bundlingGravatar Dirk Hohndel
With the right tools in place you can now create a bundle from the Makefile by calling "make create-macos-bundle" In the process of this I also moved the locale directory where we stage our .mo files to share/locale (which is much more logical). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-15Support for gettext in MacOSX application bundleGravatar Henrik Brautaset Aronsen
The MacOSX applications bundle needs to be told where to bind the text domain from. Also copy the gettext .mo files in the install-macosx target. [Dirk Hohndel: minor change in main(): move the path declaration to the beginning of the function] Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-07Fix potential crash when attempting to free default fontGravatar Dirk Hohndel
Before setting a new font we try to free the existing font. Sadly if no config value is set for the default font, we assign a string literal. Which of course means that subsurface dumps core when trying to free it. 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-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-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>