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, |
264 |
// gtk_widget_show_all(appdata->vbox); |
// gtk_widget_show_all(appdata->vbox); |
265 |
#else |
#else |
266 |
|
|
267 |
|
if(!appdata->cur_view) { |
268 |
|
printf("cachelist redraw: no active view\n"); |
269 |
|
return; |
270 |
|
} |
271 |
|
|
272 |
g_assert(!appdata->cur_cache); |
g_assert(!appdata->cur_cache); |
273 |
int redraw = 0; |
int redraw = 0; |
274 |
if(appdata->search_results) |
if(appdata->search_results) |
279 |
} |
} |
280 |
|
|
281 |
if(redraw) { |
if(redraw) { |
282 |
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
GtkWidget *container = appdata->vbox; |
283 |
|
|
284 |
|
printf("redraw %d\n", redraw); |
285 |
|
|
286 |
|
#ifdef USE_STACKABLE_WINDOW |
287 |
|
HildonWindowStack *stack = hildon_window_stack_get_default(); |
288 |
|
container = hildon_window_stack_peek(stack); |
289 |
|
#endif |
290 |
|
|
291 |
|
gtk_container_remove(GTK_CONTAINER(container), appdata->cur_view); |
292 |
switch(redraw) { |
switch(redraw) { |
293 |
case 1: |
case 1: |
294 |
appdata->cur_view = cachelist_create(appdata, |
appdata->cur_view = cachelist_create(appdata, |
300 |
break; |
break; |
301 |
} |
} |
302 |
|
|
303 |
gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
#ifdef USE_STACKABLE_WINDOW |
304 |
gtk_widget_show_all(appdata->vbox); |
if(container != appdata->vbox) |
305 |
|
gtk_container_add(GTK_CONTAINER(container), appdata->cur_view); |
306 |
|
else |
307 |
|
#endif |
308 |
|
gtk_box_pack_start_defaults(GTK_BOX(container), appdata->cur_view); |
309 |
|
|
310 |
|
gtk_widget_show_all(container); |
311 |
} |
} |
312 |
#endif |
#endif |
313 |
} |
} |
320 |
#ifdef USE_MAEMO |
#ifdef USE_MAEMO |
321 |
appdata_t *appdata = (appdata_t*)data; |
appdata_t *appdata = (appdata_t*)data; |
322 |
|
|
323 |
|
if(appdata->cur_cache) |
324 |
|
return TRUE; |
325 |
|
|
326 |
if(appdata->cachelist_disable_screensaver) |
if(appdata->cachelist_disable_screensaver) |
327 |
if (osso_display_blanking_pause(appdata->osso_context) != OSSO_OK) |
if (osso_display_blanking_pause(appdata->osso_context) != OSSO_OK) |
328 |
fprintf(stderr, "error with display blank\n"); |
fprintf(stderr, "error with display blank\n"); |
335 |
} |
} |
336 |
|
|
337 |
static void cachelist_timer_reset(appdata_t *appdata) { |
static void cachelist_timer_reset(appdata_t *appdata) { |
338 |
|
printf("cachelist timer reset\n"); |
339 |
g_assert(appdata->cachelist_handler_id); |
g_assert(appdata->cachelist_handler_id); |
340 |
gtk_timeout_remove(appdata->cachelist_handler_id); |
gtk_timeout_remove(appdata->cachelist_handler_id); |
341 |
appdata->cachelist_handler_id = |
appdata->cachelist_handler_id = |
567 |
} |
} |
568 |
#else |
#else |
569 |
#ifdef USE_STACKABLE_WINDOW |
#ifdef USE_STACKABLE_WINDOW |
570 |
|
static void search_result_free(gpx_t *result); |
571 |
|
|
572 |
|
void on_cachelist_destroy(GtkWidget *widget, appdata_t *appdata) { |
573 |
|
if(appdata->search_results) { |
574 |
|
search_result_free(appdata->search_results); |
575 |
|
appdata->search_results = NULL; |
576 |
|
} |
577 |
|
appdata->cur_gpx = NULL; |
578 |
|
|
579 |
|
/* restore cur_view */ |
580 |
|
appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view"); |
581 |
|
} |
582 |
|
|
583 |
void cachelist_dialog(appdata_t *appdata, gpx_t *gpx) { |
void cachelist_dialog(appdata_t *appdata, gpx_t *gpx) { |
584 |
GtkWidget *window = hildon_stackable_window_new(); |
GtkWidget *window = hildon_stackable_window_new(); |
585 |
|
|
586 |
gtk_window_set_title(GTK_WINDOW(window), gpx->name); |
/* store last "cur_view" in window */ |
587 |
|
g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view); |
588 |
|
|
589 |
gtk_container_add(GTK_CONTAINER(window), |
appdata->cur_gpx = gpx; |
590 |
cachelist_create(appdata, gpx, NULL)); |
char *title = g_strdup_printf("%s - GPXView", gpx->name); |
591 |
|
gtk_window_set_title(GTK_WINDOW(window), title); |
592 |
|
g_free(title); |
593 |
|
|
594 |
|
appdata->cur_view = cachelist_create(appdata, gpx, NULL); |
595 |
|
gtk_container_add(GTK_CONTAINER(window), appdata->cur_view); |
596 |
|
|
597 |
|
|
598 |
|
hildon_window_set_app_menu(HILDON_WINDOW(window), |
599 |
|
menu_create(appdata, MENU_CACHELIST)); |
600 |
|
|
601 |
|
g_signal_connect(G_OBJECT(window), "destroy", |
602 |
|
G_CALLBACK(on_cachelist_destroy), appdata); |
603 |
|
|
604 |
gtk_widget_show_all(window); |
gtk_widget_show_all(window); |
605 |
} |
} |
811 |
gpx_busy_dialog_destroy(dialog); |
gpx_busy_dialog_destroy(dialog); |
812 |
} |
} |
813 |
#ifndef USE_BREAD_CRUMB_TRAIL |
#ifndef USE_BREAD_CRUMB_TRAIL |
814 |
cachelist_dialog(appdata, gpx); |
#ifdef USE_STACKABLE_WINDOW |
815 |
|
if(!appdata->cur_gpx) |
816 |
|
#endif |
817 |
|
cachelist_dialog(appdata, gpx); |
818 |
|
#ifdef USE_STACKABLE_WINDOW |
819 |
|
else |
820 |
|
printf("selected gpx, but cachelist window already present\n"); |
821 |
|
#endif |
822 |
#else |
#else |
823 |
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
824 |
appdata->cur_view = cachelist_create(appdata, gpx, NULL); |
appdata->cur_view = cachelist_create(appdata, gpx, NULL); |
1023 |
|
|
1024 |
gtk_about_dialog_set_name(about, "GPXView"); |
gtk_about_dialog_set_name(about, "GPXView"); |
1025 |
gtk_about_dialog_set_version(about, VERSION); |
gtk_about_dialog_set_version(about, VERSION); |
1026 |
gtk_about_dialog_set_copyright(about, |
|
1027 |
_("GPXView (c) 2008 by\n" |
#ifdef ENABLE_LIBLOCATION |
1028 |
"Till Harbaum <till@harbaum.org>\n" |
char *uses = "uses liblocation"; |
1029 |
"Geocaching.com: Tantil")); |
#elif defined(ENABLE_GPSBT) |
1030 |
|
char *uses = "uses gpsbt and gpsd"; |
1031 |
|
#else |
1032 |
|
char *uses = "uses gpsd"; |
1033 |
|
#endif |
1034 |
|
|
1035 |
|
char *str = g_strdup_printf("%s\n\n(%s)", |
1036 |
|
_("GPXView (c) 2008-2009 by\n" |
1037 |
|
"Till Harbaum <till@harbaum.org>\n" |
1038 |
|
"Mailing list: gpxview-users@garage.maemo.org"), |
1039 |
|
_(uses) |
1040 |
|
); |
1041 |
|
|
1042 |
|
gtk_about_dialog_set_copyright(about, str); |
1043 |
|
g_free(str); |
1044 |
|
|
1045 |
gtk_about_dialog_set_website(about, |
gtk_about_dialog_set_website(about, |
1046 |
_("http://www.harbaum.org/till/maemo")); |
_("http://www.harbaum.org/till/maemo")); |
1078 |
if(new) gpxlist_add(appdata, new); |
if(new) gpxlist_add(appdata, new); |
1079 |
} |
} |
1080 |
|
|
|
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); |
|
|
} |
|
|
|
|
1081 |
#ifndef USE_PANNABLE_AREA |
#ifndef USE_PANNABLE_AREA |
1082 |
static void |
static void |
1083 |
cb_menu_close(GtkWidget *window, gpointer data) { |
cb_menu_close(GtkWidget *window, gpointer data) { |
1396 |
/* don't search if we are asked to search for nothing */ |
/* don't search if we are asked to search for nothing */ |
1397 |
if(((appdata->search & (SEARCH_ID|SEARCH_NAME|SEARCH_DESC|SEARCH_OWNER)) && |
if(((appdata->search & (SEARCH_ID|SEARCH_NAME|SEARCH_DESC|SEARCH_OWNER)) && |
1398 |
strlen(p) > 0) || (appdata->search & SEARCH_FINDS)) { |
strlen(p) > 0) || (appdata->search & SEARCH_FINDS)) { |
|
gpx_t *found = NULL; |
|
1399 |
|
|
1400 |
printf("Search for %s (flags = %x)...\n", p, appdata->search); |
printf("Search for %s (flags = %x)...\n", p, appdata->search); |
1401 |
|
|
1402 |
#ifndef USE_BREAD_CRUMB_TRAIL |
#ifndef USE_BREAD_CRUMB_TRAIL |
1403 |
found = search_do(appdata, appdata->gpx, p, appdata->search, FALSE); |
gpx_t *found = |
1404 |
|
search_do(appdata, appdata->gpx, p, appdata->search, FALSE); |
1405 |
|
|
1406 |
/* do search result dialog here ... */ |
/* do search result dialog here ... */ |
1407 |
cachelist_dialog(appdata, found); |
cachelist_dialog(appdata, found); |
1408 |
|
#ifndef USE_STACKABLE_WINDOW |
1409 |
search_result_free(found); |
search_result_free(found); |
1410 |
#else |
#else |
1411 |
|
appdata->search_results = found; |
1412 |
|
#endif |
1413 |
|
#else |
1414 |
|
gpx_t *found = NULL; |
1415 |
|
|
1416 |
if(appdata->cur_gpx) |
if(appdata->cur_gpx) |
1417 |
found = search_do(appdata, appdata->cur_gpx, p, appdata->search, TRUE); |
found = search_do(appdata, appdata->cur_gpx, p, appdata->search, TRUE); |
1418 |
else |
else |
1433 |
gtk_widget_destroy(dialog); |
gtk_widget_destroy(dialog); |
1434 |
} |
} |
1435 |
|
|
1436 |
void on_window_destroy (GtkWidget *widget, gpointer data); |
static void on_window_destroy (GtkWidget *widget, gpointer data); |
1437 |
|
|
1438 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
1439 |
static void |
static void |
1509 |
garmin_export(appdata); |
garmin_export(appdata); |
1510 |
} |
} |
1511 |
|
|
1512 |
|
#ifdef ENABLE_OSM_GPS_MAP |
1513 |
|
static void |
1514 |
|
cb_menu_map(GtkWidget *window, gpointer data) { |
1515 |
|
map((appdata_t *)data); |
1516 |
|
} |
1517 |
|
#endif |
1518 |
|
|
1519 |
|
static void |
1520 |
|
cb_menu_geomath(GtkWidget *window, gpointer data) { |
1521 |
|
geomath_dialog((appdata_t *)data); |
1522 |
|
} |
1523 |
|
|
1524 |
|
static void |
1525 |
|
cb_menu_geotext(GtkWidget *window, gpointer data) { |
1526 |
|
geotext_dialog((appdata_t *)data); |
1527 |
|
} |
1528 |
|
|
1529 |
|
static void |
1530 |
|
cb_menu_precpos(GtkWidget *window, gpointer data) { |
1531 |
|
precise_position((appdata_t *)data); |
1532 |
|
} |
1533 |
|
|
1534 |
|
#ifdef USE_STACKABLE_WINDOW |
1535 |
|
typedef struct { |
1536 |
|
char *label, *desc; |
1537 |
|
GtkSignalFunc activate_cb; |
1538 |
|
} menu_entry_t; |
1539 |
|
|
1540 |
|
typedef struct { |
1541 |
|
const char *title; |
1542 |
|
const menu_entry_t *menu; |
1543 |
|
int len; |
1544 |
|
} submenu_t; |
1545 |
|
|
1546 |
|
#define COLUMNS 1 |
1547 |
|
|
1548 |
|
void on_submenu_entry_clicked(GtkButton *button, GtkWidget *menu) { |
1549 |
|
|
1550 |
|
/* force closing of submenu dialog */ |
1551 |
|
gtk_dialog_response(GTK_DIALOG(menu), GTK_RESPONSE_NONE); |
1552 |
|
gtk_widget_hide(menu); |
1553 |
|
|
1554 |
|
/* let gtk clean up */ |
1555 |
|
while(gtk_events_pending()) |
1556 |
|
gtk_main_iteration(); |
1557 |
|
} |
1558 |
|
|
1559 |
|
static GtkWidget *app_submenu_create(appdata_t *appdata, |
1560 |
|
const submenu_t *submenu) { |
1561 |
|
|
1562 |
|
/* create a oridinary dialog box */ |
1563 |
|
GtkWidget *dialog = gtk_dialog_new(); |
1564 |
|
gtk_window_set_title(GTK_WINDOW(dialog), _(submenu->title)); |
1565 |
|
gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); |
1566 |
|
gtk_window_set_transient_for(GTK_WINDOW(dialog), |
1567 |
|
GTK_WINDOW(appdata->window)); |
1568 |
|
gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); |
1569 |
|
|
1570 |
|
GtkWidget *table = gtk_table_new(submenu->len/COLUMNS, COLUMNS, TRUE); |
1571 |
|
int x = 0, y = 0; |
1572 |
|
|
1573 |
|
const menu_entry_t *menu_entries = submenu->menu; |
1574 |
|
while(menu_entries->label) { |
1575 |
|
GtkWidget *button = NULL; |
1576 |
|
|
1577 |
|
button = hildon_button_new_with_text( |
1578 |
|
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
1579 |
|
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
1580 |
|
_(menu_entries->label), _(menu_entries->desc)); |
1581 |
|
|
1582 |
|
/* try to center both texts */ |
1583 |
|
hildon_button_set_title_alignment(HILDON_BUTTON(button), 0.5, 0.5); |
1584 |
|
hildon_button_set_value_alignment(HILDON_BUTTON(button), 0.5, 0.5); |
1585 |
|
|
1586 |
|
g_signal_connect(button, "clicked", |
1587 |
|
G_CALLBACK(on_submenu_entry_clicked), dialog); |
1588 |
|
|
1589 |
|
g_signal_connect(button, "clicked", |
1590 |
|
menu_entries->activate_cb, appdata); |
1591 |
|
|
1592 |
|
gtk_table_attach_defaults(GTK_TABLE(table), button, x, x+1, y, y+1); |
1593 |
|
|
1594 |
|
x++; |
1595 |
|
if(x == COLUMNS) { x = 0; y++; } |
1596 |
|
|
1597 |
|
menu_entries++; |
1598 |
|
} |
1599 |
|
|
1600 |
|
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table); |
1601 |
|
|
1602 |
|
return dialog; |
1603 |
|
} |
1604 |
|
|
1605 |
|
/* popup the dialog shaped submenu */ |
1606 |
|
static void submenu_popup(GtkWidget *menu) { |
1607 |
|
gtk_widget_show_all(menu); |
1608 |
|
gtk_dialog_run(GTK_DIALOG(menu)); |
1609 |
|
gtk_widget_hide(menu); |
1610 |
|
} |
1611 |
|
|
1612 |
|
static void submenu_cleanup(GtkWidget *menu) { |
1613 |
|
gtk_widget_destroy(menu); |
1614 |
|
} |
1615 |
|
|
1616 |
|
static const menu_entry_t submenu_export_entries[] = { |
1617 |
|
{ "Export to Maemo Mapper" , "Save a Maemo Mapper POI file", |
1618 |
|
G_CALLBACK(cb_menu_export_mmpoi) }, |
1619 |
|
{ "Export Field Notes", "Save a Garmin Field Notes file", |
1620 |
|
G_CALLBACK(cb_menu_export_log) }, |
1621 |
|
{ "Export Garmin GPX", "Save modified waypoints in GPX file", |
1622 |
|
G_CALLBACK(cb_menu_export_garmin) }, |
1623 |
|
{ NULL, NULL, NULL } |
1624 |
|
}; |
1625 |
|
|
1626 |
|
static const submenu_t submenu_export = { |
1627 |
|
"Export", submenu_export_entries, |
1628 |
|
sizeof(submenu_export_entries)/sizeof(menu_entry_t)-1 |
1629 |
|
}; |
1630 |
|
|
1631 |
|
/* the export submenu */ |
1632 |
|
void on_export_clicked(GtkButton *button, appdata_t *appdata) { |
1633 |
|
if(!appdata->export_menu) |
1634 |
|
appdata->export_menu = app_submenu_create(appdata, &submenu_export); |
1635 |
|
|
1636 |
|
submenu_popup(appdata->export_menu); |
1637 |
|
} |
1638 |
|
|
1639 |
|
static const menu_entry_t submenu_tools_entries[] = { |
1640 |
|
#ifdef ENABLE_OSM_GPS_MAP |
1641 |
|
{ "Map", "Display an interactive world map", |
1642 |
|
G_CALLBACK(cb_menu_map) }, |
1643 |
|
#endif |
1644 |
|
{ "Geomath", "Geocoordinate calculation", |
1645 |
|
G_CALLBACK(cb_menu_geomath) }, |
1646 |
|
{ "Geotext", "Text analysis", |
1647 |
|
G_CALLBACK(cb_menu_geotext) }, |
1648 |
|
{ "Precise Position", "Calculate a precise GPS position", |
1649 |
|
G_CALLBACK(cb_menu_precpos) }, |
1650 |
|
{ NULL, NULL, NULL } |
1651 |
|
}; |
1652 |
|
|
1653 |
|
static const submenu_t submenu_tools = { |
1654 |
|
"Tools", submenu_tools_entries, |
1655 |
|
sizeof(submenu_tools_entries)/sizeof(menu_entry_t)-1 |
1656 |
|
}; |
1657 |
|
|
1658 |
|
/* the tools submenu */ |
1659 |
|
void on_tools_clicked(GtkButton *button, appdata_t *appdata) { |
1660 |
|
if(!appdata->tools_menu) |
1661 |
|
appdata->tools_menu = app_submenu_create(appdata, &submenu_tools); |
1662 |
|
|
1663 |
|
submenu_popup(appdata->tools_menu); |
1664 |
|
} |
1665 |
|
|
1666 |
|
HildonAppMenu *menu_create(appdata_t *appdata, int mode) { |
1667 |
|
GtkWidget *button; |
1668 |
|
HildonAppMenu *menu = HILDON_APP_MENU(hildon_app_menu_new()); |
1669 |
|
|
1670 |
|
/* ------- */ |
1671 |
|
button = gtk_button_new_with_label(_("About")); |
1672 |
|
g_signal_connect_after(button, "clicked", |
1673 |
|
G_CALLBACK(cb_menu_about), appdata); |
1674 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1675 |
|
|
1676 |
|
button = gtk_button_new_with_label(_("Settings")); |
1677 |
|
g_signal_connect_after(button, "clicked", G_CALLBACK(cb_menu_settings), |
1678 |
|
appdata); |
1679 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1680 |
|
|
1681 |
|
if(mode == MENU_GPXLIST) { |
1682 |
|
button = gtk_button_new_with_label(_("Import file")); |
1683 |
|
g_signal_connect_after(button, "clicked", |
1684 |
|
G_CALLBACK(cb_menu_add), appdata); |
1685 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1686 |
|
|
1687 |
|
button = gtk_button_new_with_label(_("Import directory")); |
1688 |
|
g_signal_connect_after(button, "clicked", |
1689 |
|
G_CALLBACK(cb_menu_adddir), appdata); |
1690 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1691 |
|
} |
1692 |
|
|
1693 |
|
if(mode == MENU_GPXLIST) { |
1694 |
|
button = gtk_button_new_with_label(_("Export")); |
1695 |
|
g_signal_connect_after(button, "clicked", |
1696 |
|
G_CALLBACK(on_export_clicked), appdata); |
1697 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1698 |
|
|
1699 |
|
button = gtk_button_new_with_label(_("Search")); |
1700 |
|
g_signal_connect_after(button, "clicked", |
1701 |
|
G_CALLBACK(cb_menu_search), appdata); |
1702 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1703 |
|
} |
1704 |
|
|
1705 |
|
button = gtk_button_new_with_label(_("Tools")); |
1706 |
|
g_signal_connect_after(button, "clicked", |
1707 |
|
G_CALLBACK(on_tools_clicked), appdata); |
1708 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1709 |
|
|
1710 |
|
#ifdef HILDON_HELP |
1711 |
|
button = gtk_button_new_with_label(_("Help")); |
1712 |
|
g_signal_connect_after(button, "clicked", |
1713 |
|
G_CALLBACK(cb_menu_help), appdata); |
1714 |
|
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
1715 |
|
#endif |
1716 |
|
|
1717 |
|
gtk_widget_show_all(GTK_WIDGET(menu)); |
1718 |
|
|
1719 |
|
return menu; |
1720 |
|
} |
1721 |
|
#else |
1722 |
|
|
1723 |
void menu_create(appdata_t *appdata) { |
void menu_create(appdata_t *appdata) { |
1724 |
GtkWidget *menu, *item; |
GtkWidget *menu, *item; |
1725 |
menu = gtk_menu_new(); |
menu = gtk_menu_new(); |
1726 |
|
|
1727 |
#ifdef USE_MAEMO |
#ifdef USE_BREAD_CRUMB_TRAIL |
1728 |
appdata->menu_import = |
appdata->menu_import = |
1729 |
#endif |
#endif |
1730 |
item = gtk_menu_item_new_with_label(_("Import")); |
item = gtk_menu_item_new_with_label(_("Import")); |
1732 |
GtkWidget *submenu = gtk_menu_new(); |
GtkWidget *submenu = gtk_menu_new(); |
1733 |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
1734 |
|
|
1735 |
item = gtk_menu_item_new_with_label( _("File...") ); |
item = gtk_menu_item_new_with_label( _("File") ); |
1736 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1737 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_add), appdata); |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_add), appdata); |
1738 |
|
|
1739 |
item = gtk_menu_item_new_with_label( _("Directory...") ); |
item = gtk_menu_item_new_with_label( _("Directory") ); |
1740 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1741 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_adddir), appdata); |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_adddir), appdata); |
1742 |
|
|
1754 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_remove), appdata); |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_remove), appdata); |
1755 |
#endif |
#endif |
1756 |
|
|
1757 |
#ifdef USE_MAEMO |
#ifdef USE_BREAD_CRUMB_TRAIL |
1758 |
appdata->menu_export = |
appdata->menu_export = |
1759 |
#endif |
#endif |
1760 |
item = gtk_menu_item_new_with_label(_("Export")); |
item = gtk_menu_item_new_with_label(_("Export")); |
1763 |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
1764 |
|
|
1765 |
#ifdef USE_MAEMO |
#ifdef USE_MAEMO |
1766 |
item = gtk_menu_item_new_with_label( _("Maemo Mapper POI...") ); |
item = gtk_menu_item_new_with_label( _("Maemo Mapper POI") ); |
1767 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1768 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
1769 |
GTK_SIGNAL_FUNC(cb_menu_export_mmpoi), appdata); |
GTK_SIGNAL_FUNC(cb_menu_export_mmpoi), appdata); |
1770 |
#endif |
#endif |
1771 |
|
|
1772 |
item = gtk_menu_item_new_with_label( _("Garmin Field Notes...") ); |
item = gtk_menu_item_new_with_label( _("Garmin Field Notes") ); |
1773 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1774 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
1775 |
GTK_SIGNAL_FUNC(cb_menu_export_log), appdata); |
GTK_SIGNAL_FUNC(cb_menu_export_log), appdata); |
1776 |
|
|
1777 |
item = gtk_menu_item_new_with_label( _("Garmin GPX...") ); |
item = gtk_menu_item_new_with_label( _("Garmin GPX") ); |
1778 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1779 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
1780 |
GTK_SIGNAL_FUNC(cb_menu_export_garmin), appdata); |
GTK_SIGNAL_FUNC(cb_menu_export_garmin), appdata); |
1781 |
|
|
1782 |
#ifdef USE_MAEMO |
#ifdef USE_BREAD_CRUMB_TRAIL |
1783 |
appdata->menu_search = |
appdata->menu_search = |
1784 |
#endif |
#endif |
1785 |
item = gtk_menu_item_new_with_label( _("Search...") ); |
item = gtk_menu_item_new_with_label( _("Search") ); |
1786 |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
1787 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_search), appdata); |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_search), appdata); |
1788 |
|
|
1812 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_paste), appdata); |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_paste), appdata); |
1813 |
#endif |
#endif |
1814 |
|
|
1815 |
item = gtk_menu_item_new_with_label( _("Settings...") ); |
item = gtk_menu_item_new_with_label( _("Settings") ); |
1816 |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
1817 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_settings), |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_settings), |
1818 |
appdata); |
appdata); |
1824 |
submenu = gtk_menu_new(); |
submenu = gtk_menu_new(); |
1825 |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); |
1826 |
|
|
1827 |
item = gtk_menu_item_new_with_label( _("Geomath...") ); |
#ifdef ENABLE_OSM_GPS_MAP |
1828 |
|
item = gtk_menu_item_new_with_label( _("Map") ); |
1829 |
|
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1830 |
|
g_signal_connect(item, "activate", |
1831 |
|
GTK_SIGNAL_FUNC(cb_menu_map), appdata); |
1832 |
|
#endif |
1833 |
|
|
1834 |
|
item = gtk_menu_item_new_with_label( _("Geomath") ); |
1835 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1836 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
1837 |
GTK_SIGNAL_FUNC(cb_menu_geomath), appdata); |
GTK_SIGNAL_FUNC(cb_menu_geomath), appdata); |
1838 |
|
|
1839 |
item = gtk_menu_item_new_with_label( _("Geotext...") ); |
item = gtk_menu_item_new_with_label( _("Geotext") ); |
1840 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1841 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
1842 |
GTK_SIGNAL_FUNC(cb_menu_geotext), appdata); |
GTK_SIGNAL_FUNC(cb_menu_geotext), appdata); |
1843 |
|
|
1844 |
item = gtk_menu_item_new_with_label( _("Precise Position...") ); |
item = gtk_menu_item_new_with_label( _("Precise Position") ); |
1845 |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
gtk_menu_append(GTK_MENU_SHELL(submenu), item); |
1846 |
g_signal_connect(item, "activate", |
g_signal_connect(item, "activate", |
1847 |
GTK_SIGNAL_FUNC(cb_menu_precpos), appdata); |
GTK_SIGNAL_FUNC(cb_menu_precpos), appdata); |
1849 |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
gtk_menu_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); |
1850 |
|
|
1851 |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
#if defined(USE_MAEMO) && defined(HILDON_HELP) |
1852 |
item = gtk_menu_item_new_with_label( _("Help...") ); |
item = gtk_menu_item_new_with_label( _("Help") ); |
1853 |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
1854 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_help), appdata); |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_help), appdata); |
1855 |
#endif |
#endif |
1856 |
|
|
1857 |
item = gtk_menu_item_new_with_label( _("About...") ); |
item = gtk_menu_item_new_with_label( _("About") ); |
1858 |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
gtk_menu_append(GTK_MENU_SHELL(menu), item); |
1859 |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_about), appdata); |
g_signal_connect(item, "activate", GTK_SIGNAL_FUNC(cb_menu_about), appdata); |
1860 |
|
|
1880 |
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); |
1881 |
#endif |
#endif |
1882 |
} |
} |
1883 |
|
#endif |
1884 |
|
|
1885 |
/********************* end of menu **********************/ |
/********************* end of menu **********************/ |
1886 |
|
|
1890 |
if(appdata->image_path) free(appdata->image_path); |
if(appdata->image_path) free(appdata->image_path); |
1891 |
if(appdata->search_str) free(appdata->search_str); |
if(appdata->search_str) free(appdata->search_str); |
1892 |
|
|
1893 |
|
#ifdef USE_STACKABLE_WINDOW |
1894 |
|
if(appdata->export_menu) submenu_cleanup(appdata->export_menu); |
1895 |
|
if(appdata->tools_menu) submenu_cleanup(appdata->tools_menu); |
1896 |
|
#endif |
1897 |
|
|
1898 |
gnome_vfs_shutdown(); |
gnome_vfs_shutdown(); |
1899 |
icons_free(); |
icons_free(); |
1900 |
gps_release(appdata); |
gps_release(appdata); |
1923 |
puts("everything is gone"); |
puts("everything is gone"); |
1924 |
} |
} |
1925 |
|
|
1926 |
void on_window_destroy (GtkWidget *widget, gpointer data) { |
static void on_window_destroy (GtkWidget *widget, gpointer data) { |
1927 |
appdata_t *appdata = (appdata_t*)data; |
appdata_t *appdata = (appdata_t*)data; |
1928 |
|
|
1929 |
gconf_save_state(appdata); |
gconf_save_state(appdata); |
1932 |
} |
} |
1933 |
|
|
1934 |
gboolean on_window_key_press(GtkWidget *widget, |
gboolean on_window_key_press(GtkWidget *widget, |
1935 |
GdkEventKey *event, gpointer data) { |
GdkEventKey *event, appdata_t *appdata) { |
|
appdata_t *appdata = (appdata_t*)data; |
|
1936 |
int handled = FALSE; |
int handled = FALSE; |
1937 |
|
|
1938 |
// printf("key event %d\n", event->keyval); |
// printf("key event %d\n", event->keyval); |
1940 |
switch(event->keyval) { |
switch(event->keyval) { |
1941 |
#ifdef USE_MAEMO |
#ifdef USE_MAEMO |
1942 |
|
|
|
#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 |
|
|
|
|
1943 |
#ifdef HILDON_HARDKEY_INCREASE |
#ifdef HILDON_HARDKEY_INCREASE |
1944 |
case HILDON_HARDKEY_INCREASE: |
case HILDON_HARDKEY_INCREASE: |
1945 |
html_zoom(appdata, TRUE); |
html_zoom(appdata, TRUE); |
2124 |
#endif // USE_BREAD_CRUMB_TRAIL |
#endif // USE_BREAD_CRUMB_TRAIL |
2125 |
|
|
2126 |
void main_after_settings_redraw(appdata_t *appdata, int flags) { |
void main_after_settings_redraw(appdata_t *appdata, int flags) { |
2127 |
|
printf("main after settings redraw\n"); |
2128 |
|
|
2129 |
|
if(!appdata->cur_view) { |
2130 |
|
printf("no active view\n"); |
2131 |
|
return; |
2132 |
|
} |
2133 |
|
|
2134 |
#ifndef USE_MAEMO |
#ifndef USE_MAEMO |
2135 |
// in non-maemo setup this can only affect the main screen as |
// in non-maemo setup this can only affect the main screen as |
2136 |
// the menu is blocked while a dialog is open. also the main |
// the menu is blocked while a dialog is open. also the main |
2166 |
} |
} |
2167 |
|
|
2168 |
if(redraw) { |
if(redraw) { |
2169 |
gtk_container_remove(GTK_CONTAINER(appdata->vbox), appdata->cur_view); |
GtkWidget *container = appdata->vbox; |
2170 |
|
|
2171 |
|
#ifdef USE_STACKABLE_WINDOW |
2172 |
|
HildonWindowStack *stack = hildon_window_stack_get_default(); |
2173 |
|
container = hildon_window_stack_peek(stack); |
2174 |
|
#endif |
2175 |
|
|
2176 |
|
gtk_container_remove(GTK_CONTAINER(container), appdata->cur_view); |
2177 |
switch(redraw) { |
switch(redraw) { |
2178 |
case 1: |
case 1: |
2179 |
appdata->cur_view = cachelist_create(appdata, |
appdata->cur_view = cachelist_create(appdata, |
2188 |
break; |
break; |
2189 |
} |
} |
2190 |
|
|
2191 |
gtk_box_pack_start_defaults(GTK_BOX(appdata->vbox), appdata->cur_view); |
#ifdef USE_STACKABLE_WINDOW |
2192 |
gtk_widget_show_all(appdata->vbox); |
if(container != appdata->vbox) |
2193 |
} |
gtk_container_add(GTK_CONTAINER(container), appdata->cur_view); |
2194 |
|
else |
2195 |
#endif |
#endif |
2196 |
|
gtk_box_pack_start_defaults(GTK_BOX(container), appdata->cur_view); |
2197 |
|
|
2198 |
|
gtk_widget_show_all(container); |
2199 |
|
} |
2200 |
|
#endif // USE_MAEMO |
2201 |
} |
} |
2202 |
|
|
2203 |
int main(int argc, char *argv[]) { |
int main(int argc, char *argv[]) { |
2254 |
gtk_window_set_default_size(GTK_WINDOW(appdata.window), 500, 300); |
gtk_window_set_default_size(GTK_WINDOW(appdata.window), 500, 300); |
2255 |
#endif |
#endif |
2256 |
|
|
2257 |
|
#if MAEMO_VERSION_MAJOR == 5 |
2258 |
gtk_window_set_title(GTK_WINDOW(appdata.window), "GPXView"); |
gtk_window_set_title(GTK_WINDOW(appdata.window), "GPXView"); |
2259 |
|
#endif |
2260 |
|
|
2261 |
g_signal_connect(G_OBJECT(appdata.window), "destroy", |
g_signal_connect(G_OBJECT(appdata.window), "destroy", |
2262 |
G_CALLBACK(on_window_destroy), &appdata); |
G_CALLBACK(on_window_destroy), &appdata); |
2263 |
|
|
2266 |
|
|
2267 |
appdata.vbox = gtk_vbox_new(FALSE, 2); |
appdata.vbox = gtk_vbox_new(FALSE, 2); |
2268 |
gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox); |
gtk_container_add(GTK_CONTAINER(appdata.window), appdata.vbox); |
2269 |
|
#ifndef USE_STACKABLE_WINDOW |
2270 |
menu_create(&appdata); |
menu_create(&appdata); |
2271 |
|
#else |
2272 |
|
hildon_window_set_app_menu(HILDON_WINDOW(appdata.window), |
2273 |
|
menu_create(&appdata, MENU_GPXLIST)); |
2274 |
|
#endif |
2275 |
|
|
2276 |
#ifdef USE_BREAD_CRUMB_TRAIL |
#ifdef USE_BREAD_CRUMB_TRAIL |
2277 |
appdata.bct = hildon_bread_crumb_trail_new(); |
appdata.bct = hildon_bread_crumb_trail_new(); |