summaryrefslogtreecommitdiffstats
path: root/macos.c
AgeCommit message (Collapse)Author
2015-10-30Move all core-functionality to subsurface-coreGravatar Tomaz Canabrava
And adapt a new CMakeLists.txt file for it. On the way I've also found out that we where double-compilling a few files. I've also set the subsurface-core as a include_path but that was just to reduce the noise on this commit, since I plan to remove it from the include path to make it obligatory to specify something like include "subsurface-core/dive.h" for the header files. Since the app is growing quite a bit we ended up having a few different files with almost same name that did similar things, I want to kill that (for instance Dive.h, dive.h, PrintDive.h and such). Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-13This patch reverts commit 50421f1f.Gravatar Lubomir I. Ivanov
Expose subsurface_mkdir() in qthelper.h as main.cpp already includes it. Once 'default_directory' is obtained call subsurface_mkdir() on it. subsurface_mkdir() will not throw an error if the directory exists according to the QDir documentation. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-13Make sure our default path exists (for Linux and Mac)Gravatar Dirk Hohndel
I'm not sure if this could ever turn into an issue on Windows - but on Linux and Mac this is an easy and safe thing to do and it avoids a situation where we try to save the picture hashes without having this directory. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-070 initialize stringsGravatar Dirk Hohndel
Otherwise bad things happen when you strcat into them. Oops. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-06macos.c: update the default path retriavalGravatar Lubomir I. Ivanov
- added system_default_directory() - both system_default_directory() and system_default_filename() now use the helper system_default_path_append() - less safer compared to windows.c, assuming the OS is stricter on which environment variables exist! [Dirk Hohndel: switched filename to be dynamically allocated to avoid possible buffer overflow] 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-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-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-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>
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-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-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-10-06First steps towards removing glib dependenciesGravatar Dirk Hohndel
- remove the build flags and libraries from the Makefile / Configure.mk - remove the glib types (gboolean, gchar, gint64, gint) - comment out / hack around gettext - replace the glib file helper functions - replace g_ascii_strtod - replace g_build_filename - use environment variables instead of g_get_home_dir() & g_get_user_name() - comment out GPS string parsing (uses glib utf8 macros) This needs massive cleanup, but it's a snapshot of what I have right now, in case people want to look at it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-17Two header files missing for Mac OSXGravatar Robert Helling
I needed to add to include files to make the latest version compile. Here is a patch. Signed-off-by: Robert C. Helling <helling@atdotde.de> Best Robert 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-22Disable some MacOSX GTK dependenciesGravatar Henrik Brautaset Aronsen
Now it's actually possible to build the Qt variant on MacOSX with MacPorts and marble support. Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-03Matching build fixes for cross built WindowsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-03Similar build fix for MacGravatar Dirk Hohndel
Apparently only older Linux toolchains didn't bother to throw up with the remainders of Gtk related code. 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-03Try to capture some more potential buffer overflows caused by localizationGravatar Dirk Hohndel
A couple of these could clearly cause a crash just like the one fixed by commit 00865f5a1e1a ("equipment.c: Fix potential buffer overflow in size_data_funct()"). One would append user input to fixed length buffer without checking. We were hardcoding the (correct) max path length in macos.c - replaced by the actual OS constant. But the vast majority are just extremely generous guesses how long localized strings could possibly be. Yes, this commit is likely leaning towards overkill. But we have now been bitten by buffer overflow crashes twice that were caused by localization, so I tried to go through all of the code and identify every possible buffer that could be affected by this. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-28Add MacOS support to window geometry save/restoreGravatar Henrik Brautaset Aronsen
Also make sure the config is flushed to disk. Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> 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-28Better Bluetooth device support on MacGravatar Dirk Hohndel
We now show the correct device name for Bluetooth connected dive computers in the drop down menu in the Download dialog. This also updates the corresponding chapter in user manual. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-28Fix compilation problem with LaunchServices on OSXGravatar Amit Chaudhuri
You cannot include the LSOpen.h directly on OSX - it is too far down in the System hierarchy to locate. Instead we include the umbrella header CoreServices.h which finds it for us. Signed off by Amit Chaudhuri <amit.k.chaudhuri@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-25Work around yet another Gtk bug: gtk_show_uri doesn't work on MacGravatar Dirk Hohndel
Instead use the native function to open the URL. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-09Add XSLT support for the macosx install and bundle targetsGravatar Henrik Brautaset Aronsen
Works like it should for the install-macosx target. I haven't tested the create-macosx-bundle target, but it shouldn't be any different. Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-05Change default MacOS fontGravatar Henrik Brautaset Aronsen
"Arial Unicode MS" doesn't have bold fonts, at least not on my system. This makes it impossible to distinguish trip dives from non-trip dives, since dives without at trip have bold index numbers. Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-17Update gtk-osx-integration to version 2 of the APIGravatar Dirk Hohndel
In order to be able to work with Gtk3 introspection all the APIs had to be renamed. Instead of quartz_application... and gtk_osxapplication... all the API functions are now name gtkosx_application... This will break the build for people who haven't upgraded to the latest - but supporting both would be unspeakably ugly. 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 Mac buildGravatar Dirk Hohndel
Just make the code compile on MacOS X 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-12-09Consistent Quit behavior on the MacGravatar Dirk Hohndel
We were responding to the wrong Quit signal on MacOS. The one we picked was the one that basically told us "it's too late to stop me, I'm quitting". I switched this to the one asking "should I prevent the app from quitting" and now we can indeed cancel the Quit, regardless which method was used to close the app. Also removes to unused variables. Fixes #22 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-05Fix broken MacOSX buildGravatar Henrik Brautaset Aronsen
Dirk's commit 2de6f796354ad029e9e786027210fcf1b02868e2 had a typo. Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> 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-16Adjust locale path for install-macosx targetGravatar Henrik Brautaset Aronsen
gtk-mac-bundler uses Contents/Resources/share/locale, and the install-macosx target should do the same. Also quiet down the make process a bit Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> 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>