Commit graph

973 commits

Author SHA1 Message Date
Henrik Brautaset Aronsen
cfaa5563bf Better gettext build
My previous take at adding gettext to the Makefile wasn't very good,
since it always relinked the subsurface executable.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-12 12:17:09 -07:00
Linus Torvalds
920c1e58ff Add Swedish translation
This is a horrible mish-mash of the english and norwegian translation
and my random odd swedish translations of them.

It's bad. But it's a starting point. If somebody complains, they
hopefully say things like "That should be xyz" and it can be fixed.

[Dirk Hohndel: minor edit to the .po file to at least no longer claim to
               be Norwegian...]

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-12 12:37:22 +09:00
Dirk Hohndel
efb1928d51 Add translation files to the Windows installer package
A lot more needs to happen for localization on Windows, but this is the
first step.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-12 12:33:24 +09:00
Lubomir I. Ivanov
fcb09c8078 Add Bulgarian translation
Some of the exact translations of terminology such as SAC (ППК) might
need a revision by an expert. Also, some of the things ended up being up
2-3 times longer (similar to German), so I'm not sure how this is going to
reflect on the UI.

[Dirk Hohndel: minor fixes to the .po file to make it compile]

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-12 06:52:12 +09:00
Dirk Hohndel
5801dcf78b Use lang_COUNTRY.po naming convention for translation files
Rename nl.po to nl_NL.po

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-12 06:39:18 +09:00
Henrik Brautaset Aronsen
134c76ab80 Updated Norwegian translation
Added the missing translations for the File menu et al.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-12 06:32:26 +09:00
Dirk Hohndel
a68945646d Update German translations for newly added menu strings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-11 23:15:08 +09:00
Dirk Hohndel
45e84618f5 Make translations of menu entries explicit
It appears that at least for Norwegian the translations of the stock menu
entries was missing. This patch adds those as explicit strings and merges
those new strings into the .po files.

The translations need to be updated in separate commits.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-11 23:08:45 +09:00
Jacco van Koll
2a6db9c7ae Add Dutch localization
Signed-off-by: Jacco van Koll <jacco.van.koll@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-11 22:27:16 +09:00
Dirk Hohndel
d4a3ecedb0 Get divelist headers localized, too
This fixes an oversight in commit 881a2df83616 ("Conversion to gettext to
allow localization") - string literals that are marked with N_ need to be
converted when the corresponding variables are used at runtime. This was
missed for the divelist headers.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-11 22:03:10 +09:00
Henrik Brautaset Aronsen
f5de37dbcf Basic gettext support when building
Added basic support for building gettext locales in the Makefile.
The po file name should match the target locale.

[Dirk Hohndel: Used git mv to rename the German .po file]

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-11 21:45:30 +09:00
Henrik Brautaset Aronsen
870978331e Add Norwegian Bokmål translation
This file was created with "msginit --locale=no_NO --input=deutsch.po"
and edited with poedit afterwards.

The correct locale for Norwegian Bokmål really is nb_NO, but this is
a new-ish construct, and that locale doesn't seem to be available
on MacOSX.  We might need to create .mo files in both
locale/no_NO.UTF-8 and locale/nb_NO.UTF-8 to satisfy all platforms.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-11 21:27:30 +09:00
Dirk Hohndel
99846da77f Conversion to gettext to allow localization
This is just the first step - convert the string literals, try to catch
all the places where this isn't possible and the program needs to convert
string constants at runtime (those are the N_ macros).

Add a very rough first German localization so I can at least test what I
have done. Seriously, I have never used a localized OS, so I am certain
that I have many of the 'standard' translations wrong. Someone please take
over :-)

Major issues with this:

- right now it hardcodes the search path for the message catalog to be
  ./locale - that's of course bogus, but it works well while doing initial
  testing. Once the tooling support is there we just should use the OS
  default.

