Commit graph

54 commits

Author SHA1 Message Date
Lubomir I. Ivanov
f487953ad3 Files: add wrappers for certain open() methods
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-12-19 07:28:20 -08:00
Lubomir I. Ivanov
218c0956e2 main.cpp: remove usage of subsurface_command_line_*
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-08 06:26:03 -07:00
Dirk Hohndel
4e6dd75d11 Remove feature checking
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-07 09:39:25 -07:00
Dirk Hohndel
34db6dc2be Delete code and files that are no longer used
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-06 17:32:50 -07:00
Henrik Brautaset Aronsen
4d0b6e698a Changes to make the glib-removal-hack branch build on MacOSX
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-06 10:42:32 -07:00
Dirk Hohndel
4b12f28ca4 First steps towards removing glib dependencies
- 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-10-06 10:41:44 -07:00
Robert Helling
fb0ecf6cd6 Two header files missing for Mac OSX
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-17 07:58:17 -04:00
Danilo Cesar Lemes de Paula
a8d33f80b0 implement device probe in C
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-09-16 22:40:47 -03:00
Henrik Brautaset Aronsen
375faa5cff Disable some MacOSX GTK dependencies
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-22 06:20:26 -07:00
Dirk Hohndel
060e5c764c Matching build fixes for cross built Windows
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-03 13:34:55 -07:00
Dirk Hohndel
aa3838308b Similar build fix for Mac
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-05-03 13:13:14 -07:00
Henrik Brautaset Aronsen
f2ab8f42ee Match subsurface_get_conf* in windows/macos.c with linux.c
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-01 10:01:01 -07:00
Alberto Mardegan
578d633d01 Have some C++ file in the project
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-04-01 16:03:59 +03:00
Dirk Hohndel
0129192958 Try to capture some more potential buffer overflows caused by localization
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-03-03 20:18:23 -08:00
Henrik Brautaset Aronsen
b24d0f2f60 Add MacOS support to window geometry save/restore
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-28 15:39:49 -08:00
Amit Chaudhuri
d742d7b391 Remember window size
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-28 15:36:27 -08:00
Dirk Hohndel
e5f2f3e65f Better Bluetooth device support on Mac
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-28 07:43:31 -08:00
Amit Chaudhuri
92fbbd4c22 Fix compilation problem with LaunchServices on OSX
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-28 05:52:29 -08:00
Dirk Hohndel
a635c30564 Work around yet another Gtk bug: gtk_show_uri doesn't work on Mac
Instead use the native function to open the URL.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-25 13:22:33 -08:00
Henrik Brautaset Aronsen
eb7acc1d96 Add XSLT support for the macosx install and bundle targets
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-09 09:44:51 -08:00
Henrik Brautaset Aronsen
f334175bdd Change default MacOS font
"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-02-05 08:33:46 +11:00
Dirk Hohndel
91d6d12416 Update gtk-osx-integration to version 2 of the API
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-17 11:14:47 -08:00
Lubomir I. Ivanov
678fffdcf4 Added the OS dependent function subsurface_launch_for_uri()
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-15 08:51:32 -08:00
Linus Torvalds
6a10700ca5 Add default filename and divelist font to prefs structure
.. 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-11 17:46:00 -08:00
Dirk Hohndel
ac376ea379 Fix Mac build
Just make the code compile on MacOS X

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-10 20:45:22 -08:00
Linus Torvalds
8dea49ffe2 Clean up preference saving code
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-10 20:30:54 -08:00
Linus Torvalds
868a2cc090 Split up preference data structure definition into 'pref.h'
.. 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>
2013-01-10 20:30:32 -08:00
Dirk Hohndel
c9a03db480 Consistent Quit behavior on the Mac
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-12-09 15:23:33 -08:00
Henrik Brautaset Aronsen
45fce18fb2 Fix broken MacOSX build
Dirk's commit 2de6f79635 had a typo.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-05 09:04:00 -08:00
Dirk Hohndel
2de6f79635 Improve the dive computer device selection
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-27 21:12:14 -07:00
Lubomir I. Ivanov
5b3e480be3 Added a function to check if specific OS features are available
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-19 21:14:00 -07:00
Dirk Hohndel
834825f406 Find translation files on Linux after Subsurface was installed
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-18 14:30:45 -07:00
Dirk Hohndel
04c5e65b8c Redoing the Mac bundling
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-16 21:37:43 -07:00
Henrik Brautaset Aronsen
0d89d511bb Adjust locale path for install-macosx target
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-16 13:11:12 -07:00
Henrik Brautaset Aronsen
ef039c9d32 Support for gettext in MacOSX application bundle
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-15 09:36:30 -07:00
Dirk Hohndel
1a6cf2f128 Fix potential crash when attempting to free default font
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-07 20:57:24 +09:00
Lubomir I. Ivanov
f928be5061 Provide a method to use unicode command line arguments on Windows
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-10-04 03:12:19 -07:00
Henrik Brautaset Aronsen
f83625efa5 Proper placement for the file menu separator lines in MacOSX
After Lubomir's latest changes to the File menu, the separator
were a little off.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-18 19:20:44 -04:00
Dirk Hohndel
7148dea827 Once again improve existing filename handling
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-17 21:03:30 -04:00
Dirk Hohndel
1ae4b80027 Make sure Subsurface receives Quit / Command-Q callback on Mac
As usual, things work slightly different on Mac. Quartz delivers some (but not
all) accelerator notifications differently. Command-Q and Subsurface->Quit now
work on Mac as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-12 09:18:56 -07:00
Dirk Hohndel
1afe36840d Fix memory handling error on MacOS
We are not allowed to free a string that we get back from the config APIs. So
strdup it instead to be compatible with Linux in that respect.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-11 20:52:54 -07:00
Dirk Hohndel
b73f29fea3 First cut of adding a default file name
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-09-09 17:38:01 -07:00
Henrik Brautaset Aronsen
21b2289206 Remove separator line in MacOSX File menu
This separator line doesn't make sense in the File menu on MacOSX.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
2012-08-20 08:59:42 +02:00
Dirk Hohndel
5b56aa1435 Minor Macos menu entry modification fix
We have removed a menu separator from the gtk gui and that was still
referenced in the Macos code. And just in case, we are now testing
for the widget for the other separator to be non-NULL before
destroying it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-17 19:54:27 -07:00
Linus Torvalds
725e4582d9 Don't close config file when changing preferences
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-05-02 10:03:48 -07:00
Henrik Brautaset Aronsen
854391419f More Mac improvements
The startup shell script workaround isn't needed anymore. The preferences
hotkey didn't work. Remove left-over menu separators.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
2012-01-03 20:19:57 +01:00
Dirk Hohndel
513df18f50 Even more Mac-i-ness
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-03 07:25:35 -08:00
Dirk Hohndel
eac816b9d8 Use the right function to get resource path on Mac
Much better than hacking together my own...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-01-02 08:26:24 -08:00
Henrik Brautaset Aronsen
3232632fd6 Use a more standard approach to save preferences on MacOSX
CFPreferences* seems to be the proper way to handle preferences on MacOSX.
This approach also eliminates a problem where the hard coded preferences
path couldn't be read.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
[ fixed small coding style issues ]
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-01-02 07:31:19 -08:00
Dirk Hohndel
605e063203 Turn subsurface into a real Mac application
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>
2012-01-01 14:01:38 -08:00