c++ - 从 GTKMM 2.4 移动到 GTK3.0 时 Gtk::TextView::modify_font 出现问题

标签 c++ gtkmm gtk-textbuffer

我有一个使用 gtkmm 2.4 的应用程序,在我最近切换到 gtkmm 3.0 之前一直运行良好。我在使用 g++(版本 4.6.1)时遇到问题,它不断吐出错误“错误:‘class Gtk::TextView’没有名为‘modify_font’的成员”。当我将构建包含恢复到 gtkmm 2.4 时(通过将 pkg-config gtkmm-3.0 --cflags --libs 更改回 gtkmm-2.4),情况并非如此。

我按照 header 返回(从 code::blocks 中),函数 header 肯定在那里。看起来 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 has override_font()而不是 modify_font()。

文档确实缺少 3.0 中更改内容的详细信息,并且一些符号在 2.4 中被重命名但没有被弃用。我相信 gtkmm 开发人员会对一些帮助使文档处于更好的状态感兴趣,如果您有时间帮忙的话。

关于c++ - 从 GTKMM 2.4 移动到 GTK3.0 时 Gtk::TextView::modify_font 出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6990289/

相关文章:

c++ - 非托管 C++ 程序集的加载顺序(特别是 VS C++ 2015 可再发行组件和通用 CRT)

c++ - 在构造函数中访问容器子部件尺寸

c++ - Gtkmm 程序编译正常但崩溃 - Windows XP

c++ - 如何向下转换 RefPtr

python - 当用户在 gtk.TextBuffer 中输入时获取文本

Python Gtk TextView 在末尾插入文本

python - Glade GTK TextBuffer 更改或设置颜色

c++ - 高效频率计算的数据结构决策

c++ - 将 [][] 放入 **

c++ - libjpeg jpeg_write_coefficients