X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/4c77d5e0aec3c7aab32965ca4e02abb17bb6108f..d260d7985116255a0eb2232edfd8a0dbc29f31d6:/src/vikgeoreflayer.c?ds=inline diff --git a/src/vikgeoreflayer.c b/src/vikgeoreflayer.c index 53b62f6c..57915052 100644 --- a/src/vikgeoreflayer.c +++ b/src/vikgeoreflayer.c @@ -24,10 +24,10 @@ #endif #include "viking.h" -#include "vikgeoreflayer_pixmap.h" -#include -#include +#include +#include #include +#include #include "icons/icons.h" @@ -65,16 +65,16 @@ static gboolean georef_layer_zoom_press ( VikGeorefLayer *vgl, GdkEventButton *e static VikToolInterface georef_tools[] = { { N_("Georef Move Map"), (VikToolConstructorFunc) georef_layer_move_create, NULL, NULL, NULL, (VikToolMouseFunc) georef_layer_move_press, NULL, (VikToolMouseFunc) georef_layer_move_release, - (VikToolKeyFunc) NULL, &cursor_geomove }, + (VikToolKeyFunc) NULL, GDK_CURSOR_IS_PIXMAP, &cursor_geomove_pixbuf }, { N_("Georef Zoom Tool"), (VikToolConstructorFunc) georef_layer_zoom_create, NULL, NULL, NULL, (VikToolMouseFunc) georef_layer_zoom_press, NULL, NULL, - (VikToolKeyFunc) NULL, &cursor_geozoom }, + (VikToolKeyFunc) NULL, GDK_CURSOR_IS_PIXMAP, &cursor_geozoom_pixbuf }, }; VikLayerInterface vik_georef_layer_interface = { "GeoRef Map", - &georeflayer_pixbuf, /*icon */ + &vikgeoreflayer_pixbuf, /*icon */ georef_tools, sizeof(georef_tools) / sizeof(VikToolInterface), @@ -293,11 +293,12 @@ static gboolean world_file_read_line ( gchar *buffer, gint size, FILE *f, GtkWid a_dialog_error_msg ( VIK_GTK_WINDOW_FROM_WIDGET(widget), _("Unexpected end of file reading World file.") ); g_free ( buffer ); fclose ( f ); + f = NULL; return FALSE; } if ( use_value ) { - gdouble val = strtod ( buffer, NULL ); + gdouble val = g_strtod ( buffer, NULL ); gtk_spin_button_set_value ( GTK_SPIN_BUTTON(widget), val > 0 ? val : -val ); } return TRUE; @@ -305,11 +306,16 @@ static gboolean world_file_read_line ( gchar *buffer, gint size, FILE *f, GtkWid static void georef_layer_dialog_load ( GtkWidget *pass_along[4] ) { - GtkWidget *file_selector = gtk_file_selection_new (_("Choose World file")); - - if ( gtk_dialog_run ( GTK_DIALOG ( file_selector ) ) == GTK_RESPONSE_OK ) + GtkWidget *file_selector = gtk_file_chooser_dialog_new (_("Choose World file"), + NULL, + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + NULL); + + if ( gtk_dialog_run ( GTK_DIALOG ( file_selector ) ) == GTK_RESPONSE_ACCEPT ) { - FILE *f = fopen ( gtk_file_selection_get_filename ( GTK_FILE_SELECTION(file_selector) ), "r" ); + FILE *f = g_fopen ( gtk_file_chooser_get_filename ( GTK_FILE_CHOOSER(file_selector) ), "r" ); gtk_widget_destroy ( file_selector ); if ( !f ) { @@ -319,12 +325,13 @@ static void georef_layer_dialog_load ( GtkWidget *pass_along[4] ) else { gchar *buffer = g_malloc ( 1024 * sizeof(gchar) ); - if ( world_file_read_line ( buffer, 1024, f, pass_along[0], TRUE ) && world_file_read_line ( buffer, 1024, f, pass_along[1], TRUE ) - && world_file_read_line ( buffer, 1024, f, pass_along[0], FALSE ) && world_file_read_line ( buffer, 1024, f, pass_along[0], FALSE ) + if ( world_file_read_line ( buffer, 1024, f, pass_along[0], TRUE ) && world_file_read_line ( buffer, 1024, f, pass_along[0], FALSE) + && world_file_read_line ( buffer, 1024, f, pass_along[0], FALSE ) && world_file_read_line ( buffer, 1024, f, pass_along[1], TRUE) && world_file_read_line ( buffer, 1024, f, pass_along[2], TRUE ) && world_file_read_line ( buffer, 1024, f, pass_along[3], TRUE ) ) { g_free ( buffer ); fclose ( f ); + f = NULL; } } } @@ -344,11 +351,16 @@ We need a static void georef_layer_export_params ( gpointer *pass_along[2] ) { VikGeorefLayer *vgl = VIK_GEOREF_LAYER(pass_along[0]); - GtkWidget *file_selector = gtk_file_selection_new (_("Choose World file")); - - if ( gtk_dialog_run ( GTK_DIALOG ( file_selector ) ) == GTK_RESPONSE_OK ) + GtkWidget *file_selector = gtk_file_chooser_dialog_new (_("Choose World file"), + NULL, + GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + NULL); + if ( gtk_dialog_run ( GTK_DIALOG ( file_selector ) ) == GTK_RESPONSE_ACCEPT ) { - FILE *f = fopen ( gtk_file_selection_get_filename ( GTK_FILE_SELECTION(file_selector) ), "w" ); + FILE *f = g_fopen ( gtk_file_chooser_get_filename ( GTK_FILE_CHOOSER(file_selector) ), "w" ); + gtk_widget_destroy ( file_selector ); if ( !f ) { @@ -359,6 +371,7 @@ static void georef_layer_export_params ( gpointer *pass_along[2] ) { fprintf ( f, "%f\n%f\n%f\n%f\n%f\n%f\n", vgl->mpp_easting, vgl->mpp_northing, 0.0, 0.0, vgl->corner.easting, vgl->corner.northing ); fclose ( f ); + f = NULL; } } else @@ -392,18 +405,22 @@ static gboolean georef_layer_dialog ( VikGeorefLayer **vgl, gpointer vp, GtkWind ce_label = gtk_label_new ( _("Corner pixel easting:") ); ce_spin = gtk_spin_button_new ( (GtkAdjustment *) gtk_adjustment_new ( 4, 0.0, 1500000.0, 1, 5, 5 ), 1, 4 ); + gtk_widget_set_tooltip_text ( GTK_WIDGET(ce_spin), _("the UTM \"easting\" value of the upper-right corner pixel of the map") ); cn_label = gtk_label_new ( _("Corner pixel northing:") ); cn_spin = gtk_spin_button_new ( (GtkAdjustment *) gtk_adjustment_new ( 4, 0.0, 9000000.0, 1, 5, 5 ), 1, 4 ); + gtk_widget_set_tooltip_text ( GTK_WIDGET(cn_spin), _("the UTM \"northing\" value of the upper-right corner pixel of the map") ); xlabel = gtk_label_new ( _("X (easting) scale (mpp): ")); ylabel = gtk_label_new ( _("Y (northing) scale (mpp): ")); xspin = gtk_spin_button_new ( (GtkAdjustment *) gtk_adjustment_new ( 4, VIK_VIEWPORT_MIN_ZOOM, VIK_VIEWPORT_MAX_ZOOM, 1, 5, 5 ), 1, 8 ); + gtk_widget_set_tooltip_text ( GTK_WIDGET(xspin), _("the scale of the map in the X direction (meters per pixel)") ); yspin = gtk_spin_button_new ( (GtkAdjustment *) gtk_adjustment_new ( 4, VIK_VIEWPORT_MIN_ZOOM, VIK_VIEWPORT_MAX_ZOOM, 1, 5, 5 ), 1, 8 ); + gtk_widget_set_tooltip_text ( GTK_WIDGET(yspin), _("the scale of the map in the Y direction (meters per pixel)") ); imagelabel = gtk_label_new ( _("Map Image:") ); - imageentry = vik_file_entry_new (); + imageentry = vik_file_entry_new (GTK_FILE_CHOOSER_ACTION_OPEN); if (*vgl) {