95 |
GtkWidget *dialog = gtk_message_dialog_new( |
GtkWidget *dialog = gtk_message_dialog_new( |
96 |
GTK_WINDOW(NULL), |
GTK_WINDOW(NULL), |
97 |
GTK_DIALOG_DESTROY_WITH_PARENT, |
GTK_DIALOG_DESTROY_WITH_PARENT, |
98 |
GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, |
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
99 |
buf); |
GTK_MESSAGE_ERROR, |
100 |
|
#else |
101 |
|
GTK_MESSAGE_OTHER, |
102 |
|
#endif |
103 |
|
GTK_BUTTONS_CLOSE, buf); |
104 |
|
|
105 |
gtk_window_set_title(GTK_WINDOW(dialog), _("ERROR")); |
gtk_window_set_title(GTK_WINDOW(dialog), _("ERROR")); |
106 |
|
|
142 |
gtk_widget_show_all (GTK_WIDGET(dialog)); |
gtk_widget_show_all (GTK_WIDGET(dialog)); |
143 |
if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_FM_OK) { |
if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_FM_OK) { |
144 |
char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); |
char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); |
145 |
|
|
146 |
|
if(filename) { |
147 |
|
gpx_dialog_t *dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window)); |
148 |
|
|
149 |
gpx_dialog_t *dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window)); |
if(!whole_dir) |
150 |
|
gpx = gpx_parse(dialog, filename); |
151 |
if(!whole_dir) |
else { |
152 |
gpx = gpx_parse(dialog, filename); |
/* cur trailing '/' if present */ |
153 |
else { |
if(strlastchr(filename) == '/') |
154 |
/* cur trailing '/' if present */ |
filename[strlen(filename)] = 0; |
155 |
if(strlastchr(filename) == '/') |
|
156 |
filename[strlen(filename)] = 0; |
gpx = gpx_parse_dir(dialog, filename); |
|
|
|
|
gpx = gpx_parse_dir(dialog, filename); |
|
|
} |
|
|
|
|
|
gpx_busy_dialog_destroy(dialog); |
|
|
|
|
|
/* save path if gpx was successfully loaded */ |
|
|
if(gpx) { |
|
|
char *r = strrchr(filename, '/'); |
|
|
|
|
|
/* there is a delimiter, use everything left of it as path */ |
|
|
if(r && !whole_dir) { |
|
|
*r = 0; |
|
|
if(appdata->path) free(appdata->path); |
|
|
appdata->path = strdup(filename); |
|
|
/* restore path ... just in case ... */ |
|
|
*r = '/'; |
|
157 |
} |
} |
158 |
|
|
159 |
|
gpx_busy_dialog_destroy(dialog); |
160 |
|
|
161 |
|
/* save path if gpx was successfully loaded */ |
162 |
|
if(gpx) { |
163 |
|
char *r = strrchr(filename, '/'); |
164 |
|
|
165 |
|
/* there is a delimiter, use everything left of it as path */ |
166 |
|
if(r && !whole_dir) { |
167 |
|
*r = 0; |
168 |
|
if(appdata->path) free(appdata->path); |
169 |
|
appdata->path = strdup(filename); |
170 |
|
/* restore path ... just in case ... */ |
171 |
|
*r = '/'; |
172 |
|
} |
173 |
|
|
174 |
|
if(whole_dir) |
175 |
|
appdata->path = strdup(filename); |
176 |
|
} else |
177 |
|
errorf(_("Load error")); |
178 |
|
|
179 |
if(whole_dir) |
g_free (filename); |
180 |
appdata->path = strdup(filename); |
} else { |
181 |
|
#ifndef USE_MAEMO |
182 |
|
errorf(_("Error accessing the file.")); |
183 |
|
#else |
184 |
|
errorf(_("Error accessing the file. This may happen if the file " |
185 |
|
"resides on a remote file system. Please copy the file onto " |
186 |
|
"the device (e.g. onto the memory card) and try again.")); |
187 |
|
#endif |
188 |
} |
} |
|
|
|
|
g_free (filename); |
|
189 |
} |
} |
190 |
|
|
191 |
gtk_widget_destroy (dialog); |
gtk_widget_destroy (dialog); |
217 |
GtkTreeIter iter; |
GtkTreeIter iter; |
218 |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
219 |
|
|
220 |
|
#ifdef USE_MAEMO |
221 |
|
/* check if a cache is already selected and ignore click if yes */ |
222 |
|
/* (was probably a double click) */ |
223 |
|
if(appdata->cur_cache) return; |
224 |
|
#endif |
225 |
|
|
226 |
if(gtk_tree_model_get_iter(model, &iter, path)) { |
if(gtk_tree_model_get_iter(model, &iter, path)) { |
227 |
cache_t *cache; |
cache_t *cache; |
228 |
gtk_tree_model_get(model, &iter, CACHELIST_COL_DATA, &cache, -1); |
gtk_tree_model_get(model, &iter, CACHELIST_COL_DATA, &cache, -1); |
350 |
|
|
351 |
if(appdata->cachelist_update) |
if(appdata->cachelist_update) |
352 |
cachelist_redraw(appdata); |
cachelist_redraw(appdata); |
353 |
|
|
354 |
#endif |
#endif |
355 |
|
|
356 |
return TRUE; |
return TRUE; |
609 |
g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view); |
g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view); |
610 |
|
|
611 |
appdata->cur_gpx = gpx; |
appdata->cur_gpx = gpx; |
612 |
char *title = g_strdup_printf("GPXView - %s", gpx->name); |
char *title = g_strdup_printf("%s - GPXView", gpx->name); |
613 |
gtk_window_set_title(GTK_WINDOW(window), title); |
gtk_window_set_title(GTK_WINDOW(window), title); |
614 |
g_free(title); |
g_free(title); |
615 |
|
|
735 |
GtkTreeIter iter; |
GtkTreeIter iter; |
736 |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
737 |
|
|
738 |
|
#ifdef USE_MAEMO |
739 |
|
/* check if a cache is already selected and ignore click if yes */ |
740 |
|
/* (was probably a double click) */ |
741 |
|
if(appdata->cur_gpx) return; |
742 |
|
#endif |
743 |
|
|
744 |
if (gtk_tree_model_get_iter(model, &iter, path)) { |
if (gtk_tree_model_get_iter(model, &iter, path)) { |
745 |
gpx_t *gpx; |
gpx_t *gpx; |
746 |
gtk_tree_model_get(model, &iter, GPXLIST_COL_DATA, &gpx, -1); |
gtk_tree_model_get(model, &iter, GPXLIST_COL_DATA, &gpx, -1); |
985 |
GtkTreeIter iter; |
GtkTreeIter iter; |
986 |
gtk_list_store_append(appdata->gpxstore, &iter); |
gtk_list_store_append(appdata->gpxstore, &iter); |
987 |
gpxlist_set(appdata->gpxstore, &iter, gpx); |
gpxlist_set(appdata->gpxstore, &iter, gpx); |
988 |
|
|
989 |
if(gpx == sel_gpx) { |
if(gpx == sel_gpx) { |
990 |
sel_iter = iter; |
sel_iter = iter; |
991 |
sel_iter_valid = TRUE; |
sel_iter_valid = TRUE; |
1045 |
|
|
1046 |
/******************** begin of menu *********************/ |
/******************** begin of menu *********************/ |
1047 |
|
|
1048 |
|
typedef struct { |
1049 |
|
appdata_t *appdata; |
1050 |
|
GtkWidget *dialog; |
1051 |
|
} about_context_t; |
1052 |
|
|
1053 |
|
#ifdef ENABLE_BROWSER_INTERFACE |
1054 |
|
void on_paypal_button_clicked(GtkButton *button, about_context_t *context) { |
1055 |
|
gtk_dialog_response(GTK_DIALOG(context->dialog), GTK_RESPONSE_ACCEPT); |
1056 |
|
browser_url(context->appdata, |
1057 |
|
"https://www.paypal.com/cgi-bin/webscr" |
1058 |
|
"?cmd=_s-xclick&hosted_button_id=7400558"); |
1059 |
|
} |
1060 |
|
#endif |
1061 |
|
|
1062 |
static void |
static void |
1063 |
cb_menu_about(GtkWidget *window, gpointer data) { |
cb_menu_about(GtkWidget *window, gpointer data) { |
1064 |
GtkAboutDialog *about = GTK_ABOUT_DIALOG(gtk_about_dialog_new()); |
about_context_t context; |
1065 |
|
|
1066 |
gtk_about_dialog_set_name(about, "GPXView"); |
context.appdata = (appdata_t *)data; |
|
gtk_about_dialog_set_version(about, VERSION); |
|
1067 |
|
|
1068 |
#ifdef ENABLE_LIBLOCATION |
#ifdef ENABLE_LIBLOCATION |
1069 |
char *uses = "uses liblocation"; |
char *uses = "uses liblocation"; |
1073 |
char *uses = "uses gpsd"; |
char *uses = "uses gpsd"; |
1074 |
#endif |
#endif |
1075 |
|
|
1076 |
char *str = g_strdup_printf("%s\n\n(%s)", |
const gchar *authors[] = { |
1077 |
_("GPXView (c) 2008-2009 by\n" |
"Till Harbaum <till@harbaum.org>", |
1078 |
"Till Harbaum <till@harbaum.org>\n" |
"John Stowers <john.stowers@gmail.com>", |
1079 |
"Mailing list: gpxview-users@garage.maemo.org"), |
NULL }; |
1080 |
_(uses) |
|
1081 |
); |
context.dialog = g_object_new(GTK_TYPE_ABOUT_DIALOG, |
1082 |
|
"name", "GPXView", |
1083 |
gtk_about_dialog_set_copyright(about, str); |
"version", VERSION, |
1084 |
g_free(str); |
"copyright", _("Copyright 2008-2009"), |
1085 |
|
"authors", authors, |
1086 |
gtk_about_dialog_set_website(about, |
"website", _("http://www.harbaum.org/till/maemo"), |
1087 |
_("http://www.harbaum.org/till/maemo")); |
"comments", _(uses), |
1088 |
|
NULL); |
1089 |
gtk_about_dialog_set_comments(about, |
|
1090 |
_("Geocaching.com GPX file viewer")); |
#ifdef ENABLE_BROWSER_INTERFACE |
1091 |
|
/* add a way to donate to the project */ |
1092 |
gtk_widget_show_all(GTK_WIDGET(about)); |
GtkWidget *alignment = gtk_alignment_new(0.5, 0, 0, 0); |
1093 |
gtk_dialog_run(GTK_DIALOG(about)); |
|
1094 |
gtk_widget_destroy(GTK_WIDGET(about)); |
GtkWidget *hbox = gtk_hbox_new(FALSE, 8); |
1095 |
|
gtk_box_pack_start(GTK_BOX(hbox), |
1096 |
|
gtk_label_new(_("Do you like GPXView?")), |
1097 |
|
FALSE, FALSE, 0); |
1098 |
|
|
1099 |
|
GtkWidget *button = gtk_button_new(); |
1100 |
|
gtk_button_set_image(GTK_BUTTON(button), |
1101 |
|
icon_get_widget(ICON_MISC, 8)); |
1102 |
|
gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
1103 |
|
g_signal_connect(button, "clicked", |
1104 |
|
G_CALLBACK(on_paypal_button_clicked), &context); |
1105 |
|
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
1106 |
|
|
1107 |
|
gtk_container_add(GTK_CONTAINER(alignment), hbox); |
1108 |
|
gtk_box_pack_start_defaults(GTK_BOX((GTK_DIALOG(context.dialog))->vbox), |
1109 |
|
alignment); |
1110 |
|
|
1111 |
|
gtk_widget_show_all(alignment); |
1112 |
|
#endif |
1113 |
|
|
1114 |
|
gtk_dialog_run(GTK_DIALOG(context.dialog)); |
1115 |
|
gtk_widget_destroy(context.dialog); |
1116 |
} |
} |
1117 |
|
|
1118 |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
1495 |
gtk_widget_destroy(dialog); |
gtk_widget_destroy(dialog); |
1496 |
} |
} |
1497 |
|
|
1498 |
void on_window_destroy (GtkWidget *widget, gpointer data); |
static void on_window_destroy (GtkWidget *widget, gpointer data); |
1499 |
|
|
1500 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
1501 |
static void |
static void |
1555 |
cb_menu_export_log(GtkWidget *widget, gpointer data) { |
cb_menu_export_log(GtkWidget *widget, gpointer data) { |
1556 |
appdata_t *appdata = (appdata_t*)data; |
appdata_t *appdata = (appdata_t*)data; |
1557 |
notes_log_export(appdata); |
notes_log_export(appdata); |
|
#ifdef USE_STACKABLE_WINDOW |
|
|
hildon_window_stack_pop_1 (hildon_window_stack_get_default()); |
|
|
#endif |
|
1558 |
} |
} |
1559 |
|
|
1560 |
#ifdef USE_MAEMO |
#ifdef ENABLE_MAEMO_MAPPER |
1561 |
static void |
static void |
1562 |
cb_menu_export_mmpoi(GtkWidget *widget, gpointer data) { |
cb_menu_export_mmpoi(GtkWidget *widget, gpointer data) { |
1563 |
appdata_t *appdata = (appdata_t*)data; |
appdata_t *appdata = (appdata_t*)data; |
1564 |
mmpoi_export(appdata); |
mmpoi_export(appdata); |
|
#ifdef USE_STACKABLE_WINDOW |
|
|
hildon_window_stack_pop_1 (hildon_window_stack_get_default()); |
|
|
#endif |
|
1565 |
} |
} |
1566 |
#endif |
#endif |
1567 |
|
|
1569 |
cb_menu_export_garmin(GtkWidget *widget, gpointer data) { |
cb_menu_export_garmin(GtkWidget *widget, gpointer data) { |
1570 |
appdata_t *appdata = (appdata_t*)data; |
appdata_t *appdata = (appdata_t*)data; |
1571 |
garmin_export(appdata); |
garmin_export(appdata); |
|
#ifdef USE_STACKABLE_WINDOW |
|
|
hildon_window_stack_pop_1 (hildon_window_stack_get_default()); |
|
|
#endif |
|
1572 |
} |
} |
1573 |
|
|
1574 |
|
#ifdef ENABLE_OSM_GPS_MAP |
1575 |
|
static void |
1576 |
|
cb_menu_map(GtkWidget *window, gpointer data) { |
1577 |
|
map((appdata_t *)data); |
1578 |
|
} |
1579 |
|
#endif |
1580 |
|
|
1581 |
static void |
static void |
1582 |
cb_menu_geomath(GtkWidget *window, gpointer data) { |
cb_menu_geomath(GtkWidget *window, gpointer data) { |
1583 |
geomath_dialog((appdata_t *)data); |
geomath_dialog((appdata_t *)data); |
|
#ifdef USE_STACKABLE_WINDOW |
|
|
hildon_window_stack_pop_1 (hildon_window_stack_get_default()); |
|
|
#endif |
|
1584 |
} |
} |
1585 |
|
|
1586 |
static void |
static void |
1587 |
cb_menu_geotext(GtkWidget *window, gpointer data) { |
cb_menu_geotext(GtkWidget *window, gpointer data) { |
1588 |
geotext_dialog((appdata_t *)data); |
geotext_dialog((appdata_t *)data); |
|
#ifdef USE_STACKABLE_WINDOW |
|
|
hildon_window_stack_pop_1 (hildon_window_stack_get_default()); |
|
|
#endif |
|
1589 |
} |
} |
1590 |
|
|
1591 |
static void |
static void |
1592 |
cb_menu_precpos(GtkWidget *window, gpointer data) { |
cb_menu_precpos(GtkWidget *window, gpointer data) { |
1593 |
precise_position((appdata_t *)data); |
precise_position((appdata_t *)data); |
|
#ifdef USE_STACKABLE_WINDOW |
|
|
hildon_window_stack_pop_1 (hildon_window_stack_get_default()); |
|
|
#endif |
|
1594 |
} |
} |
1595 |
|
|
1596 |
#ifdef USE_STACKABLE_WINDOW |
#ifdef USE_STACKABLE_WINDOW |
1597 |
static GtkWidget *export_menu_create(appdata_t *appdata) { |
typedef struct { |
1598 |
GtkWidget *button; |
char *label, *desc; |
1599 |
HildonAppMenu *menu = HILDON_APP_MENU(hildon_app_menu_new()); |
GtkSignalFunc activate_cb; |
1600 |
|
} menu_entry_t; |
|
button = hildon_button_new_with_text( |
|
|
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
|
|
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
|
|
_("Export to Maemo Mapper"), |
|
|
_("Save a Maemo Mapper POI file")); |
|
|
g_signal_connect(button, "clicked", |
|
|
G_CALLBACK(cb_menu_export_mmpoi), appdata); |
|
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
|
1601 |
|
|
1602 |
button = hildon_button_new_with_text( |
typedef struct { |
1603 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
const char *title; |
1604 |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
const menu_entry_t *menu; |
1605 |
_("Export Field Notes"), |
int len; |
1606 |
_("Save a Garmin Field Notes file")); |
} submenu_t; |
|
g_signal_connect(button, "clicked", |
|
|
G_CALLBACK(cb_menu_export_log), appdata); |
|
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
|
1607 |
|
|
1608 |
button = hildon_button_new_with_text( |
#define COLUMNS 1 |
|
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
|
|
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
|
|
_("Export Garmin GPX"), |
|
|
_("Save modified waypoints in GPX file")); |
|
|
g_signal_connect(button, "clicked", |
|
|
G_CALLBACK(cb_menu_export_garmin), appdata); |
|
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
|
1609 |
|
|
1610 |
gtk_widget_show_all(GTK_WIDGET(menu)); |
void on_submenu_entry_clicked(GtkButton *button, GtkWidget *menu) { |
1611 |
|
|
1612 |
return GTK_WIDGET(menu); |
/* force closing of submenu dialog */ |
1613 |
|
gtk_dialog_response(GTK_DIALOG(menu), GTK_RESPONSE_NONE); |
1614 |
|
gtk_widget_hide(menu); |
1615 |
|
|
1616 |
|
/* let gtk clean up */ |
1617 |
|
while(gtk_events_pending()) |
1618 |
|
gtk_main_iteration(); |
1619 |
} |
} |
1620 |
|
|
1621 |
/* the export submenu */ |
static GtkWidget *app_submenu_create(appdata_t *appdata, |
1622 |
void on_export_clicked(GtkButton *button, appdata_t *appdata) { |
const submenu_t *submenu) { |
|
if(!appdata->export_menu) |
|
|
appdata->export_menu = export_menu_create(appdata); |
|
1623 |
|
|
1624 |
/* draw a popup menu */ |
/* create a oridinary dialog box */ |
1625 |
hildon_app_menu_popup(HILDON_APP_MENU(appdata->export_menu), |
GtkWidget *dialog = gtk_dialog_new(); |
1626 |
GTK_WINDOW(hildon_window_stack_peek( |
gtk_window_set_title(GTK_WINDOW(dialog), _(submenu->title)); |
1627 |
hildon_window_stack_get_default()))); |
gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); |
1628 |
} |
gtk_window_set_transient_for(GTK_WINDOW(dialog), |
1629 |
|
GTK_WINDOW(appdata->window)); |
1630 |
|
gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); |
1631 |
|
|
1632 |
static GtkWidget *tools_menu_create(appdata_t *appdata) { |
GtkWidget *table = gtk_table_new(submenu->len/COLUMNS, COLUMNS, TRUE); |
1633 |
GtkWidget *button; |
int x = 0, y = 0; |
|
HildonAppMenu *menu = HILDON_APP_MENU(hildon_app_menu_new()); |
|
1634 |
|
|
1635 |
/* the following doesn't have an effect */ |
const menu_entry_t *menu_entries = submenu->menu; |
1636 |
// gtk_window_set_title(GTK_WINDOW(menu), "Tools"); |
while(menu_entries->label) { |
1637 |
|
GtkWidget *button = NULL; |
1638 |
|
|
1639 |
button = hildon_button_new_with_text( |
button = hildon_button_new_with_text( |
1640 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
1641 |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
1642 |
_("Geomath"), |
_(menu_entries->label), _(menu_entries->desc)); |
|
_("Geocoordinate calculation")); |
|
|
g_signal_connect(button, "clicked", |
|
|
G_CALLBACK(cb_menu_geomath), appdata); |
|
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
|
1643 |
|
|
1644 |
|
/* try to center both texts */ |
1645 |
|
hildon_button_set_title_alignment(HILDON_BUTTON(button), 0.5, 0.5); |
1646 |
|
hildon_button_set_value_alignment(HILDON_BUTTON(button), 0.5, 0.5); |
1647 |
|
|
1648 |
button = hildon_button_new_with_text( |
g_signal_connect(button, "clicked", |
1649 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
G_CALLBACK(on_submenu_entry_clicked), dialog); |
1650 |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
|
1651 |
_("Geotext"), |
g_signal_connect(button, "clicked", |
1652 |
_("Text analysis")); |
menu_entries->activate_cb, appdata); |
1653 |
g_signal_connect(button, "clicked", |
|
1654 |
G_CALLBACK(cb_menu_geotext), appdata); |
gtk_table_attach_defaults(GTK_TABLE(table), button, x, x+1, y, y+1); |
1655 |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
|
1656 |
|
x++; |
1657 |
|
if(x == COLUMNS) { x = 0; y++; } |
1658 |
|
|
1659 |
button = hildon_button_new_with_text( |
menu_entries++; |
1660 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
} |
|
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
|
|
_("Precise Position"), |
|
|
_("Calculate a precise GPS position")); |
|
|
g_signal_connect(button, "clicked", |
|
|
G_CALLBACK(cb_menu_precpos), appdata); |
|
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
|
1661 |
|
|
1662 |
gtk_widget_show_all(GTK_WIDGET(menu)); |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table); |
1663 |
|
|
1664 |
return GTK_WIDGET(menu); |
return dialog; |
1665 |
} |
} |
1666 |
|
|
1667 |
|
/* popup the dialog shaped submenu */ |
1668 |
|
static void submenu_popup(GtkWidget *menu) { |
1669 |
|
gtk_widget_show_all(menu); |
1670 |
|
gtk_dialog_run(GTK_DIALOG(menu)); |
1671 |
|
gtk_widget_hide(menu); |
1672 |
|
} |
1673 |
|
|
1674 |
|
static void submenu_cleanup(GtkWidget *menu) { |
1675 |
|
gtk_widget_destroy(menu); |
1676 |
|
} |
1677 |
|
|
1678 |
|
static const menu_entry_t submenu_export_entries[] = { |
1679 |
|
#ifdef ENABLE_MAEMO_MAPPER |
1680 |
|
{ "Export to Maemo Mapper" , "Save a Maemo Mapper POI file", |
1681 |
|
G_CALLBACK(cb_menu_export_mmpoi) }, |
1682 |
|
#endif |
1683 |
|
{ "Export Field Notes", "Save a Garmin Field Notes file", |
1684 |
|
G_CALLBACK(cb_menu_export_log) }, |
1685 |
|
{ "Export Garmin GPX", "Save modified waypoints in GPX file", |
1686 |
|
G_CALLBACK(cb_menu_export_garmin) }, |
1687 |
|
{ NULL, NULL, NULL } |
1688 |
|
}; |
1689 |
|
|
1690 |
|
static const submenu_t submenu_export = { |
1691 |
|
"Export", submenu_export_entries, |
1692 |
|
sizeof(submenu_export_entries)/sizeof(menu_entry_t)-1 |
1693 |
|
}; |
1694 |
|
|
1695 |
|
/* the export submenu */ |
1696 |
|
void on_export_clicked(GtkButton *button, appdata_t *appdata) { |
1697 |
|
if(!appdata->export_menu) |
1698 |
|
appdata->export_menu = app_submenu_create(appdata, &submenu_export); |
1699 |
|
|
1700 |
|
submenu_popup(appdata->export_menu); |
1701 |
|
} |
1702 |
|
|
1703 |
|
static const menu_entry_t submenu_tools_entries[] = { |
1704 |
|
{ "Geomath", "Geocoordinate calculation", |
1705 |
|
G_CALLBACK(cb_menu_geomath) }, |
1706 |
|
{ "Geotext", "Text analysis", |
1707 |
|
G_CALLBACK(cb_menu_geotext) }, |
1708 |
|
{ "Precise Position", "Calculate a precise GPS position", |
1709 |
|
G_CALLBACK(cb_menu_precpos) }, |
1710 |
|
{ NULL, NULL, NULL } |
1711 |
|
}; |
1712 |
|
|
1713 |
|
static const submenu_t submenu_tools = { |
1714 |
|
"Tools", submenu_tools_entries, |
1715 |
|
sizeof(submenu_tools_entries)/sizeof(menu_entry_t)-1 |
1716 |
|
}; |
1717 |
|
|
1718 |
/* the tools submenu */ |
/* the tools submenu */ |
1719 |
void on_tools_clicked(GtkButton *button, appdata_t *appdata) { |
void on_tools_clicked(GtkButton *button, appdata_t *appdata) { |
1720 |
if(!appdata->tools_menu) |
if(!appdata->tools_menu) |
1721 |
appdata->tools_menu = tools_menu_create(appdata); |
appdata->tools_menu = app_submenu_create(appdata, &submenu_tools); |
1722 |
|
|
1723 |
/* draw a popup menu */ |
submenu_popup(appdata->tools_menu); |
|
hildon_app_menu_popup(HILDON_APP_MENU(appdata->tools_menu), |
|
|
GTK_WINDOW(hildon_window_stack_peek( |
|
|
hildon_window_stack_get_default()))); |
|
1724 |
} |
} |
1725 |
|
|
|
|
|
1726 |
HildonAppMenu *menu_create(appdata_t *appdata, int mode) { |
HildonAppMenu *menu_create(appdata_t *appdata, int mode) { |
1727 |
GtkWidget *button; |
GtkWidget *button; |
1728 |
HildonAppMenu *menu = HILDON_APP_MENU(hildon_app_menu_new()); |
HildonAppMenu *menu = HILDON_APP_MENU(hildon_app_menu_new()); |
1748 |
g_signal_connect_after(button, "clicked", |
g_signal_connect_after(button, "clicked", |
1749 |
G_CALLBACK(cb_menu_adddir), appdata); |
G_CALLBACK(cb_menu_adddir), appdata); |
1750 |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
|
} |
|
1751 |
|
|
|
if(mode == MENU_GPXLIST) { |
|
1752 |
button = gtk_button_new_with_label(_("Export")); |
button = gtk_button_new_with_label(_("Export")); |
1753 |
g_signal_connect_after(button, "clicked", |
g_signal_connect_after(button, "clicked", |
1754 |
G_CALLBACK(on_export_clicked), appdata); |
G_CALLBACK(on_export_clicked), appdata); |
1765 |
G_CALLBACK(on_tools_clicked), appdata); |
G_CALLBACK(on_tools_clicked), appdata); |
1766 |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1767 |
|
|
1768 |
|
#ifdef ENABLE_OSM_GPS_MAP |
1769 |
|
button = gtk_button_new_with_label(_("Map")); |
1770 |
|
g_signal_connect_after(button, "clicked", |
1771 |
|
G_CALLBACK(cb_menu_map), appdata); |
1772 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1773 |
|
#endif |
1774 |
|
|
1775 |
#ifdef HILDON_HELP |
#ifdef HILDON_HELP |
1776 |
button = gtk_button_new_with_label(_("Help")); |
button = gtk_button_new_with_label(_("Help")); |
1777 |
g_signal_connect_after(button, "clicked", |
g_signal_connect_after(button, "clicked", |
1827 |
submenu = gtk_menu_new(); |
submenu = gtk_menu_new(); |
1828 |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
1829 |
|
|
1830 |
#ifdef USE_MAEMO |
#ifdef ENABLE_MAEMO_MAPPER |
1831 |
item = gtk_menu_item_new_with_label( _("Maemo Mapper POI") ); |
item = gtk_menu_item_new_with_label( _("Maemo Mapper POI") ); |
1832 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1833 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
1884 |
|
|
1885 |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
1886 |
|
|
1887 |
|
#ifdef ENABLE_OSM_GPS_MAP |
1888 |
|
item = gtk_menu_item_new_with_label( _("Map") ); |
1889 |
|
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
1890 |
|
g_signal_connect(item, "activate", |
1891 |
|
GTK_SIGNAL_FUNC(cb_menu_map), appdata); |
1892 |
|
#endif |
1893 |
|
|
1894 |
item = gtk_menu_item_new_with_label(_("Tools")); |
item = gtk_menu_item_new_with_label(_("Tools")); |
1895 |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
1896 |
submenu = gtk_menu_new(); |
submenu = gtk_menu_new(); |
1955 |
if(appdata->image_path) free(appdata->image_path); |
if(appdata->image_path) free(appdata->image_path); |
1956 |
if(appdata->search_str) free(appdata->search_str); |
if(appdata->search_str) free(appdata->search_str); |
1957 |
|
|
1958 |
|
#ifdef USE_STACKABLE_WINDOW |
1959 |
|
if(appdata->export_menu) submenu_cleanup(appdata->export_menu); |
1960 |
|
if(appdata->tools_menu) submenu_cleanup(appdata->tools_menu); |
1961 |
|
#endif |
1962 |
|
|
1963 |
gnome_vfs_shutdown(); |
gnome_vfs_shutdown(); |
1964 |
icons_free(); |
icons_free(); |
1965 |
gps_release(appdata); |
gps_release(appdata); |
1988 |
puts("everything is gone"); |
puts("everything is gone"); |
1989 |
} |
} |
1990 |
|
|
1991 |
void on_window_destroy (GtkWidget *widget, gpointer data) { |
static void on_window_destroy (GtkWidget *widget, gpointer data) { |
1992 |
appdata_t *appdata = (appdata_t*)data; |
appdata_t *appdata = (appdata_t*)data; |
1993 |
|
|
1994 |
gconf_save_state(appdata); |
gconf_save_state(appdata); |
2291 |
fprintf(stderr, "error initiating osso context\n"); |
fprintf(stderr, "error initiating osso context\n"); |
2292 |
} |
} |
2293 |
|
|
2294 |
|
#ifdef ENABLE_MAEMO_MAPPER |
2295 |
dbus_register(&appdata); |
dbus_register(&appdata); |
2296 |
#endif |
#endif |
2297 |
|
#endif |
2298 |
|
|
2299 |
icons_init(); |
icons_init(); |
2300 |
|
|
2333 |
|
|
2334 |
appdata.vbox = gtk_vbox_new(FALSE, 2); |
appdata.vbox = gtk_vbox_new(FALSE, 2); |
2335 |
gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox); |
gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox); |
|
|
|
2336 |
#ifndef USE_STACKABLE_WINDOW |
#ifndef USE_STACKABLE_WINDOW |
2337 |
menu_create(&appdata); |
menu_create(&appdata); |
2338 |
#else |
#else |