- even though de_DE defaults to ISO-8859-15 (or ISO-8859-1 - the internets
  can't seem to agree) I went with UTF-8 as that is what Gtk appears to
  want to use internally. ISO-8859-15 encoded .mo files create funny
  looking artefacts instead of Umlaute.

- no support at all in the Makefile - I was hoping someone with more
  experience in how to best set this up would contribute a good set of
  Makefile rules - likely this will help fix the first issue in that it
  will also install the .mo file(s) in the correct place(s)

  For now simply run

  msgfmt -c -o subsurface.mo deutsch.po

  to create the subsurface.mo file and then move it to
  ./locale/de_DE.UTF-8/LC_MESSAGES/subsurface.mo

  If you make changes to the sources and need to add new strings to be
  translated, this is what seems to work (again, should be tooled through
  the Makefile):

  xgettext -o subsurface-new.pot -s -k_ -kN_ --add-comments="++GETTEXT" *.c
  msgmerge -s -U po/deutsch.po subsurface-new.pot

  If you do this PLEASE do one commit that just has the new msgid as
  changes in line numbers create a TON of diff-noise. Do changes to
  translations in a SEPARATE commit.

- no testing at all on Windows or Mac
  It builds on Windows :-)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-11 10:03:03 +09:00
Dirk Hohndel
a2afe41280 A file that we import should never become the default file we save to
Only files that are opened should be considered r/w. Files that are
imported should be treated as if they were r/o.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-09 21:50:16 +09:00
Lubomir I. Ivanov
ffd3b8591d subsurface.nsi: install program shortcuts for all users
http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.7.7:
"Sets the context of $SMPROGRAMS and other shell folders. If set
to 'current' (the default), the current user's shell folders are used.
If set to 'all', the 'all users' shell folder is used"

Specific to the Windows installer.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-09 16:32:05 +09:00
Dirk Hohndel
856e10ddb2 Add trip above adds all consecutive selected dives to the new trip
Before this commit we had the odd behavior that if we right clicked in the
middle of a group of selected dives, the trip was added above the dive we
clicked on, not above the group.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-09 16:32:05 +09:00
Dirk Hohndel
14856aab4b Bump version to 2.0.1
That crash is far too easy to hit for people just trying out subsurface.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-07 21:02:48 +09: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
Dirk Hohndel
b4c11a7ed3 Turn menu and button images on regardless of OS settings.
Right now the menu and button images are a distribution choice - some
have them on, some have them off. I kinda like them and think that even on
OSs that have them off by default this doesn't look out of place (as other
apps clearly do the same).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-06 05:26:55 +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
b272fb8c3b Fixed some memory leaks related to string configuration entries
Each time we retrieve a string configuration entry via
subsurface_get_conf(), all the multiplatform methods in linux.c,
macos.c, windows.c allocate memory for the returned value.

In gtk-gui.c, lets try to release the memory at:
default_dive_computer_vendor, default_dive_computer_product, divelist_font
before assigning a new address to these pointers.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-05 23:44:37 +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
3917e7b2f7 Force subsurface.sh on Mac to use bash
This was in a patch set from Henrik but got dropped at first while we
explored a different solution. So now it comes back as maybe the most
trivial commit, ever :-)

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-04 03:07:22 -07:00
Henrik Brautaset Aronsen
29e19cdfb7 Add readme file for MacOSX package
There are a couple of gothas on MacOSX involving GateKeeper on
Mountain Lion, and dialogues that sometimes doesn't pop up.  This
file explains that.  The file should be included in the DMG, but that's
for a different commit.

[Dirk Hohndel: fix whitespace and some rephrasing]

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-04 03:01:27 -07:00
Lubomir I. Ivanov
4f18f83ce9 Use GLib's g_fopen() and g_open() when working with files
On Windows, the GLib wrappers for fopen() and open() deal with the UTF-8
format used for file names when we have to open or save a file with
unicode characters in its name.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-04 02:43:10 -07:00
Dirk Hohndel
f3b9a37fb2 More fixes to MacOS bundle file and README
This still seems to fail to open the icon in the About screen in some
cases, but we don't quite understand why...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-02 12:13:19 -07:00
Henrik Brautaset Aronsen
eba4b86788 Fix typos for MacOSX packaging scripts
Fixed a couple of typos.

[Dirk Hohndel:	I took the typo fixes, but not the change of shell used;
		rewrote the commit message accordingly]

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-02 11:12:28 -07:00
Henrik Brautaset Aronsen
fec749c1b4 Rename Import XML File menu entry
Renamed to "Import XML File(s)", since we can import more than one file.

H

From 8f9b11d940d903316dcf4d023e327f365e4f4ccb Mon Sep 17 00:00:00 2001
From: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Date: Tue, 2 Oct 2012 11:38:56 +0200
Subject: [PATCH] Rename Import XML File menu entry

