Commit graph

369 commits

Author SHA1 Message Date
Tomaz Canabrava
54128aa52f Added the code to remove a dive computer.
Added the code to remove a dive computer, plus a few fixes

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-07 15:25:29 -03:00
Dirk Hohndel
f3f7bf51fa Merge branch 'Qt'
After the 3.1 release it is time to shift the focus on the Qt effort - and
the best way to do this is to merge the changes in the Qt branch into
master.

Linus was extremely nice and did a merge for me. I decided to do my own
merge instead (which by accident actually based on a different version of
the Qt branch) and then used his merge to double check what I was doing.

I resolved a few things differently but overall what we did was very much
the same (and I say this with pride since Linus is a professional git
merger)

Here's his merge commit message:

    This is a rough and tumble merge of the Qt branch into 'master',
    trying to sort out the conflicts as best as I could.

    There were two major kinds of conflicts:

     - the Makefile changes, in particular the split of the single
       Makefile into Rules.mk and Configure.mk, along with the obvious Qt
       build changes themselves.

       Those changes conflicted with some of the updates done in mainline
       wrt "release" targets and some helper macros ($(NAME) etc).

       Resolved by largely taking the Qt branch versions, and then editing
       in the most obvious parts of the Makefile updates from mainline.

       NOTE! The script/get_version shell script was made to just fail
       silently on not finding a git repository, which avoided having to
       take some particularly ugly Makefile changes.

     - Various random updates in mainline to support things like dive tags.

       The conflicts were mainly to the gtk GUI parts, which obviously
       looked different afterwards.  I fixed things up to look like the
       newer code, but since the gtk files themselves are actually dead in
       the Qt branch, this is largely irrelevant.

       NOTE! This does *NOT* introduce the equivalent Qt functionality.
       The fields are there in the code now, but there's no Qt UI for the
       whole dive tag stuff etc.

    This seems to compile for me (although I have to force
    "QMAKE=qmake-qt4" on f19), and results in a Linux binary that seems to
    work, but it is otherwise largely untested.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-17 22:01:41 -07:00
Dirk Hohndel
8316564356 Fix yet another selection issue
If we manually deselect dives without changing Gtk's notion of what is
selected and then want to simply recreate the dive list, Gtk re-selects
the unselected dives in the process of clearing out the dive list. How
very strange.

Also, after making changes to the selection we need to make sure that we
update the stats.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-17 08:34:45 -07:00
Sergey Starosek
2742d59b36 Fix "Select tags" dialog behavior
* Apply filter only when OK button pressed
* Restore tags selection from dive mask when Cancel button pressed
* Fix selection logic when selected or all dives are filtered out (hide
  profile, tooltips, etc.)

Not sure whether call to repaint_dive() is required.

Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-17 08:34:45 -07:00
Tomaz Canabrava
30297ebd4b Correctly set the unselected dive.
The selected dive was being set to zero when the program
started, but zero is actually the first dive. There
were workarounds on the gtk code for that probably

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-05-16 15:42:20 -03:00
Dirk Hohndel
1ba901fed6 Initialize / reset selected_dive to -1
The value of 0 that we used is actually a valid value and could cause
confusion.

Suggested-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-16 09:10:11 -07:00
Sergey Starosek
b202b5a2ac "Enter" button activates default OK response.
Implemented for the following dialogs: Preferences,
Select Tags, Select Events, Renumber, Upload to divelogs.de

Not shure whether this is appropriare for Print and Planner
dialogs.

Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-16 08:38:58 -07:00
Dirk Hohndel
41a97bc1ae Consistently end the list of map providers with Yahoo streetmaps
The other map providers don't appear to work at all, regardless from where
I connect to the network.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-14 20:30:17 -04:00
Dirk Hohndel
ce06ec3d17 Fix typo in user visible string
Sadly that means "new translations are needed"

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-14 06:30:49 -04:00
Henrik Brautaset Aronsen
f5ef74202b Require libzip, xslt and osm-gps-map in all builds
Conditional inclusion of libzip, xslt and osm-gps-map just
makes testing more cumbersome, since testers might lack
Subsurface features without knowing.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-11 22:02:24 -07:00
Dirk Hohndel
8677721e85 Remove the majority of the Gtk related code
- rip all Gtk code from qt-gui.cpp
- don't compile Gtk specific files
- don't link against Gtk libraries
- don't compile modules we don't use at all (yet)
- use #if USE_GTK_UI on the remaining files to disable Gtk related parts
- disable the non-functional Cochran support while I'm at it

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-03 11:37:09 -07:00
Dirk Hohndel
d5af4e2ff9 Simplistic filtering by tags
This only allows for a logical "AND" - so only dives that all of the
selected tags are displayed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-21 17:53:24 -07:00
Dirk Hohndel
2aabcf398a Add Gtk dialog to select the dives tags for which dives are shown
This literally just creates the dialog and does not hook things up with
the dive list.

