g_object_new:从g_application_send_notification()
我用的是最新的GTK +与MSYS2安装,每当我试图使用的呼叫断言 g_application_send_notification()
它总是导致以下 断言:g_object_new:从g_application_send_notification()
(Notification Project.exe:27780): GLib-GObject-CRITICAL **: g_object_new:
assertion 'G_TYPE_IS_OBJECT (object_type)' failed
为什么我认为这是一个错误 - 因为我试过很多代码样本矿山 旁边(他们都是很喜欢来到矿里),人谁得到它的工作 (包括notifaction拉尔斯Uebernickel),而这一切都作出了同样的感叹 。 断言,然后崩溃。现在我真的不知道这意味着什么,因为它 可能是GTK内部之内,但我真的希望你们中的一些可能有 线索或经验与此有关。
- 安装(GNU的coreutils)8.25
- GIO版本2.52.3
- 的mingw32 /的mingw-W64-i686的-GTK的发动机UNICO 1.0.2-2 [安装]
- 的mingw32/mingw的-w64-i686的-gtk3 3.22.16-1 [安装]
- 的mingw32 /的mingw-W64-i686的-gtkmm3 3.22.0-1 [安装]
- 的mingw32 /的mingw-W64-i686的-香料GTK 0.33- 1安装]
- 的mingw32 /的mingw-W64-i686的-webkitgtk3 2.4.11-4 [研究所alled]
- mingw64 /的mingw-W64-x86_64的-GTK的发动机UNICO 1.0.2-2 [安装]
- mingw64 /的mingw-W64-x86_64的-gtk3 3.22.16-1 [安装]
- mingw64/mingw的-W64-x86_64的-gtkmm3 3.22.0-1 [安装]
- mingw64 /的mingw-W64-x86_64的-香料-GTK 0.33-1 [安装]
- mingw64 /的mingw-W64-x86_64的-webkitgtk3 2.4。 11-4 [安装]
该GENER的代码的示例阿泰此断言:
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gtk/gtk.h>
#define ICON_PATH "/path/trash_16x16.gif"
int main (int argc, char *argv[])
{
GApplication *app;
app = g_application_new ("org.one", G_APPLICATION_FLAGS_NONE);
if(!app)
{
g_print ("Error app\n");
}
else
{
if(g_application_register (app, NULL, NULL))
{
GNotification *notification;
GFile *file;
GIcon *icon;
notification = g_notification_new ("one");
g_notification_set_body (notification, "Hello world");
file = g_file_new_for_path (ICON_PATH);
icon = g_file_icon_new (file);
g_notification_set_icon (notification, G_ICON (icon));
g_application_send_notification (app, NULL, notification);
g_object_unref (icon);
g_object_unref (file);
g_object_unref (notification);
g_object_unref (app);
g_print ("yes\n");
}
else
{
g_print ("no\n");
}
}
return 0;
}
那是我能做些什么来绕过这个问题,甚至可能是解决这个问题?
没有在W32工作的通知后端证实。贡献者曾经希望创建这种类型的API,但是所需的API(W32 Toast通知)仅用于COM,而MinGW-w64目前还没有必要的头文件。在巧舌如簧gio源代码和GNotificationBackend接口
展望而言,我们可以看到,它很简单。现在
,你可能只是做它在GTK ......或者我们可以这样做的正确的方式(TM)和实施d-Bus服务器吧。关于通知服务器的好处在于即使应用程序终止,通知也可以保留。此外,GTK已经具备说话的通知服务器后端,所以你只需要启用W32这些后端(一目了然,代码不使用任何不W32上工作的话)。此外,服务器可以透明地使用Shell_NotifyIcon
(在Windows 7和更早版本上)或Toast通知(在Windows 8和更高版本上;如果你有机会实现这些)。
,如果你想保持跨platformability另一种选择是创建一个DLL Shell_NotifyIcon
实现,并且如果窗户被检测到,如果没有,GNotification,你会使用Shell_NotifyIcon
。
首先,SO不是GTK错误跟踪器,为什么要在这里发布?如果你希望我们向你保证,你应该发布一个MCVE。 –
@EugeneSh对不起,如果我误解了,但什么是MCVE? 也不是它与编程有关的问题。这是与编程有关的问题。 – Malina
您对问题中包含的g_application_send_notification调用会更好。但是我认为这很可能并不重要,所以:我并不低调 –