X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/33bc7c1b0ed6b82ee653c7ae67fa2ffe50801081..9552af08b0de8cf0de6b8d253d5a77173f35259b:/src/vikwindow.c diff --git a/src/vikwindow.c b/src/vikwindow.c index 0b91f9fc..4818ee17 100644 --- a/src/vikwindow.c +++ b/src/vikwindow.c @@ -55,6 +55,12 @@ #include #include +// This seems rather arbitary, quite large and pointless +// I mean, if you have a thousand windows open; +// why not be allowed to open a thousand more... +#define MAX_WINDOWS 1024 +static guint window_count = 0; + #define VIKING_WINDOW_WIDTH 1000 #define VIKING_WINDOW_HEIGHT 800 #define DRAW_IMAGE_DEFAULT_WIDTH 1280 @@ -68,10 +74,18 @@ static void window_init ( VikWindow *vw ); static void window_class_init ( VikWindowClass *klass ); static void window_set_filename ( VikWindow *vw, const gchar *filename ); +static VikWindow *window_new (); + static void draw_update ( VikWindow *vw ); static void newwindow_cb ( GtkAction *a, VikWindow *vw ); +// Signals +static void open_window ( VikWindow *vw, GSList *files ); +static void statusbar_update ( VikWindow *vw, const gchar *message, vik_statusbar_type_t vs_type ); +static void destroy_window ( GtkWidget *widget, + gpointer data ); + /* Drawing & stuff */ static gboolean delete_event( VikWindow *vw ); @@ -178,7 +192,6 @@ struct _VikWindow { gpointer selected_waypoints; /* notionally GList */ gpointer selected_waypoint; /* notionally VikWaypoint */ /* only use for individual track or waypoint */ - gpointer selected_name; /* notionally gchar */ ////// NEED TO THINK ABOUT VALIDITY OF THESE ////// ////// i.e. what happens when stuff is deleted elsewhere ////// ////// Generally seems alright as can not access them ////// @@ -199,6 +212,7 @@ enum { enum { VW_NEWWINDOW_SIGNAL, VW_OPENWINDOW_SIGNAL, + VW_STATUSBAR_UPDATE_SIGNAL, VW_LAST_SIGNAL }; @@ -249,6 +263,96 @@ VikStatusbar * vik_window_get_statusbar ( VikWindow *vw ) return vw->viking_vs; } +/** + * For signalling the update from a background thread + */ +void vik_window_signal_statusbar_update (VikWindow *vw, const gchar* message, vik_statusbar_type_t vs_type) +{ + g_signal_emit ( G_OBJECT(vw), window_signals[VW_STATUSBAR_UPDATE_SIGNAL], 0, message, vs_type ); +} + +/** + * For the actual statusbar update! + */ +static gboolean statusbar_idle_update ( gpointer indata ) +{ + gpointer *data = indata; + vik_statusbar_set_message ( data[0], GPOINTER_TO_INT(data[2]), data[1] ); + return FALSE; +} + +/** + * Update statusbar in the main thread + */ +static void window_statusbar_update ( VikWindow *vw, const gchar* message, vik_statusbar_type_t vs_type ) +{ + // ATM we know the message has been statically allocated so this is OK (no need to handle any freeing) + static gpointer data[3]; + data[0] = vw->viking_vs; + data[1] = (gchar*) message; + data[2] = GINT_TO_POINTER(vs_type); + g_idle_add ( (GSourceFunc) statusbar_idle_update, data ); +} + +// Actual signal handlers +static void destroy_window ( GtkWidget *widget, + gpointer data ) +{ + if ( ! --window_count ) + gtk_main_quit (); +} + +static void statusbar_update ( VikWindow *vw, const gchar *message, vik_statusbar_type_t vs_type ) +{ + window_statusbar_update ( vw, message, vs_type ); +} + +VikWindow *vik_window_new_window () +{ + if ( window_count < MAX_WINDOWS ) + { + VikWindow *vw = window_new (); + + g_signal_connect (G_OBJECT (vw), "destroy", + G_CALLBACK (destroy_window), NULL); + g_signal_connect (G_OBJECT (vw), "newwindow", + G_CALLBACK (vik_window_new_window), NULL); + g_signal_connect (G_OBJECT (vw), "openwindow", + G_CALLBACK (open_window), NULL); + g_signal_connect (G_OBJECT (vw), "statusbarupdate", + G_CALLBACK (statusbar_update), vw); + + gtk_widget_show_all ( GTK_WIDGET(vw) ); + + window_count++; + + return vw; + } + return NULL; +} + +static void open_window ( VikWindow *vw, GSList *files ) +{ + gboolean change_fn = (g_slist_length(files) == 1); /* only change fn if one file */ + GSList *cur_file = files; + while ( cur_file ) { + // Only open a new window if a viking file + gchar *file_name = cur_file->data; + if (vw != NULL && check_file_magic_vik ( file_name ) ) { + VikWindow *newvw = vik_window_new_window (); + if (newvw) + vik_window_open_file ( newvw, file_name, change_fn ); + } + else { + vik_window_open_file ( vw, file_name, change_fn ); + } + g_free (file_name); + cur_file = g_slist_next (cur_file); + } + g_slist_free (files); +} +// End signals + void vik_window_selected_layer(VikWindow *vw, VikLayer *vl) { int i, j, tool_count; @@ -274,7 +378,7 @@ static void window_finalize ( GObject *gob ) VikWindow *vw = VIK_WINDOW(gob); g_return_if_fail ( vw != NULL ); - a_background_remove_status ( vw->viking_vs ); + a_background_remove_window ( vw ); G_OBJECT_CLASS(parent_class)->finalize(gob); } @@ -287,6 +391,7 @@ static void window_class_init ( VikWindowClass *klass ) window_signals[VW_NEWWINDOW_SIGNAL] = g_signal_new ( "newwindow", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (VikWindowClass, newwindow), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); window_signals[VW_OPENWINDOW_SIGNAL] = g_signal_new ( "openwindow", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (VikWindowClass, openwindow), NULL, NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); + window_signals[VW_STATUSBAR_UPDATE_SIGNAL] = g_signal_new ( "statusbarupdate", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (VikWindowClass, statusbarupdate), NULL, NULL, gtk_marshal_VOID__POINTER_UINT, G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_UINT); object_class = G_OBJECT_CLASS (klass); @@ -362,7 +467,7 @@ static void window_init ( VikWindow *vw ) gtk_box_pack_end (GTK_BOX(main_vbox), GTK_WIDGET(vw->viking_vs), FALSE, TRUE, 0); - a_background_add_status(vw->viking_vs); + a_background_add_window ( vw ); vw->open_dia = NULL; vw->save_dia = NULL; @@ -370,7 +475,7 @@ static void window_init ( VikWindow *vw ) vw->save_img_dir_dia = NULL; } -VikWindow *vik_window_new () +static VikWindow *window_new () { return VIK_WINDOW ( g_object_new ( VIK_WINDOW_TYPE, NULL ) ); } @@ -384,9 +489,12 @@ static gboolean key_press_event( VikWindow *vw, GdkEventKey *event, gpointer dat return vw->vt->tools[vw->vt->active_tool].ti.key_press(vl, event, vw->vt->tools[vw->vt->active_tool].state); } - // No layer - but enable window tool keypress processing - these should be able to handle a NULL layer - if ( vw->vt->tools[vw->vt->active_tool].ti.key_press ) { - return vw->vt->tools[vw->vt->active_tool].ti.key_press ( vl, event, vw->vt->tools[vw->vt->active_tool].state ); + // Ensure called only on window tools (i.e. not on any of the Layer tools since the layer is NULL) + if ( vw->current_tool < TOOL_LAYER ) { + // No layer - but enable window tool keypress processing - these should be able to handle a NULL layer + if ( vw->vt->tools[vw->vt->active_tool].ti.key_press ) { + return vw->vt->tools[vw->vt->active_tool].ti.key_press ( vl, event, vw->vt->tools[vw->vt->active_tool].state ); + } } /* Restore Main Menu via Escape key if the user has hidden it */ @@ -553,6 +661,9 @@ static void draw_click (VikWindow *vw, GdkEventButton *event) * for panning and zooming; tools only get left/right/movement */ if ( event->button == 2) { + if ( vw->vt->tools[vw->vt->active_tool].ti.pan_handler ) + // Tool still may need to do something (such as disable something) + toolbox_click(vw->vt, event); vik_window_pan_click ( vw, event ); } else { @@ -645,7 +756,10 @@ static void draw_release ( VikWindow *vw, GdkEventButton *event ) gtk_widget_grab_focus ( GTK_WIDGET(vw->viking_vvp) ); if ( event->button == 2 ) { /* move / pan */ - vik_window_pan_release(vw, event); + if ( vw->vt->tools[vw->vt->active_tool].ti.pan_handler ) + // Tool still may need to do something (such as reenable something) + toolbox_release(vw->vt, event); + vik_window_pan_release ( vw, event ); } else { toolbox_release(vw->vt, event); @@ -668,7 +782,13 @@ static void draw_scroll (VikWindow *vw, GdkEventScroll *event) else vik_viewport_set_center_screen ( vw->viking_vvp, vik_viewport_get_width(vw->viking_vvp)*2/3, vik_viewport_get_height(vw->viking_vvp)/2 ); } else if ( modifiers == (GDK_CONTROL_MASK | GDK_SHIFT_MASK) ) { - /* control+shift == make sure mouse is still over the same point on the map when we zoom */ + // This zoom is on the center position + if ( event->direction == GDK_SCROLL_UP ) + vik_viewport_zoom_in (vw->viking_vvp); + else + vik_viewport_zoom_out (vw->viking_vvp); + } else { + /* make sure mouse is still over the same point on the map when we zoom */ VikCoord coord; gint x, y; gint center_x = vik_viewport_get_width ( vw->viking_vvp ) / 2; @@ -681,11 +801,6 @@ static void draw_scroll (VikWindow *vw, GdkEventScroll *event) vik_viewport_coord_to_screen ( vw->viking_vvp, &coord, &x, &y ); vik_viewport_set_center_screen ( vw->viking_vvp, center_x + (x - event->x), center_y + (y - event->y) ); - } else { - if ( event->direction == GDK_SCROLL_UP ) - vik_viewport_zoom_in (vw->viking_vvp); - else - vik_viewport_zoom_out (vw->viking_vvp); } draw_update(vw); @@ -1029,6 +1144,7 @@ static VikToolInterface ruler_tool = (VikToolMouseMoveFunc) ruler_move, (VikToolMouseFunc) ruler_release, (VikToolKeyFunc) ruler_key_press, + FALSE, GDK_CURSOR_IS_PIXMAP, &cursor_ruler_pixbuf }; /*** end ruler code ********************************************************/ @@ -1038,43 +1154,245 @@ static VikToolInterface ruler_tool = /******************************************************************************** ** Zoom tool code ********************************************************************************/ + +typedef struct { + VikWindow *vw; + GdkPixmap *pixmap; + // Track zoom bounds for zoom tool with shift modifier: + gboolean bounds_active; + gint start_x; + gint start_y; +} zoom_tool_state_t; + +/* + * In case the screen size has changed + */ +static void zoomtool_resize_pixmap (zoom_tool_state_t *zts) +{ + int w1, h1, w2, h2; + + // Allocate a drawing area the size of the viewport + w1 = vik_viewport_get_width ( zts->vw->viking_vvp ); + h1 = vik_viewport_get_height ( zts->vw->viking_vvp ); + + if ( !zts->pixmap ) { + // Totally new + zts->pixmap = gdk_pixmap_new ( GTK_WIDGET(zts->vw->viking_vvp)->window, w1, h1, -1 ); + } + + gdk_drawable_get_size ( zts->pixmap, &w2, &h2 ); + + if ( w1 != w2 || h1 != h2 ) { + // Has changed - delete and recreate with new values + g_object_unref ( G_OBJECT ( zts->pixmap ) ); + zts->pixmap = gdk_pixmap_new ( GTK_WIDGET(zts->vw->viking_vvp)->window, w1, h1, -1 ); + } +} + static gpointer zoomtool_create (VikWindow *vw, VikViewport *vvp) { - return vw; + zoom_tool_state_t *zts = g_new(zoom_tool_state_t, 1); + zts->vw = vw; + zts->pixmap = NULL; + zts->start_x = 0; + zts->start_y = 0; + zts->bounds_active = FALSE; + return zts; } -static VikLayerToolFuncStatus zoomtool_click (VikLayer *vl, GdkEventButton *event, VikWindow *vw) +static void zoomtool_destroy ( zoom_tool_state_t *zts) { - vw->modified = TRUE; - vik_viewport_set_center_screen ( vw->viking_vvp, (gint) event->x, (gint) event->y ); - if ( event->button == 1 ) - vik_viewport_zoom_in (vw->viking_vvp); - else if ( event->button == 3 ) - vik_viewport_zoom_out (vw->viking_vvp); - draw_update ( vw ); + if ( zts->pixmap ) + g_object_unref ( G_OBJECT ( zts->pixmap ) ); + g_free(zts); +} + +static VikLayerToolFuncStatus zoomtool_click (VikLayer *vl, GdkEventButton *event, zoom_tool_state_t *zts) +{ + zts->vw->modified = TRUE; + guint modifiers = event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK); + + VikCoord coord; + gint x, y; + gint center_x = vik_viewport_get_width ( zts->vw->viking_vvp ) / 2; + gint center_y = vik_viewport_get_height ( zts->vw->viking_vvp ) / 2; + + gboolean skip_update = FALSE; + + zts->bounds_active = FALSE; + + if ( modifiers == (GDK_CONTROL_MASK | GDK_SHIFT_MASK) ) { + // This zoom is on the center position + vik_viewport_set_center_screen ( zts->vw->viking_vvp, center_x, center_y ); + if ( event->button == 1 ) + vik_viewport_zoom_in (zts->vw->viking_vvp); + else if ( event->button == 3 ) + vik_viewport_zoom_out (zts->vw->viking_vvp); + } + else if ( modifiers == GDK_CONTROL_MASK ) { + // This zoom is to recenter on the mouse position + vik_viewport_set_center_screen ( zts->vw->viking_vvp, (gint) event->x, (gint) event->y ); + if ( event->button == 1 ) + vik_viewport_zoom_in (zts->vw->viking_vvp); + else if ( event->button == 3 ) + vik_viewport_zoom_out (zts->vw->viking_vvp); + } + else if ( modifiers == GDK_SHIFT_MASK ) { + // Get start of new zoom bounds + if ( event->button == 1 ) { + zts->bounds_active = TRUE; + zts->start_x = (gint) event->x; + zts->start_y = (gint) event->y; + skip_update = TRUE; + } + } + else { + /* make sure mouse is still over the same point on the map when we zoom */ + vik_viewport_screen_to_coord ( zts->vw->viking_vvp, event->x, event->y, &coord ); + if ( event->button == 1 ) + vik_viewport_zoom_in (zts->vw->viking_vvp); + else if ( event->button == 3 ) + vik_viewport_zoom_out(zts->vw->viking_vvp); + vik_viewport_coord_to_screen ( zts->vw->viking_vvp, &coord, &x, &y ); + vik_viewport_set_center_screen ( zts->vw->viking_vvp, + center_x + (x - event->x), + center_y + (y - event->y) ); + } + + if ( !skip_update ) + draw_update ( zts->vw ); + return VIK_LAYER_TOOL_ACK; } -static VikLayerToolFuncStatus zoomtool_move (VikLayer *vl, GdkEventMotion *event, VikViewport *vvp) +static VikLayerToolFuncStatus zoomtool_move (VikLayer *vl, GdkEventMotion *event, zoom_tool_state_t *zts) { + guint modifiers = event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK); + + if ( zts->bounds_active && modifiers == GDK_SHIFT_MASK ) { + zoomtool_resize_pixmap ( zts ); + + // Blank out currently drawn area + gdk_draw_drawable ( zts->pixmap, + GTK_WIDGET(zts->vw->viking_vvp)->style->black_gc, + vik_viewport_get_pixmap(zts->vw->viking_vvp), + 0, 0, 0, 0, -1, -1); + + // Calculate new box starting point & size in pixels + int xx, yy, width, height; + if ( event->y > zts->start_y ) { + yy = zts->start_y; + height = event->y-zts->start_y; + } + else { + yy = event->y; + height = zts->start_y-event->y; + } + if ( event->x > zts->start_x ) { + xx = zts->start_x; + width = event->x-zts->start_x; + } + else { + xx = event->x; + width = zts->start_x-event->x; + } + + // Draw the box + gdk_draw_rectangle (zts->pixmap, GTK_WIDGET(zts->vw->viking_vvp)->style->black_gc, FALSE, xx, yy, width, height); + + // Only actually draw when there's time to do so + if (draw_buf_done) { + static gpointer pass_along[3]; + pass_along[0] = GTK_WIDGET(zts->vw->viking_vvp)->window; + pass_along[1] = GTK_WIDGET(zts->vw->viking_vvp)->style->black_gc; + pass_along[2] = zts->pixmap; + g_idle_add_full (G_PRIORITY_HIGH_IDLE + 10, draw_buf, pass_along, NULL); + draw_buf_done = FALSE; + } + } return VIK_LAYER_TOOL_ACK; } -static VikLayerToolFuncStatus zoomtool_release (VikLayer *vl, GdkEventButton *event, VikViewport *vvp) +static VikLayerToolFuncStatus zoomtool_release (VikLayer *vl, GdkEventButton *event, zoom_tool_state_t *zts) { + guint modifiers = event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK); + + zts->bounds_active = FALSE; + + // Ensure haven't just released on the exact same position + // i.e. probably haven't moved the mouse at all + if ( modifiers == GDK_SHIFT_MASK && !( ( event->x == zts->start_x ) && ( event->y == zts->start_y )) ) { + + VikCoord coord1, coord2; + vik_viewport_screen_to_coord ( zts->vw->viking_vvp, zts->start_x, zts->start_y, &coord1); + vik_viewport_screen_to_coord ( zts->vw->viking_vvp, event->x, event->y, &coord2); + + // From the extend of the bounds pick the best zoom level + // c.f. trw_layer_zoom_to_show_latlons() + // Maybe refactor... + struct LatLon ll1, ll2; + vik_coord_to_latlon(&coord1, &ll1); + vik_coord_to_latlon(&coord2, &ll2); + struct LatLon average = { (ll1.lat+ll2.lat)/2, + (ll1.lon+ll2.lon)/2 }; + + VikCoord new_center; + vik_coord_load_from_latlon ( &new_center, vik_viewport_get_coord_mode ( zts->vw->viking_vvp ), &average ); + vik_viewport_set_center_coord ( zts->vw->viking_vvp, &new_center ); + + /* Convert into definite 'smallest' and 'largest' positions */ + struct LatLon minmin; + if ( ll1.lat < ll2.lat ) + minmin.lat = ll1.lat; + else + minmin.lat = ll2.lat; + + struct LatLon maxmax; + if ( ll1.lon > ll2.lon ) + maxmax.lon = ll1.lon; + else + maxmax.lon = ll2.lon; + + /* Always recalculate the 'best' zoom level */ + gdouble zoom = VIK_VIEWPORT_MIN_ZOOM; + vik_viewport_set_zoom ( zts->vw->viking_vvp, zoom ); + + gdouble min_lat, max_lat, min_lon, max_lon; + /* Should only be a maximum of about 18 iterations from min to max zoom levels */ + while ( zoom <= VIK_VIEWPORT_MAX_ZOOM ) { + vik_viewport_get_min_max_lat_lon ( zts->vw->viking_vvp, &min_lat, &max_lat, &min_lon, &max_lon ); + /* NB I think the logic used in this test to determine if the bounds is within view + fails if track goes across 180 degrees longitude. + Hopefully that situation is not too common... + Mind you viking doesn't really do edge locations to well anyway */ + if ( min_lat < minmin.lat && + max_lat > minmin.lat && + min_lon < maxmax.lon && + max_lon > maxmax.lon ) + /* Found within zoom level */ + break; + + /* Try next */ + zoom = zoom * 2; + vik_viewport_set_zoom ( zts->vw->viking_vvp, zoom ); + } + + draw_update ( zts->vw ); + } return VIK_LAYER_TOOL_ACK; } static VikToolInterface zoom_tool = { { "Zoom", "vik-icon-zoom", N_("_Zoom"), "Z", N_("Zoom Tool"), 1 }, (VikToolConstructorFunc) zoomtool_create, - (VikToolDestructorFunc) NULL, + (VikToolDestructorFunc) zoomtool_destroy, (VikToolActivationFunc) NULL, (VikToolActivationFunc) NULL, (VikToolMouseFunc) zoomtool_click, (VikToolMouseMoveFunc) zoomtool_move, (VikToolMouseFunc) zoomtool_release, NULL, + FALSE, GDK_CURSOR_IS_PIXMAP, &cursor_zoom_pixbuf }; /*** end zoom code ********************************************************/ @@ -1119,6 +1437,7 @@ static VikToolInterface pan_tool = (VikToolMouseMoveFunc) pantool_move, (VikToolMouseFunc) pantool_release, NULL, + FALSE, GDK_FLEUR }; /*** end pan code ********************************************************/ @@ -1193,7 +1512,7 @@ static VikLayerToolFuncStatus selecttool_click (VikLayer *vl, GdkEventButton *ev else if ( ( event->button == 3 ) && ( vl && ( vl->type == VIK_LAYER_TRW ) ) ) { if ( vl->visible ) /* Act on currently selected item to show menu */ - if ( ( t->vw->selected_track || t->vw->selected_waypoint ) && t->vw->selected_name ) + if ( t->vw->selected_track || t->vw->selected_waypoint ) if ( vik_layer_get_interface(vl->type)->show_viewport_menu ) vik_layer_get_interface(vl->type)->show_viewport_menu ( vl, event, t->vw->viking_vvp ); } @@ -1235,6 +1554,7 @@ static VikToolInterface select_tool = (VikToolMouseMoveFunc) selecttool_move, (VikToolMouseFunc) selecttool_release, (VikToolKeyFunc) NULL, + FALSE, GDK_LEFT_PTR, NULL, NULL }; @@ -1752,6 +2072,9 @@ void vik_window_open_file ( VikWindow *vw, const gchar *filename, gboolean chang case LOAD_TYPE_GPSBABEL_FAILURE: a_dialog_error_msg ( GTK_WINDOW(vw), _("GPSBabel is required to load files of this type or GPSBabel encountered problems.") ); break; + case LOAD_TYPE_GPX_FAILURE: + a_dialog_error_msg_extra ( GTK_WINDOW(vw), _("Unable to load malformed GPX file %s"), filename ); + break; case LOAD_TYPE_UNSUPPORTED_FAILURE: a_dialog_error_msg_extra ( GTK_WINDOW(vw), _("Unsupported file type for %s"), filename ); break; @@ -1893,6 +2216,12 @@ static gboolean save_file_as ( GtkAction *a, VikWindow *vw ) gtk_window_set_transient_for ( GTK_WINDOW(vw->save_dia), GTK_WINDOW(vw) ); gtk_window_set_destroy_with_parent ( GTK_WINDOW(vw->save_dia), TRUE ); } + // Auto append / replace extension with '.vik' to the suggested file name as it's going to be a Viking File + gchar* auto_save_name = strdup ( vw->filename ? a_file_basename ( vw->filename ) : _("Untitled") ); + if ( ! check_file_ext ( auto_save_name, ".vik" ) ) + auto_save_name = g_strconcat ( auto_save_name, ".vik", NULL ); + + gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER(vw->save_dia), auto_save_name); while ( gtk_dialog_run ( GTK_DIALOG(vw->save_dia) ) == GTK_RESPONSE_ACCEPT ) { @@ -1905,6 +2234,7 @@ static gboolean save_file_as ( GtkAction *a, VikWindow *vw ) break; } } + g_free ( auto_save_name ); gtk_widget_hide ( vw->save_dia ); return rv; } @@ -1949,10 +2279,12 @@ static void acquire_from_file ( GtkAction *a, VikWindow *vw ) a_acquire(vw, vw->viking_vlp, vw->viking_vvp, &vik_datasource_file_interface ); } +#ifdef VIK_CONFIG_GOOGLE_DIRECTIONS static void acquire_from_google ( GtkAction *a, VikWindow *vw ) { a_acquire(vw, vw->viking_vlp, vw->viking_vvp, &vik_datasource_google_interface ); } +#endif #ifdef VIK_CONFIG_OPENSTREETMAP static void acquire_from_osm ( GtkAction *a, VikWindow *vw ) @@ -2539,7 +2871,9 @@ static GtkActionEntry entries[] = { { "Acquire", GTK_STOCK_GO_DOWN, N_("A_cquire"), NULL, NULL, (GCallback)NULL }, { "AcquireGPS", NULL, N_("From _GPS..."), NULL, N_("Transfer data from a GPS device"), (GCallback)acquire_from_gps }, { "AcquireGPSBabel", NULL, N_("Import File With GPS_Babel..."), NULL, N_("Import file via GPSBabel converter"), (GCallback)acquire_from_file }, +#ifdef VIK_CONFIG_GOOGLE_DIRECTIONS { "AcquireGoogle", NULL, N_("Google _Directions..."), NULL, N_("Get driving directions from Google"), (GCallback)acquire_from_google }, +#endif #ifdef VIK_CONFIG_OPENSTREETMAP { "AcquireOSM", NULL, N_("_OSM Traces..."), NULL, N_("Get traces from OpenStreetMap"), (GCallback)acquire_from_osm }, #endif @@ -2759,7 +3093,7 @@ static struct { { &select_18_pixbuf, "vik-icon-select" }, { &begintr_18_pixbuf, "vik-icon-Begin Track" }, { &route_finder_18_pixbuf, "vik-icon-Route Finder" }, - { &demdl_18_pixbuf, "vik-icon-DEM Download/Import"}, + { &demdl_18_pixbuf, "vik-icon-DEM Download" }, { &showpic_18_pixbuf, "vik-icon-Show Picture" }, { &addtr_18_pixbuf, "vik-icon-Create Track" }, { &edtr_18_pixbuf, "vik-icon-Edit Trackpoint" }, @@ -2800,7 +3134,6 @@ void vik_window_set_selected_trw_layer ( VikWindow *vw, gpointer vtl ) vw->selected_tracks = NULL; vw->selected_waypoint = NULL; vw->selected_waypoints = NULL; - vw->selected_name = NULL; // Set highlight thickness vik_viewport_set_highlight_thickness ( vw->viking_vvp, vik_trw_layer_get_property_tracks_line_thickness (vw->containing_vtl) ); } @@ -2819,7 +3152,6 @@ void vik_window_set_selected_tracks ( VikWindow *vw, gpointer gl, gpointer vtl ) vw->selected_track = NULL; vw->selected_waypoint = NULL; vw->selected_waypoints = NULL; - vw->selected_name = NULL; // Set highlight thickness vik_viewport_set_highlight_thickness ( vw->viking_vvp, vik_trw_layer_get_property_tracks_line_thickness (vw->containing_vtl) ); } @@ -2833,7 +3165,6 @@ void vik_window_set_selected_track ( VikWindow *vw, gpointer *vt, gpointer vtl, { vw->selected_track = vt; vw->containing_vtl = vtl; - vw->selected_name = name; /* Clear others */ vw->selected_vtl = NULL; vw->selected_tracks = NULL; @@ -2857,7 +3188,6 @@ void vik_window_set_selected_waypoints ( VikWindow *vw, gpointer gl, gpointer vt vw->selected_track = NULL; vw->selected_tracks = NULL; vw->selected_waypoint = NULL; - vw->selected_name = NULL; } gpointer vik_window_get_selected_waypoint ( VikWindow *vw ) @@ -2869,7 +3199,6 @@ void vik_window_set_selected_waypoint ( VikWindow *vw, gpointer *vwp, gpointer v { vw->selected_waypoint = vwp; vw->containing_vtl = vtl; - vw->selected_name = name; /* Clear others */ vw->selected_vtl = NULL; vw->selected_track = NULL; @@ -2877,11 +3206,6 @@ void vik_window_set_selected_waypoint ( VikWindow *vw, gpointer *vwp, gpointer v vw->selected_waypoints = NULL; } -gpointer vik_window_get_selected_name ( VikWindow *vw ) -{ - return vw->selected_name; -} - gboolean vik_window_clear_highlight ( VikWindow *vw ) { gboolean need_redraw = FALSE;