gboolean gs_plugin_launch (GsPlugin *plugin, GsApp *app, GCancellable *cancellable, GError **error) { const gchar *launch_name; g_autofree gchar *binary_name = NULL; GAppInfoCreateFlags flags = G_APP_INFO_CREATE_NONE; g_autoptr(GAppInfo) info = NULL; /* We can only launch apps we know of */ if (g_strcmp0 (gs_app_get_management_plugin (app), "snap") != 0) return TRUE; launch_name = gs_app_get_metadata_item (app, "snap::launch-name"); if (!launch_name) return TRUE; if (g_strcmp0 (launch_name, gs_app_get_id (app)) == 0) binary_name = g_strdup_printf ("/snap/bin/%s", launch_name); else binary_name = g_strdup_printf ("/snap/bin/%s.%s", gs_app_get_id (app), launch_name); if (!is_graphical (app, cancellable)) flags |= G_APP_INFO_CREATE_NEEDS_TERMINAL; info = g_app_info_create_from_commandline (binary_name, NULL, flags, error); if (info == NULL) return FALSE; return g_app_info_launch (info, NULL, NULL, error); }
gboolean gs_plugin_launch (GsPlugin *plugin, GsApp *app, GCancellable *cancellable, GError **error) { const gchar *launch_name; const gchar *launch_desktop; g_autoptr(GAppInfo) info = NULL; /* We can only launch apps we know of */ if (g_strcmp0 (gs_app_get_management_plugin (app), "snap") != 0) return TRUE; launch_name = gs_app_get_metadata_item (app, "snap::launch-name"); launch_desktop = gs_app_get_metadata_item (app, "snap::launch-desktop"); if (!launch_name) return TRUE; if (launch_desktop) { info = (GAppInfo *)g_desktop_app_info_new_from_filename (launch_desktop); } else { g_autofree gchar *commandline = NULL; GAppInfoCreateFlags flags = G_APP_INFO_CREATE_NONE; if (g_strcmp0 (launch_name, gs_app_get_metadata_item (app, "snap::name")) == 0) commandline = g_strdup_printf ("snap run %s", launch_name); else commandline = g_strdup_printf ("snap run %s.%s", gs_app_get_metadata_item (app, "snap::name"), launch_name); if (!is_graphical (plugin, app, cancellable)) flags |= G_APP_INFO_CREATE_NEEDS_TERMINAL; info = g_app_info_create_from_commandline (commandline, NULL, flags, error); } if (info == NULL) return FALSE; return g_app_info_launch (info, NULL, NULL, error); }