-static void
-g_application_impl_publish_menu (GApplicationImpl *impl,
- const gchar *type,
- GMenuModel *model,
- guint *id,
- gchar **path)
-{
- gint i;
-
- /* unexport any existing menu */
- if (*id)
- {
- g_dbus_connection_unexport_menu_model (impl->session_bus, *id);
- g_free (*path);
- *path = NULL;
- *id = 0;
- }
-
- /* export the new menu, if there is one */
- if (model != NULL)
- {
- /* try getting the preferred name */
- *path = g_strconcat (impl->object_path, "/menus/", type, NULL);
- *id = g_dbus_connection_export_menu_model (impl->session_bus, *path, model, NULL);
-
- /* keep trying until we get a working name... */
- for (i = 0; *id == 0; i++)
- {
- g_free (*path);
- *path = g_strdup_printf ("%s/menus/%s%d", impl->object_path, type, i);
- *id = g_dbus_connection_export_menu_model (impl->session_bus, *path, model, NULL);
- }
- }
-
- /* notify for changes, if needed */
- if (impl->properties_live)
- {
- GVariantBuilder builder;
-
- g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
- g_variant_builder_add (&builder, "{sv}", type, g_variant_new_objv ((const gchar **) path, *path != NULL));
- g_dbus_connection_emit_signal (impl->session_bus, NULL, impl->object_path,
- "org.freedesktop.DBus.Properties", "PropertiesChanged",
- g_variant_new ("(sa{sv}as)", "org.gtk.Actions", &builder, NULL), NULL);
- }
-}
-
-static void
-g_application_impl_app_menu_changed (GObject *source,
- GParamSpec *pspec,
- gpointer user_data)
-{
- GApplicationImpl *impl = user_data;
-
- g_assert (source == impl->app);
-
- g_application_impl_publish_menu (impl, "AppMenu", g_application_get_app_menu (impl->app),
- &impl->app_menu_id, &impl->app_menu_path);
-}
-
-static void
-g_application_impl_menubar_changed (GObject *source,
- GParamSpec *pspec,
- gpointer user_data)
-{
- GApplicationImpl *impl = user_data;
-
- g_assert (source == impl->app);
-
- g_application_impl_publish_menu (impl, "MenuBar", g_application_get_menubar (impl->app),
- &impl->menubar_id, &impl->menubar_path);
-}
-