static void restart (void) { gchar *buf; struct ball *f = (struct ball*) field; int i; if (debugging) g_print ("Retrieving state\n"); score = gnome_config_get_int_with_default ("Game/Score", 0); nstones = gnome_config_get_int_with_default ("Game/NStones", 0); buf = gnome_config_get_string_with_default ("Game/Field", NULL); if (buf) { for (i= 0; i < (STONE_COLS*STONE_LINES); i++) { f[i].color= buf[i] - 'a'; f[i].tag = 0; f[i].frame= nstones ? (rand () % nstones) : 0; } g_free (buf); } }
char * confsection_t::get_string(const char *name, const char *deflt) { char *val; string_var key = make_key(name); #if HAVE_LIBGCONF GError *e = 0; GConfValue *gcv = gconf_client_get(gconf_client_get_default(), key, &e); handle_error(secname_, e); if (gcv == 0) { val = (deflt == 0 ? 0 : g_strdup(deflt)); } else { val = g_strdup(gconf_value_get_string(gcv)); gconf_value_free(gcv); } #else gboolean defaulted = FALSE; val = gnome_config_get_string_with_default(key.data(), &defaulted); if (defaulted) val = (deflt == 0 ? 0 : g_strdup(deflt)); #endif return val; }