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 module gtk.Assistant;
26 
27 private import gdkpixbuf.Pixbuf;
28 private import glib.ConstructionException;
29 private import glib.Str;
30 private import gobject.ObjectG;
31 private import gobject.Signals;
32 private import gtk.Widget;
33 private import gtk.Window;
34 public  import gtkc.gdktypes;
35 private import gtkc.gtk;
36 public  import gtkc.gtktypes;
37 
38 
39 /**
40  * A #GtkAssistant is a widget used to represent a generally complex
41  * operation splitted in several steps, guiding the user through its
42  * pages and controlling the page flow to collect the necessary data.
43  * 
44  * The design of GtkAssistant is that it controls what buttons to show
45  * and to make sensitive, based on what it knows about the page sequence
46  * and the [type][GtkAssistantPageType] of each page,
47  * in addition to state information like the page
48  * [completion][gtk-assistant-set-page-complete]
49  * and [committed][gtk-assistant-commit] status.
50  * 
51  * If you have a case that doesn’t quite fit in #GtkAssistants way of
52  * handling buttons, you can use the #GTK_ASSISTANT_PAGE_CUSTOM page
53  * type and handle buttons yourself.
54  * 
55  * # GtkAssistant as GtkBuildable
56  * 
57  * The GtkAssistant implementation of the #GtkBuildable interface
58  * exposes the @action_area as internal children with the name
59  * “action_area”.
60  * 
61  * To add pages to an assistant in #GtkBuilder, simply add it as a
62  * child to the GtkAssistant object, and set its child properties
63  * as necessary.
64  */
65 public class Assistant : Window
66 {
67 	/** the main Gtk struct */
68 	protected GtkAssistant* gtkAssistant;
69 
70 	/** Get the main Gtk struct */
71 	public GtkAssistant* getAssistantStruct()
72 	{
73 		return gtkAssistant;
74 	}
75 
76 	/** the main Gtk struct as a void* */
77 	protected override void* getStruct()
78 	{
79 		return cast(void*)gtkAssistant;
80 	}
81 
82 	protected override void setStruct(GObject* obj)
83 	{
84 		gtkAssistant = cast(GtkAssistant*)obj;
85 		super.setStruct(obj);
86 	}
87 
88 	/**
89 	 * Sets our main struct and passes it to the parent class.
90 	 */
91 	public this (GtkAssistant* gtkAssistant, bool ownedRef = false)
92 	{
93 		this.gtkAssistant = gtkAssistant;
94 		super(cast(GtkWindow*)gtkAssistant, ownedRef);
95 	}
96 
97 
98 	/** */
99 	public static GType getType()
100 	{
101 		return gtk_assistant_get_type();
102 	}
103 
104 	/**
105 	 * Creates a new #GtkAssistant.
106 	 *
107 	 * Return: a newly created #GtkAssistant
108 	 *
109 	 * Since: 2.10
110 	 *
111 	 * Throws: ConstructionException GTK+ fails to create the object.
112 	 */
113 	public this()
114 	{
115 		auto p = gtk_assistant_new();
116 		
117 		if(p is null)
118 		{
119 			throw new ConstructionException("null returned by new");
120 		}
121 		
122 		this(cast(GtkAssistant*) p);
123 	}
124 
125 	/**
126 	 * Adds a widget to the action area of a #GtkAssistant.
127 	 *
128 	 * Params:
129 	 *     child = a #GtkWidget
130 	 *
131 	 * Since: 2.10
132 	 */
133 	public void addActionWidget(Widget child)
134 	{
135 		gtk_assistant_add_action_widget(gtkAssistant, (child is null) ? null : child.getWidgetStruct());
136 	}
137 
138 	/**
139 	 * Appends a page to the @assistant.
140 	 *
141 	 * Params:
142 	 *     page = a #GtkWidget
143 	 *
144 	 * Return: the index (starting at 0) of the inserted page
145 	 *
146 	 * Since: 2.10
147 	 */
148 	public int appendPage(Widget page)
149 	{
150 		return gtk_assistant_append_page(gtkAssistant, (page is null) ? null : page.getWidgetStruct());
151 	}
152 
153 	/**
154 	 * Erases the visited page history so the back button is not
155 	 * shown on the current page, and removes the cancel button
156 	 * from subsequent pages.
157 	 *
158 	 * Use this when the information provided up to the current
159 	 * page is hereafter deemed permanent and cannot be modified
160 	 * or undone. For example, showing a progress page to track
161 	 * a long-running, unreversible operation after the user has
162 	 * clicked apply on a confirmation page.
163 	 *
164 	 * Since: 2.22
165 	 */
166 	public void commit()
167 	{
168 		gtk_assistant_commit(gtkAssistant);
169 	}
170 
171 	/**
172 	 * Returns the page number of the current page.
173 	 *
174 	 * Return: The index (starting from 0) of the current
175 	 *     page in the @assistant, or -1 if the @assistant has no pages,
176 	 *     or no current page.
177 	 *
178 	 * Since: 2.10
179 	 */
180 	public int getCurrentPage()
181 	{
182 		return gtk_assistant_get_current_page(gtkAssistant);
183 	}
184 
185 	/**
186 	 * Returns the number of pages in the @assistant
187 	 *
188 	 * Return: the number of pages in the @assistant
189 	 *
190 	 * Since: 2.10
191 	 */
192 	public int getNPages()
193 	{
194 		return gtk_assistant_get_n_pages(gtkAssistant);
195 	}
196 
197 	/**
198 	 * Returns the child widget contained in page number @page_num.
199 	 *
200 	 * Params:
201 	 *     pageNum = the index of a page in the @assistant,
202 	 *         or -1 to get the last page
203 	 *
204 	 * Return: the child widget, or %NULL
205 	 *     if @page_num is out of bounds
206 	 *
207 	 * Since: 2.10
208 	 */
209 	public Widget getNthPage(int pageNum)
210 	{
211 		auto p = gtk_assistant_get_nth_page(gtkAssistant, pageNum);
212 		
213 		if(p is null)
214 		{
215 			return null;
216 		}
217 		
218 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
219 	}
220 
221 	/**
222 	 * Gets whether @page is complete.
223 	 *
224 	 * Params:
225 	 *     page = a page of @assistant
226 	 *
227 	 * Return: %TRUE if @page is complete.
228 	 *
229 	 * Since: 2.10
230 	 */
231 	public bool getPageComplete(Widget page)
232 	{
233 		return gtk_assistant_get_page_complete(gtkAssistant, (page is null) ? null : page.getWidgetStruct()) != 0;
234 	}
235 
236 	/**
237 	 * Gets whether page has padding.
238 	 *
239 	 * Params:
240 	 *     page = a page of @assistant
241 	 *
242 	 * Return: %TRUE if @page has padding
243 	 *
244 	 * Since: 3.18
245 	 */
246 	public bool getPageHasPadding(Widget page)
247 	{
248 		return gtk_assistant_get_page_has_padding(gtkAssistant, (page is null) ? null : page.getWidgetStruct()) != 0;
249 	}
250 
251 	/**
252 	 * Gets the header image for @page.
253 	 *
254 	 * Deprecated: Since GTK+ 3.2, a header is no longer shown;
255 	 * add your header decoration to the page content instead.
256 	 *
257 	 * Params:
258 	 *     page = a page of @assistant
259 	 *
260 	 * Return: the header image for @page,
261 	 *     or %NULL if there’s no header image for the page
262 	 *
263 	 * Since: 2.10
264 	 */
265 	public Pixbuf getPageHeaderImage(Widget page)
266 	{
267 		auto p = gtk_assistant_get_page_header_image(gtkAssistant, (page is null) ? null : page.getWidgetStruct());
268 		
269 		if(p is null)
270 		{
271 			return null;
272 		}
273 		
274 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p);
275 	}
276 
277 	/**
278 	 * Gets the side image for @page.
279 	 *
280 	 * Deprecated: Since GTK+ 3.2, sidebar images are not
281 	 * shown anymore.
282 	 *
283 	 * Params:
284 	 *     page = a page of @assistant
285 	 *
286 	 * Return: the side image for @page,
287 	 *     or %NULL if there’s no side image for the page
288 	 *
289 	 * Since: 2.10
290 	 */
291 	public Pixbuf getPageSideImage(Widget page)
292 	{
293 		auto p = gtk_assistant_get_page_side_image(gtkAssistant, (page is null) ? null : page.getWidgetStruct());
294 		
295 		if(p is null)
296 		{
297 			return null;
298 		}
299 		
300 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p);
301 	}
302 
303 	/**
304 	 * Gets the title for @page.
305 	 *
306 	 * Params:
307 	 *     page = a page of @assistant
308 	 *
309 	 * Return: the title for @page
310 	 *
311 	 * Since: 2.10
312 	 */
313 	public string getPageTitle(Widget page)
314 	{
315 		return Str.toString(gtk_assistant_get_page_title(gtkAssistant, (page is null) ? null : page.getWidgetStruct()));
316 	}
317 
318 	/**
319 	 * Gets the page type of @page.
320 	 *
321 	 * Params:
322 	 *     page = a page of @assistant
323 	 *
324 	 * Return: the page type of @page
325 	 *
326 	 * Since: 2.10
327 	 */
328 	public GtkAssistantPageType getPageType(Widget page)
329 	{
330 		return gtk_assistant_get_page_type(gtkAssistant, (page is null) ? null : page.getWidgetStruct());
331 	}
332 
333 	/**
334 	 * Inserts a page in the @assistant at a given position.
335 	 *
336 	 * Params:
337 	 *     page = a #GtkWidget
338 	 *     position = the index (starting at 0) at which to insert the page,
339 	 *         or -1 to append the page to the @assistant
340 	 *
341 	 * Return: the index (starting from 0) of the inserted page
342 	 *
343 	 * Since: 2.10
344 	 */
345 	public int insertPage(Widget page, int position)
346 	{
347 		return gtk_assistant_insert_page(gtkAssistant, (page is null) ? null : page.getWidgetStruct(), position);
348 	}
349 
350 	/**
351 	 * Navigate to the next page.
352 	 *
353 	 * It is a programming error to call this function when
354 	 * there is no next page.
355 	 *
356 	 * This function is for use when creating pages of the
357 	 * #GTK_ASSISTANT_PAGE_CUSTOM type.
358 	 *
359 	 * Since: 3.0
360 	 */
361 	public void nextPage()
362 	{
363 		gtk_assistant_next_page(gtkAssistant);
364 	}
365 
366 	/**
367 	 * Prepends a page to the @assistant.
368 	 *
369 	 * Params:
370 	 *     page = a #GtkWidget
371 	 *
372 	 * Return: the index (starting at 0) of the inserted page
373 	 *
374 	 * Since: 2.10
375 	 */
376 	public int prependPage(Widget page)
377 	{
378 		return gtk_assistant_prepend_page(gtkAssistant, (page is null) ? null : page.getWidgetStruct());
379 	}
380 
381 	/**
382 	 * Navigate to the previous visited page.
383 	 *
384 	 * It is a programming error to call this function when
385 	 * no previous page is available.
386 	 *
387 	 * This function is for use when creating pages of the
388 	 * #GTK_ASSISTANT_PAGE_CUSTOM type.
389 	 *
390 	 * Since: 3.0
391 	 */
392 	public void previousPage()
393 	{
394 		gtk_assistant_previous_page(gtkAssistant);
395 	}
396 
397 	/**
398 	 * Removes a widget from the action area of a #GtkAssistant.
399 	 *
400 	 * Params:
401 	 *     child = a #GtkWidget
402 	 *
403 	 * Since: 2.10
404 	 */
405 	public void removeActionWidget(Widget child)
406 	{
407 		gtk_assistant_remove_action_widget(gtkAssistant, (child is null) ? null : child.getWidgetStruct());
408 	}
409 
410 	/**
411 	 * Removes the @page_num’s page from @assistant.
412 	 *
413 	 * Params:
414 	 *     pageNum = the index of a page in the @assistant,
415 	 *         or -1 to remove the last page
416 	 *
417 	 * Since: 3.2
418 	 */
419 	public void removePage(int pageNum)
420 	{
421 		gtk_assistant_remove_page(gtkAssistant, pageNum);
422 	}
423 
424 	/**
425 	 * Switches the page to @page_num.
426 	 *
427 	 * Note that this will only be necessary in custom buttons,
428 	 * as the @assistant flow can be set with
429 	 * gtk_assistant_set_forward_page_func().
430 	 *
431 	 * Params:
432 	 *     pageNum = index of the page to switch to, starting from 0.
433 	 *         If negative, the last page will be used. If greater
434 	 *         than the number of pages in the @assistant, nothing
435 	 *         will be done.
436 	 *
437 	 * Since: 2.10
438 	 */
439 	public void setCurrentPage(int pageNum)
440 	{
441 		gtk_assistant_set_current_page(gtkAssistant, pageNum);
442 	}
443 
444 	/**
445 	 * Sets the page forwarding function to be @page_func.
446 	 *
447 	 * This function will be used to determine what will be
448 	 * the next page when the user presses the forward button.
449 	 * Setting @page_func to %NULL will make the assistant to
450 	 * use the default forward function, which just goes to the
451 	 * next visible page.
452 	 *
453 	 * Params:
454 	 *     pageFunc = the #GtkAssistantPageFunc, or %NULL
455 	 *         to use the default one
456 	 *     data = user data for @page_func
457 	 *     destroy = destroy notifier for @data
458 	 *
459 	 * Since: 2.10
460 	 */
461 	public void setForwardPageFunc(GtkAssistantPageFunc pageFunc, void* data, GDestroyNotify destroy)
462 	{
463 		gtk_assistant_set_forward_page_func(gtkAssistant, pageFunc, data, destroy);
464 	}
465 
466 	/**
467 	 * Sets whether @page contents are complete.
468 	 *
469 	 * This will make @assistant update the buttons state
470 	 * to be able to continue the task.
471 	 *
472 	 * Params:
473 	 *     page = a page of @assistant
474 	 *     complete = the completeness status of the page
475 	 *
476 	 * Since: 2.10
477 	 */
478 	public void setPageComplete(Widget page, bool complete)
479 	{
480 		gtk_assistant_set_page_complete(gtkAssistant, (page is null) ? null : page.getWidgetStruct(), complete);
481 	}
482 
483 	/**
484 	 * Sets whether the assistant is adding padding around
485 	 * the page.
486 	 *
487 	 * Params:
488 	 *     page = a page of @assistant
489 	 *     hasPadding = whether this page has padding
490 	 *
491 	 * Since: 3.18
492 	 */
493 	public void setPageHasPadding(Widget page, bool hasPadding)
494 	{
495 		gtk_assistant_set_page_has_padding(gtkAssistant, (page is null) ? null : page.getWidgetStruct(), hasPadding);
496 	}
497 
498 	/**
499 	 * Sets a header image for @page.
500 	 *
501 	 * Deprecated: Since GTK+ 3.2, a header is no longer shown;
502 	 * add your header decoration to the page content instead.
503 	 *
504 	 * Params:
505 	 *     page = a page of @assistant
506 	 *     pixbuf = the new header image @page
507 	 *
508 	 * Since: 2.10
509 	 */
510 	public void setPageHeaderImage(Widget page, Pixbuf pixbuf)
511 	{
512 		gtk_assistant_set_page_header_image(gtkAssistant, (page is null) ? null : page.getWidgetStruct(), (pixbuf is null) ? null : pixbuf.getPixbufStruct());
513 	}
514 
515 	/**
516 	 * Sets a side image for @page.
517 	 *
518 	 * This image used to be displayed in the side area of the assistant
519 	 * when @page is the current page.
520 	 *
521 	 * Deprecated: Since GTK+ 3.2, sidebar images are not
522 	 * shown anymore.
523 	 *
524 	 * Params:
525 	 *     page = a page of @assistant
526 	 *     pixbuf = the new side image @page
527 	 *
528 	 * Since: 2.10
529 	 */
530 	public void setPageSideImage(Widget page, Pixbuf pixbuf)
531 	{
532 		gtk_assistant_set_page_side_image(gtkAssistant, (page is null) ? null : page.getWidgetStruct(), (pixbuf is null) ? null : pixbuf.getPixbufStruct());
533 	}
534 
535 	/**
536 	 * Sets a title for @page.
537 	 *
538 	 * The title is displayed in the header area of the assistant
539 	 * when @page is the current page.
540 	 *
541 	 * Params:
542 	 *     page = a page of @assistant
543 	 *     title = the new title for @page
544 	 *
545 	 * Since: 2.10
546 	 */
547 	public void setPageTitle(Widget page, string title)
548 	{
549 		gtk_assistant_set_page_title(gtkAssistant, (page is null) ? null : page.getWidgetStruct(), Str.toStringz(title));
550 	}
551 
552 	/**
553 	 * Sets the page type for @page.
554 	 *
555 	 * The page type determines the page behavior in the @assistant.
556 	 *
557 	 * Params:
558 	 *     page = a page of @assistant
559 	 *     type = the new type for @page
560 	 *
561 	 * Since: 2.10
562 	 */
563 	public void setPageType(Widget page, GtkAssistantPageType type)
564 	{
565 		gtk_assistant_set_page_type(gtkAssistant, (page is null) ? null : page.getWidgetStruct(), type);
566 	}
567 
568 	/**
569 	 * Forces @assistant to recompute the buttons state.
570 	 *
571 	 * GTK+ automatically takes care of this in most situations,
572 	 * e.g. when the user goes to a different page, or when the
573 	 * visibility or completeness of a page changes.
574 	 *
575 	 * One situation where it can be necessary to call this
576 	 * function is when changing a value on the current page
577 	 * affects the future page flow of the assistant.
578 	 *
579 	 * Since: 2.10
580 	 */
581 	public void updateButtonsState()
582 	{
583 		gtk_assistant_update_buttons_state(gtkAssistant);
584 	}
585 
586 	int[string] connectedSignals;
587 
588 	void delegate(Assistant)[] onApplyListeners;
589 	/**
590 	 * The ::apply signal is emitted when the apply button is clicked.
591 	 *
592 	 * The default behavior of the #GtkAssistant is to switch to the page
593 	 * after the current page, unless the current page is the last one.
594 	 *
595 	 * A handler for the ::apply signal should carry out the actions for
596 	 * which the wizard has collected data. If the action takes a long time
597 	 * to complete, you might consider putting a page of type
598 	 * %GTK_ASSISTANT_PAGE_PROGRESS after the confirmation page and handle
599 	 * this operation within the #GtkAssistant::prepare signal of the progress
600 	 * page.
601 	 *
602 	 * Since: 2.10
603 	 */
604 	void addOnApply(void delegate(Assistant) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
605 	{
606 		if ( "apply" !in connectedSignals )
607 		{
608 			Signals.connectData(
609 				this,
610 				"apply",
611 				cast(GCallback)&callBackApply,
612 				cast(void*)this,
613 				null,
614 				connectFlags);
615 			connectedSignals["apply"] = 1;
616 		}
617 		onApplyListeners ~= dlg;
618 	}
619 	extern(C) static void callBackApply(GtkAssistant* assistantStruct, Assistant _assistant)
620 	{
621 		foreach ( void delegate(Assistant) dlg; _assistant.onApplyListeners )
622 		{
623 			dlg(_assistant);
624 		}
625 	}
626 
627 	void delegate(Assistant)[] onCancelListeners;
628 	/**
629 	 * The ::cancel signal is emitted when then the cancel button is clicked.
630 	 *
631 	 * Since: 2.10
632 	 */
633 	void addOnCancel(void delegate(Assistant) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
634 	{
635 		if ( "cancel" !in connectedSignals )
636 		{
637 			Signals.connectData(
638 				this,
639 				"cancel",
640 				cast(GCallback)&callBackCancel,
641 				cast(void*)this,
642 				null,
643 				connectFlags);
644 			connectedSignals["cancel"] = 1;
645 		}
646 		onCancelListeners ~= dlg;
647 	}
648 	extern(C) static void callBackCancel(GtkAssistant* assistantStruct, Assistant _assistant)
649 	{
650 		foreach ( void delegate(Assistant) dlg; _assistant.onCancelListeners )
651 		{
652 			dlg(_assistant);
653 		}
654 	}
655 
656 	void delegate(Assistant)[] onCloseListeners;
657 	/**
658 	 * The ::close signal is emitted either when the close button of
659 	 * a summary page is clicked, or when the apply button in the last
660 	 * page in the flow (of type %GTK_ASSISTANT_PAGE_CONFIRM) is clicked.
661 	 *
662 	 * Since: 2.10
663 	 */
664 	void addOnClose(void delegate(Assistant) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
665 	{
666 		if ( "close" !in connectedSignals )
667 		{
668 			Signals.connectData(
669 				this,
670 				"close",
671 				cast(GCallback)&callBackClose,
672 				cast(void*)this,
673 				null,
674 				connectFlags);
675 			connectedSignals["close"] = 1;
676 		}
677 		onCloseListeners ~= dlg;
678 	}
679 	extern(C) static void callBackClose(GtkAssistant* assistantStruct, Assistant _assistant)
680 	{
681 		foreach ( void delegate(Assistant) dlg; _assistant.onCloseListeners )
682 		{
683 			dlg(_assistant);
684 		}
685 	}
686 
687 	void delegate(Assistant)[] onEscapeListeners;
688 	/** */
689 	void addOnEscape(void delegate(Assistant) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
690 	{
691 		if ( "escape" !in connectedSignals )
692 		{
693 			Signals.connectData(
694 				this,
695 				"escape",
696 				cast(GCallback)&callBackEscape,
697 				cast(void*)this,
698 				null,
699 				connectFlags);
700 			connectedSignals["escape"] = 1;
701 		}
702 		onEscapeListeners ~= dlg;
703 	}
704 	extern(C) static void callBackEscape(GtkAssistant* assistantStruct, Assistant _assistant)
705 	{
706 		foreach ( void delegate(Assistant) dlg; _assistant.onEscapeListeners )
707 		{
708 			dlg(_assistant);
709 		}
710 	}
711 
712 	void delegate(Widget, Assistant)[] onPrepareListeners;
713 	/**
714 	 * The ::prepare signal is emitted when a new page is set as the
715 	 * assistant's current page, before making the new page visible.
716 	 *
717 	 * A handler for this signal can do any preparations which are
718 	 * necessary before showing @page.
719 	 *
720 	 * Params:
721 	 *     page = the current page
722 	 *
723 	 * Since: 2.10
724 	 */
725 	void addOnPrepare(void delegate(Widget, Assistant) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
726 	{
727 		if ( "prepare" !in connectedSignals )
728 		{
729 			Signals.connectData(
730 				this,
731 				"prepare",
732 				cast(GCallback)&callBackPrepare,
733 				cast(void*)this,
734 				null,
735 				connectFlags);
736 			connectedSignals["prepare"] = 1;
737 		}
738 		onPrepareListeners ~= dlg;
739 	}
740 	extern(C) static void callBackPrepare(GtkAssistant* assistantStruct, GtkWidget* page, Assistant _assistant)
741 	{
742 		foreach ( void delegate(Widget, Assistant) dlg; _assistant.onPrepareListeners )
743 		{
744 			dlg(ObjectG.getDObject!(Widget)(page), _assistant);
745 		}
746 	}
747 }