The idea is to abstract out the idea behind the invalid dives to allow the
user to select / deselect all kinds of dives and then do statistics on
the selected ones.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-21 17:12:35 -07:00
Dirk Hohndel
0a9ad49f0a Fix selection handling for invalid dives
This is the downside of having to track our own selection state. We now
have a class of dives that potentially isn't known to Gtk as we aren't
adding them to the TreeView. So we need to make sure that their selection
state is consistent by deselecting them (either when they are marked as
invalid OR when we change preferences to no longer show invalid dives).

And because Gtk sends out another set of selection events when clearing
the TreeView (not sure why), we also need to make sure that their
selection state isn't reset to selected by mistake when the divelist is
recreated.

A bit of a pain, but it seems to work now and be consistent.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-10 10:04:50 -07:00
Dirk Hohndel
83a313f1ee Correctly conditionalize compilation for menu structure
Only call upload_all_dives_divelogs_cb() if we have both libzip and xslt.

Reported-by: Jozef Ivanecký (dodo.sk@gmail.com)
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-09 16:01:17 -07:00
Henrik Brautaset Aronsen
5f03a6f631 Add menu entry for divelogs.de upload
The menu entry for upload to divelogs.de was missing. Also renamed
the divelogs context menu entry to something less generic.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-09 13:27:36 -07:00
Ďoďo
ed3f67bc33 Add dive tags and support invalid dives
This started out as a way to keep dives in the dive list but being able to
mark them as 'invalid' so they wouldn't be visible (with an option to
disable that feature).

Now it supports an (at this point, fixed) set of tags that can be assigned
to a dive with 'invalid' being just one of them (but one that is special
as it gets some additional support for hiding such dive and marking dives
as (in)valid from the divelist).

[Dirk Hohndel: merged with the latest code and minor changes for coding
	       style and consistency. Ensure divelist is marked as
	       modified when changing 'invalid' tag]

Signed-Off-By: Jozef Ivanecký (dodo.sk@gmail.com)
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-09 10:31:36 -07:00
Dirk Hohndel
a70a889872 Fix some of the gcc-4.8 warnings
Most of the warnings are IMHO false positives:
e.g.: an enum variable is initialized in a switch statement that has a case for
      each possible enum value - yet gcc 4.8 warns that it could be used
      uninitialized;
or:   two variables are initialized together in the code - second one of them
      is previously initialized to -1 at declaration time, both are initialized
      in an if (second one == -1) clause - so they are guaranteed to both be
      initialized...
I did not "fix" those as the code is actually correct.

But there are three spots where it catches things that could indeed go wrong
(with odd input data in one of them).

This commit also adds a check to only call g_type_init() for older versions of
glib as in newer ones it is deprecated.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-07 20:31:49 -07:00
Alberto Mardegan
68119c5b54 Move set_filename() calls outside of parse_file()
Remove the boolean parameter from parse_file; the code is more readable
by having an explicit call to set_filename() where necessary, rather
than a boolean parameter.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Alberto Mardegan <mardy@users.sourceforge.net>
2013-04-07 17:37:09 +02: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
Lubomir I. Ivanov
2a6fded3b7 gtk-gui.c: Some small whitespace indentation fixes
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-26 19:26:55 -07:00
Lubomir I. Ivanov
c2520125d1 Store the main window maximized state in the configuration
In save_window_geometry() use gdk_window_get_state() to retrieve
the window maximized state and store it in the user configuration.
Then in restore_window_geometry() restore the maximized state with
gtk_window_maximize(), if needed.

