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>
34 GSpawnChildSetupFunc child_setup;
39 * Set the DISPLAY variable, and then call the user-specified child setup
40 * function. This is required so that applications can use gdk_spawn_* and
41 * call putenv() in their child_setup functions.
44 set_environment (gpointer user_data)
46 UserChildSetup *setup = user_data;
48 g_setenv ("DISPLAY", setup->display, TRUE);
50 if (setup->child_setup)
51 setup->child_setup (setup->user_data);
55 * gdk_spawn_on_screen:
56 * @screen: a #GdkScreen
57 * @working_directory: child's current working directory, or %NULL to
59 * @argv: child's argument vector
60 * @envp: child's environment, or %NULL to inherit parent's
61 * @flags: flags from #GSpawnFlags
62 * @child_setup: function to run in the child just before exec()
63 * @user_data: user data for @child_setup
64 * @child_pid: return location for child process ID, or %NULL
65 * @error: return location for error
67 * Like g_spawn_async(), except the child process is spawned in such
68 * an environment that on calling gdk_display_open() it would be
69 * returned a #GdkDisplay with @screen as the default screen.
71 * This is useful for applications which wish to launch an application
72 * on a specific screen.
74 * Return value: %TRUE on success, %FALSE if error is set
79 gdk_spawn_on_screen (GdkScreen *screen,
80 const gchar *working_directory,
84 GSpawnChildSetupFunc child_setup,
89 UserChildSetup setup_data;
91 g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
93 setup_data.display = gdk_screen_make_display_name (screen);
94 setup_data.child_setup = child_setup;
95 setup_data.user_data = user_data;
97 return g_spawn_async (working_directory,
108 * gdk_spawn_on_screen_with_pipes:
109 * @screen: a #GdkScreen
110 * @working_directory: child's current working directory, or %NULL to
112 * @argv: child's argument vector
113 * @envp: child's environment, or %NULL to inherit parent's
114 * @flags: flags from #GSpawnFlags
115 * @child_setup: function to run in the child just before exec()
116 * @user_data: user data for @child_setup
117 * @child_pid: return location for child process ID, or %NULL
118 * @standard_input: return location for file descriptor to write to
119 * child's stdin, or %NULL
120 * @standard_output: return location for file descriptor to read child's
122 * @standard_error: return location for file descriptor to read child's
124 * @error: return location for error
126 * Like g_spawn_async_with_pipes(), except the child process is
127 * spawned in such an environment that on calling gdk_display_open()
128 * it would be returned a #GdkDisplay with @screen as the default
131 * This is useful for applications which wish to launch an application
132 * on a specific screen.
134 * Return value: %TRUE on success, %FALSE if an error was set
139 gdk_spawn_on_screen_with_pipes (GdkScreen *screen,
140 const gchar *working_directory,
144 GSpawnChildSetupFunc child_setup,
147 gint *standard_input,
148 gint *standard_output,
149 gint *standard_error,
152 UserChildSetup setup_data;
154 g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
156 setup_data.display = gdk_screen_make_display_name (screen);
157 setup_data.child_setup = child_setup;
158 setup_data.user_data = user_data;
160 return g_spawn_async_with_pipes (working_directory,
175 * gdk_spawn_command_line_on_screen:
176 * @screen: a #GdkScreen
177 * @command_line: a command line
178 * @error: return location for errors
180 * Like g_spawn_command_line_async(), except the child process is
181 * spawned in such an environment that on calling gdk_display_open()
182 * it would be returned a #GdkDisplay with @screen as the default
185 * This is useful for applications which wish to launch an application
186 * on a specific screen.
188 * Return value: %TRUE on success, %FALSE if error is set.
193 gdk_spawn_command_line_on_screen (GdkScreen *screen,
194 const gchar *command_line,
200 g_return_val_if_fail (command_line != NULL, FALSE);
202 if (!g_shell_parse_argv (command_line,
207 retval = gdk_spawn_on_screen (screen,
217 #define __GDK_SPAWN_X11_C__
218 #include "gdkaliasdef.c"