2 * Copyright (C) 2003 Sun Microsystems Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
19 * Authors: Mark McLoughlin <mark@skynet.ie>
33 GSpawnChildSetupFunc child_setup;
38 * Set the DISPLAY variable, and then call the user-specified child setup
39 * function. This is required so that applications can use gdk_spawn_* and
40 * call putenv() in their child_setup functions.
43 set_environment (gpointer user_data)
45 UserChildSetup *setup = user_data;
47 g_setenv ("DISPLAY", setup->display, TRUE);
49 if (setup->child_setup)
50 setup->child_setup (setup->user_data);
54 * gdk_spawn_on_screen:
55 * @screen: a #GdkScreen
56 * @working_directory: child's current working directory, or %NULL to
58 * @argv: child's argument vector
59 * @envp: child's environment, or %NULL to inherit parent's
60 * @flags: flags from #GSpawnFlags
61 * @child_setup: function to run in the child just before exec()
62 * @user_data: user data for @child_setup
63 * @child_pid: return location for child process ID, or %NULL
64 * @error: return location for error
66 * Like g_spawn_async(), except the child process is spawned in such
67 * an environment that on calling gdk_display_open() it would be
68 * returned a #GdkDisplay with @screen as the default screen.
70 * This is useful for applications which wish to launch an application
71 * on a specific screen.
73 * Return value: %TRUE on success, %FALSE if error is set
78 gdk_spawn_on_screen (GdkScreen *screen,
79 const gchar *working_directory,
83 GSpawnChildSetupFunc child_setup,
88 UserChildSetup setup_data;
90 g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
92 setup_data.display = gdk_screen_make_display_name (screen);
93 setup_data.child_setup = child_setup;
94 setup_data.user_data = user_data;
96 return g_spawn_async (working_directory,
107 * gdk_spawn_on_screen_with_pipes:
108 * @screen: a #GdkScreen
109 * @working_directory: child's current working directory, or %NULL to
111 * @argv: child's argument vector
112 * @envp: child's environment, or %NULL to inherit parent's
113 * @flags: flags from #GSpawnFlags
114 * @child_setup: function to run in the child just before exec()
115 * @user_data: user data for @child_setup
116 * @child_pid: return location for child process ID, or %NULL
117 * @standard_input: return location for file descriptor to write to
118 * child's stdin, or %NULL
119 * @standard_output: return location for file descriptor to read child's
121 * @standard_error: return location for file descriptor to read child's
123 * @error: return location for error
125 * Like g_spawn_async_with_pipes(), except the child process is
126 * spawned in such an environment that on calling gdk_display_open()
127 * it would be returned a #GdkDisplay with @screen as the default
130 * This is useful for applications which wish to launch an application
131 * on a specific screen.
133 * Return value: %TRUE on success, %FALSE if an error was set
138 gdk_spawn_on_screen_with_pipes (GdkScreen *screen,
139 const gchar *working_directory,
143 GSpawnChildSetupFunc child_setup,
146 gint *standard_input,
147 gint *standard_output,
148 gint *standard_error,
151 UserChildSetup setup_data;
153 g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
155 setup_data.display = gdk_screen_make_display_name (screen);
156 setup_data.child_setup = child_setup;
157 setup_data.user_data = user_data;
159 return g_spawn_async_with_pipes (working_directory,
174 * gdk_spawn_command_line_on_screen:
175 * @screen: a #GdkScreen
176 * @command_line: a command line
177 * @error: return location for errors
179 * Like g_spawn_command_line_async(), except the child process is
180 * spawned in such an environment that on calling gdk_display_open()
181 * it would be returned a #GdkDisplay with @screen as the default
184 * This is useful for applications which wish to launch an application
185 * on a specific screen.
187 * Return value: %TRUE on success, %FALSE if error is set.
192 gdk_spawn_command_line_on_screen (GdkScreen *screen,
193 const gchar *command_line,
199 g_return_val_if_fail (command_line != NULL, FALSE);
201 if (!g_shell_parse_argv (command_line,
206 retval = gdk_spawn_on_screen (screen,