To achieve good results we also need to override "window-state-event"
for the main window and define an extra couple of configuration parameters:
"vpane_position_maximized" and "hpane_position_maximized".
Then store two different pane states for maximized and restored window each
time the user makes a switch.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-26 19:26:43 -07:00
Miika Turkia
12d5ab4ce3 Export dives to UDDF file
This patch implements exporting dives from Subsurface to UDDF format.
Events and cylinder info are the most remarkable things still missing
from the export.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-24 06:37:56 -07:00
Dirk Hohndel
487fe8784c Make slider labels consistent in print dialog
To make this easier I created a new helper function create_label that
takes printf style arguments. I assumed this would be usable in many
places but ended up finding just one other obvious use for it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-19 14:09:28 -07:00
Dirk Hohndel
14b6551a6a Manually remove events in the profile context menu
As logical extension of the ability to add bookmarks and gas changes this
adds the ability to remove (any arbitrary) event that happens at the mouse
position (specifically, that is within +/- six (scaled) pixels around the
x-position (time) of the mouse). That's the same width that the triangle
marker occupies which was moved to be centered around the event time in
commit 5752e9742e86 ("Finetune event triangle position to have the top
point at the event time").

Fixes #60

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-18 19:46:17 -07:00
Robert C. Helling
1e37fa99ed Manually add bookmarks in the profile context menu
Use the infrastructure created for manually adding gas change events to
also be able to add bookmarks.

[Dirk Hohndel: This combines two commits for clarity. I also cleaned up
               the indentation and changed the code to no longer print the
               exact same text twice.]

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-18 09:59:20 -07:00
Dirk Hohndel
8a5792d473 Manually add gas changes to a dive
Create a little widget that lists all the gases / tanks we know about and
allow the user to pick one of them.

Turns out that add_event only added events at the end of the list - but we
treat that list as chronologically sorted. So I fixed that little
mis-feature as well.

This does raise the question whether we need the inverse operation
(removing a gas change). And if there are other things that we should be
able to manually edit, now that we have the infrastructure for this neat
little context menu...

See #60 -- this doesn't address all of the issues mentioned there, but at
least deals with the 'headline' of the feature request...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-17 20:04:25 -07:00
Dirk Hohndel
bfa37c3cac First step towards a context menu in the profile view
This is completely bogus as all it does is print out the corresponding
time for the spot we right-clicked on the profile. But that at least shows
that the infrastructure is working as intended...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-17 16:15:36 -07:00
Lubomir I. Ivanov
6dd31a6cc6 Bring back support for GTK versions pre 2.24
The introduction of GtkComboBoxText usage for selecting a map provider,
removed support for older versions of GTK on distros like Debian 6.0.4.

Parent class (GtkComboBox) methods have to be used instead, around
more pre-processor branching.

This patch also fixes a small memory leak when retrieving text from said
combo box.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-09 10:28:54 -08:00
Amit Chaudhuri
29be221bd8 Reorganise view menus and file import.
Move the view submenu to a top level location.

Alter the wording of File|Import to drop XML qualifier; we import more
formats than this.

Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-08 08:48:52 -08:00
Miika Turkia
6d181e05f8 Add .jlb and .udcf as supported file types
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-05 09:55:47 -08:00
Miika Turkia
a94f7807f8 Limited support for Suunto DM4 import
Basic functionality is implemented but at least support for multiple
cylinders is missing. Event/alarm support is only partial.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-04 22:08:03 -08:00
Robert C. Helling
c13a10986e Improve pane position saving code
We should test for being in PANE_THREE mode in save_pane_position() and
replace the if()'s testing against window geometry. This eliminates some
code duplication and, more importantly, save_pane_position() is also
called from save_window_geometry() whose calling pattern is not obvious.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-04 00:26:32 -08:00
Dirk Hohndel
d8811e2e40 Only store pane positions if we currently display "View Three"
We tried to detect this without needing a global variable but that clearly
was too dependent on decorations that the window manager might add. This
code works reliably.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-03 21:07:09 -08: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
Robert C. Helling
9fcb28a6f5 Fix pane position bug
Argh. Maxint is not at the bottom or at the right. We have to check
against the size of the window to determine we are not saving a maximized
position.  Here is a fix.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-03 11:56:51 -08:00
Sergey Starosek
0e7f0cc1ed Fix ESC key handling in Save dialog.
Closing unsaved dive raises Save dialog with Yes/No/Cancel buttons.
Pressing ESC dismisses dialog without saving changes.

This commit adds GTK_RESPONSE_DELETE_EVENT response code check in order
to fix that behavior.

Reported-by: Jan Schubert <Jan.Schubert@GMX.li>
Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-03 10:45:11 -08:00
Robert C. Helling
0e3c6f7517 Save window pane positions
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-02 09:10:34 -08:00
Cristian Ionescu-Idbohrn
e89c2fd656 Another unused variable warning when building without libosmgpsmap.
gtk-gui.c: In function 'preferences_dialog':
gtk-gui.c:670:30: warning: unused variable 'map_provider' [-Wunused-variable]

Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-02 08:42:48 -08:00
Dirk Hohndel
51d2088021 Merge branch 'map-providers' 2013-03-01 23:11:41 -08:00
Dirk Hohndel
d1c394e51f Make the map provider choice a preference
Not all of the providers seem to work for me (Yahoo Satellite doesn't
appear to give me any data), but for now I'll leave most of them in.
We can later decide to offer only some of them.

It might be more fun to be able to pick the provider directly from the map
widget. But for now I kept this in the preferences which seemed to be a
good place for it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-01 23:09:12 -08:00
Robert C. Helling
f7d373bae6 Remember window pane positions
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-01 16:22:29 -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
Lubomir I. Ivanov
a31af7419f Added back support for versions of GTK pre 2.24
Some functions in combo_box_with_model_and_entry() are only
available to GTK 2.24 and newer. This patch adds only one #if branch,
but probably adds support to a number of outdated distributions,
such as Debian 6.0.4 and Ubuntu 10.04.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-27 15:04:06 -08:00
Dirk Hohndel
4c04fe5316 Add all dive computers to the device_info_list
Calling set_dc_nickname() only added a new entry if there was a conflict
with an existing one - which works fine if we are reading a file saved by
Subsurface, as there the device_info_list is populated at parse time, but
fails for data imported from other sources.

Fixes #74

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-27 13:55:15 -08:00
Cristian Ionescu-Idbohrn
42fa5a6368 Generate/update a version.h header file.
This is dedicated to Lubomir ;)

