summaryrefslogtreecommitdiffstats
path: root/profile.c
diff options
context:
space:
mode:
Diffstat (limited to 'profile.c')
-rw-r--r--profile.c138
1 files changed, 35 insertions, 103 deletions
diff --git a/profile.c b/profile.c
index 2e100c30a..656c6bb6a 100644
--- a/profile.c
+++ b/profile.c
@@ -2,14 +2,12 @@
/* creates all the necessary data for drawing the dive profile
* uses cairo to draw it
*/
-#include <glib/gi18n.h>
+#include "gettext.h"
#include <limits.h>
+#include <string.h>
#include "dive.h"
#include "display.h"
-#if USE_GTK_UI
-#include "display-gtk.h"
-#endif
#include "divelist.h"
#include "profile.h"
@@ -27,24 +25,6 @@ static struct plot_data *last_pi_entry = NULL;
#define cairo_set_line_width_scaled(cr, w) \
cairo_set_line_width((cr), (w) * plot_scale);
-#if USE_GTK_UI
-
-/* keep the last used gc around so we can invert the SCALEX calculation in
- * order to calculate a time value for an x coordinate */
-static struct graphics_context last_gc;
-int x_to_time(double x)
-{
- int seconds = (x - last_gc.drawing_area.x) / last_gc.maxx * (last_gc.rightx - last_gc.leftx) + last_gc.leftx;
- return (seconds > 0) ? seconds : 0;
-}
-
-/* x offset into the drawing area */
-int x_abs(double x)
-{
- return x - last_gc.drawing_area.x;
-}
-#endif /* USE_GTK_UI */
-
/* debugging tool - not normally used */
static void dump_pi (struct plot_info *pi)
{
@@ -129,7 +109,7 @@ int evn_foreach(void (*callback)(const char *, int *, void *), void *data)
for (i = 0; i < evn_used; i++) {
/* here we display an event name on screen - so translate */
- callback(_(ev_namelist[i].ev_name), &ev_namelist[i].plot_ev, data);
+ callback(tr(ev_namelist[i].ev_name), &ev_namelist[i].plot_ev, data);
}
return i;
}
@@ -204,54 +184,6 @@ void setup_pp_limits(struct graphics_context *gc)
gc->bottomy = -gc->topy / 20;
}
-
-#if 0
-
-static void plot_smoothed_profile(struct graphics_context *gc, struct plot_info *pi)
-{
- int i;
- struct plot_data *entry = pi->entry;
-
- set_source_rgba(gc, SMOOTHED);
- move_to(gc, entry->sec, entry->smoothed);
- for (i = 1; i < pi->nr; i++) {
- entry++;
- line_to(gc, entry->sec, entry->smoothed);
- }
- cairo_stroke(gc->cr);
-}
-
-static void plot_minmax_profile_minute(struct graphics_context *gc, struct plot_info *pi,
- int index)
-{
- int i;
- struct plot_data *entry = pi->entry;
-
- set_source_rgba(gc, MINUTE);
- move_to(gc, entry->sec, entry->min[index]->depth);
- for (i = 1; i < pi->nr; i++) {
- entry++;
- line_to(gc, entry->sec, entry->min[index]->depth);
- }
- for (i = 1; i < pi->nr; i++) {
- line_to(gc, entry->sec, entry->max[index]->depth);
- entry--;
- }
- cairo_close_path(gc->cr);
- cairo_fill(gc->cr);
-}
-
-static void plot_minmax_profile(struct graphics_context *gc, struct plot_info *pi)
-{
- if (gc->printer)
- return;
- plot_minmax_profile_minute(gc, pi, 2);
- plot_minmax_profile_minute(gc, pi, 1);
- plot_minmax_profile_minute(gc, pi, 0);
-}
-
-#endif /* USE_GTK_UI */
-
int get_cylinder_pressure_range(struct graphics_context *gc)
{
gc->leftx = 0;
@@ -931,7 +863,7 @@ static void populate_pressure_information(struct dive *dive, struct divecomputer
int i, cylinderindex;
pr_track_t *track_pr[MAX_CYLINDERS] = {NULL, };
pr_track_t *current;
- gboolean missing_pr = FALSE;
+ bool missing_pr = FALSE;
cylinderindex = -1;
current = NULL;
@@ -1210,7 +1142,7 @@ struct divecomputer *select_dc(struct divecomputer *main)
}
static void plot_string(struct plot_data *entry, char *buf, int bufsize,
- int depth, int pressure, int temp, gboolean has_ndl)
+ int depth, int pressure, int temp, bool has_ndl)
{
int pressurevalue, mod, ead, end, eadd;
const char *depth_unit, *pressure_unit, *temp_unit, *vertical_speed_unit;
@@ -1218,22 +1150,22 @@ static void plot_string(struct plot_data *entry, char *buf, int bufsize,
double depthvalue, tempvalue, speedvalue;
depthvalue = get_depth_units(depth, NULL, &depth_unit);
- snprintf(buf, bufsize, _("D:%.1f %s"), depthvalue, depth_unit);
+ snprintf(buf, bufsize, tr("D:%.1f %s"), depthvalue, depth_unit);
if (prefs.show_time) {
memcpy(buf2, buf, bufsize);
- snprintf(buf, bufsize, _("%s\nT:%d:%02d"), buf2, FRACTION(entry->sec, 60));
+ snprintf(buf, bufsize, tr("%s\nT:%d:%02d"), buf2, FRACTION(entry->sec, 60));
}
if (pressure) {
pressurevalue = get_pressure_units(pressure, &pressure_unit);
memcpy(buf2, buf, bufsize);
- snprintf(buf, bufsize, _("%s\nP:%d %s"), buf2, pressurevalue, pressure_unit);
+ snprintf(buf, bufsize, tr("%s\nP:%d %s"), buf2, pressurevalue, pressure_unit);
}
if (temp) {
tempvalue = get_temp_units(temp, &temp_unit);
memcpy(buf2, buf, bufsize);
- snprintf(buf, bufsize, _("%s\nT:%.1f %s"), buf2, tempvalue, temp_unit);
+ snprintf(buf, bufsize, tr("%s\nT:%.1f %s"), buf2, tempvalue, temp_unit);
}
speedvalue = get_vertical_speed_units(abs(entry->speed), NULL, &vertical_speed_unit);
@@ -1241,19 +1173,19 @@ static void plot_string(struct plot_data *entry, char *buf, int bufsize,
/* Ascending speeds are positive, descending are negative */
if (entry->speed > 0)
speedvalue *= -1;
- snprintf(buf, bufsize, _("%s\nV:%.2f %s"), buf2, speedvalue, vertical_speed_unit);
+ snprintf(buf, bufsize, tr("%s\nV:%.2f %s"), buf2, speedvalue, vertical_speed_unit);
if (entry->ceiling) {
depthvalue = get_depth_units(entry->ceiling, NULL, &depth_unit);
memcpy(buf2, buf, bufsize);
- snprintf(buf, bufsize, _("%s\nCalculated ceiling %.0f %s"), buf2, depthvalue, depth_unit);
+ snprintf(buf, bufsize, tr("%s\nCalculated ceiling %.0f %s"), buf2, depthvalue, depth_unit);
if (prefs.calc_all_tissues){
int k;
for (k=0; k<16; k++){
if (entry->ceilings[k]){
depthvalue = get_depth_units(entry->ceilings[k], NULL, &depth_unit);
memcpy(buf2, buf, bufsize);
- snprintf(buf, bufsize, _("%s\nTissue %.0fmin: %.0f %s"), buf2, buehlmann_N2_t_halflife[k], depthvalue, depth_unit);
+ snprintf(buf, bufsize, tr("%s\nTissue %.0fmin: %.0f %s"), buf2, buehlmann_N2_t_halflife[k], depthvalue, depth_unit);
}
}
}
@@ -1264,62 +1196,62 @@ static void plot_string(struct plot_data *entry, char *buf, int bufsize,
if (entry->ndl) {
/* this is a safety stop as we still have ndl */
if (entry->stoptime)
- snprintf(buf, bufsize, _("%s\nSafetystop:%umin @ %.0f %s"), buf2, DIV_UP(entry->stoptime, 60),
+ snprintf(buf, bufsize, tr("%s\nSafetystop:%umin @ %.0f %s"), buf2, DIV_UP(entry->stoptime, 60),
depthvalue, depth_unit);
else
- snprintf(buf, bufsize, _("%s\nSafetystop:unkn time @ %.0f %s"), buf2,
+ snprintf(buf, bufsize, tr("%s\nSafetystop:unkn time @ %.0f %s"), buf2,
depthvalue, depth_unit);
} else {
/* actual deco stop */
if (entry->stoptime)
- snprintf(buf, bufsize, _("%s\nDeco:%umin @ %.0f %s"), buf2, DIV_UP(entry->stoptime, 60),
+ snprintf(buf, bufsize, tr("%s\nDeco:%umin @ %.0f %s"), buf2, DIV_UP(entry->stoptime, 60),
depthvalue, depth_unit);
else
- snprintf(buf, bufsize, _("%s\nDeco:unkn time @ %.0f %s"), buf2,
+ snprintf(buf, bufsize, tr("%s\nDeco:unkn time @ %.0f %s"), buf2,
depthvalue, depth_unit);
}
} else if (entry->in_deco) {
/* this means we had in_deco set but don't have a stop depth */
memcpy(buf2, buf, bufsize);
- snprintf(buf, bufsize, _("%s\nIn deco"), buf2);
+ snprintf(buf, bufsize, tr("%s\nIn deco"), buf2);
} else if (has_ndl) {
memcpy(buf2, buf, bufsize);
if (entry->ndl == -1)
- snprintf(buf, bufsize, _("%s\nNDL:-"), buf2);
+ snprintf(buf, bufsize, tr("%s\nNDL:-"), buf2);
else
- snprintf(buf, bufsize, _("%s\nNDL:%umin"), buf2, DIV_UP(entry->ndl, 60));
+ snprintf(buf, bufsize, tr("%s\nNDL:%umin"), buf2, DIV_UP(entry->ndl, 60));
}
if (entry->tts) {
memcpy(buf2, buf, bufsize);
- snprintf(buf, bufsize, _("%s\nTTS:%umin"), buf2, DIV_UP(entry->tts, 60));
+ snprintf(buf, bufsize, tr("%s\nTTS:%umin"), buf2, DIV_UP(entry->tts, 60));
}
if (entry->cns) {
memcpy(buf2, buf, bufsize);
- snprintf(buf, bufsize, _("%s\nCNS:%u%%"), buf2, entry->cns);
+ snprintf(buf, bufsize, tr("%s\nCNS:%u%%"), buf2, entry->cns);
}
if (prefs.pp_graphs.po2) {
memcpy(buf2, buf, bufsize);
- snprintf(buf, bufsize, _("%s\npO%s:%.2fbar"), buf2, UTF8_SUBSCRIPT_2, entry->po2);
+ snprintf(buf, bufsize, tr("%s\npO%s:%.2fbar"), buf2, UTF8_SUBSCRIPT_2, entry->po2);
}
if (prefs.pp_graphs.pn2) {
memcpy(buf2, buf, bufsize);
- snprintf(buf, bufsize, _("%s\npN%s:%.2fbar"), buf2, UTF8_SUBSCRIPT_2, entry->pn2);
+ snprintf(buf, bufsize, tr("%s\npN%s:%.2fbar"), buf2, UTF8_SUBSCRIPT_2, entry->pn2);
}
if (prefs.pp_graphs.phe) {
memcpy(buf2, buf, bufsize);
- snprintf(buf, bufsize, _("%s\npHe:%.2fbar"), buf2, entry->phe);
+ snprintf(buf, bufsize, tr("%s\npHe:%.2fbar"), buf2, entry->phe);
}
if (prefs.mod) {
mod = (int)get_depth_units(entry->mod, NULL, &depth_unit);
memcpy(buf2, buf, bufsize);
- snprintf(buf, bufsize, _("%s\nMOD:%d%s"), buf2, mod, depth_unit);
+ snprintf(buf, bufsize, tr("%s\nMOD:%d%s"), buf2, mod, depth_unit);
}
if (prefs.ead) {
ead = (int)get_depth_units(entry->ead, NULL, &depth_unit);
end = (int)get_depth_units(entry->end, NULL, &depth_unit);
eadd = (int)get_depth_units(entry->eadd, NULL, &depth_unit);
memcpy(buf2, buf, bufsize);
- snprintf(buf, bufsize, _("%s\nEAD:%d%s\nEND:%d%s\nEADD:%d%s"), buf2, ead, depth_unit, end, depth_unit, eadd, depth_unit);
+ snprintf(buf, bufsize, tr("%s\nEAD:%d%s\nEND:%d%s\nEADD:%d%s"), buf2, ead, depth_unit, end, depth_unit, eadd, depth_unit);
}
free(buf2);
}
@@ -1418,42 +1350,42 @@ void compare_samples(struct plot_data *e1, struct plot_data *e2, char *buf, int
avg_depth /= stop->sec-start->sec;
avg_speed /= stop->sec-start->sec;
- snprintf(buf, bufsize, _("%sT: %d:%02d min"), UTF8_DELTA, delta_time/60, delta_time%60);
+ snprintf(buf, bufsize, tr("%sT: %d:%02d min"), UTF8_DELTA, delta_time/60, delta_time%60);
memcpy(buf2, buf, bufsize);
depthvalue = get_depth_units(delta_depth, NULL, &depth_unit);
- snprintf(buf, bufsize, _("%s %sD:%.1f%s"), buf2, UTF8_DELTA, depthvalue, depth_unit);
+ snprintf(buf, bufsize, tr("%s %sD:%.1f%s"), buf2, UTF8_DELTA, depthvalue, depth_unit);
memcpy(buf2, buf, bufsize);
depthvalue = get_depth_units(min_depth, NULL, &depth_unit);
- snprintf(buf, bufsize, _("%s %sD:%.1f%s"), buf2, UTF8_DOWNWARDS_ARROW, depthvalue, depth_unit);
+ snprintf(buf, bufsize, tr("%s %sD:%.1f%s"), buf2, UTF8_DOWNWARDS_ARROW, depthvalue, depth_unit);
memcpy(buf2, buf, bufsize);
depthvalue = get_depth_units(max_depth, NULL, &depth_unit);
- snprintf(buf, bufsize, _("%s %sD:%.1f %s"), buf2, UTF8_UPWARDS_ARROW, depthvalue, depth_unit);
+ snprintf(buf, bufsize, tr("%s %sD:%.1f %s"), buf2, UTF8_UPWARDS_ARROW, depthvalue, depth_unit);
memcpy(buf2, buf, bufsize);
depthvalue = get_depth_units(avg_depth, NULL, &depth_unit);
- snprintf(buf, bufsize, _("%s %sD:%.1f%s\n"), buf2, UTF8_AVERAGE, depthvalue, depth_unit);
+ snprintf(buf, bufsize, tr("%s %sD:%.1f%s\n"), buf2, UTF8_AVERAGE, depthvalue, depth_unit);
memcpy(buf2, buf, bufsize);
speedvalue = get_depth_units(min_speed, NULL, &depth_unit);
- snprintf(buf, bufsize, _("%s%sV:%.2f%s/s"), buf2, UTF8_DOWNWARDS_ARROW, speedvalue, depth_unit);
+ snprintf(buf, bufsize, tr("%s%sV:%.2f%s/s"), buf2, UTF8_DOWNWARDS_ARROW, speedvalue, depth_unit);
memcpy(buf2, buf, bufsize);
speedvalue = get_depth_units(max_speed, NULL, &depth_unit);
- snprintf(buf, bufsize, _("%s %sV:%.2f%s/s"), buf2, UTF8_UPWARDS_ARROW, speedvalue, depth_unit);
+ snprintf(buf, bufsize, tr("%s %sV:%.2f%s/s"), buf2, UTF8_UPWARDS_ARROW, speedvalue, depth_unit);
memcpy(buf2, buf, bufsize);
speedvalue = get_depth_units(avg_speed, NULL, &depth_unit);
- snprintf(buf, bufsize, _("%s %sV:%.2f%s/s"), buf2, UTF8_AVERAGE, speedvalue, depth_unit);
+ snprintf(buf, bufsize, tr("%s %sV:%.2f%s/s"), buf2, UTF8_AVERAGE, speedvalue, depth_unit);
memcpy(buf2, buf, bufsize);
/* Only print if gas has been used */
if (bar_used) {
pressurevalue = get_pressure_units(bar_used, &pressure_unit);
memcpy(buf2, buf, bufsize);
- snprintf(buf, bufsize, _("%s %sP:%d %s"), buf2, UTF8_DELTA, pressurevalue, pressure_unit);
+ snprintf(buf, bufsize, tr("%s %sP:%d %s"), buf2, UTF8_DELTA, pressurevalue, pressure_unit);
}
free(buf2);