/** * egg_desktop_file_launch: * @desktop_file: an #EggDesktopFile * @documents: a list of URIs or paths to documents to open * @error: error pointer * @...: additional options * * Launches @desktop_file with the given arguments. Additional options * can be specified as follows: * * %EGG_DESKTOP_FILE_LAUNCH_CLEARENV: (no arguments) * clears the environment in the child process * %EGG_DESKTOP_FILE_LAUNCH_PUTENV: (char **variables) * adds the NAME=VALUE strings in the given %NULL-terminated * array to the child process's environment * %EGG_DESKTOP_FILE_LAUNCH_SCREEN: (GdkScreen *screen) * causes the application to be launched on the given screen * %EGG_DESKTOP_FILE_LAUNCH_WORKSPACE: (int workspace) * causes the application to be launched on the given workspace * %EGG_DESKTOP_FILE_LAUNCH_DIRECTORY: (char *dir) * causes the application to be launched in the given directory * %EGG_DESKTOP_FILE_LAUNCH_TIME: (guint32 launch_time) * sets the "launch time" for the application. If the user * interacts with another window after @launch_time but before * the launched application creates its first window, the window * manager may choose to not give focus to the new application. * Passing 0 for @launch_time will explicitly request that the * application not receive focus. * %EGG_DESKTOP_FILE_LAUNCH_FLAGS (GSpawnFlags flags) * Sets additional #GSpawnFlags to use. See g_spawn_async() for * more details. * %EGG_DESKTOP_FILE_LAUNCH_SETUP_FUNC (GSpawnChildSetupFunc, gpointer) * Sets the child setup callback and the data to pass to it. * (See g_spawn_async() for more details.) * * %EGG_DESKTOP_FILE_LAUNCH_RETURN_PID (GPid **pid) * On a successful launch, sets *@pid to the PID of the launched * application. * %EGG_DESKTOP_FILE_LAUNCH_RETURN_STARTUP_ID (char **startup_id) * On a successful launch, sets *@startup_id to the Startup * Notification "startup id" of the launched application. * %EGG_DESKTOP_FILE_LAUNCH_RETURN_STDIN_PIPE (int *fd) * On a successful launch, sets *@fd to the file descriptor of * a pipe connected to the application's stdin. * %EGG_DESKTOP_FILE_LAUNCH_RETURN_STDOUT_PIPE (int *fd) * On a successful launch, sets *@fd to the file descriptor of * a pipe connected to the application's stdout. * %EGG_DESKTOP_FILE_LAUNCH_RETURN_STDERR_PIPE (int *fd) * On a successful launch, sets *@fd to the file descriptor of * a pipe connected to the application's stderr. * * The options should be terminated with a single %NULL. * * If @documents contains multiple documents, but * egg_desktop_file_accepts_multiple() returns %FALSE for * @desktop_file, then egg_desktop_file_launch() will actually launch * multiple instances of the application. In that case, the return * value (as well as any values passed via * %EGG_DESKTOP_FILE_LAUNCH_RETURN_PID, etc) will only reflect the * first instance of the application that was launched (but the * %EGG_DESKTOP_FILE_LAUNCH_SETUP_FUNC will be called for each * instance). * * Return value: %TRUE if the application was successfully launched. **/ gboolean egg_desktop_file_launch (EggDesktopFile *desktop_file, GSList *documents, GError **error, ...) { va_list args; gboolean success; EggDesktopFile *app_desktop_file; switch (desktop_file->type) { case EGG_DESKTOP_FILE_TYPE_APPLICATION: va_start (args, error); success = egg_desktop_file_launchv (desktop_file, documents, args, error); va_end (args); break; case EGG_DESKTOP_FILE_TYPE_LINK: if (documents) { g_set_error (error, EGG_DESKTOP_FILE_ERROR, EGG_DESKTOP_FILE_ERROR_NOT_LAUNCHABLE, /* translators: The 'Type=Link' string is found in a * desktop file, and should not be translated. */ _("Can't pass document URIs to a 'Type=Link' desktop entry")); return FALSE; } if (!parse_link (desktop_file, &app_desktop_file, &documents, error)) return FALSE; va_start (args, error); success = egg_desktop_file_launchv (app_desktop_file, documents, args, error); va_end (args); egg_desktop_file_free (app_desktop_file); free_document_list (documents); break; case EGG_DESKTOP_FILE_TYPE_UNRECOGNIZED: case EGG_DESKTOP_FILE_TYPE_DIRECTORY: default: g_set_error (error, EGG_DESKTOP_FILE_ERROR, EGG_DESKTOP_FILE_ERROR_NOT_LAUNCHABLE, _("Not a launchable item")); success = FALSE; break; } return success; }
/** * egg_desktop_file_launch: * @desktop_file: an #EggDesktopFile * @documents: a list of URIs or paths to documents to open * @error: error pointer * @...: additional options * * Launches @desktop_file with the given arguments. Additional options * can be specified as follows: * * %EGG_DESKTOP_FILE_LAUNCH_CLEARENV: (no arguments) * clears the environment in the child process * %EGG_DESKTOP_FILE_LAUNCH_PUTENV: (char **variables) * adds the NAME=VALUE strings in the given %NULL-terminated * array to the child process's environment * %EGG_DESKTOP_FILE_LAUNCH_SCREEN: (GdkScreen *screen) * causes the application to be launched on the given screen * %EGG_DESKTOP_FILE_LAUNCH_WORKSPACE: (int workspace) * causes the application to be launched on the given workspace * %EGG_DESKTOP_FILE_LAUNCH_DIRECTORY: (char *dir) * causes the application to be launched in the given directory * %EGG_DESKTOP_FILE_LAUNCH_TIME: (guint32 launch_time) * sets the "launch time" for the application. If the user * interacts with another window after @launch_time but before * the launched application creates its first window, the window * manager may choose to not give focus to the new application. * Passing 0 for @launch_time will explicitly request that the * application not receive focus. * %EGG_DESKTOP_FILE_LAUNCH_FLAGS (GSpawnFlags flags) * Sets additional #GSpawnFlags to use. See g_spawn_async() for * more details. * %EGG_DESKTOP_FILE_LAUNCH_SETUP_FUNC (GSpawnChildSetupFunc, gpointer) * Sets the child setup callback and the data to pass to it. * (See g_spawn_async() for more details.) * * %EGG_DESKTOP_FILE_LAUNCH_RETURN_PID (GPid **pid) * On a successful launch, sets *@pid to the PID of the launched * application. * %EGG_DESKTOP_FILE_LAUNCH_RETURN_STARTUP_ID (char **startup_id) * On a successful launch, sets *@startup_id to the Startup * Notification "startup id" of the launched application. * %EGG_DESKTOP_FILE_LAUNCH_RETURN_STDIN_PIPE (int *fd) * On a successful launch, sets *@fd to the file descriptor of * a pipe connected to the application's stdin. * %EGG_DESKTOP_FILE_LAUNCH_RETURN_STDOUT_PIPE (int *fd) * On a successful launch, sets *@fd to the file descriptor of * a pipe connected to the application's stdout. * %EGG_DESKTOP_FILE_LAUNCH_RETURN_STDERR_PIPE (int *fd) * On a successful launch, sets *@fd to the file descriptor of * a pipe connected to the application's stderr. * * The options should be terminated with a single %NULL. * * If @documents contains multiple documents, but * egg_desktop_file_accepts_multiple() returns %FALSE for * @desktop_file, then egg_desktop_file_launch() will actually launch * multiple instances of the application. In that case, the return * value (as well as any values passed via * %EGG_DESKTOP_FILE_LAUNCH_RETURN_PID, etc) will only reflect the * first instance of the application that was launched (but the * %EGG_DESKTOP_FILE_LAUNCH_SETUP_FUNC will be called for each * instance). * * Return value: %TRUE if the application was successfully launched. **/ gboolean egg_desktop_file_launch (EggDesktopFile *desktop_file, GSList *documents, GError **error, ...) { va_list args; gboolean success; EggDesktopFile *app_desktop_file; switch (desktop_file->type) { case EGG_DESKTOP_FILE_TYPE_APPLICATION: va_start (args, error); success = egg_desktop_file_launchv (desktop_file, documents, args, error); va_end (args); break; case EGG_DESKTOP_FILE_TYPE_LINK: if (documents) { g_set_error (error, EGG_DESKTOP_FILE_ERROR, EGG_DESKTOP_FILE_ERROR_NOT_LAUNCHABLE, _("Can't pass documents to this desktop element")); return FALSE; } if (!parse_link (desktop_file, &app_desktop_file, &documents, error)) return FALSE; va_start (args, error); success = egg_desktop_file_launchv (app_desktop_file, documents, args, error); va_end (args); egg_desktop_file_free (app_desktop_file); free_document_list (documents); break; default: g_set_error (error, EGG_DESKTOP_FILE_ERROR, EGG_DESKTOP_FILE_ERROR_NOT_LAUNCHABLE, _("Not a launchable item")); success = FALSE; break; } return success; }