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 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 507 } 508 509 /** 510 * Warning 511 * 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 512 * shown anymore. 513 * Sets a side image for page. 514 * This image used to be displayed in the side area of the assistant 515 * when page is the current page. 516 * Since 2.10 517 * Params: 518 * page = a page of assistant 519 * pixbuf = the new side image page. [allow-none] 520 */ 521 public void setPageSideImage(Widget page, Pixbuf pixbuf) 522 { 523 // void gtk_assistant_set_page_side_image (GtkAssistant *assistant, GtkWidget *page, GdkPixbuf *pixbuf); 524 gtk_assistant_set_page_side_image(gtkAssistant, (page is null) ? null : page.getWidgetStruct(), (pixbuf is null) ? null : pixbuf.getPixbufStruct()); 525 } 526 527 /** 528 * Warning 529 * 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 530 * shown anymore. 531 * Gets the side image for page. 532 * Since 2.10 533 * Params: 534 * page = a page of assistant 535 * Returns: the side image for page, or NULL if there's no side image for the page. [transfer none] 536 */ 537 public Pixbuf getPageSideImage(Widget page) 538 { 539 // GdkPixbuf * gtk_assistant_get_page_side_image (GtkAssistant *assistant, GtkWidget *page); 540 auto p = gtk_assistant_get_page_side_image(gtkAssistant, (page is null) ? null : page.getWidgetStruct()); 541 542 if(p is null) 543 { 544 return null; 545 } 546 547 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 548 } 549 550 /** 551 * Sets whether page contents are complete. 552 * This will make assistant update the buttons state 553 * to be able to continue the task. 554 * Since 2.10 555 * Params: 556 * page = a page of assistant 557 * complete = the completeness status of the page 558 */ 559 public void setPageComplete(Widget page, int complete) 560 { 561 // void gtk_assistant_set_page_complete (GtkAssistant *assistant, GtkWidget *page, gboolean complete); 562 gtk_assistant_set_page_complete(gtkAssistant, (page is null) ? null : page.getWidgetStruct(), complete); 563 } 564 565 /** 566 * Gets whether page is complete. 567 * Since 2.10 568 * Params: 569 * page = a page of assistant 570 * Returns: TRUE if page is complete. 571 */ 572 public int getPageComplete(Widget page) 573 { 574 // gboolean gtk_assistant_get_page_complete (GtkAssistant *assistant, GtkWidget *page); 575 return gtk_assistant_get_page_complete(gtkAssistant, (page is null) ? null : page.getWidgetStruct()); 576 } 577 578 /** 579 * Adds a widget to the action area of a GtkAssistant. 580 * Since 2.10 581 * Params: 582 * child = a GtkWidget 583 */ 584 public void addActionWidget(Widget child) 585 { 586 // void gtk_assistant_add_action_widget (GtkAssistant *assistant, GtkWidget *child); 587 gtk_assistant_add_action_widget(gtkAssistant, (child is null) ? null : child.getWidgetStruct()); 588 } 589 590 /** 591 * Removes a widget from the action area of a GtkAssistant. 592 * Since 2.10 593 * Params: 594 * child = a GtkWidget 595 */ 596 public void removeActionWidget(Widget child) 597 { 598 // void gtk_assistant_remove_action_widget (GtkAssistant *assistant, GtkWidget *child); 599 gtk_assistant_remove_action_widget(gtkAssistant, (child is null) ? null : child.getWidgetStruct()); 600 } 601 602 /** 603 * Forces assistant to recompute the buttons state. 604 * GTK+ automatically takes care of this in most situations, 605 * e.g. when the user goes to a different page, or when the 606 * visibility or completeness of a page changes. 607 * One situation where it can be necessary to call this 608 * function is when changing a value on the current page 609 * affects the future page flow of the assistant. 610 * Since 2.10 611 */ 612 public void updateButtonsState() 613 { 614 // void gtk_assistant_update_buttons_state (GtkAssistant *assistant); 615 gtk_assistant_update_buttons_state(gtkAssistant); 616 } 617 618 /** 619 * Erases the visited page history so the back button is not 620 * shown on the current page, and removes the cancel button 621 * from subsequent pages. 622 * Use this when the information provided up to the current 623 * page is hereafter deemed permanent and cannot be modified 624 * or undone. For example, showing a progress page to track 625 * a long-running, unreversible operation after the user has 626 * clicked apply on a confirmation page. 627 * Since 2.22 628 */ 629 public void commit() 630 { 631 // void gtk_assistant_commit (GtkAssistant *assistant); 632 gtk_assistant_commit(gtkAssistant); 633 } 634 635 /** 636 * Navigate to the next page. 637 * It is a programming error to call this function when 638 * there is no next page. 639 * This function is for use when creating pages of the 640 * GTK_ASSISTANT_PAGE_CUSTOM type. 641 */ 642 public void nextPage() 643 { 644 // void gtk_assistant_next_page (GtkAssistant *assistant); 645 gtk_assistant_next_page(gtkAssistant); 646 } 647 648 /** 649 * Navigate to the previous visited page. 650 * It is a programming error to call this function when 651 * no previous page is available. 652 * This function is for use when creating pages of the 653 * GTK_ASSISTANT_PAGE_CUSTOM type. 654 * Since 2.10 655 */ 656 public void previousPage() 657 { 658 // void gtk_assistant_previous_page (GtkAssistant *assistant); 659 gtk_assistant_previous_page(gtkAssistant); 660 } 661 }