我可以看到使用 D-Feet 导出的菜单,但 Unity 不显示它们...有什么想法、附加文档或代码示例吗?
这是我的代码:
GMenu *menu = g_menu_new ();
g_menu_append (menu, "Add", "app.add");
g_menu_append (menu, "Del", "app.del");
g_menu_append (menu, "Quit", "app.quit");
GDBusConnection *bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
guint id = g_dbus_connection_export_menu_model (bus, "/org/gtk/example/menus/AppMenu", G_MENU_MODEL (menubar), NULL);
g_object_unref (menu);
我不会使用 gtk_application_set_app_menu 或 libdbusmenu。
答案1
错过了一些 XSettings
GdkWindow *gdkwindow = gtk_widget_get_window (GTK_WIDGET (window));
gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_UNIQUE_BUS_NAME", "org.gtk.example");
gdk_x11_window_set_utf8_property (gdkwindow, "_GTK_APP_MENU_OBJECT_PATH", "/org/gtk/example/menus/appmenu");