29 |
GtkWidget *loc; |
GtkWidget *loc; |
30 |
} settings_dialog_state_t; |
} settings_dialog_state_t; |
31 |
|
|
|
/* ------------------------ special gui elements for fremantle ------------------ */ |
|
|
|
|
|
static GtkWidget *toggle_button_new_with_label(char *label) { |
|
|
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
|
|
return gtk_check_button_new_with_label(label); |
|
|
#else |
|
|
GtkWidget *cbut = gtk_toggle_button_new_with_label(label); |
|
|
hildon_gtk_widget_set_theme_size(cbut, |
|
|
(HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH)); |
|
|
gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(cbut), FALSE); |
|
|
return cbut; |
|
|
#endif |
|
|
} |
|
|
|
|
|
static void toggle_button_set_active(GtkWidget *button, gboolean active) { |
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active); |
|
|
} |
|
|
|
|
|
static gboolean toggle_button_get_active(GtkWidget *button) { |
|
|
return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)); |
|
|
} |
|
|
|
|
|
static GtkWidget *check_button_new_with_label(char *label) { |
|
|
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
|
|
return gtk_check_button_new_with_label(label); |
|
|
#else |
|
|
GtkWidget *cbut = |
|
|
hildon_check_button_new(HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH); |
|
|
gtk_button_set_label(GTK_BUTTON(cbut), label); |
|
|
return cbut; |
|
|
#endif |
|
|
} |
|
|
|
|
|
static void check_button_set_active(GtkWidget *button, gboolean active) { |
|
|
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
|
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active); |
|
|
#else |
|
|
hildon_check_button_set_active(HILDON_CHECK_BUTTON(button), active); |
|
|
#endif |
|
|
} |
|
|
|
|
|
static gboolean check_button_get_active(GtkWidget *button) { |
|
|
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
|
|
return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)); |
|
|
#else |
|
|
return hildon_check_button_get_active(HILDON_CHECK_BUTTON(button)); |
|
|
#endif |
|
|
} |
|
|
|
|
32 |
/* Our usual callback function */ |
/* Our usual callback function */ |
33 |
static void settings_update(GtkWidget *widget, gpointer data) { |
static void settings_update(GtkWidget *widget, gpointer data) { |
34 |
settings_dialog_state_t *hstate = (settings_dialog_state_t *)data; |
settings_dialog_state_t *hstate = (settings_dialog_state_t *)data; |
75 |
gtk_widget_set_sensitive(context->but_remove, FALSE); |
gtk_widget_set_sensitive(context->but_remove, FALSE); |
76 |
} |
} |
77 |
|
|
|
#ifdef ENABLE_MAEMO_MAPPER |
|
|
#include "dbus.h" |
|
|
|
|
|
typedef struct { |
|
|
appdata_t *appdata; |
|
|
pos_t pos; |
|
|
GtkWidget *import_button; |
|
|
GtkWidget *export_button; |
|
|
GtkWidget *lat, *lon; |
|
|
} mm_context_t; |
|
|
|
|
|
static void on_mm_import_clicked(GtkButton *button, gpointer data) { |
|
|
char str[32]; |
|
|
mm_context_t *context = (mm_context_t*)data; |
|
|
|
|
|
pos_lat_str(str, sizeof(str), context->appdata->mmpos.lat); |
|
|
gtk_entry_set_text(GTK_ENTRY(context->lat), str); |
|
|
pos_lon_str(str, sizeof(str), context->appdata->mmpos.lon); |
|
|
gtk_entry_set_text(GTK_ENTRY(context->lon), str); |
|
|
} |
|
|
|
|
|
static void on_mm_export_clicked(GtkButton *button, gpointer data) { |
|
|
mm_context_t *context = (mm_context_t*)data; |
|
|
|
|
|
/* update position from entries */ |
|
|
pos_t pos; |
|
|
pos.lat = lat_get(context->lat); |
|
|
pos.lon = lon_get(context->lon); |
|
|
|
|
|
g_assert(!isnan(pos.lat) && !isnan(pos.lon)); |
|
|
|
|
|
dbus_mm_set_position(context->appdata, &pos); |
|
|
} |
|
|
|
|
|
static void callback_modified_pos(GtkWidget *widget, gpointer data ) { |
|
|
mm_context_t *context = (mm_context_t*)data; |
|
|
|
|
|
gboolean valid = |
|
|
(!isnan(lat_get(context->lat))) && (!isnan(lon_get(context->lon))); |
|
|
|
|
|
gtk_widget_set_sensitive(context->export_button, valid); |
|
|
} |
|
|
#endif |
|
|
|
|
78 |
static void on_location_edit(GtkWidget *button, location_context_t *context) { |
static void on_location_edit(GtkWidget *button, location_context_t *context) { |
79 |
GtkWidget *dialog = gtk_dialog_new_with_buttons(_("Edit Location"), |
GtkWidget *dialog = gtk_dialog_new_with_buttons(_("Edit Location"), |
80 |
GTK_WINDOW(context->settings_dialog), GTK_DIALOG_MODAL, |
GTK_WINDOW(context->settings_dialog), GTK_DIALOG_MODAL, |
100 |
} else |
} else |
101 |
printf("location edit for Home\n"); |
printf("location edit for Home\n"); |
102 |
|
|
|
#ifdef ENABLE_MAEMO_MAPPER |
|
|
mm_context_t mm_context; |
|
|
#else |
|
|
GtkWidget *lat, *lon; |
|
|
#endif |
|
|
|
|
103 |
GtkWidget *label, *name; |
GtkWidget *label, *name; |
104 |
GtkWidget *table = gtk_table_new(2, 3, FALSE); |
GtkWidget *table = gtk_table_new(3, 3, FALSE); |
105 |
|
|
106 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), |
107 |
label = gtk_label_new(_("Name:")), 0, 1, 0, 1); |
label = left_label_new(_("Name:")), 0, 1, 0, 1); |
108 |
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); |
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); |
109 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), |
110 |
name = gtk_entry_new(), 1, 2, 0, 1); |
name = entry_new(), 1, 3, 0, 1); |
111 |
|
|
112 |
pos_t pos; |
pos_t pos; |
113 |
if(loc) pos = loc->pos; |
if(loc) pos = loc->pos; |
118 |
if(isnan(pos.lat)) pos.lat = 0; |
if(isnan(pos.lat)) pos.lat = 0; |
119 |
if(isnan(pos.lon)) pos.lon = 0; |
if(isnan(pos.lon)) pos.lon = 0; |
120 |
|
|
121 |
|
GtkWidget *latw, *lonw; |
122 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), |
123 |
label = gtk_label_new(_("Latitude:")), 0, 1, 1, 2); |
label = left_label_new(_("Latitude:")), 0, 1, 1, 2); |
124 |
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); |
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); |
|
#ifdef ENABLE_MAEMO_MAPPER |
|
125 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), |
126 |
mm_context.lat = lat_entry_new(pos.lat), 1, 2, 1, 2); |
latw = lat_entry_new(pos.lat), 1, 2, 1, 2); |
|
g_signal_connect(G_OBJECT(mm_context.lat), "changed", |
|
|
G_CALLBACK(callback_modified_pos), &mm_context); |
|
|
#else |
|
|
gtk_table_attach_defaults(GTK_TABLE(table), |
|
|
lat = lat_entry_new(pos.lat), 1, 2, 1, 2); |
|
|
#endif |
|
127 |
|
|
|
|
|
128 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), |
129 |
label = gtk_label_new(_("Longitude:")), 0, 1, 2, 3); |
label = left_label_new(_("Longitude:")), 0, 1, 2, 3); |
130 |
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); |
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); |
|
#ifdef ENABLE_MAEMO_MAPPER |
|
131 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), |
132 |
mm_context.lon = lon_entry_new(pos.lon), 1, 2, 2, 3); |
lonw = lon_entry_new(pos.lon), 1, 2, 2, 3); |
133 |
g_signal_connect(G_OBJECT(mm_context.lon), "changed", |
|
|
G_CALLBACK(callback_modified_pos), &mm_context); |
|
|
#else |
|
134 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), |
135 |
lon = lon_entry_new(pos.lon), 1, 2, 2, 3); |
preset_coordinate_picker(context->appdata, latw, lonw), 2, 3, 1, 2); |
136 |
#endif |
gtk_table_attach_defaults(GTK_TABLE(table), |
137 |
|
goto_coordinate(context->appdata, latw, lonw), 2, 3, 2, 3); |
138 |
|
|
139 |
if(loc) |
if(loc) |
140 |
gtk_entry_set_text(GTK_ENTRY(name), loc->name); |
gtk_entry_set_text(GTK_ENTRY(name), loc->name); |
143 |
gtk_widget_set_sensitive(GTK_WIDGET(name), FALSE); |
gtk_widget_set_sensitive(GTK_WIDGET(name), FALSE); |
144 |
} |
} |
145 |
|
|
|
#ifdef ENABLE_MAEMO_MAPPER |
|
|
mm_context.appdata = context->appdata; |
|
|
if(loc) mm_context.pos = loc->pos; |
|
|
else mm_context.pos = context->appdata->home; |
|
|
|
|
|
mm_context.import_button = gtk_button_new(); |
|
|
gtk_button_set_image(GTK_BUTTON(mm_context.import_button), |
|
|
icon_get_widget(ICON_MISC, 5)); |
|
|
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), |
|
|
mm_context.import_button); |
|
|
gtk_signal_connect(GTK_OBJECT(mm_context.import_button), "clicked", |
|
|
(GtkSignalFunc)on_mm_import_clicked, &mm_context); |
|
|
|
|
|
if(!context->appdata->mmpos_valid) |
|
|
gtk_widget_set_sensitive(mm_context.import_button, FALSE); |
|
|
|
|
|
mm_context.export_button = gtk_button_new(); |
|
|
gtk_button_set_image(GTK_BUTTON(mm_context.export_button), |
|
|
icon_get_widget(ICON_MISC, 0)); |
|
|
gtk_signal_connect(GTK_OBJECT(mm_context.export_button), "clicked", |
|
|
(GtkSignalFunc)on_mm_export_clicked, &mm_context); |
|
|
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), |
|
|
mm_context.export_button); |
|
|
#endif |
|
|
|
|
146 |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table); |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table); |
147 |
|
|
148 |
gtk_widget_show_all(dialog); |
gtk_widget_show_all(dialog); |
150 |
if(GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) { |
if(GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) { |
151 |
pos_t pos; |
pos_t pos; |
152 |
|
|
153 |
#ifdef ENABLE_MAEMO_MAPPER |
pos.lat = lat_entry_get(latw); |
154 |
pos.lat = lat_get(mm_context.lat); |
pos.lon = lon_entry_get(lonw); |
|
pos.lon = lon_get(mm_context.lon); |
|
|
#else |
|
|
pos.lat = lat_get(lat); |
|
|
pos.lon = lon_get(lon); |
|
|
#endif |
|
155 |
|
|
156 |
if(isnan(pos.lat) || isnan(pos.lon)) |
if(isnan(pos.lat) || isnan(pos.lon)) |
157 |
errorf(_("Ignoring invalid position")); |
errorf(_("Ignoring invalid position")); |
425 |
return vbox; |
return vbox; |
426 |
} |
} |
427 |
|
|
428 |
|
#ifdef FREMANTLE |
429 |
static GtkWidget *title_new(char *title) { |
static GtkWidget *title_new(char *title) { |
430 |
GtkWidget *vbox = gtk_vbox_new(FALSE, 10); |
GtkWidget *vbox = gtk_vbox_new(FALSE, 10); |
431 |
gtk_box_pack_start_defaults(GTK_BOX(vbox), gtk_label_new("")); |
gtk_box_pack_start_defaults(GTK_BOX(vbox), gtk_label_new("")); |
436 |
gtk_box_pack_start_defaults(GTK_BOX(vbox), hbox); |
gtk_box_pack_start_defaults(GTK_BOX(vbox), hbox); |
437 |
return vbox; |
return vbox; |
438 |
} |
} |
439 |
|
#endif |
440 |
|
|
441 |
void cb_menu_settings(GtkWidget *window, gpointer data) { |
void cb_menu_settings(GtkWidget *window, gpointer data) { |
442 |
appdata_t *appdata = (appdata_t *)data; |
appdata_t *appdata = (appdata_t *)data; |
502 |
|
|
503 |
/* ---------------- misc old main menu entries ----------------- */ |
/* ---------------- misc old main menu entries ----------------- */ |
504 |
|
|
505 |
#if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5) |
#ifndef FREMANTLE |
|
// gtk_box_pack_start_defaults(GTK_BOX(vbox), title_new(_("Misc"))); |
|
|
#else |
|
506 |
vbox = gtk_vbox_new(FALSE, 0); |
vbox = gtk_vbox_new(FALSE, 0); |
507 |
#endif |
#endif |
508 |
|
|
510 |
check_button_set_active(cbox_imperial, appdata->imperial); |
check_button_set_active(cbox_imperial, appdata->imperial); |
511 |
gtk_box_pack_start(GTK_BOX(vbox), cbox_imperial, FALSE, FALSE, 0); |
gtk_box_pack_start(GTK_BOX(vbox), cbox_imperial, FALSE, FALSE, 0); |
512 |
|
|
513 |
|
hbox = gtk_hbox_new(FALSE,2); |
514 |
|
gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(_("Username:")), |
515 |
|
FALSE, FALSE, 0); |
516 |
|
|
517 |
|
GtkWidget *username = entry_new(); |
518 |
|
if(appdata->username) |
519 |
|
gtk_entry_set_text(GTK_ENTRY(username), appdata->username); |
520 |
|
|
521 |
|
gtk_box_pack_start(GTK_BOX(hbox), username, FALSE, FALSE, 0); |
522 |
|
|
523 |
|
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
524 |
|
|
525 |
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
526 |
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, |
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, |
527 |
gtk_label_new(_("Misc"))); |
gtk_label_new(_("Misc"))); |
666 |
appdata->imperial = |
appdata->imperial = |
667 |
check_button_get_active(cbox_imperial); |
check_button_get_active(cbox_imperial); |
668 |
|
|
669 |
|
if(appdata->username) { |
670 |
|
g_free(appdata->username); |
671 |
|
appdata->username = NULL; |
672 |
|
} |
673 |
|
|
674 |
|
const char *uname = gtk_entry_get_text(GTK_ENTRY(username)); |
675 |
|
if(uname && strlen(uname)>0) |
676 |
|
appdata->username = g_strdup(uname); |
677 |
|
|
678 |
appdata->compass_damping = 0.5 + gtk_range_get_value(GTK_RANGE(scale)); |
appdata->compass_damping = 0.5 + gtk_range_get_value(GTK_RANGE(scale)); |
679 |
|
|
680 |
appdata->gpxlist_items = GPXLIST_ITEM_VALID; |
appdata->gpxlist_items = GPXLIST_ITEM_VALID; |