This enables all languages for the moment - let's see if we can get them
all ready for the 3.1 release.
It also fixes the use of \% instead of %% in one of the strings.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The window which holds the custom print options tab appears to have
unchangeable dimensions on Windows OS (unless hacked in some way).
This makes the sliders in the custom tab not accessible unless
we add the entire dialog into a GtkScrolledWindow and return that
for the "create-custom-widget" event.
The patch also makes the contents of the "Layout Options" frame
packed vertically (with a GtkVBox) instead of horizontally, so that
the entire tab contents are "mostly" scrollable vertically instead
of horizontally.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
While colorButton defaults to "color" in first access to print menu, it seems
preferable to keep the last state selected by the user. At least until exit session.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
92.5 is wrong the correct divisor is its inverse number 108.1
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
While it makes sense for the program to have a 7.5% fixed header, from a
user perspectice this is just odd. So instead we now have the notes,
profile and tank data sizes add up to 100% and scale the information when
it is combined with the header.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
We can trim the printout with only profile and tanks sliders, so add an
insensitive scale for notes which report the percentage that it's is
getting while changing the others, for informative purposes.
Initialize default values for print_options struct.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Gtk complains if there is no GCallback to connect.
Fixes too a bug with gtk_toggle_button_set_active for radio5.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Define a new frame wich will englobe the layout options.
1.- Move to this frame the color profile printing by Amit
2.- Add an option which switches the position of the profile and a
predefined block comprensive of header, tanks data and notes.
- Divide print() in two macros PROFILE_BLOCK and NOTES_BLOCK
- Add a gboolean to print_options. If unselected (default) we
get the actual disposition. If selected, switches blocks.
3.- Add two buttons with labels to set the height of the profile, and tanks.
We select the percentage of layout occupied by each option, reserving
7% for the header (non adjustable), and assign the rest to notes.
- Values in % have got hardcoded min/max (e.g. being the
profile a major feature of subsurface, would be meaningless
make it < 37%)
- The values are initialised to the actual ones, so leaving
them untouched defaults to the old printout.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The callback function for switching colour printing on/off was
registered after the initial activation of the button. This meant the
first attempt to print was compromised. We move the registration so that
printing works as the user specifies from the first attempt.
Tested by printing both B/W and colour images to file with minimal mouse
clicks.
Spotted by Salva - thanks.
Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
- Add a button and callback to the print dialog to let the user select
color printing.
- Add a state variable to the options struct to track the users choice.
- Use a darker color for the grid on dive plot; that way we can see it.
- Default to use color printing.
Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
draw_table():
When get_dive_for_printing() returns NULL, instead of
breaking, we should 'continue' trough the entire loop. Otherwise
the paginate() handler will be called dive_table.nr times, until
it returns TRUE.
Fixes a bug where, for example one selected dive can end up allocating
dive_table.nr pages for printing.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In 'table print' for some launguages the table header titles can span
on two lines and the text on the second line ends up overlapping with
the table border. With this patch two lines are reserved for the table
header instead of one.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Strangely on Linux everything looks fine, but Windows shows the header
two times on the first page, which is due to the pango_cairo_show_layout()
function being called both for the 'paginating' and 'regular' stages
in show_table_header().
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
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>
A "\n" was giving 2 lines height for the layout.
Wipping it out makes unnecesary the *2 divisor.
As there may be wrapped strings in tank we need to take
account of this height. There is no need, really, to get the
height of the gasmix or gas_consumed strings, as they are
"semi-fixed" size, but under some locales and imperial units they
could be wrapped too.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
"Dive details" doesn't really capture what this is about and it got very
odd translations. So we just repeat the "Print type" text - this avoids
needing a new translation, too.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Instead of a fixed number of dives per page we are now using the paginate
callback to dynamically figure out how many pages we need and which dive to
start each page with.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Instead of odd hard coded offsets we evaluate the height of a single line and
modify the height per row (and the vertical positioning of the text within that
row) by a fraction of that height.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This appears to make the table layout much easier to follow, much easier
to modify and it has the edit benefit of working in my limited testing.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
1.- On draw_table() we now set the layout, make the scaling *0.5, and the
make traslations row by row.
2.- Wipe out print_table_header and print_table as they now don't make
anything but call show_table which now we can call directly from
draw_table.
3.- Modify show_table to get account of the height of the higher column
and return it.
4.- The frame is now plot with an auxiliar func. directly from draw_table.
With this changes we have a variable height pattern which lets us have
complete the more sensible info (date, time, location, ...) without
wrapping it to fit in the predefined width of the layout.
The printout is tighter than old one so we can print 35 dives in a page,
leaving enough room at the bottom to fit some extra-large (three lines or
more) dives' info. Have increased *1.2 the size of the fonts as they got
too little with the change in DPI. Wrap the header strings to limit the
impact of different string sizes in the different supported languages.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
print_tanks():
It seems the macro call NC_("Amount","Gas Used") generates an entry in the
.po file that then isn't matched at run time, which makes the bg_BG print
have "Gas Used" in english instead of the translated text (which is
already present in other places).
On the other hand if we use N_ here (only mark it), the printed text
is translated correctly.
[Dirk Hohndel: added GETTEXT comment in code and rephrased commit message]
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
print.c has a lot of defined buffer sizes, which do not consider
UTF-8 expansion. gettext() with UTF-8 can inflate a string up to
2x the length (with 2byte characters).
So if you set a buffer with length, say 20 bytes, lets see what happens:
divenr[20];
snprintf(divenr, sizeof(divenr), _("Dive #%d - "), dive->number);
But wait, in Russian "Dive" (which in latin text is "Pogrugenie")
ends up with 10 cyrilic characters (20 bytes), so there is already
buffer overflow here and snprintf() kicks in to corrupt the string.
In matters of truncation snprintf() isn't UTF-8 safe.
So if the buffer size happens to be less of the requested string
to be put in there, the truncation can corrupt a trailing unicode
character.
For now, lets try fixing these by expanding the buffer sizes.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Modify for use said pango function, suposes changing the way of doing things:
Before this we were moving along the cr (cairo object) and creating and closing a layout
for each line we printed. To use this func we need to create a layout (say for tanks),
and then we move along the layout getting the distance with the get_extents func.
As the layout is set and passed to the auxiliary functions there's no need to pass some
values we were passing.
Clean a bit the positioning of SAC, CNS and OTU which were out of the scope of the
change.
Changes to draw_table() are wider and unclear as we have to change from a fixed
number of dives (25 actually) to a variable one. Not patched still.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The context for this text is Duration, not Time. The translation for
string Time was impossible when considering that on one location it was
used to mean 'duration' and on the other it meant 'time'.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
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>
Populate during dive fixup as the maximum depth shown by all the
divecomputers. Use this value (instead of the one in the first
divecomputer) in printing, statistics, etc.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Increase the size of "buffer" to 160 bytes. This was causing
a problem with the first call to pango_layout_text(), where
for the "bg_BG" locale, not enought space was allocated for the
month name, the translation of "dive" and the other values.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
- Set parameters for scaling the layout ( w and h_scale_factor),
number of prints per page and rotation.
- Let draw_page() manage the whole print whith the received params.
- Remove draw_oneperpage() as it's unused.
- Use the w_scale_factor for scaling the fonts.
- Change option text in the GTK menu.
TODO:
- A GTK menu which let the user select the print params directly or ...
- Introduce new predefined options in the printing menu.
- Modify draw_page() for printing "landscaped" 6 dives if selected.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
One is about the amount, the other about the specific type of gar that was
used.
Reported-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Changes in print_weight had displaced the plot of next prints.
This fix the displacement using cairo_save/restore.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The old code was computing locations based on relative portions of the
available height. The correct thing to do, (and done here in the
patch), is to advance by the logical height of rendered text each
time.
What's stll missing is anything to guarantee that the text drawn will
fit in the box. The correct answer here is along one of two lines:
1. Use the logical text extents to decide what size to draw the box.
2. Use a pre-computed box size and choose a font size that will fit
Either approach will involve a fairly substantial reworking of the
rendering code in print.c.
Signed-off-by: Carl Worth <cworth@cworth.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The print_weight_data function was making several cairo_translate
calls and then doing some final cairo_translate calls with the goal of
manually undoing any changes to cairo's state. Obviously, this is
fragile.
Cairo provides save/restore calls which solve this problem in a robust
way. Switch to using these instead.
Signed-off-by: Carl Worth <cworth@cworth.org>
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>
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>
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>
If there's no weightsystem description, as in most imported
dives, print a literal "unknown" instead of null pointer
or blank.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Good night.
Here is the corrected patch. It would need to be tested in other
languages because of the size of the units string in imperial.
It performs well in spanish and (I supose) in english, but if a language
make grow the string it could easily be wrapped and make a mess.
On Mon, Jan 07, 2013 at 10:50:31AM -0800, Dirk Hohndel wrote:
>
> Thanks. I appreciate your patience with this. I'm very happy for every
> contibutor we have and I am especially happy to have someone working on
> the print layout code.
>
Thaks to all of you, Dirk, for all your efforts in the gui, the deco, the
planner ... That's the real hard work.
Regards.
Salva.
From 51dace93a1dae68960fee2229d4f274e8e4543fd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Salvador=20Cu=C3=B1at?= <salvador.cunat@gmail.com>
Date: Mon, 7 Jan 2013 22:58:09 +0100
Subject: [PATCH] Add SAC to the printout
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- Add the SAC to the printout, displacing the less utils OTUs.
- Substitute repetitive math operations with variables.
- Correct bad translations (correct with *0.90 scaling).
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If we print out the pressure difference (because we do not have a cylinder
size), we didn't initialize the precision. We should print out pressures
without decimals.
The attached patch fixes that, and also avoids a NULL pointer printout
(which on Linux will just print out "(null)") if there is no cylinder
type descriptor string. It also cleans things up a bit and uses the
"cyl" pointer instead of repeating the "dive->cylinder[n]" thing.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The cylinder information in the printouts was wrong in many ways. As
Dirk noted, it didn't work at all for air-integrated computers that
had the pressures in the samples, but the math was also confusing and
wrong.
This should fix it.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
For dives with more than 4 cylinders, the frame got very crowded and we
needed a magnifier to see the numbers.
If we used more than four tanks, let's put the info in another frame, if not, print
the OTUs, the maxcns and the weight sytem in the new frame.
There is still room for two more short data.
Changed naming of nitrox and trimix mixes.
Changed cylinder description.
There are issues with the size of some translations.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
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>
Add info of the used tanks, which isn't displayed by the
dive plot, with a new function.
The relative width and height are fixed in print(), so the function needs:
- Modify the font size depending on the number of tanks.
- As it uses translations, return to the original coords when ends.
Modify print() acordingly with the new function.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Create a function show_dive_header() and show_dive_notes() as a first step
to introduce other infos in diferent funcs.
Modify print() acordingly to the new funcs.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
- Create a grid for each dive printed.
- We change justify "center" to "left" wich contributes to diferentiate each component of the array.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This extends on our current tooltip logic (which shows events when you
mouse over them) to show tooltips for the whole profile area.
If you mouse over an event, that is still shown in the tooltip, but
even in the absense of events, the tooltip will be active, and mousing
over the profile area will show the time, depth and pressure.
This can certainly be improved upon further, but even in this form it is
useful.
Fixes#9
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Simply add a dive option on bigger surface, whith bigger fonts.
The size isn't A4 nor A5, but the size used by some popular paper
divelogs.
The modification performs better if we transpose the profile and
the text of the dive, because, if the notes are very brief,we get
an excess of white space at the bottom of the print.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This looks like a massive commit mainly because of the line number changes
in the .po files. That sadly hides what really happened here:
- the places where we manually build dates have now been localized
- the one place where we did the English "calculated plural" has been
modified so that it now can be correctly translated (in English this
just adds an 's' to the noun if the number is != 1 - in other languages
this tends to be much more complicated)
I then updated the two German translations to take advantage of the new
constructs. And while I was at it, I changed the translation Trip->Gruppe
to Trip->Reise as that seemed much more appropriate.
I also fixed another error in the German translation where I translated
"dive time" as "Startzeit" - but in the context it was "Dauer".
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>