summaryrefslogtreecommitdiffstats
path: root/gtk-gui.c
AgeCommit message (Collapse)Author
2011-10-29Get icons working correctly under WindowsGravatar Dirk Hohndel
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>
2011-10-28Use Registry on Windows to store preferencesGravatar Dirk Hohndel
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>
2011-10-27Don't use gconf on WindowsGravatar Dirk Hohndel
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>
2011-10-25Rearrange the event filter dialogGravatar Dirk Hohndel
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>
2011-10-25Add menu item and dialog to select which events to displayGravatar Dirk Hohndel
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>
2011-10-23Fix oversight in preference implementationGravatar Dirk Hohndel
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>
2011-10-23Make columns for temperature, cylinder, and nitrox optionalGravatar Dirk Hohndel
Just like SAC and OTU these can now be turned on and off through the preferences. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-21Fix "Keep window size for new notebook pages" to not set minimum sizeGravatar Dirk Hohndel
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>
2011-10-21Make the first filename on the command line the default filenameGravatar Dirk Hohndel
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>
2011-10-20Keep window size for new notebook pagesGravatar Dirk Hohndel
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>
2011-10-11Have "make install" act more as expected for a desktop applicationGravatar Dirk Hohndel
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>
2011-10-06Remove some useless casts from and to void pointersGravatar Julian Andres Klode
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>
2011-10-05Make FileChooserButton end import dialogGravatar Dirk Hohndel
If we choose a file in the import dialog then this should imply clicking OK in that dialog - no reason for a two step process. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-05Mark the FileChooserButton as UNABLE to select multiple filesGravatar Dirk Hohndel
That's a gtk limitation. So you have to import XML files one at a time. If this is too big of a restriction then we need to redesign the import dialog. Sgned-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-05Add XML file import back and treat open and import differentlyGravatar Dirk Hohndel
Open (or adding a file name on the command line) means that this is just one of the files that you consider part of your dive history. So dives don't get automagically numbered and the dive_list is not considered "changed" just because another file was opened. Import (or adding a file on the command line after --import) means that you are importing the content of this file to your dive history. So if the imported file has un-numbered dives that are newer than everything else, those get correctly renumbered. And importing marks the dive_list as changed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-05For a manual renumber, default to the existing first dive numberGravatar Linus Torvalds
If renumbering a list of dives, default the start number to the existing first dive number. That way, if you do need to renumber (overlapping import or whatever), but your at least had your really old dives already numbered, we start off with a sane default. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-10-05Move 'dive_list_update_dives()' call into 'report_dives()'Gravatar Linus Torvalds
All the callers were always calling report_dives first, followed by dive_list_update_dives(). And there really was no reason to have the callers call two separate functions for the "I've added new dives" case. So just call dive_list_update_dives() directly from report_dives(), and remove it from the callers. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-10-04Shorten the tooltip timeoutGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-04Replace event text with small red triangle and tooltipGravatar Dirk Hohndel
We draw a little red triangle (of hardcoded size - not sure if this SHOULD scale with the size of the plot... I like it better if it doesn't) to the left of an event. We then maintain an array of rectangles that each circumscribe one of those event triangles and if the mouse pointer enters one of these rectangles then we display (after a short delay) a tooltip with the event text. Manually creating these rectangles, maintaining the coordinate offset, checking if we are inside one of these rectangles and then showing a tooltip... this all seems like there should be gtk functions to do this by default... but if there are then I failed to find them. So instead I manually implemented the necessary logic. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-04Change plot routine to take a drawing_area as argumentGravatar Dirk Hohndel
Previously we passed in width and height and the routine itself decided to keep 5% margin around each edge - oddly doing this with double precision, even though this is all integer coordinates. Instead we are now passing in a drawing_area. We are kind of abusing the cairo_rectangle_int_t data type here - but it seemed silly to redefine a new data type for this. Width and height give the size of the TOTAL drawing area (as before). x and y give the offset from the edges - so the EFFECTIVE drawing area is width-2x and height-2y This is in preparation for adding tooltips - those need to know the coordinate offsets from the edges - so having this hard coded inside the plot function didn't make sense anymore. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-03Merge branch 'uemis-integration' of git://github.com/dirkhh/subsurfaceGravatar Linus Torvalds
* 'uemis-integration' of git://github.com/dirkhh/subsurface: Remove the ability to 'Import' .SDA files Integrate loading of uemis SDA files into the regular xml parsing First steps towards integrating SDA files into the default XML loading
2011-10-03Remove the ability to 'Import' .SDA filesGravatar Dirk Hohndel
We can instead 'Open' these files as they are just bastardized XML files. This gets us back to a more consistent point where 'Import' gets data directly from the dive computer (and hopefully soon we will add the ability to load a dive directly from a uemis SDA to libdivecomputer), and 'Open' loads a file from the filesystem of the computer we are running on (this last sentence phrased so awkwardly as the uemis Zurich SDA is a computer and presents a file system when connected via USB - it just doesn't have the dive data in an accessible format in that file system). As a bonus we get to throw away quite a bit of code (the uemis specific file handling, mini-XML parser with helper functions, the file open dialog in the importer). Yay! Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-02Split up generic code to generate a gtk tree view columnGravatar Linus Torvalds
We used to do this just for the dive list, but the new cylinder view will want to do a lot of the same boilerplate gtk stuff, so make it a bit more generic and move it to gtk-gui.c. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-27The notebook pages can only be dropped back into the main notebookGravatar Dirk Hohndel
Disable the secondary notebooks that are created when ripping off a page (dive_list or dive_profile) as drop targets for other pages. Also fix the incorrect arguments for the drag callback function. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-27Linus would like to be less on the bleeding edge of Gtk+Gravatar Dirk Hohndel
So we go back to the old interfaces to identify the notebook as part of one group - the one that was just recently deprecated Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-27Use the correct signal to avoid Gtk-CRITICAL error messageGravatar Dirk Hohndel
We used the wrong signal - "data-drag-received" is intended to check whether the target will accept the drop. What we want is the "drag-drop" signal which tells the widget that something was dropped on it. Also fix an embarrassing lack of NULL pointer checks in my string comparisons... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-27Clean up the drag and drop code and allow ripping off the Dive ProfileGravatar Dirk Hohndel
Linus had used some deprecated interfcase and didn't correctly untangle the new window that he created (hiding it the window... very nifty). I think I'm closer to the real solution with a data structure that keeps track of the components of the new top level window that I need to be able to untangle (and eventually, destroy) at the end. The one error I also can't seem to get rid of is the Clean up the drag and drop code and allow ripping of the Dive Profile Gtk-CRITICAL **: IA__gtk_selection_data_set: assertion `length <= 0' failed Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-27Add drag-n-drop support to be able to re-integrate the dive listGravatar Linus Torvalds
This is somewhat hacky, and there is clearly something I still don't understand about gtk selections and drag-n-drop. Dropping it back works, but I get a nasty error when I do it: (subsurface:8512): Gtk-CRITICAL **: IA__gtk_selection_data_set: assertion `length <= 0' failed even though I actually never set any selection at all directly. So there must be some internal gtk rule that I am violating, but I can't see what it is. I probably shouldn't commit it with a known ugly wart like that, but I really have no clue. Maybe somebody else can figure out what is up. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-27Don't mark the divelist window transientGravatar Linus Torvalds
That also makes it always stay in front of the other window, which is just annoying. I only did it because I wanted to make sure it dies when the main window does, but since we just kill the main loop when closing either window, that just isn't an issue. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-27Merge branch 'otu-tracking-v2' of git://github.com/dirkhh/subsurfaceGravatar Linus Torvalds
* 'otu-tracking-v2' of git://github.com/dirkhh/subsurface: Store options in gconf Add preference option to chose if SAC and/or OTU should be in divelist Fix up trivial conflicts in gtk-gui.c (cleanup in gtk dialog wrt gtk_dialog_get_content_area() having introduced a new 'vbox' widget)
2011-09-27Store options in gconfGravatar Dirk Hohndel
While it's not the most elegant way to do this I opted to store the options with "inverted polarity" - i.e., the options that are supposed to default to "True" are stored inverted since gconf reports an unset option (first time the user runs the program) as "False". Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-27Make the dive list start as a plain notebook pageGravatar Linus Torvalds
I've been wondering how to make 'subsurface' work better on a small screen (I used to travel with a crappy netbook - I may have upgraded my laptop since, but it is still a design goal of mine to make sure it all works fine in that kind of environment). And ever since the dive list was made much wider and moved below the notebook, it's annoyed me how much room it all takes if I want to have both a reasonable plot window and several dives visible at the same time. The solution seems to be to just make the dive list be a notebook page. That makes the default layout very dense. At the same time, when you have the pixels, it's horrible, because you would want to see the dive list and move between dives while at the same time also seeing the dive profile change. But that is solvable by simply making the dive list notebook page be detachable, so if you have a nice big screen, just detach the dive list page and now you have independent windows for the dive list and the dive info. NOTE! I don't have any way to re-attach the dang thing. I think I'd need to learn about drag-and-drop targets etc. So once you've detached the dive list, it stays detached. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-27Add preference option to chose if SAC and/or OTU should be in divelistGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-26Add the version to the MakefileGravatar Linus Torvalds
Not quite the same format as for the kernel, but I want to do the normal "edit the makefile before making a release" model that I'm used to. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-26Add a GtkEntry to allow editing of the device nameGravatar Linus Torvalds
Ok, so some file chooser widget with a popup dialog would have been more professional, but I'm lazy. Plus I suspect the popup would look horrible when populated with /dev entries, and I don't think there is any sane filter function. So this works, and means that you don't *have* to recompile the whole program just because you have your dive computer on something else than a USB serial line. I suspect I should save the default name as a config variable too. Maybe a setting in the preferences dialog. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-26Add a "Dive Computer" frame around the dive computer choice in importGravatar Linus Torvalds
I'll add a widget to allow the user to select the device too, so let's name things to make them more obvious. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-26Add a xml file filter to the file open dialogGravatar Linus Torvalds
My home directory is a mess. Don't show all the crap, just the stuff that might be relevant. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-24Add an 'About' dialogGravatar Linus Torvalds
It's really just about the logo, but whatever. Dirk tells me I need one of these in order to call it 1.0. And I'm not going to fall into the trap of thinking that 1.0 needs to be something polished, it just needs to be working well enough.. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-24Use 'gtk_dialog_get_content_area()' instead of accessing dialog directlyGravatar Linus Torvalds
I'm reading gtk docs, and trying to clean things up a bit. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-22Fix progress bar during libdivecomputer importsGravatar Linus Torvalds
As reported by Mauro Dreissig, the progress bar doesn't work and causes a SIGSEGV due to a missing allocation. The code broke when Dirk separated out the GUI from the core code, and I hadn't tried divecomputer downloads since. Reported-by: Mauro Dreissig <mukadr@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-21Use the last (or only) filename on command line as default for savingGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-21Show the "save changes" dialog before the main window is destroyedGravatar Dirk Hohndel
By using the delete-event callback instead of the destroy callback we are able to display our dialog (and the file-save dialog) while the program window is still being displayed. Much nicer this way. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-21Check for changes at regular 'quit' events as wellGravatar Dirk Hohndel
Also make the dialog box less offensively ugly Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-21Catch changes to the info of the current dive when quittingGravatar Dirk Hohndel
As the application shuts down we do one more check to see if the dive that is currently being displayed has been modified (we previously just checked as we switch dives) Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-21Simplistic first attempt to get changes saved when quitting subsurfaceGravatar Dirk Hohndel
Track whether things changed in the global dive_list So far this actually works if changing dive info (but only if dive selected was changed after the dive info was changed). We are not tracking changes to the cylinder information, yet. also remove the duplicate static dive_list Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-20Fix preferences dialogGravatar Linus Torvalds
Dirk took some old code when he did the merge of the newly split gui code. Fix it up. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-20Separate out the UI from the program logicGravatar Dirk Hohndel
The following are UI toolkit specific: gtk-gui.c - overall layout, main window of the UI divelist.c - list of dives subsurface maintains equipment.c - equipment / tank information for each dive info.c - detailed dive info print.c - printing The rest is independent of the UI: main.c i - program frame dive.c i - creates and maintaines the internal dive list structure libdivecomputer.c uemis.c parse-xml.c save-xml.c - interface with dive computers and the XML files profile.c - creates the data for the profile and draws it using cairo This commit should contain NO functional changes, just moving code around and a couple of minor abstractions. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>