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 gio.ListModelIF; 28 private import glib.ConstructionException; 29 private import glib.Str; 30 private import glib.c.functions; 31 private import gobject.ObjectG; 32 private import gobject.Signals; 33 private import gtk.AssistantPage; 34 private import gtk.Widget; 35 private import gtk.Window; 36 private import gtk.c.functions; 37 public import gtk.c.types; 38 private import std.algorithm; 39 40 41 /** 42 * `GtkAssistant` is used to represent a complex as a series of steps. 43 * 44 * ![An example GtkAssistant](assistant.png) 45 * 46 * Each step consists of one or more pages. `GtkAssistant` guides the user 47 * through the pages, and controls the page flow to collect the data needed 48 * for the operation. 49 * 50 * `GtkAssistant` handles which buttons to show and to make sensitive based 51 * on page sequence knowledge and the [enum@Gtk.AssistantPageType] of each 52 * page in addition to state information like the *completed* and *committed* 53 * page statuses. 54 * 55 * If you have a case that doesn’t quite fit in `GtkAssistant`s way of 56 * handling buttons, you can use the %GTK_ASSISTANT_PAGE_CUSTOM page 57 * type and handle buttons yourself. 58 * 59 * `GtkAssistant` maintains a `GtkAssistantPage` object for each added 60 * child, which holds additional per-child properties. You 61 * obtain the `GtkAssistantPage` for a child with [method@Gtk.Assistant.get_page]. 62 * 63 * # GtkAssistant as GtkBuildable 64 * 65 * The `GtkAssistant` implementation of the `GtkBuildable` interface 66 * exposes the @action_area as internal children with the name 67 * “action_area”. 68 * 69 * To add pages to an assistant in `GtkBuilder`, simply add it as a 70 * child to the `GtkAssistant` object. If you need to set per-object 71 * properties, create a `GtkAssistantPage` object explicitly, and 72 * set the child widget as a property on it. 73 * 74 * # CSS nodes 75 * 76 * `GtkAssistant` has a single CSS node with the name window and style 77 * class .assistant. 78 */ 79 public class Assistant : Window 80 { 81 /** the main Gtk struct */ 82 protected GtkAssistant* gtkAssistant; 83 84 /** Get the main Gtk struct */ 85 public GtkAssistant* getAssistantStruct(bool transferOwnership = false) 86 { 87 if (transferOwnership) 88 ownedRef = false; 89 return gtkAssistant; 90 } 91 92 /** the main Gtk struct as a void* */ 93 protected override void* getStruct() 94 { 95 return cast(void*)gtkAssistant; 96 } 97 98 /** 99 * Sets our main struct and passes it to the parent class. 100 */ 101 public this (GtkAssistant* gtkAssistant, bool ownedRef = false) 102 { 103 this.gtkAssistant = gtkAssistant; 104 super(cast(GtkWindow*)gtkAssistant, ownedRef); 105 } 106 107 108 /** */ 109 public static GType getType() 110 { 111 return gtk_assistant_get_type(); 112 } 113 114 /** 115 * Creates a new `GtkAssistant`. 116 * 117 * Returns: a newly created `GtkAssistant` 118 * 119 * Throws: ConstructionException GTK+ fails to create the object. 120 */ 121 public this() 122 { 123 auto __p = gtk_assistant_new(); 124 125 if(__p is null) 126 { 127 throw new ConstructionException("null returned by new"); 128 } 129 130 this(cast(GtkAssistant*) __p); 131 } 132 133 /** 134 * Adds a widget to the action area of a `GtkAssistant`. 135 * 136 * Params: 137 * child = a `GtkWidget` 138 */ 139 public void addActionWidget(Widget child) 140 { 141 gtk_assistant_add_action_widget(gtkAssistant, (child is null) ? null : child.getWidgetStruct()); 142 } 143 144 /** 145 * Appends a page to the @assistant. 146 * 147 * Params: 148 * page = a `GtkWidget` 149 * 150 * Returns: the index (starting at 0) of the inserted page 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. 159 * 160 * GTK will then hide the back button on the current page, 161 * and removes the cancel button from subsequent pages. 162 * 163 * Use this when the information provided up to the current 164 * page is hereafter deemed permanent and cannot be modified 165 * or undone. For example, showing a progress page to track 166 * a long-running, unreversible operation after the user has 167 * clicked apply on a confirmation page. 168 */ 169 public void commit() 170 { 171 gtk_assistant_commit(gtkAssistant); 172 } 173 174 /** 175 * Returns the page number of the current page. 176 * 177 * Returns: The index (starting from 0) of the current 178 * page in the @assistant, or -1 if the @assistant has no pages, 179 * or no current page. 180 */ 181 public int getCurrentPage() 182 { 183 return gtk_assistant_get_current_page(gtkAssistant); 184 } 185 186 /** 187 * Returns the number of pages in the @assistant 188 * 189 * Returns: the number of pages in the @assistant 190 */ 191 public int getNPages() 192 { 193 return gtk_assistant_get_n_pages(gtkAssistant); 194 } 195 196 /** 197 * Returns the child widget contained in page number @page_num. 198 * 199 * Params: 200 * pageNum = the index of a page in the @assistant, 201 * or -1 to get the last page 202 * 203 * Returns: the child widget, or %NULL 204 * if @page_num is out of bounds 205 */ 206 public Widget getNthPage(int pageNum) 207 { 208 auto __p = gtk_assistant_get_nth_page(gtkAssistant, pageNum); 209 210 if(__p is null) 211 { 212 return null; 213 } 214 215 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p); 216 } 217 218 /** 219 * Returns the `GtkAssistantPage` object for @child. 220 * 221 * Params: 222 * child = a child of @assistant 223 * 224 * Returns: the `GtkAssistantPage` for @child 225 */ 226 public AssistantPage getPage(Widget child) 227 { 228 auto __p = gtk_assistant_get_page(gtkAssistant, (child is null) ? null : child.getWidgetStruct()); 229 230 if(__p is null) 231 { 232 return null; 233 } 234 235 return ObjectG.getDObject!(AssistantPage)(cast(GtkAssistantPage*) __p); 236 } 237 238 /** 239 * Gets whether @page is complete. 240 * 241 * Params: 242 * page = a page of @assistant 243 * 244 * Returns: %TRUE if @page is complete. 245 */ 246 public bool getPageComplete(Widget page) 247 { 248 return gtk_assistant_get_page_complete(gtkAssistant, (page is null) ? null : page.getWidgetStruct()) != 0; 249 } 250 251 /** 252 * Gets the title for @page. 253 * 254 * Params: 255 * page = a page of @assistant 256 * 257 * Returns: the title for @page 258 */ 259 public string getPageTitle(Widget page) 260 { 261 return Str.toString(gtk_assistant_get_page_title(gtkAssistant, (page is null) ? null : page.getWidgetStruct())); 262 } 263 264 /** 265 * Gets the page type of @page. 266 * 267 * Params: 268 * page = a page of @assistant 269 * 270 * Returns: the page type of @page 271 */ 272 public GtkAssistantPageType getPageType(Widget page) 273 { 274 return gtk_assistant_get_page_type(gtkAssistant, (page is null) ? null : page.getWidgetStruct()); 275 } 276 277 /** 278 * Gets a list model of the assistant pages. 279 * 280 * Returns: A list model of the pages. 281 */ 282 public ListModelIF getPages() 283 { 284 auto __p = gtk_assistant_get_pages(gtkAssistant); 285 286 if(__p is null) 287 { 288 return null; 289 } 290 291 return ObjectG.getDObject!(ListModelIF)(cast(GListModel*) __p, true); 292 } 293 294 /** 295 * Inserts a page in the @assistant at a given position. 296 * 297 * Params: 298 * page = a `GtkWidget` 299 * position = the index (starting at 0) at which to insert the page, 300 * or -1 to append the page to the @assistant 301 * 302 * Returns: the index (starting from 0) of the inserted page 303 */ 304 public int insertPage(Widget page, int position) 305 { 306 return gtk_assistant_insert_page(gtkAssistant, (page is null) ? null : page.getWidgetStruct(), position); 307 } 308 309 /** 310 * Navigate to the next page. 311 * 312 * It is a programming error to call this function when 313 * there is no next page. 314 * 315 * This function is for use when creating pages of the 316 * %GTK_ASSISTANT_PAGE_CUSTOM type. 317 */ 318 public void nextPage() 319 { 320 gtk_assistant_next_page(gtkAssistant); 321 } 322 323 /** 324 * Prepends a page to the @assistant. 325 * 326 * Params: 327 * page = a `GtkWidget` 328 * 329 * Returns: the index (starting at 0) of the inserted page 330 */ 331 public int prependPage(Widget page) 332 { 333 return gtk_assistant_prepend_page(gtkAssistant, (page is null) ? null : page.getWidgetStruct()); 334 } 335 336 /** 337 * Navigate to the previous visited page. 338 * 339 * It is a programming error to call this function when 340 * no previous page is available. 341 * 342 * This function is for use when creating pages of the 343 * %GTK_ASSISTANT_PAGE_CUSTOM type. 344 */ 345 public void previousPage() 346 { 347 gtk_assistant_previous_page(gtkAssistant); 348 } 349 350 /** 351 * Removes a widget from the action area of a `GtkAssistant`. 352 * 353 * Params: 354 * child = a `GtkWidget` 355 */ 356 public void removeActionWidget(Widget child) 357 { 358 gtk_assistant_remove_action_widget(gtkAssistant, (child is null) ? null : child.getWidgetStruct()); 359 } 360 361 /** 362 * Removes the @page_num’s page from @assistant. 363 * 364 * Params: 365 * pageNum = the index of a page in the @assistant, 366 * or -1 to remove the last page 367 */ 368 public void removePage(int pageNum) 369 { 370 gtk_assistant_remove_page(gtkAssistant, pageNum); 371 } 372 373 /** 374 * Switches the page to @page_num. 375 * 376 * Note that this will only be necessary in custom buttons, 377 * as the @assistant flow can be set with 378 * gtk_assistant_set_forward_page_func(). 379 * 380 * Params: 381 * pageNum = index of the page to switch to, starting from 0. 382 * If negative, the last page will be used. If greater 383 * than the number of pages in the @assistant, nothing 384 * will be done. 385 */ 386 public void setCurrentPage(int pageNum) 387 { 388 gtk_assistant_set_current_page(gtkAssistant, pageNum); 389 } 390 391 /** 392 * Sets the page forwarding function to be @page_func. 393 * 394 * This function will be used to determine what will be 395 * the next page when the user presses the forward button. 396 * Setting @page_func to %NULL will make the assistant to 397 * use the default forward function, which just goes to the 398 * next visible page. 399 * 400 * Params: 401 * pageFunc = the `GtkAssistant`PageFunc, or %NULL 402 * to use the default one 403 * data = user data for @page_func 404 * destroy = destroy notifier for @data 405 */ 406 public void setForwardPageFunc(GtkAssistantPageFunc pageFunc, void* data, GDestroyNotify destroy) 407 { 408 gtk_assistant_set_forward_page_func(gtkAssistant, pageFunc, data, destroy); 409 } 410 411 /** 412 * Sets whether @page contents are complete. 413 * 414 * This will make @assistant update the buttons state 415 * to be able to continue the task. 416 * 417 * Params: 418 * page = a page of @assistant 419 * complete = the completeness status of the page 420 */ 421 public void setPageComplete(Widget page, bool complete) 422 { 423 gtk_assistant_set_page_complete(gtkAssistant, (page is null) ? null : page.getWidgetStruct(), complete); 424 } 425 426 /** 427 * Sets a title for @page. 428 * 429 * The title is displayed in the header area of the assistant 430 * when @page is the current page. 431 * 432 * Params: 433 * page = a page of @assistant 434 * title = the new title for @page 435 */ 436 public void setPageTitle(Widget page, string title) 437 { 438 gtk_assistant_set_page_title(gtkAssistant, (page is null) ? null : page.getWidgetStruct(), Str.toStringz(title)); 439 } 440 441 /** 442 * Sets the page type for @page. 443 * 444 * The page type determines the page behavior in the @assistant. 445 * 446 * Params: 447 * page = a page of @assistant 448 * type = the new type for @page 449 */ 450 public void setPageType(Widget page, GtkAssistantPageType type) 451 { 452 gtk_assistant_set_page_type(gtkAssistant, (page is null) ? null : page.getWidgetStruct(), type); 453 } 454 455 /** 456 * Forces @assistant to recompute the buttons state. 457 * 458 * GTK automatically takes care of this in most situations, 459 * e.g. when the user goes to a different page, or when the 460 * visibility or completeness of a page changes. 461 * 462 * One situation where it can be necessary to call this 463 * function is when changing a value on the current page 464 * affects the future page flow of the assistant. 465 */ 466 public void updateButtonsState() 467 { 468 gtk_assistant_update_buttons_state(gtkAssistant); 469 } 470 471 /** 472 * Emitted when the apply button is clicked. 473 * 474 * The default behavior of the `GtkAssistant` is to switch to the page 475 * after the current page, unless the current page is the last one. 476 * 477 * A handler for the ::apply signal should carry out the actions for 478 * which the wizard has collected data. If the action takes a long time 479 * to complete, you might consider putting a page of type 480 * %GTK_ASSISTANT_PAGE_PROGRESS after the confirmation page and handle 481 * this operation within the [signal@Gtk.Assistant::prepare] signal of 482 * the progress page. 483 */ 484 gulong addOnApply(void delegate(Assistant) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 485 { 486 return Signals.connect(this, "apply", dlg, connectFlags ^ ConnectFlags.SWAPPED); 487 } 488 489 /** 490 * Emitted when then the cancel button is clicked. 491 */ 492 gulong addOnCancel(void delegate(Assistant) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 493 { 494 return Signals.connect(this, "cancel", dlg, connectFlags ^ ConnectFlags.SWAPPED); 495 } 496 497 /** 498 * Emitted either when the close button of a summary page is clicked, 499 * or when the apply button in the last page in the flow (of type 500 * %GTK_ASSISTANT_PAGE_CONFIRM) is clicked. 501 */ 502 gulong addOnClose(void delegate(Assistant) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 503 { 504 return Signals.connect(this, "close", dlg, connectFlags ^ ConnectFlags.SWAPPED); 505 } 506 507 /** 508 * The action signal for the Escape binding. 509 */ 510 gulong addOnEscape(void delegate(Assistant) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 511 { 512 return Signals.connect(this, "escape", dlg, connectFlags ^ ConnectFlags.SWAPPED); 513 } 514 515 /** 516 * Emitted when a new page is set as the assistant's current page, 517 * before making the new page visible. 518 * 519 * A handler for this signal can do any preparations which are 520 * necessary before showing @page. 521 * 522 * Params: 523 * page = the current page 524 */ 525 gulong addOnPrepare(void delegate(Widget, Assistant) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 526 { 527 return Signals.connect(this, "prepare", dlg, connectFlags ^ ConnectFlags.SWAPPED); 528 } 529 }