【问题标题】:Get displayed text from GtkTreeView markup column从 GtkTreeView 标记列中获取显示的文本
【发布时间】:2019-10-07 18:30:11
【问题描述】:

我正在使用gtk_tree_view_column_new_with_attributes(NULL, renderer, "markup", 0, NULL);。当我为一行设置标记时,我使用g_markup_printf_escaped 转义作为可变参数传递的文本字符串中的任何字符。

我需要一种方法来稍后从这个编码的标记字符串中取回文本,去除所有格式标记并替换 &entities。或者,只需将 GtkTreeView 行的显示文本作为字符串获取也可以。我也不想将原始文本存储在隐藏列中。最好的方法是什么?

【问题讨论】:

    标签: c gtk pango


    【解决方案1】:

    我找到了一个 Pango 函数来执行此操作: 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);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-04-21
      • 1970-01-01
      • 2021-09-24
      • 2014-06-17
      • 1970-01-01
      • 2011-05-18
      • 2021-08-06
      • 1970-01-01
      相关资源
      最近更新 更多