与gtk3一起使用cairo [英] using cairo with gtk3
问题描述
我试图在gtk3中用cairo绘制散点图。首先,我在这里使用示例: http://zetcode.com/tutorials/cairographicstutorial/
I am trying to draw a scatterplot with cairo in gtk3. To start, I am using the examples here: http://zetcode.com/tutorials/cairographicstutorial/
它们成功地用gtk2编译,但是没有显示图像。它们不使用gtk3进行编译,但是会出现以下错误:
They compile with gtk2 successfully but display no image. They do not compile with gtk3 but give the following error:
example.c: In function ‘on_expose_event’:
example.c:17:31: error: ‘GtkWidget’ has no member named ‘window’
任何
btw如果有帮助,我正在使用ArchLinux进行编写。
btw I am using writing using ArchLinux for this if that helps.
推荐答案
Gtk3进行了很多更改。 GtkWidget
的一部分没有成员 window
,成员已移至 GtkWidgetPrivate
这是一个不透明的结构,因此您不能直接从 GtkWidget
访问成员。您将必须使用访问器功能,在这种情况下,您需要 GtkWidget
的窗口
成员,则可以使用 gtk_widget_get_window
,但这可能无法修复您正在使用的代码示例。请注意, expose_event
信号已替换为 draw
信号,因此您将需要更新实际绘制的函数适当(我认为您的情况是 on_expose_event
)。请参阅此链接以查看列表切换到Gtk3所需的更改。您可以从Gtk3源代码中引用 gtk-demo
应用程序提供的源或 demos / gtk-demo
提供的源代码来获取示例代码。 。
关于在Gtk2中未显示的图像,如果您正在处理图像样本,请确保在源代码中提到的路径中可以使用该图像文件。
希望这会有所帮助!
There have been quite a few changes in Gtk3. There is no member window
exposed as part of GtkWidget
anymore, the members have been moved to GtkWidgetPrivate
which is an opaque structure so you cannot access the members directly from GtkWidget
. You will have to use accessor function, in this case where you need window
member of GtkWidget
you can use gtk_widget_get_window
, but that may not fix the code sample with which you are working. Please note that the expose_event
signal has been replaced with draw
signal so you will need to update the function which is actually drawing appropriately (on_expose_event
in your case I think). Please refer this link to see the list of changes needed to switch to Gtk3. You can refer source provided by gtk-demo
application or demos/gtk-demo
from Gtk3 source code to get sample code.
Regarding image not being shown in case of Gtk2, if you are working with image sample, please make sure that the image file is available in the path mentioned in the source.
Hope this helps!
这篇关于与gtk3一起使用cairo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!