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.Notebook; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gobject.Signals; 31 private import gtk.Container; 32 private import gtk.Label; 33 private import gtk.Widget; 34 public import gtkc.gdktypes; 35 private import gtkc.gtk; 36 public import gtkc.gtktypes; 37 38 39 /** 40 * The #GtkNotebook widget is a #GtkContainer whose children are pages that 41 * can be switched between using tab labels along one edge. 42 * 43 * There are many configuration options for GtkNotebook. Among other 44 * things, you can choose on which edge the tabs appear 45 * (see gtk_notebook_set_tab_pos()), whether, if there are too many 46 * tabs to fit the notebook should be made bigger or scrolling 47 * arrows added (see gtk_notebook_set_scrollable()), and whether there 48 * will be a popup menu allowing the users to switch pages. 49 * (see gtk_notebook_popup_enable(), gtk_notebook_popup_disable()) 50 * 51 * # GtkNotebook as GtkBuildable 52 * 53 * The GtkNotebook implementation of the #GtkBuildable interface 54 * supports placing children into tabs by specifying “tab” as the 55 * “type” attribute of a <child> element. Note that the content 56 * of the tab must be created before the tab can be filled. 57 * A tab child can be specified without specifying a <child> 58 * type attribute. 59 * 60 * To add a child widget in the notebooks action area, specify 61 * "action-start" or “action-end” as the “type” attribute of the 62 * <child> element. 63 * 64 * An example of a UI definition fragment with GtkNotebook: 65 * |[ 66 * <object class="GtkNotebook"> 67 * <child> 68 * <object class="GtkLabel" id="notebook-content"> 69 * <property name="label">Content</property> 70 * </object> 71 * </child> 72 * <child type="tab"> 73 * <object class="GtkLabel" id="notebook-tab"> 74 * <property name="label">Tab</property> 75 * </object> 76 * </child> 77 * </object> 78 * ]| 79 */ 80 public class Notebook : Container 81 { 82 /** the main Gtk struct */ 83 protected GtkNotebook* gtkNotebook; 84 85 /** Get the main Gtk struct */ 86 public GtkNotebook* getNotebookStruct() 87 { 88 return gtkNotebook; 89 } 90 91 /** the main Gtk struct as a void* */ 92 protected override void* getStruct() 93 { 94 return cast(void*)gtkNotebook; 95 } 96 97 protected override void setStruct(GObject* obj) 98 { 99 gtkNotebook = cast(GtkNotebook*)obj; 100 super.setStruct(obj); 101 } 102 103 /** 104 * Sets our main struct and passes it to the parent class. 105 */ 106 public this (GtkNotebook* gtkNotebook, bool ownedRef = false) 107 { 108 this.gtkNotebook = gtkNotebook; 109 super(cast(GtkContainer*)gtkNotebook, ownedRef); 110 } 111 112 /** 113 * Append a page with a widget and a text for a label 114 */ 115 public int appendPage(Widget child, string tabLabel) 116 { 117 return appendPage(child, new Label(tabLabel)); 118 } 119 120 /** */ 121 void setCurrentPage(Widget child) 122 { 123 gtk_notebook_set_current_page(gtkNotebook,gtk_notebook_page_num(gtkNotebook, child.getWidgetStruct())); 124 } 125 126 /** 127 */ 128 129 public static GType getType() 130 { 131 return gtk_notebook_get_type(); 132 } 133 134 /** 135 * Creates a new #GtkNotebook widget with no pages. 136 * 137 * Return: the newly created #GtkNotebook 138 * 139 * Throws: ConstructionException GTK+ fails to create the object. 140 */ 141 public this() 142 { 143 auto p = gtk_notebook_new(); 144 145 if(p is null) 146 { 147 throw new ConstructionException("null returned by new"); 148 } 149 150 this(cast(GtkNotebook*) p); 151 } 152 153 /** 154 * Appends a page to @notebook. 155 * 156 * Params: 157 * child = the #GtkWidget to use as the contents of the page 158 * tabLabel = the #GtkWidget to be used as the label 159 * for the page, or %NULL to use the default label, “page N” 160 * 161 * Return: the index (starting from 0) of the appended 162 * page in the notebook, or -1 if function fails 163 */ 164 public int appendPage(Widget child, Widget tabLabel) 165 { 166 return gtk_notebook_append_page(gtkNotebook, (child is null) ? null : child.getWidgetStruct(), (tabLabel is null) ? null : tabLabel.getWidgetStruct()); 167 } 168 169 /** 170 * Appends a page to @notebook, specifying the widget to use as the 171 * label in the popup menu. 172 * 173 * Params: 174 * child = the #GtkWidget to use as the contents of the page 175 * tabLabel = the #GtkWidget to be used as the label 176 * for the page, or %NULL to use the default label, “page N” 177 * menuLabel = the widget to use as a label for the 178 * page-switch menu, if that is enabled. If %NULL, and @tab_label 179 * is a #GtkLabel or %NULL, then the menu label will be a newly 180 * created label with the same text as @tab_label; if @tab_label 181 * is not a #GtkLabel, @menu_label must be specified if the 182 * page-switch menu is to be used. 183 * 184 * Return: the index (starting from 0) of the appended 185 * page in the notebook, or -1 if function fails 186 */ 187 public int appendPageMenu(Widget child, Widget tabLabel, Widget menuLabel) 188 { 189 return gtk_notebook_append_page_menu(gtkNotebook, (child is null) ? null : child.getWidgetStruct(), (tabLabel is null) ? null : tabLabel.getWidgetStruct(), (menuLabel is null) ? null : menuLabel.getWidgetStruct()); 190 } 191 192 /** 193 * Gets one of the action widgets. See gtk_notebook_set_action_widget(). 194 * 195 * Params: 196 * packType = pack type of the action widget to receive 197 * 198 * Return: The action widget with the given @pack_type 199 * or %NULL when this action widget has not been set 200 * 201 * Since: 2.20 202 */ 203 public Widget getActionWidget(GtkPackType packType) 204 { 205 auto p = gtk_notebook_get_action_widget(gtkNotebook, packType); 206 207 if(p is null) 208 { 209 return null; 210 } 211 212 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 213 } 214 215 /** 216 * Returns the page number of the current page. 217 * 218 * Return: the index (starting from 0) of the current 219 * page in the notebook. If the notebook has no pages, 220 * then -1 will be returned. 221 */ 222 public int getCurrentPage() 223 { 224 return gtk_notebook_get_current_page(gtkNotebook); 225 } 226 227 /** 228 * Gets the current group name for @notebook. 229 * 230 * Return: the group name, 231 * or %NULL if none is set. 232 * 233 * Since: 2.24 234 */ 235 public string getGroupName() 236 { 237 return Str.toString(gtk_notebook_get_group_name(gtkNotebook)); 238 } 239 240 /** 241 * Retrieves the menu label widget of the page containing @child. 242 * 243 * Params: 244 * child = a widget contained in a page of @notebook 245 * 246 * Return: the menu label, or %NULL if the 247 * notebook page does not have a menu label other than the 248 * default (the tab label). 249 */ 250 public Widget getMenuLabel(Widget child) 251 { 252 auto p = gtk_notebook_get_menu_label(gtkNotebook, (child is null) ? null : child.getWidgetStruct()); 253 254 if(p is null) 255 { 256 return null; 257 } 258 259 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 260 } 261 262 /** 263 * Retrieves the text of the menu label for the page containing 264 * @child. 265 * 266 * Params: 267 * child = the child widget of a page of the notebook. 268 * 269 * Return: the text of the tab label, or %NULL if the 270 * widget does not have a menu label other than the default 271 * menu label, or the menu label widget is not a #GtkLabel. 272 * The string is owned by the widget and must not be freed. 273 */ 274 public string getMenuLabelText(Widget child) 275 { 276 return Str.toString(gtk_notebook_get_menu_label_text(gtkNotebook, (child is null) ? null : child.getWidgetStruct())); 277 } 278 279 /** 280 * Gets the number of pages in a notebook. 281 * 282 * Return: the number of pages in the notebook 283 * 284 * Since: 2.2 285 */ 286 public int getNPages() 287 { 288 return gtk_notebook_get_n_pages(gtkNotebook); 289 } 290 291 /** 292 * Returns the child widget contained in page number @page_num. 293 * 294 * Params: 295 * pageNum = the index of a page in the notebook, or -1 296 * to get the last page 297 * 298 * Return: the child widget, or %NULL 299 * if @page_num is out of bounds 300 */ 301 public Widget getNthPage(int pageNum) 302 { 303 auto p = gtk_notebook_get_nth_page(gtkNotebook, pageNum); 304 305 if(p is null) 306 { 307 return null; 308 } 309 310 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 311 } 312 313 /** 314 * Returns whether the tab label area has arrows for scrolling. 315 * See gtk_notebook_set_scrollable(). 316 * 317 * Return: %TRUE if arrows for scrolling are present 318 */ 319 public bool getScrollable() 320 { 321 return gtk_notebook_get_scrollable(gtkNotebook) != 0; 322 } 323 324 /** 325 * Returns whether a bevel will be drawn around the notebook pages. 326 * See gtk_notebook_set_show_border(). 327 * 328 * Return: %TRUE if the bevel is drawn 329 */ 330 public bool getShowBorder() 331 { 332 return gtk_notebook_get_show_border(gtkNotebook) != 0; 333 } 334 335 /** 336 * Returns whether the tabs of the notebook are shown. 337 * See gtk_notebook_set_show_tabs(). 338 * 339 * Return: %TRUE if the tabs are shown 340 */ 341 public bool getShowTabs() 342 { 343 return gtk_notebook_get_show_tabs(gtkNotebook) != 0; 344 } 345 346 /** 347 * Returns whether the tab contents can be detached from @notebook. 348 * 349 * Params: 350 * child = a child #GtkWidget 351 * 352 * Return: %TRUE if the tab is detachable. 353 * 354 * Since: 2.10 355 */ 356 public bool getTabDetachable(Widget child) 357 { 358 return gtk_notebook_get_tab_detachable(gtkNotebook, (child is null) ? null : child.getWidgetStruct()) != 0; 359 } 360 361 /** 362 * Returns the horizontal width of a tab border. 363 * 364 * Deprecated: this function returns zero 365 * 366 * Return: horizontal width of a tab border 367 * 368 * Since: 2.22 369 */ 370 public ushort getTabHborder() 371 { 372 return gtk_notebook_get_tab_hborder(gtkNotebook); 373 } 374 375 /** 376 * Returns the tab label widget for the page @child. 377 * %NULL is returned if @child is not in @notebook or 378 * if no tab label has specifically been set for @child. 379 * 380 * Params: 381 * child = the page 382 * 383 * Return: the tab label 384 */ 385 public Widget getTabLabel(Widget child) 386 { 387 auto p = gtk_notebook_get_tab_label(gtkNotebook, (child is null) ? null : child.getWidgetStruct()); 388 389 if(p is null) 390 { 391 return null; 392 } 393 394 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 395 } 396 397 /** 398 * Retrieves the text of the tab label for the page containing 399 * @child. 400 * 401 * Params: 402 * child = a widget contained in a page of @notebook 403 * 404 * Return: the text of the tab label, or %NULL if the 405 * tab label widget is not a #GtkLabel. The string is owned 406 * by the widget and must not be freed. 407 */ 408 public string getTabLabelText(Widget child) 409 { 410 return Str.toString(gtk_notebook_get_tab_label_text(gtkNotebook, (child is null) ? null : child.getWidgetStruct())); 411 } 412 413 /** 414 * Gets the edge at which the tabs for switching pages in the 415 * notebook are drawn. 416 * 417 * Return: the edge at which the tabs are drawn 418 */ 419 public GtkPositionType getTabPos() 420 { 421 return gtk_notebook_get_tab_pos(gtkNotebook); 422 } 423 424 /** 425 * Gets whether the tab can be reordered via drag and drop or not. 426 * 427 * Params: 428 * child = a child #GtkWidget 429 * 430 * Return: %TRUE if the tab is reorderable. 431 * 432 * Since: 2.10 433 */ 434 public bool getTabReorderable(Widget child) 435 { 436 return gtk_notebook_get_tab_reorderable(gtkNotebook, (child is null) ? null : child.getWidgetStruct()) != 0; 437 } 438 439 /** 440 * Returns the vertical width of a tab border. 441 * 442 * Deprecated: this function returns zero 443 * 444 * Return: vertical width of a tab border 445 * 446 * Since: 2.22 447 */ 448 public ushort getTabVborder() 449 { 450 return gtk_notebook_get_tab_vborder(gtkNotebook); 451 } 452 453 /** 454 * Insert a page into @notebook at the given position. 455 * 456 * Params: 457 * child = the #GtkWidget to use as the contents of the page 458 * tabLabel = the #GtkWidget to be used as the label 459 * for the page, or %NULL to use the default label, “page N” 460 * position = the index (starting at 0) at which to insert the page, 461 * or -1 to append the page after all other pages 462 * 463 * Return: the index (starting from 0) of the inserted 464 * page in the notebook, or -1 if function fails 465 */ 466 public int insertPage(Widget child, Widget tabLabel, int position) 467 { 468 return gtk_notebook_insert_page(gtkNotebook, (child is null) ? null : child.getWidgetStruct(), (tabLabel is null) ? null : tabLabel.getWidgetStruct(), position); 469 } 470 471 /** 472 * Insert a page into @notebook at the given position, specifying 473 * the widget to use as the label in the popup menu. 474 * 475 * Params: 476 * child = the #GtkWidget to use as the contents of the page 477 * tabLabel = the #GtkWidget to be used as the label 478 * for the page, or %NULL to use the default label, “page N” 479 * menuLabel = the widget to use as a label for the 480 * page-switch menu, if that is enabled. If %NULL, and @tab_label 481 * is a #GtkLabel or %NULL, then the menu label will be a newly 482 * created label with the same text as @tab_label; if @tab_label 483 * is not a #GtkLabel, @menu_label must be specified if the 484 * page-switch menu is to be used. 485 * position = the index (starting at 0) at which to insert the page, 486 * or -1 to append the page after all other pages. 487 * 488 * Return: the index (starting from 0) of the inserted 489 * page in the notebook 490 */ 491 public int insertPageMenu(Widget child, Widget tabLabel, Widget menuLabel, int position) 492 { 493 return gtk_notebook_insert_page_menu(gtkNotebook, (child is null) ? null : child.getWidgetStruct(), (tabLabel is null) ? null : tabLabel.getWidgetStruct(), (menuLabel is null) ? null : menuLabel.getWidgetStruct(), position); 494 } 495 496 /** 497 * Switches to the next page. Nothing happens if the current page is 498 * the last page. 499 */ 500 public void nextPage() 501 { 502 gtk_notebook_next_page(gtkNotebook); 503 } 504 505 /** 506 * Finds the index of the page which contains the given child 507 * widget. 508 * 509 * Params: 510 * child = a #GtkWidget 511 * 512 * Return: the index of the page containing @child, or 513 * -1 if @child is not in the notebook 514 */ 515 public int pageNum(Widget child) 516 { 517 return gtk_notebook_page_num(gtkNotebook, (child is null) ? null : child.getWidgetStruct()); 518 } 519 520 /** 521 * Disables the popup menu. 522 */ 523 public void popupDisable() 524 { 525 gtk_notebook_popup_disable(gtkNotebook); 526 } 527 528 /** 529 * Enables the popup menu: if the user clicks with the right 530 * mouse button on the tab labels, a menu with all the pages 531 * will be popped up. 532 */ 533 public void popupEnable() 534 { 535 gtk_notebook_popup_enable(gtkNotebook); 536 } 537 538 /** 539 * Prepends a page to @notebook. 540 * 541 * Params: 542 * child = the #GtkWidget to use as the contents of the page 543 * tabLabel = the #GtkWidget to be used as the label 544 * for the page, or %NULL to use the default label, “page N” 545 * 546 * Return: the index (starting from 0) of the prepended 547 * page in the notebook, or -1 if function fails 548 */ 549 public int prependPage(Widget child, Widget tabLabel) 550 { 551 return gtk_notebook_prepend_page(gtkNotebook, (child is null) ? null : child.getWidgetStruct(), (tabLabel is null) ? null : tabLabel.getWidgetStruct()); 552 } 553 554 /** 555 * Prepends a page to @notebook, specifying the widget to use as the 556 * label in the popup menu. 557 * 558 * Params: 559 * child = the #GtkWidget to use as the contents of the page 560 * tabLabel = the #GtkWidget to be used as the label 561 * for the page, or %NULL to use the default label, “page N” 562 * menuLabel = the widget to use as a label for the 563 * page-switch menu, if that is enabled. If %NULL, and @tab_label 564 * is a #GtkLabel or %NULL, then the menu label will be a newly 565 * created label with the same text as @tab_label; if @tab_label 566 * is not a #GtkLabel, @menu_label must be specified if the 567 * page-switch menu is to be used. 568 * 569 * Return: the index (starting from 0) of the prepended 570 * page in the notebook, or -1 if function fails 571 */ 572 public int prependPageMenu(Widget child, Widget tabLabel, Widget menuLabel) 573 { 574 return gtk_notebook_prepend_page_menu(gtkNotebook, (child is null) ? null : child.getWidgetStruct(), (tabLabel is null) ? null : tabLabel.getWidgetStruct(), (menuLabel is null) ? null : menuLabel.getWidgetStruct()); 575 } 576 577 /** 578 * Switches to the previous page. Nothing happens if the current page 579 * is the first page. 580 */ 581 public void prevPage() 582 { 583 gtk_notebook_prev_page(gtkNotebook); 584 } 585 586 /** 587 * Removes a page from the notebook given its index 588 * in the notebook. 589 * 590 * Params: 591 * pageNum = the index of a notebook page, starting 592 * from 0. If -1, the last page will be removed. 593 */ 594 public void removePage(int pageNum) 595 { 596 gtk_notebook_remove_page(gtkNotebook, pageNum); 597 } 598 599 /** 600 * Reorders the page containing @child, so that it appears in position 601 * @position. If @position is greater than or equal to the number of 602 * children in the list or negative, @child will be moved to the end 603 * of the list. 604 * 605 * Params: 606 * child = the child to move 607 * position = the new position, or -1 to move to the end 608 */ 609 public void reorderChild(Widget child, int position) 610 { 611 gtk_notebook_reorder_child(gtkNotebook, (child is null) ? null : child.getWidgetStruct(), position); 612 } 613 614 /** 615 * Sets @widget as one of the action widgets. Depending on the pack type 616 * the widget will be placed before or after the tabs. You can use 617 * a #GtkBox if you need to pack more than one widget on the same side. 618 * 619 * Note that action widgets are “internal” children of the notebook and thus 620 * not included in the list returned from gtk_container_foreach(). 621 * 622 * Params: 623 * widget = a #GtkWidget 624 * packType = pack type of the action widget 625 * 626 * Since: 2.20 627 */ 628 public void setActionWidget(Widget widget, GtkPackType packType) 629 { 630 gtk_notebook_set_action_widget(gtkNotebook, (widget is null) ? null : widget.getWidgetStruct(), packType); 631 } 632 633 /** 634 * Switches to the page number @page_num. 635 * 636 * Note that due to historical reasons, GtkNotebook refuses 637 * to switch to a page unless the child widget is visible. 638 * Therefore, it is recommended to show child widgets before 639 * adding them to a notebook. 640 * 641 * Params: 642 * pageNum = index of the page to switch to, starting from 0. 643 * If negative, the last page will be used. If greater 644 * than the number of pages in the notebook, nothing 645 * will be done. 646 */ 647 public void setCurrentPage(int pageNum) 648 { 649 gtk_notebook_set_current_page(gtkNotebook, pageNum); 650 } 651 652 /** 653 * Sets a group name for @notebook. 654 * 655 * Notebooks with the same name will be able to exchange tabs 656 * via drag and drop. A notebook with a %NULL group name will 657 * not be able to exchange tabs with any other notebook. 658 * 659 * Params: 660 * groupName = the name of the notebook group, 661 * or %NULL to unset it 662 * 663 * Since: 2.24 664 */ 665 public void setGroupName(string groupName) 666 { 667 gtk_notebook_set_group_name(gtkNotebook, Str.toStringz(groupName)); 668 } 669 670 /** 671 * Changes the menu label for the page containing @child. 672 * 673 * Params: 674 * child = the child widget 675 * menuLabel = the menu label, or %NULL for default 676 */ 677 public void setMenuLabel(Widget child, Widget menuLabel) 678 { 679 gtk_notebook_set_menu_label(gtkNotebook, (child is null) ? null : child.getWidgetStruct(), (menuLabel is null) ? null : menuLabel.getWidgetStruct()); 680 } 681 682 /** 683 * Creates a new label and sets it as the menu label of @child. 684 * 685 * Params: 686 * child = the child widget 687 * menuText = the label text 688 */ 689 public void setMenuLabelText(Widget child, string menuText) 690 { 691 gtk_notebook_set_menu_label_text(gtkNotebook, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(menuText)); 692 } 693 694 /** 695 * Sets whether the tab label area will have arrows for 696 * scrolling if there are too many tabs to fit in the area. 697 * 698 * Params: 699 * scrollable = %TRUE if scroll arrows should be added 700 */ 701 public void setScrollable(bool scrollable) 702 { 703 gtk_notebook_set_scrollable(gtkNotebook, scrollable); 704 } 705 706 /** 707 * Sets whether a bevel will be drawn around the notebook pages. 708 * This only has a visual effect when the tabs are not shown. 709 * See gtk_notebook_set_show_tabs(). 710 * 711 * Params: 712 * showBorder = %TRUE if a bevel should be drawn around the notebook 713 */ 714 public void setShowBorder(bool showBorder) 715 { 716 gtk_notebook_set_show_border(gtkNotebook, showBorder); 717 } 718 719 /** 720 * Sets whether to show the tabs for the notebook or not. 721 * 722 * Params: 723 * showTabs = %TRUE if the tabs should be shown 724 */ 725 public void setShowTabs(bool showTabs) 726 { 727 gtk_notebook_set_show_tabs(gtkNotebook, showTabs); 728 } 729 730 /** 731 * Sets whether the tab can be detached from @notebook to another 732 * notebook or widget. 733 * 734 * Note that 2 notebooks must share a common group identificator 735 * (see gtk_notebook_set_group_name()) to allow automatic tabs 736 * interchange between them. 737 * 738 * If you want a widget to interact with a notebook through DnD 739 * (i.e.: accept dragged tabs from it) it must be set as a drop 740 * destination and accept the target “GTK_NOTEBOOK_TAB”. The notebook 741 * will fill the selection with a GtkWidget** pointing to the child 742 * widget that corresponds to the dropped tab. 743 * |[<!-- language="C" --> 744 * static void 745 * on_drag_data_received (GtkWidget *widget, 746 * GdkDragContext *context, 747 * gint x, 748 * gint y, 749 * GtkSelectionData *data, 750 * guint info, 751 * guint time, 752 * gpointer user_data) 753 * { 754 * GtkWidget *notebook; 755 * GtkWidget **child; 756 * GtkContainer *container; 757 * 758 * notebook = gtk_drag_get_source_widget (context); 759 * child = (void*) gtk_selection_data_get_data (data); 760 * 761 * process_widget (*child); 762 * container = GTK_CONTAINER (notebook); 763 * gtk_container_remove (container, *child); 764 * } 765 * ]| 766 * 767 * If you want a notebook to accept drags from other widgets, 768 * you will have to set your own DnD code to do it. 769 * 770 * Params: 771 * child = a child #GtkWidget 772 * detachable = whether the tab is detachable or not 773 * 774 * Since: 2.10 775 */ 776 public void setTabDetachable(Widget child, bool detachable) 777 { 778 gtk_notebook_set_tab_detachable(gtkNotebook, (child is null) ? null : child.getWidgetStruct(), detachable); 779 } 780 781 /** 782 * Changes the tab label for @child. 783 * If %NULL is specified for @tab_label, then the page will 784 * have the label “page N”. 785 * 786 * Params: 787 * child = the page 788 * tabLabel = the tab label widget to use, or %NULL 789 * for default tab label 790 */ 791 public void setTabLabel(Widget child, Widget tabLabel) 792 { 793 gtk_notebook_set_tab_label(gtkNotebook, (child is null) ? null : child.getWidgetStruct(), (tabLabel is null) ? null : tabLabel.getWidgetStruct()); 794 } 795 796 /** 797 * Creates a new label and sets it as the tab label for the page 798 * containing @child. 799 * 800 * Params: 801 * child = the page 802 * tabText = the label text 803 */ 804 public void setTabLabelText(Widget child, string tabText) 805 { 806 gtk_notebook_set_tab_label_text(gtkNotebook, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(tabText)); 807 } 808 809 /** 810 * Sets the edge at which the tabs for switching pages in the 811 * notebook are drawn. 812 * 813 * Params: 814 * pos = the edge to draw the tabs at 815 */ 816 public void setTabPos(GtkPositionType pos) 817 { 818 gtk_notebook_set_tab_pos(gtkNotebook, pos); 819 } 820 821 /** 822 * Sets whether the notebook tab can be reordered 823 * via drag and drop or not. 824 * 825 * Params: 826 * child = a child #GtkWidget 827 * reorderable = whether the tab is reorderable or not 828 * 829 * Since: 2.10 830 */ 831 public void setTabReorderable(Widget child, bool reorderable) 832 { 833 gtk_notebook_set_tab_reorderable(gtkNotebook, (child is null) ? null : child.getWidgetStruct(), reorderable); 834 } 835 836 int[string] connectedSignals; 837 838 bool delegate(int, Notebook)[] onChangeCurrentPageListeners; 839 void addOnChangeCurrentPage(bool delegate(int, Notebook) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 840 { 841 if ( "change-current-page" !in connectedSignals ) 842 { 843 Signals.connectData( 844 this, 845 "change-current-page", 846 cast(GCallback)&callBackChangeCurrentPage, 847 cast(void*)this, 848 null, 849 connectFlags); 850 connectedSignals["change-current-page"] = 1; 851 } 852 onChangeCurrentPageListeners ~= dlg; 853 } 854 extern(C) static int callBackChangeCurrentPage(GtkNotebook* notebookStruct, int object, Notebook _notebook) 855 { 856 foreach ( bool delegate(int, Notebook) dlg; _notebook.onChangeCurrentPageListeners ) 857 { 858 if ( dlg(object, _notebook) ) 859 { 860 return 1; 861 } 862 } 863 864 return 0; 865 } 866 867 Notebook delegate(Widget, int, int, Notebook)[] onCreateWindowListeners; 868 /** 869 * The ::create-window signal is emitted when a detachable 870 * tab is dropped on the root window. 871 * 872 * A handler for this signal can create a window containing 873 * a notebook where the tab will be attached. It is also 874 * responsible for moving/resizing the window and adding the 875 * necessary properties to the notebook (e.g. the 876 * #GtkNotebook:group-name ). 877 * 878 * Params: 879 * page = the tab of @notebook that is being detached 880 * x = the X coordinate where the drop happens 881 * y = the Y coordinate where the drop happens 882 * 883 * Return: a #GtkNotebook that @page should be 884 * added to, or %NULL. 885 * 886 * Since: 2.12 887 */ 888 void addOnCreateWindow(Notebook delegate(Widget, int, int, Notebook) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 889 { 890 if ( "create-window" !in connectedSignals ) 891 { 892 Signals.connectData( 893 this, 894 "create-window", 895 cast(GCallback)&callBackCreateWindow, 896 cast(void*)this, 897 null, 898 connectFlags); 899 connectedSignals["create-window"] = 1; 900 } 901 onCreateWindowListeners ~= dlg; 902 } 903 extern(C) static GtkNotebook* callBackCreateWindow(GtkNotebook* notebookStruct, GtkWidget* page, int x, int y, Notebook _notebook) 904 { 905 foreach ( Notebook delegate(Widget, int, int, Notebook) dlg; _notebook.onCreateWindowListeners ) 906 { 907 if ( auto r = dlg(ObjectG.getDObject!(Widget)(page), x, y, _notebook) ) 908 return r.getNotebookStruct(); 909 } 910 911 return null; 912 } 913 914 bool delegate(GtkNotebookTab, Notebook)[] onFocusTabListeners; 915 void addOnFocusTab(bool delegate(GtkNotebookTab, Notebook) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 916 { 917 if ( "focus-tab" !in connectedSignals ) 918 { 919 Signals.connectData( 920 this, 921 "focus-tab", 922 cast(GCallback)&callBackFocusTab, 923 cast(void*)this, 924 null, 925 connectFlags); 926 connectedSignals["focus-tab"] = 1; 927 } 928 onFocusTabListeners ~= dlg; 929 } 930 extern(C) static int callBackFocusTab(GtkNotebook* notebookStruct, GtkNotebookTab object, Notebook _notebook) 931 { 932 foreach ( bool delegate(GtkNotebookTab, Notebook) dlg; _notebook.onFocusTabListeners ) 933 { 934 if ( dlg(object, _notebook) ) 935 { 936 return 1; 937 } 938 } 939 940 return 0; 941 } 942 943 void delegate(GtkDirectionType, Notebook)[] onMoveFocusOutListeners; 944 void addOnMoveFocusOut(void delegate(GtkDirectionType, Notebook) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 945 { 946 if ( "move-focus-out" !in connectedSignals ) 947 { 948 Signals.connectData( 949 this, 950 "move-focus-out", 951 cast(GCallback)&callBackMoveFocusOut, 952 cast(void*)this, 953 null, 954 connectFlags); 955 connectedSignals["move-focus-out"] = 1; 956 } 957 onMoveFocusOutListeners ~= dlg; 958 } 959 extern(C) static void callBackMoveFocusOut(GtkNotebook* notebookStruct, GtkDirectionType object, Notebook _notebook) 960 { 961 foreach ( void delegate(GtkDirectionType, Notebook) dlg; _notebook.onMoveFocusOutListeners ) 962 { 963 dlg(object, _notebook); 964 } 965 } 966 967 void delegate(Widget, uint, Notebook)[] onPageAddedListeners; 968 /** 969 * the ::page-added signal is emitted in the notebook 970 * right after a page is added to the notebook. 971 * 972 * Params: 973 * child = the child #GtkWidget affected 974 * pageNum = the new page number for @child 975 * 976 * Since: 2.10 977 */ 978 void addOnPageAdded(void delegate(Widget, uint, Notebook) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 979 { 980 if ( "page-added" !in connectedSignals ) 981 { 982 Signals.connectData( 983 this, 984 "page-added", 985 cast(GCallback)&callBackPageAdded, 986 cast(void*)this, 987 null, 988 connectFlags); 989 connectedSignals["page-added"] = 1; 990 } 991 onPageAddedListeners ~= dlg; 992 } 993 extern(C) static void callBackPageAdded(GtkNotebook* notebookStruct, GtkWidget* child, uint pageNum, Notebook _notebook) 994 { 995 foreach ( void delegate(Widget, uint, Notebook) dlg; _notebook.onPageAddedListeners ) 996 { 997 dlg(ObjectG.getDObject!(Widget)(child), pageNum, _notebook); 998 } 999 } 1000 1001 void delegate(Widget, uint, Notebook)[] onPageRemovedListeners; 1002 /** 1003 * the ::page-removed signal is emitted in the notebook 1004 * right after a page is removed from the notebook. 1005 * 1006 * Params: 1007 * child = the child #GtkWidget affected 1008 * pageNum = the @child page number 1009 * 1010 * Since: 2.10 1011 */ 1012 void addOnPageRemoved(void delegate(Widget, uint, Notebook) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1013 { 1014 if ( "page-removed" !in connectedSignals ) 1015 { 1016 Signals.connectData( 1017 this, 1018 "page-removed", 1019 cast(GCallback)&callBackPageRemoved, 1020 cast(void*)this, 1021 null, 1022 connectFlags); 1023 connectedSignals["page-removed"] = 1; 1024 } 1025 onPageRemovedListeners ~= dlg; 1026 } 1027 extern(C) static void callBackPageRemoved(GtkNotebook* notebookStruct, GtkWidget* child, uint pageNum, Notebook _notebook) 1028 { 1029 foreach ( void delegate(Widget, uint, Notebook) dlg; _notebook.onPageRemovedListeners ) 1030 { 1031 dlg(ObjectG.getDObject!(Widget)(child), pageNum, _notebook); 1032 } 1033 } 1034 1035 void delegate(Widget, uint, Notebook)[] onPageReorderedListeners; 1036 /** 1037 * the ::page-reordered signal is emitted in the notebook 1038 * right after a page has been reordered. 1039 * 1040 * Params: 1041 * child = the child #GtkWidget affected 1042 * pageNum = the new page number for @child 1043 * 1044 * Since: 2.10 1045 */ 1046 void addOnPageReordered(void delegate(Widget, uint, Notebook) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1047 { 1048 if ( "page-reordered" !in connectedSignals ) 1049 { 1050 Signals.connectData( 1051 this, 1052 "page-reordered", 1053 cast(GCallback)&callBackPageReordered, 1054 cast(void*)this, 1055 null, 1056 connectFlags); 1057 connectedSignals["page-reordered"] = 1; 1058 } 1059 onPageReorderedListeners ~= dlg; 1060 } 1061 extern(C) static void callBackPageReordered(GtkNotebook* notebookStruct, GtkWidget* child, uint pageNum, Notebook _notebook) 1062 { 1063 foreach ( void delegate(Widget, uint, Notebook) dlg; _notebook.onPageReorderedListeners ) 1064 { 1065 dlg(ObjectG.getDObject!(Widget)(child), pageNum, _notebook); 1066 } 1067 } 1068 1069 bool delegate(GtkDirectionType, bool, Notebook)[] onReorderTabListeners; 1070 void addOnReorderTab(bool delegate(GtkDirectionType, bool, Notebook) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1071 { 1072 if ( "reorder-tab" !in connectedSignals ) 1073 { 1074 Signals.connectData( 1075 this, 1076 "reorder-tab", 1077 cast(GCallback)&callBackReorderTab, 1078 cast(void*)this, 1079 null, 1080 connectFlags); 1081 connectedSignals["reorder-tab"] = 1; 1082 } 1083 onReorderTabListeners ~= dlg; 1084 } 1085 extern(C) static int callBackReorderTab(GtkNotebook* notebookStruct, GtkDirectionType object, bool p0, Notebook _notebook) 1086 { 1087 foreach ( bool delegate(GtkDirectionType, bool, Notebook) dlg; _notebook.onReorderTabListeners ) 1088 { 1089 if ( dlg(object, p0, _notebook) ) 1090 { 1091 return 1; 1092 } 1093 } 1094 1095 return 0; 1096 } 1097 1098 bool delegate(bool, Notebook)[] onSelectPageListeners; 1099 void addOnSelectPage(bool delegate(bool, Notebook) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1100 { 1101 if ( "select-page" !in connectedSignals ) 1102 { 1103 Signals.connectData( 1104 this, 1105 "select-page", 1106 cast(GCallback)&callBackSelectPage, 1107 cast(void*)this, 1108 null, 1109 connectFlags); 1110 connectedSignals["select-page"] = 1; 1111 } 1112 onSelectPageListeners ~= dlg; 1113 } 1114 extern(C) static int callBackSelectPage(GtkNotebook* notebookStruct, bool object, Notebook _notebook) 1115 { 1116 foreach ( bool delegate(bool, Notebook) dlg; _notebook.onSelectPageListeners ) 1117 { 1118 if ( dlg(object, _notebook) ) 1119 { 1120 return 1; 1121 } 1122 } 1123 1124 return 0; 1125 } 1126 1127 void delegate(Widget, uint, Notebook)[] onSwitchPageListeners; 1128 /** 1129 * Emitted when the user or a function changes the current page. 1130 * 1131 * Params: 1132 * page = the new current page 1133 * pageNum = the index of the page 1134 */ 1135 void addOnSwitchPage(void delegate(Widget, uint, Notebook) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1136 { 1137 if ( "switch-page" !in connectedSignals ) 1138 { 1139 Signals.connectData( 1140 this, 1141 "switch-page", 1142 cast(GCallback)&callBackSwitchPage, 1143 cast(void*)this, 1144 null, 1145 connectFlags); 1146 connectedSignals["switch-page"] = 1; 1147 } 1148 onSwitchPageListeners ~= dlg; 1149 } 1150 extern(C) static void callBackSwitchPage(GtkNotebook* notebookStruct, GtkWidget* page, uint pageNum, Notebook _notebook) 1151 { 1152 foreach ( void delegate(Widget, uint, Notebook) dlg; _notebook.onSwitchPageListeners ) 1153 { 1154 dlg(ObjectG.getDObject!(Widget)(page), pageNum, _notebook); 1155 } 1156 } 1157 }