Gtk::TextView::modify_font从GTKMM 2.4移动到GTK3.0时的问题

Problem with Gtk::TextView::modify_font when moving from GTKMM 2.4 to GTK3.0

本文关键字:移动 GTK3 问题 0时 GTKMM modify TextView font Gtk      更新时间:2023-10-16

我有一个使用gtkmm 2.4的应用程序,它工作得很好,直到我最近切换到gtkmm 3.0。我有一个问题与g++(版本4.6.1),它一直吐出错误"error: ' class Gtk::TextView '没有名为' modify_font '的成员"。当我将构建包含恢复到gtkmm 2.4时(通过将pkg-config gtkmm-3.0 --cflags --libs更改回gtkmm-2.4),情况就不是这样了。

我跟着头回来(从代码::块)和函数头肯定在那里。它看起来也不像Gtk::Widget::modify_font贬值了。

关于Gtk::TextView:

的类层次结构的示例
// The parent of the offending TextView
class popupWindow : public Gtk::Window
{
public:
  popupWindow();
private:
  Gtk::TextView theView;
  Gtk::ScrolledWindow scrollView;
  Gtk::VBox layoutBox;
  Glib::RefPtr<Gtk::TextBuffer> textBuffer;
};
// The main window class
class mainWindow : public Gtk::Window
{
private:
  popupWindow foo;
};
// Part of the header where I try and set the modified font
popupWindow::popupwindow() : layoutBox(false, 8)
{
  // Modify the font styling of the TextView
  {
    Pango::FontDescription fdesc;
    fdesc.set_family("monospace");
    fdesc.set_size(10 * PANGO_SCALE);
    theView.modify_font(fdesc);
  }
  // Make a new text buffer
  textBuffer = Gtk::TextBuffer::create();

  add(layoutBox);
  layoutBox.pack_start(scrollView);
  scrollView.add(theView);
  theView.set_buffer(textBuffer);
}

gtkmm 3.0有override_font()而不是modify_font()。

文档确实有些缺乏3.0中变化的细节,并且一些符号在2.4中被重命名而没有被弃用。我相信gtkmm开发人员会有兴趣得到一些帮助,使文档更好的形状,如果你有时间帮助。