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