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