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); |
593 |
g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view); |
g_object_set_data(G_OBJECT(window), "cur_view", appdata->cur_view); |
594 |
|
|
595 |
appdata->cur_gpx = gpx; |
appdata->cur_gpx = gpx; |
596 |
char *title = g_strdup_printf("GPXView - %s", gpx->name); |
char *title = g_strdup_printf("%s - GPXView", gpx->name); |
597 |
gtk_window_set_title(GTK_WINDOW(window), title); |
gtk_window_set_title(GTK_WINDOW(window), title); |
598 |
g_free(title); |
g_free(title); |
599 |
|
|
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); |
1047 |
char *str = g_strdup_printf("%s\n\n(%s)", |
char *str = g_strdup_printf("%s\n\n(%s)", |
1048 |
_("GPXView (c) 2008-2009 by\n" |
_("GPXView (c) 2008-2009 by\n" |
1049 |
"Till Harbaum <till@harbaum.org>\n" |
"Till Harbaum <till@harbaum.org>\n" |
1050 |
"Mailing list: gpxview-users@garage.maemo.org" |
"Mailing list: gpxview-users@garage.maemo.org"), |
1051 |
_(uses) |
_(uses) |
1052 |
); |
); |
1053 |
|
|
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 |
static void |
1532 |
cb_menu_geomath(GtkWidget *window, gpointer data) { |
cb_menu_geomath(GtkWidget *window, gpointer data) { |
1533 |
geomath_dialog((appdata_t *)data); |
geomath_dialog((appdata_t *)data); |
1544 |
} |
} |
1545 |
|
|
1546 |
#ifdef USE_STACKABLE_WINDOW |
#ifdef USE_STACKABLE_WINDOW |
1547 |
static void on_export_destroy(GtkWidget *widget, appdata_t *appdata) { |
typedef struct { |
1548 |
appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view"); |
char *label, *desc; |
1549 |
} |
GtkSignalFunc activate_cb; |
1550 |
|
} menu_entry_t; |
1551 |
|
|
1552 |
void on_export_clicked(GtkButton *button, appdata_t *appdata) { |
typedef struct { |
1553 |
HildonStackableWindow *view_window; |
const char *title; |
1554 |
GtkWidget *but; |
const menu_entry_t *menu; |
1555 |
|
int len; |
1556 |
|
} submenu_t; |
1557 |
|
|
1558 |
view_window = HILDON_STACKABLE_WINDOW (hildon_stackable_window_new ()); |
#define COLUMNS 1 |
|
gtk_window_set_title (GTK_WINDOW (view_window), "GPXView - Export"); |
|
1559 |
|
|
1560 |
/* store last "cur_view" in window */ |
void on_submenu_entry_clicked(GtkButton *button, GtkWidget *menu) { |
|
g_object_set_data(G_OBJECT(view_window), "cur_view", appdata->cur_view); |
|
|
appdata->cur_view = NULL; |
|
1561 |
|
|
1562 |
g_signal_connect(G_OBJECT(view_window), "destroy", |
/* force closing of submenu dialog */ |
1563 |
G_CALLBACK(on_export_destroy), appdata); |
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 |
GtkVBox *contents = GTK_VBOX(gtk_vbox_new (12, FALSE)); |
static GtkWidget *app_submenu_create(appdata_t *appdata, |
1572 |
|
const submenu_t *submenu) { |
1573 |
|
|
1574 |
but = hildon_button_new_with_text( |
/* create a oridinary dialog box */ |
1575 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
GtkWidget *dialog = gtk_dialog_new(); |
1576 |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
gtk_window_set_title(GTK_WINDOW(dialog), _(submenu->title)); |
1577 |
_("Export to Maemo Mapper"), |
gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); |
1578 |
_("Save a Maemo Mapper POI file")); |
gtk_window_set_transient_for(GTK_WINDOW(dialog), |
1579 |
g_signal_connect(but, "clicked", |
GTK_WINDOW(appdata->window)); |
1580 |
G_CALLBACK(cb_menu_export_mmpoi), appdata); |
gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); |
|
gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0); |
|
1581 |
|
|
1582 |
|
GtkWidget *table = gtk_table_new(submenu->len/COLUMNS, COLUMNS, TRUE); |
1583 |
|
int x = 0, y = 0; |
1584 |
|
|
1585 |
but = hildon_button_new_with_text( |
const menu_entry_t *menu_entries = submenu->menu; |
1586 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
while(menu_entries->label) { |
1587 |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
GtkWidget *button = NULL; |
|
_("Export Field Notes"), |
|
|
_("Save a Garmin Field Notes file")); |
|
|
g_signal_connect(but, "clicked", |
|
|
G_CALLBACK(cb_menu_export_log), appdata); |
|
|
gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0); |
|
|
|
|
1588 |
|
|
1589 |
but = hildon_button_new_with_text( |
button = hildon_button_new_with_text( |
1590 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
1591 |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
1592 |
_("Export Garmin GPX"), |
_(menu_entries->label), _(menu_entries->desc)); |
|
_("Save a GPX file containing modified waypoints")); |
|
|
g_signal_connect(but, "clicked", |
|
|
G_CALLBACK(cb_menu_export_garmin), appdata); |
|
|
gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0); |
|
1593 |
|
|
1594 |
gtk_container_add (GTK_CONTAINER (view_window), GTK_WIDGET (contents)); |
/* try to center both texts */ |
1595 |
gtk_widget_show_all (GTK_WIDGET (view_window)); |
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 |
static void on_tools_destroy(GtkWidget *widget, appdata_t *appdata) { |
g_signal_connect(button, "clicked", |
1599 |
appdata->cur_view = g_object_get_data(G_OBJECT(widget), "cur_view"); |
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 |
void on_tools_clicked(GtkButton *button, appdata_t *appdata) { |
menu_entries++; |
1610 |
HildonStackableWindow *view_window; |
} |
|
GtkWidget *but; |
|
1611 |
|
|
1612 |
view_window = HILDON_STACKABLE_WINDOW (hildon_stackable_window_new ()); |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(dialog)->vbox), table); |
|
gtk_window_set_title (GTK_WINDOW (view_window), "GPXView - Tools"); |
|
1613 |
|
|
1614 |
/* store last "cur_view" in window */ |
return dialog; |
1615 |
g_object_set_data(G_OBJECT(view_window), "cur_view", appdata->cur_view); |
} |
|
appdata->cur_view = NULL; |
|
1616 |
|
|
1617 |
g_signal_connect(G_OBJECT(view_window), "destroy", |
/* popup the dialog shaped submenu */ |
1618 |
G_CALLBACK(on_tools_destroy), appdata); |
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 |
GtkVBox *contents = GTK_VBOX(gtk_vbox_new (12, FALSE)); |
static void submenu_cleanup(GtkWidget *menu) { |
1625 |
|
gtk_widget_destroy(menu); |
1626 |
|
} |
1627 |
|
|
1628 |
but = hildon_button_new_with_text( |
static const menu_entry_t submenu_export_entries[] = { |
1629 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
{ "Export to Maemo Mapper" , "Save a Maemo Mapper POI file", |
1630 |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
G_CALLBACK(cb_menu_export_mmpoi) }, |
1631 |
_("Geomath"), |
{ "Export Field Notes", "Save a Garmin Field Notes file", |
1632 |
_("Geocoordinate calculation")); |
G_CALLBACK(cb_menu_export_log) }, |
1633 |
g_signal_connect(but, "clicked", |
{ "Export Garmin GPX", "Save modified waypoints in GPX file", |
1634 |
G_CALLBACK(cb_menu_geomath), appdata); |
G_CALLBACK(cb_menu_export_garmin) }, |
1635 |
gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0); |
{ 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 |
but = hildon_button_new_with_text( |
/* the export submenu */ |
1644 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
void on_export_clicked(GtkButton *button, appdata_t *appdata) { |
1645 |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
if(!appdata->export_menu) |
1646 |
_("Geotext"), |
appdata->export_menu = app_submenu_create(appdata, &submenu_export); |
|
_("Text analysis, letter counting etc")); |
|
|
g_signal_connect(but, "clicked", |
|
|
G_CALLBACK(cb_menu_geotext), appdata); |
|
|
gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0); |
|
|
|
|
1647 |
|
|
1648 |
but = hildon_button_new_with_text( |
submenu_popup(appdata->export_menu); |
1649 |
HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH, |
} |
1650 |
HILDON_BUTTON_ARRANGEMENT_VERTICAL, |
|
1651 |
_("Precise Position"), |
static const menu_entry_t submenu_tools_entries[] = { |
1652 |
_("Calculate a very precise GPS position")); |
{ "Geomath", "Geocoordinate calculation", |
1653 |
g_signal_connect(but, "clicked", |
G_CALLBACK(cb_menu_geomath) }, |
1654 |
G_CALLBACK(cb_menu_precpos), appdata); |
{ "Geotext", "Text analysis", |
1655 |
gtk_box_pack_start(GTK_BOX(contents), but, FALSE, FALSE, 0); |
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 |
gtk_container_add (GTK_CONTAINER (view_window), GTK_WIDGET (contents)); |
submenu_popup(appdata->tools_menu); |
|
gtk_widget_show_all (GTK_WIDGET (view_window)); |
|
1672 |
} |
} |
1673 |
|
|
1674 |
HildonAppMenu *menu_create(appdata_t *appdata, int mode) { |
HildonAppMenu *menu_create(appdata_t *appdata, int mode) { |
1696 |
g_signal_connect_after(button, "clicked", |
g_signal_connect_after(button, "clicked", |
1697 |
G_CALLBACK(cb_menu_adddir), appdata); |
G_CALLBACK(cb_menu_adddir), appdata); |
1698 |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
|
} |
|
1699 |
|
|
|
if(mode == MENU_GPXLIST) { |
|
1700 |
button = gtk_button_new_with_label(_("Export")); |
button = gtk_button_new_with_label(_("Export")); |
1701 |
g_signal_connect_after(button, "clicked", |
g_signal_connect_after(button, "clicked", |
1702 |
G_CALLBACK(on_export_clicked), appdata); |
G_CALLBACK(on_export_clicked), appdata); |
1713 |
G_CALLBACK(on_tools_clicked), appdata); |
G_CALLBACK(on_tools_clicked), appdata); |
1714 |
hildon_app_menu_append(menu, GTK_BUTTON(button)); |
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 |
#ifdef HILDON_HELP |
1726 |
button = gtk_button_new_with_label(_("Help")); |
button = gtk_button_new_with_label(_("Help")); |
1727 |
g_signal_connect_after(button, "clicked", |
g_signal_connect_after(button, "clicked", |
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 |
|
#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") ); |
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", |
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); |
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 |
#ifndef USE_STACKABLE_WINDOW |
2285 |
menu_create(&appdata); |
menu_create(&appdata); |
2286 |
#else |
#else |