aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--callbacks-gtk.h2
-rw-r--r--device.h8
-rw-r--r--display-gtk.h8
-rw-r--r--display.h8
-rw-r--r--dive.h10
-rw-r--r--divelist.h9
-rw-r--r--linux.c16
-rw-r--r--macos.c14
-rw-r--r--pref.h22
-rw-r--r--qt-gui.cpp (renamed from gtk-gui.c)72
-rw-r--r--webservice.h8
-rw-r--r--windows.c10
13 files changed, 124 insertions, 65 deletions
diff --git a/Makefile b/Makefile
index 3d3febd9a..a38586ff0 100644
--- a/Makefile
+++ b/Makefile
@@ -184,7 +184,7 @@ MSGOBJS=$(addprefix share/locale/,$(MSGLANGS:.po=.UTF-8/LC_MESSAGES/subsurface.m
OBJS = main.o dive.o time.o profile.o info.o equipment.o divelist.o deco.o planner.o \
parse-xml.o save-xml.o libdivecomputer.o print.o uemis.o uemis-downloader.o \
- gtk-gui.o statistics.o file.o cochran.o device.o download-dialog.o prefs.o \
+ qt-gui.o statistics.o file.o cochran.o device.o download-dialog.o prefs.o \
webservice.o sha1.o $(GPSOBJ) $(OSSUPPORT).o $(RESFILE)
DEPS = $(wildcard .dep/*.dep)
diff --git a/callbacks-gtk.h b/callbacks-gtk.h
index 08c159b4d..568916f6c 100644
--- a/callbacks-gtk.h
+++ b/callbacks-gtk.h
@@ -9,7 +9,7 @@ static void name(GtkWidget *w, gpointer data) \
#define OPTIONCALLBACK(name, option) \
static void name(GtkWidget *w, gpointer data) \
{ \
- GtkWidget **entry = data; \
+ GtkWidget **entry = (GtkWidget**)data; \
option = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w)); \
update_screen(); \
if (entry) \
diff --git a/device.h b/device.h
index 8a306ef78..636eb73c6 100644
--- a/device.h
+++ b/device.h
@@ -1,6 +1,10 @@
#ifndef DEVICE_INFO_H
#define DEVICE_INFO_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct device_info {
const char *model;
uint32_t deviceid;
@@ -17,4 +21,8 @@ extern struct device_info *create_device_info(const char *model, uint32_t device
extern struct device_info *remove_device_info(const char *model, uint32_t deviceid);
extern struct device_info *head_of_device_info_list(void);
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/display-gtk.h b/display-gtk.h
index 7c1bcad4a..4cc86659f 100644
--- a/display-gtk.h
+++ b/display-gtk.h
@@ -8,6 +8,10 @@
#include <gdk/gdkkeysyms-compat.h>
#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
extern GtkWidget *main_window;
/* we want a progress bar as part of the device_data_t - let's abstract this out */
@@ -117,4 +121,8 @@ GError *uemis_download(const char *path, progressbar_t *progress, GtkDialog *dia
/* from planner.c */
extern void input_plan(void);
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/display.h b/display.h
index 8200770d7..d5c69e81b 100644
--- a/display.h
+++ b/display.h
@@ -3,6 +3,10 @@
#include <cairo.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define SCALE_SCREEN 1.0
#define SCALE_PRINT (1.0 / get_screen_dpi())
@@ -63,4 +67,8 @@ struct options {
extern char zoomed_plot, dc_number;
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/dive.h b/dive.h
index 7d08828a8..4528ac1db 100644
--- a/dive.h
+++ b/dive.h
@@ -15,6 +15,10 @@
#include "sha1.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define O2_IN_AIR 209 // permille
#define N2_IN_AIR 781
#define O2_DENSITY 1429 // mg/Liter
@@ -523,7 +527,7 @@ static inline struct divecomputer *get_dive_dc(struct dive *dive, int nr)
#define for_each_gps_location(_i,_x) \
for ((_i) = 0; ((_x) = get_gps_location(_i, &gps_location_table)) != NULL; (_i)++)
-static inline struct dive *get_dive_by_diveid(int diveid, int deviceid)
+static inline struct dive *get_dive_by_diveid(uint32_t diveid, uint32_t deviceid)
{
int i;
struct dive *dive;
@@ -700,6 +704,10 @@ extern char *debugfilename;
extern FILE *debugfile;
#endif
+#ifdef __cplusplus
+}
+#endif
+
#include "pref.h"
#endif /* DIVE_H */
diff --git a/divelist.h b/divelist.h
index 856318e2d..c9ec973f7 100644
--- a/divelist.h
+++ b/divelist.h
@@ -1,6 +1,10 @@
#ifndef DIVELIST_H
#define DIVELIST_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct dive;
extern void dive_list_update_dives(void);
@@ -16,4 +20,9 @@ extern void select_prev_dive(void);
extern void show_and_select_dive(struct dive *dive);
extern double init_decompression(struct dive * dive);
extern void export_all_dives_uddf_cb();
+
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/linux.c b/linux.c
index 4add7bb01..bf7383822 100644
--- a/linux.c
+++ b/linux.c
@@ -9,7 +9,7 @@ const char system_divelist_default_font[] = "Sans 8";
GConfClient *gconf;
-static char *gconf_name(char *name)
+static char *gconf_name(const char *name)
{
static char buf[255] = "/apps/subsurface/";
@@ -23,32 +23,32 @@ void subsurface_open_conf(void)
gconf = gconf_client_get_default();
}
-void subsurface_unset_conf(char *name)
+void subsurface_unset_conf(const char *name)
{
gconf_client_unset(gconf, gconf_name(name), NULL);
}
-void subsurface_set_conf(char *name, const char *value)
+void subsurface_set_conf(const char *name, const char *value)
{
gconf_client_set_string(gconf, gconf_name(name), value, NULL);
}
-void subsurface_set_conf_bool(char *name, int value)
+void subsurface_set_conf_bool(const char *name, int value)
{
gconf_client_set_bool(gconf, gconf_name(name), value > 0, NULL);
}
-void subsurface_set_conf_int(char *name, int value)
+void subsurface_set_conf_int(const char *name, int value)
{
gconf_client_set_int(gconf, gconf_name(name), value , NULL);
}
-const void *subsurface_get_conf(char *name)
+const char *subsurface_get_conf(const char *name)
{
return gconf_client_get_string(gconf, gconf_name(name), NULL);
}
-int subsurface_get_conf_bool(char *name)
+int subsurface_get_conf_bool(const char *name)
{
GConfValue *val;
gboolean ret;
@@ -61,7 +61,7 @@ int subsurface_get_conf_bool(char *name)
return ret;
}
-int subsurface_get_conf_int(char *name)
+int subsurface_get_conf_int(const char *name)
{
int val = gconf_client_get_int(gconf, gconf_name(name), NULL);
if(!val)
diff --git a/macos.c b/macos.c
index aee4c73ca..93bc00eea 100644
--- a/macos.c
+++ b/macos.c
@@ -30,29 +30,29 @@ void subsurface_open_conf(void)
/* nothing at this time */
}
-void subsurface_unset_conf(char *name)
+void subsurface_unset_conf(const char *name)
{
CFPreferencesSetAppValue(CFSTR_VAR(name), NULL, SUBSURFACE_PREFERENCES);
}
-void subsurface_set_conf(char *name, const char *value)
+void subsurface_set_conf(const char *name, const char *value)
{
CFPreferencesSetAppValue(CFSTR_VAR(name), CFSTR_VAR(value), SUBSURFACE_PREFERENCES);
}
-void subsurface_set_conf_bool(char *name, int value)
+void subsurface_set_conf_bool(const char *name, int value)
{
CFPreferencesSetAppValue(CFSTR_VAR(name),
value ? kCFBooleanTrue : kCFBooleanFalse, SUBSURFACE_PREFERENCES);
}
-void subsurface_set_conf_int(char *name, int value)
+void subsurface_set_conf_int(const char *name, int value)
{
CFNumberRef numRef = CFNumberCreate(NULL, kCFNumberIntType, &value);
CFPreferencesSetAppValue(CFSTR_VAR(name), numRef, SUBSURFACE_PREFERENCES);
}
-const void *subsurface_get_conf(char *name)
+const char *subsurface_get_conf(char *name)
{
CFPropertyListRef strpref;
@@ -62,7 +62,7 @@ const void *subsurface_get_conf(char *name)
return strdup(CFStringGetCStringPtr(strpref, kCFStringEncodingMacRoman));
}
-int subsurface_get_conf_bool(char *name)
+int subsurface_get_conf_bool(const char *name)
{
Boolean boolpref, exists;
@@ -72,7 +72,7 @@ int subsurface_get_conf_bool(char *name)
return boolpref;
}
-int subsurface_get_conf_int(char *name)
+int subsurface_get_conf_int(const char *name)
{
Boolean exists;
CFIndex value;
diff --git a/pref.h b/pref.h
index 60fe1104c..d622ebf3a 100644
--- a/pref.h
+++ b/pref.h
@@ -1,6 +1,10 @@
#ifndef PREF_H
#define PREF_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef struct {
gboolean cylinder;
gboolean temperature;
@@ -43,13 +47,13 @@ extern struct preferences prefs, default_prefs;
#define PP_GRAPHS_ENABLED (prefs.pp_graphs.po2 || prefs.pp_graphs.pn2 || prefs.pp_graphs.phe)
extern void subsurface_open_conf(void);
-extern void subsurface_set_conf(char *name, const char *value);
-extern void subsurface_set_conf_bool(char *name, gboolean value);
-extern void subsurface_set_conf_int(char *name, int value);
-extern void subsurface_unset_conf(char *name);
-extern const void *subsurface_get_conf(char *name);
-extern int subsurface_get_conf_bool(char *name);
-extern int subsurface_get_conf_int(char *name);
+extern void subsurface_set_conf(const char *name, const char *value);
+extern void subsurface_set_conf_bool(const char *name, gboolean value);
+extern void subsurface_set_conf_int(const char *name, int value);
+extern void subsurface_unset_conf(const char *name);
+extern const char *subsurface_get_conf(const char *name);
+extern int subsurface_get_conf_bool(const char *name);
+extern int subsurface_get_conf_int(const char *name);
extern void subsurface_flush_conf(void);
extern void subsurface_close_conf(void);
@@ -59,4 +63,8 @@ extern const char *system_default_filename();
extern void load_preferences(void);
extern void save_preferences(void);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* PREF_H */
diff --git a/gtk-gui.c b/qt-gui.cpp
index 91a70acf0..54aa582b4 100644
--- a/gtk-gui.c
+++ b/qt-gui.cpp
@@ -27,12 +27,13 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk-pixbuf/gdk-pixdata.h>
-#include "subsurface-icon.h"
#if HAVE_OSM_GPS_MAP
#include <osm-gps-map-source.h>
#endif
+static const GdkPixdata subsurface_icon_pixbuf = {};
+
GtkWidget *main_window;
GtkWidget *main_vbox;
GtkWidget *error_info_bar;
@@ -224,7 +225,7 @@ static gboolean ask_save_changes()
GtkWidget *dialog, *label, *content;
gboolean quit = TRUE;
dialog = gtk_dialog_new_with_buttons(_("Save Changes?"),
- GTK_WINDOW(main_window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_WINDOW(main_window), GtkDialogFlags(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
GTK_STOCK_NO, GTK_RESPONSE_NO,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
@@ -320,7 +321,7 @@ static void file_open(GtkWidget *w, gpointer data)
fn_glist = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog));
GError *error = NULL;
- filename = fn_glist->data;
+ filename = (char *)fn_glist->data;
parse_file(filename, &error, TRUE);
if (error != NULL)
{
@@ -609,16 +610,16 @@ void update_screen()
update_dive_list_col_visibility();
}
-UNITCALLBACK(set_meter, length, METERS)
-UNITCALLBACK(set_feet, length, FEET)
-UNITCALLBACK(set_bar, pressure, BAR)
-UNITCALLBACK(set_psi, pressure, PSI)
-UNITCALLBACK(set_liter, volume, LITER)
-UNITCALLBACK(set_cuft, volume, CUFT)
-UNITCALLBACK(set_celsius, temperature, CELSIUS)
-UNITCALLBACK(set_fahrenheit, temperature, FAHRENHEIT)
-UNITCALLBACK(set_kg, weight, KG)
-UNITCALLBACK(set_lbs, weight, LBS)
+UNITCALLBACK(set_meter, length, units::METERS)
+UNITCALLBACK(set_feet, length, units::FEET)
+UNITCALLBACK(set_bar, pressure, units::BAR)
+UNITCALLBACK(set_psi, pressure, units::PSI)
+UNITCALLBACK(set_liter, volume, units::LITER)
+UNITCALLBACK(set_cuft, volume, units::CUFT)
+UNITCALLBACK(set_celsius, temperature, units::CELSIUS)
+UNITCALLBACK(set_fahrenheit, temperature, units::FAHRENHEIT)
+UNITCALLBACK(set_kg, weight, units::KG)
+UNITCALLBACK(set_lbs, weight, units::LBS)
OPTIONCALLBACK(otu_toggle, prefs.visible_cols.otu)
OPTIONCALLBACK(maxcns_toggle, prefs.visible_cols.maxcns)
@@ -667,7 +668,7 @@ static gboolean gfhigh_edit(GtkWidget *w, GdkEvent *event, gpointer _data)
static void event_toggle(GtkWidget *w, gpointer _data)
{
- gboolean *plot_ev = _data;
+ gboolean *plot_ev = (gboolean *)_data;
*plot_ev = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w));
}
@@ -710,7 +711,7 @@ static void pick_default_file(GtkWidget *w, GtkButton *button)
list = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(fs_dialog));
if (g_slist_length(list) == 1)
- gtk_button_set_label(button, list->data);
+ gtk_button_set_label(button, (const gchar *)list->data);
g_slist_free(list);
}
@@ -779,28 +780,28 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
gtk_container_add(GTK_CONTAINER(frame), box);
create_radio(box, _("Depth:"),
- _("Meter"), set_meter, (prefs.units.length == METERS),
- _("Feet"), set_feet, (prefs.units.length == FEET),
+ _("Meter"), set_meter, (prefs.units.length == units::METERS),
+ _("Feet"), set_feet, (prefs.units.length == units::FEET),
NULL);
create_radio(box, _("Pressure:"),
- _("Bar"), set_bar, (prefs.units.pressure == BAR),
- _("PSI"), set_psi, (prefs.units.pressure == PSI),
+ _("Bar"), set_bar, (prefs.units.pressure == units::BAR),
+ _("PSI"), set_psi, (prefs.units.pressure == units::PSI),
NULL);
create_radio(box, _("Volume:"),
- _("Liter"), set_liter, (prefs.units.volume == LITER),
- _("CuFt"), set_cuft, (prefs.units.volume == CUFT),
+ _("Liter"), set_liter, (prefs.units.volume == units::LITER),
+ _("CuFt"), set_cuft, (prefs.units.volume == units::CUFT),
NULL);
create_radio(box, _("Temperature:"),
- _("Celsius"), set_celsius, (prefs.units.temperature == CELSIUS),
- _("Fahrenheit"), set_fahrenheit, (prefs.units.temperature == FAHRENHEIT),
+ _("Celsius"), set_celsius, (prefs.units.temperature == units::CELSIUS),
+ _("Fahrenheit"), set_fahrenheit, (prefs.units.temperature == units::FAHRENHEIT),
NULL);
create_radio(box, _("Weight:"),
- _("kg"), set_kg, (prefs.units.weight == KG),
- _("lbs"), set_lbs, (prefs.units.weight == LBS),
+ _("kg"), set_kg, (prefs.units.weight == units::KG),
+ _("lbs"), set_lbs, (prefs.units.weight == units::LBS),
NULL);
frame = gtk_frame_new(_("Show Columns"));
@@ -1082,7 +1083,7 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
static void create_toggle(const char* label, int *on, void *_data)
{
- GtkWidget *button, *table = _data;
+ GtkWidget *button, *table = GTK_WIDGET(_data);
int rows, cols, x, y;
static int count;
@@ -1345,7 +1346,7 @@ static void edit_dc_delete_rows(GtkTreeView *view)
selected_rows = gtk_tree_selection_get_selected_rows(selection, &model);
for (list = selected_rows; list; list = g_list_next(list)) {
- path = list->data;
+ path = (GtkTreePath *)list->data;
ref = gtk_tree_row_reference_new(model, path);
row_references = g_list_append(row_references, ref);
}
@@ -1441,7 +1442,7 @@ static void edit_dc_nicknames(GtkWidget *w, gpointer data)
dialog = gtk_dialog_new_with_buttons(_("Edit Dive Computer Nicknames"),
GTK_WINDOW(main_window),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GtkDialogFlags(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_DELETE,
SUB_RESPONSE_DELETE,
GTK_STOCK_CANCEL,
@@ -1509,7 +1510,7 @@ static void edit_dc_nicknames(GtkWidget *w, gpointer data)
if (res == SUB_RESPONSE_DELETE) {
confirm = gtk_dialog_new_with_buttons(_("Delete a dive computer information entry"),
GTK_WINDOW(dialog),
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GtkDialogFlags(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
GTK_STOCK_YES,
GTK_RESPONSE_YES,
GTK_STOCK_NO,
@@ -1855,7 +1856,8 @@ static int tooltips;
void attach_tooltip(int x, int y, int w, int h, const char *text, struct event *event)
{
cairo_rectangle_t *rect;
- tooltip_rects = realloc(tooltip_rects, (tooltips + 1) * sizeof(tooltip_record_t));
+ tooltip_rects = (tooltip_record_t *)
+ realloc(tooltip_rects, (tooltips + 1) * sizeof(tooltip_record_t));
rect = &tooltip_rects[tooltips].rect;
rect->x = x;
rect->y = y;
@@ -1975,7 +1977,7 @@ static gboolean draw_callback(GtkWidget *widget, cairo_t *cr, gpointer data)
static gboolean expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
GtkAllocation allocation;
- static struct graphics_context gc = { .printer = 0 };
+ static struct graphics_context gc = { 0 };
/* the drawing area gives TOTAL width * height - x,y is used as the topx/topy offset
* so effective drawing area is width-2x * height-2y */
@@ -2021,7 +2023,7 @@ static gboolean scroll_event(GtkWidget *widget, GdkEventScroll *event, gpointer
static void add_gas_change_cb(GtkWidget *menuitem, gpointer data)
{
- double *x = data;
+ double *x = (double *)data;
int when = x_to_time(*x);
int cylnr = select_cylinder(current_dive, when);
if (cylnr >= 0) {
@@ -2061,7 +2063,7 @@ int confirm_dialog(int when, char *action_text, char *event_text)
static void add_bookmark_cb(GtkWidget *menuitem, gpointer data)
{
- double *x = data;
+ double *x = (double *)data;
int when = x_to_time(*x);
if (confirm_dialog(when, _("Add"), _("bookmark"))){
@@ -2089,7 +2091,7 @@ static struct event *event_at_x(double rel_x)
static void remove_event_cb(GtkWidget *menuitem, gpointer data)
{
- struct event *event = data;
+ struct event *event = (struct event *)data;
if (confirm_dialog(event->time.seconds, _("Remove"), _(event->name))){
struct event **ep = &current_dc->events;
while (ep && *ep != event)
@@ -2204,7 +2206,7 @@ static GtkWidget *dive_profile_widget(void)
static void do_import_file(gpointer data, gpointer user_data)
{
GError *error = NULL;
- parse_file(data, &error, FALSE);
+ parse_file((const char *)data, &error, FALSE);
if (error != NULL)
{
diff --git a/webservice.h b/webservice.h
index bb3a71f3b..ee07e9438 100644
--- a/webservice.h
+++ b/webservice.h
@@ -1,3 +1,11 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
extern void webservice_download_dialog(void);
extern gboolean webservice_request_user_xml(const gchar *, gchar **, guint *, guint *);
extern int divelogde_upload(char *fn);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/windows.c b/windows.c
index f06ffc7a8..23b6d2f4c 100644
--- a/windows.c
+++ b/windows.c
@@ -20,12 +20,12 @@ void subsurface_open_conf(void)
printf("CreateKey Software\\subsurface failed %ld\n", success);
}
-void subsurface_unset_conf(char *name)
+void subsurface_unset_conf(const char *name)
{
RegDeleteValue(hkey, (LPCTSTR)name);
}
-void subsurface_set_conf(char *name, const char *value)
+void subsurface_set_conf(const char *name, const char *value)
{
/* since we are using the pointer 'value' as both an actual
* pointer to the string setting and as a way to pass the
@@ -52,17 +52,17 @@ void subsurface_set_conf(char *name, const char *value)
free(wname);
}
-void subsurface_set_conf_int(char *name, int value)
+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(char *name, int value)
+void subsurface_set_conf_bool(const char *name, int value)
{
subsurface_set_conf_int(name, value);
}
-const void *subsurface_get_conf(char *name)
+const char *subsurface_get_conf(const char *name)
{
const int csize = 64;
int blen = 0;