]> git.street.me.uk Git - andy/viking.git/commitdiff
Add preference to support writing Waypoint symbol names in Title or lower case.
authorRob Norris <rw_norris@hotmail.com>
Fri, 22 Mar 2013 00:19:19 +0000 (00:19 +0000)
committerRob Norris <rw_norris@hotmail.com>
Sun, 24 Mar 2013 11:48:58 +0000 (11:48 +0000)
src/globals.c
src/globals.h
src/gpx.c

index 5938c7a4827ef99fdd05fa85c30a63b89cf4badc..84dc5d56b9451ffd187b6aa01041e3a0d1278780 100644 (file)
@@ -71,10 +71,13 @@ static VikLayerParam prefs7[] = {
 
 static gchar * params_kml_export_units[] = {"Metric", "Statute", "Nautical", NULL};
 static gchar * params_gpx_export_trk_sort[] = {N_("Alphabetical"), N_("Time"), NULL};
+static gchar * params_gpx_export_wpt_symbols[] = {N_("Title Case"), N_("Lowercase"), NULL};
 
 static VikLayerParam io_prefs[] = {
-  { VIK_LAYER_NUM_TYPES, VIKING_PREFERENCES_IO_NAMESPACE "kml_export_units", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, N_("KML File Export Units:"), VIK_LAYER_WIDGET_COMBOBOX, params_kml_export_units, NULL, NULL },
-  { VIK_LAYER_NUM_TYPES, VIKING_PREFERENCES_IO_NAMESPACE "gpx_export_track_sort", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, N_("GPX Track Order:"), VIK_LAYER_WIDGET_COMBOBOX, params_gpx_export_trk_sort, NULL, NULL },
+  { VIK_LAYER_NUM_TYPES, VIKING_PREFERENCES_IO_NAMESPACE "kml_export_units", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, N_("KML File Export Units:"), VIK_LAYER_WIDGET_COMBOBOX, params_kml_export_units, NULL, NULL, NULL },
+  { VIK_LAYER_NUM_TYPES, VIKING_PREFERENCES_IO_NAMESPACE "gpx_export_track_sort", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, N_("GPX Track Order:"), VIK_LAYER_WIDGET_COMBOBOX, params_gpx_export_trk_sort, NULL, NULL, NULL },
+  { VIK_LAYER_NUM_TYPES, VIKING_PREFERENCES_IO_NAMESPACE "gpx_export_wpt_sym_names", VIK_LAYER_PARAM_UINT, VIK_LAYER_GROUP_NONE, N_("GPX Waypoint Symbols:"), VIK_LAYER_WIDGET_COMBOBOX, params_gpx_export_wpt_symbols, NULL,
+      N_("Save GPX Waypoint Symbol names in the specified case. May be useful for compatibility with various devices"), NULL },
 };
 
 #ifndef WINDOWS
@@ -126,6 +129,9 @@ void a_vik_preferences_init ()
   tmp.u = VIK_GPX_EXPORT_TRK_SORT_TIME;
   a_preferences_register(&io_prefs[1], tmp, VIKING_PREFERENCES_IO_GROUP_KEY);
 
+  tmp.u = VIK_GPX_EXPORT_WPT_SYM_NAME_TITLECASE;
+  a_preferences_register(&io_prefs[2], tmp, VIKING_PREFERENCES_IO_GROUP_KEY);
+
 #ifndef WINDOWS
   tmp.s = "xdg-open";
   a_preferences_register(&io_prefs_non_windows[0], tmp, VIKING_PREFERENCES_IO_GROUP_KEY);
@@ -204,6 +210,13 @@ vik_gpx_export_trk_sort_t a_vik_get_gpx_export_trk_sort ( )
   return sort;
 }
 
+vik_gpx_export_wpt_sym_name_t a_vik_gpx_export_wpt_sym_name ( )
+{
+  gboolean val;
+  val = a_preferences_get(VIKING_PREFERENCES_IO_NAMESPACE "gpx_export_wpt_sym_names")->u;
+  return val;
+}
+
 #ifndef WINDOWS
 const gchar* a_vik_get_image_viewer ( )
 {
index 2d0fbe4a5b47eae3d2ba4bff7dab109f01400725..61bd7ef5601f449215d0630d45519b18ca23e105 100644 (file)
@@ -140,6 +140,13 @@ typedef enum {
 
 vik_gpx_export_trk_sort_t a_vik_get_gpx_export_trk_sort ( );
 
+typedef enum {
+  VIK_GPX_EXPORT_WPT_SYM_NAME_TITLECASE,
+  VIK_GPX_EXPORT_WPT_SYM_NAME_LOWERCASE,
+} vik_gpx_export_wpt_sym_name_t;
+
+vik_gpx_export_wpt_sym_name_t a_vik_gpx_export_wpt_sym_name ( );
+
 #ifndef WINDOWS
 /* Windows automatically uses the system defined viewer
    ATM for other systems need to specify the program to use */
index aa7372d9c7951548a56632292c1cd058e13595eb..37dc1670b801e0ef3169e24ddd3906dc00361b78 100644 (file)
--- a/src/gpx.c
+++ b/src/gpx.c
@@ -706,7 +706,14 @@ static void gpx_write_waypoint ( VikWaypoint *wp, GpxWritingContext *context )
   if ( wp->symbol ) 
   {
     tmp = entitize(wp->symbol);
-    fprintf ( f, "  <sym>%s</sym>\n", tmp);
+    if ( a_vik_gpx_export_wpt_sym_name ( ) ) {
+       // Lowercase the symbol name
+       gchar *tmp2 = g_utf8_strdown ( tmp, -1 );
+       fprintf ( f, "  <sym>%s</sym>\n",  tmp2 );
+       g_free ( tmp2 );
+    }
+    else
+      fprintf ( f, "  <sym>%s</sym>\n", tmp);
     g_free ( tmp );
   }