Commit graph

69 commits

Author SHA1 Message Date
Tomaz Canabrava
4c0156e3d5 Move all core-functionality to subsurface-core
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-30 10:36:48 -07:00
Lubomir I. Ivanov
8d2d7cd4a3 This patch reverts commit 50421f1f.
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-13 11:34:26 -07:00
Dirk Hohndel
50421f1fa8 Make sure our default path exists (for Linux and Mac)
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-13 10:32:33 -07:00
Dirk Hohndel
43023fa519 0 initialize strings
Otherwise bad things happen when you strcat into them. Oops.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-07 09:38:55 +01:00
Lubomir I. Ivanov
ed98d3bc60 macos.c: update the default path retriaval
- 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>
2015-10-06 16:04:10 +01:00
Lubomir I. Ivanov
4096383fb5 Add subsurface_access()
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-11-13 11:58:59 -08:00
Dirk Hohndel
9aca309611 Default font: more fine tuning
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-27 15:45:43 -07:00
Dirk Hohndel
e893f6bd9d Use the Windows default font on Windows 7 and 8/8.1
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-08-22 15:56:57 -07:00
Dirk Hohndel
c4899aa8f1 Download from dive computer: Fix the broken selection of devices
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-19 20:12:58 +09:00
Dirk Hohndel
047032ee46 Divecomputer download: try to offer only those devices that make sense
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-05-19 20:12:55 +09:00
Linus Torvalds
a3aacfc6c2 git-save: improve commit authorship data
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-14 16:07:59 -07:00
Lubomir I. Ivanov
74ed786d75 Add optional Win32 console allocation
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-25 07:57:27 -07:00
Anton Lundin
9cfc585563 Fix system default font handling
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-03-21 21:30:39 -07:00
Dirk Hohndel
76e6420f6b Massive automated whitespace cleanup
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-27 20:09:57 -08:00
Linus Torvalds
90dddeb4cc Rename old 'xml' file as 'bak' file when saving
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-02-16 15:58:02 -08:00
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