120 |
HELP_ID_IMPORT, appdata->osso_context); |
HELP_ID_IMPORT, appdata->osso_context); |
121 |
#endif |
#endif |
122 |
#else |
#else |
123 |
dialog = gtk_file_chooser_dialog_new (whole_dir?_("Open Directory"): |
dialog = gtk_file_chooser_dialog_new (whole_dir?_("Import directory"): |
124 |
_("Open File"), |
_("Import file"), |
125 |
GTK_WINDOW(appdata->window), |
GTK_WINDOW(appdata->window), |
126 |
whole_dir?GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER : |
whole_dir?GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER : |
127 |
GTK_FILE_CHOOSER_ACTION_OPEN, |
GTK_FILE_CHOOSER_ACTION_OPEN, |
202 |
GtkTreeIter iter; |
GtkTreeIter iter; |
203 |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
204 |
|
|
205 |
|
#ifdef USE_MAEMO |
206 |
|
/* check if a cache is already selected and ignore click if yes */ |
207 |
|
/* (was probably a double click) */ |
208 |
|
if(appdata->cur_cache) return; |
209 |
|
#endif |
210 |
|
|
211 |
if(gtk_tree_model_get_iter(model, &iter, path)) { |
if(gtk_tree_model_get_iter(model, &iter, path)) { |
212 |
cache_t *cache; |
cache_t *cache; |
213 |
gtk_tree_model_get(model, &iter, CACHELIST_COL_DATA, &cache, -1); |
gtk_tree_model_get(model, &iter, CACHELIST_COL_DATA, &cache, -1); |
270 |
// gtk_widget_show_all(appdata->vbox); |
// gtk_widget_show_all(appdata->vbox); |
271 |
#else |
#else |
272 |
|
|
273 |
|
if(!appdata->cur_view) { |
274 |
|
printf("cachelist redraw: no active view\n"); |
275 |
|
return; |
276 |
|
} |
277 |
|
|
278 |
g_assert(!appdata->cur_cache); |
g_assert(!appdata->cur_cache); |
279 |
int redraw = 0; |
int redraw = 0; |
280 |
if(appdata->search_results) |
if(appdata->search_results) |
285 |
} |
} |
286 |
|
|
287 |
if(redraw) { |
if(redraw) { |
288 |
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
GtkWidget *container = appdata->vbox; |
289 |
|
|
290 |
|
printf("redraw %d\n", redraw); |
291 |
|
|
292 |
|
#ifdef USE_STACKABLE_WINDOW |
293 |
|
HildonWindowStack *stack = hildon_window_stack_get_default(); |
294 |
|
container = hildon_window_stack_peek(stack); |
295 |
|
#endif |
296 |
|
|
297 |
|
gtk_container_remove(GTK_CONTAINER(container), appdata->cur_view); |
298 |
switch(redraw) { |
switch(redraw) { |
299 |
case 1: |
case 1: |
300 |
appdata->cur_view = cachelist_create(appdata, |
appdata->cur_view = cachelist_create(appdata, |
306 |
break; |
break; |
307 |
} |
} |
308 |
|
|
309 |
gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
#ifdef USE_STACKABLE_WINDOW |
310 |
gtk_widget_show_all(appdata->vbox); |
if(container != appdata->vbox) |
311 |
|
gtk_container_add(GTK_CONTAINER(container), appdata->cur_view); |
312 |
|
else |
313 |
|
#endif |
314 |
|
gtk_box_pack_start_defaults(GTK_BOX(container), appdata->cur_view); |
315 |
|
|
316 |
|
gtk_widget_show_all(container); |
317 |
} |
} |
318 |
#endif |
#endif |
319 |
} |
} |
326 |
#ifdef USE_MAEMO |
#ifdef USE_MAEMO |
327 |
appdata_t *appdata = (appdata_t*)data; |
appdata_t *appdata = (appdata_t*)data; |
328 |
|
|
329 |
|
if(appdata->cur_cache) |
330 |
|
return TRUE; |
331 |
|
|
332 |
if(appdata->cachelist_disable_screensaver) |
if(appdata->cachelist_disable_screensaver) |
333 |
if (osso_display_blanking_pause(appdata->osso_context) != OSSO_OK) |
if (osso_display_blanking_pause(appdata->osso_context) != OSSO_OK) |
334 |
fprintf(stderr, "error with display blank\n"); |
fprintf(stderr, "error with display blank\n"); |
341 |
} |
} |
342 |
|
|
343 |
static void cachelist_timer_reset(appdata_t *appdata) { |
static void cachelist_timer_reset(appdata_t *appdata) { |
344 |
|
printf("cachelist timer reset\n"); |
345 |
g_assert(appdata->cachelist_handler_id); |
g_assert(appdata->cachelist_handler_id); |
346 |
gtk_timeout_remove(appdata->cachelist_handler_id); |
gtk_timeout_remove(appdata->cachelist_handler_id); |
347 |
appdata->cachelist_handler_id = |
appdata->cachelist_handler_id = |
573 |
} |
} |
574 |
#else |
#else |
575 |
#ifdef USE_STACKABLE_WINDOW |
#ifdef USE_STACKABLE_WINDOW |
576 |
|
static void search_result_free(gpx_t *result); |
577 |
|
|
578 |
|
void on_cachelist_destroy(GtkWidget *widget, appdata_t *appdata) { |
579 |
|
if(appdata->search_results) { |
580 |
|
search_result_free(appdata->search_results); |
581 |
|
appdata->search_results = NULL; |
582 |
|
} |
583 |
|
appdata->cur_gpx = NULL; |
584 |
|
|
585 |
|
/* restore cur_view */ |
586 |
|
appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view"); |
587 |
|
} |
588 |
|
|
589 |
void cachelist_dialog(appdata_t *appdata, gpx_t *gpx) { |
void cachelist_dialog(appdata_t *appdata, gpx_t *gpx) { |
590 |
GtkWidget *window = hildon_stackable_window_new(); |
GtkWidget *window = hildon_stackable_window_new(); |
591 |
|
|
592 |
gtk_window_set_title(GTK_WINDOW(window), gpx->name); |
/* store last "cur_view" in window */ |
593 |
|
g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view); |
594 |
|
|
595 |
gtk_container_add(GTK_CONTAINER(window), |
appdata->cur_gpx = gpx; |
596 |
cachelist_create(appdata, gpx, NULL)); |
char *title = g_strdup_printf("%s - GPXView", gpx->name); |
597 |
|
gtk_window_set_title(GTK_WINDOW(window), title); |
598 |
|
g_free(title); |
599 |
|
|
600 |
|
appdata->cur_view = cachelist_create(appdata, gpx, NULL); |
601 |
|
gtk_container_add(GTK_CONTAINER(window), appdata->cur_view); |
602 |
|
|
603 |
|
|
604 |
|
hildon_window_set_app_menu(HILDON_WINDOW(window), |
605 |
|
menu_create(appdata, MENU_CACHELIST)); |
606 |
|
|
607 |
|
g_signal_connect(G_OBJECT(window), "destroy", |
608 |
|
G_CALLBACK(on_cachelist_destroy), appdata); |
609 |
|
|
610 |
gtk_widget_show_all(window); |
gtk_widget_show_all(window); |
611 |
} |
} |
719 |
GtkTreeIter iter; |
GtkTreeIter iter; |
720 |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
GtkTreeModel *model = gtk_tree_view_get_model(treeview); |
721 |
|
|
722 |
|
#ifdef USE_MAEMO |
723 |
|
/* check if a cache is already selected and ignore click if yes */ |
724 |
|
/* (was probably a double click) */ |
725 |
|
if(appdata->cur_gpx) return; |
726 |
|
#endif |
727 |
|
|
728 |
if (gtk_tree_model_get_iter(model, &iter, path)) { |
if (gtk_tree_model_get_iter(model, &iter, path)) { |
729 |
gpx_t *gpx; |
gpx_t *gpx; |
730 |
gtk_tree_model_get(model, &iter, GPXLIST_COL_DATA, &gpx, -1); |
gtk_tree_model_get(model, &iter, GPXLIST_COL_DATA, &gpx, -1); |
823 |
gpx_busy_dialog_destroy(dialog); |
gpx_busy_dialog_destroy(dialog); |
824 |
} |
} |
825 |
#ifndef USE_BREAD_CRUMB_TRAIL |
#ifndef USE_BREAD_CRUMB_TRAIL |
826 |
cachelist_dialog(appdata, gpx); |
#ifdef USE_STACKABLE_WINDOW |
827 |
|
if(!appdata->cur_gpx) |
828 |
|
#endif |
829 |
|
cachelist_dialog(appdata, gpx); |
830 |
|
#ifdef USE_STACKABLE_WINDOW |
831 |
|
else |
832 |
|
printf("selected gpx, but cachelist window already present\n"); |
833 |
|
#endif |
834 |
#else |
#else |
835 |
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
836 |
appdata->cur_view = cachelist_create(appdata, gpx, NULL); |
appdata->cur_view = cachelist_create(appdata, gpx, NULL); |
1035 |
|
|
1036 |
gtk_about_dialog_set_name(about, "GPXView"); |
gtk_about_dialog_set_name(about, "GPXView"); |
1037 |
gtk_about_dialog_set_version(about, VERSION); |
gtk_about_dialog_set_version(about, VERSION); |
1038 |
gtk_about_dialog_set_copyright(about, |
|
1039 |
_("GPXView (c) 2008 by\n" |
#ifdef ENABLE_LIBLOCATION |
1040 |
"Till Harbaum <till@harbaum.org>\n" |
char *uses = "uses liblocation"; |
1041 |
"Geocaching.com: Tantil")); |
#elif defined(ENABLE_GPSBT) |
1042 |
|
char *uses = "uses gpsbt and gpsd"; |
1043 |
|
#else |
1044 |
|
char *uses = "uses gpsd"; |
1045 |
|
#endif |
1046 |
|
|
1047 |
|
char *str = g_strdup_printf("%s\n\n(%s)", |
1048 |
|
_("GPXView (c) 2008-2009 by\n" |
1049 |
|
"Till Harbaum <till@harbaum.org>\n" |
1050 |
|
"Mailing list: gpxview-users@garage.maemo.org"), |
1051 |
|
_(uses) |
1052 |
|
); |
1053 |
|
|
1054 |
|
gtk_about_dialog_set_copyright(about, str); |
1055 |
|
g_free(str); |
1056 |
|
|
1057 |
gtk_about_dialog_set_website(about, |
gtk_about_dialog_set_website(about, |
1058 |
_("http://www.harbaum.org/till/maemo")); |
_("http://www.harbaum.org/till/maemo")); |
1090 |
if(new) gpxlist_add(appdata, new); |
if(new) gpxlist_add(appdata, new); |
1091 |
} |
} |
1092 |
|
|
|
static void |
|
|
cb_menu_geomath(GtkWidget *window, gpointer data) { |
|
|
geomath_dialog((appdata_t *)data); |
|
|
} |
|
|
|
|
|
static void |
|
|
cb_menu_geotext(GtkWidget *window, gpointer data) { |
|
|
geotext_dialog((appdata_t *)data); |
|
|
} |
|
|
|
|
|
static void |
|
|
cb_menu_precpos(GtkWidget *window, gpointer data) { |
|
|
precise_position((appdata_t *)data); |
|
|
} |
|
|
|
|
1093 |
#ifndef USE_PANNABLE_AREA |
#ifndef USE_PANNABLE_AREA |
1094 |
static void |
static void |
1095 |
cb_menu_close(GtkWidget *window, gpointer data) { |
cb_menu_close(GtkWidget *window, gpointer data) { |
1408 |
/* don't search if we are asked to search for nothing */ |
/* don't search if we are asked to search for nothing */ |
1409 |
if(((appdata->search & (SEARCH_ID|SEARCH_NAME|SEARCH_DESC|SEARCH_OWNER)) && |
if(((appdata->search & (SEARCH_ID|SEARCH_NAME|SEARCH_DESC|SEARCH_OWNER)) && |
1410 |
strlen(p) > 0) || (appdata->search & SEARCH_FINDS)) { |
strlen(p) > 0) || (appdata->search & SEARCH_FINDS)) { |
|
gpx_t *found = NULL; |
|
1411 |
|
|
1412 |
printf("Search for %s (flags = %x)...\n", p, appdata->search); |
printf("Search for %s (flags = %x)...\n", p, appdata->search); |
1413 |
|
|
1414 |
#ifndef USE_BREAD_CRUMB_TRAIL |
#ifndef USE_BREAD_CRUMB_TRAIL |
1415 |
found = search_do(appdata, appdata->gpx, p, appdata->search, FALSE); |
gpx_t *found = |
1416 |
|
search_do(appdata, appdata->gpx, p, appdata->search, FALSE); |
1417 |
|
|
1418 |
/* do search result dialog here ... */ |
/* do search result dialog here ... */ |
1419 |
cachelist_dialog(appdata, found); |
cachelist_dialog(appdata, found); |
1420 |
|
#ifndef USE_STACKABLE_WINDOW |
1421 |
search_result_free(found); |
search_result_free(found); |
1422 |
#else |
#else |
1423 |
|
appdata->search_results = found; |
1424 |
|
#endif |
1425 |
|
#else |
1426 |
|
gpx_t *found = NULL; |
1427 |
|
|
1428 |
if(appdata->cur_gpx) |
if(appdata->cur_gpx) |
1429 |
found = search_do(appdata, appdata->cur_gpx, p, appdata->search, TRUE); |
found = search_do(appdata, appdata->cur_gpx, p, appdata->search, TRUE); |
1430 |
else |
else |
1445 |
gtk_widget_destroy(dialog); |
gtk_widget_destroy(dialog); |
1446 |
} |
} |
1447 |
|
|
1448 |
void on_window_destroy (GtkWidget *widget, gpointer data); |
static void on_window_destroy (GtkWidget *widget, gpointer data); |
1449 |
|
|
1450 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
1451 |
static void |
static void |
1521 |
garmin_export(appdata); |
garmin_export(appdata); |
1522 |
} |
} |
1523 |
|
|
1524 |
|
#ifdef ENABLE_OSM_GPS_MAP |
1525 |
|
static void |
1526 |
|
cb_menu_map(GtkWidget *window, gpointer data) { |
1527 |
|
map((appdata_t *)data); |
1528 |
|
} |
1529 |
|
#endif |
1530 |
|
|
1531 |
|
static void |
1532 |
|
cb_menu_geomath(GtkWidget *window, gpointer data) { |
1533 |
|
geomath_dialog((appdata_t *)data); |
1534 |
|
} |
1535 |
|
|
1536 |
|
static void |
1537 |
|
cb_menu_geotext(GtkWidget *window, gpointer data) { |
1538 |
|
geotext_dialog((appdata_t *)data); |
1539 |
|
} |
1540 |
|
|
1541 |
|
static void |
1542 |
|
cb_menu_precpos(GtkWidget *window, gpointer data) { |
1543 |
|
precise_position((appdata_t *)data); |
1544 |
|
} |
1545 |
|
|
1546 |
|
#ifdef USE_STACKABLE_WINDOW |
1547 |
|
typedef struct { |
1548 |
|
char *label, *desc; |
1549 |
|
GtkSignalFunc activate_cb; |
1550 |
|
} menu_entry_t; |
1551 |
|
|
1552 |
|
typedef struct { |
1553 |
|
const char *title; |
1554 |
|
const menu_entry_t *menu; |
1555 |
|
int len; |
1556 |
|
} submenu_t; |
1557 |
|
|
1558 |
|
#define COLUMNS 1 |
1559 |
|
|
1560 |
|
void on_submenu_entry_clicked(GtkButton *button, GtkWidget *menu) { |
1561 |
|
|
1562 |
|
/* force closing of submenu dialog */ |
1563 |
|
gtk_dialog_response(GTK_DIALOG(menu), GTK_RESPONSE_NONE); |
1564 |
|
gtk_widget_hide(menu); |
1565 |
|
|
1566 |
|
/* let gtk clean up */ |
1567 |
|
while(gtk_events_pending()) |
1568 |
|
gtk_main_iteration(); |
1569 |
|
} |
1570 |
|
|
1571 |
|
static GtkWidget *app_submenu_create(appdata_t *appdata, |
1572 |
|
const submenu_t *submenu) { |
1573 |
|
|
1574 |
|
/* create a oridinary dialog box */ |
1575 |
|
GtkWidget *dialog = gtk_dialog_new(); |
1576 |
|
gtk_window_set_title(GTK_WINDOW(dialog), _(submenu->title)); |
1577 |
|
gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); |
1578 |
|
gtk_window_set_transient_for(GTK_WINDOW(dialog), |
1579 |
|
GTK_WINDOW(appdata->window)); |
1580 |
|
gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); |
1581 |
|
|
1582 |
|
GtkWidget *table = gtk_table_new(submenu->len/COLUMNS, COLUMNS, TRUE); |
1583 |
|
int x = 0, y = 0; |
1584 |
|
|
1585 |
|
const menu_entry_t *menu_entries = submenu->menu; |
1586 |
|
while(menu_entries->label) { |
1587 |
|
GtkWidget *button = NULL; |
1588 |
|
|
1589 |
|
button = hildon_button_new_with_text( |
1590 |
|
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
1591 |
|
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
1592 |
|
_(menu_entries->label), _(menu_entries->desc)); |
1593 |
|
|
1594 |
|
/* try to center both texts */ |
1595 |
|
hildon_button_set_title_alignment(HILDON_BUTTON(button), 0.5, 0.5); |
1596 |
|
hildon_button_set_value_alignment(HILDON_BUTTON(button), 0.5, 0.5); |
1597 |
|
|
1598 |
|
g_signal_connect(button, "clicked", |
1599 |
|
G_CALLBACK(on_submenu_entry_clicked), dialog); |
1600 |
|
|
1601 |
|
g_signal_connect(button, "clicked", |
1602 |
|
menu_entries->activate_cb, appdata); |
1603 |
|
|
1604 |
|
gtk_table_attach_defaults(GTK_TABLE(table), button, x, x+1, y, y+1); |
1605 |
|
|
1606 |
|
x++; |
1607 |
|
if(x == COLUMNS) { x = 0; y++; } |
1608 |
|
|
1609 |
|
menu_entries++; |
1610 |
|
} |
1611 |
|
|
1612 |
|
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table); |
1613 |
|
|
1614 |
|
return dialog; |
1615 |
|
} |
1616 |
|
|
1617 |
|
/* popup the dialog shaped submenu */ |
1618 |
|
static void submenu_popup(GtkWidget *menu) { |
1619 |
|
gtk_widget_show_all(menu); |
1620 |
|
gtk_dialog_run(GTK_DIALOG(menu)); |
1621 |
|
gtk_widget_hide(menu); |
1622 |
|
} |
1623 |
|
|
1624 |
|
static void submenu_cleanup(GtkWidget *menu) { |
1625 |
|
gtk_widget_destroy(menu); |
1626 |
|
} |
1627 |
|
|
1628 |
|
static const menu_entry_t submenu_export_entries[] = { |
1629 |
|
{ "Export to Maemo Mapper" , "Save a Maemo Mapper POI file", |
1630 |
|
G_CALLBACK(cb_menu_export_mmpoi) }, |
1631 |
|
{ "Export Field Notes", "Save a Garmin Field Notes file", |
1632 |
|
G_CALLBACK(cb_menu_export_log) }, |
1633 |
|
{ "Export Garmin GPX", "Save modified waypoints in GPX file", |
1634 |
|
G_CALLBACK(cb_menu_export_garmin) }, |
1635 |
|
{ NULL, NULL, NULL } |
1636 |
|
}; |
1637 |
|
|
1638 |
|
static const submenu_t submenu_export = { |
1639 |
|
"Export", submenu_export_entries, |
1640 |
|
sizeof(submenu_export_entries)/sizeof(menu_entry_t)-1 |
1641 |
|
}; |
1642 |
|
|
1643 |
|
/* the export submenu */ |
1644 |
|
void on_export_clicked(GtkButton *button, appdata_t *appdata) { |
1645 |
|
if(!appdata->export_menu) |
1646 |
|
appdata->export_menu = app_submenu_create(appdata, &submenu_export); |
1647 |
|
|
1648 |
|
submenu_popup(appdata->export_menu); |
1649 |
|
} |
1650 |
|
|
1651 |
|
static const menu_entry_t submenu_tools_entries[] = { |
1652 |
|
{ "Geomath", "Geocoordinate calculation", |
1653 |
|
G_CALLBACK(cb_menu_geomath) }, |
1654 |
|
{ "Geotext", "Text analysis", |
1655 |
|
G_CALLBACK(cb_menu_geotext) }, |
1656 |
|
{ "Precise Position", "Calculate a precise GPS position", |
1657 |
|
G_CALLBACK(cb_menu_precpos) }, |
1658 |
|
{ NULL, NULL, NULL } |
1659 |
|
}; |
1660 |
|
|
1661 |
|
static const submenu_t submenu_tools = { |
1662 |
|
"Tools", submenu_tools_entries, |
1663 |
|
sizeof(submenu_tools_entries)/sizeof(menu_entry_t)-1 |
1664 |
|
}; |
1665 |
|
|
1666 |
|
/* the tools submenu */ |
1667 |
|
void on_tools_clicked(GtkButton *button, appdata_t *appdata) { |
1668 |
|
if(!appdata->tools_menu) |
1669 |
|
appdata->tools_menu = app_submenu_create(appdata, &submenu_tools); |
1670 |
|
|
1671 |
|
submenu_popup(appdata->tools_menu); |
1672 |
|
} |
1673 |
|
|
1674 |
|
HildonAppMenu *menu_create(appdata_t *appdata, int mode) { |
1675 |
|
GtkWidget *button; |
1676 |
|
HildonAppMenu *menu = HILDON_APP_MENU(hildon_app_menu_new()); |
1677 |
|
|
1678 |
|
/* ------- */ |
1679 |
|
button = gtk_button_new_with_label(_("About")); |
1680 |
|
g_signal_connect_after(button, "clicked", |
1681 |
|
G_CALLBACK(cb_menu_about), appdata); |
1682 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1683 |
|
|
1684 |
|
button = gtk_button_new_with_label(_("Settings")); |
1685 |
|
g_signal_connect_after(button, "clicked", G_CALLBACK(cb_menu_settings), |
1686 |
|
appdata); |
1687 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1688 |
|
|
1689 |
|
if(mode == MENU_GPXLIST) { |
1690 |
|
button = gtk_button_new_with_label(_("Import file")); |
1691 |
|
g_signal_connect_after(button, "clicked", |
1692 |
|
G_CALLBACK(cb_menu_add), appdata); |
1693 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1694 |
|
|
1695 |
|
button = gtk_button_new_with_label(_("Import directory")); |
1696 |
|
g_signal_connect_after(button, "clicked", |
1697 |
|
G_CALLBACK(cb_menu_adddir), appdata); |
1698 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1699 |
|
|
1700 |
|
button = gtk_button_new_with_label(_("Export")); |
1701 |
|
g_signal_connect_after(button, "clicked", |
1702 |
|
G_CALLBACK(on_export_clicked), appdata); |
1703 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1704 |
|
|
1705 |
|
button = gtk_button_new_with_label(_("Search")); |
1706 |
|
g_signal_connect_after(button, "clicked", |
1707 |
|
G_CALLBACK(cb_menu_search), appdata); |
1708 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1709 |
|
} |
1710 |
|
|
1711 |
|
button = gtk_button_new_with_label(_("Tools")); |
1712 |
|
g_signal_connect_after(button, "clicked", |
1713 |
|
G_CALLBACK(on_tools_clicked), appdata); |
1714 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1715 |
|
|
1716 |
|
#ifdef ENABLE_OSM_GPS_MAP |
1717 |
|
if((mode == MENU_GPXLIST) || (mode == MENU_CACHELIST)) { |
1718 |
|
button = gtk_button_new_with_label(_("Map")); |
1719 |
|
g_signal_connect_after(button, "clicked", |
1720 |
|
G_CALLBACK(cb_menu_map), appdata); |
1721 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1722 |
|
} |
1723 |
|
#endif |
1724 |
|
|
1725 |
|
#ifdef HILDON_HELP |
1726 |
|
button = gtk_button_new_with_label(_("Help")); |
1727 |
|
g_signal_connect_after(button, "clicked", |
1728 |
|
G_CALLBACK(cb_menu_help), appdata); |
1729 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1730 |
|
#endif |
1731 |
|
|
1732 |
|
gtk_widget_show_all(GTK_WIDGET(menu)); |
1733 |
|
|
1734 |
|
return menu; |
1735 |
|
} |
1736 |
|
#else |
1737 |
|
|
1738 |
void menu_create(appdata_t *appdata) { |
void menu_create(appdata_t *appdata) { |
1739 |
GtkWidget *menu, *item; |
GtkWidget *menu, *item; |
1740 |
menu = gtk_menu_new(); |
menu = gtk_menu_new(); |
1741 |
|
|
1742 |
#ifdef USE_MAEMO |
#ifdef USE_BREAD_CRUMB_TRAIL |
1743 |
appdata->menu_import = |
appdata->menu_import = |
1744 |
#endif |
#endif |
1745 |
item = gtk_menu_item_new_with_label(_("Import")); |
item = gtk_menu_item_new_with_label(_("Import")); |
1747 |
GtkWidget *submenu = gtk_menu_new(); |
GtkWidget *submenu = gtk_menu_new(); |
1748 |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
1749 |
|
|
1750 |
item = gtk_menu_item_new_with_label( _("File...") ); |
item = gtk_menu_item_new_with_label( _("File") ); |
1751 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1752 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_add), appdata); |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_add), appdata); |
1753 |
|
|
1754 |
item = gtk_menu_item_new_with_label( _("Directory...") ); |
item = gtk_menu_item_new_with_label( _("Directory") ); |
1755 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1756 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_adddir), appdata); |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_adddir), appdata); |
1757 |
|
|
1769 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_remove), appdata); |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_remove), appdata); |
1770 |
#endif |
#endif |
1771 |
|
|
1772 |
#ifdef USE_MAEMO |
#ifdef USE_BREAD_CRUMB_TRAIL |
1773 |
appdata->menu_export = |
appdata->menu_export = |
1774 |
#endif |
#endif |
1775 |
item = gtk_menu_item_new_with_label(_("Export")); |
item = gtk_menu_item_new_with_label(_("Export")); |
1778 |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
1779 |
|
|
1780 |
#ifdef USE_MAEMO |
#ifdef USE_MAEMO |
1781 |
item = gtk_menu_item_new_with_label( _("Maemo Mapper POI...") ); |
item = gtk_menu_item_new_with_label( _("Maemo Mapper POI") ); |
1782 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1783 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
1784 |
GTK_SIGNAL_FUNC(cb_menu_export_mmpoi), appdata); |
GTK_SIGNAL_FUNC(cb_menu_export_mmpoi), appdata); |
1785 |
#endif |
#endif |
1786 |
|
|
1787 |
item = gtk_menu_item_new_with_label( _("Garmin Field Notes...") ); |
item = gtk_menu_item_new_with_label( _("Garmin Field Notes") ); |
1788 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1789 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
1790 |
GTK_SIGNAL_FUNC(cb_menu_export_log), appdata); |
GTK_SIGNAL_FUNC(cb_menu_export_log), appdata); |
1791 |
|
|
1792 |
item = gtk_menu_item_new_with_label( _("Garmin GPX...") ); |
item = gtk_menu_item_new_with_label( _("Garmin GPX") ); |
1793 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1794 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
1795 |
GTK_SIGNAL_FUNC(cb_menu_export_garmin), appdata); |
GTK_SIGNAL_FUNC(cb_menu_export_garmin), appdata); |
1796 |
|
|
1797 |
#ifdef USE_MAEMO |
#ifdef USE_BREAD_CRUMB_TRAIL |
1798 |
appdata->menu_search = |
appdata->menu_search = |
1799 |
#endif |
#endif |
1800 |
item = gtk_menu_item_new_with_label( _("Search...") ); |
item = gtk_menu_item_new_with_label( _("Search") ); |
1801 |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
1802 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_search), appdata); |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_search), appdata); |
1803 |
|
|
1827 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_paste), appdata); |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_paste), appdata); |
1828 |
#endif |
#endif |
1829 |
|
|
1830 |
item = gtk_menu_item_new_with_label( _("Settings...") ); |
item = gtk_menu_item_new_with_label( _("Settings") ); |
1831 |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
1832 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_settings), |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_settings), |
1833 |
appdata); |
appdata); |
1839 |
submenu = gtk_menu_new(); |
submenu = gtk_menu_new(); |
1840 |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
1841 |
|
|
1842 |
item = gtk_menu_item_new_with_label( _("Geomath...") ); |
#ifdef ENABLE_OSM_GPS_MAP |
1843 |
|
item = gtk_menu_item_new_with_label( _("Map") ); |
1844 |
|
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1845 |
|
g_signal_connect(item, "activate", |
1846 |
|
GTK_SIGNAL_FUNC(cb_menu_map), appdata); |
1847 |
|
#endif |
1848 |
|
|
1849 |
|
item = gtk_menu_item_new_with_label( _("Geomath") ); |
1850 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1851 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
1852 |
GTK_SIGNAL_FUNC(cb_menu_geomath), appdata); |
GTK_SIGNAL_FUNC(cb_menu_geomath), appdata); |
1853 |
|
|
1854 |
item = gtk_menu_item_new_with_label( _("Geotext...") ); |
item = gtk_menu_item_new_with_label( _("Geotext") ); |
1855 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1856 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
1857 |
GTK_SIGNAL_FUNC(cb_menu_geotext), appdata); |
GTK_SIGNAL_FUNC(cb_menu_geotext), appdata); |
1858 |
|
|
1859 |
item = gtk_menu_item_new_with_label( _("Precise Position...") ); |
item = gtk_menu_item_new_with_label( _("Precise Position") ); |
1860 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1861 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
1862 |
GTK_SIGNAL_FUNC(cb_menu_precpos), appdata); |
GTK_SIGNAL_FUNC(cb_menu_precpos), appdata); |
1864 |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
1865 |
|
|
1866 |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
1867 |
item = gtk_menu_item_new_with_label( _("Help...") ); |
item = gtk_menu_item_new_with_label( _("Help") ); |
1868 |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
1869 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_help), appdata); |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_help), appdata); |
1870 |
#endif |
#endif |
1871 |
|
|
1872 |
item = gtk_menu_item_new_with_label( _("About...") ); |
item = gtk_menu_item_new_with_label( _("About") ); |
1873 |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
1874 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_about), appdata); |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_about), appdata); |
1875 |
|
|
1895 |
gtk_box_pack_start(GTK_BOX(appdata->vbox), menu_bar, 0, 0, 0); |
gtk_box_pack_start(GTK_BOX(appdata->vbox), menu_bar, 0, 0, 0); |
1896 |
#endif |
#endif |
1897 |
} |
} |
1898 |
|
#endif |
1899 |
|
|
1900 |
/********************* end of menu **********************/ |
/********************* end of menu **********************/ |
1901 |
|
|
1905 |
if(appdata->image_path) free(appdata->image_path); |
if(appdata->image_path) free(appdata->image_path); |
1906 |
if(appdata->search_str) free(appdata->search_str); |
if(appdata->search_str) free(appdata->search_str); |
1907 |
|
|
1908 |
|
#ifdef USE_STACKABLE_WINDOW |
1909 |
|
if(appdata->export_menu) submenu_cleanup(appdata->export_menu); |
1910 |
|
if(appdata->tools_menu) submenu_cleanup(appdata->tools_menu); |
1911 |
|
#endif |
1912 |
|
|
1913 |
gnome_vfs_shutdown(); |
gnome_vfs_shutdown(); |
1914 |
icons_free(); |
icons_free(); |
1915 |
gps_release(appdata); |
gps_release(appdata); |
1938 |
puts("everything is gone"); |
puts("everything is gone"); |
1939 |
} |
} |
1940 |
|
|
1941 |
void on_window_destroy (GtkWidget *widget, gpointer data) { |
static void on_window_destroy (GtkWidget *widget, gpointer data) { |
1942 |
appdata_t *appdata = (appdata_t*)data; |
appdata_t *appdata = (appdata_t*)data; |
1943 |
|
|
1944 |
gconf_save_state(appdata); |
gconf_save_state(appdata); |
1947 |
} |
} |
1948 |
|
|
1949 |
gboolean on_window_key_press(GtkWidget *widget, |
gboolean on_window_key_press(GtkWidget *widget, |
1950 |
GdkEventKey *event, gpointer data) { |
GdkEventKey *event, appdata_t *appdata) { |
|
appdata_t *appdata = (appdata_t*)data; |
|
1951 |
int handled = FALSE; |
int handled = FALSE; |
1952 |
|
|
1953 |
// printf("key event %d\n", event->keyval); |
// printf("key event %d\n", event->keyval); |
1955 |
switch(event->keyval) { |
switch(event->keyval) { |
1956 |
#ifdef USE_MAEMO |
#ifdef USE_MAEMO |
1957 |
|
|
|
#if 0 /* don't do this as it interferes with gtkentry fields */ |
|
|
case HILDON_HARDKEY_SELECT: |
|
|
/* remove as long as we haven't reached the main gpx list */ |
|
|
if(appdata->cur_gpx) |
|
|
hildon_bread_crumb_trail_pop(HILDON_BREAD_CRUMB_TRAIL(appdata->bct)); |
|
|
handled = TRUE; |
|
|
break; |
|
|
#endif |
|
|
|
|
1958 |
#ifdef HILDON_HARDKEY_INCREASE |
#ifdef HILDON_HARDKEY_INCREASE |
1959 |
case HILDON_HARDKEY_INCREASE: |
case HILDON_HARDKEY_INCREASE: |
1960 |
html_zoom(appdata, TRUE); |
html_zoom(appdata, TRUE); |
2139 |
#endif // USE_BREAD_CRUMB_TRAIL |
#endif // USE_BREAD_CRUMB_TRAIL |
2140 |
|
|
2141 |
void main_after_settings_redraw(appdata_t *appdata, int flags) { |
void main_after_settings_redraw(appdata_t *appdata, int flags) { |
2142 |
|
printf("main after settings redraw\n"); |
2143 |
|
|
2144 |
|
if(!appdata->cur_view) { |
2145 |
|
printf("no active view\n"); |
2146 |
|
return; |
2147 |
|
} |
2148 |
|
|
2149 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
2150 |
// in non-maemo setup this can only affect the main screen as |
// in non-maemo setup this can only affect the main screen as |
2151 |
// the menu is blocked while a dialog is open. also the main |
// the menu is blocked while a dialog is open. also the main |
2181 |
} |
} |
2182 |
|
|
2183 |
if(redraw) { |
if(redraw) { |
2184 |
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
GtkWidget *container = appdata->vbox; |
2185 |
|
|
2186 |
|
#ifdef USE_STACKABLE_WINDOW |
2187 |
|
HildonWindowStack *stack = hildon_window_stack_get_default(); |
2188 |
|
container = hildon_window_stack_peek(stack); |
2189 |
|
#endif |
2190 |
|
|
2191 |
|
gtk_container_remove(GTK_CONTAINER(container), appdata->cur_view); |
2192 |
switch(redraw) { |
switch(redraw) { |
2193 |
case 1: |
case 1: |
2194 |
appdata->cur_view = cachelist_create(appdata, |
appdata->cur_view = cachelist_create(appdata, |
2203 |
break; |
break; |
2204 |
} |
} |
2205 |
|
|
2206 |
gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
#ifdef USE_STACKABLE_WINDOW |
2207 |
gtk_widget_show_all(appdata->vbox); |
if(container != appdata->vbox) |
2208 |
} |
gtk_container_add(GTK_CONTAINER(container), appdata->cur_view); |
2209 |
|
else |
2210 |
#endif |
#endif |
2211 |
|
gtk_box_pack_start_defaults(GTK_BOX(container), appdata->cur_view); |
2212 |
|
|
2213 |
|
gtk_widget_show_all(container); |
2214 |
|
} |
2215 |
|
#endif // USE_MAEMO |
2216 |
} |
} |
2217 |
|
|
2218 |
int main(int argc, char *argv[]) { |
int main(int argc, char *argv[]) { |
2269 |
gtk_window_set_default_size(GTK_WINDOW(appdata.window), 500, 300); |
gtk_window_set_default_size(GTK_WINDOW(appdata.window), 500, 300); |
2270 |
#endif |
#endif |
2271 |
|
|
2272 |
|
#if MAEMO_VERSION_MAJOR == 5 |
2273 |
gtk_window_set_title(GTK_WINDOW(appdata.window), "GPXView"); |
gtk_window_set_title(GTK_WINDOW(appdata.window), "GPXView"); |
2274 |
|
#endif |
2275 |
|
|
2276 |
g_signal_connect(G_OBJECT(appdata.window), "destroy", |
g_signal_connect(G_OBJECT(appdata.window), "destroy", |
2277 |
G_CALLBACK(on_window_destroy), &appdata); |
G_CALLBACK(on_window_destroy), &appdata); |
2278 |
|
|
2281 |
|
|
2282 |
appdata.vbox = gtk_vbox_new(FALSE, 2); |
appdata.vbox = gtk_vbox_new(FALSE, 2); |
2283 |
gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox); |
gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox); |
2284 |
|
#ifndef USE_STACKABLE_WINDOW |
2285 |
menu_create(&appdata); |
menu_create(&appdata); |
2286 |
|
#else |
2287 |
|
hildon_window_set_app_menu(HILDON_WINDOW(appdata.window), |
2288 |
|
menu_create(&appdata, MENU_GPXLIST)); |
2289 |
|
#endif |
2290 |
|
|
2291 |
#ifdef USE_BREAD_CRUMB_TRAIL |
#ifdef USE_BREAD_CRUMB_TRAIL |
2292 |
appdata.bct = hildon_bread_crumb_trail_new(); |
appdata.bct = hildon_bread_crumb_trail_new(); |