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  = GtkAssistant.html
27  * outPack = gtk
28  * outFile = Assistant
29  * strct   = GtkAssistant
30  * realStrct=
31  * ctorStrct=
32  * clss    = Assistant
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_assistant_
41  * 	- gtk_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- gdk.Pixbuf
49  * 	- gtk.Widget
50  * structWrap:
51  * 	- GdkPixbuf* -> Pixbuf
52  * 	- GtkWidget* -> Widget
53  * module aliases:
54  * local aliases:
55  * overrides:
56  */
57 
58 module gtk.Assistant;
59 
60 public  import gtkc.gtktypes;
61 
62 private import gtkc.gtk;
63 private import glib.ConstructionException;
64 private import gobject.ObjectG;
65 
66 private import gobject.Signals;
67 public  import gtkc.gdktypes;
68 
69 private import glib.Str;
70 private import gdk.Pixbuf;
71 private import gtk.Widget;
72 
73 
74 
75 private import gtk.Window;
76 
77 /**
78  * Description
79  * A GtkAssistant is a widget used to represent a generally complex
80  * operation splitted in several steps, guiding the user through its pages
81  * and controlling the page flow to collect the necessary data.
82  * GtkAssistant as GtkBuildable
83  * The GtkAssistant implementation of the GtkBuildable interface exposes the
84  * action_area as internal children with the name "action_area".
85  * To add pages to an assistant in GtkBuilder, simply add it as a
86  * <child> to the GtkAssistant object, and set its child properties
87  * as necessary.
88  */
89 public class Assistant : Window
90 {
91 	
92 	/** the main Gtk struct */
93 	protected GtkAssistant* gtkAssistant;
94 	
95 	
96 	public GtkAssistant* getAssistantStruct()
97 	{
98 		return gtkAssistant;
99 	}
100 	
101 	
102 	/** the main Gtk struct as a void* */
103 	protected override void* getStruct()
104 	{
105 		return cast(void*)gtkAssistant;
106 	}
107 	
108 	/**
109 	 * Sets our main struct and passes it to the parent class
110 	 */
111 	public this (GtkAssistant* gtkAssistant)
112 	{
113 		super(cast(GtkWindow*)gtkAssistant);
114 		this.gtkAssistant = gtkAssistant;
115 	}
116 	
117 	protected override void setStruct(GObject* obj)
118 	{
119 		super.setStruct(obj);
120 		gtkAssistant = cast(GtkAssistant*)obj;
121 	}
122 	
123 	/**
124 	 */
125 	int[string] connectedSignals;
126 	
127 	void delegate(Assistant)[] onApplyListeners;
128 	/**
129 	 * The ::apply signal is emitted when the apply button is clicked. The default
130 	 * behavior of the GtkAssistant is to switch to the page after the current
131 	 * page, unless the current page is the last one.
132 	 * A handler for the ::apply signal should carry out the actions for which
133 	 * the wizard has collected data. If the action takes a long time to complete,
134 	 * you might consider putting a page of type GTK_ASSISTANT_PAGE_PROGRESS
135 	 * after the confirmation page and handle this operation within the
136 	 * "prepare" signal of the progress page.
137 	 * Since 2.10
138 	 */
139 	void addOnApply(void delegate(Assistant) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
140 	{
141 		if ( !("apply" in connectedSignals) )
142 		{
143 			Signals.connectData(
144 			getStruct(),
145 			"apply",
146 			cast(GCallback)&callBackApply,
147 			cast(void*)this,
148 			null,
149 			connectFlags);
150 			connectedSignals["apply"] = 1;
151 		}
152 		onApplyListeners ~= dlg;
153 	}
154 	extern(C) static void callBackApply(GtkAssistant* assistantStruct, Assistant _assistant)
155 	{
156 		foreach ( void delegate(Assistant) dlg ; _assistant.onApplyListeners )
157 		{
158 			dlg(_assistant);
159 		}
160 	}
161 	
162 	void delegate(Assistant)[] onCancelListeners;
163 	/**
164 	 * The ::cancel signal is emitted when then the cancel button is clicked.
165 	 * Since 2.10
166 	 */
167 	void addOnCancel(void delegate(Assistant) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
168 	{
169 		if ( !("cancel" in connectedSignals) )
170 		{
171 			Signals.connectData(
172 			getStruct(),
173 			"cancel",
174 			cast(GCallback)&callBackCancel,
175 			cast(void*)this,
176 			null,
177 			connectFlags);
178 			connectedSignals["cancel"] = 1;
179 		}
180 		onCancelListeners ~= dlg;
181 	}
182 	extern(C) static void callBackCancel(GtkAssistant* assistantStruct, Assistant _assistant)
183 	{
184 		foreach ( void delegate(Assistant) dlg ; _assistant.onCancelListeners )
185 		{
186 			dlg(_assistant);
187 		}
188 	}
189 	
190 	void delegate(Assistant)[] onCloseListeners;
191 	/**
192 	 * The ::close signal is emitted either when the close button of
193 	 * a summary page is clicked, or when the apply button in the last
194 	 * page in the flow (of type GTK_ASSISTANT_PAGE_CONFIRM) is clicked.
195 	 * Since 2.10
196 	 */
197 	void addOnClose(void delegate(Assistant) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
198 	{
199 		if ( !("close" in connectedSignals) )
200 		{
201 			Signals.connectData(
202 			getStruct(),
203 			"close",
204 			cast(GCallback)&callBackClose,
205 			cast(void*)this,
206 			null,
207 			connectFlags);
208 			connectedSignals["close"] = 1;
209 		}
210 		onCloseListeners ~= dlg;
211 	}
212 	extern(C) static void callBackClose(GtkAssistant* assistantStruct, Assistant _assistant)
213 	{
214 		foreach ( void delegate(Assistant) dlg ; _assistant.onCloseListeners )
215 		{
216 			dlg(_assistant);
217 		}
218 	}
219 	
220 	void delegate(Widget, Assistant)[] onPrepareListeners;
221 	/**
222 	 * The ::prepare signal is emitted when a new page is set as the assistant's
223 	 * current page, before making the new page visible. A handler for this signal
224 	 * can do any preparation which are necessary before showing page.
225 	 * Since 2.10
226 	 */
227 	void addOnPrepare(void delegate(Widget, Assistant) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
228 	{
229 		if ( !("prepare" in connectedSignals) )
230 		{
231 			Signals.connectData(
232 			getStruct(),
233 			"prepare",
234 			cast(GCallback)&callBackPrepare,
235 			cast(void*)this,
236 			null,
237 			connectFlags);
238 			connectedSignals["prepare"] = 1;
239 		}
240 		onPrepareListeners ~= dlg;
241 	}
242 	extern(C) static void callBackPrepare(GtkAssistant* assistantStruct, GtkWidget* page, Assistant _assistant)
243 	{
244 		foreach ( void delegate(Widget, Assistant) dlg ; _assistant.onPrepareListeners )
245 		{
246 			dlg(ObjectG.getDObject!(Widget)(page), _assistant);
247 		}
248 	}
249 	
250 	
251 	/**
252 	 * Creates a new GtkAssistant.
253 	 * Since 2.10
254 	 * Throws: ConstructionException GTK+ fails to create the object.
255 	 */
256 	public this ()
257 	{
258 		// GtkWidget * gtk_assistant_new (void);
259 		auto p = gtk_assistant_new();
260 		if(p is null)
261 		{
262 			throw new ConstructionException("null returned by gtk_assistant_new()");
263 		}
264 		this(cast(GtkAssistant*) p);
265 	}
266 	
267 	/**
268 	 * Returns the page number of the current page
269 	 * Since 2.10
270 	 * Returns: The index (starting from 0) of the current page in the assistant, if the assistant has no pages, -1 will be returned
271 	 */
272 	public int getCurrentPage()
273 	{
274 		// gint gtk_assistant_get_current_page (GtkAssistant *assistant);
275 		return gtk_assistant_get_current_page(gtkAssistant);
276 	}
277 	
278 	/**
279 	 * Switches the page to page_num. Note that this will only be necessary
280 	 * in custom buttons, as the assistant flow can be set with
281 	 * gtk_assistant_set_forward_page_func().
282 	 * Since 2.10
283 	 * Params:
284 	 * pageNum = index of the page to switch to, starting from 0.
285 	 * If negative, the last page will be used. If greater
286 	 * than the number of pages in the assistant, nothing
287 	 * will be done.
288 	 */
289 	public void setCurrentPage(int pageNum)
290 	{
291 		// void gtk_assistant_set_current_page (GtkAssistant *assistant,  gint page_num);
292 		gtk_assistant_set_current_page(gtkAssistant, pageNum);
293 	}
294 	
295 	/**
296 	 * Returns the number of pages in the assistant
297 	 * Since 2.10
298 	 * Returns: The number of pages in the assistant.
299 	 */
300 	public int getNPages()
301 	{
302 		// gint gtk_assistant_get_n_pages (GtkAssistant *assistant);
303 		return gtk_assistant_get_n_pages(gtkAssistant);
304 	}
305 	
306 	/**
307 	 * Returns the child widget contained in page number page_num.
308 	 * Since 2.10
309 	 * Params:
310 	 * pageNum = The index of a page in the assistant, or -1 to get the last page;
311 	 * Returns: The child widget, or NULL if page_num is out of bounds. [transfer none]
312 	 */
313 	public Widget getNthPage(int pageNum)
314 	{
315 		// GtkWidget * gtk_assistant_get_nth_page (GtkAssistant *assistant,  gint page_num);
316 		auto p = gtk_assistant_get_nth_page(gtkAssistant, pageNum);
317 		
318 		if(p is null)
319 		{
320 			return null;
321 		}
322 		
323 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
324 	}
325 	
326 	/**
327 	 * Prepends a page to the assistant.
328 	 * Since 2.10
329 	 * Params:
330 	 * page = a GtkWidget
331 	 * Returns: the index (starting at 0) of the inserted page
332 	 */
333 	public int prependPage(Widget page)
334 	{
335 		// gint gtk_assistant_prepend_page (GtkAssistant *assistant,  GtkWidget *page);
336 		return gtk_assistant_prepend_page(gtkAssistant, (page is null) ? null : page.getWidgetStruct());
337 	}
338 	
339 	/**
340 	 * Appends a page to the assistant.
341 	 * Since 2.10
342 	 * Params:
343 	 * page = a GtkWidget
344 	 * Returns: the index (starting at 0) of the inserted page
345 	 */
346 	public int appendPage(Widget page)
347 	{
348 		// gint gtk_assistant_append_page (GtkAssistant *assistant,  GtkWidget *page);
349 		return gtk_assistant_append_page(gtkAssistant, (page is null) ? null : page.getWidgetStruct());
350 	}
351 	
352 	/**
353 	 * Inserts a page in the assistant at a given position.
354 	 * Since 2.10
355 	 * Params:
356 	 * page = a GtkWidget
357 	 * position = the index (starting at 0) at which to insert the page,
358 	 * or -1 to append the page to the assistant
359 	 * Returns: the index (starting from 0) of the inserted page
360 	 */
361 	public int insertPage(Widget page, int position)
362 	{
363 		// gint gtk_assistant_insert_page (GtkAssistant *assistant,  GtkWidget *page,  gint position);
364 		return gtk_assistant_insert_page(gtkAssistant, (page is null) ? null : page.getWidgetStruct(), position);
365 	}
366 	
367 	/**
368 	 * Sets the page forwarding function to be page_func, this function will
369 	 * be used to determine what will be the next page when the user presses
370 	 * the forward button. Setting page_func to NULL will make the assistant
371 	 * to use the default forward function, which just goes to the next visible
372 	 * page.
373 	 * Since 2.10
374 	 * Params:
375 	 * pageFunc = the GtkAssistantPageFunc, or NULL to use the default one. [allow-none]
376 	 * data = user data for page_func
377 	 * destroy = destroy notifier for data
378 	 */
379 	public void setForwardPageFunc(GtkAssistantPageFunc pageFunc, void* data, GDestroyNotify destroy)
380 	{
381 		// void gtk_assistant_set_forward_page_func (GtkAssistant *assistant,  GtkAssistantPageFunc page_func,  gpointer data,  GDestroyNotify destroy);
382 		gtk_assistant_set_forward_page_func(gtkAssistant, pageFunc, data, destroy);
383 	}
384 	
385 	/**
386 	 * Sets the page type for page. The page type determines the page
387 	 * behavior in the assistant.
388 	 * Since 2.10
389 	 * Params:
390 	 * page = a page of assistant
391 	 * type = the new type for page
392 	 */
393 	public void setPageType(Widget page, GtkAssistantPageType type)
394 	{
395 		// void gtk_assistant_set_page_type (GtkAssistant *assistant,  GtkWidget *page,  GtkAssistantPageType type);
396 		gtk_assistant_set_page_type(gtkAssistant, (page is null) ? null : page.getWidgetStruct(), type);
397 	}
398 	
399 	/**
400 	 * Gets the page type of page.
401 	 * Since 2.10
402 	 * Params:
403 	 * page = a page of assistant
404 	 * Returns: the page type of page.
405 	 */
406 	public GtkAssistantPageType getPageType(Widget page)
407 	{
408 		// GtkAssistantPageType gtk_assistant_get_page_type (GtkAssistant *assistant,  GtkWidget *page);
409 		return gtk_assistant_get_page_type(gtkAssistant, (page is null) ? null : page.getWidgetStruct());
410 	}
411 	
412 	/**
413 	 * Sets a title for page. The title is displayed in the header
414 	 * area of the assistant when page is the current page.
415 	 * Since 2.10
416 	 * Params:
417 	 * page = a page of assistant
418 	 * title = the new title for page
419 	 */
420 	public void setPageTitle(Widget page, string title)
421 	{
422 		// void gtk_assistant_set_page_title (GtkAssistant *assistant,  GtkWidget *page,  const gchar *title);
423 		gtk_assistant_set_page_title(gtkAssistant, (page is null) ? null : page.getWidgetStruct(), Str.toStringz(title));
424 	}
425 	
426 	/**
427 	 * Gets the title for page.
428 	 * Since 2.10
429 	 * Params:
430 	 * page = a page of assistant
431 	 * Returns: the title for page.
432 	 */
433 	public string getPageTitle(Widget page)
434 	{
435 		// const gchar * gtk_assistant_get_page_title (GtkAssistant *assistant,  GtkWidget *page);
436 		return Str.toString(gtk_assistant_get_page_title(gtkAssistant, (page is null) ? null : page.getWidgetStruct()));
437 	}
438 	
439 	/**
440 	 * Sets a header image for page. This image is displayed in the header
441 	 * area of the assistant when page is the current page.
442 	 * Since 2.10
443 	 * Params:
444 	 * page = a page of assistant
445 	 * pixbuf = the new header image page. [allow-none]
446 	 */
447 	public void setPageHeaderImage(Widget page, Pixbuf pixbuf)
448 	{
449 		// void gtk_assistant_set_page_header_image (GtkAssistant *assistant,  GtkWidget *page,  GdkPixbuf *pixbuf);
450 		gtk_assistant_set_page_header_image(gtkAssistant, (page is null) ? null : page.getWidgetStruct(), (pixbuf is null) ? null : pixbuf.getPixbufStruct());
451 	}
452 	
453 	/**
454 	 * Gets the header image for page.
455 	 * Since 2.10
456 	 * Params:
457 	 * page = a page of assistant
458 	 * Returns: the header image for page, or NULL if there's no header image for the page. [transfer none]
459 	 */
460 	public Pixbuf getPageHeaderImage(Widget page)
461 	{
462 		// GdkPixbuf * gtk_assistant_get_page_header_image (GtkAssistant *assistant,  GtkWidget *page);
463 		auto p = gtk_assistant_get_page_header_image(gtkAssistant, (page is null) ? null : page.getWidgetStruct());
464 		
465 		if(p is null)
466 		{
467 			return null;
468 		}
469 		
470 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p);
471 	}
472 	
473 	/**
474 	 * Sets a header image for page. This image is displayed in the side
475 	 * area of the assistant when page is the current page.
476 	 * Since 2.10
477 	 * Params:
478 	 * page = a page of assistant
479 	 * pixbuf = the new header image page. [allow-none]
480 	 */
481 	public void setPageSideImage(Widget page, Pixbuf pixbuf)
482 	{
483 		// void gtk_assistant_set_page_side_image (GtkAssistant *assistant,  GtkWidget *page,  GdkPixbuf *pixbuf);
484 		gtk_assistant_set_page_side_image(gtkAssistant, (page is null) ? null : page.getWidgetStruct(), (pixbuf is null) ? null : pixbuf.getPixbufStruct());
485 	}
486 	
487 	/**
488 	 * Gets the header image for page.
489 	 * Since 2.10
490 	 * Params:
491 	 * page = a page of assistant
492 	 * Returns: the side image for page, or NULL if there's no side image for the page. [transfer none]
493 	 */
494 	public Pixbuf getPageSideImage(Widget page)
495 	{
496 		// GdkPixbuf * gtk_assistant_get_page_side_image (GtkAssistant *assistant,  GtkWidget *page);
497 		auto p = gtk_assistant_get_page_side_image(gtkAssistant, (page is null) ? null : page.getWidgetStruct());
498 		
499 		if(p is null)
500 		{
501 			return null;
502 		}
503 		
504 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p);
505 	}
506 	
507 	/**
508 	 * Sets whether page contents are complete. This will make
509 	 * assistant update the buttons state to be able to continue the task.
510 	 * Since 2.10
511 	 * Params:
512 	 * page = a page of assistant
513 	 * complete = the completeness status of the page
514 	 */
515 	public void setPageComplete(Widget page, int complete)
516 	{
517 		// void gtk_assistant_set_page_complete (GtkAssistant *assistant,  GtkWidget *page,  gboolean complete);
518 		gtk_assistant_set_page_complete(gtkAssistant, (page is null) ? null : page.getWidgetStruct(), complete);
519 	}
520 	
521 	/**
522 	 * Gets whether page is complete.
523 	 * Since 2.10
524 	 * Params:
525 	 * page = a page of assistant
526 	 * Returns: TRUE if page is complete.
527 	 */
528 	public int getPageComplete(Widget page)
529 	{
530 		// gboolean gtk_assistant_get_page_complete (GtkAssistant *assistant,  GtkWidget *page);
531 		return gtk_assistant_get_page_complete(gtkAssistant, (page is null) ? null : page.getWidgetStruct());
532 	}
533 	
534 	/**
535 	 * Adds a widget to the action area of a GtkAssistant.
536 	 * Since 2.10
537 	 * Params:
538 	 * child = a GtkWidget
539 	 */
540 	public void addActionWidget(Widget child)
541 	{
542 		// void gtk_assistant_add_action_widget (GtkAssistant *assistant,  GtkWidget *child);
543 		gtk_assistant_add_action_widget(gtkAssistant, (child is null) ? null : child.getWidgetStruct());
544 	}
545 	
546 	/**
547 	 * Removes a widget from the action area of a GtkAssistant.
548 	 * Since 2.10
549 	 * Params:
550 	 * child = a GtkWidget
551 	 */
552 	public void removeActionWidget(Widget child)
553 	{
554 		// void gtk_assistant_remove_action_widget (GtkAssistant *assistant,  GtkWidget *child);
555 		gtk_assistant_remove_action_widget(gtkAssistant, (child is null) ? null : child.getWidgetStruct());
556 	}
557 	
558 	/**
559 	 * Forces assistant to recompute the buttons state.
560 	 * GTK+ automatically takes care of this in most situations,
561 	 * e.g. when the user goes to a different page, or when the
562 	 * visibility or completeness of a page changes.
563 	 * One situation where it can be necessary to call this
564 	 * function is when changing a value on the current page
565 	 * affects the future page flow of the assistant.
566 	 * Since 2.10
567 	 */
568 	public void updateButtonsState()
569 	{
570 		// void gtk_assistant_update_buttons_state (GtkAssistant *assistant);
571 		gtk_assistant_update_buttons_state(gtkAssistant);
572 	}
573 	
574 	/**
575 	 * Erases the visited page history so the back button is not
576 	 * shown on the current page, and removes the cancel button
577 	 * from subsequent pages.
578 	 * Use this when the information provided up to the current
579 	 * page is hereafter deemed permanent and cannot be modified
580 	 * or undone. For example, showing a progress page to track
581 	 * a long-running, unreversible operation after the user has
582 	 * clicked apply on a confirmation page.
583 	 * Since 2.22
584 	 * Child Property Details
585 	 * The "complete" child property
586 	 *  "complete" gboolean : Read / Write
587 	 * Setting the "complete" child property to TRUE marks a page as complete
588 	 * (i.e.: all the required fields are filled out). GTK+ uses this information
589 	 * to control the sensitivity of the navigation buttons.
590 	 * Default value: FALSE
591 	 * Since 2.10
592 	 */
593 	public void commit()
594 	{
595 		// void gtk_assistant_commit (GtkAssistant *assistant);
596 		gtk_assistant_commit(gtkAssistant);
597 	}
598 }