【发布时间】:2019-05-10 10:58:09
【问题描述】:
我正在尝试创建一个 GTK-3 应用程序,并且在初始化过程中我想检查 GSetting 的值是否已设置,否则我想显示一个“启动”对话框,该对话框仅在第一次运行时可见。
GObject 有一个_init 后缀,可用于类初始化。在这种情况下,MyGtkApplication 将被构造,它基于GtkApplication。 GtkApplication 有 startup-thing 也可用于初始化。
在那个例子中,我仍然需要为 GApplicationClass 实现 _init 函数。
GApplicationClass *gapp_class;
gapp_class = G_APPLICATION_CLASS (class);
gapp_class->startup = app_startup;
// This must be always implemented, because the MyGtkApplication is "GtkApplication"-based class.
void app_init(MyGtkApplication *app) {
// Check and show the modal dialog if key does not exist?
}
// This will overwrite the GApplicatio's "startup".
void app_startup(GApplication *app) {
// Check and show the modal dialog if key does not exist?
}
目前app_init 没有正文。
有什么区别,我应该使用哪一个?
问候, TheAifam5.
【问题讨论】: