*
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include "viking.h"
-#include "vikgeoreflayer_pixmap.h"
-#include <stdlib.h>
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <glib/gi18n.h>
#include <string.h>
+#include "icons/icons.h"
+
VikLayerParam georef_layer_params[] = {
{ "image", VIK_LAYER_PARAM_STRING, VIK_LAYER_NOT_IN_PROPERTIES },
{ "corner_easting", VIK_LAYER_PARAM_DOUBLE, VIK_LAYER_NOT_IN_PROPERTIES },
static void georef_layer_marshall( VikGeorefLayer *vgl, guint8 **data, gint *len );
static VikGeorefLayer *georef_layer_unmarshall( guint8 *data, gint len, VikViewport *vvp );
-static VikGeorefLayer *georef_layer_copy ( VikGeorefLayer *vgl, gpointer vp );
static gboolean georef_layer_set_param ( VikGeorefLayer *vgl, guint16 id, VikLayerParamData data, VikViewport *vp );
static VikLayerParamData georef_layer_get_param ( VikGeorefLayer *vgl, guint16 id );
VikGeorefLayer *georef_layer_new ( );
static gboolean georef_layer_zoom_press ( VikGeorefLayer *vgl, GdkEventButton *event, VikViewport *vvp );
static VikToolInterface georef_tools[] = {
- { "Georef Move Map", (VikToolConstructorFunc) georef_layer_move_create, NULL, NULL, NULL,
- (VikToolMouseFunc) georef_layer_move_press, NULL, (VikToolMouseFunc) georef_layer_move_release },
+ { 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, GDK_CURSOR_IS_PIXMAP, &cursor_geomove_pixbuf },
- { "Georef Zoom Tool", (VikToolConstructorFunc) georef_layer_zoom_create, NULL, NULL, NULL,
- (VikToolMouseFunc) georef_layer_zoom_press, NULL, NULL },
+ { N_("Georef Zoom Tool"), (VikToolConstructorFunc) georef_layer_zoom_create, NULL, NULL, NULL,
+ (VikToolMouseFunc) georef_layer_zoom_press, NULL, NULL,
+ (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),
(VikLayerFuncDraw) georef_layer_draw,
(VikLayerFuncChangeCoordMode) NULL,
+ (VikLayerFuncSetMenuItemsSelection) NULL,
+ (VikLayerFuncGetMenuItemsSelection) NULL,
+
(VikLayerFuncAddMenuItems) georef_layer_add_menu_items,
(VikLayerFuncSublayerAddMenuItems) NULL,
(VikLayerFuncSublayerRenameRequest) NULL,
(VikLayerFuncSublayerToggleVisible) NULL,
- (VikLayerFuncCopy) georef_layer_copy,
(VikLayerFuncMarshall) georef_layer_marshall,
(VikLayerFuncUnmarshall) georef_layer_unmarshall,
return vgl_type;
}
-static VikGeorefLayer *georef_layer_copy ( VikGeorefLayer *vgl, gpointer vp )
-{
- VikGeorefLayer *rv = georef_layer_new ();
- rv->corner = vgl->corner;
- rv->mpp_easting = vgl->mpp_easting;
- rv->mpp_northing = vgl->mpp_northing;
- rv->width = vgl->width;
- rv->height = vgl->height;
-
- if ( vgl->image )
- {
- rv->image = g_strdup ( vgl->image );
- georef_layer_load_image ( rv );
- }
- return rv;
-}
-
static void georef_layer_marshall( VikGeorefLayer *vgl, guint8 **data, gint *len )
{
vik_layer_marshall_params ( VIK_LAYER(vgl), data, len );
if (gx)
{
- g_warning ( "Couldn't open image file: %s", gx->message );
+ g_warning ( _("Couldn't open image file: %s"), gx->message );
g_error_free ( gx );
}
else
{
if (!fgets ( buffer, 1024, f ))
{
- a_dialog_error_msg ( VIK_GTK_WINDOW_FROM_WIDGET(widget), "Unexpected end of file reading World file." );
+ 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;
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 )
{
- a_dialog_error_msg ( VIK_GTK_WINDOW_FROM_WIDGET(pass_along[0]), "The World file you requested could not be opened for reading." );
+ a_dialog_error_msg ( VIK_GTK_WINDOW_FROM_WIDGET(pass_along[0]), _("The World file you requested could not be opened for reading.") );
return;
}
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;
}
}
}
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 )
{
- a_dialog_error_msg ( VIK_GTK_WINDOW_FROM_WIDGET(pass_along[0]), "The file you requested could not be opened for writing." );
+ a_dialog_error_msg ( VIK_GTK_WINDOW_FROM_WIDGET(pass_along[0]), _("The file you requested could not be opened for writing.") );
return;
}
else
{
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
/* returns TRUE if OK was pressed. */
static gboolean georef_layer_dialog ( VikGeorefLayer **vgl, gpointer vp, GtkWindow *w )
{
- GtkWidget *dialog = gtk_dialog_new_with_buttons ("Layer Properties",
+ GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Layer Properties"),
w,
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CANCEL,
GTK_RESPONSE_REJECT,
GTK_STOCK_OK,
GTK_RESPONSE_ACCEPT,
- 0 );
+ NULL );
GtkWidget *table, *wfp_hbox, *wfp_label, *wfp_button, *ce_label, *ce_spin, *cn_label, *cn_spin, *xlabel, *xspin, *ylabel, *yspin, *imagelabel, *imageentry;
GtkWidget *pass_along[4];
gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(dialog)->vbox), table, TRUE, TRUE, 0 );
wfp_hbox = gtk_hbox_new ( FALSE, 0 );
- wfp_label = gtk_label_new ( "World File Parameters:" );
- wfp_button = gtk_button_new_with_label ( "Load From File..." );
+ wfp_label = gtk_label_new ( _("World File Parameters:") );
+ wfp_button = gtk_button_new_with_label ( _("Load From File...") );
gtk_box_pack_start ( GTK_BOX(wfp_hbox), wfp_label, TRUE, TRUE, 0 );
gtk_box_pack_start ( GTK_BOX(wfp_hbox), wfp_button, FALSE, FALSE, 3 );
- ce_label = gtk_label_new ( "Corner pixel easting:" );
+ 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_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): ");
+ 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 ();
+ imagelabel = gtk_label_new ( _("Map Image:") );
+ imageentry = vik_file_entry_new (GTK_FILE_CHOOSER_ACTION_OPEN);
if (*vgl)
{
gtk_menu_shell_append ( GTK_MENU_SHELL(menu), item );
gtk_widget_show ( item );
- item = gtk_menu_item_new_with_label ( "Zoom to Fit Map" );
+ item = gtk_menu_item_new_with_label ( _("Zoom to Fit Map") );
g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(georef_layer_zoom_to_fit), pass_along );
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show ( item );
- item = gtk_menu_item_new_with_label ( "Goto Map Center" );
+ item = gtk_menu_item_new_with_label ( _("Goto Map Center") );
g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(georef_layer_goto_center), pass_along );
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show ( item );
- item = gtk_menu_item_new_with_label ( "Export to World File" );
+ item = gtk_menu_item_new_with_label ( _("Export to World File") );
g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(georef_layer_export_params), pass_along );
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_widget_show ( item );