aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-10-06 10:57:16 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-10-06 10:57:16 -0700
commitb3490213f42ed63bc4b05b37bcfc12809f2d432c (patch)
treed56ede6f1ea8d20c2120eba2b9ca705927a77913
parent92d8978ab4ad980397883b50d0e7bc81d2bf5f73 (diff)
parent70352c3962cf3b4379590326cdc489ac0543f7e9 (diff)
downloadsubsurface-b3490213f42ed63bc4b05b37bcfc12809f2d432c.tar.gz
Merge branch 'glib-removal-hack'
Fix obvious merge issue in Rules.mk Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--Configure.mk26
-rw-r--r--Makefile1
-rw-r--r--Rules.mk2
-rw-r--r--deco.c2
-rw-r--r--dive.c35
-rw-r--r--dive.h56
-rw-r--r--divelist.c67
-rw-r--r--download-dialog.c2
-rw-r--r--equipment.c38
-rw-r--r--file.c14
-rw-r--r--file.h2
-rw-r--r--gettext.h9
-rw-r--r--gettextfromc.cpp19
-rw-r--r--gettextfromc.h15
-rw-r--r--gtk-gui.c2
-rw-r--r--info.c295
-rw-r--r--info.h4
-rw-r--r--libdivecomputer.c58
-rw-r--r--libdivecomputer.h4
-rw-r--r--linux.c10
-rw-r--r--macos.c14
-rw-r--r--main.cpp4
-rw-r--r--parse-xml.c132
-rw-r--r--planner-gtk.c1
-rw-r--r--planner.c80
-rw-r--r--planner.h5
-rw-r--r--profile.c138
-rw-r--r--qt-gui.cpp30
-rw-r--r--qt-ui/diveplanner.cpp4
-rw-r--r--qt-ui/diveplanner.h3
-rw-r--r--qt-ui/maintab.cpp6
-rw-r--r--qt-ui/mainwindow.cpp5
-rw-r--r--qt-ui/subsurfacewebservices.cpp6
-rw-r--r--qthelper.cpp63
-rw-r--r--qthelper.h5
-rw-r--r--save-xml.c8
-rw-r--r--statistics.c35
-rw-r--r--subsurfacestartup.c16
-rw-r--r--time.c1
-rw-r--r--uemis-downloader.c159
-rw-r--r--uemis.c41
-rw-r--r--webservice.c1
-rw-r--r--windows.c6
43 files changed, 629 insertions, 795 deletions
diff --git a/Configure.mk b/Configure.mk
index ba5ff018c..9e9a2ba0e 100644
--- a/Configure.mk
+++ b/Configure.mk
@@ -113,20 +113,14 @@ endif
RCC = $(shell $(PKGCONFIG) --variable=rcc_location QtGui)
#endif
-# we need GLIB2CFLAGS for gettext
-QTCXXFLAGS = $(shell $(PKGCONFIG) --cflags $(QT_MODULES)) $(GLIB2CFLAGS)
+QTCXXFLAGS = $(shell $(PKGCONFIG) --cflags $(QT_MODULES))
LIBQT = $(shell $(PKGCONFIG) --libs $(QT_MODULES))
ifneq ($(filter reduce_relocations, $(shell $(PKGCONFIG) --variable qt_config $(QT_CORE))), )
QTCXXFLAGS += -fPIE
endif
-LIBGTK = $(shell $(PKGCONFIG) --libs gtk+-2.0 glib-2.0)
-ifneq (,$(filter $(UNAME),linux kfreebsd gnu))
- LIBGCONF2 = $(shell $(PKGCONFIG) --libs gconf-2.0)
- GCONF2CFLAGS = $(shell $(PKGCONFIG) --cflags gconf-2.0)
-else ifeq ($(UNAME), darwin)
+ifeq ($(UNAME), darwin)
LDFLAGS += -framework CoreFoundation -framework CoreServices
- GTK_MAC_BUNDLER = ~/.local/bin/gtk-mac-bundler
endif
LIBDIVECOMPUTERCFLAGS = $(LIBDIVECOMPUTERINCLUDES)
@@ -135,13 +129,7 @@ LIBDIVECOMPUTER = $(LIBDIVECOMPUTERARCHIVE) $(LIBUSB)
LIBXML2 = $(shell $(XML2CONFIG) --libs)
LIBXSLT = $(shell $(XSLCONFIG) --libs)
XML2CFLAGS = $(shell $(XML2CONFIG) --cflags)
-GLIB2CFLAGS = $(shell $(PKGCONFIG) --cflags glib-2.0)
-GTKCFLAGS += $(shell $(PKGCONFIG) --cflags gtk+-2.0)
XSLCFLAGS = $(shell $(XSLCONFIG) --cflags)
-OSMGPSMAPFLAGS += $(shell $(PKGCONFIG) --cflags osmgpsmap 2> /dev/null)
-LIBOSMGPSMAP += $(shell $(PKGCONFIG) --libs osmgpsmap 2> /dev/null)
-LIBSOUPCFLAGS = $(shell $(PKGCONFIG) --cflags libsoup-2.4)
-LIBSOUP = $(shell $(PKGCONFIG) --libs libsoup-2.4)
LIBZIP = $(shell $(PKGCONFIG) --libs libzip 2> /dev/null)
ZIPFLAGS = $(strip $(shell $(PKGCONFIG) --cflags libzip 2> /dev/null))
@@ -171,20 +159,10 @@ configure $(CONFIGURE): Configure.mk
MOC = $(MOC)\\\
UIC = $(UIC)\\\
RCC = $(RCC)\\\
- LIBGTK = $(LIBGTK)\\\
- GTKCFLAGS = $(GTKCFLAGS)\\\
- LIBGCONF2 = $(LIBGCONF2)\\\
- GCONF2CFLAGS = $(GCONF2CFLAGS)\\\
- GTK_MAC_BUNDLER = $(GTK_MAC_BUNDLER)\\\
LIBXML2 = $(LIBXML2)\\\
LIBXSLT = $(LIBXSLT)\\\
XML2CFLAGS = $(XML2CFLAGS)\\\
- GLIB2CFLAGS = $(GLIB2CFLAGS)\\\
XSLCFLAGS = $(XSLCFLAGS)\\\
- OSMGPSMAPFLAGS = $(OSMGPSMAPFLAGS)\\\
- LIBOSMGPSMAP = $(LIBOSMGPSMAP)\\\
- LIBSOUPCFLAGS = $(LIBSOUPCFLAGS)\\\
- LIBSOUP = $(LIBSOUP)\\\
LIBZIP = $(LIBZIP)\\\
ZIPFLAGS = $(ZIPFLAGS)\\\
LIBSQLITE3 = $(LIBSQLITE3)\\\
diff --git a/Makefile b/Makefile
index 5fac71f59..5c44073a8 100644
--- a/Makefile
+++ b/Makefile
@@ -79,6 +79,7 @@ SOURCES = \
uemis.c \
uemis-downloader.c \
libdivecomputer.c \
+ gettextfromc.cpp \
qthelper.cpp \
qt-ui/simplewidgets.cpp \
qt-ui/tableview.cpp \
diff --git a/Rules.mk b/Rules.mk
index 1f20e4477..7f30a84dd 100644
--- a/Rules.mk
+++ b/Rules.mk
@@ -48,7 +48,7 @@ CREATOR_FILES = $(NAME).config $(NAME).creator $(NAME).files $(NAME).includes
all: $(TARGET) doc
-$(TARGET): gen_version_file $(UIC_HEADERS) $(ALL_OBJS) $(MSGOBJS) $(INFOPLIST)
+$(TARGET): gen_version_file $(UIC_HEADERS) $(ALL_OBJS) $(INFOPLIST)
@$(PRETTYECHO) ' LINK' $(TARGET)
$(COMPILE_PREFIX)$(CXX) $(LDFLAGS) -o $(TARGET) $(ALL_OBJS) $(LIBS)
diff --git a/deco.c b/deco.c
index c7ad61660..788c258fe 100644
--- a/deco.c
+++ b/deco.c
@@ -249,7 +249,7 @@ double restore_deco_state(char *data)
return tissue_tolerance;
}
-unsigned int deco_allowed_depth(double tissues_tolerance, double surface_pressure, struct dive *dive, gboolean smooth)
+unsigned int deco_allowed_depth(double tissues_tolerance, double surface_pressure, struct dive *dive, bool smooth)
{
unsigned int depth;
double pressure_delta;
diff --git a/dive.c b/dive.c
index 1d8986ab9..554bfd54b 100644
--- a/dive.c
+++ b/dive.c
@@ -2,8 +2,7 @@
/* maintains the internal dive list structure */
#include <string.h>
#include <stdio.h>
-#include <glib/gi18n.h>
-
+#include "gettext.h"
#include "dive.h"
void add_event(struct divecomputer *dc, int time, int type, int flags, int value, const char *name)
@@ -41,15 +40,15 @@ int get_pressure_units(unsigned int mb, const char **units)
switch (units_p->pressure) {
case PASCAL:
pressure = mb * 100;
- unit = _("pascal");
+ unit = tr("pascal");
break;
case BAR:
pressure = (mb + 500) / 1000;
- unit = _("bar");
+ unit = tr("bar");
break;
case PSI:
pressure = mbar_to_PSI(mb);
- unit = _("psi");
+ unit = tr("psi");
break;
}
if (units)
@@ -85,12 +84,12 @@ double get_volume_units(unsigned int ml, int *frac, const char **units)
switch (units_p->volume) {
case LITER:
vol = ml / 1000.0;
- unit = _("l");
+ unit = tr("l");
decimals = 1;
break;
case CUFT:
vol = ml_to_cuft(ml);
- unit = _("cuft");
+ unit = tr("cuft");
decimals = 2;
break;
}
@@ -111,12 +110,12 @@ double get_depth_units(unsigned int mm, int *frac, const char **units)
switch (units_p->length) {
case METERS:
d = mm / 1000.0;
- unit = _("m");
+ unit = tr("m");
decimals = d < 20;
break;
case FEET:
d = mm_to_feet(mm);
- unit = _("ft");
+ unit = tr("ft");
decimals = 0;
break;
}
@@ -137,11 +136,11 @@ double get_vertical_speed_units(unsigned int mms, int *frac, const char **units)
switch (units_p->length) {
case METERS:
d = mms / 1000.0 * time_factor;
- unit = _((units_p->vertical_speed_time == MINUTES) ? "m/min" : "m/s");
+ unit = tr((units_p->vertical_speed_time == MINUTES) ? "m/min" : "m/s");
break;
case FEET:
d = mm_to_feet(mms) * time_factor;
- unit = _((units_p->vertical_speed_time == MINUTES) ? "ft/min" : "ft/s");
+ unit = tr((units_p->vertical_speed_time == MINUTES) ? "ft/min" : "ft/s");
break;
}
if (frac)
@@ -160,11 +159,11 @@ double get_weight_units(unsigned int grams, int *frac, const char **units)
if (units_p->weight == LBS) {
value = grams_to_lbs(grams);
- unit = _("lbs");
+ unit = tr("lbs");
decimals = 0;
} else {
value = grams / 1000.0;
- unit = _("kg");
+ unit = tr("kg");
decimals = 1;
}
if (frac)
@@ -481,7 +480,7 @@ static void sanitize_cylinder_info(struct dive *dive)
}
/* some events should never be thrown away */
-static gboolean is_potentially_redundant(struct event *event)
+static bool is_potentially_redundant(struct event *event)
{
if (!strcmp(event->name, "gaschange"))
return FALSE;
@@ -960,7 +959,7 @@ static char *merge_text(const char *a, const char *b)
res = malloc(strlen(a) + strlen(b) + 32);
if (!res)
return (char *)a;
- sprintf(res, _("(%s) or (%s)"), a, b);
+ sprintf(res, tr("(%s) or (%s)"), a, b);
return res;
}
@@ -1585,7 +1584,7 @@ static int likely_same_dive(struct dive *a, struct dive *b)
* merges almost exact duplicates - something that happens easily
* with overlapping dive downloads.
*/
-struct dive *try_to_merge(struct dive *a, struct dive *b, gboolean prefer_downloaded)
+struct dive *try_to_merge(struct dive *a, struct dive *b, bool prefer_downloaded)
{
if (likely_same_dive(a, b))
return merge_dives(a, b, 0, prefer_downloaded);
@@ -1810,7 +1809,7 @@ static void join_dive_computers(struct divecomputer *res, struct divecomputer *a
remove_redundant_dc(res, prefer_downloaded);
}
-struct dive *merge_dives(struct dive *a, struct dive *b, int offset, gboolean prefer_downloaded)
+struct dive *merge_dives(struct dive *a, struct dive *b, int offset, bool prefer_downloaded)
{
struct dive *res = alloc_dive();
struct dive *dl = NULL;
@@ -1877,7 +1876,7 @@ struct dive *find_dive_including(timestamp_t when)
return NULL;
}
-gboolean dive_within_time_range(struct dive *dive, timestamp_t when, timestamp_t offset)
+bool dive_within_time_range(struct dive *dive, timestamp_t when, timestamp_t offset)
{
return when - offset <= dive->when && dive->when + dive->duration.seconds <= when + offset;
}
diff --git a/dive.h b/dive.h
index 3b0df197c..f2d8f236d 100644
--- a/dive.h
+++ b/dive.h
@@ -5,9 +5,8 @@
#include <stdint.h>
#include <time.h>
#include <math.h>
+#include <sys/param.h>
-#include <glib.h>
-#include <glib/gstdio.h>
#include <libxml/tree.h>
#include <libxslt/transform.h>
@@ -18,8 +17,16 @@ extern "C" {
#else
#if __STDC_VERSION__ >= 199901L
#include <stdbool.h>
+#define TRUE true
+#define FALSE false
#else
typedef int bool;
+#ifndef TRUE
+#define TRUE 1
+#endif
+#ifndef FALSE
+#define FALSE 0
+#endif
#endif
#endif
@@ -99,7 +106,7 @@ extern int dive_mask;
* We don't actually use these all yet, so maybe they'll change, but
* I made a number of types as guidelines.
*/
-typedef gint64 timestamp_t;
+typedef int64_t timestamp_t;
typedef struct {
int seconds;
@@ -257,7 +264,7 @@ static inline int get_he(const struct gasmix *mix)
return mix->he.permille;
}
-static inline gboolean is_air(int o2, int he)
+static inline bool is_air(int o2, int he)
{
return (he == 0) && (o2 == 0 || ((o2 >= O2_IN_AIR - 1) && (o2 <= O2_IN_AIR + 1)));
}
@@ -279,7 +286,7 @@ struct sample {
duration_t ndl;
duration_t stoptime;
depth_t stopdepth;
- gboolean in_deco;
+ bool in_deco;
int cns;
int po2;
};
@@ -296,7 +303,7 @@ struct event {
struct event *next;
duration_t time;
int type, flags, value;
- gboolean deleted;
+ bool deleted;
char name[];
};
@@ -355,7 +362,7 @@ struct dive {
dive_trip_t *divetrip;
struct dive *next, **pprev;
int selected;
- gboolean downloaded;
+ bool downloaded;
timestamp_t when;
char *location;
char *notes;
@@ -394,7 +401,7 @@ static inline void copy_gps_location(struct dive *from, struct dive *to)
}
}
-static inline int get_surface_pressure_in_mbar(const struct dive *dive, gboolean non_null)
+static inline int get_surface_pressure_in_mbar(const struct dive *dive, bool non_null)
{
int mbar = dive->surface_pressure.mbar;
if (!mbar && non_null)
@@ -576,16 +583,17 @@ static inline struct dive *get_dive_by_diveid(uint32_t diveid, uint32_t deviceid
return NULL;
}
extern struct dive *find_dive_including(timestamp_t when);
-extern gboolean dive_within_time_range(struct dive *dive, timestamp_t when, timestamp_t offset);
+extern bool dive_within_time_range(struct dive *dive, timestamp_t when, timestamp_t offset);
struct dive *find_dive_n_near(timestamp_t when, int n, timestamp_t offset);
/* Check if two dive computer entries are the exact same dive (-1=no/0=maybe/1=yes) */
extern int match_one_dc(struct divecomputer *a, struct divecomputer *b);
+extern double ascii_strtod(char *, char **);
extern void parse_xml_init(void);
extern void parse_xml_buffer(const char *url, const char *buf, int size, struct dive_table *table, char **error);
extern void parse_xml_exit(void);
-extern void set_filename(const char *filename, gboolean force);
+extern void set_filename(const char *filename, bool force);
extern int parse_dm4_buffer(const char *url, const char *buf, int size, struct dive_table *table, char **error);
@@ -606,7 +614,7 @@ extern void show_yearly_stats(void);
extern void update_dive(struct dive *new_dive);
extern void save_dives(const char *filename);
-extern void save_dives_logic(const char *filename, gboolean select_only);
+extern void save_dives_logic(const char *filename, bool select_only);
extern void save_dive(FILE *f, struct dive *dive);
extern xsltStylesheetPtr get_stylesheet(const char *name);
@@ -625,8 +633,8 @@ extern void finish_sample(struct divecomputer *dc);
extern void sort_table(struct dive_table *table);
extern struct dive *fixup_dive(struct dive *dive);
extern unsigned int dc_airtemp(struct divecomputer *dc);
-extern struct dive *merge_dives(struct dive *a, struct dive *b, int offset, gboolean prefer_downloaded);
-extern struct dive *try_to_merge(struct dive *a, struct dive *b, gboolean prefer_downloaded);
+extern struct dive *merge_dives(struct dive *a, struct dive *b, int offset, bool prefer_downloaded);
+extern struct dive *try_to_merge(struct dive *a, struct dive *b, bool prefer_downloaded);
extern void renumber_dives(int nr);
extern void copy_samples(struct dive *s, struct dive *d);
@@ -635,7 +643,7 @@ extern void add_event(struct divecomputer *dc, int time, int type, int flags, in
/* UI related protopypes */
-extern void report_error(GError* error);
+// extern void report_error(GError* error);
extern void add_cylinder_description(cylinder_type_t *);
extern void add_weightsystem_description(weightsystem_t *);
@@ -647,14 +655,14 @@ extern int evn_foreach(void (*callback)(const char *, int *, void *), void *data
extern void clear_events(void);
extern int add_new_dive(struct dive *dive);
-extern gboolean edit_trip(dive_trip_t *trip);
-extern int edit_dive_info(struct dive *dive, gboolean newdive);
+extern bool edit_trip(dive_trip_t *trip);
+extern int edit_dive_info(struct dive *dive, bool newdive);
extern int edit_multi_dive_info(struct dive *single_dive);
extern void dive_list_update_dives(void);
extern void flush_divelist(struct dive *dive);
extern void set_dc_nickname(struct dive *dive);
-extern void set_autogroup(gboolean value);
+extern void set_autogroup(bool value);
extern int total_weight(struct dive *);
#define DIVE_ERROR_PARSE 1
@@ -687,17 +695,17 @@ typedef enum {
extern const char *existing_filename;
extern const char *subsurface_gettext_domainpath(char *);
-extern gboolean subsurface_os_feature_available(os_feature_t);
-extern gboolean subsurface_launch_for_uri(const char *);
-extern void subsurface_command_line_init(gint *, gchar ***);
-extern void subsurface_command_line_exit(gint *, gchar ***);
+extern bool subsurface_os_feature_available(os_feature_t);
+extern bool subsurface_launch_for_uri(const char *);
+extern void subsurface_command_line_init(int *, char ***);
+extern void subsurface_command_line_exit(int *, char ***);
#define FRACTION(n,x) ((unsigned)(n)/(x)),((unsigned)(n)%(x))
extern double add_segment(double pressure, const struct gasmix *gasmix, int period_in_seconds, int setpoint, const struct dive *dive);
extern void clear_deco(double surface_pressure);
extern void dump_tissues(void);
-extern unsigned int deco_allowed_depth(double tissues_tolerance, double surface_pressure, struct dive *dive, gboolean smooth);
+extern unsigned int deco_allowed_depth(double tissues_tolerance, double surface_pressure, struct dive *dive, bool smooth);
extern void set_gf(short gflow, short gfhigh);
extern void cache_deco_state(double, char **datap);
extern double restore_deco_state(char *data);
@@ -708,7 +716,7 @@ struct divedatapoint {
int o2;
int he;
int po2;
- gboolean entered;
+ bool entered;
struct divedatapoint *next;
};
@@ -730,7 +738,7 @@ void free_dps(struct divedatapoint *dp);
void get_gas_string(int o2, int he, char *buf, int len);
struct divedatapoint *create_dp(int time_incr, int depth, int o2, int he, int po2);
void dump_plan(struct diveplan *diveplan);
-void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, bool add_deco, char **error_string_p);
+void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, bool add_deco, const char **error_string_p);
void delete_single_dive(int idx);
struct event *get_next_event(struct event *event, char *name);
diff --git a/divelist.c b/divelist.c
index d5ee9b71a..e0ad204b7 100644
--- a/divelist.c
+++ b/divelist.c
@@ -38,7 +38,7 @@
#include <string.h>
#include <time.h>
#include <math.h>
-#include <glib/gi18n.h>
+#include "gettext.h"
#include <assert.h>
#include <zip.h>
#include <libxslt/transform.h>
@@ -71,7 +71,7 @@ void dump_selection(void)
}
#endif
-void set_autogroup(gboolean value)
+void set_autogroup(bool value)
{
/* if we keep the UI paradigm, this needs to toggle
* the checkbox on the autogroup menu item */
@@ -456,7 +456,7 @@ double init_decompression(struct dive *dive)
int i, divenr = -1;
unsigned int surface_time;
timestamp_t when, lasttime = 0;
- gboolean deco_init = FALSE;
+ bool deco_init = FALSE;
double tissue_tolerance, surface_pressure;
if (!dive)
@@ -534,36 +534,6 @@ void update_cylinder_related_info(struct dive *dive)
}
}
-static void get_string(char **str, const char *s)
-{
- int len;
- char *n;
-
- if (!s)
- s = "";
- len = g_utf8_strlen(s, -1);
- if (len > 60)
- len = 60;
- n = malloc(len * sizeof(gunichar) + 1);
- g_utf8_strncpy(n, s, len);
- *str = n;
-}
-
-void get_location(struct dive *dive, char **str)
-{
- get_string(str, dive->location);
-}
-
-void get_cylinder(struct dive *dive, char **str)
-{
- get_string(str, dive->cylinder[0].type.description);
-}
-
-void get_suit(struct dive *dive, char **str)
-{
- get_string(str, dive->suit);
-}
-
#define MAX_DATE_STRING 256
/* caller needs to free the string */
char *get_dive_date_string(timestamp_t when)
@@ -574,7 +544,7 @@ char *get_dive_date_string(timestamp_t when)
utc_mkdate(when, &tm);
snprintf(buffer, MAX_DATE_STRING,
/*++GETTEXT 60 char buffer weekday, monthname, day of month, year, hour:min */
- _("%1$s, %2$s %3$d, %4$d %5$02d:%6$02d"),
+ tr("%1$s, %2$s %3$d, %4$d %5$02d:%6$02d"),
weekday(tm.tm_wday),
monthname(tm.tm_mon),
tm.tm_mday, tm.tm_year + 1900,
@@ -591,7 +561,7 @@ char *get_short_dive_date_string(timestamp_t when)
utc_mkdate(when, &tm);
snprintf(buffer, MAX_DATE_STRING,
/*++GETTEXT 40 char buffer monthname, day of month, year, hour:min */
- _("%1$s %2$d, %3$d\n%4$02d:%5$02d"),
+ tr("%1$s %2$d, %3$d\n%4$02d:%5$02d"),
monthname(tm.tm_mon),
tm.tm_mday, tm.tm_year +1900,
tm.tm_hour, tm.tm_min);
@@ -606,13 +576,24 @@ char *get_trip_date_string(timestamp_t when, int nr)
if (buffer) {
struct tm tm;
utc_mkdate(when, &tm);
- snprintf(buffer, MAX_DATE_STRING,
- /*++GETTEXT 60 char buffer monthname, year, nr dives */
- ngettext("%1$s %2$d (%3$d dive)",
- "%1$s %2$d (%3$d dives)", nr),
- monthname(tm.tm_mon),
- tm.tm_year + 1900,
- nr);
+ if (nr != 1) {
+ snprintf(buffer, MAX_DATE_STRING,
+#if PLURAL_HANDLING_IN_TRANLATION
+ /*++GETTEXT 60 char buffer monthname, year, nr dives */
+ ngettext("%1$s %2$d (%3$d dive)",
+ "%1$s %2$d (%3$d dives)", nr),
+#else
+ tr("%1$s %2$d (%3$d dives)"),
+#endif
+ monthname(tm.tm_mon),
+ tm.tm_year + 1900,
+ nr);
+ } else {
+ snprintf(buffer, MAX_DATE_STRING,
+ tr("%1$s %2$d (1 dive)"),
+ monthname(tm.tm_mon),
+ tm.tm_year + 1900);
+ }
}
return buffer;
}
@@ -640,7 +621,7 @@ char *get_nitrox_string(struct dive *dive)
else
snprintf(buffer, MAX_NITROX_STRING, "%d" UTF8_ELLIPSIS "%d", o2low, o2);
else
- strcpy(buffer, _("air"));
+ strcpy(buffer, tr("air"));
}
return buffer;
}
diff --git a/download-dialog.c b/download-dialog.c
index b98562571..b5632d593 100644
--- a/download-dialog.c
+++ b/download-dialog.c
@@ -1,5 +1,3 @@
-#include <libintl.h>
-#include <glib/gi18n.h>
#include "dive.h"
#include "divelist.h"
#include "display.h"
diff --git a/equipment.c b/equipment.c
index 2e41bf209..5485b2101 100644
--- a/equipment.c
+++ b/equipment.c
@@ -12,8 +12,8 @@
#include <stdlib.h>
#include <stdarg.h>
#include <time.h>
-#include <glib/gi18n.h>
-
+#include "gettext.h"
+#define QT_TR_NOOP(arg) arg
#include "dive.h"
#include "display.h"
#if USE_GTK_UI
@@ -186,7 +186,7 @@ static void set_weight_weight_spinbutton(struct ws_widget *ws_widget, int grams)
static GtkTreeIter *found_match = NULL;
static GtkTreeIter match_iter;
-static gboolean match_desc(GtkTreeModel *model, GtkTreePath *path,
+static bool match_desc(GtkTreeModel *model, GtkTreePath *path,
GtkTreeIter *iter, gpointer data)
{
int match;
@@ -492,7 +492,7 @@ void add_weightsystem_description(weightsystem_t *weightsystem)
#endif /* USE_GTK_UI */
-gboolean cylinder_nodata(cylinder_t *cyl)
+bool cylinder_nodata(cylinder_t *cyl)
{
return !cyl->type.size.mliter &&
!cyl->type.workingpressure.mbar &&
@@ -503,13 +503,13 @@ gboolean cylinder_nodata(cylinder_t *cyl)
!cyl->end.mbar;
}
-static gboolean cylinder_nosamples(cylinder_t *cyl)
+static bool cylinder_nosamples(cylinder_t *cyl)
{
return !cyl->sample_start.mbar &&
!cyl->sample_end.mbar;
}
-gboolean cylinder_none(void *_data)
+bool cylinder_none(void *_data)
{
cylinder_t *cyl = _data;
return cylinder_nodata(cyl) && cylinder_nosamples(cyl);
@@ -517,19 +517,19 @@ gboolean cylinder_none(void *_data)
/* descriptions are equal if they are both NULL or both non-NULL
and the same text */
-static gboolean description_equal(const char *desc1, const char *desc2)
+static bool description_equal(const char *desc1, const char *desc2)
{
return ((! desc1 && ! desc2) ||
(desc1 && desc2 && strcmp(desc1, desc2) == 0));
}
-gboolean weightsystem_none(void *_data)
+bool weightsystem_none(void *_data)
{
weightsystem_t *ws = _data;
return !ws->weight.grams && !ws->description;
}
-gboolean no_weightsystems(weightsystem_t *ws)
+bool no_weightsystems(weightsystem_t *ws)
{
int i;
@@ -539,13 +539,13 @@ gboolean no_weightsystems(weightsystem_t *ws)
return TRUE;
}
-static gboolean one_weightsystem_equal(weightsystem_t *ws1, weightsystem_t *ws2)
+static bool one_weightsystem_equal(weightsystem_t *ws1, weightsystem_t *ws2)
{
return ws1->weight.grams == ws2->weight.grams &&
description_equal(ws1->description, ws2->description);
}
-gboolean weightsystems_equal(weightsystem_t *ws1, weightsystem_t *ws2)
+bool weightsystems_equal(weightsystem_t *ws1, weightsystem_t *ws2)
{
int i;
@@ -601,7 +601,7 @@ static void *ws_ptr(struct dive *dive, int idx)
static void show_equipment(struct dive *dive, int max,
struct equipment_list *equipment_list,
void*(*ptr_function)(struct dive*, int),
- gboolean(*none_function)(void *),
+ bool(*none_function)(void *),
void(*set_one_function)(void*, GtkListStore*, GtkTreeIter *))
{
int i, used;
@@ -861,8 +861,8 @@ struct tank_info_t tank_info[100] = {
{ "HP130", .cuft = 130, .psi = 3442 },
/* Common European steel cylinders */
- { "3L 232 bar", .ml = 3000, .bar = 232 },
- { "3L 300 bar", .ml = 3000, .bar = 300 },
+ { "3L 232 bar", .ml = 3000, .bar = 232 },
+ { "3L 300 bar", .ml = 3000, .bar = 300 },
{ "10L 300 bar", .ml = 10000, .bar = 300 },
{ "12L 200 bar", .ml = 12000, .bar = 200 },
{ "12L 232 bar", .ml = 12000, .bar = 232 },
@@ -929,11 +929,11 @@ bad_tank_info:
* This is a bit odd as the weight system types don't usually encode weight
*/
struct ws_info_t ws_info[100] = {
- { N_("integrated"), 0 },
- { N_("belt"), 0 },
- { N_("ankle"), 0 },
- { N_("backplate weight"), 0 },
- { N_("clip-on"), 0 },
+ { QT_TR_NOOP("integrated"), 0 },
+ { QT_TR_NOOP("belt"), 0 },
+ { QT_TR_NOOP("ankle"), 0 },
+ { QT_TR_NOOP("backplate weight"), 0 },
+ { QT_TR_NOOP("clip-on"), 0 },
};
#if USE_GTK_UI
diff --git a/file.c b/file.c
index 53b03330c..130568245 100644
--- a/file.c
+++ b/file.c
@@ -4,7 +4,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <glib/gi18n.h>
+#include "gettext.h"
#include <zip.h>
#include "dive.h"
@@ -24,7 +24,7 @@ int readfile(const char *filename, struct memblock *mem)
mem->buffer = NULL;
mem->size = 0;
- fd = g_open(filename, O_RDONLY | O_BINARY, 0);
+ fd = open(filename, O_RDONLY | O_BINARY, 0);
if (fd < 0)
return fd;
ret = fstat(fd, &st);
@@ -103,9 +103,9 @@ static int try_to_xslt_open_csv(const char *filename, struct memblock *mem, char
if (readfile(filename, mem) < 0) {
if (error) {
- int len = strlen(_("Failed to read '%s'")) + strlen(filename);
+ int len = strlen(tr("Failed to read '%s'")) + strlen(filename);
*error = malloc(len);
- snprintf(*error, len, _("Failed to read '%s'"), filename);
+ snprintf(*error, len, tr("Failed to read '%s'"), filename);
}
return 1;
@@ -232,7 +232,7 @@ static int try_to_open_csv(const char *filename, struct memblock *mem, enum csv_
struct sample *sample;
errno = 0;
- val = g_ascii_strtod(p,&end);
+ val = strtod(p,&end); // FIXME == localization issue
if (end == p)
break;
if (errno)
@@ -300,9 +300,9 @@ void parse_file(const char *filename, char **error)
return;
if (error) {
- int len = strlen(_("Failed to read '%s'")) + strlen(filename);
+ int len = strlen(tr("Failed to read '%s'")) + strlen(filename);
*error = malloc(len);
- snprintf(*error, len, _("Failed to read '%s'"), filename);
+ snprintf(*error, len, tr("Failed to read '%s'"), filename);
}
return;
diff --git a/file.h b/file.h
index 38f7b496e..b3a1ebac3 100644
--- a/file.h
+++ b/file.h
@@ -6,7 +6,9 @@ struct memblock {
size_t size;
};
+#if 0
extern int try_to_open_cochran(const char *filename, struct memblock *mem, GError **error);
+#endif
extern int readfile(const char *filename, struct memblock *mem);
#endif
diff --git a/gettext.h b/gettext.h
new file mode 100644
index 000000000..d3283998d
--- /dev/null
+++ b/gettext.h
@@ -0,0 +1,9 @@
+#ifndef MYGETTEXT_H
+#define MYGETTEXT_H
+
+/* this is for the Qt based translations */
+extern const char *gettext(const char *);
+#define tr(arg) gettext(arg)
+#define QT_TR_NOOP(arg) arg
+
+#endif // MYGETTEXT_H
diff --git a/gettextfromc.cpp b/gettextfromc.cpp
new file mode 100644
index 000000000..4976d70f8
--- /dev/null
+++ b/gettextfromc.cpp
@@ -0,0 +1,19 @@
+#include <QCoreApplication>
+#include <QString>
+#include <gettextfromc.h>
+
+char *gettextFromC::gettext(const char *text)
+{
+ return tr(text).toLocal8Bit().data();
+}
+
+gettextFromC* gettextFromC::instance()
+{
+ static gettextFromC *self = new gettextFromC();
+ return self;
+}
+
+extern "C" const char *gettext(const char *text)
+{
+ return gettextFromC::instance()->gettext(text);
+}
diff --git a/gettextfromc.h b/gettextfromc.h
new file mode 100644
index 000000000..3852709c9
--- /dev/null
+++ b/gettextfromc.h
@@ -0,0 +1,15 @@
+#ifndef GETTEXT_H
+#define GETTEXT_H
+
+
+extern "C" const char *gettext(const char *text);
+
+class gettextFromC
+{
+Q_DECLARE_TR_FUNCTIONS(gettextFromC)
+public:
+ static gettextFromC *instance();
+ char *gettext(const char *text);
+};
+
+#endif // GETTEXT_H
diff --git a/gtk-gui.c b/gtk-gui.c
index e873fc622..7ec3d8819 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -8,8 +8,6 @@
* functions. It's renamed back to gtk-ui.c to keep the old Gtk code
* around for reference in case we still need it... all that has now been
* ripped out of qt-gui.cpp */
-#include <libintl.h>
-#include <glib/gi18n.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
diff --git a/info.c b/info.c
index 4e0c3cadb..e5978fc4b 100644
--- a/info.c
+++ b/info.c
@@ -2,7 +2,7 @@
*
* UI toolkit independent logic used for the info frame
*
- * gboolean gps_changed(struct dive *dive, struct dive *master, const char *gps_text);
+ * bool gps_changed(struct dive *dive, struct dive *master, const char *gps_text);
* void print_gps_coordinates(char *buffer, int len, int lat, int lon);
* void save_equipment_data(struct dive *dive);
* void update_equipment_data(struct dive *dive, struct dive *master);
@@ -10,7 +10,7 @@
* const char *get_window_title(struct dive *dive);
* char *evaluate_string_change(const char *newstring, char **textp, const char *master);
* int text_changed(const char *old, const char *new);
- * gboolean parse_gps_text(const char *gps_text, double *latitude, double *longitude);
+ * bool parse_gps_text(const char *gps_text, double *latitude, double *longitude);
* int divename(char *buf, size_t size, struct dive *dive, char *trailer);
*/
#include <stdio.h>
@@ -19,306 +19,33 @@
#include <time.h>
#include <ctype.h>
#include <sys/time.h>
-#include <glib/gi18n.h>
-
+#include "gettext.h"
#include "dive.h"
#include "display.h"
#include "divelist.h"
-/* old is NULL or a valid string, new is a valid string
- * NOTE: NULL and "" need to be treated as "unchanged" */
-int text_changed(const char *old, const char *new)
-{
- return (old && strcmp(old,new)) ||
- (!old && strcmp("",new));
-}
-
-static const char *skip_space(const char *str)
-{
- if (str) {
- while (g_ascii_isspace(*str))
- str++;
- if (!*str)
- str = NULL;
- }
- return str;
-}
-
-/*
- * should this string be changed?
- * The "master" string is the string of the current dive - we only consider it
- * changed if the old string is either empty, or matches that master string.
- */
-char *evaluate_string_change(const char *newstring, char **textp, const char *master)
-{
- char *old = *textp;
- const char *old_text;
-
- old_text = skip_space(old);
- master = skip_space(master);
-
- /*
- * If we had a master string, and it doesn't match our old
- * string, we will always pick the old value (it means that
- * we're editing another dive's info that already had a
- * valid value).
- */
- if (master && old_text)
- if (strcmp(master, old_text))
- return NULL;
-
- while (g_ascii_isspace(*newstring))
- newstring++;
- /* If the master string didn't change, don't change other dives either! */
- if (!text_changed(master, newstring))
- return NULL;
- if (!text_changed(old, newstring))
- return NULL;
- free(old);
- *textp = strdup(newstring);
- return *textp;
-}
-
-int divename(char *buf, size_t size, struct dive *dive, char *trailer)
-{
- struct tm tm;
-
- utc_mkdate(dive->when, &tm);
- /*++GETTEXT 80 char buffer: dive nr, weekday, month, day, year, hour, min <trailing text>*/
- return snprintf(buf, size, _("Dive #%1$d - %2$s %3$02d/%4$02d/%5$04d at %6$d:%7$02d %8$s"),
- dive->number,
- weekday(tm.tm_wday),
- tm.tm_mon+1, tm.tm_mday,
- tm.tm_year+1900,
- tm.tm_hour, tm.tm_min,
- trailer);
-}
-
-/* caller should free the string returned after it is no longer needed */
-const char *get_window_title(struct dive *dive)
-{
- const char *text;
- const int maxlen = 128;
- char *basename;
- char *title;
- char *buffer = NULL;
- int len1, len2, sz;
-
- if (!dive) {
- if (existing_filename) {
- char *basename;
- basename = g_path_get_basename(existing_filename);
- len1 = sizeof("Subsurface: ");
- len2 = g_utf8_strlen(basename, -1);
- sz = (len1 + len2) * sizeof(gunichar);
- title = malloc(sz);
- strncpy(title, "Subsurface: ", len1);
- g_utf8_strncpy(title + len1, basename, len2);
- } else {
- title = strdup("Subsurface");
- }
- } else {
- /* dive number and location (or lacking that, the date) go in the window title */
- text = dive->location;
- if (!text)
- text = "";
- if (*text) {
- if (dive->number) {
- len1 = g_utf8_strlen(text, -1);
- sz = (len1 + 32) * sizeof(gunichar);
- buffer = malloc(sz);
- snprintf(buffer, sz, _("Dive #%d - "), dive->number);
- g_utf8_strncpy(buffer + strlen(buffer), text, len1);
- text = buffer;
- }
- } else {
- sz = (maxlen + 32) * sizeof(gunichar);
- buffer = malloc(sz);
- divename(buffer, sz, dive, "");
- text = buffer;
- }
- /* put it all together */
- if (existing_filename) {
- basename = g_path_get_basename(existing_filename);
- len1 = g_utf8_strlen(basename, -1);
- len2 = g_utf8_strlen(text, -1);
- if (len2 > maxlen)
- len2 = maxlen;
- sz = (len1 + len2 + 3) * sizeof(gunichar); /* reserver space for ": " */
- title = malloc(sz);
- g_utf8_strncpy(title, basename, len1);
- strncpy(title + strlen(basename), (const char *)": ", 2);
- g_utf8_strncpy(title + strlen(basename) + 2, text, len2);
- } else {
- title = strdup(text);
- }
- if (buffer)
- free(buffer);
- }
- return title;
-}
-
-/* this is used to skip the cardinal directions (or check if they are
- * present). You pass in the text and a STRING with the direction.
- * This checks for both the standard english text (just one character)
- * and the translated text (possibly longer) and returns 0 if not found
- * and the number of chars to skip otherwise. */
-static int string_advance_cardinal(const char *text, const char *look)
-{
- char *trans;
- int len = strlen(look);
- if (!strncasecmp(text, look, len))
- return len;
- trans = _(look);
- len = strlen(trans);
- if (!strncasecmp(text, trans, len))
- return len;
- return 0;
-}
-
-/* this has to be done with UTF8 as people might want to enter the degree symbol */
-gboolean parse_gps_text(const char *gps_text, double *latitude, double *longitude)
-{
- const char *text = gps_text;
- char *endptr;
- gboolean south = FALSE;
- gboolean west = FALSE;
- double parselat, parselong;
- gunichar degrees = UCS4_DEGREE;
- gunichar c;
- int incr;
-
- while (g_unichar_isspace(g_utf8_get_char(text)))
- text = g_utf8_next_char(text);
-
- /* an empty string is interpreted as 0.0,0.0 and therefore "no gps location" */
- if (!*text) {
- *latitude = 0.0;
- *longitude = 0.0;
- return TRUE;
- }
- /* ok, let's parse by hand - first degrees of latitude */
- text += string_advance_cardinal(text, "N");
- if ((incr = string_advance_cardinal(text, "S")) > 0) {
- text += incr;
- south = TRUE;
- }
- parselat = g_ascii_strtod(text, &endptr);
- if (text == endptr)
- return FALSE;
- text = endptr;
- if (parselat < 0.0) {
- south = TRUE;
- parselat *= -1;
- }
-
- /* next optional minutes as decimal, skipping degree symbol */
- while (g_unichar_isspace(c = g_utf8_get_char(text)) || c == degrees)
- text = g_utf8_next_char(text);
- incr = string_advance_cardinal(text, "E") + string_advance_cardinal(text, "W");
- if (!incr && c != ';' && c != ',') {
- parselat += g_ascii_strtod(text, &endptr) / 60.0;
- if (text == endptr)
- return FALSE;
- text = endptr;
- /* skip trailing minute symbol */
- if (g_utf8_get_char(text) == '\'')
- text = g_utf8_next_char(text);
- }
- /* skip seperator between latitude and longitude */
- while (g_unichar_isspace(c = g_utf8_get_char(text)) || c == ';' || c == ',')
- text = g_utf8_next_char(text);
-
- /* next degrees of longitude */
- text += string_advance_cardinal(text, "E");
- if ((incr = string_advance_cardinal(text, "W")) > 0) {
- text += incr;
- west = TRUE;
- }
- parselong = g_ascii_strtod(text, &endptr);
- if (text == endptr)
- return FALSE;
- text = endptr;
- if (parselong < 0.0) {
- west = TRUE;
- parselong *= -1;
- }
-
- /* next optional minutes as decimal, skipping degree symbol */
- while (g_unichar_isspace(c = g_utf8_get_char(text)) || c == degrees)
- text = g_utf8_next_char(text);
- if (*text) {
- parselong += g_ascii_strtod(text, &endptr) / 60.0;
- if (text == endptr)
- return FALSE;
- text = endptr;
- /* skip trailing minute symbol */
- if (g_utf8_get_char(text) == '\'')
- text = g_utf8_next_char(text);
- /* make sure there's nothing else left on the input */
- while (g_unichar_isspace(g_utf8_get_char(text)))
- text = g_utf8_next_char(text);
- if (*text)
- return FALSE;
- }
- if (west && parselong > 0.0)
- parselong *= -1;
- if (south && parselat > 0.0)
- parselat *= -1;
- *latitude = parselat;
- *longitude = parselong;
- return TRUE;
-}
-
-gboolean gps_changed(struct dive *dive, struct dive *master, const char *gps_text)
-{
- double latitude, longitude;
- int latudeg, longudeg;
-
- /* if we have a master and the dive's gps address is different from it,
- * don't change the dive */
- if (master && (master->latitude.udeg != dive->latitude.udeg ||
- master->longitude.udeg != dive->longitude.udeg))
- return FALSE;
-
- if (!parse_gps_text(gps_text, &latitude, &longitude))
- return FALSE;
-
- latudeg = rint(1000000 * latitude);
- longudeg = rint(1000000 * longitude);
-
- /* if dive gps didn't change, nothing changed */
- if (dive->latitude.udeg == latudeg && dive->longitude.udeg == longudeg)
- return FALSE;
- /* ok, update the dive and mark things changed */
- dive->latitude.udeg = latudeg;
- dive->longitude.udeg = longudeg;
- return TRUE;
-}
-
/* take latitude and longitude in udeg and print them in a human readable
* form, without losing precision */
void print_gps_coordinates(char *buffer, int len, int lat, int lon)
{
unsigned int latdeg, londeg;
- double latmin, lonmin;
- char *lath, *lonh, dbuf_lat[32], dbuf_lon[32];
+ const char *lath, *lonh;
+ char dbuf_lat[32], dbuf_lon[32];
if (!lat && !lon) {
*buffer = 0;
return;
}
- lath = lat >= 0 ? _("N") : _("S");
- lonh = lon >= 0 ? _("E") : _("W");
+ lath = lat >= 0 ? tr("N") : tr("S");
+ lonh = lon >= 0 ? tr("E") : tr("W");
lat = abs(lat);
lon = abs(lon);
latdeg = lat / 1000000;
londeg = lon / 1000000;
- latmin = (lat % 1000000) * 60.0 / 1000000.0;
- lonmin = (lon % 1000000) * 60.0 / 1000000.0;
- *dbuf_lat = *dbuf_lon = 0;
- g_ascii_formatd(dbuf_lat, sizeof(dbuf_lat), "%8.5f", latmin);
- g_ascii_formatd(dbuf_lon, sizeof(dbuf_lon), "%8.5f", lonmin);
+ int ilatmin = (lat % 1000000) * 60;
+ int ilonmin = (lon % 1000000) * 60;
+ snprintf(dbuf_lat, sizeof(dbuf_lat), "%2d.%05d", ilatmin / 1000000, (ilatmin % 1000000) / 10);
+ snprintf(dbuf_lon, sizeof(dbuf_lon), "%2d.%05d", ilonmin / 1000000, (ilonmin % 1000000) / 10);
if (!*dbuf_lat || !*dbuf_lon) {
*buffer = 0;
return;
diff --git a/info.h b/info.h
index ac8f42d2b..87515ef14 100644
--- a/info.h
+++ b/info.h
@@ -10,7 +10,7 @@
extern "C" {
#endif
-extern gboolean gps_changed(struct dive *dive, struct dive *master, const char *gps_text);
+extern bool gps_changed(struct dive *dive, struct dive *master, const char *gps_text);
extern void print_gps_coordinates(char *buffer, int len, int lat, int lon);
extern void save_equipment_data(struct dive *dive);
extern void update_equipment_data(struct dive *dive, struct dive *master);
@@ -18,7 +18,7 @@ extern void update_time_depth(struct dive *dive, struct dive *edited);
extern const char *get_window_title(struct dive *dive);
extern char *evaluate_string_change(const char *newstring, char **textp, const char *master);
extern int text_changed(const char *old, const char * /*new is a c++ keyword*/);
-extern gboolean parse_gps_text(const char *gps_text, double *latitude, double *longitude);
+extern bool parse_gps_text(const char *gps_text, double *latitude, double *longitude);
extern int divename(char *buf, size_t size, struct dive *dive, char *trailer);
#ifdef __cplusplus
diff --git a/libdivecomputer.c b/libdivecomputer.c
index 01c356873..a60131614 100644
--- a/libdivecomputer.c
+++ b/libdivecomputer.c
@@ -1,8 +1,8 @@
#include <stdio.h>
#include <unistd.h>
#include <inttypes.h>
-#include <glib/gi18n.h>
-
+#include <string.h>
+#include "gettext.h"
#include "dive.h"
#include "device.h"
#include "divelist.h"
@@ -26,7 +26,7 @@ const char *progress_bar_text = "";
double progress_bar_fraction = 0.0;
static int stoptime, stopdepth, ndl, po2, cns;
-static gboolean in_deco, first_temp_is_air;
+static bool in_deco, first_temp_is_air;
#if USE_GTK_UI
static GError *error(const char *fmt, ...)
@@ -150,12 +150,12 @@ static void handle_event(struct divecomputer *dc, struct sample *sample, dc_samp
/* we mark these for translation here, but we store the untranslated strings
* and only translate them when they are displayed on screen */
static const char *events[] = {
- N_("none"), N_("deco stop"), N_("rbt"), N_("ascent"), N_("ceiling"), N_("workload"),
- N_("transmitter"), N_("violation"), N_("bookmark"), N_("surface"), N_("safety stop"),
- N_("gaschange"), N_("safety stop (voluntary)"), N_("safety stop (mandatory)"),
- N_("deepstop"), N_("ceiling (safety stop)"), N_("below floor"), N_("divetime"),
- N_("maxdepth"), N_("OLF"), N_("PO2"), N_("airtime"), N_("rgbm"), N_("heading"),
- N_("tissue level warning"), N_("gaschange"), N_("non stop time")
+ QT_TR_NOOP("none"), QT_TR_NOOP("deco stop"), QT_TR_NOOP("rbt"), QT_TR_NOOP("ascent"), QT_TR_NOOP("ceiling"), QT_TR_NOOP("workload"),
+ QT_TR_NOOP("transmitter"), QT_TR_NOOP("violation"), QT_TR_NOOP("bookmark"), QT_TR_NOOP("surface"), QT_TR_NOOP("safety stop"),
+ QT_TR_NOOP("gaschange"), QT_TR_NOOP("safety stop (voluntary)"), QT_TR_NOOP("safety stop (mandatory)"),
+ QT_TR_NOOP("deepstop"), QT_TR_NOOP("ceiling (safety stop)"), QT_TR_NOOP("below floor"), QT_TR_NOOP("divetime"),
+ QT_TR_NOOP("maxdepth"), QT_TR_NOOP("OLF"), QT_TR_NOOP("PO2"), QT_TR_NOOP("airtime"), QT_TR_NOOP("rgbm"), QT_TR_NOOP("heading"),
+ QT_TR_NOOP("tissue level warning"), QT_TR_NOOP("gaschange"), QT_TR_NOOP("non stop time")
};
const int nr_events = sizeof(events) / sizeof(const char *);
const char *name;
@@ -172,7 +172,7 @@ static void handle_event(struct divecomputer *dc, struct sample *sample, dc_samp
* Other evens might be more interesting, but for now we just print them out.
*/
type = value.event.type;
- name = N_("invalid event number");
+ name = QT_TR_NOOP("invalid event number");
if (type < nr_events)
name = events[type];
@@ -405,13 +405,13 @@ static int dive_cb(const unsigned char *data, unsigned int size,
rc = create_parser(devdata, &parser);
if (rc != DC_STATUS_SUCCESS) {
- dev_info(devdata, _("Unable to create parser for %s %s"), devdata->vendor, devdata->product);
+ dev_info(devdata, tr("Unable to create parser for %s %s"), devdata->vendor, devdata->product);
return rc;
}
rc = dc_parser_set_data(parser, data, size);
if (rc != DC_STATUS_SUCCESS) {
- dev_info(devdata, _("Error registering the data"));
+ dev_info(devdata, tr("Error registering the data"));
dc_parser_destroy(parser);
return rc;
}
@@ -420,7 +420,7 @@ static int dive_cb(const unsigned char *data, unsigned int size,
dive = alloc_dive();
rc = dc_parser_get_datetime(parser, &dt);
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
- dev_info(devdata, _("Error parsing the datetime"));
+ dev_info(devdata, tr("Error parsing the datetime"));
dc_parser_destroy(parser);
return rc;
}
@@ -437,12 +437,12 @@ static int dive_cb(const unsigned char *data, unsigned int size,
dive->when = dive->dc.when = utc_mktime(&tm);
// Parse the divetime.
- dev_info(devdata, _("Dive %d: %s %d %04d"), import_dive_number,
+ dev_info(devdata, tr("Dive %d: %s %d %04d"), import_dive_number,
monthname(tm.tm_mon), tm.tm_mday, year(tm.tm_year));
unsigned int divetime = 0;
rc = dc_parser_get_field (parser, DC_FIELD_DIVETIME, 0, &divetime);
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
- dev_info(devdata, _("Error parsing the divetime"));
+ dev_info(devdata, tr("Error parsing the divetime"));
dc_parser_destroy(parser);
return rc;
}
@@ -452,7 +452,7 @@ static int dive_cb(const unsigned char *data, unsigned int size,
double maxdepth = 0.0;
rc = dc_parser_get_field(parser, DC_FIELD_MAXDEPTH, 0, &maxdepth);
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
- dev_info(devdata, _("Error parsing the maxdepth"));
+ dev_info(devdata, tr("Error parsing the maxdepth"));
dc_parser_destroy(parser);
return rc;
}
@@ -462,7 +462,7 @@ static int dive_cb(const unsigned char *data, unsigned int size,
unsigned int ngases = 0;
rc = dc_parser_get_field(parser, DC_FIELD_GASMIX_COUNT, 0, &ngases);
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
- dev_info(devdata, _("Error parsing the gas mix count"));
+ dev_info(devdata, tr("Error parsing the gas mix count"));
dc_parser_destroy(parser);
return rc;
}
@@ -475,7 +475,7 @@ static int dive_cb(const unsigned char *data, unsigned int size,
};
rc = dc_parser_get_field(parser, DC_FIELD_SALINITY, 0, &salinity);
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
- dev_info(devdata, _("Error obtaining water salinity"));
+ dev_info(devdata, tr("Error obtaining water salinity"));
dc_parser_destroy(parser);
return rc;
}
@@ -484,7 +484,7 @@ static int dive_cb(const unsigned char *data, unsigned int size,
double surface_pressure = 1.0;
rc = dc_parser_get_field(parser, DC_FIELD_ATMOSPHERIC, 0, &surface_pressure);
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
- dev_info(devdata, _("Error obtaining surface pressure"));
+ dev_info(devdata, tr("Error obtaining surface pressure"));
dc_parser_destroy(parser);
return rc;
}
@@ -493,7 +493,7 @@ static int dive_cb(const unsigned char *data, unsigned int size,
rc = parse_gasmixes(devdata, dive, parser, ngases, data);
if (rc != DC_STATUS_SUCCESS) {
- dev_info(devdata, _("Error parsing the gas mix"));
+ dev_info(devdata, tr("Error parsing the gas mix"));
dc_parser_destroy(parser);
return rc;
}
@@ -501,7 +501,7 @@ static int dive_cb(const unsigned char *data, unsigned int size,
// Initialize the sample data.
rc = parse_samples(devdata, &dive->dc, parser);
if (rc != DC_STATUS_SUCCESS) {
- dev_info(devdata, _("Error parsing the samples"));
+ dev_info(devdata, tr("Error parsing the samples"));
dc_parser_destroy(parser);
return rc;
}
@@ -628,7 +628,7 @@ static void event_cb(dc_device_t *device, dc_event_type_t event, const void *dat
switch (event) {
case DC_EVENT_WAITING:
- dev_info(devdata, _("Event: waiting for user action"));
+ dev_info(devdata, tr("Event: waiting for user action"));
break;
case DC_EVENT_PROGRESS:
if (!progress->maximum)
@@ -636,7 +636,7 @@ static void event_cb(dc_device_t *device, dc_event_type_t event, const void *dat
progress_bar_fraction = (double) progress->current / (double) progress->maximum;
break;
case DC_EVENT_DEVINFO:
- dev_info(devdata, _("model=%u (0x%08x), firmware=%u (0x%08x), serial=%u (0x%08x)"),
+ dev_info(devdata, tr("model=%u (0x%08x), firmware=%u (0x%08x), serial=%u (0x%08x)"),
devinfo->model, devinfo->model,
devinfo->firmware, devinfo->firmware,
devinfo->serial, devinfo->serial);
@@ -651,7 +651,7 @@ static void event_cb(dc_device_t *device, dc_event_type_t event, const void *dat
break;
case DC_EVENT_CLOCK:
- dev_info(devdata, _("Event: systime=%"PRId64", devtime=%u\n"),
+ dev_info(devdata, tr("Event: systime=%"PRId64", devtime=%u\n"),
(uint64_t)clock->systime, clock->devtime);
break;
default:
@@ -678,16 +678,16 @@ static const char *do_device_import(device_data_t *data)
int events = DC_EVENT_WAITING | DC_EVENT_PROGRESS | DC_EVENT_DEVINFO | DC_EVENT_CLOCK;
rc = dc_device_set_events(device, events, event_cb, data);
if (rc != DC_STATUS_SUCCESS)
- return _("Error registering the event handler.");
+ return tr("Error registering the event handler.");
// Register the cancellation handler.
rc = dc_device_set_cancel(device, cancel_cb, data);
if (rc != DC_STATUS_SUCCESS)
- return _("Error registering the cancellation handler.");
+ return tr("Error registering the cancellation handler.");
rc = import_device_data(device, data);
if (rc != DC_STATUS_SUCCESS)
- return _("Dive data import error");
+ return tr("Dive data import error");
/* All good */
return NULL;
@@ -705,9 +705,9 @@ const char *do_libdivecomputer_import(device_data_t *data)
rc = dc_context_new(&data->context);
if (rc != DC_STATUS_SUCCESS)
- return _("Unable to create libdivecomputer context");
+ return tr("Unable to create libdivecomputer context");
- err = _("Unable to open %s %s (%s)");
+ err = tr("Unable to open %s %s (%s)");
rc = dc_device_open(&data->device, data->context, data->descriptor, data->devname);
if (rc == DC_STATUS_SUCCESS) {
err = do_device_import(data);
diff --git a/libdivecomputer.h b/libdivecomputer.h
index 07d965ef6..39fd80909 100644
--- a/libdivecomputer.h
+++ b/libdivecomputer.h
@@ -24,11 +24,11 @@ typedef struct device_data_t {
dc_device_t *device;
dc_context_t *context;
int preexisting;
- gboolean force_download;
+ bool force_download;
} device_data_t;
const char *do_libdivecomputer_import(device_data_t *data);
-char *do_uemis_import(const char *mountpath, short force_download);
+const char *do_uemis_import(const char *mountpath, short force_download);
extern int import_thread_cancelled;
extern const char *progress_bar_text;
diff --git a/linux.c b/linux.c
index 21cc10822..070a091fe 100644
--- a/linux.c
+++ b/linux.c
@@ -30,8 +30,8 @@ const char *system_default_filename(void)
char *buffer;
int len;
- home = g_get_home_dir();
- user = g_get_user_name();
+ home = getenv("HOME");
+ user = getenv("LOGNAME");
len = strlen(home) + strlen(user) + 17;
buffer = malloc(len);
snprintf(buffer, len, "%s/subsurface/%s.xml", home, user);
@@ -49,17 +49,17 @@ const char *subsurface_gettext_domainpath(char *argv0)
}
}
-void subsurface_command_line_init(gint *argc, gchar ***argv)
+void subsurface_command_line_init(int *argc, char ***argv)
{
/* this is a no-op */
}
-void subsurface_command_line_exit(gint *argc, gchar ***argv)
+void subsurface_command_line_exit(int *argc, char ***argv)
{
/* this is a no-op */
}
-gboolean subsurface_os_feature_available(os_feature_t f)
+bool subsurface_os_feature_available(os_feature_t f)
{
return TRUE;
}
diff --git a/macos.c b/macos.c
index e27a76007..4f41970b6 100644
--- a/macos.c
+++ b/macos.c
@@ -42,7 +42,7 @@ void subsurface_set_conf(const char *name, const char *value)
CFPreferencesSetAppValue(CFSTR_VAR(name), CFSTR_VAR(value), SUBSURFACE_PREFERENCES);
}
-void subsurface_set_conf_bool(const char *name, int value)
+void subsurface_set_conf_bool(const char *name, bool value)
{
CFPreferencesSetAppValue(CFSTR_VAR(name),
value ? kCFBooleanTrue : kCFBooleanFalse, SUBSURFACE_PREFERENCES);
@@ -169,8 +169,8 @@ const char *system_default_filename(void)
char *buffer;
int len;
- home = g_get_home_dir();
- user = g_get_user_name();
+ home = getenv("HOME");
+ user = getenv("LOGNAME");
len = strlen(home) + strlen(user) + 45;
buffer = malloc(len);
snprintf(buffer, len, "%s/Library/Application Support/Subsurface/%s.xml", home, user);
@@ -242,22 +242,22 @@ void subsurface_ui_setup(GtkSettings *settings, GtkWidget *menubar,
}
#endif /* UES_GTK_UI */
-void subsurface_command_line_init(gint *argc, gchar ***argv)
+void subsurface_command_line_init(int *argc, char ***argv)
{
/* this is a no-op */
}
-void subsurface_command_line_exit(gint *argc, gchar ***argv)
+void subsurface_command_line_exit(int *argc, char ***argv)
{
/* this is a no-op */
}
-gboolean subsurface_os_feature_available(os_feature_t f)
+bool subsurface_os_feature_available(os_feature_t f)
{
return TRUE;
}
-gboolean subsurface_launch_for_uri(const char* uri)
+bool subsurface_launch_for_uri(const char* uri)
{
CFURLRef urlref = CFURLCreateWithBytes(NULL, uri, strlen(uri), kCFStringEncodingMacRoman, NULL);
OSStatus status = LSOpenCFURLRef(urlref, NULL);
diff --git a/main.cpp b/main.cpp
index f12d293d6..fddf508ec 100644
--- a/main.cpp
+++ b/main.cpp
@@ -4,7 +4,6 @@
#include <string.h>
#include <stdlib.h>
#include <time.h>
-#include <libintl.h>
#include "qt-gui.h"
#include "version.h"
@@ -18,6 +17,7 @@ int main(int argc, char **argv)
{
int i;
bool no_filenames = true;
+#if 0
const char *path;
/* set up l18n - the search directory needs to change
@@ -28,7 +28,7 @@ int main(int argc, char **argv)
bindtextdomain("subsurface", path);
bind_textdomain_codeset("subsurface", "utf-8");
textdomain("subsurface");
-
+#endif
setup_system_prefs();
prefs = default_prefs;
diff --git a/parse-xml.c b/parse-xml.c
index 66246570f..b301aefec 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -11,7 +11,9 @@
#include <libxml/parserInternals.h>
#include <libxml/tree.h>
#include <libxslt/transform.h>
-#include <glib/gi18n.h>
+
+#include "gettext.h"
+
#include<sqlite3.h>
#include "dive.h"
@@ -129,7 +131,7 @@ struct {
const char *nickname, *serial_nr, *firmware;
} dc;
} cur_settings;
-static gboolean in_settings = FALSE;
+static bool in_settings = FALSE;
static struct tm cur_tm;
static int cur_cylinder_index, cur_ws_index;
static int lastndl, laststoptime, laststopdepth, lastcns, lastpo2, lastindeco;
@@ -235,13 +237,101 @@ enum number_type {
FLOAT
};
+double ascii_strtod(char *str, char **ptr)
+{
+ char *p;
+
+ if (ptr == (char **)0)
+ return atof (str);
+
+ p = str;
+
+ while (isspace (*p))
+ ++p;
+
+ if (*p == '+' || *p == '-')
+ ++p;
+
+ /* INF or INFINITY. */
+ if ((p[0] == 'i' || p[0] == 'I')
+ && (p[1] == 'n' || p[1] == 'N')
+ && (p[2] == 'f' || p[2] == 'F'))
+ {
+ if ((p[3] == 'i' || p[3] == 'I')
+ && (p[4] == 'n' || p[4] == 'N')
+ && (p[5] == 'i' || p[5] == 'I')
+ && (p[6] == 't' || p[6] == 'T')
+ && (p[7] == 'y' || p[7] == 'Y'))
+ {
+ *ptr = p + 7;
+ return atof (str);
+ }
+ else
+ {
+ *ptr = p + 3;
+ return atof (str);
+ }
+ }
+
+ /* NAN or NAN(foo). */
+ if ((p[0] == 'n' || p[0] == 'N')
+ && (p[1] == 'a' || p[1] == 'A')
+ && (p[2] == 'n' || p[2] == 'N'))
+ {
+ p += 3;
+ if (*p == '(')
+ {
+ ++p;
+ while (*p != '\0' && *p != ')')
+ ++p;
+ if (*p == ')')
+ ++p;
+ }
+ *ptr = p;
+ return atof (str);
+ }
+
+ /* digits, with 0 or 1 periods in it. */
+ if (isdigit (*p) || *p == '.')
+ {
+ int got_dot = 0;
+ while (isdigit (*p) || (!got_dot && *p == '.'))
+ {
+ if (*p == '.')
+ got_dot = 1;
+ ++p;
+ }
+
+ /* Exponent. */
+ if (*p == 'e' || *p == 'E')
+ {
+ int i;
+ i = 1;
+ if (p[i] == '+' || p[i] == '-')
+ ++i;
+ if (isdigit (p[i]))
+ {
+ while (isdigit (p[i]))
+ ++i;
+ *ptr = p + i;
+ return atof (str);
+ }
+ }
+ *ptr = p;
+ return atof (str);
+ }
+ /* Didn't find any digits. Doesn't look like a number. */
+ *ptr = str;
+ return 0.0;
+}
+
static enum number_type parse_float(char *buffer, double *res, char **endp)
{
double val;
- static gboolean first_time = TRUE;
+ static bool first_time = TRUE;
errno = 0;
- val = g_ascii_strtod(buffer, endp);
+ val = ascii_strtod(buffer, endp);
if (errno || *endp == buffer)
return NEITHER;
if (**endp == ',') {
@@ -255,7 +345,7 @@ static enum number_type parse_float(char *buffer, double *res, char **endp)
}
/* Try again */
**endp = '.';
- val = g_ascii_strtod(buffer, endp);
+ val = ascii_strtod(buffer, endp);
}
}
@@ -436,7 +526,7 @@ static void percent(char *buffer, void *_fraction)
case FLOAT:
/* Turn fractions into percent unless explicit.. */
if (val <= 1.0) {
- while (g_ascii_isspace(*end))
+ while (isspace(*end))
end++;
if (*end != '%')
val *= 100;
@@ -448,7 +538,7 @@ static void percent(char *buffer, void *_fraction)
break;
}
default:
- printf(_("Strange percentage reading %s\n"), buffer);
+ printf(tr("Strange percentage reading %s\n"), buffer);
break;
}
}
@@ -487,10 +577,10 @@ static void utf8_string(char *buffer, void *_res)
{
int size;
char *res;
- while (g_ascii_isspace(*buffer))
+ while (isspace(*buffer))
buffer++;
size = strlen(buffer);
- while (size && g_ascii_isspace(buffer[size-1]))
+ while (size && isspace(buffer[size-1]))
size--;
if (!size)
return;
@@ -521,7 +611,7 @@ static void get_rating(char *buffer, void *_i)
static void double_to_permil(char *buffer, void *_i)
{
int *i = _i;
- *i = g_ascii_strtod(buffer, NULL) * 1000.0 + 0.5;
+ *i = ascii_strtod(buffer, NULL) * 1000.0 + 0.5;
}
static void hex_value(char *buffer, void *_i)
@@ -976,7 +1066,7 @@ static degrees_t parse_degrees(char *buf, char **end)
int sign = 1, decimals = 6, value = 0;
degrees_t ret;
- while (g_ascii_isspace(*buf))
+ while (isspace(*buf))
buf++;
switch (*buf) {
case '-':
@@ -1181,7 +1271,7 @@ static void try_to_fill_trip(dive_trip_t **dive_trip_p, const char *name, char *
* to make a dive valid, but if it has no location, no date and no
* samples I'm pretty sure it's useless.
*/
-static gboolean is_dive(void)
+static bool is_dive(void)
{
return (cur_dive &&
(cur_dive->location || cur_dive->when || cur_dive->dc.samples));
@@ -1594,8 +1684,8 @@ void parse_xml_buffer(const char *url, const char *buffer, int size,
free((char *)res);
if (!doc) {
- fprintf(stderr, _("Failed to parse '%s'.\n"), url);
- parser_error(error, _("Failed to parse '%s'"), url);
+ fprintf(stderr, tr("Failed to parse '%s'.\n"), url);
+ parser_error(error, tr("Failed to parse '%s'"), url);
return;
}
reset_all();
@@ -1793,7 +1883,7 @@ extern int dm4_dive(void *param, int columns, char **data, char **column)
snprintf(get_events, sizeof(get_events) - 1, get_events_template, cur_dive->number);
retval = sqlite3_exec(handle, get_events, &dm4_events, 0, &err);
if (retval != SQLITE_OK) {
- fprintf(stderr, _("Database query get_events failed.\n"));
+ fprintf(stderr, tr("Database query get_events failed.\n"));
return 1;
}
@@ -1828,14 +1918,14 @@ int parse_dm4_buffer(const char *url, const char *buffer, int size,
retval = sqlite3_open(url,&handle);
if(retval) {
- fprintf(stderr, _("Database connection failed '%s'.\n"), url);
+ fprintf(stderr, tr("Database connection failed '%s'.\n"), url);
return 1;
}
retval = sqlite3_exec(handle, get_dives, &dm4_dive, handle, &err);
if (retval != SQLITE_OK) {
- fprintf(stderr, _("Database query failed '%s'.\n"), url);
+ fprintf(stderr, tr("Database query failed '%s'.\n"), url);
return 1;
}
@@ -1863,7 +1953,11 @@ static xsltStylesheetPtr try_get_stylesheet(const char *path, int len, const cha
return NULL;
memcpy(filename, path, len);
- filename[len] = G_DIR_SEPARATOR;
+#ifdef WIN32
+ filename[len] = '\\';
+#else
+ filename[len] = '/';
+#endif
memcpy(filename + len + 1, name, namelen+1);
ret = NULL;
@@ -1943,7 +2037,7 @@ static xmlDoc *test_xslt_transforms(xmlDoc *doc, char **error)
xmlSubstituteEntitiesDefault(1);
xslt = get_stylesheet(info->file);
if (xslt == NULL) {
- parser_error(error, _("Can't open stylesheet (%s)/%s"), xslt_path, info->file);
+ parser_error(error, tr("Can't open stylesheet (%s)/%s"), xslt_path, info->file);
return doc;
}
diff --git a/planner-gtk.c b/planner-gtk.c
index d5fddec46..b6306bdee 100644
--- a/planner-gtk.c
+++ b/planner-gtk.c
@@ -4,7 +4,6 @@
*
* (c) Dirk Hohndel 2013
*/
-#include <libintl.h>
#include <glib/gi18n.h>
#include <unistd.h>
#include <ctype.h>
diff --git a/planner.c b/planner.c
index 4d790dc9e..bddb5a737 100644
--- a/planner.c
+++ b/planner.c
@@ -4,13 +4,13 @@
*
* (c) Dirk Hohndel 2013
*/
-#include <libintl.h>
-#include <glib/gi18n.h>
#include <unistd.h>
#include <ctype.h>
+#include <string.h>
#include "dive.h"
#include "divelist.h"
#include "planner.h"
+#include "gettext.h"
int decostoplevels[] = { 0, 3000, 6000, 9000, 12000, 15000, 18000, 21000, 24000, 27000,
30000, 33000, 36000, 39000, 42000, 45000, 48000, 51000, 54000, 57000,
@@ -47,7 +47,7 @@ void dump_plan(struct diveplan *diveplan)
}
#endif
-void set_last_stop(gboolean last_stop_6m)
+void set_last_stop(bool last_stop_6m)
{
if (last_stop_6m == TRUE)
decostoplevels[1] = 6000;
@@ -69,7 +69,7 @@ void get_gas_from_events(struct divecomputer *dc, int time, int *o2, int *he)
/* simple helper function to compare two permille values with
* (rounded) percent granularity */
-static inline gboolean match_percent(int a, int b)
+static inline bool match_percent(int a, int b)
{
return (a + 5) / 10 == (b + 5) / 10;
}
@@ -91,15 +91,15 @@ static int get_gasidx(struct dive *dive, int o2, int he)
void get_gas_string(int o2, int he, char *text, int len)
{
if (is_air(o2, he))
- snprintf(text, len, _("air"));
+ snprintf(text, len, tr("air"));
else if (he == 0)
- snprintf(text, len, _("EAN%d"), (o2 + 5) / 10);
+ snprintf(text, len, tr("EAN%d"), (o2 + 5) / 10);
else
snprintf(text, len, "(%d/%d)", (o2 + 5) / 10, (he + 5) / 10);
}
/* returns the tissue tolerance at the end of this (partial) dive */
-double tissue_at_end(struct dive *dive, char **cached_datap, char **error_string_p)
+double tissue_at_end(struct dive *dive, char **cached_datap, const char **error_string_p)
{
struct divecomputer *dc;
struct sample *sample, *psample;
@@ -128,7 +128,7 @@ double tissue_at_end(struct dive *dive, char **cached_datap, char **error_string
t1 = sample->time.seconds;
get_gas_from_events(&dive->dc, t0, &o2, &he);
if ((gasidx = get_gasidx(dive, o2, he)) == -1) {
- snprintf(buf, sizeof(buf),_("Can't find gas %d/%d"), (o2 + 5) / 10, (he + 5) / 10);
+ snprintf(buf, sizeof(buf),tr("Can't find gas %d/%d"), (o2 + 5) / 10, (he + 5) / 10);
*error_string_p = buf;
gasidx = 0;
}
@@ -146,7 +146,7 @@ double tissue_at_end(struct dive *dive, char **cached_datap, char **error_string
}
/* how many seconds until we can ascend to the next stop? */
-int time_at_last_depth(struct dive *dive, int o2, int he, int next_stop, char **cached_data_p, char **error_string_p)
+int time_at_last_depth(struct dive *dive, int o2, int he, int next_stop, char **cached_data_p, const char **error_string_p)
{
int depth, gasidx;
double surface_pressure, tissue_tolerance;
@@ -189,11 +189,11 @@ int add_gas(struct dive *dive, int o2, int he)
mix->he.permille = he;
/* since air is stored as 0/0 we need to set a name or an air cylinder
* would be seen as unset (by cylinder_nodata()) */
- cyl->type.description = strdup(_("Cylinder for planning"));
+ cyl->type.description = strdup(tr("Cylinder for planning"));
return i;
}
-struct dive *create_dive_from_plan(struct diveplan *diveplan, char **error_string)
+struct dive *create_dive_from_plan(struct diveplan *diveplan, const char **error_string)
{
struct dive *dive;
struct divedatapoint *dp;
@@ -214,7 +214,7 @@ struct dive *create_dive_from_plan(struct diveplan *diveplan, char **error_strin
dive->when = diveplan->when;
dive->dc.surface_pressure.mbar = diveplan->surface_pressure;
dc = &dive->dc;
- dc->model = strdup(_("Simulated Dive"));
+ dc->model = strdup(tr("Simulated Dive"));
dp = diveplan->dp;
/* let's start with the gas given on the first segment */
@@ -291,7 +291,7 @@ struct dive *create_dive_from_plan(struct diveplan *diveplan, char **error_strin
gas_error_exit:
free(dive);
- *error_string = _("Too many gas mixes");
+ *error_string = tr("Too many gas mixes");
return NULL;
}
@@ -337,7 +337,7 @@ struct divedatapoint *get_nth_dp(struct diveplan *diveplan, int idx)
}
/* return -1 to warn about potentially very long calculation */
-int add_duration_to_nth_dp(struct diveplan *diveplan, int idx, int duration, gboolean is_rel)
+int add_duration_to_nth_dp(struct diveplan *diveplan, int idx, int duration, bool is_rel)
{
struct divedatapoint *pdp, *dp = get_nth_dp(diveplan, idx);
if (idx > 0) {
@@ -508,7 +508,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive)
if (!dp)
return;
- snprintf(buffer, sizeof(buffer), _("%s\nSubsurface dive plan\nbased on GFlow = %.0f and GFhigh = %.0f\n\n"),
+ snprintf(buffer, sizeof(buffer), tr("%s\nSubsurface dive plan\nbased on GFlow = %.0f and GFhigh = %.0f\n\n"),
disclaimer, plangflow * 100, plangfhigh * 100);
/* we start with gas 0, then check if that was changed */
o2 = dive->cylinder[0].gasmix.o2.permille;
@@ -549,7 +549,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive)
if (dp->depth != lastdepth) {
used = diveplan->bottomsac / 1000.0 * depth_to_mbar((dp->depth + lastdepth) / 2, dive) *
(dp->time - lasttime) / 60;
- snprintf(buffer + len, sizeof(buffer) - len, _("Transition to %.*f %s in %d:%02d min - runtime %d:%02u on %s\n"),
+ snprintf(buffer + len, sizeof(buffer) - len, tr("Transition to %.*f %s in %d:%02d min - runtime %d:%02u on %s\n"),
decimals, depthvalue, depth_unit,
FRACTION(dp->time - lasttime, 60),
FRACTION(dp->time, 60),
@@ -558,7 +558,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive)
/* we use deco SAC rate during the calculated deco stops, bottom SAC rate everywhere else */
int sac = dp->entered ? diveplan->bottomsac : diveplan->decosac;
used = sac / 1000.0 * depth_to_mbar(dp->depth, dive) * (dp->time - lasttime) / 60;
- snprintf(buffer + len, sizeof(buffer) - len, _("Stay at %.*f %s for %d:%02d min - runtime %d:%02u on %s\n"),
+ snprintf(buffer + len, sizeof(buffer) - len, tr("Stay at %.*f %s for %d:%02d min - runtime %d:%02u on %s\n"),
decimals, depthvalue, depth_unit,
FRACTION(dp->time - lasttime, 60),
FRACTION(dp->time, 60),
@@ -569,7 +569,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive)
get_gas_string(newo2, newhe, gas, sizeof(gas));
if (o2 != newo2 || he != newhe) {
len = strlen(buffer);
- snprintf(buffer + len, sizeof(buffer) - len, _("Switch gas to %s\n"), gas);
+ snprintf(buffer + len, sizeof(buffer) - len, tr("Switch gas to %s\n"), gas);
}
o2 = newo2;
he = newhe;
@@ -577,7 +577,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive)
lastdepth = dp->depth;
} while ((dp = dp->next) != NULL);
len = strlen(buffer);
- snprintf(buffer + len, sizeof(buffer) - len, _("Gas consumption:\n"));
+ snprintf(buffer + len, sizeof(buffer) - len, tr("Gas consumption:\n"));
for (gasidx = 0; gasidx < MAX_CYLINDERS; gasidx++) {
double volume;
const char *unit;
@@ -588,13 +588,13 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive)
volume = get_volume_units(consumption[gasidx], NULL, &unit);
get_gas_string(dive->cylinder[gasidx].gasmix.o2.permille,
dive->cylinder[gasidx].gasmix.he.permille, gas, sizeof(gas));
- snprintf(buffer + len, sizeof(buffer) - len, _("%.0f%s of %s\n"), volume, unit, gas);
+ snprintf(buffer + len, sizeof(buffer) - len, tr("%.0f%s of %s\n"), volume, unit, gas);
}
dive->notes = strdup(buffer);
}
#endif
-void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, bool add_deco, char **error_string_p)
+void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, bool add_deco, const char **error_string_p)
{
struct dive *dive;
struct sample *sample;
@@ -803,15 +803,15 @@ int validate_gas(const char *text, int *o2_p, int *he_p)
if (!text)
return 0;
- while (g_ascii_isspace(*text))
+ while (isspace(*text))
text++;
if (!*text)
return 0;
- if (!strcasecmp(text, _("air"))) {
- o2 = O2_IN_AIR; he = 0; text += strlen(_("air"));
- } else if (!strncasecmp(text, _("ean"), 3)) {
+ if (!strcasecmp(text, tr("air"))) {
+ o2 = O2_IN_AIR; he = 0; text += strlen(tr("air"));
+ } else if (!strncasecmp(text, tr("ean"), 3)) {
o2 = get_permille(text+3, &text); he = 0;
} else {
o2 = get_permille(text, &text); he = 0;
@@ -820,7 +820,7 @@ int validate_gas(const char *text, int *o2_p, int *he_p)
}
/* We don't want any extra crud */
- while (g_ascii_isspace(*text))
+ while (isspace(*text))
text++;
if (*text)
return 0;
@@ -843,19 +843,19 @@ int validate_time(const char *text, int *sec_p, int *rel_p)
if (!text)
return 0;
- while (g_ascii_isspace(*text))
+ while (isspace(*text))
text++;
rel = 1;
if (*text == '+') {
rel = 1;
text++;
- while (g_ascii_isspace(*text))
+ while (isspace(*text))
text++;
} else if (*text == '@') {
rel = 0;
text++;
- while (g_ascii_isspace(*text))
+ while (isspace(*text))
text++;
}
@@ -892,7 +892,7 @@ int validate_time(const char *text, int *sec_p, int *rel_p)
}
/* Maybe we should accept 'min' at the end? */
- if (g_ascii_isspace(*text))
+ if (isspace(*text))
text++;
if (*text)
return 0;
@@ -913,18 +913,18 @@ int validate_depth(const char *text, int *mm_p)
if (depth < 0)
return 0;
- while (g_ascii_isspace(*text))
+ while (isspace(*text))
text++;
imperial = get_units()->length == FEET;
if (*text == 'm') {
imperial = 0;
text++;
- } else if (!strcasecmp(text, _("ft"))) {
+ } else if (!strcasecmp(text, tr("ft"))) {
imperial = 1;
text += 2;
}
- while (g_ascii_isspace(*text))
+ while (isspace(*text))
text++;
if (*text)
return 0;
@@ -952,10 +952,10 @@ int validate_po2(const char *text, int *mbar_po2)
if (po2 < 0)
return 0;
- while (g_ascii_isspace(*text))
+ while (isspace(*text))
text++;
- while (g_ascii_isspace(*text))
+ while (isspace(*text))
text++;
if (*text)
return 0;
@@ -975,22 +975,22 @@ int validate_volume(const char *text, int *sac)
if (volume < 0)
return 0;
- while (g_ascii_isspace(*text))
+ while (isspace(*text))
text++;
imperial = get_units()->volume == CUFT;
if (*text == 'l') {
imperial = 0;
text++;
- } else if (!strncasecmp(text, _("cuft"), 4)) {
+ } else if (!strncasecmp(text, tr("cuft"), 4)) {
imperial = 1;
text += 4;
}
- while (g_ascii_isspace(*text) || *text == '/')
+ while (isspace(*text) || *text == '/')
text++;
- if (!strncasecmp(text, _("min"), 3))
+ if (!strncasecmp(text, tr("min"), 3))
text += 3;
- while (g_ascii_isspace(*text))
+ while (isspace(*text))
text++;
if (*text)
return 0;
diff --git a/planner.h b/planner.h
index fbff88ad8..b61d76b7d 100644
--- a/planner.h
+++ b/planner.h
@@ -6,7 +6,6 @@
extern "C" {
#endif
-extern void plan(struct diveplan *diveplan, char **cache_datap, struct dive **divep, bool add_plan, char **error_string_p);
extern int validate_gas(const char *text, int *o2_p, int *he_p);
extern int validate_time(const char *text, int *sec_p, int *rel_p);
extern int validate_depth(const char *text, int *mm_p);
@@ -14,9 +13,9 @@ extern int validate_po2(const char *text, int *mbar_po2);
extern int validate_volume(const char *text, int *sac);
extern timestamp_t current_time_notz(void);
extern void show_planned_dive(char **error_string_p);
-extern int add_duration_to_nth_dp(struct diveplan *diveplan, int idx, int duration, gboolean is_rel);
+extern int add_duration_to_nth_dp(struct diveplan *diveplan, int idx, int duration, bool is_rel);
extern void add_po2_to_nth_dp(struct diveplan *diveplan, int idx, int po2);
-extern void set_last_stop(gboolean last_stop_6m);
+extern void set_last_stop(bool last_stop_6m);
extern struct diveplan diveplan;
extern struct dive *planned_dive;
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);
diff --git a/qt-gui.cpp b/qt-gui.cpp
index 701a88b9e..178ed52af 100644
--- a/qt-gui.cpp
+++ b/qt-gui.cpp
@@ -1,7 +1,5 @@
/* qt-gui.cpp */
/* Qt UI implementation */
-#include <libintl.h>
-#include <glib/gi18n.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -39,11 +37,15 @@
#include <QDateTime>
#include <QRegExp>
+#include <gettextfromc.h>
+#define tr(arg) gettextFromC::instance()->tr(arg)
+
const char *default_dive_computer_vendor;
const char *default_dive_computer_product;
const char *default_dive_computer_device;
DiveComputerList dcList;
+#if 0
class Translator: public QTranslator
{
Q_OBJECT
@@ -66,6 +68,7 @@ QString Translator::translate(const char *context, const char *sourceText,
{
return gettext(sourceText);
}
+#endif
static QApplication *application = NULL;
static MainWindow *window = NULL;
@@ -115,7 +118,6 @@ void init_ui(int *argcp, char ***argvp)
default_dive_computer_device = getSetting(s, "dive_computer_device");
s.endGroup();
- application->installTranslator(new Translator(application));
window = new MainWindow();
window->show();
if (existing_filename && existing_filename[0] != '\0')
@@ -141,7 +143,7 @@ void exit_ui(void)
free((void *)default_dive_computer_device);
}
-void set_filename(const char *filename, gboolean force)
+void set_filename(const char *filename, bool force)
{
if (!force && existing_filename)
return;
@@ -195,10 +197,10 @@ QString get_depth_string(int mm, bool showunit, bool showdecimal)
{
if (prefs.units.length == units::METERS) {
double meters = mm / 1000.0;
- return QString("%1%2").arg(meters, 0, 'f', (showdecimal && meters < 20.0) ? 1 : 0 ).arg(showunit ? _("m") : "");
+ return QString("%1%2").arg(meters, 0, 'f', (showdecimal && meters < 20.0) ? 1 : 0 ).arg(showunit ? tr("m") : "");
} else {
double feet = mm_to_feet(mm);
- return QString("%1%2").arg(feet, 0, 'f', showdecimal ? 1 : 0). arg(showunit ? _("ft") : "");
+ return QString("%1%2").arg(feet, 0, 'f', showdecimal ? 1 : 0). arg(showunit ? tr("ft") : "");
}
}
@@ -219,9 +221,9 @@ QString get_weight_string(weight_t weight, bool showunit)
{
QString str = weight_string (weight.grams);
if (get_units()->weight == units::KG) {
- str = QString ("%1%2").arg(str).arg(showunit ? _("kg") : "");
+ str = QString ("%1%2").arg(str).arg(showunit ? tr("kg") : "");
} else {
- str = QString ("%1%2").arg(str).arg(showunit ? _("lbs") : "");
+ str = QString ("%1%2").arg(str).arg(showunit ? tr("lbs") : "");
}
return (str);
}
@@ -270,11 +272,11 @@ QString get_temperature_string(temperature_t temp, bool showunit)
if (prefs.units.temperature == units::CELSIUS) {
double celsius = mkelvin_to_C(temp.mkelvin);
return QString("%1%2%3").arg(celsius, 0, 'f', 1).arg(showunit ? (UTF8_DEGREE): "")
- .arg(showunit ? _("C") : "");
+ .arg(showunit ? tr("C") : "");
} else {
double fahrenheit = mkelvin_to_F(temp.mkelvin);
return QString("%1%2%3").arg(fahrenheit, 0, 'f', 1).arg(showunit ? (UTF8_DEGREE): "")
- .arg(showunit ? _("F") : "");
+ .arg(showunit ? tr("F") : "");
}
}
@@ -290,10 +292,10 @@ QString get_volume_string(volume_t volume, bool showunit)
{
if (prefs.units.volume == units::LITER) {
double liter = volume.mliter / 1000.0;
- return QString("%1%2").arg(liter, 0, 'f', liter >= 40.0 ? 0 : 1 ).arg(showunit ? _("l") : "");
+ return QString("%1%2").arg(liter, 0, 'f', liter >= 40.0 ? 0 : 1 ).arg(showunit ? tr("l") : "");
} else {
double cuft = ml_to_cuft(volume.mliter);
- return QString("%1%2").arg(cuft, 0, 'f', cuft >= 20.0 ? 0 : (cuft >= 2.0 ? 1 : 2)).arg(showunit ? _("cuft") : "");
+ return QString("%1%2").arg(cuft, 0, 'f', cuft >= 20.0 ? 0 : (cuft >= 2.0 ? 1 : 2)).arg(showunit ? tr("cuft") : "");
}
}
@@ -309,10 +311,10 @@ QString get_pressure_string(pressure_t pressure, bool showunit)
{
if (prefs.units.pressure == units::BAR) {
double bar = pressure.mbar / 1000.0;
- return QString("%1%2").arg(bar, 0, 'f', 1).arg(showunit ? _("bar") : "");
+ return QString("%1%2").arg(bar, 0, 'f', 1).arg(showunit ? tr("bar") : "");
} else {
double psi = mbar_to_PSI(pressure.mbar);
- return QString("%1%2").arg(psi, 0, 'f', 0).arg(showunit ? _("psi") : "");
+ return QString("%1%2").arg(psi, 0, 'f', 0).arg(showunit ? tr("psi") : "");
}
}
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 1976fcb9d..452d1c848 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -1184,7 +1184,7 @@ void DivePlannerPointsModel::createTemporaryPlan()
#endif
char *cache = NULL;
tempDive = NULL;
- char *errorString = NULL;
+ const char *errorString = NULL;
plan(&diveplan, &cache, &tempDive, isPlanner(), &errorString);
if (mode == ADD)
copy_samples(tempDive, current_dive);
@@ -1216,7 +1216,7 @@ void DivePlannerPointsModel::createPlan()
// to not delete it later. mumble. ;p
char *cache = NULL;
tempDive = NULL;
- char *errorString = NULL;
+ const char *errorString = NULL;
createTemporaryPlan();
plan(&diveplan, &cache, &tempDive, isPlanner(), &errorString);
diff --git a/qt-ui/diveplanner.h b/qt-ui/diveplanner.h
index ee81c6996..acb36e63e 100644
--- a/qt-ui/diveplanner.h
+++ b/qt-ui/diveplanner.h
@@ -8,7 +8,6 @@
#include <QDateTime>
#include "dive.h"
-#include "ui_diveplanner.h"
class QListView;
class QStringListModel;
@@ -202,6 +201,8 @@ private:
int dpMaxTime; // this is the time of the dive calculated by the deco.
};
+#include "ui_diveplanner.h"
+
class DivePlannerWidget : public QWidget {
Q_OBJECT
public:
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 2498a0d97..fd40bed86 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -14,6 +14,7 @@
#include "globe.h"
#include "completionmodels.h"
#include "diveplanner.h"
+#include "qthelper.h"
#include <QLabel>
#include <QCompleter>
@@ -695,9 +696,8 @@ void MainTab::on_notes_textChanged()
void MainTab::on_coordinates_textChanged(const QString& text)
{
- QByteArray textByteArray = text.toLocal8Bit();
- gboolean gpsChanged = FALSE;
- EDIT_SELECTED_DIVES(gpsChanged |= gps_changed(mydive, NULL, textByteArray.data()));
+ bool gpsChanged = FALSE;
+ EDIT_SELECTED_DIVES(gpsChanged |= gpsHasChanged(mydive, NULL, text));
if (gpsChanged) {
markChangedWidget(ui.coordinates);
} else {
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 84b1bc50b..247cfdf2f 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -20,7 +20,6 @@
#include "divelistview.h"
#include "starwidget.h"
-#include "glib.h"
#include "../dive.h"
#include "../divelist.h"
#include "../pref.h"
@@ -36,8 +35,6 @@
#include "about.h"
#include "printdialog.h"
-#include "glib/gi18n.h"
-
static MainWindow* instance = 0;
MainWindow* mainWindow()
@@ -271,7 +268,7 @@ void MainWindow::on_actionAddDive_triggered()
// now cheat - create one dive that we use to store the info tab data in
struct dive *dive = alloc_dive();
dive->when = QDateTime::currentMSecsSinceEpoch() / 1000L;
- dive->dc.model = _("manually added dive"); // do not use tr here since it expects a char*.
+ dive->dc.model = tr("manually added dive").toLocal8Bit().constData(); // do not use tr here since it expects a char*.
record_dive(dive);
select_dive(get_divenr(dive));
ui.InfoWidget->updateDiveInfo(selected_dive);
diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp
index f0d33e53f..cd6273087 100644
--- a/qt-ui/subsurfacewebservices.cpp
+++ b/qt-ui/subsurfacewebservices.cpp
@@ -13,7 +13,7 @@
#include "../divelist.h"
struct dive_table gps_location_table;
-static gboolean merge_locations_into_dives(void);
+static bool merge_locations_into_dives(void);
SubsurfaceWebServices* SubsurfaceWebServices::instance()
{
@@ -177,7 +177,7 @@ unsigned int SubsurfaceWebServices::download_dialog_parse_response(const QByteAr
return status;
}
-static gboolean is_automatic_fix(struct dive *gpsfix)
+static bool is_automatic_fix(struct dive *gpsfix)
{
if (gpsfix && gpsfix->location &&
(!strcmp(gpsfix->location, "automatic fix") ||
@@ -188,7 +188,7 @@ static gboolean is_automatic_fix(struct dive *gpsfix)
#define SAME_GROUP 6 * 3600 // six hours
-static gboolean merge_locations_into_dives(void)
+static bool merge_locations_into_dives(void)
{
int i, nr = 0, changed = 0;
struct dive *gpsfix, *last_named_fix = NULL, *dive;
diff --git a/qthelper.cpp b/qthelper.cpp
index 36d1d02c7..a4e8bd50b 100644
--- a/qthelper.cpp
+++ b/qthelper.cpp
@@ -1,4 +1,6 @@
#include "qthelper.h"
+#include <QRegExp>
+#include <QDebug>
DiveComputerList::DiveComputerList()
{
@@ -83,14 +85,65 @@ QString weight_string(int weight_in_grams)
if (get_units()->weight == units::KG) {
int gr = weight_in_grams % 1000;
int kg = weight_in_grams / 1000;
- if (kg >= 20.0) {
- str = QString("0");
- } else {
- str = QString("%1.%2").arg(kg).arg((unsigned)(gr) / 100);
- }
+ if (kg >= 20.0) {
+ str = QString("0");
+ } else {
+ str = QString("%1.%2").arg(kg).arg((unsigned)(gr) / 100);
+ }
} else {
double lbs = grams_to_lbs(weight_in_grams);
str = QString("%1").arg(lbs, 0, 'f', lbs >= 40.0 ? 0 : 1 );
}
return (str);
}
+
+bool parseGpsText(const QString& gps_text, double *latitude, double *longitude)
+{
+ /* an empty string is interpreted as 0.0,0.0 and therefore "no gps location" */
+ if (gps_text.trimmed() == "") {
+ *latitude = 0.0;
+ *longitude = 0.0;
+ return true;
+ }
+ QRegExp r("\\s*([SN])\\s*(\\d+)[" UTF8_DEGREE "\\s]+(\\d+)\\.(\\d+)[^EW]*([EW])\\s*(\\d+)[" UTF8_DEGREE "\\s]+(\\d+)\\.(\\d+)");
+ if (r.indexIn(gps_text) != 8) {
+ // qDebug() << "Hemisphere" << r.cap(1) << "deg" << r.cap(2) << "min" << r.cap(3) << "decimal" << r.cap(4);
+ // qDebug() << "Hemisphere" << r.cap(5) << "deg" << r.cap(6) << "min" << r.cap(7) << "decimal" << r.cap(8);
+ *latitude = r.cap(2).toInt() + (r.cap(3) + QString(".") + r.cap(4)).toDouble() / 60.0;
+ *longitude = r.cap(6).toInt() + (r.cap(7) + QString(".") + r.cap(8)).toDouble() / 60.0;
+ if (r.cap(1) == "S")
+ *latitude *= -1.0;
+ if (r.cap(5) == "W")
+ *longitude *= -1.0;
+ // qDebug("%s -> %8.5f / %8.5f", gps_text.toLocal8Bit().data(), *latitude, *longitude);
+ return true;
+ }
+ return false;
+}
+
+bool gpsHasChanged(struct dive *dive, struct dive *master, const QString& gps_text)
+{
+ double latitude, longitude;
+ int latudeg, longudeg;
+
+ /* if we have a master and the dive's gps address is different from it,
+ * don't change the dive */
+ if (master && (master->latitude.udeg != dive->latitude.udeg ||
+ master->longitude.udeg != dive->longitude.udeg))
+ return false;
+
+ if (!parseGpsText(gps_text, &latitude, &longitude))
+ return false;
+
+ latudeg = rint(1000000 * latitude);
+ longudeg = rint(1000000 * longitude);
+
+ /* if dive gps didn't change, nothing changed */
+ if (dive->latitude.udeg == latudeg && dive->longitude.udeg == longudeg)
+ return false;
+ /* ok, update the dive and mark things changed */
+ dive->latitude.udeg = latudeg;
+ dive->longitude.udeg = longudeg;
+ return true;
+
+}
diff --git a/qthelper.h b/qthelper.h
index 3ac83b5c4..0ab184b78 100644
--- a/qthelper.h
+++ b/qthelper.h
@@ -29,10 +29,11 @@ public:
void rmDC(QString m, uint32_t d);
DiveComputerNode matchDC(QString m, uint32_t d);
DiveComputerNode matchModel(QString m);
- QMultiMap<QString, struct DiveComputerNode> dcMap;
- QMultiMap<QString, struct DiveComputerNode> dcWorkingMap;
+ QMultiMap<QString, class DiveComputerNode> dcMap;
+ QMultiMap<QString, class DiveComputerNode> dcWorkingMap;
};
QString weight_string(int weight_in_grams);
+bool gpsHasChanged(struct dive* dive, struct dive *master, const QString &gps_text);
#endif // QTHELPER_H
diff --git a/save-xml.c b/save-xml.c
index 454da8484..6d95cb4f7 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -125,12 +125,12 @@ static void show_utf8(FILE *f, const char *text, const char *pre, const char *po
if (!text)
return;
- while (g_ascii_isspace(*text))
+ while (isspace(*text))
text++;
len = strlen(text);
if (!len)
return;
- while (len && g_ascii_isspace(text[len-1]))
+ while (len && isspace(text[len-1]))
len--;
/* FIXME! Quoting! */
fputs(pre, f);
@@ -549,13 +549,13 @@ void save_dives(const char *filename)
save_dives_logic(filename, FALSE);
}
-void save_dives_logic(const char *filename, const gboolean select_only)
+void save_dives_logic(const char *filename, const bool select_only)
{
int i;
struct dive *dive;
dive_trip_t *trip;
- FILE *f = g_fopen(filename, "w");
+ FILE *f = fopen(filename, "w");
if (!f)
return;
diff --git a/statistics.c b/statistics.c
index 83675cf22..09d9d9e54 100644
--- a/statistics.c
+++ b/statistics.c
@@ -6,7 +6,8 @@
* void process_all_dives(struct dive *dive, struct dive **prev_dive);
* void get_selected_dives_text(char *buffer, int size);
*/
-#include <glib/gi18n.h>
+#include "gettext.h"
+#include <string.h>
#include <ctype.h>
#include "dive.h"
@@ -17,10 +18,10 @@
/* mark for translation but don't translate here as these terms are used
* in save-xml.c */
char *dtag_names[DTAG_NR] = {
- N_("invalid"), N_("boat"), N_("shore"), N_("drift"), N_("deep"), N_("cavern"),
- N_("ice"), N_("wreck"), N_("cave"), N_("altitude"), N_("pool"), N_("lake"),
- N_("river"), N_("night"), N_("freshwater"), N_("training"), N_("teaching"),
- N_("photo"), N_("video"), N_("deco")
+ QT_TR_NOOP("invalid"), QT_TR_NOOP("boat"), QT_TR_NOOP("shore"), QT_TR_NOOP("drift"), QT_TR_NOOP("deep"), QT_TR_NOOP("cavern"),
+ QT_TR_NOOP("ice"), QT_TR_NOOP("wreck"), QT_TR_NOOP("cave"), QT_TR_NOOP("altitude"), QT_TR_NOOP("pool"), QT_TR_NOOP("lake"),
+ QT_TR_NOOP("river"), QT_TR_NOOP("night"), QT_TR_NOOP("freshwater"), QT_TR_NOOP("training"), QT_TR_NOOP("teaching"),
+ QT_TR_NOOP("photo"), QT_TR_NOOP("video"), QT_TR_NOOP("deco")
};
static stats_t stats;
@@ -195,15 +196,15 @@ char *get_time_string(int seconds, int maxdays)
{
static char buf[80];
if (maxdays && seconds > 3600 * 24 * maxdays) {
- snprintf(buf, sizeof(buf), _("more than %d days"), maxdays);
+ snprintf(buf, sizeof(buf), tr("more than %d days"), maxdays);
} else {
int days = seconds / 3600 / 24;
int hours = (seconds - days * 3600 * 24) / 3600;
int minutes = (seconds - days * 3600 * 24 - hours * 3600) / 60;
if (days > 0)
- snprintf(buf, sizeof(buf), _("%dd %dh %dmin"), days, hours, minutes);
+ snprintf(buf, sizeof(buf), tr("%dd %dh %dmin"), days, hours, minutes);
else
- snprintf(buf, sizeof(buf), _("%dh %dmin"), hours, minutes);
+ snprintf(buf, sizeof(buf), tr("%dh %dmin"), hours, minutes);
}
return buf;
}
@@ -214,14 +215,14 @@ static void get_ranges(char *buffer, int size)
int i, len;
int first, last = -1;
- snprintf(buffer, size, _("for dives #"));
+ snprintf(buffer, size, tr("for dives #"));
for (i = 0; i < dive_table.nr; i++) {
struct dive *dive = get_dive(i);
if (! dive->selected)
continue;
if (dive->number < 1) {
/* uhh - weird numbers - bail */
- snprintf(buffer, size, _("for selected dives"));
+ snprintf(buffer, size, tr("for selected dives"));
return;
}
len = strlen(buffer);
@@ -256,13 +257,13 @@ void get_selected_dives_text(char *buffer, int size)
{
if (amount_selected == 1) {
if (current_dive)
- snprintf(buffer, size, _("for dive #%d"), current_dive->number);
+ snprintf(buffer, size, tr("for dive #%d"), current_dive->number);
else
- snprintf(buffer, size, _("for selected dive"));
+ snprintf(buffer, size, tr("for selected dive"));
} else if (amount_selected == dive_table.nr) {
- snprintf(buffer, size, _("for all dives"));
+ snprintf(buffer, size, tr("for all dives"));
} else if (amount_selected == 0) {
- snprintf(buffer, size, _("(no dives)"));
+ snprintf(buffer, size, tr("(no dives)"));
} else {
get_ranges(buffer, size);
if (strlen(buffer) == size -1) {
@@ -352,10 +353,10 @@ char *get_gaslist(struct dive *dive)
o2 = get_o2(&cyl->gasmix);
he = get_he(&cyl->gasmix);
if (is_air(o2, he))
- snprintf(buf + offset, MAXBUF - offset, (offset > 0) ? ", %s" : "%s", _("air"));
+ snprintf(buf + offset, MAXBUF - offset, (offset > 0) ? ", %s" : "%s", tr("air"));
else
if (he == 0)
- snprintf(buf + offset, MAXBUF - offset, (offset > 0) ? _(", EAN%d") : _("EAN%d"),
+ snprintf(buf + offset, MAXBUF - offset, (offset > 0) ? tr(", EAN%d") : tr("EAN%d"),
(o2 + 5) / 10);
else
snprintf(buf + offset, MAXBUF - offset, (offset > 0) ? ", %d/%d" : "%d/%d",
@@ -363,6 +364,6 @@ char *get_gaslist(struct dive *dive)
offset = strlen(buf);
}
if (*buf == '\0')
- strncpy(buf, _("air"), MAXBUF);
+ strncpy(buf, tr("air"), MAXBUF);
return buf;
}
diff --git a/subsurfacestartup.c b/subsurfacestartup.c
index 741606ee4..a65c5c800 100644
--- a/subsurfacestartup.c
+++ b/subsurfacestartup.c
@@ -1,7 +1,7 @@
#include "subsurfacestartup.h"
#include <stdbool.h>
-#include <glib/gi18n.h>
-
+#include <string.h>
+#include "gettext.h"
struct preferences prefs;
struct preferences default_prefs = {
.units = SI_UNITS,
@@ -58,19 +58,19 @@ const char *weekday(int wday)
{
static const char wday_array[7][7] = {
/*++GETTEXT: these are three letter days - we allow up to six code bytes */
- N_("Sun"), N_("Mon"), N_("Tue"), N_("Wed"), N_("Thu"), N_("Fri"), N_("Sat")
+ QT_TR_NOOP("Sun"), QT_TR_NOOP("Mon"), QT_TR_NOOP("Tue"), QT_TR_NOOP("Wed"), QT_TR_NOOP("Thu"), QT_TR_NOOP("Fri"), QT_TR_NOOP("Sat")
};
- return _(wday_array[wday]);
+ return tr(wday_array[wday]);
}
const char *monthname(int mon)
{
static const char month_array[12][7] = {
/*++GETTEXT: these are three letter months - we allow up to six code bytes*/
- N_("Jan"), N_("Feb"), N_("Mar"), N_("Apr"), N_("May"), N_("Jun"),
- N_("Jul"), N_("Aug"), N_("Sep"), N_("Oct"), N_("Nov"), N_("Dec"),
+ QT_TR_NOOP("Jan"), QT_TR_NOOP("Feb"), QT_TR_NOOP("Mar"), QT_TR_NOOP("Apr"), QT_TR_NOOP("May"), QT_TR_NOOP("Jun"),
+ QT_TR_NOOP("Jul"), QT_TR_NOOP("Aug"), QT_TR_NOOP("Sep"), QT_TR_NOOP("Oct"), QT_TR_NOOP("Nov"), QT_TR_NOOP("Dec"),
};
- return _(month_array[mon]);
+ return tr(month_array[mon]);
}
/*
@@ -126,7 +126,7 @@ void parse_argument(const char *arg)
/* fallthrough */
case 'p':
/* ignore process serial number argument when run as native macosx app */
- if (strncmp(arg, "-psn_", 5) == 0) {
+ if (strncmp(arg, "-psQT_TR_NOOP(", 5) == 0) {
return;
}
/* fallthrough */
diff --git a/time.c b/time.c
index 36a834400..ed8222a0f 100644
--- a/time.c
+++ b/time.c
@@ -1,4 +1,3 @@
-#include <glib/gi18n.h>
#include <string.h>
#include "dive.h"
diff --git a/uemis-downloader.c b/uemis-downloader.c
index 9864cfe66..554da290c 100644
--- a/uemis-downloader.c
+++ b/uemis-downloader.c
@@ -13,11 +13,12 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <dirent.h>
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
#include <string.h>
-#include <glib/gi18n.h>
+#include "gettext.h"
#include "libdivecomputer.h"
#include "uemis.h"
@@ -27,9 +28,9 @@
#if USE_GTK_UI
#include "display-gtk.h"
#endif
-#define ERR_FS_ALMOST_FULL N_("Uemis Zurich: File System is almost full\nDisconnect/reconnect the dive computer\nand click \'Retry\'")
-#define ERR_FS_FULL N_("Uemis Zurich: File System is full\nDisconnect/reconnect the dive computer\nand try again")
-#define ERR_FS_SHORT_WRITE N_("Short write to req.txt file\nIs the Uemis Zurich plugged in correctly?")
+#define ERR_FS_ALMOST_FULL QT_TR_NOOP("Uemis Zurich: File System is almost full\nDisconnect/reconnect the dive computer\nand click \'Retry\'")
+#define ERR_FS_FULL QT_TR_NOOP("Uemis Zurich: File System is full\nDisconnect/reconnect the dive computer\nand try again")
+#define ERR_FS_SHORT_WRITE QT_TR_NOOP("Short write to req.txt file\nIs the Uemis Zurich plugged in correctly?")
#define BUFLEN 2048
#define NUM_PARAM_BUFS 10
@@ -55,7 +56,7 @@ static int mbuf_size = 0;
struct argument_block {
const char *mountpath;
progressbar_t *progress;
- gboolean force_download;
+ bool force_download;
};
#endif
@@ -98,7 +99,7 @@ static void uemis_ts(char *buffer, void *_when)
/* float minutes */
static void uemis_duration(char *buffer, duration_t *duration)
{
- duration->seconds = g_ascii_strtod(buffer, NULL) * 60 + 0.5;
+ duration->seconds = ascii_strtod(buffer, NULL) * 60 + 0.5;
}
/* int cm */
@@ -113,7 +114,7 @@ static void uemis_get_index(char *buffer, int *idx)
}
/* space separated */
-static void uemis_add_string(char *buffer, char **text)
+static void uemis_add_string(const char *buffer, char **text)
{
/* do nothing if this is an empty buffer (Uemis sometimes returns a single
* space for empty buffers) */
@@ -135,8 +136,8 @@ static void uemis_add_string(char *buffer, char **text)
static void uemis_get_weight(char *buffer, weightsystem_t *weight, int diveid)
{
weight->weight.grams = uemis_get_weight_unit(diveid) ?
- lbs_to_grams(g_ascii_strtod(buffer, NULL)) : g_ascii_strtod(buffer, NULL) * 1000;
- weight->description = strdup(_("unknown"));
+ lbs_to_grams(ascii_strtod(buffer, NULL)) : ascii_strtod(buffer, NULL) * 1000;
+ weight->description = strdup(tr("unknown"));
}
static struct dive *uemis_start_dive(uint32_t deviceid)
@@ -172,18 +173,36 @@ static long bytes_available(int file)
static int number_of_file(char *path)
{
int count = 0;
- GDir *dir = g_dir_open(path, 0, NULL);
- while (g_dir_read_name(dir))
- count++;
- g_dir_close(dir);
+ DIR * dirp;
+ struct dirent * entry;
+
+ dirp = opendir(path);
+ while ((entry = readdir(dirp)) != NULL) {
+ if (entry->d_type == DT_REG) { /* If the entry is a regular file */
+ count++;
+ }
+ }
+ closedir(dirp);
return count;
}
+static char *build_filename(const char *path, const char *name)
+{
+ int len = strlen(path) + strlen(name) + 1;
+ char *buf = malloc(len);
+#if WIN32
+ snprintf(buf, len, "%s\%s", path, name);
+#else
+ snprintf(buf, len, "%s/%s", path, name);
+#endif
+ return buf;
+}
+
/* Check if there's a req.txt file and get the starting filenr from it.
* Test for the maximum number of ANS files (I believe this is always
* 4000 but in case there are differences depending on firmware, this
* code is easy enough */
-static gboolean uemis_init(const char *path)
+static bool uemis_init(const char *path)
{
char *ans_path;
int i;
@@ -191,8 +210,8 @@ static gboolean uemis_init(const char *path)
if (!path)
return FALSE;
/* let's check if this is indeed a Uemis DC */
- reqtxt_path = g_build_filename(path, "/req.txt", NULL);
- reqtxt_file = g_open(reqtxt_path, O_RDONLY, 0666);
+ reqtxt_path = build_filename(path,"req.txt");
+ reqtxt_file = open(reqtxt_path, O_RDONLY, 0666);
if (!reqtxt_file) {
#if UEMIS_DEBUG & 1
fprintf(debugfile, ":EE req.txt can't be opened\n");
@@ -218,9 +237,9 @@ static gboolean uemis_init(const char *path)
/* It would be nice if we could simply go back to the first set of
* ANS files. But with a FAT filesystem that isn't possible */
- ans_path = g_build_filename(path, "ANS", NULL);
+ ans_path = build_filename(path, "ANS");
number_of_files = number_of_file(ans_path);
- g_free(ans_path);
+ free(ans_path);
/* initialize the array in which we collect the answers */
for (i = 0; i < NUM_PARAM_BUFS; i++)
param_buff[i] = "";
@@ -274,7 +293,7 @@ static char *next_segment(char *buf, int *offset, int size)
{
int i = *offset;
int seg_size;
- gboolean done = FALSE;
+ bool done = FALSE;
char *segment;
while (!done) {
@@ -319,7 +338,7 @@ static void buffer_add(char **buffer, int *buffer_size, char *buf)
}
/* are there more ANS files we can check? */
-static gboolean next_file(int max)
+static bool next_file(int max)
{
if (filenr >= max)
return FALSE;
@@ -359,7 +378,7 @@ static char *first_object_id_val(char* buf)
/* ultra-simplistic; it doesn't deal with the case when the object_id is
* split across two chunks. It also doesn't deal with the discrepancy between
* object_id and dive number as understood by the dive computer */
-static void show_progress(char *buf, char *what)
+static void show_progress(char *buf, const char *what)
{
char *val = first_object_id_val(buf);
if (val) {
@@ -367,7 +386,7 @@ static void show_progress(char *buf, char *what)
#if UEMIS_DEBUG & 2
fprintf(debugfile,"reading %s %s\n", what, val);
#endif
- uemis_info(_("Reading %s %s"), what, val);
+ uemis_info(tr("Reading %s %s"), what, val);
free(val);
}
}
@@ -380,25 +399,25 @@ static void uemis_increased_timeout(int *timeout)
}
/* send a request to the dive computer and collect the answer */
-static gboolean uemis_get_answer(const char *path, char *request, int n_param_in,
- int n_param_out, char **error_text)
+static bool uemis_get_answer(const char *path, char *request, int n_param_in,
+ int n_param_out, const char **error_text)
{
int i = 0, file_length;
char sb[BUFLEN];
char fl[13];
char tmp[101];
- char *what = _("data");
- gboolean searching = TRUE;
- gboolean assembling_mbuf = FALSE;
- gboolean ismulti = FALSE;
- gboolean found_answer = FALSE;
- gboolean more_files = TRUE;
- gboolean answer_in_mbuf = FALSE;
+ const char *what = tr("data");
+ bool searching = TRUE;
+ bool assembling_mbuf = FALSE;
+ bool ismulti = FALSE;
+ bool found_answer = FALSE;
+ bool more_files = TRUE;
+ bool answer_in_mbuf = FALSE;
char *ans_path;
int ans_file;
int timeout = UEMIS_LONG_TIMEOUT;
- reqtxt_file = g_open(reqtxt_path, O_RDWR | O_CREAT, 0666);
+ reqtxt_file = open(reqtxt_path, O_RDWR | O_CREAT, 0666);
snprintf(sb, BUFLEN, "n%04d12345678", filenr);
str_append_with_delim(sb, request);
for (i = 0; i < n_param_in; i++)
@@ -408,11 +427,11 @@ static gboolean uemis_get_answer(const char *path, char *request, int n_param_in
answer_in_mbuf = TRUE;
str_append_with_delim(sb, "");
if (! strcmp(request, "getDivelogs"))
- what = _("divelog entry id");
+ what = tr("divelog entry id");
else if (!strcmp(request, "getDivespot"))
- what = _("divespot data id");
+ what = tr("divespot data id");
else if (!strcmp(request, "getDive"))
- what = _("more data dive id");
+ what = tr("more data dive id");
}
str_append_with_delim(sb, "");
file_length = strlen(sb);
@@ -422,11 +441,11 @@ static gboolean uemis_get_answer(const char *path, char *request, int n_param_in
fprintf(debugfile,"::w req.txt \"%s\"\n", sb);
#endif
if (write(reqtxt_file, sb, strlen(sb)) != strlen(sb)) {
- *error_text = _(ERR_FS_SHORT_WRITE);
+ *error_text = tr(ERR_FS_SHORT_WRITE);
return FALSE;
}
if (! next_file(number_of_files)) {
- *error_text = _(ERR_FS_FULL);
+ *error_text = tr(ERR_FS_FULL);
more_files = FALSE;
}
trigger_response(reqtxt_file, "n", filenr, file_length);
@@ -438,8 +457,8 @@ static gboolean uemis_get_answer(const char *path, char *request, int n_param_in
return FALSE;
progress_bar_fraction = filenr / 4000.0;
snprintf(fl, 13, "ANS%d.TXT", filenr - 1);
- ans_path = g_build_filename(path, "ANS", fl, NULL);
- ans_file = g_open(ans_path, O_RDONLY, 0666);
+ ans_path = build_filename(build_filename(path, "ANS"), fl);
+ ans_file = open(ans_path, O_RDONLY, 0666);
read(ans_file, tmp, 100);
close(ans_file);
#if UEMIS_DEBUG & 8
@@ -453,7 +472,7 @@ static gboolean uemis_get_answer(const char *path, char *request, int n_param_in
pbuf[3] = 0;
fprintf(debugfile, "::t %s \"%s...\"\n", ans_path, pbuf);
#endif
- g_free(ans_path);
+ free(ans_path);
if (tmp[0] == '1') {
searching = FALSE;
if (tmp[1] == 'm') {
@@ -464,29 +483,29 @@ static gboolean uemis_get_answer(const char *path, char *request, int n_param_in
assembling_mbuf = FALSE;
if (assembling_mbuf) {
if (! next_file(number_of_files)) {
- *error_text = _(ERR_FS_FULL);
+ *error_text = tr(ERR_FS_FULL);
more_files = FALSE;
assembling_mbuf = FALSE;
}
- reqtxt_file = g_open(reqtxt_path, O_RDWR | O_CREAT, 0666);
+ reqtxt_file = open(reqtxt_path, O_RDWR | O_CREAT, 0666);
trigger_response(reqtxt_file, "n", filenr, file_length);
}
} else {
if (! next_file(number_of_files - 1)) {
- *error_text = _(ERR_FS_FULL);
+ *error_text = tr(ERR_FS_FULL);
more_files = FALSE;
assembling_mbuf = FALSE;
searching = FALSE;
}
- reqtxt_file = g_open(reqtxt_path, O_RDWR | O_CREAT, 0666);
+ reqtxt_file = open(reqtxt_path, O_RDWR | O_CREAT, 0666);
trigger_response(reqtxt_file, "r", filenr, file_length);
uemis_increased_timeout(&timeout);
}
if (ismulti && more_files && tmp[0] == '1') {
int size;
snprintf(fl, 13, "ANS%d.TXT", assembling_mbuf ? filenr - 2 : filenr - 1);
- ans_path = g_build_filename(path, "ANS", fl, NULL);
- ans_file = g_open(ans_path, O_RDONLY, 0666);
+ ans_path = build_filename(build_filename(path, "ANS"), fl);
+ ans_file = open(ans_path, O_RDONLY, 0666);
size = bytes_available(ans_file);
if (size > 3) {
char *buf = malloc(size - 2);
@@ -509,8 +528,8 @@ static gboolean uemis_get_answer(const char *path, char *request, int n_param_in
if (!ismulti) {
snprintf(fl, 13, "ANS%d.TXT", filenr - 1);
- ans_path = g_build_filename(path, "ANS", fl, NULL);
- ans_file = g_open(ans_path, O_RDONLY, 0666);
+ ans_path = build_filename(build_filename(path, "ANS"), fl);
+ ans_file = open(ans_path, O_RDONLY, 0666);
size = bytes_available(ans_file);
if (size > 3) {
buf = malloc(size - 2);
@@ -575,9 +594,9 @@ static void parse_divespot(char *buf)
"%s%s", len ? ", " : "", val);
} else if (!strcmp(type, "float")) {
if (!strcmp(tag, "longitude"))
- longitude = g_ascii_strtod(val, NULL);
+ longitude = ascii_strtod(val, NULL);
else if (!strcmp(tag, "latitude"))
- latitude = g_ascii_strtod(val, NULL);
+ latitude = ascii_strtod(val, NULL);
}
} while (tag && *tag);
uemis_set_divelocation(divespot, locationstring, latitude, longitude);
@@ -592,9 +611,9 @@ static void track_divespot(char *val, int diveid, char **location, degrees_t *la
return;
}
-static char *suit[] = { "", N_("wetsuit"), N_("semidry"), N_("drysuit") };
-static char *suit_type[] = { "", N_("shorty"), N_("vest"), N_("long john"), N_("jacket"), N_("full suit"), N_("2 pcs full suit") };
-static char *suit_thickness[] = { "", "0.5-2mm", "2-3mm", "3-5mm", "5-7mm", "8mm+", N_("membrane") };
+static char *suit[] = { "", QT_TR_NOOP("wetsuit"), QT_TR_NOOP("semidry"), QT_TR_NOOP("drysuit") };
+static char *suit_type[] = { "", QT_TR_NOOP("shorty"), QT_TR_NOOP("vest"), QT_TR_NOOP("long john"), QT_TR_NOOP("jacket"), QT_TR_NOOP("full suit"), QT_TR_NOOP("2 pcs full suit") };
+static char *suit_thickness[] = { "", "0.5-2mm", "2-3mm", "3-5mm", "5-7mm", "8mm+", QT_TR_NOOP("membrane") };
static void parse_tag(struct dive *dive, char *tag, char *val)
{
@@ -616,13 +635,13 @@ static void parse_tag(struct dive *dive, char *tag, char *val)
uemis_add_string(val, &dive->notes);
} else if (!strcmp(tag, "u8DiveSuit")) {
if (*suit[atoi(val)])
- uemis_add_string(_(suit[atoi(val)]), &dive->suit);
+ uemis_add_string(tr(suit[atoi(val)]), &dive->suit);
} else if (!strcmp(tag, "u8DiveSuitType")) {
if (*suit_type[atoi(val)])
- uemis_add_string(_(suit_type[atoi(val)]), &dive->suit);
+ uemis_add_string(tr(suit_type[atoi(val)]), &dive->suit);
} else if (!strcmp(tag, "u8SuitThickness")) {
if (*suit_thickness[atoi(val)])
- uemis_add_string(_(suit_thickness[atoi(val)]), &dive->suit);
+ uemis_add_string(tr(suit_thickness[atoi(val)]), &dive->suit);
}
}
@@ -637,14 +656,14 @@ static void parse_tag(struct dive *dive, char *tag, char *val)
* index into yet another data store that we read out later. In order to
* correctly populate the location and gps data from that we need to remember
* the adresses of those fields for every dive that references the divespot. */
-static void process_raw_buffer(uint32_t deviceid, char *inbuf, char **max_divenr, gboolean keep_number, int *for_dive)
+static void process_raw_buffer(uint32_t deviceid, char *inbuf, char **max_divenr, bool keep_number, int *for_dive)
{
char *buf = strdup(inbuf);
char *tp, *bp, *tag, *type, *val;
- gboolean done = FALSE;
+ bool done = FALSE;
int inbuflen = strlen(inbuf);
char *endptr = buf + inbuflen;
- gboolean log = FALSE;
+ bool log = FALSE;
char *sections[10];
int s, nr_sections = 0;
struct dive *dive = NULL;
@@ -758,22 +777,22 @@ static char *uemis_get_divenr(char *deviceidstr)
return strdup(divenr);
}
-char *do_uemis_import(const char *mountpath, short force_download)
+const char *do_uemis_import(const char *mountpath, short force_download)
{
char *newmax = NULL;
int start, end, i, offset;
uint32_t deviceidnr;
char objectid[10];
char *deviceid = NULL;
- char *result = NULL;
+ const char *result = NULL;
char *endptr;
- gboolean success, keep_number = FALSE, once = TRUE;
+ bool success, keep_number = FALSE, once = TRUE;
if (dive_table.nr == 0)
keep_number = TRUE;
- uemis_info(_("Init Communication"));
+ uemis_info(tr("Init Communication"));
if (! uemis_init(mountpath))
- return _("Uemis init failed");
+ return tr("Uemis init failed");
if (! uemis_get_answer(mountpath, "getDeviceId", 0, 1, &result))
goto bail;
deviceid = strdup(param_buff[0]);
@@ -784,7 +803,7 @@ char *do_uemis_import(const char *mountpath, short force_download)
/* param_buff[0] is still valid */
if (! uemis_get_answer(mountpath, "initSession", 1, 6, &result))
goto bail;
- uemis_info(_("Start download"));
+ uemis_info(tr("Start download"));
if (! uemis_get_answer(mountpath, "processSync", 0, 2, &result))
goto bail;
/* before starting the long download, check if user pressed cancel */
@@ -820,7 +839,7 @@ char *do_uemis_import(const char *mountpath, short force_download)
break;
/* finally, if the memory is getting too full, maybe we better stop, too */
if (progress_bar_fraction > 0.85) {
- result = _(ERR_FS_ALMOST_FULL);
+ result = tr(ERR_FS_ALMOST_FULL);
break;
}
/* clean up mbuf */
@@ -878,7 +897,7 @@ bail:
(void) uemis_get_answer(mountpath, "terminateSync", 0, 3, &result);
if (! strcmp(param_buff[0], "error")) {
if (! strcmp(param_buff[2],"Out of Memory"))
- result = _(ERR_FS_FULL);
+ result = tr(ERR_FS_FULL);
else
result = param_buff[2];
}
@@ -898,7 +917,7 @@ static void *pthread_wrapper(void *_data)
/* this simply ends the dialog without a response and asks not to be fired again
* as we set this function up in every loop while uemis_download is waiting for
* the download to finish */
-static gboolean timeout_func(gpointer _data)
+static bool timeout_func(gpointer _data)
{
GtkDialog *dialog = _data;
if (!import_thread_cancelled)
@@ -907,7 +926,7 @@ static gboolean timeout_func(gpointer _data)
}
GError *uemis_download(const char *mountpath, progressbar_t *progress,
- GtkDialog *dialog, gboolean force_download)
+ GtkDialog *dialog, bool force_download)
{
pthread_t pthread;
void *retval;
@@ -935,7 +954,7 @@ GError *uemis_download(const char *mountpath, progressbar_t *progress,
import_thread_cancelled = TRUE;
} else {
update_progressbar(args.progress, progress_bar_fraction);
- update_progressbar_text(args.progress, _("Cancelled, exiting cleanly..."));
+ update_progressbar_text(args.progress, tr("Cancelled, exiting cleanly..."));
usleep(100000);
}
}
diff --git a/uemis.c b/uemis.c
index 3f7c71b7f..26d6e1ab9 100644
--- a/uemis.c
+++ b/uemis.c
@@ -12,7 +12,8 @@
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
-#include <glib/gi18n.h>
+
+#include "gettext.h"
#define __USE_XOPEN
#include <time.h>
#include <math.h>
@@ -166,8 +167,10 @@ void uemis_mark_divelocation(int diveid, int divespot, char **location, degrees_
void uemis_set_divelocation(int divespot, char *text, double longitude, double latitude)
{
struct uemis_helper *hp = uemis_helper;
+#if 0 /* seems overkill */
if (!g_utf8_validate(text, -1, NULL))
return;
+#endif
while (hp) {
if (hp->divespot == divespot && hp->location) {
*hp->location = strdup(text);
@@ -195,45 +198,45 @@ static void uemis_event(struct dive *dive, struct divecomputer *dc, struct sampl
static int lastndl;
if (flags[1] & 0x01)
- add_event(dc, sample->time.seconds, 0, 0, 0, N_("Safety Stop Violation"));
+ add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("Safety Stop Violation"));
if (flags[1] & 0x08)
- add_event(dc, sample->time.seconds, 0, 0, 0, N_("Speed Alarm"));
+ add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("Speed Alarm"));
#if WANT_CRAZY_WARNINGS
if (flags[1] & 0x06) /* both bits 1 and 2 are a warning */
- add_event(dc, sample->time.seconds, 0, 0, 0, N_("Speed Warning"));
+ add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("Speed Warning"));
if (flags[1] & 0x10)
- add_event(dc, sample->time.seconds, 0, 0, 0, N_("PO2 Green Warning"));
+ add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("PO2 Green Warning"));
#endif
if (flags[1] & 0x20)
- add_event(dc, sample->time.seconds, 0, 0, 0, N_("PO2 Ascend Warning"));
+ add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("PO2 Ascend Warning"));
if (flags[1] & 0x40)
- add_event(dc, sample->time.seconds, 0, 0, 0, N_("PO2 Ascend Alarm"));
+ add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("PO2 Ascend Alarm"));
/* flags[2] reflects the deco / time bar
* flags[3] reflects more display details on deco and pO2 */
if (flags[4] & 0x01)
- add_event(dc, sample->time.seconds, 0, 0, 0, N_("Tank Pressure Info"));
+ add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("Tank Pressure Info"));
if (flags[4] & 0x04)
- add_event(dc, sample->time.seconds, 0, 0, 0, N_("RGT Warning"));
+ add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("RGT Warning"));
if (flags[4] & 0x08)
- add_event(dc, sample->time.seconds, 0, 0, 0, N_("RGT Alert"));
+ add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("RGT Alert"));
if (flags[4] & 0x40)
- add_event(dc, sample->time.seconds, 0, 0, 0, N_("Tank Change Suggested"));
+ add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("Tank Change Suggested"));
if (flags[4] & 0x80)
- add_event(dc, sample->time.seconds, 0, 0, 0, N_("Depth Limit Exceeded"));
+ add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("Depth Limit Exceeded"));
if (flags[5] & 0x01)
- add_event(dc, sample->time.seconds, 0, 0, 0, N_("Max Deco Time Warning"));
+ add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("Max Deco Time Warning"));
if (flags[5] & 0x04)
- add_event(dc, sample->time.seconds, 0, 0, 0, N_("Dive Time Info"));
+ add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("Dive Time Info"));
if (flags[5] & 0x08)
- add_event(dc, sample->time.seconds, 0, 0, 0, N_("Dive Time Alert"));
+ add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("Dive Time Alert"));
if (flags[5] & 0x10)
- add_event(dc, sample->time.seconds, 0, 0, 0, N_("Marker"));
+ add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("Marker"));
if (flags[6] & 0x02)
- add_event(dc, sample->time.seconds, 0, 0, 0, N_("No Tank Data"));
+ add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("No Tank Data"));
if (flags[6] & 0x04)
- add_event(dc, sample->time.seconds, 0, 0, 0, N_("Low Battery Warning"));
+ add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("Low Battery Warning"));
if (flags[6] & 0x08)
- add_event(dc, sample->time.seconds, 0, 0, 0, N_("Low Battery Alert"));
+ add_event(dc, sample->time.seconds, 0, 0, 0, QT_TR_NOOP("Low Battery Alert"));
/* flags[7] reflects the little on screen icons that remind of previous
* warnings / alerts - not useful for events */
diff --git a/webservice.c b/webservice.c
index f4f8baeb4..e713e1282 100644
--- a/webservice.c
+++ b/webservice.c
@@ -1,4 +1,3 @@
-#include <libintl.h>
#include <glib/gi18n.h>
#include <libsoup/soup.h>
#include <libxml/tree.h>
diff --git a/windows.c b/windows.c
index 823615c4a..fb2883916 100644
--- a/windows.c
+++ b/windows.c
@@ -60,7 +60,7 @@ void subsurface_set_conf_int(const char *name, int value)
RegSetValueEx(hkey, (LPCTSTR)name, 0, REG_DWORD, (const BYTE *)&value, 4);
}
-void subsurface_set_conf_bool(const char *name, int value)
+void subsurface_set_conf_bool(const char *name, bool value)
{
subsurface_set_conf_int(name, value);
}
@@ -305,7 +305,7 @@ void subsurface_command_line_exit(gint *argc, gchar ***argv)
g_free(*argv);
}
-gboolean subsurface_launch_for_uri(const char* uri)
+bool subsurface_launch_for_uri(const char* uri)
{
gboolean ret = FALSE;
wchar_t *wuri = (wchar_t *)g_utf8_to_utf16(uri, -1, NULL, NULL, NULL);
@@ -320,7 +320,7 @@ gboolean subsurface_launch_for_uri(const char* uri)
}
/* check if we are running a newer OS version */
-gboolean subsurface_os_feature_available(os_feature_t f)
+bool subsurface_os_feature_available(os_feature_t f)
{
switch (f) {
case UTF8_FONT_WITH_STARS: