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