Have some C++ file in the project

Rename gtk-gui.c to qt-gui.cpp, and make the necessary changes so that
the project still builds.

Signed-off-by: Alberto Mardegan <mardy@users.sourceforge.net>
This commit is contained in:
Alberto Mardegan 2013-04-01 13:51:49 +03:00
parent 42365ede79
commit 578d633d01
13 changed files with 124 additions and 65 deletions

View file

@ -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)

View file

@ -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) \

View file

@ -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

View file

@ -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

View file

@ -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

10
dive.h
View file

@ -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 */

View file

@ -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

16
linux.c
View file

@ -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)

14
macos.c
View file

@ -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;

22
pref.h
View file

@ -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 */

View file

@ -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)
{

View file

@ -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

View file

@ -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;