0
votes

I'm using gtk_tree_view_column_new_with_attributes(NULL, renderer, "markup", 0, NULL);. When I set the markup for a row, I use g_markup_printf_escaped to escape any characters in text strings passed as varargs.

I need a way to later get the text back from this encoded markup string, stripping out any formatting tags and replacing &entities. Alternatively just getting the displayed text of the GtkTreeView row as a string would also work. I'd prefer not to have to store the original text in hidden column(s) too. What's the best way to do this?

1

1 Answers

1
votes

I found a Pango function to do this: https://developer.gnome.org/pango/stable/pango-Markup.html#pango-parse-markup

    gchar *markup, *text;

    gtk_tree_model_get(model, &iter, 0, &markup, -1);
    pango_parse_markup(markup, -1, 0, NULL, &text, NULL, NULL);