1 /*
2  * Copyright (C) 2003 Sun Microsystems Inc.
3  *
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.
8  *
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.
13  *
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.
18  *
19  * Authors: Mark McLoughlin <mark@skynet.ie>
20  */
21 
22 #include "config.h"
23 #include <glib.h>
24 #include "gdk.h"
25 #include "gdkspawn.h"
26 #include "gdkprivate.h"
27 #include "gdkalias.h"
28 
29 
30 gboolean
gdk_spawn_on_screen(GdkScreen * screen,const gchar * working_directory,gchar ** argv,gchar ** envp,GSpawnFlags flags,GSpawnChildSetupFunc child_setup,gpointer user_data,gint * child_pid,GError ** error)31 gdk_spawn_on_screen (GdkScreen             *screen,
32 		     const gchar           *working_directory,
33 		     gchar                **argv,
34 		     gchar                **envp,
35 		     GSpawnFlags            flags,
36 		     GSpawnChildSetupFunc   child_setup,
37 		     gpointer               user_data,
38 		     gint                  *child_pid,
39 		     GError               **error)
40 {
41   g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
42 
43   return g_spawn_async (working_directory,
44 			argv,
45 			envp,
46 			flags,
47 			child_setup,
48 			user_data,
49 			child_pid,
50 			error);
51 }
52 
53 gboolean
gdk_spawn_on_screen_with_pipes(GdkScreen * screen,const gchar * working_directory,gchar ** argv,gchar ** envp,GSpawnFlags flags,GSpawnChildSetupFunc child_setup,gpointer user_data,gint * child_pid,gint * standard_input,gint * standard_output,gint * standard_error,GError ** error)54 gdk_spawn_on_screen_with_pipes (GdkScreen            *screen,
55 				const gchar          *working_directory,
56 				gchar               **argv,
57 				gchar               **envp,
58 				GSpawnFlags           flags,
59 				GSpawnChildSetupFunc  child_setup,
60 				gpointer              user_data,
61 				gint                 *child_pid,
62 				gint                 *standard_input,
63 				gint                 *standard_output,
64 				gint                 *standard_error,
65 				GError              **error)
66 {
67   g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
68 
69   return g_spawn_async_with_pipes (working_directory,
70 				   argv,
71 				   envp,
72 				   flags,
73 				   child_setup,
74 				   user_data,
75 				   child_pid,
76 				   standard_input,
77 				   standard_output,
78 				   standard_error,
79 				   error);
80 }
81 
82 gboolean
gdk_spawn_command_line_on_screen(GdkScreen * screen,const gchar * command_line,GError ** error)83 gdk_spawn_command_line_on_screen (GdkScreen    *screen,
84 				  const gchar  *command_line,
85 				  GError      **error)
86 {
87   gchar    **argv = NULL;
88   gboolean   retval;
89 
90   g_return_val_if_fail (command_line != NULL, FALSE);
91 
92   if (!g_shell_parse_argv (command_line,
93 			   NULL, &argv,
94 			   error))
95     return FALSE;
96 
97   retval = gdk_spawn_on_screen (screen,
98 				NULL, argv, NULL,
99 				G_SPAWN_SEARCH_PATH,
100 				NULL, NULL, NULL,
101 				error);
102   g_strfreev (argv);
103 
104   return retval;
105 }
106 
107 #define __GDK_SPAWN_X11_C__
108 #include "gdkaliasdef.c"
109