summaryrefslogtreecommitdiffstats
path: root/print.c
AgeCommit message (Collapse)Author
2012-09-19Use a 64-bit 'timestamp_t' for all timestamps, rather than 'time_t'Gravatar Linus Torvalds
This makes the time type unambiguous, and we can use G_TYPE_INT64 for it in the divelist too. It also implements a portable (and thread-safe) "utc_mkdate()" function that acts kind of like gmtime_r(), but using the 64-bit timestamp_t. It matches our original "utc_mktime()". Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-09-11Use GTK_UNIT_INCH when printing to provide consistency across OSGravatar Lubomir I. Ivanov
Tests have shown that the most multi-platform way to do printing with GTK is to use GTK_UNIT_INCH (or GTK_UNIT_MM) with GtkPrintOperation. Tested on Linux, OSX, Windows. However this requires the appropriate scaling for Pango and Cairo to be done, with separate plotting logic for printing and drawing on the screen. To achieve that, profile.c:plot() now accepts a scaling parameter from type "scale_mode_t" defined in "display.h". Also due to new scale, small decimal numbers (such as 6.12345) cannot be well stored in "cairo_rectangle_int_t" therefore it is replaced with "cairo_rectangle_t", which uses doubles to provide Cairo with a drawing area. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Minor whitespace cleanup. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-03Add the 'Print only selection' checkbox in the print optionsGravatar Pierre-Yves Chibon
With this commit, if few dives are selected by default it will only print the selected dives but in the option panel there is a checkbox that allows to print all dives and not only the selection. Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
2012-08-30Add support for printing only the selected divesGravatar Linus Torvalds
Right now we just implicitly decide "print only selected dives" when there is more than one dive selected (and then print all dives if only one dive is selected). We probably should have an checkbutton in the dive details page for the choice. But I wanted to avoid the pain that is gtk as far as possible for the initial implementation. The code is ready to be changed to just use a checkbutton instead. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-08-30Remove the pretty-print without dive profile option.Gravatar Pierre-Yves Chibon
Until now we had the choice between: - pretty-print - with dive profiles - without dive profiles - table-print This commit remove the pretty-print without dive profiles, leaving the choice to either pretty-print or table-print. Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
2012-08-29Have a nice table formating with choosing the 'Table print' option.Gravatar Pierre-Yves Chibon
With this commit we finally have a nice table output when we want to print the list of dives with minimal information. Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
2012-08-29Invert the print 'dive profile' option.Gravatar Pierre-Yves Chibon
With this change, instead of asking to print the dive profile, you ask to not print them. So the checkbox in the print options changes from 'Show profiles' to 'No dive profiles'. Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
2012-08-29Deactivate 'Show profiles' if 'table print' is checked.Gravatar Pierre-Yves Chibon
This bug was reported by Henrik Brautaset Aronsen, it was happening when: """you select table print, perform the print and then open the print dialogue again""". In such case the 'Show profiles' button was activated while the 'Print table' type was selected. Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
2012-08-28Work on the printing of the dives, first attempt to print as table.Gravatar Pierre-Yves Chibon
With this commit, the user can choose between two printing modes: - pretty print (with or without the dive profile) - table print (which is nothing less than a table formating containing the information) Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
2012-08-27make the font size the same when printing on win32/linuxGravatar Lubomir I. Ivanov
Setting the cairo transformation units (..?) to GTK_UNIT_POINTS makes the font size the same on windows as on linux, when printing. Otherwise the text is unreadable ie way too small. It now looks like http://i47.tinypic.com/154ks2d.png Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-08-27Start re-working the print UI to allow printing tables with no profiles.Gravatar Pierre-Yves Chibon
With this commit we add a checkbox in the "Dive details" tab of the print window. This checkbox allows to print the dives profile or not. If you don't print the dives profile, you get 15 dives on the page (instead of 6 with the profiles). Future work should include: - Ability to choose what is printed - Table layout vs the current one (if no dives profile) - Ability to choose the number of dives per page (play with the font size for this) Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr> Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
2012-08-20Add a "Dive details" widget to the print dialogGravatar Linus Torvalds
Ok, so the widget doesn't actually *do* anything, but this is where you would add dive printing settings for things like "print list" vs "print profiles" etc. Printing just a dense dive table (no profiles etc) is being discussed on the list, maybe starting the scaffolding will inspire somebody to do something about it ... Signed-off-by: Linus Torvalds <torvalds@linux-foundation.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-09-22In summary printout, show divemaster if there was no buddyGravatar Linus Torvalds
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-21Small printing tweaksGravatar Linus Torvalds
It's getting to the point where I'm happy with this. This just makes the spacing between the location and the notes a bit bigger to visually separate them more, and adds units ("min") to the dive duration (and removes the seconds, that really didn't make any sense at an overview level). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-21Add helper function for doing depth unit calculationsGravatar Linus Torvalds
.. and use it for printing too. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-21Fix dive location width problemGravatar Linus Torvalds
For really long dive locations, we now limit the width to the same size as the date and time, and force it to a single line - with an ellipsis if it ends up being too big. Also, since we no longer use any markup anywhere, we migth as well show the dive buddy information too, as we don't need no stinking quoting. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-21Do the pango text layout in multiple chunksGravatar Linus Torvalds
This way we can avoid the need for quoting, since we can just use text rendering instead of markup for the free-form fields. And we will want to make the pango layout width different for the date and location, since we want to fit the depth/duration to the right of them. I still haven't set the different width for the date/location, but this at least is going in the rigth direction. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-21Sue me: I'm not a fan of SerifGravatar Linus Torvalds
The default cairo font seems to be sans, but the default pango font is serif. Maybe it has something to do with my system font settings, but I doubt it: my desktop font settings are all sans-serif. So I think pango is just showing bad taste. Anyway, this just hardcodes the font to "Sans". Maybe somebody wants to make this all part of preferences some day, or pick it from their desktop font preferences. In the meantime, just fix the pango brain-damage. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-21Fix up printing some moreGravatar Linus Torvalds
This makes things slightly prettier and adds back the depth and duration details to the printout. Still a few known problems: font choice, and the depth/duration thing can end up overlapping with a long location name. But it looks pretty good on the whole. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-20Printing: use pango markup for text generationGravatar Linus Torvalds
This gets us text wrapping etc. I think I have some serious memory leak somewhere, though, because if I print out all my dives it eventually ends up with broken dives and doesn't complete. But I am going to commit this as a "it kind of works" point. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-20Add completely BS dive text printingGravatar Linus Torvalds
The layout is crap, the handling of long lines in notes (or location) is wrong, the dive number handling is wrong. The thing is just a toy. But it's a toy that kind of works, and gives a much better idea of what a real dive log printout might look like. With the right kind of dive notes, it looks fine. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-20Try printing six dives per pageGravatar Linus Torvalds
Ok, so this may be too much, but I'm just playing around with layout. It could be a runtime choice too, of course. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-20Print out only simplified depth profileGravatar Linus Torvalds
None of the colors, nothing like that. Just a gray fill and a plain black depth line. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-20Start fleshing out the dive printing a bit moreGravatar Linus Torvalds
Four dives per page sounds good. Maybe even six? But dangit, the default font choice for cairo printing sucks. And I need to learn about pango for actually printing the dive info. 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>
2011-09-20Fix Segmentation fault when trying to print an empty plot.Gravatar Riccardo Albertini
When printing an empty plot, the function was missing nullability check for 'current_dive'. Now the print of an empty plot results with an empty blank page. A better solution could be making unsensitive the Print entry in the menu, until a plot is loaded. Signed-off-by: Riccardo Albertini <ssirowain@gmail.com>
2011-09-13Make the printout look differentGravatar Linus Torvalds
Not *better* mint you. Just different. I suck at graphs. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-13Add the capability to print a dive profileGravatar Linus Torvalds
Ok, this is the ugliest f*&$ing printout I have ever seen in my life, but think of it as a "the concept of printing works" commit, and you'll be able to hold your lunch down and not gouge out your eyeballs with a spoon. Maybe. I'm just doing the cairo display as-is for the printout, which is a seriously bad idea. I need to not try to do colors etc, and instead of having white lines on a black background I just need to make thelines be black on white paper. But that would involve actually changing the current "plot()" routine, which is against the point of the exercise right now. This really is just a demonstration of how to add printing capabilities. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>