#include "viktrwlayer_propwin.h"
#include "viktrwlayer_analysis.h"
#include "viktrwlayer_tracklist.h"
+#include "viktrwlayer_waypointlist.h"
#ifdef VIK_CONFIG_GEOTAG
#include "viktrwlayer_geotag.h"
#include "geotag_exif.h"
static void trw_layer_draw_track_cb ( const gpointer id, VikTrack *track, struct DrawingParams *dp );
static void trw_layer_draw_waypoint ( const gpointer id, VikWaypoint *wp, struct DrawingParams *dp );
-static void trw_layer_calculate_bounds_waypoints ( VikTrwLayer *vtl );
-
static void goto_coord ( gpointer *vlp, gpointer vvp, gpointer vl, const VikCoord *coord );
static void trw_layer_goto_track_startpoint ( gpointer pass_along[6] );
static void trw_layer_goto_track_endpoint ( gpointer pass_along[6] );
static void trw_layer_track_list_dialog_single ( gpointer pass_along[6] );
static void trw_layer_track_list_dialog ( gpointer lav[2] );
+static void trw_layer_waypoint_list_dialog ( gpointer lav[2] );
// Specific route versions:
// Most track handling functions can handle operating on the route list
/*
* Can accept a null symbol, and may return null value
*/
-static GdkPixbuf* get_wp_sym_small ( gchar *symbol )
+GdkPixbuf* get_wp_sym_small ( gchar *symbol )
{
GdkPixbuf* wp_icon = a_get_wp_sym (symbol);
// ATM a_get_wp_sym returns a cached icon, with the size dependent on the preferences.
gboolean need2free = FALSE;
if ( !a_settings_get_string ( VIK_SETTINGS_TRKPT_SELECTED_STATUSBAR_FORMAT, &statusbar_format_code ) ) {
// Otherwise use default
- statusbar_format_code = g_strdup ( "KATDN" );
+ statusbar_format_code = g_strdup ( "KEATDN" );
need2free = TRUE;
}
g_free ( auto_save_name );
}
-typedef struct {
- VikWaypoint *wp; // input
- gpointer uuid; // output
-} wpu_udata;
-
-static gboolean trw_layer_waypoint_find_uuid ( const gpointer id, const VikWaypoint *wp, gpointer udata )
+gboolean trw_layer_waypoint_find_uuid ( const gpointer id, const VikWaypoint *wp, gpointer udata )
{
wpu_udata *user_data = udata;
if ( wp == user_data->wp ) {
vtl->has_verified_thumbnails = FALSE;
trw_layer_geotag_dialog ( VIK_GTK_WINDOW_FROM_LAYER(vtl),
- vtl,
- track,
- track->name );
+ vtl,
+ NULL,
+ track );
+}
+
+static void trw_layer_geotagging_waypoint ( gpointer pass_along[6] )
+{
+ VikTrwLayer *vtl = VIK_TRW_LAYER(pass_along[0]);
+ VikWaypoint *wpt = g_hash_table_lookup ( VIK_TRW_LAYER(pass_along[0])->waypoints, pass_along[3] );
+
+ trw_layer_geotag_dialog ( VIK_GTK_WINDOW_FROM_LAYER(vtl),
+ vtl,
+ wpt,
+ NULL );
}
static void trw_layer_geotagging ( gpointer lav[2] )
vtl->has_verified_thumbnails = FALSE;
trw_layer_geotag_dialog ( VIK_GTK_WINDOW_FROM_LAYER(vtl),
- vtl,
- NULL,
- NULL);
+ vtl,
+ NULL,
+ NULL );
}
#endif
gtk_menu_shell_append ( GTK_MENU_SHELL(menu), item );
gtk_widget_show ( item );
gtk_widget_set_sensitive ( item, (gboolean)(g_hash_table_size (vtl->tracks)+g_hash_table_size (vtl->routes)) );
+
+ item = gtk_image_menu_item_new_with_mnemonic ( _("_Waypoint List...") );
+ gtk_image_menu_item_set_image ( (GtkImageMenuItem*)item, gtk_image_new_from_stock (GTK_STOCK_INDEX, GTK_ICON_SIZE_MENU) );
+ g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(trw_layer_waypoint_list_dialog), pass_along );
+ gtk_menu_shell_append ( GTK_MENU_SHELL(menu), item );
+ gtk_widget_show ( item );
+ gtk_widget_set_sensitive ( item, (gboolean)(g_hash_table_size (vtl->waypoints)) );
}
// Fake Waypoint UUIDs vi simple increasing integer
g_hash_table_insert ( vtl->tracks, GUINT_TO_POINTER(tr_uuid), t );
- trw_layer_update_treeview ( vtl, t, GUINT_TO_POINTER(tr_uuid) );
+ trw_layer_update_treeview ( vtl, t );
}
// Fake Route UUIDs vi simple increasing integer
g_hash_table_insert ( vtl->routes, GUINT_TO_POINTER(rt_uuid), t );
- trw_layer_update_treeview ( vtl, t, GUINT_TO_POINTER(rt_uuid) );
+ trw_layer_update_treeview ( vtl, t );
}
/* to be called whenever a track has been deleted or may have been changed. */
/**
* Rename waypoint and maintain corresponding name of waypoint in the treeview
*/
-static void trw_layer_waypoint_rename ( VikTrwLayer *vtl, VikWaypoint *wp, const gchar *new_name )
+void trw_layer_waypoint_rename ( VikTrwLayer *vtl, VikWaypoint *wp, const gchar *new_name )
{
vik_waypoint_set_name ( wp, new_name );
}
}
+/**
+ * Maintain icon of waypoint in the treeview
+ */
+void trw_layer_waypoint_reset_icon ( VikTrwLayer *vtl, VikWaypoint *wp )
+{
+ // update the treeview
+ wpu_udata udataU;
+ udataU.wp = wp;
+ udataU.uuid = NULL;
+
+ // Need key of it for treeview update
+ gpointer *wpf = g_hash_table_find ( vtl->waypoints, (GHRFunc) trw_layer_waypoint_find_uuid, &udataU );
+
+ if ( wpf && udataU.uuid ) {
+ GtkTreeIter *it = g_hash_table_lookup ( vtl->waypoints_iters, udataU.uuid );
+
+ if ( it ) {
+ vik_treeview_item_set_icon ( VIK_LAYER(vtl)->vt, it, get_wp_sym_small (wp->symbol) );
+ }
+ }
+}
+
static void trw_layer_properties_item ( gpointer pass_along[7] )
{
VikTrwLayer *vtl = VIK_TRW_LAYER(pass_along[0]);
tr,
pass_along[1], /* vlp */
pass_along[5], /* vvp */
- pass_along[6], /* iter */
FALSE );
}
}
trk,
pass_along[1], // vlp
pass_along[5], // vvp
- pass_along[6], // iter
TRUE );
}
}
/*
* Update the treeview of the track id - primarily to update the icon
*/
-void trw_layer_update_treeview ( VikTrwLayer *vtl, VikTrack *trk, gpointer *trk_id )
+void trw_layer_update_treeview ( VikTrwLayer *vtl, VikTrack *trk )
{
trku_udata udata;
udata.trk = trk;
vik_layer_emit_update ( VIK_LAYER(vtl) );
}
+/**
+ * vik_trw_layer_build_waypoint_list_t:
+ *
+ * Helper function to construct a list of #vik_trw_waypoint_list_t
+ */
+GList *vik_trw_layer_build_waypoint_list_t ( VikTrwLayer *vtl, GList *waypoints )
+{
+ GList *waypoints_and_layers = NULL;
+ // build waypoints_and_layers list
+ while ( waypoints ) {
+ vik_trw_waypoint_list_t *vtdl = g_malloc (sizeof(vik_trw_waypoint_list_t));
+ vtdl->wpt = VIK_WAYPOINT(waypoints->data);
+ vtdl->vtl = vtl;
+ waypoints_and_layers = g_list_prepend ( waypoints_and_layers, vtdl );
+ waypoints = g_list_next ( waypoints );
+ }
+ return waypoints_and_layers;
+}
+
+/**
+ * trw_layer_create_waypoint_list:
+ *
+ * Create the latest list of waypoints with the associated layer(s)
+ * Although this will always be from a single layer here
+ */
+static GList* trw_layer_create_waypoint_list ( VikLayer *vl, gpointer user_data )
+{
+ VikTrwLayer *vtl = VIK_TRW_LAYER(vl);
+ GList *waypoints = g_hash_table_get_values ( vik_trw_layer_get_waypoints(vtl) );
+
+ return vik_trw_layer_build_waypoint_list_t ( vtl, waypoints );
+}
+
/**
* trw_layer_analyse_close:
*
if ( subtype == VIK_TRW_LAYER_SUBLAYER_WAYPOINT )
{
- gboolean separator_created = FALSE;
+ // Always create separator as now there is always at least the transform menu option
+ item = gtk_menu_item_new ();
+ gtk_menu_shell_append ( GTK_MENU_SHELL(menu), item );
+ gtk_widget_show ( item );
/* could be a right-click using the tool */
if ( vlp != NULL ) {
- item = gtk_menu_item_new ();
- gtk_menu_shell_append ( GTK_MENU_SHELL(menu), item );
- gtk_widget_show ( item );
-
- separator_created = TRUE;
-
item = gtk_image_menu_item_new_with_mnemonic ( _("_Goto") );
- gtk_image_menu_item_set_image ( (GtkImageMenuItem*)item, gtk_image_new_from_stock (GTK_STOCK_JUMP_TO, GTK_ICON_SIZE_MENU) );
+ gtk_image_menu_item_set_image ( (GtkImageMenuItem*)item, gtk_image_new_from_stock (GTK_STOCK_JUMP_TO, GTK_ICON_SIZE_MENU) );
g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(trw_layer_goto_waypoint), pass_along );
gtk_menu_shell_append ( GTK_MENU_SHELL(menu), item );
gtk_widget_show ( item );
if ( wp && wp->name ) {
if ( is_valid_geocache_name ( wp->name ) ) {
-
- if ( !separator_created ) {
- item = gtk_menu_item_new ();
- gtk_menu_shell_append ( GTK_MENU_SHELL(menu), item );
- gtk_widget_show ( item );
- separator_created = TRUE;
- }
-
item = gtk_menu_item_new_with_mnemonic ( _("_Visit Geocache Webpage") );
g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(trw_layer_waypoint_gc_webpage), pass_along );
gtk_menu_shell_append ( GTK_MENU_SHELL(menu), item );
gtk_widget_show ( item );
}
+#ifdef VIK_CONFIG_GEOTAG
+ item = gtk_menu_item_new_with_mnemonic ( _("Geotag _Images...") );
+ g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(trw_layer_geotagging_waypoint), pass_along );
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ gtk_widget_set_tooltip_text (item, _("Geotag multiple images against this waypoint"));
+ gtk_widget_show ( item );
+#endif
}
if ( wp && wp->image )
{
- if ( !separator_created ) {
- item = gtk_menu_item_new ();
- gtk_menu_shell_append ( GTK_MENU_SHELL(menu), item );
- gtk_widget_show ( item );
- separator_created = TRUE;
- }
-
// Set up image paramater
pass_along[5] = wp->image;
gtk_widget_show ( item );
}
}
-
}
}
g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(trw_layer_waypoints_visibility_toggle), pass_along );
gtk_menu_shell_append ( GTK_MENU_SHELL(vis_submenu), item );
gtk_widget_show ( item );
+
+ item = gtk_image_menu_item_new_with_mnemonic ( _("_List Waypoints...") );
+ gtk_image_menu_item_set_image ( (GtkImageMenuItem*)item, gtk_image_new_from_stock (GTK_STOCK_INDEX, GTK_ICON_SIZE_MENU) );
+ g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(trw_layer_waypoint_list_dialog), pass_along );
+ gtk_menu_shell_append ( GTK_MENU_SHELL(menu), item );
}
if ( subtype == VIK_TRW_LAYER_SUBLAYER_TRACKS )
gtk_image_menu_item_set_image ( (GtkImageMenuItem*)item, gtk_image_new_from_stock (GTK_STOCK_INDEX, GTK_ICON_SIZE_MENU) );
g_signal_connect_swapped ( G_OBJECT(item), "activate", G_CALLBACK(trw_layer_track_list_dialog_single), pass_along );
gtk_menu_shell_append ( GTK_MENU_SHELL(menu), item );
-
gtk_widget_show ( item );
item = gtk_menu_item_new_with_mnemonic ( _("_Statistics") );
VIK_TRACK(value)->has_color = TRUE;
}
- trw_layer_update_treeview ( vtl, VIK_TRACK(value), key );
+ trw_layer_update_treeview ( vtl, VIK_TRACK(value) );
ii++;
if (ii > VIK_TRW_LAYER_TRACK_GCS)
VIK_TRACK(value)->has_color = TRUE;
}
- trw_layer_update_treeview ( vtl, VIK_TRACK(value), key );
+ trw_layer_update_treeview ( vtl, VIK_TRACK(value) );
ii = !ii;
}
* (Re)Calculate the bounds of the waypoints in this layer,
* This should be called whenever waypoints are changed
*/
-static void trw_layer_calculate_bounds_waypoints ( VikTrwLayer *vtl )
+void trw_layer_calculate_bounds_waypoints ( VikTrwLayer *vtl )
{
struct LatLon topleft = { 0.0, 0.0 };
struct LatLon bottomright = { 0.0, 0.0 };
vik_trw_layer_track_list_show_dialog ( title, VIK_LAYER(vtl), NULL, trw_layer_create_track_list_both, FALSE );
g_free ( title );
}
+
+static void trw_layer_waypoint_list_dialog ( gpointer lav[2] )
+{
+ VikTrwLayer *vtl = VIK_TRW_LAYER(lav[0]);
+ //VikLayersPanel *vlp = VIK_LAYERS_PANEL(lav[1]);
+
+ gchar *title = g_strdup_printf ( _("%s: Waypoint List"), VIK_LAYER(vtl)->name );
+ vik_trw_layer_waypoint_list_show_dialog ( title, VIK_LAYER(vtl), NULL, trw_layer_create_waypoint_list, FALSE );
+ g_free ( title );
+}