void on_interpreter_cell_changed(GtkCellRendererCombo *combo, char *path_string, GtkTreeIter *new_iter, ChimaraGlk *glk) { unsigned int format, interpreter; format = (unsigned int)strtol(path_string, NULL, 10); GtkTreeModel *combo_model; g_object_get(combo, "model", &combo_model, NULL); char *combo_string = gtk_tree_model_get_string_from_iter(combo_model, new_iter); interpreter = (unsigned int)strtol(combo_string, NULL, 10); g_free(combo_string); chimara_if_set_preferred_interpreter(CHIMARA_IF(glk), format, interpreter); /* Display the new setting in the list */ GtkTreeIter iter; GtkTreePath *path = gtk_tree_path_new_from_string(path_string); gtk_tree_model_get_iter(GTK_TREE_MODEL(preferred_list), &iter, path); gtk_tree_path_free(path); gtk_list_store_set(preferred_list, &iter, 1, interpreter_to_display_string(interpreter), -1); /* Save the new settings in the preferences file */ extern GSettings *prefs_settings; GVariantBuilder *builder = g_variant_builder_new( G_VARIANT_TYPE("a{ss}") ); unsigned int count; for(count = 0; count < CHIMARA_IF_NUM_FORMATS; count++) { g_variant_builder_add(builder, "{ss}", format_to_string(count), interpreter_to_string(chimara_if_get_preferred_interpreter(CHIMARA_IF(glk), count))); } g_settings_set(prefs_settings, "preferred-interpreters", "a{ss}", builder); g_variant_builder_unref(builder); }
// ### primitive-format Value SYS_primitive_format(unsigned int numargs, Value args[]) { if (numargs < 2) return wrong_number_of_arguments(S_format, numargs, 2, MANY); Value destination = args[0]; Value format_control = args[1]; Value format_arguments = NIL; for (long i = numargs; i-- > 2;) format_arguments = make_cons(args[i], format_arguments); String * string = format_to_string(format_control, format_arguments); if (destination == T) { AnsiStream * out = check_ansi_stream(current_thread()->symbol_value(S_standard_output)); out->write_string(string); return NIL; } if (destination == NIL) return make_value(string); // REVIEW if (ansi_stream_p(destination)) { the_ansi_stream(destination)->write_string(string); return NIL; } assert(false); return NIL; }
static void print_surface (const cairo_test_context_t *ctx, cairo_surface_t *surface) { cairo_test_log (ctx, "%s (%dx%d)\n", format_to_string (cairo_image_surface_get_format (surface)), cairo_image_surface_get_width (surface), cairo_image_surface_get_height (surface)); }
AbstractString * Condition::write_to_string() { Thread * const thread = current_thread(); if (CL_fboundp(S_print_object) != NIL) { StringOutputStream * stream = new StringOutputStream(S_character); thread->execute(the_symbol(S_print_object)->function(), make_value(this), make_value(stream)); AbstractString * s = stream->get_string(); return s; } if (thread->symbol_value(S_print_escape) == NIL && thread->symbol_value(S_print_readably) == NIL) { if (stringp(format_control())) { if (format_arguments() != NIL) return format_to_string(format_control(), format_arguments()); else return the_string(format_control()); } } return unreadable_string(); }