gchar * go_conf_get_value_as_str (GOConfNode *node, gchar const *key) { gchar *value_string; GVariant *value = NULL; if (node) { if (key && !strchr (key, '/') && !strchr (key, '.')) value = g_settings_get_value (node->settings, key); else if (node->key) value = g_settings_get_value (node->settings, node->key); } if (value == NULL) { GOConfNode *real_node = go_conf_get_node (node, key); value = real_node? g_settings_get_value (real_node->settings, real_node->key): NULL; go_conf_free_node (real_node); } switch (g_variant_classify (value)) { case 's': value_string = g_strdup (g_variant_get_string (value, NULL)); break; case 'i': value_string = g_strdup_printf ("%i", g_variant_get_int32 (value)); break; case 'd': value_string = g_strdup_printf ("%f", g_variant_get_double (value)); break; case 'b': value_string = g_strdup (go_locale_boolean_name (g_variant_get_boolean (value))); break; default: value_string = g_strdup ("ERROR FIXME"); break; } return value_string; }
/* Debugging utility to print a GnmValue */ void value_dump (GnmValue const *value) { switch (value->v_any.type){ case VALUE_EMPTY: g_print ("EMPTY\n"); break; case VALUE_ERROR: g_print ("ERROR: %s\n", value->v_err.mesg->str); break; case VALUE_BOOLEAN: g_print ("BOOLEAN: %s\n", go_locale_boolean_name (value->v_bool.val)); break; case VALUE_STRING: g_print ("STRING: %s\n", value->v_str.val->str); break; case VALUE_FLOAT: g_print ("NUMBER: %" GNM_FORMAT_f "\n", value_get_as_float (value)); break; case VALUE_ARRAY: { int x, y; g_print ("Array: { "); for (y = 0; y < value->v_array.y; y++) for (x = 0; x < value->v_array.x; x++) value_dump (value->v_array.vals [x][y]); g_print ("}\n"); break; } case VALUE_CELLRANGE: { /* * Do NOT normalize the ranges. * Lets see them in their inverted glory if need be. */ GnmCellRef const *c = &value->v_range.cell.a; Sheet const *sheet = c->sheet; g_print ("CellRange\n"); if (sheet && sheet->name_unquoted) g_print ("%s:", sheet->name_quoted); else g_print ("%p :", (void *)sheet); g_print ("%s%s%s%s\n", (c->col_relative ? "":"$"), col_name(c->col), (c->row_relative ? "":"$"), row_name(c->row)); c = &value->v_range.cell.b; if (sheet && sheet->name_quoted) g_print ("%s:", sheet->name_unquoted); else g_print ("%p :", (void *)sheet); g_print ("%s%s%s%s\n", (c->col_relative ? "":"$"), col_name(c->col), (c->row_relative ? "":"$"), row_name(c->row)); break; } default: g_print ("Unhandled item type\n"); } }