Renamed to "Import XML File(s)", since we can import more than one file.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-02 11:11:21 -07:00
Lubomir I. Ivanov
5468f19a05 Fixed potential, rare corruption of unicode characters
In divelist.c:get_string(), when truncating the string to a maximum
of 60 characters (to be shown in the divelist), make sure we are
counting in guinchar (sizeof usually 2) instead of gchar (sizeof usually 1).
Use Glib functions such as g_utf8_strlen() and g_utf8_strncpy() to do that.

This patch fixes the potential problem when truncating a UTF-8 string
by calculating its length using strlen() in bytes.

For char = 1 byte, if the length returned by strlen() is an odd number
this means there is at least one single byte length character in there.

But also if the same string has a UTF-8 character at exactly the truncate
position minus x(probably 1) bytes, we are going to split the bytes
forming said UTF-8 char resulting in an incorrect string.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-02 10:11:16 -07:00
Lubomir I. Ivanov
f2adb0cea6 fixup_dive(): move the add_* calls before a possible return
In dive.c:fixup_dive() it would be better to call functions
like add_people() and add_location() before the possible return
in the "if (end < 0)" branch.

This prevents a partial auto-complete list in "Dive Info"
combo boxes.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-02 09:27:14 -07:00
Lubomir I. Ivanov
fa5afc697e Fix memory leaks related to dive_trip->location
When creating a new dive_trip from a dive, we should probably
always copy the location via strdup(). However we then have to take
care of the de-allocation in divelist.c:delete_trip()
and gtk-gui.c:file_close().

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-01 20:56:17 -07:00
Lubomir I. Ivanov
cfefa0206d Destroy the divelist (tree) before calling gtk_main_quit()
Added new function dive_list_destroy() in divelist.c

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-01 20:55:28 -07:00
Lubomir I. Ivanov
7f01b91c99 Fixed memory leaks specific to divelist.c
move_dive_between_trips() always returns a pointer to a new
allocated memory block of size = GtkTreeIter. Lets free said memory
when no longer needed in the caller functions.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-01 20:53:52 -07:00
Dirk Hohndel
73f290be8f Add packaging files for MacOS
I couldn't figure out how the current packaging infrastructure was supposed to
work, but with not too much work I could get the more standard gtk-mac-bundler
to do what I wanted, so I added the support files needed for that and a little
README on how to use them.

The subsurface.sh and subsurface.bundle files are based on the launcher.sh
and gtk-demo.bundle files from the gtk-mac-bundler release which is under GPLv2.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-01 20:47:50 -07:00
Lubomir I. Ivanov
0559a6a783 Fixed some small memory leaks
Looks like a GtkEntryCompletion object created with
gtk_entry_completion_new() should be unreferenced after usage
(e.g. post gtk_entry_set_completion())

In info.c:get_combo_box_entry_text(), moved the free(..) line outside,
so that we can free regardless.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-01 14:06:46 -07:00
Linus Torvalds
3244a828f3 New XML format for saving dives
This patch makes the trips nest, and it also fixes the fact that you never
saved the trip notes (you could edit it, but saving would throw it away).

I did *not* change the indentation of the dives, so the trip stuff shows
up the the beginning of the line, at the same level as the <dive> and
<dives> thing. I think it's fairly readable xml, though, and we haven't
really had proper "indentation shows nesting" anyway, since the top-level
"<dives>" thing also didn't indent stuff inside of it.

Anyway, the way I wrote it, it still parses your old "INTRIP" stuff etc,
so as far as I know, it should happily read the old-style XML too. At
least it seemed to work with your xml file that already had the old-style
one (I haven't committed my divetrips, exactly because I didn't like the
new format).

It always saves in the new style, though.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-30 12:36:18 -07:00
Dirk Hohndel
946d9c7166 ENOTENOUGHCOFFEE
Third attempt to get this trivial memory leak fix right.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-30 09:12:53 -07:00
Dirk Hohndel
02bfd2d9ea Better fix for one of the memory leaks
The return value of subsurface_get_conf is a const void * - so we shouldn't
just assign it to a variable where we know it will be changed. Instead we
duplicate the string and free the original one. A little less efficient but
cleaner.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-30 09:01:15 -07:00
Dirk Hohndel
24c6197c10 Fix a number of obvious memory leaks
Just the result of cppcheck and valgrind...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-29 20:58:26 -07:00
Dirk Hohndel
12ca6112e5 Counting is hard
When updating the "You have usnaved change..." string I didn't pay
attention and missed the fact that we used it's hard coded length above to
allocate a large enough buffer.

