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 private import glib.Str;
67 private import glib.ErrorG;
68 private import glib.GException;
69 private import gio.InitableIF;
70 private import gio.InitableT;
71 
72 
73 
74 /**
75  * The terminal widget uses these functions to start commands with new controlling
76  * pseudo-terminals and to resize pseudo-terminals.
77  */
78 public class Pty : InitableIF
79 {
80 	
81 	/** the main Gtk struct */
82 	protected VtePty* vtePty;
83 	
84 	
85 	/** Get the main Gtk struct */
86 	public VtePty* getPtyStruct()
87 	{
88 		return vtePty;
89 	}
90 	
91 	
92 	/** the main Gtk struct as a void* */
93 	protected void* getStruct()
94 	{
95 		return cast(void*)vtePty;
96 	}
97 	
98 	/**
99 	 * Sets our main struct and passes it to the parent class
100 	 */
101 	public this (VtePty* vtePty)
102 	{
103 		this.vtePty = vtePty;
104 	}
105 	
106 	// add the Initable capabilities
107 	mixin InitableT!(VtePty);
108 	
109 	/**
110 	 */
111 	
112 	/**
113 	 * Allocates a new pseudo-terminal.
114 	 * You can later use fork() or the g_spawn_async() family of functions
115 	 * to start a process on the PTY.
116 	 * If using fork(), you MUST call vte_pty_child_setup() in the child.
117 	 * If using g_spawn_async() and friends, you MUST either use
118 	 * vte_pty_child_setup() directly as the child setup function, or call
119 	 * vte_pty_child_setup() from your own child setup function supplied.
120 	 * When using vte_terminal_fork_command_full() with a custom child setup
121 	 * function, vte_pty_child_setup() will be called before the supplied
122 	 * function; you must not call it again.
123 	 * Also, you MUST pass the G_SPAWN_DO_NOT_REAP_CHILD flag.
124 	 * If GNOME PTY Helper is available and
125 	 * unless some of the VTE_PTY_NO_LASTLOG, VTE_PTY_NO_UTMP or
126 	 * VTE_PTY_NO_WTMP flags are passed in flags, the
127 	 * session is logged in the corresponding lastlog, utmp or wtmp
128 	 * system files. When passing VTE_PTY_NO_HELPER in flags, the
129 	 * GNOME PTY Helper is bypassed entirely.
130 	 * When passing VTE_PTY_NO_FALLBACK in flags,
131 	 * and opening a PTY using the PTY helper fails, there will
132 	 * be no fallback to allocate a PTY using Unix98 PTY functions.
133 	 * Params:
134 	 * flags = flags from VtePtyFlags
135 	 * Throws: GException on failure.
136 	 * Throws: ConstructionException GTK+ fails to create the object.
137 	 */
138 	public this (VtePtyFlags flags)
139 	{
140 		// VtePty * vte_pty_new (VtePtyFlags flags,  GError **error);
141 		GError* err = null;
142 		
143 		auto p = vte_pty_new(flags, &err);
144 		
145 		if (err !is null)
146 		{
147 			throw new GException( new ErrorG(err) );
148 		}
149 		
150 		if(p is null)
151 		{
152 			throw new ConstructionException("null returned by vte_pty_new(flags, &err)");
153 		}
154 		this(cast(VtePty*) p);
155 	}
156 	
157 	/**
158 	 * Creates a new VtePty for the PTY master fd.
159 	 * No entry will be made in the lastlog, utmp or wtmp system files.
160 	 * Note that the newly created VtePty will take ownership of fd
161 	 * and close it on finalize.
162 	 * Params:
163 	 * fd = a file descriptor to the PTY. [transfer full]
164 	 * Throws: GException on failure.
165 	 * Throws: ConstructionException GTK+ fails to create the object.
166 	 */
167 	public this (int fd)
168 	{
169 		// VtePty * vte_pty_new_foreign (int fd,  GError **error);
170 		GError* err = null;
171 		
172 		auto p = vte_pty_new_foreign(fd, &err);
173 		
174 		if (err !is null)
175 		{
176 			throw new GException( new ErrorG(err) );
177 		}
178 		
179 		if(p is null)
180 		{
181 			throw new ConstructionException("null returned by vte_pty_new_foreign(fd, &err)");
182 		}
183 		this(cast(VtePty*) p);
184 	}
185 	
186 	/**
187 	 * Cleans up the PTY, specifically any logging performed for the session.
188 	 * The file descriptor to the PTY master remains open.
189 	 */
190 	public void close()
191 	{
192 		// void vte_pty_close (VtePty *pty);
193 		vte_pty_close(vtePty);
194 	}
195 	
196 	/**
197 	 * FIXMEchpe
198 	 */
199 	public void childSetup()
200 	{
201 		// void vte_pty_child_setup (VtePty *pty);
202 		vte_pty_child_setup(vtePty);
203 	}
204 	
205 	/**
206 	 * Returns: the file descriptor of the PTY master in pty. The file descriptor belongs to pty and must not be closed. [transfer none]
207 	 */
208 	public int getFd()
209 	{
210 		// int vte_pty_get_fd (VtePty *pty);
211 		return vte_pty_get_fd(vtePty);
212 	}
213 	
214 	/**
215 	 * Attempts to resize the pseudo terminal's window size. If successful, the
216 	 * OS kernel will send SIGWINCH to the child process group.
217 	 * If setting the window size failed, error will be set to a GIOError.
218 	 * Params:
219 	 * rows = the desired number of rows
220 	 * columns = the desired number of columns
221 	 * Returns: TRUE on success, FALSE on failure with error filled in Since 0.26
222 	 * Throws: GException on failure.
223 	 */
224 	public int setSize(int rows, int columns)
225 	{
226 		// gboolean vte_pty_set_size (VtePty *pty,  int rows,  int columns,  GError **error);
227 		GError* err = null;
228 		
229 		auto p = vte_pty_set_size(vtePty, rows, columns, &err);
230 		
231 		if (err !is null)
232 		{
233 			throw new GException( new ErrorG(err) );
234 		}
235 		
236 		return p;
237 	}
238 	
239 	/**
240 	 * Reads the pseudo terminal's window size.
241 	 * If getting the window size failed, error will be set to a GIOError.
242 	 * Params:
243 	 * rows = a location to store the number of rows, or NULL. [out][allow-none]
244 	 * columns = a location to store the number of columns, or NULL. [out][allow-none]
245 	 * Returns: TRUE on success, FALSE on failure with error filled in Since 0.26
246 	 * Throws: GException on failure.
247 	 */
248 	public int getSize(out int rows, out int columns)
249 	{
250 		// gboolean vte_pty_get_size (VtePty *pty,  int *rows,  int *columns,  GError **error);
251 		GError* err = null;
252 		
253 		auto p = vte_pty_get_size(vtePty, &rows, &columns, &err);
254 		
255 		if (err !is null)
256 		{
257 			throw new GException( new ErrorG(err) );
258 		}
259 		
260 		return p;
261 	}
262 	
263 	/**
264 	 * Sets what value of the TERM environment variable to set just after forking.
265 	 * Params:
266 	 * emulation = the name of a terminal description, or NULL. [allow-none]
267 	 * Since 0.26
268 	 */
269 	public void setTerm(string emulation)
270 	{
271 		// void vte_pty_set_term (VtePty *pty,  const char *emulation);
272 		vte_pty_set_term(vtePty, Str.toStringz(emulation));
273 	}
274 	
275 	/**
276 	 * Tells the kernel whether the terminal is UTF-8 or not, in case it can make
277 	 * use of the info. Linux 2.6.5 or so defines IUTF8 to make the line
278 	 * discipline do multibyte backspace correctly.
279 	 * Params:
280 	 * utf8 = whether or not the pty is in UTF-8 mode
281 	 * Returns: TRUE on success, FALSE on failure with error filled in Since 0.26
282 	 * Throws: GException on failure.
283 	 */
284 	public int setUtf8(int utf8)
285 	{
286 		// gboolean vte_pty_set_utf8 (VtePty *pty,  gboolean utf8,  GError **error);
287 		GError* err = null;
288 		
289 		auto p = vte_pty_set_utf8(vtePty, utf8, &err);
290 		
291 		if (err !is null)
292 		{
293 			throw new GException( new ErrorG(err) );
294 		}
295 		
296 		return p;
297 	}
298 }