Diff of /trunk/src/gconf.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 203 by harbaum, Thu Nov 19 12:38:03 2009 UTC revision 204 by harbaum, Mon Nov 23 18:32:06 2009 UTC
# Line 80  static store_t store[] = { Line 80  static store_t store[] = {
80    { "cachelist_hide_found", STORE_BOOL, OFFSET(cachelist_hide_found) },    { "cachelist_hide_found", STORE_BOOL, OFFSET(cachelist_hide_found) },
81    { "cachelist_update", STORE_BOOL,   OFFSET(cachelist_update) },    { "cachelist_update", STORE_BOOL,   OFFSET(cachelist_update) },
82    { "disable_gcvote",   STORE_BOOL,   OFFSET(disable_gcvote) },    { "disable_gcvote",   STORE_BOOL,   OFFSET(disable_gcvote) },
83      { "username",         STORE_STRING, OFFSET(username) },
84  #ifdef USE_MAEMO  #ifdef USE_MAEMO
85    { "mmpoi_dontlaunch", STORE_BOOL,   OFFSET(mmpoi_dontlaunch) },    { "mmpoi_dontlaunch", STORE_BOOL,   OFFSET(mmpoi_dontlaunch) },
86    { "cachelist_dss",    STORE_BOOL,   OFFSET(cachelist_disable_screensaver) },    { "cachelist_dss",    STORE_BOOL,   OFFSET(cachelist_disable_screensaver) },
# Line 92  static store_t store[] = { Line 93  static store_t store[] = {
93    { "map_source",       STORE_INT,    OFFSET(map.source) },    { "map_source",       STORE_INT,    OFFSET(map.source) },
94  #endif  #endif
95    
   { "geotoad/username", STORE_STRING, OFFSET(gt.username) },  
96    { "geotoad/password", STORE_STRING, OFFSET(gt.password) },    { "geotoad/password", STORE_STRING, OFFSET(gt.password) },
97    { "geotoad/filename", STORE_STRING, OFFSET(gt.filename) },    { "geotoad/filename", STORE_STRING, OFFSET(gt.filename) },
98    { "geotoad/distance", STORE_FLOAT,  OFFSET(gt.distance) },    { "geotoad/distance", STORE_FLOAT,  OFFSET(gt.distance) },
# Line 264  void gconf_load_state(appdata_t *appdata Line 264  void gconf_load_state(appdata_t *appdata
264      }      }
265    }    }
266    
267      /* restore everything listed in the store table */
268      store_t *st = store;
269      while(st->key) {
270        void **ptr = ((void*)appdata) + st->offset;
271        char *key = g_strdup_printf(GCONF_PATH "%s", st->key);
272    
273        /* check if key is present */
274        GConfValue *value = gconf_client_get(appdata->gconf_client, key, NULL);
275        if(value) {
276          gconf_value_free(value);
277    
278          switch(st->type) {
279          case STORE_STRING: {
280            char **str = (char**)ptr;
281            *str = gconf_client_get_string(appdata->gconf_client, key, NULL);
282          } break;
283    
284          case STORE_BOOL:
285            *((int*)ptr) = gconf_client_get_bool(appdata->gconf_client, key, NULL);
286            break;
287    
288          case STORE_INT:
289            *((int*)ptr) = gconf_client_get_int(appdata->gconf_client, key, NULL);
290            break;
291    
292          case STORE_FLOAT:
293            *((float*)ptr) = gconf_client_get_float(appdata->gconf_client, key, NULL);
294            break;
295    
296          default:
297            printf("Unsupported type %d\n", st->type);
298            break;
299          }
300        }
301        g_free(key);
302        st++;
303      }
304    
305    int i, entries = gconf_client_get_int(appdata->gconf_client,    int i, entries = gconf_client_get_int(appdata->gconf_client,
306                                   GCONF_KEY_CNT, NULL);                                   GCONF_KEY_CNT, NULL);
307    
# Line 285  void gconf_load_state(appdata_t *appdata Line 323  void gconf_load_state(appdata_t *appdata
323          (*gpx)->closed = TRUE;          (*gpx)->closed = TRUE;
324        } else {        } else {
325          if(g_file_test(fname, G_FILE_TEST_IS_DIR))          if(g_file_test(fname, G_FILE_TEST_IS_DIR))
326            *gpx = gpx_parse_dir(dialog, fname);            *gpx = gpx_parse_dir(dialog, fname, appdata->username);
327          else          else
328            *gpx = gpx_parse(dialog, fname);            *gpx = gpx_parse(dialog, fname, appdata->username);
329    
330          if(!*gpx) {          if(!*gpx) {
331            /* restoring the gpx file failed, mark it as unusable, but save */            /* restoring the gpx file failed, mark it as unusable, but save */
# Line 332  void gconf_load_state(appdata_t *appdata Line 370  void gconf_load_state(appdata_t *appdata
370      }      }
371    }    }
372    
   /* restore everything listed in the store table */  
   store_t *st = store;  
   while(st->key) {  
     void **ptr = ((void*)appdata) + st->offset;  
     char *key = g_strdup_printf(GCONF_PATH "%s", st->key);  
   
     /* check if key is present */  
     GConfValue *value = gconf_client_get(appdata->gconf_client, key, NULL);  
     if(value) {  
       gconf_value_free(value);  
   
       switch(st->type) {  
       case STORE_STRING: {  
         char **str = (char**)ptr;  
         *str = gconf_client_get_string(appdata->gconf_client, key, NULL);  
       } break;  
   
       case STORE_BOOL:  
         *((int*)ptr) = gconf_client_get_bool(appdata->gconf_client, key, NULL);  
         break;  
   
       case STORE_INT:  
         *((int*)ptr) = gconf_client_get_int(appdata->gconf_client, key, NULL);  
         break;  
   
       case STORE_FLOAT:  
         *((float*)ptr) = gconf_client_get_float(appdata->gconf_client, key, NULL);  
         break;  
   
       default:  
         printf("Unsupported type %d\n", st->type);  
         break;  
       }  
     }  
     g_free(key);  
     st++;  
   }  
   
373    /* ----- set all kinds of defaults ------- */    /* ----- set all kinds of defaults ------- */
374    
375    if(!appdata->compass_damping) appdata->compass_damping = 1;    if(!appdata->compass_damping) appdata->compass_damping = 1;
# Line 486  void gconf_load_state(appdata_t *appdata Line 486  void gconf_load_state(appdata_t *appdata
486      char *name = g_strdup(ICONPATH "welcome.gpx");      char *name = g_strdup(ICONPATH "welcome.gpx");
487      dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window));      dialog = gpx_busy_dialog_new(GTK_WIDGET(appdata->window));
488      printf("No GPX file loaded, trying to load demo\n");      printf("No GPX file loaded, trying to load demo\n");
489      appdata->gpx = gpx_parse(dialog, name);      appdata->gpx = gpx_parse(dialog, name, appdata->username);
490      gpx_busy_dialog_destroy(dialog);      gpx_busy_dialog_destroy(dialog);
491      g_free(name);      g_free(name);
492    }    }

Legend:
Removed from v.203  
changed lines
  Added in v.204