No need for right-clicks. It's inconvenient on lots of laptops etc, so
allow just using the Dive menu as an alternative.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This does mean that you have to build subsurface against a new version
of libdivecomputer, and that version is likely going to have various
slightly incompatible changes. But the new interfaces allow for easily
adding new supported dive computers without subsurface having to be
updated for each new vendor and model, so some slight pain is definitely
worth it this time.
I'm not even going to try to have some backwards-compatible version
here, the libdivecomputer interface changes are so extensive. Native
enumeration of devices is just the smallest part of it: the constants
and types that libdivecomputer uses now have much nicer names that all
start with DC_ or dc_, so you don't get the kinds of name clashes we had
with "gasmix_t" etc.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
It is really annoying to have to type the device name each time you need
to import a dive from your computer, if you are not using the default
device name. This will save the device name in the configuration file and
matches the logic currently used to save the dive computer name in the
configuration file.
Signed-off-by: Terrance Stanfield <t@hollowcranium.com>
Instead of using printf() to print the string updates ("Parsing sample
data" etc), introduce a function to show those strings in the graphical
progress bar itself.
Subsurface hasn't been a text-mode application in a long time ;)
This partially fixes the second todo entry from commit b0ba22a068
("Show dive import error messages in the import dialog") and generally
makes for a more helpful import - at least for the largely error-free
cases.
Sadly, the messages that really come from within libdivecomputer itself
(like "suunto_vyper2.c:193: Failed to receive the answer.") when things
go really wrong are not caught. libdivecomputer does have a notion of a
logfile (set with "message_set_logfile()"), but that ends up being
really inconvenient.
Maybe we could use some pipe setup or something. Oh well.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This was a todo item in commit b0ba22a068 ("Show dive import error
messages in the import dialog") which made the import dialog able to
retry the import on errors.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Sure, you can import a file too, but it really makes more sense to have
the actions related to importing new logs under "Log", I think. I don't
think of it as a file operation.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
.. not in the main window. And leave the import dialog open, so that
you can either try doing it again, or cancel. This makes it much easier
to re-try a failed dive import, and actually makes the failure more
obvious too.
Todo:
- make the "Ok" button change to "Retry" when an error happens
- try to see if we can catch the actual status update messages from
libdivecomputer and show them too in the import dialog. Right now
they are printed out to stderr by the library.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Always having to re-select the same dive computer got really annoying
when I had trouble importing the dives. Let's not force the user to do
that, since we could just remember the last dive computer used, and
default to that one.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
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>
Pull weight management from Dirk Hohndel:
"This is the fifth or sixth version of this code, I'm begining to lose
track. I still struggle with the balance between code duplication and
unnecessary indirectness and complexity. Maybe I'm just not finding
the right level of abstraction. Maybe I'm just trying too hard.
The code here is reasonably well tested. Works for me :-)
It can import DivingLog xml files with weight systems and correctly
parses those. It obviously can read and write weight systems in its
own file format. It adds a KG/lbs unit default (and correctly stores
that).
The thing I still worry about is the code in equipment.c. You'll see
that I tried to abstract things in a way that weight systems and
cylinders share quite a bit of code - but there's more very similar
code that isn't shared as my attempts to do so turned into ugly and
hard to read code. It always felt like trying to write C++ in C..."
* 'weight' of git://subsurface.hohndel.org/subsurface:
Add weight system tracking
Fix up some trivial conflicts due to various renaming of globals and
simplification in function interfaces.
- supports multiple weight systems per dive
- supports multiple weight system types
- supports import of weight as tracked by DivingLog
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If at least 2 dives are selected, show statistics of these dives on
Overall Stats. Otherwise, show the statistics of all dives. Temperature
is also added to the shown statistics.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Minor change to avoid adding statistics.h (moved the global variable and
external function declaration to display-gtk.h).
Another minor change to the text displayed for the "Stats" notebook page.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We're going to eventually import non-xml files too, so let's begin
splitting the logic up.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
We have local variables or function arguments with the same names as
function static variables (or in one case, function arguments).
While all the current code was correct, it could potentially cause
confusion when chasing bugs or reviewing patches. This should make things
clearer.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
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>
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>
Right now the options are "Save" and "Cancel". I wrote that code and it
always bugged me - "Cancel" could mean that I want to cancel the the whole
operation, i.e. that I don't want to quit after all. Showing "Save" and
"No" seems much more logical.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
They were never intended to be sortable, but using common code with the
dive list picked up that "sort by index" thing by mistake.
If we really want to be able to sort cylinders by O2 percentage (which
really doesn't seem to make much sense, considering that you usually
have just one or two cylinders) we will need to also handle the case of
editing the (differently sorted) cylinder table. Which we don't do now.
Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Suggested by Henrik Aronsen, and seems much more natural. Especially
with lots of keyboards having function keys oddly mapped.
Suggested-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Currently just tied to F1-F4 (for divelist, profile, info, and "all
three" respectively), which is just crazy. But using "ctrl-P" for
"Profile" isn't sane either, that's the standard printer keyboard
shortcut. So what would be good keyboard shortcuts for these things?
I also wonder how I can get gtk to shut up about the fact that a pane
becomes too small for the contents of that pane? We very much want to do
that, and it's very intentional. Gtk does the right thing apart from
the whining (and apart from the visually ugly part of a widget that
doesn't fit, but making it pretty doesn't really seem possible).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
The profile colors were defined all over the place, so I put them all in one spot. I'm unsure if this is the best solution to that problem, but I guess it's a step in the right direction.
Signed-Off-By: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
It doesn't make sense with the new three-pane layout, and I don't think
we're reviving it.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
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>
I'm not happy with it, but it looks good and works better than the
alternatives I've looked at so far.
So why not happy? It's not configurable, and gtk really doesn't do a
great job with the case of notebook widgets that are shrunk to be
smaller than the contents (the cut-off gets ugly, and is outside the
notebook page!)
But committing as a way to keep track of this, and let Dirk use it.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Linus noted an odd "CRITICAL" warning when ripping off a page of the
notebook and then dropping it within the same notebook.
Turns out we need to simply accept a drop on ourselves and gtk does the
rest correctly.
I also fixed the fact that we incorrectly declared the callback as 'void'.
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
* 'add-info-stats-page' of git://github.com/dirkhh/subsurface:
Add Info & Stats page to the notebook
Even more places with pressure and volume conversions
Further cleanup of pressure and volume conversions
Use unit functions to get column headers, add unit function for pressure
More consistency improvements
Add new helper function to get temperature and unit
This provides the relevant information for the currently selected dive
plus a bunch of statistics over all dives in the dive_table.
The visual design has lots of room for improvement
- right now the different fields change size
- it might be nice to have a more modern look for the entries
- the O2/He field is odd - for most divers the He value will
always be 0, so maybe we should only show He if there's at least one
dive that uses He? Also, we simply do a comma separated list of gases
for all the tanks used
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
That's what gtk_init() does with gtk-specific arguments. IOW, if you do
things like
subsurface --g-fatal-warnings dives.xml
to get a real abort on gtk warnings, gtk_init needs to be able to
actually change argc/argv.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Provides compatibility with winxp-32bit in gtk-gui.c,
since RegGetValue is only available on the 64bit build of the OS.
Fixed whitespace issues, fixed obvious typo (this patch clearly wasn't
even compile tested)
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
With this we are able to include both a separate .ico file that the
program can load at runtime and a .res file (that is created from the .rc
file, both in the packaging/windows directory) that is linked into the
executable and makes the Windows Explorer show the correct icon for
subsurface.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
No change at all to non-Windows builds.
Everything seems to work with preferences - but only tested on Win7
Remaining issue: displaying an icon (or the logo in the About dialog)
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
So far this just removes the gconf code - so no preferences for Windows.
It also removes the unsused gconf references in main.c
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Create a table with four rows of toggle events and resize it as needed.
This may not create the most beautiful layout, but it works.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Right now they are displayed in one hbox which doesn't work if you have
many events - but the code itself works and correctly toggles the events
on and off.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Not being careful enough doing copy and paste and then making manual
changes... this inconsistency caused subsurface to always store the
opposite of what you wanted in the preferences for SAC and O2%.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Turns out I used the wrong function to keep the size of notebook pages
that were ripped off. Using gtk_widget_set_size_request on the new
notebook creates a hard minimum size for this window.
Instead we should use gtk_window_set_default_size on the new window that
is the parent of the notebook. This has the desired effect of creating the
new window with the same size as the one the page was ripped off from -
without making that the minimum size for this window.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
From a usecase point of view - if we call with multiple file names then
most likely it's
subsurface MyDives.xml new_dive1.xml new_dive2.xml
and therefore the existing "database" is the first filename, not the last
one (as the current implementation assumes).
Frankly, this is a bit arbitrary - but this one seems to make more sense.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We used to set a fixed size instead of just copying the size that the
existing notebook has - which didn't really feel right when resizing and
then ripping of a page.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I'm trying to get subsurface to get closer to becoming a "regular desktop
application"; so far this is based on the recommendations and guidelines
on OpenSUSE and Fedora.
The icon is now named subsurface.svg and make install installs it in the
correct location. At runtime subsurface first checks if an icon is
installed and if it is it uses that - otherwise it falls back to the old
code that tries to read the svg file from the current directory.
We also install a subsurface.desktop file
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Remove casts from/to void*. They are unneeded in C, can hide problems
in the future, and are far too C++ish. Furthermore, they were
inconsistent with the rest of the code and even with regards to
themselves (at least in terms of whether or not to have space after the
cast).
In this case, we temporarily lose const specifiers in libdivecomputer.c
due to the unneeded cast, so it seems better to avoid the cast at all,
so you get warned about a const->non-const cast if you ever change it to
do something like this.
The casts in gtk-gui.c are just useless semantically, although they
might be useful as a hint to the reader that the void pointers are char
arrays.
Signed-off-by: Julian Andres Klode <jak@jak-linux.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>