Commit graph

67 commits

Author SHA1 Message Date
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
3e7780e7cd Added unicode support for the configuration entries on Windows
windows.c:

Windows's registry (which is technically a filesystem) uses UTF-16
for its "keys". This forces us to convert each of our UTF-8 (GLib, GTK)
configuration entries if we want to store special characters. To do that
we use the RegQueryValueExW() and do some conversation around
the function call itself.

The opposite happens when we require a UTF-16 value to be read from the
registry and converted to UTF-8 in subsurface_set_conf().

An addition to this patch is a somehow expandable buffer in
windows.c: subsurface_get_conf(). We increase the size of the buffer
in chunks of 64 bytes, until RegQueryValueExW() is able to write to it
(as suggested by the WINAPI documentation).

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-05 23:44:54 +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
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
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
Lubomir I. Ivanov
cf475114f6 set subsurface_flush_conf() to no-op in wondows.c
flushing the entire registry is not required on windows. simply
closing the registry key when done would suffice.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-05-05 10:00:10 -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
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
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
Dirk Hohndel
565736a471 Make icon file name OS helper function
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-28 15:57:36 -08:00
Dirk Hohndel
0a9e5aa735 Return is not a function
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-12-14 20:53:25 -08:00
Dirk Hohndel
4b77a5def6 Add reasonable default device names for divecomputer import
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-12-13 20:34:56 -08:00
Dirk Hohndel
192713680e Add more typecasts for Windows`
This is based on an older patch by Lubomir I. Ivanov <neolit123@gmail.com>
which no longer applies due to the refactoring of the registry setting
code.

It takes care of all of the casts between actual C types and the Windows
specific types that the Windows API functions expect. It also adds some
comments to the overloading of "value" in our subsurface_set_conf function.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-25 20:19:58 -08:00
Dirk Hohndel
d2654d4951 Fix the Windows preferences support
Now that I can test Windows binaries again, the bugs were rather easy to
spot. Because of the different flow of the opening, writing and closing of
the registry key my first attempt got things wrong - we simply always
create the key with all access rights; if it exists Windows will just open
it for us. The second bug was a cut'n'paste error.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-25 19:48:53 -08:00
Dirk Hohndel
042c77c0fc Improve cross compile support and fix windows.c
This should make the Makefile much more robust when cross compiling.

The windows.c code is now compile tested but not functionally tested.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-24 22:34:39 -08:00
Dirk Hohndel
671f6544ac Split reading/writing preferences into OS specific files
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>
2011-11-24 10:12:40 -08:00