Thanks you, Valgrind.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-29 20:17:08 -07:00
Dirk Hohndel
82abbf5904 Merge branch 'delmulti' of git://github.com/neolit123/subsurface 2012-09-29 19:29:21 -07:00
Lubomir I. Ivanov
45d6d6ac71 Keep the "Add/Edit Cylinder & Weight" dialogs on top
This is the same issue as 882cb159a4 (although now we
don't have "Import XML Files" within a dialog). It applies when
in the "Dive info" dialog.

There is some sort of a GTK bug on Ubuntu 12.04 with GTK 2.24.10 that
prevents us from using the gtk_window_set_accept_focus() and similar
API to make the window behind fully inactive.

The proposed portable solution is to completely disable the background
window (NOTE: unless its the main window), disabling child controls
(gtk_widget_set_sensitive) and making the top window "transient for" or
putting it on top (gtk_window_set_transient_for).

Still we do not want to hide the background window titlebar with
gtk_window_set_decorated(), which makes it still clickable.
Make this change to older code in gtk-gui.c as well.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2012-09-30 03:47:10 +03:00
Dirk Hohndel
a544d74044 Correctly handle merging dives that are part of a trip
If we have already created a dive_trip structure we need to also copy the link.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-29 16:18:19 -07:00
Lubomir I. Ivanov
cfb1baa030 Set a default size to the "Edit Trip Info" window
Debian and Ubuntu's distributed Gtk decide to make the window
tiny (completely hiding the Notes section). To prevent that we "put"
a default size of 400x300px to the window, which is proportionally OK
compared to the main window's default size.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-29 08:29:48 -07:00
Lubomir I. Ivanov
3e3e632e1f Clear the display widgets when deleting all dives in the list
After calling dive_list_update_dives() in delete_selected_dives_cb(),
if the selection length is zero, we can clear the display widgets
not to show information of a deleted dive.

[Dirk Hohndel: please watch your whitespace - you once again added a bunch
	       of empty lines that really didn't help the code...
	       I removed them]

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-29 08:27:03 -07:00
Martin Gysel
69aec317f0 close directory after reading entries
otherwise the filedescriptor keeps open which prevents a
smooth unmounting as long as subsurface is open

Signed-off-by: Martin Gysel <me@bearsh.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-29 08:19:27 -07:00
Dirk Hohndel
7f5ecb5bb7 Redo the delete dive code
The existing code (both my first single dive delete and then Lubomir's
multi dive delete code) had way too many issues and was just painfully
inefficient.

This new code takes a radically different approach and mostly ignores the
Gtk tree model (as that gets recreated after a delete, anyway) and instead
is linear time on the number of dives in the list. It does do its best to
maintain the existing selection and the expand state of tree model (the
latter isn't possible if we have switched to the list model).

Many thanks to "Lubomir I. Ivanov" <neolit123@gmail.com> for his work on
this - this commit actually contains a few lines out of one of the patches
that he wrote.

Reported-by: "Lubomir I. Ivanov" <neolit123@gmail.com>
Tested-by: "Lubomir I. Ivanov" <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-28 16:23:59 -07:00
Dirk Hohndel
bd3df859bc Restructure the Uemis native download buffer code
Running under Valgrind showed a couple of silly bugs.

Worse, intentionally running into various error scenarios showed that we
could get the buffer handling in the raw parsing code to break down - we
would fail to process the correctly downloaded files.

To make it easier to get this right I restructured the code to collect the
XML buffer in a different way - this works much better and has stood up
well under testing so far.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-27 00:29:31 -07:00
Dirk Hohndel
58ba24b84e Getting ready for the 2.0 release
Changing the version to 2.0-rc1

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-26 20:50:23 -07:00
Dirk Hohndel
49fbccd61a Much improved handling of out of memory errors in the Uemis downloader
Instead of trying to figure out in the GUI code whether to call the
downloader again, the logic was moved into the downloader itself. It now
attempts to deal cleverly with running out of space on the dive computer
filesystem - and in return is able to process the maximum number of dives
(instead of just ten or so at a time).

Even on partial reads before a failure we are able to collect the data
that was completely transferred and report those dives.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-26 20:39:51 -07:00