#include <math.h>
#include <string.h>
#include <ctype.h>
+#include <glib.h>
+#include <glib/gstdio.h>
#include <glib/gprintf.h>
#include <glib/gi18n.h>
-#ifdef WINDOWS
-/* TODO IMPORTANT: mkdir for windows header? is it called 'mkdir' */
-#define make_dir(dir) mkdir(dir)
-#else
-#include <sys/types.h>
-#include <sys/stat.h>
-#define make_dir(dir) mkdir(dir,0777)
-#endif
#define VIKING_WINDOW_WIDTH 1000
#define VIKING_WINDOW_HEIGHT 800
static void toolbox_activate(toolbox_tools_t *vt, const gchar *tool_name);
static const GdkCursor *toolbox_get_cursor(toolbox_tools_t *vt, const gchar *tool_name);
static void toolbox_click (toolbox_tools_t *vt, GdkEventButton *event);
-static void toolbox_move (toolbox_tools_t *vt, GdkEventButton *event);
+static void toolbox_move (toolbox_tools_t *vt, GdkEventMotion *event);
static void toolbox_release (toolbox_tools_t *vt, GdkEventButton *event);
gtk_window_set_default_size ( GTK_WINDOW(vw), VIKING_WINDOW_WIDTH, VIKING_WINDOW_HEIGHT);
hpaned = gtk_hpaned_new ();
- gtk_paned_add1 ( GTK_PANED(hpaned), GTK_WIDGET (vw->viking_vlp) );
- gtk_paned_add2 ( GTK_PANED(hpaned), GTK_WIDGET (vw->viking_vvp) );
+ gtk_paned_pack1 ( GTK_PANED(hpaned), GTK_WIDGET (vw->viking_vlp), FALSE, FALSE );
+ gtk_paned_pack2 ( GTK_PANED(hpaned), GTK_WIDGET (vw->viking_vvp), TRUE, TRUE );
/* This packs the button into the window (a gtk container). */
gtk_box_pack_start (GTK_BOX(main_vbox), hpaned, TRUE, TRUE, 0);
void vik_window_set_redraw_trigger(VikLayer *vl)
{
VikWindow *vw = VIK_WINDOW(VIK_GTK_WINDOW_FROM_LAYER(vl));
- vw->trigger = vl;
+ if (NULL != vw)
+ vw->trigger = vl;
}
static void window_configure_event ( VikWindow *vw )
static VikCoord coord;
static struct UTM utm;
static struct LatLon ll;
- static char pointer_buf[36];
+ #define BUFFER_SIZE 50
+ static char pointer_buf[BUFFER_SIZE];
+ gchar *lat = NULL, *lon = NULL;
gint16 alt;
gdouble zoom;
VikDemInterpol interpol_method;
vik_viewport_screen_to_coord ( vw->viking_vvp, event->x, event->y, &coord );
vik_coord_to_utm ( &coord, &utm );
a_coords_utm_to_latlon ( &utm, &ll );
+ a_coords_latlon_to_string ( &ll, &lat, &lon );
/* Change interpolate method according to scale */
zoom = vik_viewport_get_zoom(vw->viking_vvp);
if (zoom > 2.0)
else
interpol_method = VIK_DEM_INTERPOL_BEST;
if ((alt = a_dems_get_elev_by_coord(&coord, interpol_method)) != VIK_DEM_INVALID_ELEVATION)
- g_snprintf ( pointer_buf, 36, _("Cursor: %f %f %dm"), ll.lat, ll.lon, alt );
+ g_snprintf ( pointer_buf, BUFFER_SIZE, _("%s %s %dm"), lat, lon, alt );
else
- g_snprintf ( pointer_buf, 36, _("Cursor: %f %f"), ll.lat, ll.lon );
+ g_snprintf ( pointer_buf, BUFFER_SIZE, _("%s %s"), lat, lon );
+ g_free (lat);
+ lat = NULL;
+ g_free (lon);
+ lon = NULL;
vik_statusbar_set_message ( vw->viking_vs, 4, pointer_buf );
vik_window_pan_move ( vw, event );
VikCoord coord;
gchar *temp;
if ( event->button == 1 ) {
+ gchar *lat=NULL, *lon=NULL;
vik_viewport_screen_to_coord ( s->vvp, (gint) event->x, (gint) event->y, &coord );
vik_coord_to_latlon ( &coord, &ll );
+ a_coords_latlon_to_string ( &ll, &lat, &lon );
if ( s->has_oldcoord ) {
- temp = g_strdup_printf ( "%f %f DIFF %f meters", ll.lat, ll.lon, vik_coord_diff( &coord, &(s->oldcoord) ) );
+ temp = g_strdup_printf ( "%s %s DIFF %f meters", lat, lon, vik_coord_diff( &coord, &(s->oldcoord) ) );
s->has_oldcoord = FALSE;
}
else {
- temp = g_strdup_printf ( "%f %f", ll.lat, ll.lon );
+ temp = g_strdup_printf ( "%s %s", lat, lon );
s->has_oldcoord = TRUE;
}
return VIK_LAYER_TOOL_ACK;
}
-static VikLayerToolFuncStatus ruler_move (VikLayer *vl, GdkEventButton *event, ruler_tool_state_t *s)
+static VikLayerToolFuncStatus ruler_move (VikLayer *vl, GdkEventMotion *event, ruler_tool_state_t *s)
{
VikViewport *vvp = s->vvp;
VikWindow *vw = s->vw;
if ( s->has_oldcoord ) {
int oldx, oldy, w1, h1, w2, h2;
static GdkPixmap *buf = NULL;
+ gchar *lat=NULL, *lon=NULL;
w1 = vik_viewport_get_width(vvp);
h1 = vik_viewport_get_height(vvp);
if (!buf) {
g_idle_add_full (G_PRIORITY_HIGH_IDLE + 10, draw_buf, pass_along, NULL);
draw_buf_done = FALSE;
}
-
- temp = g_strdup_printf ( "%f %f DIFF %f meters", ll.lat, ll.lon, vik_coord_diff( &coord, &(s->oldcoord) ) );
+ a_coords_latlon_to_string(&ll, &lat, &lon);
+ temp = g_strdup_printf ( "%s %s DIFF %f meters", lat, lon, vik_coord_diff( &coord, &(s->oldcoord) ) );
vik_statusbar_set_message ( vw->viking_vs, 3, temp );
g_free ( temp );
}
(VikToolActivationFunc) NULL,
(VikToolActivationFunc) ruler_deactivate,
(VikToolMouseFunc) ruler_click,
- (VikToolMouseFunc) ruler_move,
+ (VikToolMouseMoveFunc) ruler_move,
(VikToolMouseFunc) ruler_release,
NULL,
GDK_CURSOR_IS_PIXMAP,
- &cursor_ruler };
+ &cursor_ruler_pixbuf };
/*** end ruler code ********************************************************/
return VIK_LAYER_TOOL_ACK;
}
-static VikLayerToolFuncStatus zoomtool_move (VikLayer *vl, GdkEventButton *event, VikViewport *vvp)
+static VikLayerToolFuncStatus zoomtool_move (VikLayer *vl, GdkEventMotion *event, VikViewport *vvp)
{
return VIK_LAYER_TOOL_ACK;
}
(VikToolActivationFunc) NULL,
(VikToolActivationFunc) NULL,
(VikToolMouseFunc) zoomtool_click,
- (VikToolMouseFunc) zoomtool_move,
+ (VikToolMouseMoveFunc) zoomtool_move,
(VikToolMouseFunc) zoomtool_release,
NULL,
GDK_CURSOR_IS_PIXMAP,
- &cursor_zoom };
+ &cursor_zoom_pixbuf };
/*** end zoom code ********************************************************/
/********************************************************************************
return VIK_LAYER_TOOL_ACK;
}
-static VikLayerToolFuncStatus pantool_move (VikLayer *vl, GdkEventButton *event, VikWindow *vw)
+static VikLayerToolFuncStatus pantool_move (VikLayer *vl, GdkEventMotion *event, VikWindow *vw)
{
vik_window_pan_move ( vw, event );
return VIK_LAYER_TOOL_ACK;
(VikToolActivationFunc) NULL,
(VikToolActivationFunc) NULL,
(VikToolMouseFunc) pantool_click,
- (VikToolMouseFunc) pantool_move,
+ (VikToolMouseMoveFunc) pantool_move,
(VikToolMouseFunc) pantool_release,
NULL,
GDK_FLEUR };
a_dialog_info_msg ( GTK_WINDOW(vw), _("You must select a layer to delete.") );
}
+static void view_side_panel_cb ( GtkAction *a, VikWindow *vw )
+{
+ GtkWidget *check_box = gtk_ui_manager_get_widget ( vw->uim, "/ui/MainMenu/View/ViewSidePanel" );
+ g_assert(check_box);
+ gboolean state = gtk_check_menu_item_get_active ( GTK_CHECK_MENU_ITEM(check_box));
+ if ( state )
+ gtk_widget_show(GTK_WIDGET(vw->viking_vlp));
+ else
+ gtk_widget_hide(GTK_WIDGET(vw->viking_vlp));
+}
+
/***************************************
** tool management routines
**
}
}
-static void toolbox_move (toolbox_tools_t *vt, GdkEventButton *event)
+static void toolbox_move (toolbox_tools_t *vt, GdkEventMotion *event)
{
VikLayer *vl = vik_layers_panel_get_selected ( vt->vw->viking_vlp );
if (vt->active_tool != -1 && vt->tools[vt->active_tool].ti.move) {
GtkWidget *mode_button;
gchar *buttonname;
switch ( mode ) {
- case VIK_VIEWPORT_DRAWMODE_UTM: buttonname = "/ui/MainMenu/View/ModeUTM"; break;
+#ifdef VIK_CONFIG_EXPEDIA
case VIK_VIEWPORT_DRAWMODE_EXPEDIA: buttonname = "/ui/MainMenu/View/ModeExpedia"; break;
- case VIK_VIEWPORT_DRAWMODE_GOOGLE: buttonname = "/ui/MainMenu/View/ModeGoogle"; break;
+#endif
case VIK_VIEWPORT_DRAWMODE_MERCATOR: buttonname = "/ui/MainMenu/View/ModeMercator"; break;
- default: buttonname = "/ui/MainMenu/View/ModeKH";
+ default: buttonname = "/ui/MainMenu/View/ModeUTM";
}
mode_button = gtk_ui_manager_get_widget ( vw->uim, buttonname );
g_assert ( mode_button );
while ( gtk_dialog_run ( GTK_DIALOG(vw->save_dia) ) == GTK_RESPONSE_ACCEPT )
{
fn = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(vw->save_dia) );
- if ( access ( fn, F_OK ) != 0 || a_dialog_overwrite ( GTK_WINDOW(vw->save_dia), _("The file \"%s\" exists, do you wish to overwrite it?"), a_file_basename ( fn ) ) )
+ if ( g_file_test ( fn, G_FILE_TEST_EXISTS ) == FALSE || a_dialog_overwrite ( GTK_WINDOW(vw->save_dia), _("The file \"%s\" exists, do you wish to overwrite it?"), a_file_basename ( fn ) ) )
{
window_set_filename ( vw, fn );
rv = window_save ( vw );
g_assert ( vik_viewport_get_coord_mode ( vw->viking_vvp ) == VIK_COORD_UTM );
- make_dir(fn);
+ g_mkdir(fn,0777);
utm_orig = *((const struct UTM *)vik_viewport_get_center ( vw->viking_vvp ));
while ( gtk_dialog_run ( GTK_DIALOG(vw->save_img_dia) ) == GTK_RESPONSE_ACCEPT )
{
fn = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(vw->save_img_dia) );
- if ( access ( fn, F_OK ) != 0 || a_dialog_overwrite ( GTK_WINDOW(vw->save_img_dia), _("The file \"%s\" exists, do you wish to overwrite it?"), a_file_basename ( fn ) ) )
+ if ( g_file_test ( fn, G_FILE_TEST_EXISTS ) == FALSE || a_dialog_overwrite ( GTK_WINDOW(vw->save_img_dia), _("The file \"%s\" exists, do you wish to overwrite it?"), a_file_basename ( fn ) ) )
{
draw_to_image_file ( vw, fn, TRUE );
break;
else if (!strcmp(gtk_action_get_name(a), "ModeExpedia")) {
drawmode = VIK_VIEWPORT_DRAWMODE_EXPEDIA;
}
- else if (!strcmp(gtk_action_get_name(a), "ModeGoogle")) {
- drawmode = VIK_VIEWPORT_DRAWMODE_GOOGLE;
- }
- else if (!strcmp(gtk_action_get_name(a), "ModeKH")) {
- drawmode = VIK_VIEWPORT_DRAWMODE_KH;
- }
else if (!strcmp(gtk_action_get_name(a), "ModeMercator")) {
drawmode = VIK_VIEWPORT_DRAWMODE_MERCATOR;
}
{ "Exit", GTK_STOCK_QUIT, N_("E_xit"), "<control>W", N_("Exit the program"), (GCallback)window_close },
{ "SaveExit", GTK_STOCK_QUIT, N_("Save and Exit"), NULL, N_("Save and Exit the program"), (GCallback)save_file_and_exit },
- { "GoogleMapsSearch", GTK_STOCK_GO_FORWARD, N_("Go To Google Maps location"), NULL, N_("Go to address/place using Google Maps search"), (GCallback)goto_address },
+ { "GoogleMapsSearch", GTK_STOCK_JUMP_TO, N_("Go To Google Maps location"), NULL, N_("Go to address/place using Google Maps search"), (GCallback)goto_address },
{ "GotoLL", GTK_STOCK_QUIT, N_("_Go to Lat\\/Lon..."), NULL, N_("Go to arbitrary lat\\/lon coordinate"), (GCallback)draw_goto_cb },
{ "GotoUTM", GTK_STOCK_QUIT, N_("Go to UTM..."), NULL, N_("Go to arbitrary UTM coordinate"), (GCallback)draw_goto_cb },
{ "SetBGColor",GTK_STOCK_SELECT_COLOR, N_("Set Background Color..."), NULL, NULL, (GCallback)set_bg_color },
static GtkRadioActionEntry mode_entries[] = {
{ "ModeUTM", NULL, N_("_UTM Mode"), "<control>u", NULL, 0 },
{ "ModeExpedia", NULL, N_("_Expedia Mode"), "<control>e", NULL, 1 },
- { "ModeGoogle", NULL, N_("_Old Google Mode"), "<control>o", NULL, 2 },
- { "ModeKH", NULL, N_("Old _KH Mode"), "<control>k", NULL, 3 },
- { "ModeMercator", NULL, N_("_Google Mode"), "<control>g", NULL, 4 }
+ { "ModeMercator", NULL, N_("_Mercator Mode"), "<control>g", NULL, 4 }
};
static GtkRadioActionEntry tool_entries[] = {
};
static GtkToggleActionEntry toggle_entries[] = {
- { "ShowScale", NULL, N_("Show Scale"), NULL, NULL, (GCallback)set_draw_scale, TRUE },
- { "ShowCenterMark", NULL, N_("Show Center Mark"), NULL, NULL, (GCallback)set_draw_centermark, TRUE },
- { "FullScreen", NULL, N_("Full Screen"), "F11", NULL, (GCallback)full_screen_cb, FALSE },
+ { "ShowScale", NULL, N_("Show Scale"), NULL, N_("Show Scale"), (GCallback)set_draw_scale, TRUE },
+ { "ShowCenterMark", NULL, N_("Show Center Mark"), NULL, N_("Show Center Mark"), (GCallback)set_draw_centermark, TRUE },
+ { "FullScreen", GTK_STOCK_FULLSCREEN, N_("Full Screen"), "F11", N_("Activate full screen mode"), (GCallback)full_screen_cb, FALSE },
+ { "ViewSidePanel", GTK_STOCK_INDEX, N_("Show Side Panel"), "F9", N_("Show Side Panel"), (GCallback)view_side_panel_cb, TRUE },
};
#include "menu.xml.h"
const GdkPixdata *data;
gchar *stock_id;
} stock_icons[] = {
- { &addtr_18, "Create Track" },
- { &begintr_18, "Begin Track" },
- { &edtr_18, "Edit Trackpoint" },
- { &addwp_18, "Create Waypoint" },
- { &edwp_18, "Edit Waypoint" },
- { &iscissors_18, "Magic Scissors" },
- { &mover_22, "vik-icon-pan" },
- { &zoom_18, "vik-icon-zoom" },
- { &ruler_18, "vik-icon-ruler" },
- { &geozoom_18, "Georef Zoom Tool" },
- { &geomove_18, "Georef Move Map" },
- { &mapdl_18, "Maps Download" },
- { &demdl_18, "DEM Download/Import" },
- { &showpic_18, "Show Picture" },
+ { &begintr_18_pixbuf, "Begin Track" },
+ { &iscissors_18_pixbuf, "Magic Scissors" },
+ { &mover_22_pixbuf, "vik-icon-pan" },
+ { &demdl_18_pixbuf, "DEM Download/Import" },
+ { &showpic_18_pixbuf, "Show Picture" },
+ { &addtr_18_pixbuf, "Create Track" },
+ { &edtr_18_pixbuf, "Edit Trackpoint" },
+ { &addwp_18_pixbuf, "Create Waypoint" },
+ { &edwp_18_pixbuf, "Edit Waypoint" },
+ { &zoom_18_pixbuf, "vik-icon-zoom" },
+ { &ruler_18_pixbuf, "vik-icon-ruler" },
+ { &geozoom_18_pixbuf, "Georef Zoom Tool" },
+ { &geomove_18_pixbuf, "Georef Move Map" },
+ { &mapdl_18_pixbuf, "Maps Download" },
+ { &showpic_18_pixbuf, "Show Picture" },
};
static gint n_stock_icons = G_N_ELEMENTS (stock_icons);