summaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2012-10-07Bump version to 2.0.1v2.0.1Gravatar Dirk Hohndel
That crash is far too easy to hit for people just trying out subsurface. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-07Fix potential crash when attempting to free default fontGravatar Dirk Hohndel
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-06Turn menu and button images on regardless of OS settings.v2.0Gravatar Dirk Hohndel
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-05Added unicode support for the configuration entries on WindowsGravatar Lubomir I. Ivanov
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-05Fixed some memory leaks related to string configuration entriesGravatar Lubomir I. Ivanov
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-04Provide a method to use unicode command line arguments on WindowsGravatar Lubomir I. Ivanov
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-04Force subsurface.sh on Mac to use bashGravatar Dirk Hohndel
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-04Add readme file for MacOSX packageGravatar Henrik Brautaset Aronsen
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-04Use GLib's g_fopen() and g_open() when working with filesGravatar Lubomir I. Ivanov
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-02More fixes to MacOS bundle file and READMEGravatar Dirk Hohndel
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-02Fix typos for MacOSX packaging scriptsGravatar Henrik Brautaset Aronsen
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-02Rename Import XML File menu entryGravatar Henrik Brautaset Aronsen
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-02Fixed potential, rare corruption of unicode charactersGravatar Lubomir I. Ivanov
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-02fixup_dive(): move the add_* calls before a possible returnGravatar Lubomir I. Ivanov
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-01Fix memory leaks related to dive_trip->locationGravatar Lubomir I. Ivanov
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-01Destroy the divelist (tree) before calling gtk_main_quit()Gravatar Lubomir I. Ivanov
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-01Fixed memory leaks specific to divelist.cGravatar Lubomir I. Ivanov
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-01Add packaging files for MacOSGravatar Dirk Hohndel
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-01Fixed some small memory leaksGravatar Lubomir I. Ivanov
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-09-30New XML format for saving divesGravatar Linus Torvalds
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-30ENOTENOUGHCOFFEEGravatar Dirk Hohndel
Third attempt to get this trivial memory leak fix right. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-30Better fix for one of the memory leaksGravatar Dirk Hohndel
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-29Fix a number of obvious memory leaksGravatar Dirk Hohndel
Just the result of cppcheck and valgrind... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-29Counting is hardGravatar Dirk Hohndel
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-29Merge branch 'delmulti' of git://github.com/neolit123/subsurfaceGravatar Dirk Hohndel
2012-09-30Keep the "Add/Edit Cylinder & Weight" dialogs on topGravatar Lubomir I. Ivanov
This is the same issue as 882cb159a46d5d9dbd0 (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-29Correctly handle merging dives that are part of a tripGravatar Dirk Hohndel
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-29Set a default size to the "Edit Trip Info" windowGravatar Lubomir I. Ivanov
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-29Clear the display widgets when deleting all dives in the listGravatar Lubomir I. Ivanov
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-29close directory after reading entriesGravatar Martin Gysel
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-28Redo the delete dive codeGravatar Dirk Hohndel
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-27Restructure the Uemis native download buffer codeGravatar Dirk Hohndel
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-26Getting ready for the 2.0 releaseGravatar Dirk Hohndel
Changing the version to 2.0-rc1 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-26Much improved handling of out of memory errors in the Uemis downloaderGravatar Dirk Hohndel
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-26Merge branch 'uemis-native'Gravatar Dirk Hohndel
This brings in the code to download dive information directly from a Uemis Zurich dive computer. The implementation contains a major hack that hooks the uemis code into the same data structures used to setup libdivecomputer. This gives the best result for the user, but is not something that I like as a long term solution as it relies on internal libdivecomputer data structures.
2012-09-26Fix stupid packing error on WindowsGravatar Dirk Hohndel
I guess no one has ever tried to import Uemis dive data under Windows. The glib-2 libraries for Windows (at least the ones that are part of the mingw package, but my guess is this is true for all of them), force the whole program to be compiled with Windows packing rules for structures. That broke the structure we use for decoding Uemis binary data. This commit changes the data structure to no longer use unaligned 16bit values but instead two 8bit values and assemble them in the actual code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-26First implementation of native Uemis downloaderGravatar Dirk Hohndel
This includes one major hack that uses a private data structure from libdivecomputer to allow us to show the Uemis Zurich as one computer the user can import from. Once the user has chosen the Uemis we don't use libdivecomputer but our own downloader. Just like in the libdicecomputer case this runs in its own thread and updates the import dialog with progress information. The code also keeps track of the last dive that has been downloaded from a Uemis computer so we only import new dives on subsequent downloads. And since the Uemis Zurich gives us its device id, we make this a "per divecomputer" property for people who dive with multiple Uemis Zurich computers. This uses the debugfile infrastructure to allow easily collecting debugging output - especially on Windows where by default console output is lost. Known limitations: when the Uemis runs out of space (it uses its filesystem for communication with the host computer) we have no graceful way to reset things. This is why the code doesn't try to download ALL dives on the computer but instead download them in increments of ten dives. This clearly needs to be addressed once I understand how to reset the device. The Cancel button of the import dialog isn't correctly hooked up, yet. I still need to figure out how to gracefully shut down a download without potentially hanging the device. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-26Add the ability to create a log file for debugging outputGravatar Dirk Hohndel
Especially when asking non-developers for help debugging a problem it can be extremely useful to have debugging output not go to the console but to a log file instead. This just adds the infrastructure to create (and close) such a file. No changes to the debug output are made. All this is of course #ifdef'ed out. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-26Merge branch 'delmulti' of github.com:neolit123/subsurfaceGravatar Dirk Hohndel
This brings in Lubomir's latest version of the code. This allows deleting multiple selected dives from the divelist. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-24Update cylinder info properlyGravatar Linus Torvalds
The "cylinders_equal()/copy_cylinders()" functions were buggered, and only checked (and copied) the cylinder type. That was on purpose, since you do want to be able to change the type of a cylinder without changing the gasmix of the cylinder. HOWEVER, the reverse is also true: you may want to change the gasmix of a cylinder without changing the type. So it's not that the type of the cylinder is special - it's that the type and the gasmix should be considered separately. Do that properly for the equipment editing case. Reported-by: Ďoďo <dodo.sk@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-09-24Update the trip's "when" flag after deleting a dive from itGravatar Lubomir I. Ivanov
Both gtk_tree_selection_selected_foreach() and gtk_tree_selection_get_selected_rows() are problematic. gtk_tree_selection_get_selected_rows is not compatible with older GTK, while gtk_tree_selection_selected_foreach() should not be used to modify the tree. A workaround to is allocate memory and store what is returned from the gtk_tree_selection_selected_foreach() callback function as a GtkTreeIter array. Once done iterate trought the array and pass the values to delete_single_dive(). A bit excesive, but it is not certain how safe is modifying the tree while in the "_foreach" loop, even if it only shows a warning. On the other hand the GTK source shows gtk_tree_selection_get_selected_rows() to be a rather complicated and slow method. Inside delete_single_dive(), once a dive is no longer part of "dive_table" and if the dive was part of a trip, remove the dive from the tree (gtk_tree_store_remove()) and call update_trip_timestamp(). The struct type "tree_selected_st" and tree_selected_foreach() are reusable. Reported-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2012-09-23Prevent a warning when showing the "About" dialogGravatar Lubomir I. Ivanov
gtk-gui.c:about_dialog(): Before assigning a pixel buffer to "logo" check if "image" has a GTK_IMAGE_PIXBUF storage type. Prevents the following message if the icon file is missing: Gtk-CRITICAL **: gtk_image_get_pixbuf: assertion The message that the file is missing is still shown. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2012-09-23Use the name "Subsurface" in the "About" dialogGravatar Lubomir I. Ivanov
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2012-09-23Make sure memory for default_dive_computer_device is allocatedGravatar Lubomir I. Ivanov
When calling gtk-gui.c:set_default_dive_computer_device(), first free memory at default_dive_computer_device and then use strdup(). This fixed a case, where after selecting a device for the first time in the "Download" dialog, then pressing "OK" followed by "Cancel" (after a device error) the device text is garbled the next time the dialog is opened. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2012-09-23Added the functionality to delete selected (multiple) divesGravatar Lubomir I. Ivanov
Moved portion of the code from delete_dive_cb() to a function called delete_single_dive(), that directly accepts a GtkTreeIter pointer. Added the function delete_selected_dives_cb(), which is called when calling "Delete dives" from the combo box for the selected dives. The above function iterates trought the selection calling delete_selected_foreach(), which on its own calls delete_single_dive(). The "for-each" API in this case looks much prettier C code wise, however we do potentially create an extra jump and also do not have anything but the redirection: delete_selected_foreach() -> delete_single_dive() Probably slighly slower than using gtk_tree_selection_get_selected_rows(), performance wise, but less C code. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2012-09-22Added different delete label when right clicking multiple drivesGravatar Lubomir I. Ivanov
When clicking multiple dives in the list, check if more than one are selected and if so show the text "Delete dives". Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2012-09-21Fix missing save of (almost empty) cylinder informationGravatar Linus Torvalds
If we have no explicit cylinder info at all (it's normal air, no size or working pressure information, and no beginning/end pressure information), we don't save the cylinders in question because that would be redundant. Such non-saved cylinders may still show up in the equipment list because there may be implicit mention of them elsewhere, notably due to sample data, so not saving them is the right thing to do - there is nothing to save. However, we missed one case: if there were other cylinders that *did* have explicit information in it following such an uninteresting cylinder, we do need to save the cylinder information for the useless case - if only in order to be able to save the non-useless information for subsequent cylinders. This patch does that. Now, if you had an air-filled cylinder with no information as your first cylinder, and a 51% nitrox as your second one, it will save that information as <cylinder /> <cylinder o2='51.0%' /> rather than dropping the cylinder information entirely. This bug has been there for a long time, and was hidden by the fact that normally you'd fill in cylinder descriptions etc after importing new dives. It also used to be that we saved the cylinder beginning/end pressure even if that was generated from the sample data, so if you imported from a air-integrated computer and had samples for that cylinder, we used to save it even though it was technically redundant. We stopped saving redundant air sample information in commit 0089dd8819b7 ("Don't save cylinder start/end pressures unless set by hand"). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Removed start and end in save_cylinder_info(). These two variables are no longer used. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-21Activate the new separate "Import XML File" functionalityGravatar Lubomir I. Ivanov
Renamed the function pick_import_files() to import_files() and added a declaration in "display-gtk.h". The declaration is "extern" for consistency with download_dialog(). Since the new dialog is a real child off "main_window", we no longer need some of the calls to gtk_widget_set_sensitive(), gtk_window_set_decorated() to disable the parent, which previously was the old "Import" combined dialog. Once the file list is retrieved, attempt to import each file and update the list via report_dives(). Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Minor changes to file select box title Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-21Remove the XML file selection from the DC download dialogGravatar Lubomir I. Ivanov
Renamed "import_dialog" to "download_dialog" and also focused the download dialog strictly on dive computer functionality. Removed the file button and "filenames" checks from "download_dialog". Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2012-09-21Separate the "Import" menu entry into two menu entries in "File" and "Log"Gravatar Lubomir I. Ivanov
New entries with icons and shortcut keys in the menus. "Import XML File" is now using CTRL + I. Reserve CTRL + E for "Export XML File" if possible. "Download From Dive Computer" is using CTRL + D and a GTK_STOCK_GO_DOWN icon. Added separator below this entry in the "Log" menu. Note: menu entry callbacks are NULL at this stage. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>