13 #include <glib/gstdio.h>
19 #include "hildon-mapper.h"
29 #include "mapper-types.h"
31 #include "ui-common.h"
36 #include "gps-panels.h"
41 menu_cb_route_download(GtkAction * action)
46 store=route_generate_store();
48 gtk_tree_view_set_model(route_tree_view, store);
49 g_object_unref(G_OBJECT(store));
55 menu_cb_route_open(GtkAction * action)
60 store=route_generate_store();
62 gtk_tree_view_set_model(route_tree_view, store);
63 g_object_unref(G_OBJECT(store));
69 menu_cb_route_distnext(GtkAction * action)
71 route_show_distance_to_next();
76 menu_cb_route_distlast(GtkAction * action)
78 route_show_distance_to_last();
83 menu_cb_route_reset(GtkAction * action)
85 route_find_nearest_point();
87 MACRO_QUEUE_DRAW_AREA();
92 menu_cb_route_clear(GtkAction * action)
95 gtk_tree_view_set_model(route_tree_view, NULL);
100 menu_cb_track_open(GtkAction * action)
107 menu_cb_track_save(GtkAction * action)
114 menu_cb_track_insert_break(GtkAction * action)
116 track_insert_break();
121 menu_cb_track_insert_mark(GtkAction * action)
128 menu_cb_track_distlast(GtkAction * action)
130 track_show_distance_from_last();
135 menu_cb_track_distfirst(GtkAction * action)
137 track_show_distance_from_first();
142 menu_cb_route_save(GtkAction * action)
149 menu_cb_track_clear(GtkAction * action)
156 menu_cb_track_filter(GtkAction * action)
163 menu_cb_show_tracks(GtkAction *action)
165 _show_tracks ^= TRACKS_MASK;
166 if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action))) {
167 _show_tracks |= TRACKS_MASK;
169 MACRO_QUEUE_DRAW_AREA();
170 MACRO_BANNER_SHOW_INFO(_window, _("Tracks are now shown"));
172 _show_tracks &= ~TRACKS_MASK;
174 MACRO_BANNER_SHOW_INFO(_window, _("Tracks are now hidden"));
180 menu_cb_show_scale(GtkAction * action)
182 _show_scale = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action));
183 MACRO_QUEUE_DRAW_AREA();
188 menu_cb_show_routes(GtkAction * action)
190 if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action))) {
191 _show_tracks |= ROUTES_MASK;
193 MACRO_QUEUE_DRAW_AREA();
194 MACRO_BANNER_SHOW_INFO(_window, _("Routes are now shown"));
196 _show_tracks &= ~ROUTES_MASK;
198 MACRO_BANNER_SHOW_INFO(_window, _("Routes are now hidden"));
204 menu_cb_show_velvec(GtkAction * action)
206 _show_velvec = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action));
212 menu_cb_show_poi(GtkAction * action)
214 _show_poi = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action));
220 menu_cb_gps_show_info(GtkAction * action)
222 _gps_info = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action));
228 menu_cb_autocenter(GtkAction *action, GtkRadioAction *current)
230 guint new_center_unitx, new_center_unity;
231 gint value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (current));
235 _center_mode = CENTER_LEAD;
236 MACRO_BANNER_SHOW_INFO(_window, _("Auto-Center Mode: Lead"));
239 _center_mode = CENTER_LATLON;
240 MACRO_BANNER_SHOW_INFO(_window, _("Auto-Center Mode: Lat/Lon"));
244 _center_mode = -_center_mode;
245 MACRO_BANNER_SHOW_INFO(_window, _("Auto-Center Off"));
250 MACRO_RECALC_CENTER(new_center_unitx, new_center_unity);
251 map_center_unit(new_center_unitx, new_center_unity);
256 menu_cb_goto_latlon(GtkAction * action)
264 dialog = gtk_dialog_new_with_buttons(_("Go to Lat/Lon"),
266 GTK_DIALOG_MODAL, GTK_STOCK_OK,
269 GTK_RESPONSE_REJECT, NULL);
271 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), table = gtk_table_new(2, 3, FALSE), TRUE, TRUE, 0);
273 gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Latitude")),0, 1, 0, 1, GTK_FILL, 0, 2, 4);
274 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
276 gtk_table_attach(GTK_TABLE(table), txt_lat = gtk_entry_new(), 1, 2, 0, 1, GTK_FILL, 0, 2, 4);
277 gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
279 gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Longitude")), 0, 1, 1, 2, GTK_FILL, 0, 2, 4);
280 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
282 gtk_table_attach(GTK_TABLE(table), txt_lon = gtk_entry_new(), 1, 2, 1, 2, GTK_FILL, 0, 2, 4);
283 gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
285 #if defined (WITH_DEVICE_770) && !defined(WITH_HILDON_NEW)
286 g_object_set(G_OBJECT(txt_lat), HILDON_INPUT_MODE_HINT, HILDON_INPUT_MODE_HINT_NUMERICSPECIAL, NULL);
287 g_object_set(G_OBJECT(txt_lon), HILDON_INPUT_MODE_HINT, HILDON_INPUT_MODE_HINT_NUMERICSPECIAL, NULL);
290 /* Initialize with the current center position. */
294 unit2latlon(_center.unitx, _center.unity, lat, lon);
295 snprintf(buffer, sizeof(buffer), "%.06f", lat);
296 gtk_label_set_text(GTK_LABEL(txt_lat), buffer);
297 snprintf(buffer, sizeof(buffer), "%.06f", lon);
298 gtk_label_set_text(GTK_LABEL(txt_lon), buffer);
301 gtk_widget_show_all(dialog);
303 while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
309 text = gtk_entry_get_text(GTK_ENTRY(txt_lat));
310 lat = strtof(text, &error_check);
311 if (text == error_check || lat < -90.f || lat > 90.f) {
312 popup_error(dialog, _("Invalid Latitude"));
316 text = gtk_entry_get_text(GTK_ENTRY(txt_lon));
317 lon = strtof(text, &error_check);
318 if (text == error_check || lon < -180.f || lon > 180.f) {
319 popup_error(dialog, _("Invalid Longitude"));
323 latlon2unit(lat, lon, unitx, unity);
324 if (_center_mode > 0)
325 set_action_activate("autocenter_none", TRUE);
327 map_center_unit(unitx, unity);
330 gtk_widget_destroy(dialog);
335 menu_cb_goto_home(GtkAction *action)
337 if (map_goto_position(&_home)==FALSE) {
338 MACRO_BANNER_SHOW_INFO(_window, _("Home not set."));
340 MACRO_BANNER_SHOW_INFO(_window, _("At home location"));
346 menu_cb_goto_destination(GtkAction *action)
348 if (map_goto_position(&_dest)==FALSE) {
349 MACRO_BANNER_SHOW_INFO(_window, _("Destination not set."));
351 MACRO_BANNER_SHOW_INFO(_window, _("At destination"));
357 menu_cb_goto_gps(GtkAction *action)
359 _center_mode = CENTER_LATLON;
360 map_center_unit(_pos.unitx, _pos.unity);
361 map_update_location_from_center();
367 menu_cb_goto_nextway(GtkAction * action)
369 if (_next_way && _next_way->point->unity) {
370 if (_center_mode > 0)
371 set_action_activate("autocenter_none", TRUE);
373 map_center_unit(_next_way->point->unitx, _next_way->point->unity);
375 MACRO_BANNER_SHOW_INFO(_window, _("There is no next waypoint."));
382 menu_cb_goto_nearpoi(GtkAction * action)
387 if (_center_mode > 0) {
388 /* Auto-Center is enabled - use the GPS position. */
389 unit2latlon(_pos.unitx, _pos.unity, lat, lon);
391 /* Auto-Center is disabled - use the view center. */
392 unit2latlon(_center.unitx, _center.unity, lat, lon);
395 p=poi_find_nearest(lat, lon);
401 latlon2unit(p->lat, p->lon, unitx, unity);
402 banner = g_strdup_printf("%s (%s)", p->label, p->cat_label);
403 g_printf("%s\n", banner);
404 MACRO_BANNER_SHOW_INFO(_window, banner);
408 if (_center_mode > 0)
409 set_action_activate("autocenter_none", TRUE);
411 map_center_unit(unitx, unity);
412 map_update_location_from_center();
414 MACRO_BANNER_SHOW_INFO(_window, _("No POIs found."));
421 menu_cb_maps_repoman(GtkAction * action)
428 menu_cb_maps_select(GtkAction * action, gpointer new_repo)
430 repo_set_curr(new_repo);
436 cb_zoom_auto(GtkAction * action)
438 map_set_autozoom(TRUE);
443 cb_zoom_base(GtkAction * action)
445 map_set_autozoom(FALSE);
451 cb_zoomin(GtkAction * action)
453 map_set_autozoom(FALSE);
459 cb_zoomout(GtkAction * action)
461 map_set_autozoom(FALSE);
467 cb_fullscreen(GtkAction * action)
469 if ((_fullscreen = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)))) {
470 gtk_window_fullscreen(GTK_WINDOW(_window));
472 gtk_window_unfullscreen(GTK_WINDOW(_window));
474 gtk_idle_add((GSourceFunc) window_present, NULL);
479 menu_cb_enable_gps(GtkAction * action)
481 if ((_enable_gps = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)))) {
483 gps_conn_set_state(RCVR_DOWN);
486 popup_error(_window, _("Cannot enable GPS until a GPS Receiver MAC is set in the Settings dialog box."));
487 set_action_activate("gps_enable", FALSE);
490 if (_conn_state > RCVR_OFF)
491 gps_conn_set_state(RCVR_OFF);
496 set_action_sensitive("gps_details", _enable_gps);
497 set_action_sensitive("goto_gps", _enable_gps);
498 set_action_sensitive("autocenter_latlon", _enable_gps);
499 set_action_sensitive("autocenter_lead", _enable_gps);
508 menu_cb_auto_download(GtkAction * action)
510 if ((_auto_download = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)) )) {
511 if (_curr_repo->url == REPOTYPE_NONE)
512 popup_error(_window, _("NOTE: You must set a Map URI in the current repository in order to download maps."));
520 menu_cb_gps_details(GtkAction * action)
527 menu_cb_settings(GtkAction * action)
529 if (settings_dialog()) {
530 /* Settings have changed - reconnect to receiver. */
532 gps_conn_set_state(RCVR_DOWN);
537 MACRO_RECALC_FOCUS_BASE();
538 MACRO_RECALC_FOCUS_SIZE();
544 menu_cb_help(GtkAction * action)
546 help_topic_display(HELP_ID_INTRO, 0);
551 menu_cb_about(GtkAction * action)
556 "Cezary Jackiewicz", NULL
559 gtk_show_about_dialog(GTK_WINDOW(_window),
562 "copyright", "Kaj-Michael Lang",
570 window_cb_key_press(GtkWidget * widget, GdkEventKey * event)
572 CustomKey custom_key;
574 switch (event->keyval) {
575 case HILDON_HARDKEY_UP:
576 custom_key = CUSTOM_KEY_UP;
578 case HILDON_HARDKEY_DOWN:
579 custom_key = CUSTOM_KEY_DOWN;
581 case HILDON_HARDKEY_LEFT:
582 custom_key = CUSTOM_KEY_LEFT;
584 case HILDON_HARDKEY_RIGHT:
585 custom_key = CUSTOM_KEY_RIGHT;
587 case HILDON_HARDKEY_SELECT:
588 custom_key = CUSTOM_KEY_SELECT;
590 case HILDON_HARDKEY_INCREASE:
591 custom_key = CUSTOM_KEY_INCREASE;
593 case HILDON_HARDKEY_DECREASE:
594 custom_key = CUSTOM_KEY_DECREASE;
596 case HILDON_HARDKEY_FULLSCREEN:
597 custom_key = CUSTOM_KEY_FULLSCREEN;
599 case HILDON_HARDKEY_ESC:
600 custom_key = CUSTOM_KEY_ESC;
606 switch (_action[custom_key]) {
607 case CUSTOM_ACTION_PAN_NORTH:
608 map_pan(0, -PAN_UNITS);
610 case CUSTOM_ACTION_PAN_WEST:
611 map_pan(-PAN_UNITS, 0);
613 case CUSTOM_ACTION_PAN_SOUTH:
614 map_pan(0, PAN_UNITS);
616 case CUSTOM_ACTION_PAN_EAST:
617 map_pan(PAN_UNITS, 0);
619 case CUSTOM_ACTION_TOGGLE_AUTOCENTER:
620 switch (_center_mode) {
622 case CENTER_WAS_LEAD:
623 set_action_activate("autocenter_lead", TRUE);
626 case CENTER_WAS_LATLON:
627 set_action_activate("autocenter_latlon", TRUE);
630 set_action_activate("autocenter_latlon", TRUE);
634 case CUSTOM_ACTION_ZOOM_IN:
635 case CUSTOM_ACTION_ZOOM_OUT:
636 if (!_key_zoom_timeout_sid) {
637 g_printf("Z: %d %d\n", _key_zoom_new, _zoom);
638 _key_zoom_new = _zoom + (_action[custom_key] == CUSTOM_ACTION_ZOOM_IN
639 ? -_curr_repo->view_zoom_steps : _curr_repo->view_zoom_steps);
640 /* Remember, _key_zoom_new is unsigned. */
641 if (_key_zoom_new < MAX_ZOOM) {
643 snprintf(buffer, sizeof(buffer), "%s %d", _("Zoom to Level"), _key_zoom_new);
644 MACRO_BANNER_SHOW_INFO(_window, buffer);
645 _key_zoom_timeout_sid = g_timeout_add(400, map_key_zoom_timeout, NULL);
649 case CUSTOM_ACTION_TOGGLE_FULLSCREEN:
650 set_action_activate("view_fullscreen", !_fullscreen);
652 case CUSTOM_ACTION_TOGGLE_TRACKS:
653 switch (_show_tracks) {
655 /* Nothing shown, nothing saved; just set both. */
656 _show_tracks = TRACKS_MASK | ROUTES_MASK;
658 case TRACKS_MASK << 16:
659 case ROUTES_MASK << 16:
660 case (ROUTES_MASK | TRACKS_MASK) << 16:
661 /* Something was saved and nothing changed since.
663 _show_tracks = _show_tracks >> 16;
666 /* There is no history, or they changed something
667 * since the last historical change. Save and
669 _show_tracks = _show_tracks << 16;
671 set_action_activate("view_route", _show_tracks & ROUTES_MASK);
672 set_action_activate("view_track", _show_tracks & TRACKS_MASK);
674 case CUSTOM_ACTION_TOGGLE_SCALE:
675 set_action_activate("view_scale", _show_scale);
677 case CUSTOM_ACTION_TOGGLE_POI:
678 set_action_activate("view_poi", _show_poi);
680 case CUSTOM_ACTION_CHANGE_REPO: {
681 GList *curr = g_list_find(_repo_list, _curr_repo);
685 /* Loop until we reach a next-able repo, or until we get
686 * back to the current repo. */
687 while ((curr = (curr->next ? curr->next : _repo_list)) && !((RepoData *) curr->data)->nextable && curr->data != _curr_repo) {
690 if (curr->data != _curr_repo) {
691 repo_set_curr(curr->data);
692 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_curr_repo->menu_item), TRUE);
694 popup_error(_window, _("There are no other next-able repositories."));
699 case CUSTOM_ACTION_ROUTE_DISTNEXT:
700 route_show_distance_to_next();
702 case CUSTOM_ACTION_ROUTE_DISTLAST:
703 route_show_distance_to_last();
705 case CUSTOM_ACTION_TRACK_BREAK:
706 track_insert_break();
708 case CUSTOM_ACTION_TRACK_DISTLAST:
709 track_show_distance_from_last();
711 case CUSTOM_ACTION_TRACK_DISTFIRST:
712 track_show_distance_from_first();
714 case CUSTOM_ACTION_TOGGLE_GPS:
715 set_action_activate("gps_enable", !_enable_gps);
717 case CUSTOM_ACTION_TOGGLE_GPSINFO:
718 set_action_activate("gps_info", !_gps_info);
720 case CUSTOM_ACTION_TOGGLE_SPEEDLIMIT:
721 _speed_limit_on ^= 1;
730 window_cb_key_release(GtkWidget * widget, GdkEventKey * event)
732 switch (event->keyval) {
733 case HILDON_HARDKEY_INCREASE:
734 case HILDON_HARDKEY_DECREASE:
735 if (_key_zoom_timeout_sid) {
736 g_source_remove(_key_zoom_timeout_sid);
737 _key_zoom_timeout_sid = 0;
738 map_set_zoom(_key_zoom_new);
748 cmenu_show_latlon(guint unitx, guint unity)
751 gchar buffer[80], tmp1[16], tmp2[16];
753 unit2latlon(unitx, unity, lat, lon);
754 lat_format(lat, tmp1);
755 lon_format(lon, tmp2);
757 snprintf(buffer, sizeof(buffer),
759 "%s: %s", _("Latitude"), tmp1, _("Longitude"), tmp2);
761 MACRO_BANNER_SHOW_INFO(_window, buffer);
765 cmenu_clip_latlon(guint unitx, guint unity)
770 unit2latlon(unitx, unity, lat, lon);
771 snprintf(buffer, sizeof(buffer), "%.06f,%.06f", lat, lon);
773 gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), buffer, -1);
777 cmenu_route_to(guint unitx, guint unity)
784 unit2latlon(unitx, unity, lat, lon);
786 g_ascii_formatd(strlat, 32, "%.06f", lat);
787 g_ascii_formatd(strlon, 32, "%.06f", lon);
788 snprintf(buffer, sizeof(buffer), "%s, %s", strlat, strlon);
790 route_download(buffer);
794 cmenu_distance_to(guint unitx, guint unity)
799 unit2latlon(unitx, unity, lat, lon);
801 snprintf(buffer, sizeof(buffer), "%s: %.02lf %s", _("Distance"),
802 calculate_distance(_gps.lat, _gps.lon, lat, lon) * UNITS_CONVERT[_units], UNITS_TEXT[_units]);
803 MACRO_BANNER_SHOW_INFO(_window, buffer);
807 cmenu_add_route(guint unitx, guint unity)
809 MACRO_PATH_INCREMENT_TAIL(_route);
810 _route.tail->unitx = x2unit(_cmenu_position_x);
811 _route.tail->unity = y2unit(_cmenu_position_y);
812 route_find_nearest_point();
816 void cmenu_route_add_way(guint unitx, guint unity)
819 gchar tmp1[16], tmp2[16], *p_latlon;
823 GtkWidget *txt_scroll;
826 dialog = gtk_dialog_new_with_buttons(_("Add Waypoint"),
828 GTK_DIALOG_MODAL, GTK_STOCK_OK,
831 GTK_RESPONSE_REJECT, NULL);
833 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
834 table = gtk_table_new(2, 2, FALSE), TRUE, TRUE, 0);
836 gtk_table_attach(GTK_TABLE(table),
837 label = gtk_label_new(_("Lat, Lon")),
838 0, 1, 0, 1, GTK_FILL, 0, 2, 4);
839 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
841 unit2latlon(unitx, unity, lat, lon);
842 lat_format(lat, tmp1);
843 lon_format(lon, tmp2);
844 p_latlon = g_strdup_printf("%s, %s", tmp1, tmp2);
845 gtk_table_attach(GTK_TABLE(table),
846 label = gtk_label_new(p_latlon),
847 1, 2, 0, 1, GTK_FILL, 0, 2, 4);
848 gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
851 gtk_table_attach(GTK_TABLE(table),
852 label = gtk_label_new(_("Description")),
853 0, 1, 1, 2, GTK_FILL, 0, 2, 4);
854 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
856 txt_scroll = gtk_scrolled_window_new(NULL, NULL);
857 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(txt_scroll),
859 gtk_table_attach(GTK_TABLE(table),
861 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4);
863 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scroll),
864 GTK_POLICY_AUTOMATIC,
865 GTK_POLICY_AUTOMATIC);
867 txt_desc = gtk_text_view_new();
868 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(txt_desc), GTK_WRAP_WORD);
870 gtk_container_add(GTK_CONTAINER(txt_scroll), txt_desc);
871 gtk_widget_set_size_request(GTK_WIDGET(txt_scroll), 400, 60);
873 gtk_widget_show_all(dialog);
875 while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
877 GtkTextIter ti1, ti2;
880 tbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(txt_desc));
881 gtk_text_buffer_get_iter_at_offset(tbuf, &ti1, 0);
882 gtk_text_buffer_get_end_iter(tbuf, &ti2);
883 desc = gtk_text_buffer_get_text(tbuf, &ti1, &ti2, TRUE);
886 /* There's a description. Add a waypoint. */
887 MACRO_PATH_INCREMENT_TAIL(_route);
888 _route.tail->unitx = unitx;
889 _route.tail->unity = unity;
890 _route.tail->time = 0;
891 _route.tail->altitude = NAN;
893 MACRO_PATH_INCREMENT_WTAIL(_route);
894 _route.wtail->point = _route.tail;
896 = gtk_text_buffer_get_text(tbuf, &ti1, &ti2, TRUE);
902 confirm = hildon_note_new_confirmation(GTK_WINDOW(dialog),
903 _("Creating a \"waypoint\" with no description actually "
904 "adds a break point. Is that what you want?"));
906 if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
907 /* There's no description. Add a break by adding a (0, 0)
908 * point (if necessary), and then the ordinary route point. */
909 if (_route.tail->unity) {
910 MACRO_PATH_INCREMENT_TAIL(_route);
911 *_route.tail = _point_null;
914 MACRO_PATH_INCREMENT_TAIL(_route);
915 _route.tail->unitx = unitx;
916 _route.tail->unity = unity;
917 _route.tail->time = 0;
918 _route.tail->altitude = NAN;
920 gtk_widget_destroy(confirm);
922 gtk_widget_destroy(confirm);
927 route_find_nearest_point();
929 MACRO_QUEUE_DRAW_AREA();
932 gtk_widget_destroy(dialog);
936 cmenu_cb_loc_show_latlon(GtkAction * action)
938 cmenu_show_latlon(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
943 cmenu_cb_loc_clip_latlon(GtkAction * action)
945 cmenu_clip_latlon(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
950 cmenu_cb_loc_route_to(GtkAction * action)
952 cmenu_route_to(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
957 cmenu_cb_loc_distance_to(GtkAction * action)
959 cmenu_distance_to(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
964 cmenu_cb_loc_add_route(GtkAction * action)
966 cmenu_add_route(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
971 cmenu_cb_loc_add_way(GtkAction * action)
973 cmenu_route_add_way(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
978 cmenu_cb_loc_add_poi(GtkAction * action)
980 poi_dialog(ACTION_ADD_POI, x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
985 cb_poi_search(GtkAction *action)
990 unit2latlon(_center.unitx, _center.unity, lat, lon);
992 poi_search_dialog(NULL, &poi, lat, lon);
997 cb_poi_add(GtkAction *action)
1000 const gchar *name = gtk_action_get_name(action);
1002 if (_center_mode > 0) {
1003 latlon2unit(_gps.lat, _gps.lon, unitx, unity);
1005 unitx=_center.unitx;
1006 unity=_center.unity;
1009 if (strcmp(name, "poi_add")==0)
1010 poi_dialog(ACTION_ADD_POI, unitx, unity);
1011 else if (strcmp(name, "poi_quick_add")==0)
1012 poi_quick_dialog(unitx, unity);
1014 g_assert_not_reached();
1020 cmenu_cb_loc_set_home(GtkAction * action)
1024 unitx = x2unit(_cmenu_position_x);
1025 unity = y2unit(_cmenu_position_y);
1026 unit2latlon(unitx, unity, _home.lat, _home.lon);
1035 cmenu_cb_loc_set_destination(GtkAction *action)
1039 unitx = x2unit(_cmenu_position_x);
1040 unity = y2unit(_cmenu_position_y);
1041 unit2latlon(unitx, unity, _dest.lat, _dest.lon);
1043 map_update_location_from_center();
1048 cmenu_cb_loc_set_gps(GtkAction * action)
1050 _pos.unitx = x2unit(_cmenu_position_x);
1051 _pos.unity = y2unit(_cmenu_position_y);
1052 unit2latlon(_pos.unitx, _pos.unity, _gps.lat, _gps.lon);
1054 /* Move mark to new location. */
1056 track_add(time(NULL), FALSE);
1062 cmenu_cb_way_show_latlon(GtkAction * action)
1066 if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y))))
1067 cmenu_show_latlon(way->point->unitx, way->point->unity);
1073 cmenu_cb_way_show_desc(GtkAction * action)
1077 if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y)))) {
1078 MACRO_BANNER_SHOW_INFO(_window, way->desc);
1085 cmenu_cb_way_clip_latlon(GtkAction * action)
1089 if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y))))
1090 cmenu_clip_latlon(way->point->unitx, way->point->unity);
1095 cmenu_cb_way_clip_desc(GtkAction * action)
1099 if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y))))
1100 gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), way->desc, -1);
1106 cmenu_cb_way_route_to(GtkAction * action)
1110 if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y))))
1111 cmenu_route_to(way->point->unitx, way->point->unity);
1117 cmenu_cb_way_distance_to(GtkAction * action)
1121 if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y))))
1122 route_show_distance_to(way->point);
1128 cmenu_cb_way_delete(GtkAction * action)
1132 if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y)))) {
1133 gchar buffer[BUFFER_SIZE];
1136 snprintf(buffer, sizeof(buffer), "%s:\n%s\n",
1137 _("Confirm delete of waypoint"), way->desc);
1138 confirm = hildon_note_new_confirmation(GTK_WINDOW(_window), buffer);
1140 if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
1141 Point *pdel_min, *pdel_max, *pdel_start, *pdel_end;
1144 /* Delete surrounding route data, too. */
1145 if (way == _route.whead)
1146 pdel_min = _route.head;
1148 pdel_min = way[-1].point;
1150 if (way == _route.wtail)
1151 pdel_max = _route.tail;
1153 pdel_max = way[1].point;
1155 /* Find largest continuous segment around the waypoint, EXCLUDING
1156 * pdel_min and pdel_max. */
1157 for (pdel_start = way->point - 1; pdel_start->unity
1158 && pdel_start > pdel_min; pdel_start--) {
1160 for (pdel_end = way->point + 1; pdel_end->unity
1161 && pdel_end < pdel_max; pdel_end++) {
1164 /* If pdel_end is set to _route.tail, and if _route.tail is a
1165 * non-zero point, then delete _route.tail. */
1166 if (pdel_end == _route.tail && pdel_end->unity)
1167 pdel_end++; /* delete _route.tail too */
1168 /* else, if *both* endpoints are zero points, delete one. */
1169 else if (!pdel_start->unity && !pdel_end->unity)
1172 /* Delete BETWEEN pdel_start and pdel_end, exclusive. */
1173 num_del = pdel_end - pdel_start - 1;
1175 memmove(pdel_start + 1, pdel_end,(_route.tail - pdel_end + 1) * sizeof(Point));
1176 _route.tail -= num_del;
1178 /* Remove waypoint and move/adjust subsequent waypoints. */
1180 while (way++ != _route.wtail) {
1182 way[-1].point -= num_del;
1186 route_find_nearest_point();
1189 gtk_widget_destroy(confirm);
1196 menu_cb_category(GtkAction * action)
1198 if (poi_category_list())
1205 cmenu_cb_way_add_poi(GtkAction * action)
1209 if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y))))
1210 poi_dialog(ACTION_ADD_POI, way->point->unitx, way->point->unity);
1216 cmenu_cb_poi_route_to(GtkAction * action)
1220 if (poi_select(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y), &poi)) {
1222 latlon2unit(poi.lat, poi.lon, unitx, unity);
1223 cmenu_route_to(unitx, unity);
1230 cmenu_cb_poi_distance_to(GtkAction * action)
1234 if (poi_select(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y), &poi)) {
1236 latlon2unit(poi.lat, poi.lon, unitx, unity);
1237 cmenu_distance_to(unitx, unity);
1244 cmenu_cb_poi_add_route(GtkAction * action)
1248 if (poi_select(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y), &poi)) {
1250 latlon2unit(poi.lat, poi.lon, unitx, unity);
1251 cmenu_add_route(unitx, unity);
1258 cmenu_cb_poi_add_way(GtkAction * action)
1262 if (poi_select(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y), &poi)) {
1264 latlon2unit(poi.lat, poi.lon, unitx, unity);
1265 cmenu_route_add_way(unitx, unity);
1272 cmenu_cb_poi_edit_poi(GtkAction * action)
1274 poi_dialog(ACTION_EDIT_POI, x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));