]> git.street.me.uk Git - andy/viking.git/blobdiff - src/preferences.c
[I18N] Mark translatable string
[andy/viking.git] / src / preferences.c
index 65cacc50a04e86faf2b27bb44f443f47125af84c..6558693825160cd332428363ad49cbd6187279e6 100644 (file)
@@ -1,3 +1,23 @@
+/*
+ * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
+ *
+ * Copyright (C) 2003-2007, Evan Battaglia <gtoevan@gmx.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
 #include <gtk/gtk.h>
 #include <glib/gi18n.h>
 #include <string.h>
@@ -5,6 +25,7 @@
 #include <stdio.h>
 #include <glib/gstdio.h>
 #include "preferences.h"
+#include "dir.h"
 #include "file.h"
 
 // TODO: register_group
@@ -42,7 +63,7 @@ static void preferences_groups_uninit()
 void a_preferences_register_group ( const gchar *key, const gchar *name )
 {
   if ( g_hash_table_lookup ( groups_keys_to_indices, key ) )
-    g_error("Duplicate preferences group keys");
+    g_critical("Duplicate preferences group keys");
   else {
     g_ptr_array_add ( groups_names, g_strdup(name) );
     g_hash_table_insert ( groups_keys_to_indices, g_strdup(key), GINT_TO_POINTER ( (gint) groups_names->len ) ); /* index + 1 */
@@ -82,7 +103,7 @@ void layer_typed_param_data_free(gpointer p)
      * by the layer -- i.e. free'd by the layer.
      */
     case VIK_LAYER_PARAM_STRING_LIST:
-      g_error ( "Param strings not implemented in preferences"); //fake it
+      g_critical ( "Param strings not implemented in preferences"); //fake it
       break;
   }
   g_free ( val );
@@ -105,7 +126,7 @@ VikLayerTypedParamData *layer_typed_param_data_copy_from_data(guint8 type, VikLa
      * by the layer -- i.e. free'd by the layer.
      */
     case VIK_LAYER_PARAM_STRING_LIST:
-      g_error ( "Param strings not implemented in preferences"); //fake it
+      g_critical ( "Param strings not implemented in preferences"); //fake it
       break;
   }
   return newval;
@@ -169,7 +190,8 @@ static gboolean preferences_load_from_file()
     gchar *key, *val;
     VikLayerTypedParamData *oldval, *newval;
     while ( ! feof (f) ) {
-      fgets(buf,sizeof(buf),f);
+      if (fgets(buf,sizeof(buf),f) == NULL)
+        break;
       if ( preferences_load_parse_param(buf, &key, &val ) ) {
         // if it's not in there, ignore it
         oldval = g_hash_table_lookup ( values, key );
@@ -181,7 +203,7 @@ static gboolean preferences_load_from_file()
         // otherwise change it (you know the type!)
         // if it's a string list do some funky stuff ... yuck... not yet.
         if ( oldval->type == VIK_LAYER_PARAM_STRING_LIST )
-          g_error ( "Param strings not implemented in preferences"); // fake it
+          g_critical ( "Param strings not implemented in preferences"); // fake it
 
         newval = layer_data_typed_param_copy_from_string ( oldval->type, val );
         g_hash_table_insert ( values, key, newval );
@@ -201,7 +223,7 @@ static gboolean preferences_load_from_file()
 static void preferences_run_setparam ( gpointer notused, guint16 i, VikLayerParamData data, VikLayerParam *params )
 {
   if ( params[i].type == VIK_LAYER_PARAM_STRING_LIST )
-    g_error ( "Param strings not implemented in preferences"); //fake it
+    g_critical ( "Param strings not implemented in preferences"); //fake it
   g_hash_table_insert ( values, (gchar *)(params[i].name), layer_typed_param_data_copy_from_data(params[i].type, data) );
 }
 
@@ -211,12 +233,12 @@ void a_preferences_run_setparam ( VikLayerParamData data, VikLayerParam *params
   preferences_run_setparam (NULL, 0, data, params);
 }
 
-static VikLayerParamData preferences_run_getparam ( gpointer notused, guint16 i )
+static VikLayerParamData preferences_run_getparam ( gpointer notused, guint16 i, gboolean notused2 )
 {
   VikLayerTypedParamData *val = (VikLayerTypedParamData *) g_hash_table_lookup ( values, ((VikLayerParam *)g_ptr_array_index(params,i))->name );
   g_assert ( val != NULL );
   if ( val->type == VIK_LAYER_PARAM_STRING_LIST )
-    g_error ( "Param strings not implemented in preferences"); //fake it
+    g_critical ( "Param strings not implemented in preferences"); //fake it
   return val->data;
 }
 
@@ -265,7 +287,7 @@ void a_preferences_show_window(GtkWindow *parent) {
     preferences_load_from_file();
     if ( a_uibuilder_properties_factory ( _("Preferences"), parent, contiguous_params, params_count,
                                (gchar **) groups_names->pdata, groups_names->len, // groups, groups_count, // groups? what groups?!
-                                (gboolean (*) (gpointer,guint16,VikLayerParamData,gpointer)) preferences_run_setparam,
+                               (gboolean (*) (gpointer,guint16,VikLayerParamData,gpointer,gboolean)) preferences_run_setparam,
                                NULL /* not used */, contiguous_params,
                                 preferences_run_getparam, NULL /* not used */ ) ) {
       a_preferences_save_to_file();