Should work (tm).  Not sure though if you want target
'gen_version_file' as a pre-requisite to $(NAME) or some other target.

[Dirk Hohndel: minor adjustments to make it work with gtk-gui.c]

Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-26 10:47:04 -08:00
Dirk Hohndel
f6673ab359 Add link to user manual to Help menu
Yes, we could try and bundle the user manual with the executables and open
a local copy of it - but this seemed much easier and safer to do. It does,
of course, add another string...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-25 17:31:02 -08:00
Lubomir I. Ivanov
aa5f1f0ce2 Show a "No Events" label when there are no events in the filter dialog
Uses profile.c:evn_foreach() to retrieve the number of events, which
if zero, no table is added in the dialog and the label is added instead.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-25 13:56:22 -08:00
Lubomir I. Ivanov
cd5c61e102 Don't use gtk_show_about_dialog() for the about dialog
There is a bug in GTK 2.2x where the links in the about dialog
(and URI's in general) do not work on Windows. To solve that
we add the OS specific method subsurface_launch_for_uri().
But to dispatch URI requests from the about dialog we need to
set a hook either with gtk_about_dialog_set_url_hook() (which is
deprecated from 2.24) or using signals like "activate-link".

One problem with the "activate-link" signal thought is that
we need to have a reference of an about dialog to pass to
g_signal_connect(). So instead of using gtk_show_about_dialog()
let's manage a dialog ourself with gtk_about_dialog_new(),
gtk_dialog_run(), gtk_widget_destroy().

Other changes:
- for GTK _bellow_ (but not including) 2.24 use
gtk_about_dialog_set_url_hook()
- use g_object_set() which is a convenient replacement for
the varargs list in gtk_show_about_dialog() (also makes the diff smaller).

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-25 11:08:47 -08:00