summaryrefslogtreecommitdiffstats
path: root/gtk-gui.c
AgeCommit message (Collapse)Author
2013-02-02Move about icon to include fileGravatar Henrik Brautaset Aronsen
Getting the about icon to display in various scenarios on MacOSX was a pain. Moving the icon to an include file solved the problem. This commit also fixes the problem Dirk was having when converting satellite.svg to a png in commit cf3c0266c2. I couldn't quite get ImageMagick to preserve transparency and color when converting subsurface-icon.svg, though, so I used Gimp instead. Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
2013-02-01Clear yearly statistics when closing data fileGravatar Dirk Hohndel
Another oversight of what needed to be done when cleaning up the UI after closing the data file. Reported-by: Sergey Starosek <sergey.starosek@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-01Clear the list of events when closing data fileGravatar Dirk Hohndel
When the data file is closed we should reset the events that we offer for filtering. Reported-by: Sergey Starosek <sergey.starosek@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-01Turn off tooltips if no dives are selectedGravatar Dirk Hohndel
We already clear the widgets but forgot to turn off the tooltips as well. Reported-by: Sergey Starosek <sergey.starosek@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-31Add tooltip that tells user how to edit dive informationGravatar Dirk Hohndel
This adds the tooltip just to the Dive Notes page of the notebook area - that's where people are tempted to try to do "edit in-place" which we currently don't support. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-30Properly destroy the cairo context when we're done with itGravatar Linus Torvalds
Henrik reports that on OSX, not destroying the cairo context results in a corrupted profile display. It seems to just leak memory on Linux. For gtk3, the cairo context is embedded in the GtkDrawable, for gtk2 we need to create and destroy it appropriately. Although maybe we could just make it static instead of creating/destroying it all the time. Anyway, this goes back to the old cairo destroy logic for gtk2. Reported-and-analyzed-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-30Massive cleanupGravatar Dirk Hohndel
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>
2013-01-30Show Gradient Factors in plot when showing calculated ceilingsGravatar Dirk Hohndel
This adds the GFlow/high values used to calculate the ceiling (if any). Right now it shows those numbers even if at no point of the dive there was an actual ceiling (but only if showing the ceiling itself is enabled). This should make it easier to for the user to make sense of the calculated ceiling, especially if posting screen shots. As an aside - for some dive computers like the OSTC and the Shearwaters we should be able to also plot the GF used by its calculation which might be interesting for comparison purposes, as both of them also give us the ceiling (lowest deco stop) calculated during the dive.. See #13 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-29Add missing strings for translationsGravatar Dirk Hohndel
Mostly in new code, but some of them are strings in older code that have been missed in the past. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-28Prepare to compile with gtk-3Gravatar Linus Torvalds
To actually compile with gtk-3 you currently need to disable the use of OSM (compatible with gtk2 only for now). And obviously figure out the headers and libraries by using pkg-config on gtk-3 instead of gtk-2. But now it should be only a Makefile change. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-28Clean up gtk combo box handlingGravatar Linus Torvalds
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>
2013-01-28Make subsurface compile with -DGSEAL_ENABLEGravatar Linus Torvalds
This forces us to use the proper gtk accessor functions. It may not be worth it if people actually do the Qt conversion, but if we want to try gtk3 at some point, this might help. This all came about because I was trying to explain on G+ what an immense pain this all was to even figure out, if you don't actually know gtk at all. Google and the gtk migration guide are almost useless, and the gtk2 documentation itself actually uses the fields directly without any accessor functions in several places. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-25Remove some unnecessary variable initializationsGravatar Dirk Hohndel
Not really bugs, just wasted. They clutter up the output of static analysis with cppcheck. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-25Fix memory leak in set_dc_nicknameGravatar Dirk Hohndel
remember_dc() already does a strdup of the nickname. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-25Move get_units() to prefs.cGravatar Henrik Brautaset Aronsen
get_units() returns the current unit preference, thus it belongs in prefs.c rather than gtk-gui.c Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24Add 2013 to the copyright lineGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24Remove saving of dive computer nicnames in system configGravatar Linus Torvalds
We save the (more complete) dive computer information in the XML file with serial numbers and firmware version if we know about them, so using a complicated string in the system config was redundant and confusing. So remove that code. NOTE! Since the dive computer nicknames are now only saved if the XML file is saved, we also mark the dive list "changed" when we edit the nicknames. That way we'll be prompted to save things before exiting, even if we don't actually edit any actual dive data. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24Save all dive computer nicknames - whether used or notGravatar Linus Torvalds
We used to save dive computer information only if that dive computer was actually used in any of the dives we saved. But we can simplify the code if we just always save any dive computers we know about. And it does allow for some usage cases where you have nicknames for other peoples computers that you may not actively use, but you want to see if you end up loading multiple XML files in one go. So there's just no compelling reason to not just save all the info we have. And this will make it less painful to remove the "use system config for dive computer nicknames", because you can also use this to continue to gather dive computer info in a separate XML file if you want to. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-23Fix setting of the dive_table.preexisting logicGravatar Linus Torvalds
The 'preexisting' value is used for downloading dives: we want to add new dives but, but then compare those new dives against the preexisting ones before we start sorting things and possibly merging them. However, the value was only updated sporadically, resulting in it having stale information in it. Which would cause problems particularly if you deleted dives, so that the preexisting value would point past the actual existing values! So just update it unconditionally in dive_list_update_dives(), which anything that changes the dive list is supposed to call in order to display the changes anyway. Also, just for safety, when removing a dive, put NULL in the last dive table location. Nobody should ever access past the end anyway (this is enforced by 'get_dive()') but there are places that access the dive list table directly, and the libdivecomputer download was one of those. No reason to leave stale dive pointers possibly around for uses like that. Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-23Fix crash when applying a non-edit of nicknamesGravatar Amit Chaudhuri
As reported by Henrik, there was a crash lurking in edit_dc_nickname code. Invoking the dialog and selecting apply without changes exposed it neatly. This is a one line fix. Signed off by Amit Chaudhuri <amit.k.chaudhuri@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-22Add GPS icon to the location column for dive sites where we have GPS dataGravatar Dirk Hohndel
This replaces the really lame "italics text" from commit abe810ca1a29 ("Mark locations that have GPS location data attached") with a marginally less lame GPS icon.There's a reason why I am not making a living as graphics artist. But I think this is a huge step forward from what we had before... The satellite.svg file is very loosely based on a different icon that I found as public domain here http://www.clker.com/clipart-30400.html. From that I created the PNG and then that was converted into the GdkPixdata via gdk-pixbuf-csource; a rule for that was added to the Makefile but commented out as I don't know if this tool will always be available in the path. Having this icon included in the sources avoids locating yet another icon file. Better icons are certainly welcome! Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-18Consistently use uint32_t for deviceidGravatar Dirk Hohndel
There were a handful of places that incorrectly used signed values for the deviceid. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-18Add facility to edit nicknames / remove nickname entryGravatar Amit Chaudhuri
This allows users to edit one or more nick name entries in a single session. Entries can also be removed individually. Based on mock up by Lubomir Ivanov and various conversations from Dirk. Thanks to both. [Dirk Hohndel: quite a bit of editing for coding style and whitespace] Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-17Added client side communication to the Subsurface Web ServiceGravatar Lubomir I. Ivanov
A couple of new files webservice.c and webservice.h are added. webservice.h exposes two methods at the moment: - webservice_download_dialog(): this function creates the user interface for the download dialog from the web service. - webservice_request_user_xml() this function is a direct call to retrieve XML for a specific user identifier. the actual data, data length and error codes are stored in passed pointers. A menu entry is added in the Log menu: "Download From Web Service" The used backend for communication at the moment is provided by libsoup. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-17Hack Makefile, gtk-gui.c and divelist.c to allow building w/o osm-gps-mapGravatar Dirk Hohndel
While we are waiting for an autotools generated Makefile, this should allow people to build that don't have osm-gps-map. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-15Attempt to override the URI handler in the about dialogGravatar Lubomir I. Ivanov
The previous patch in this series adds the function subsurface_launch_for_uri(), which has to be called from the about dialog instead of the default function for the URI calls to work on Windows - i.e. opening links from the dialog. gtk_about_dialog_set_url_hook() is a deprecated method, but seems to be the only reasonable way to make the override between GTK 2.20 - 2.24 possible. The "activate-link" signal is recomended instead, but is not portable for GTK bellow 2.24. An alternative would be to somehow hack into the GtkAboutDialog and override the callback for each clickable link. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-14Centralising and redefining values as integersGravatar Jan Schubert
This patch centralizes the definition for surface pressure, oxygen in air, (re)defines all such values as plain integers and adapts calculations. It eliminates 11 (!) occurrences of definitions for surface pressure and also a few for oxygen in air. It also rewrites the calculation for EAD, END and EADD using the new definitons, harmonizing it for OC and CC and fixes a bug for EADD OC calculation. And finally it removes the unneeded variable entry_ead in gtk-gui.c. Jan Signed-off-by: Jan Schubert <Jan.Schubert@GMX.li> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-13Add support for MOD, EAD, AND and EADD in the mouse over displayGravatar Dirk Hohndel
- MOD: Maximum Operation Depth based on a configurable limit - EAD: Equivalent Air Depth considering N2 and (!) O2 narcotic - END: Equivalent Nitrogen (Narcotic) Depth considering just N2 narcotic (ignoring O2) - EADD: Equivalent Air Density Depth Please note that some people and even diving organisations have opposite definitions for EAD and END. Considering A stands for Air, lets choose the above. And considering N for Nitrogen it also fits in this scheme. This patch moves N2_IN_AIR from deco.c to dive.h as this is already used in several places and might be useful for future use also. It also respecifies N2_IN_AIR to a more correct value of 78,084%, the former one also included all other gases than oxygen appearing in air. If someone needs to use the former value it would be more correct to use 1-O2_IN_AIR instead. Signed-off-by: Jan Schubert / Jan.Schubert@GMX.li Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-13Work on a dive localisation tool using GPS coordinatesGravatar Pierre-Yves Chibon
For each dive recorded, place their GPS coordinates onto a map using the OSM-GPS-MAP library. This map is accessible via the "log" menu or the shortcut ctrl+M (M as map). We check for the GPS coordinates "0, 0" which are the default when we do not have real GPS coordinates set. [Dirk Hohndel: fixed int/float math confusion, fixed some whitespace and coding style issues, cleaned up some comments, added a missing cast to prevent a compiler warning] Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr> Signed-Off-By: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-11Add default filename and divelist font to prefs structureGravatar Linus Torvalds
.. and add the usual logic to not save the default values. This also simplifies the initial system-specific setup of both of these: since we have defaults for all the preferences that get set up at startup, we can just initialize those defaults to the system-specific fonts then and there. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-11Fix SIGSEGV if no pre-existing nickname informationGravatar Linus Torvalds
Loading an xml file with dive computer information without any preexisting nickname data would try to "remember" that NULL nickname. Causing a SIGSEGV if there was no nickname information. The bug was introduced by commit ec38d3708df2 ("Move device_info handling into a new 'device.c' file") when I inadvertently removed a bit too much code. It actually wants to remember a missing DC nickname as an empty one. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-11Update preference saving for numeric valuesGravatar Linus Torvalds
This does the "don't save defaults" for numeric values too. Also, move the preferences loading/saving to a new "prefs.c" file. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-11gtk-gui.c: Move the download dialog related code to a new fileGravatar Lubomir I. Ivanov
A new file download-dialog.c now contains all code related to the download dialog, which was previously defined in gtk-gui.c. Also, a new file callbacks-gtk.h now has two macros OPTIONCALLBACK, UNITCALLBACK shared only between download-dialog.c and gtk-gui.c. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-10Clean up preference saving codeGravatar Linus Torvalds
The old code (on purpose) didn't try to differentiate "nonexisting boolean configuration" with "existing boolean configuration set to false", which is problematic if we optimize the saving to not save default preferences at all. Which this does. So in addition to the logic to know about default preferences, this has to change the interfaces for the PREF_BOOL reading code so that you can tell the difference between "no value" and "false". And since the previous calling convention was an abomination of doing pointer casting and having case-statements for the config types, change that while at it. Both from a usage perspective *and* from a back-end perspective it is actually much simpler to just have different functions for the string vs boolean config read/write versions. The OSX versions in particular end up being one-liners. (The GConf library is a nightmare, and doesn't seem to have any way to know whether a boolean value exists or not, so you have to read it as a GConfVal and then turn it into a gboolean rather than just get the "oh, it didn't exist" as an error value). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-10Make the default preferences explicitGravatar Linus Torvalds
This makes it explicit what the default preferences are, so that we can more easily avoid unnecessarily saving default settings. It also makes imperial metrics the default for the US (Burma and Liberia always get forgotten!) Right now we tend to be somewhat confused about defaults. We do have them, but then even if something has a default value, we tend to write it out to the config file. Which is not just unnecessary, but makes it really hard to see after-the-fact whether the user actually wanted that *specific* value, or whether they just wanted the default behavior. So this prepares for having explicit configuration for when we want something different than the defaults. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-10Split up preference data structure definition into 'pref.h'Gravatar Linus Torvalds
.. 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>
2013-01-09Move device_info handling into a new 'device.c' fileGravatar Linus Torvalds
The legacy nickname wrappers (that use the device_info structure) are left in gtk-gui.c. We can slowly start moving away from them, we don't want to start exporting that thing as some kind of generic interface. This isn't a pure code movement - because we leave the legacy interfaces alone, there are a few new interfaces in device.c (like "create a new device_info entry") that were embedded into the legacy "create nickname" code, and needed to be abstracted out. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-09Rename 'dcnicknamelist' struct as 'device_info'Gravatar Linus Torvalds
We'll start recording more than just nicknames in it, like serial numbers and firmware version etc. Start off just renaming it, and re-ordering the members to reflect how the nickname is not the primary issue. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-07Move planner UI into planner.cGravatar Dirk Hohndel
There should be NO other changes in this commit - just moving the code and adjusting the includes (and adding the entry point to display-gtk.h). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-07Remove the now obsolete hard coded test_planGravatar Dirk Hohndel
This was just a crutch to get something out there for people to play with. With the ability to input a plan in place this is now obsolete. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-07Support relative times in diveplanner input "on the fly" modeGravatar Dirk Hohndel
This had gotten lost when updating the profile on the fly. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-06Display dive profile of the dive we plan, as we plan itGravatar Dirk Hohndel
As the user enters data into the entry fields, that data is validated and as soon as there is enough data we start constructing a dive profile, including the final ascent to the surface, including required deco stops, etc. This commit still has some serious issues. - when data is input that doesn't validate, we just print a warning to stdout - instead we need to change the backgroundcolor of the input field or something. - when we switch to the last dive in order to show the profile we don't actually search for the last dive - we just show the first one in the tree. This works for the default sort order but is of course wrong otherwise I'm sure there are many other bugs, but I want to push it out where it is right now for others to be able to take a look. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-06Remove Linus' plan input UIGravatar Dirk Hohndel
This was added in commit 594da00612ab "Do a minimal hook-up of the dive plan tree view to the actual planning" and has been replaced by a different UI in subsequent commits. No point in keeping it around. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-06Planner: hook the gas combo box to a "focus-out" event handlerGravatar Lubomir I. Ivanov
GTK's logic might be a bit flawed (or complicated) in terms of "focus-out-event" and GtkComboBoxEntry objects as it does not work by attaching said signal type directly to the GtkComboBoxEntry. Perhaps it only makes sense for text input. Since "focus-out-event" works for GtkEntry, we can retrieve the child GtkEntry from the combo using gtk_bin_get_child(GTK_BIN(combo) and attach the event handler to that. This change should make it possible to update gas_model (GtkListStore) when changing the widget focus with both the keyboard and mouse clicks. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-05Make the dive plan input much more compactGravatar Dirk Hohndel
Have the frames just for the top row and get rid of all of the extra space in the layout. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-05Add new gases to the combo box in dive plan entryGravatar Dirk Hohndel
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>
2013-01-05Make the 'Add waypoint' button work in the Input Plan dialogGravatar Dirk Hohndel
Just after pushing out the last set of changes I had one more idea what I could try. And of course that was it. Don't queue up a redraw. Simply run gtk_widget_show_all on the dialog! That does the trick. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-05Different widget to input the planGravatar Dirk Hohndel
Linus' treeview for the plan input is just too ugly for words. And doesn't work, either. So let's go with plan C: a table of waypoint entries. Depth, duration (or absolute time), and gas used. The gas is a combobox that does completion. I am reusing Linus' validation functions / parsers. This works if you can fit your dive into the four waypoints that are there by default. The add waypoint button is hooked up but even though it does what I think should modify the dialog that is currently displayed that clearly doesn't work. But at least it "mostly" works and isn't as horrifyingly uggly as the first two attempts. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-05Do a minimal hook-up of the dive plan tree view to theGravatar Linus Torvalds
actual planning Yes, you can actually enter your segments now. No, it's not wonderfully user-friendly. If you don't enter enough segments to create a dive plan, it will just silently fail, for example. And the <tab> key that should get you to the next editable segment doesn't. And so on. But it kind of works. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-05Create the infrastructure for a dive plannder based on a tree-modelGravatar Linus Torvalds
This doesn't actually do the real work yet, but it creates all the infrastructure to edit a tree model, and verify the contents for time, depth and gas mix. Now we just need the ability to add entries to the tree model (this adds one fake one, just to test the editing), and then read out the final end result and turn it into a plan. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>