- 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>
Surprisingly straight forward, just a couple of places where we really mix
significant logic with UI code (for example setting the window title).
I had to move amount_selected from display-gtk.h to display.h - I guess
the number of dives that are selected is UI independent. But I wonder if
we still will track this as a global variable in a Qt UI (since the Gtk
selection logic is the main reason this existed in the first place).
Added a new info.h files for the necessary declarations.
This should make no difference to functionality.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
dac29e7bc4 introduced changes to how the GPS coordinate string
is parsed; we now prefer to parse decimal numbers using the '.'
character.
This patch makes modifications to info.c:print_gps_coordinates(),
where we are still using a locale dependent method for converting
a double to string - snprintf(). Instead, we attempt to use GLib's
g_ascii_formatd(), and store the resulted strings into two
buffers named 'dbuf_lat' and 'dbuf_lon'. We then pass the buffers
to the final snprintf() formatting with '%s'.
Reported-and-tested-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Testing the Planner in Subsurface on a Windows XP SP3 installation,
shows corrupted UTF-8 strings in the case of Cyrillic locales, but
possibly others as well. Instead limited to the Planner, this affects
the entire application.
After some examination it appears that <ctype>'s isspace() in MSVC
on the tested version of Windows is broken for some UTF-8 characters,
after enabling the user locale using: setlocale(LC_ALL, "");
For example, characters such as the Cyrillic capital "BE" are defined as:
0xD091, where isspace() for the first byte returns 0x08, which is the
bytemask for C1_SPACE and the character is treated as space.
After a byte is treated as space, it is usually discarded from a UTF-8
character/string, where if only one byte left, corrupting the entire
string.
In Subsurface, usages of string trimming are present in multiple
locations, so to make this work try to use GLib's g_ascii_isspace(),
which is a locale agnostic version of isspace().
Affected versions of Windows could be everything up to XP SP3,
but not apparently Vista.
Reported-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
With this change resizing the dive edit dialog once again has its content
resize as well. So now we have the best of both worlds: if the content
grows we add scroll bars (so things stay usable on small screens), yet
when we resize the window, the notes area gets nice and big (which is
great on big screens).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
This sould give the notes text box around 8 lines of text.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch puts the contents of the dive edit dialog inside
a scroll container, with a minimal size equal to the default dialog
size when no equipment is added. If more tanks and weights entries
are added, a scrollbar will appear on the right and the dialog
will become scrollable.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This change makes it possible to edit date and time of a dive from the
normal dive edit dialog (it turns the label at the top of the dialog into
a button and allows the user to change the time from there - this seems
much more obvious than the 'right-click in the divelist' approach).
Additionally, if the dive has only one divecomputer and no samples (which
likely means that the dive was manually entered in Subsurface or imported
from another divelog where it was manually entered) then we allow editing
of duration, max depth and avg depth as well.
This fixes#75 (well, with the exception of water temperature.... we
don't allow editing of that at all... I guess that should become a new
trac item...)
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We had a report that on small screen systems like netbooks with a vertical
screen resolution of only 600 pixels Subsurface has usability issues, as
the dive editing dialog is taller than the screen.
While on some OSs the dialog can at least be moved around so the user can
fill it out and click OK or Cancel, on others (Windows XP) that does not
appear to be the case.
This small change simply takes the equipment part of this dialog and
positions it next to the dive info part instead of below it. This appears
to solve the immediate issue - but by adding the maximum number of tanks
and weight systems the dialog can still grow beyond 600 pixels vertically,
so we may have to add a scroll widget in here as well.
But for now this should be a nice improvement (and I find it reasonably
pleasing on a large display as well).
Fixes#67
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This reverts commit af9ba96da4.
I had applied this to directory with work-in-progress code that was now
mixed up with Eduardo's translation work. I'll re-apply just his
translation instead.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Most of the translated phrases have more characters than in english. But I
verified the Subsurface user interface, and there are no strange side effects.
I had just a doubt about "trip" translation. I used portuguese word
equivalent to "expedition". Some of the diving related words we don't
translate. Even "buddy" is the word used on local diving boats!
Signed-off-by: Eduardo Ramalho <eduardo.ramalho@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
So far we only allowed setting the max depth.
This changes the layout of the entry widget and makes our helper function
create_date_time_widget return the hbox in which it positions the time
entry. I plan to reuse this later when allowing to edit the duration as
well as the start date and time under certain circumstances.
This is a small part of a feature request; see #75
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
For the "Edit dive date/time" dialog, (time->tm_min / 5)*5)
with integers can lose precision due to truncation, showing for example
a value of 55, where 59 is the actual previsouly stored value.
Reported-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add a new method in info.c called info_widget_destroy(), which
clears all GtkListStore instances. The method is exposed via
display-gtk.h and called from gtk-gui.c:on_destroy().
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We can't use gps_changed() in the gps_map_callback function, because that
will actually change the GPS data in the dive being edited, which in turn
will then cause us to later (when we *really* want to change it) not match
the master dive data any more, and think we shouldn't edit the dive at
all.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The whole "+ 0.5" to round to integers only works for positive values,
and GPS coordinates are signed.
So use the proper "round to int" function (rint()), which does this correctly.
Also, remove the redundant check against the master gps values: we
already checked that if we do have a master dive, the gps values must
match the currently edited dive, so comparing against the master is
entirely redundant.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This adds watertemp and airtemp to the dive, populates them in fixup and
uses them elsewhere in the code.
WARNING: as a sideeffect we now edit the airtemp in the dive, but we never
display this in the DIve Info notebook (as that always displays the data
from the specific selected divecomputer). This is likely to cause
confusion. It's consistent behavior, but... odd. This brings back the
desire to have a view of "best data available" for a dive, in addition to
the "per divecomputer" view. This would also allow us to consolidate the
different pressure graphs we may be getting from different divecomputers
(consider the case where you dive with multiple air integrated computers
that are connected to different tanks - now we could have one profile with
all the correct tank pressure plots overlayed - and the best available (or
edited) data in the corresponding Dive Info notebook.
This commit also fixes a few remaining accesses to the first divecomputer
that fell through the cracks earlier and does a couple of other related
cleanups.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When starting on this quest to stop using the first divecomputer instead
of data for the whole dive in commit eb73b5a528c8 ("Duration of a dive is
the maximum duration from all divecomputers") I introduced an accessor
function that calculates the dive duration on the fly as the maximum of
the durations in the divecomputers.
Since then Linus and I have added quite a few of the variables back to the
dive data structure and it makes perfect sense to do the same thing for
the duration as well and simply do the calculation once during fixup.
This commit also replaces accesses to the first divecomputer in
likely_same_dive to use the maxdepth and meandepth of the dive (those two
slipped through the cracks in the previous commits, it seems).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Float values have insufficient precision compared to the udeg we usually
store - so we create a special callback function to use from osm-gps-map
and everywhere else use integers.
This patch also increases the decimal places displayed in the GPS text
entry box - this way we can cut and paste the text without loss of
precision.
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The fixup_dives() code used to only look at the first divecomputer,
which meant that minimun temperatures etc for the dive would only ever
come from the primary divecomputer.
This splits up the code that walks over the divecomputer into a function
of its own, and iterates over all computers in fixup_dive() calling into
it.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
So far we always used the duration of the first divecomputer. The same fix
needs to be done for some of the other calculations that always use the
first divecomputer.
This commit also removes some obsolete code from the webservice merging.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The previous attempt in commit f305c5c83fe1 ("Correctly parse translated
cardinal directions") suffered from a bit of false advertising in that it
wasn't, actually, "correct". It made silly assumptions about the length of
the translated strings being 1 and also forgot the middle part of the
algorithm where we use the appearance of 'E' or 'W' (and their translated
brethren) as indication that there are no minutes for the the latitude.
Hopefully this version does better.
Reported-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The air temperature editing was broken when you edited multiple dives at
once: even if you didn't actually change the air temperature, all dives
would be reset to that particular temperature.
The logic for editing dives is that we have a 'master' dive (which is
the dive that all the entries get filled in from), and only if the
entries have changed from what the master dive information was (ie the
user actually edited it) do we change that particular piece of
information.
And we only change it for dives that match the master dive for that
entry.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When editing a new dive, and using a dive site name that we have
already seen previously, and have GPS information for, pick up that
GPS information from the previous dive by default.
NOTE! When editing dive site locations for dives that already have GPS
information, or when we've modified the GPS information explicitly
some way while editing the dive (either through map input or by
editing the text field directly) we do *not* use this automatic logic.
So if you messed up the GPS information some way and want to
re-populate it with the automatic mode, you need to explicitly clear
the GPS text-field, at which point we go back to "ok, let's try to
pick up automatic GPS data from previous dives with the same name"
mode.
Also note that we do the automatic location lookup only when actually
editing the location field. So if you already wrote the dive site
name, then cleared the GPS field, you now need to go back to the dive
site name and edit it again to get the automatic GPS filling.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We now compare to both the standard English characters ('N', 'E', etc) as
well as to the translated strings (_("N"), _("E")) when parsing GPS
strings.
Reported-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
With the changes to the selection logic the selected_dive variable didn't
get updated at the end of planning a dive. With an empty dive list that
could cause selected_dive to be -1 which would subsequently cause a
SIGSEGV when trying to edit the newly created dive.
With this commit we use the shared go_to_iter() function and also make
sure that selected_dive is set correctly.
Reported-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This no longer abuses the dive merging code (which would leave stray
"dives" behind if a gps fix couldn't be merged with any of the dives) and
instead parses the gps fixes into a second table and then walks that table
and tries to find matching dives.
The code tries to be reasonably smart about this. If we have
auto-generated GPS fixes at regular intervals, we look for a fix that is
during a dive (that's likely when the boat where the phone is staying dry
is more or less above the diver having fun). And if we have named entries
(so the user typed in a location name) we try to match them in order to
the dives that happened "that day" (where "that day" is about 6h before
and after the timestamp of the gps fix).
This commit also renames dive_has_location() to dive_has_gps_location() as
the difference between if(!dive->location) and if(dives_has_location) is a
bit too subtle...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Mostly coding style and whitespace changes plus making lots of functions
static that have no need to be extern. This also helped find a bit of code
that is actually no longer used.
This should have absolutely no functional impact - all changes should be
purely cosmetic. But it removes a bunch of lines of code and makes the
rest easier to read.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
On 28 January 2013 23:26, Dirk Hohndel <dirk@hohndel.org> wrote:
>
> Just pushed out Linus' Gtk3 readiness changes plus my change that allows
> the user to not only type in GPS coordinates but also use a map widget
> to pick the dive site.
>
> There were a few very odd Gtk things going on - when I opened the map
> widget from the dive info dialog (by clicking the button), the widget
> would be completely unresponsive. No panning, no zooming, no
> right-click, nothing.
>
> Opening an equipent widget and immideately closing it again suddenly
> made the map widget responsive. WTF?
>
> I worked around this by doing an explicit grab in the map widget, but
> that seems like a hack and just to work around the underlying issue.
>
> If anyone can figure this out, patches welcome.
>
> The other shortcomings (besides the uglyness of the UI) are that it may
> be non-obvious to the user that it takes a right click to get a menu
> item that allows you to "mark location here" - I'm sure there's a more
> intuitive way to do this, but since left click is used for panning, this
> was the best idea I could come up with...
>
> Please test - I wouldn't be surprised if there are a few bugs still
> hidden in this code.
>
here an fix to make this work on win32 and also solve a potential issue of type:
(subsurface.bin:19441): Gtk-CRITICAL **: IA__gtk_entry_set_text:
assertion `GTK_IS_ENTRY (entry)' failed
my commit message is explicit on the reasons:
------------------------
When called from the "dive edit" dialog the, map windows seems
inactive on Windows. It cannot accept focus and is also behind all
other application windows.
There are a couple of important new calls in gps.c:show_map():
gtk_window_set_transient_for(GTK_WINDOW(*window), GTK_WINDOW(main_window));
(^ docs say gtk "may" call this one for us, on what condition - not specified)
gtk_window_set_modal(GTK_WINDOW(*window), TRUE);
(^ broken on ubuntu 12.04, but needed on Win32))
Making the window transient for the main window and also modal for
the entire application's window stack (or at least try).
Older versions of gtk+2 and also in the most recently tested
libgtk2.0-0 2.24.10-0ubuntu6, seem not to recognize the significance
of gtk_window_set_modal() and the call does not work as expected.
This forces us to check if the dialog from which the call originated
exists, since its possible to close it _while_ the map widget is active.
More specifically, we check in info.c if the location_update.entry pointer
was set to NULL before performing actions with in the update_gps_entry()
callback.
------------------------
also removed the gtk_window_present() call as it seemed redundant post
these changes (?).
-------
on a side note:
looks like i'm above 100 commits...
cheers everyone <has a sip of some late beer> :0 ~ c|_|
lubomir
--
From fe9967c7ad2ec3b93ad336c2c6bed492a5ad0d8b Mon Sep 17 00:00:00 2001
From: "Lubomir I. Ivanov" <neolit123@gmail.com>
Date: Tue, 29 Jan 2013 00:24:21 +0200
Subject: [PATCH] Fix a "stacking" issue with the map-window on Windows
When called from the "dive edit" dialog the, map windows seems
inactive on Windows. It cannot accept focus and is also behind all
other application windows.
There are a couple of important new calls in gps.c:show_map():
gtk_window_set_transient_for(GTK_WINDOW(*window), GTK_WINDOW(main_window));
(^ docs say gtk "may" call this one for us, on what condition - not specified)
gtk_window_set_modal(GTK_WINDOW(*window), TRUE);
(^ broken on ubuntu 12.04, but needed on Win32))
Making the window transient for the main window and also modal for
the entire application's window stack (or at least try).
Older versions of gtk+2 and also in the most recently tested
libgtk2.0-0 2.24.10-0ubuntu6, seem not to recognize the significance
of gtk_window_set_modal() and the call does not work as expected.
This forces us to check if the dialog from which the call originated
exists, since its possible to close it _while_ the map widget is active.
More specifically, we check in info.c if the location_update.entry pointer
was set to NULL before performing actions with in the update_gps_entry()
callback.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The location map picker introduced in commit 801a61e7e0f2 ("Pick GPS
coordinates of dive location via map widget") failed to add the necessary
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This cleans up our handling of combo boxes and all the duplicated
completion logic, and simplifies the code.
In particular, we get rid of the deprecated GtkComboBoxEntry. While it
made some things easier, it made other things harder. Just using
GtkComboBox and setting that up correctly ends up being simpler, and
also makes the logic work with gtk-3.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I have some concerns about the way this is implemented - especially the
use of gtk_grab_add to make the map widget work has me worried. But it
seems to work and survived some test cases that I threw at it.
The GtkButton with the Pixmap looks a little off on my screen, but this
way it was easy to implement. Feel free to come up with a better design.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I'm sure there are better ways to do this, but this appears to grok most
rational formats I was able to find. NSEW or positive/negative numbers.
Decimal degrees (WGS84) or degrees and decimal minutes (that's what most
GPSs seem to provide). I'm sure there are still corner cases that confuse
it, but it seemed reasonably robust in testing.
I don't really love the ';' as separator but that solves the obvious
problem with locales that use a decimal comma.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
That's much more intuitive to remove GPS data from a dive than having to
type in 0,0 as coordinates.
With this change we also skip leading whitespace for WGS84 coordinates.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This implementation gives the user the ability to add GPS coordinates to
the dive location. It works as expected in multi-dive edit scenarios. It
has two major flaws:
- it only support WGS84 style coordinates - it should instead be
intelligent enough to parse the common formats, at least using NSEW
instead of sign and understanding minutes and seconds instead of decimal
degrees
- but in reality, it really needs to support a map picker
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This moves the fields 'duration', 'surfacetime', 'maxdepth',
'meandepth', 'airtemp', 'watertemp', 'salinity' and 'surface_pressure'
to the per-divecomputer data structure. They are filled in by the dive
computer, and normally not edited.
NOTE! All actual *use* of this data was then changed from dive->field to
dive->dc.field programmatically with a shell-script and sed, and the
result then edited for details. So while the XML save and restore code
has been updated, all the displaying etc will currently always just show
the first dive computer entry.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
.. and rename the badly named 'output_units/input_units' variables.
We used to have this confusing thing where we had two different units
(input vs output) that *look* like they are mirror images, but in fact
"output_units" was the user units, and "input_units" are the XML parsing
units.
So this renames them to be clearer. "output_units" is now just "units"
(it's the units a user would ever see), and "input_units" is now
"xml_parsing_units" and set by the XML file parsers to reflect the units
of the parsed file.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Stupid Gtk. Seriously. So in order to get a notification if the user
selects the drop down for the gas with the mouse I need to connect to the
"changed" signal for the combobox. But that also fires whenever the user
types something into the GtkEntry. Which means we once again get called
for all kinds of silly partial names.
Instead we want to handle the manual entry in the "focus-out" callback
(the user has hit tab or something else to move away from the GtkEntry -
let's assume that this is the text he wants us to use) and only respond to
the changed signal on the combobox if the user selected something from the
dropdown.
The easiest way to do that (I think) is to check the text with the strings
stored in the model. If this indeed matches a string stored in the model
then most likely this is something the user selected from the dropdown.
But more importantly if it isn't in the model, then we KNOW that this is
just a partial string that was typed in. And we can ignore that one.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Once again Gtk does everything it can to make our lives miserable. It
requires major hackery to be able to add new gases to the drop down lists
"on the fly". Right now this only works if you edit the gas and then use
Tab to move to the next field.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This can cause some fun unintended side effects - especially when the dive
is part of a trip and the new date/time moves this into a different trip.
Instead, trips get split and the overall result is consistent, but a bit
unexpected.
But since this is designed to help people right after a dive import in
case the clock on the dive computer was wrong, my guess is this won't ever
be a problem for actual users.
Fixes ticket 18
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Now we can simply remember the state of all the preferences at the
beginning of preferences_dialog() and restore them if the user presses
'Cancel'.
Fixes#21
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Lubomir's commit aec904b612 broke the Add
Dive menu item: The Edit Dive dialogue didn't show up after the initial
dialogue.
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Turns out we had a data field for visibility as a length unit - but never
used it. I can never guess how much visibility we actually had on a dive -
but I think most everyone can assign a rating between abysmal (zero stars,
"I couldn't read my dive computer even right in front of my mask" - trust
me, I had some of those dives) to amazing ("five stars, I could see farther
than I though possible" - and I had one or two of those, too). So I
changed this to an integer and am re-using the star infrastructure we have
for the overall dive rating.
When displaying this I was dismayed that we are running out of space in
the "Dive Notes" notbook. So I moved this to the "Dive Info" notebook.
This is not consistent and not logical. I think we need to revisit the
notebooks and think about what we want to display where.
While adding the infrastructure to manually enter the visibility I went
ahead and added the ability to manually enter the air temperature as well
(that was one of the things missing in the previous commit).
Fixes#7
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
info.c
- Removed the additional pop-up menu entry "Delete"
- Removed the delete_dive_info() function, which created
the yes/no dialog.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>