1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = vte-Vte-PTY.html
27  * outPack = vte
28  * outFile = Pty
29  * strct   = VtePty
30  * realStrct=
31  * ctorStrct=
32  * clss    = Pty
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * 	- InitableIF
40  * prefixes:
41  * 	- vte_pty_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- glib.ErrorG
49  * 	- glib.GException
50  * 	- gio.InitableIF
51  * 	- gio.InitableT
52  * structWrap:
53  * module aliases:
54  * local aliases:
55  * overrides:
56  */
57 
58 module vte.Pty;
59 
60 public  import vtec.vtetypes;
61 
62 private import vtec.vte;
63 private import glib.ConstructionException;
64 private import gobject.ObjectG;
65 
66 
67 private import glib.Str;
68 private import glib.ErrorG;
69 private import glib.GException;
70 private import gio.InitableIF;
71 private import gio.InitableT;
72 
73 
74 
75 
76 /**
77  * The terminal widget uses these functions to start commands with new controlling
78  * pseudo-terminals and to resize pseudo-terminals.
79  */
80 public class Pty : InitableIF
81 {
82 	
83 	/** the main Gtk struct */
84 	protected VtePty* vtePty;
85 	
86 	
87 	public VtePty* getPtyStruct()
88 	{
89 		return vtePty;
90 	}
91 	
92 	
93 	/** the main Gtk struct as a void* */
94 	protected void* getStruct()
95 	{
96 		return cast(void*)vtePty;
97 	}
98 	
99 	/**
100 	 * Sets our main struct and passes it to the parent class
101 	 */
102 	public this (VtePty* vtePty)
103 	{
104 		this.vtePty = vtePty;
105 	}
106 	
107 	// add the Initable capabilities
108 	mixin InitableT!(VtePty);
109 	
110 	/**
111 	 */
112 	
113 	/**
114 	 * Allocates a new pseudo-terminal.
115 	 * You can later use fork() or the g_spawn_async() family of functions
116 	 * to start a process on the PTY.
117 	 * If using fork(), you MUST call vte_pty_child_setup() in the child.
118 	 * If using g_spawn_async() and friends, you MUST either use
119 	 * vte_pty_child_setup() directly as the child setup function, or call
120 	 * vte_pty_child_setup() from your own child setup function supplied.
121 	 * When using vte_terminal_fork_command_full() with a custom child setup
122 	 * function, vte_pty_child_setup() will be called before the supplied
123 	 * function; you must not call it again.
124 	 * Also, you MUST pass the G_SPAWN_DO_NOT_REAP_CHILD flag.
125 	 * If GNOME PTY Helper is available and
126 	 * unless some of the VTE_PTY_NO_LASTLOG, VTE_PTY_NO_UTMP or
127 	 * VTE_PTY_NO_WTMP flags are passed in flags, the
128 	 * session is logged in the corresponding lastlog, utmp or wtmp
129 	 * system files. When passing VTE_PTY_NO_HELPER in flags, the
130 	 * GNOME PTY Helper is bypassed entirely.
131 	 * When passing VTE_PTY_NO_FALLBACK in flags,
132 	 * and opening a PTY using the PTY helper fails, there will
133 	 * be no fallback to allocate a PTY using Unix98 PTY functions.
134 	 * Params:
135 	 * flags = flags from VtePtyFlags
136 	 * Throws: GException on failure.
137 	 * Throws: ConstructionException GTK+ fails to create the object.
138 	 */
139 	public this (VtePtyFlags flags)
140 	{
141 		// VtePty * vte_pty_new (VtePtyFlags flags,  GError **error);
142 		GError* err = null;
143 		
144 		auto p = vte_pty_new(flags, &err);
145 		
146 		if (err !is null)
147 		{
148 			throw new GException( new ErrorG(err) );
149 		}
150 		
151 		if(p is null)
152 		{
153 			throw new ConstructionException("null returned by vte_pty_new(flags, &err)");
154 		}
155 		this(cast(VtePty*) p);
156 	}
157 	
158 	/**
159 	 * Creates a new VtePty for the PTY master fd.
160 	 * No entry will be made in the lastlog, utmp or wtmp system files.
161 	 * Note that the newly created VtePty will take ownership of fd
162 	 * and close it on finalize.
163 	 * Params:
164 	 * fd = a file descriptor to the PTY. [transfer full]
165 	 * Throws: GException on failure.
166 	 * Throws: ConstructionException GTK+ fails to create the object.
167 	 */
168 	public this (int fd)
169 	{
170 		// VtePty * vte_pty_new_foreign (int fd,  GError **error);
171 		GError* err = null;
172 		
173 		auto p = vte_pty_new_foreign(fd, &err);
174 		
175 		if (err !is null)
176 		{
177 			throw new GException( new ErrorG(err) );
178 		}
179 		
180 		if(p is null)
181 		{
182 			throw new ConstructionException("null returned by vte_pty_new_foreign(fd, &err)");
183 		}
184 		this(cast(VtePty*) p);
185 	}
186 	
187 	/**
188 	 * Cleans up the PTY, specifically any logging performed for the session.
189 	 * The file descriptor to the PTY master remains open.
190 	 */
191 	public void close()
192 	{
193 		// void vte_pty_close (VtePty *pty);
194 		vte_pty_close(vtePty);
195 	}
196 	
197 	/**
198 	 * FIXMEchpe
199 	 */
200 	public void childSetup()
201 	{
202 		// void vte_pty_child_setup (VtePty *pty);
203 		vte_pty_child_setup(vtePty);
204 	}
205 	
206 	/**
207 	 * Returns: the file descriptor of the PTY master in pty. The file descriptor belongs to pty and must not be closed. [transfer none]
208 	 */
209 	public int getFd()
210 	{
211 		// int vte_pty_get_fd (VtePty *pty);
212 		return vte_pty_get_fd(vtePty);
213 	}
214 	
215 	/**
216 	 * Attempts to resize the pseudo terminal's window size. If successful, the
217 	 * OS kernel will send SIGWINCH to the child process group.
218 	 * If setting the window size failed, error will be set to a GIOError.
219 	 * Params:
220 	 * rows = the desired number of rows
221 	 * columns = the desired number of columns
222 	 * Returns: TRUE on success, FALSE on failure with error filled in Since 0.26
223 	 * Throws: GException on failure.
224 	 */
225 	public int setSize(int rows, int columns)
226 	{
227 		// gboolean vte_pty_set_size (VtePty *pty,  int rows,  int columns,  GError **error);
228 		GError* err = null;
229 		
230 		auto p = vte_pty_set_size(vtePty, rows, columns, &err);
231 		
232 		if (err !is null)
233 		{
234 			throw new GException( new ErrorG(err) );
235 		}
236 		
237 		return p;
238 	}
239 	
240 	/**
241 	 * Reads the pseudo terminal's window size.
242 	 * If getting the window size failed, error will be set to a GIOError.
243 	 * Params:
244 	 * rows = a location to store the number of rows, or NULL. [out][allow-none]
245 	 * columns = a location to store the number of columns, or NULL. [out][allow-none]
246 	 * Returns: TRUE on success, FALSE on failure with error filled in Since 0.26
247 	 * Throws: GException on failure.
248 	 */
249 	public int getSize(out int rows, out int columns)
250 	{
251 		// gboolean vte_pty_get_size (VtePty *pty,  int *rows,  int *columns,  GError **error);
252 		GError* err = null;
253 		
254 		auto p = vte_pty_get_size(vtePty, &rows, &columns, &err);
255 		
256 		if (err !is null)
257 		{
258 			throw new GException( new ErrorG(err) );
259 		}
260 		
261 		return p;
262 	}
263 	
264 	/**
265 	 * Sets what value of the TERM environment variable to set just after forking.
266 	 * Params:
267 	 * emulation = the name of a terminal description, or NULL. [allow-none]
268 	 * Since 0.26
269 	 */
270 	public void setTerm(string emulation)
271 	{
272 		// void vte_pty_set_term (VtePty *pty,  const char *emulation);
273 		vte_pty_set_term(vtePty, Str.toStringz(emulation));
274 	}
275 	
276 	/**
277 	 * Tells the kernel whether the terminal is UTF-8 or not, in case it can make
278 	 * use of the info. Linux 2.6.5 or so defines IUTF8 to make the line
279 	 * discipline do multibyte backspace correctly.
280 	 * Params:
281 	 * utf8 = whether or not the pty is in UTF-8 mode
282 	 * Returns: TRUE on success, FALSE on failure with error filled in Since 0.26
283 	 * Throws: GException on failure.
284 	 */
285 	public int setUtf8(int utf8)
286 	{
287 		// gboolean vte_pty_set_utf8 (VtePty *pty,  gboolean utf8,  GError **error);
288 		GError* err = null;
289 		
290 		auto p = vte_pty_set_utf8(vtePty, utf8, &err);
291 		
292 		if (err !is null)
293 		{
294 			throw new GException( new ErrorG(err) );
295 		}
296 		
297 		return p;
298 	}
299 }