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.Entry; 26 27 private import gdk.Event; 28 private import gdkpixbuf.Pixbuf; 29 private import gio.IconIF; 30 private import glib.ConstructionException; 31 private import glib.Str; 32 private import gobject.ObjectG; 33 private import gobject.Signals; 34 private import gtk.Adjustment; 35 private import gtk.Border; 36 private import gtk.CellEditableIF; 37 private import gtk.CellEditableT; 38 private import gtk.EditableIF; 39 private import gtk.EditableT; 40 private import gtk.EntryBuffer; 41 private import gtk.EntryCompletion; 42 private import gtk.TargetList; 43 private import gtk.Widget; 44 private import gtk.c.functions; 45 public import gtk.c.types; 46 public import gtkc.gtktypes; 47 private import pango.PgAttributeList; 48 private import pango.PgLayout; 49 private import pango.PgTabArray; 50 private import std.algorithm; 51 52 53 /** 54 * The #GtkEntry widget is a single line text entry 55 * widget. A fairly large set of key bindings are supported 56 * by default. If the entered text is longer than the allocation 57 * of the widget, the widget will scroll so that the cursor 58 * position is visible. 59 * 60 * When using an entry for passwords and other sensitive information, 61 * it can be put into “password mode” using gtk_entry_set_visibility(). 62 * In this mode, entered text is displayed using a “invisible” character. 63 * By default, GTK+ picks the best invisible character that is available 64 * in the current font, but it can be changed with 65 * gtk_entry_set_invisible_char(). Since 2.16, GTK+ displays a warning 66 * when Caps Lock or input methods might interfere with entering text in 67 * a password entry. The warning can be turned off with the 68 * #GtkEntry:caps-lock-warning property. 69 * 70 * Since 2.16, GtkEntry has the ability to display progress or activity 71 * information behind the text. To make an entry display such information, 72 * use gtk_entry_set_progress_fraction() or gtk_entry_set_progress_pulse_step(). 73 * 74 * Additionally, GtkEntry can show icons at either side of the entry. These 75 * icons can be activatable by clicking, can be set up as drag source and 76 * can have tooltips. To add an icon, use gtk_entry_set_icon_from_gicon() or 77 * one of the various other functions that set an icon from a stock id, an 78 * icon name or a pixbuf. To trigger an action when the user clicks an icon, 79 * connect to the #GtkEntry::icon-press signal. To allow DND operations 80 * from an icon, use gtk_entry_set_icon_drag_source(). To set a tooltip on 81 * an icon, use gtk_entry_set_icon_tooltip_text() or the corresponding function 82 * for markup. 83 * 84 * Note that functionality or information that is only available by clicking 85 * on an icon in an entry may not be accessible at all to users which are not 86 * able to use a mouse or other pointing device. It is therefore recommended 87 * that any such functionality should also be available by other means, e.g. 88 * via the context menu of the entry. 89 * 90 * # CSS nodes 91 * 92 * |[<!-- language="plain" --> 93 * entry 94 * ├── image.left 95 * ├── image.right 96 * ├── undershoot.left 97 * ├── undershoot.right 98 * ├── [selection] 99 * ├── [progress[.pulse]] 100 * ╰── [window.popup] 101 * ]| 102 * 103 * GtkEntry has a main node with the name entry. Depending on the properties 104 * of the entry, the style classes .read-only and .flat may appear. The style 105 * classes .warning and .error may also be used with entries. 106 * 107 * When the entry shows icons, it adds subnodes with the name image and the 108 * style class .left or .right, depending on where the icon appears. 109 * 110 * When the entry has a selection, it adds a subnode with the name selection. 111 * 112 * When the entry shows progress, it adds a subnode with the name progress. 113 * The node has the style class .pulse when the shown progress is pulsing. 114 * 115 * The CSS node for a context menu is added as a subnode below entry as well. 116 * 117 * The undershoot nodes are used to draw the underflow indication when content 118 * is scrolled out of view. These nodes get the .left and .right style classes 119 * added depending on where the indication is drawn. 120 * 121 * When touch is used and touch selection handles are shown, they are using 122 * CSS nodes with name cursor-handle. They get the .top or .bottom style class 123 * depending on where they are shown in relation to the selection. If there is 124 * just a single handle for the text cursor, it gets the style class 125 * .insertion-cursor. 126 */ 127 public class Entry : Widget, CellEditableIF, EditableIF 128 { 129 /** the main Gtk struct */ 130 protected GtkEntry* gtkEntry; 131 132 /** Get the main Gtk struct */ 133 public GtkEntry* getEntryStruct(bool transferOwnership = false) 134 { 135 if (transferOwnership) 136 ownedRef = false; 137 return gtkEntry; 138 } 139 140 /** the main Gtk struct as a void* */ 141 protected override void* getStruct() 142 { 143 return cast(void*)gtkEntry; 144 } 145 146 /** 147 * Sets our main struct and passes it to the parent class. 148 */ 149 public this (GtkEntry* gtkEntry, bool ownedRef = false) 150 { 151 this.gtkEntry = gtkEntry; 152 super(cast(GtkWidget*)gtkEntry, ownedRef); 153 } 154 155 // add the CellEditable capabilities 156 mixin CellEditableT!(GtkEntry); 157 158 // add the Editable capabilities 159 mixin EditableT!(GtkEntry); 160 161 /** */ 162 public this (string text) 163 { 164 this(); 165 setText(text); 166 } 167 168 /** */ 169 public this (string text, int max) 170 { 171 this(text); 172 setMaxLength(max); 173 } 174 175 /** 176 * Gets the stock id of action. 177 * Since 2.16 178 * Returns: the stock id 179 */ 180 public StockID getStockId(GtkEntryIconPosition iconPos) 181 { 182 return cast(StockID)Str.toString(gtk_entry_get_icon_stock(gtkEntry, iconPos)); 183 } 184 185 /** 186 * Sets the stock id on action 187 * Since 2.16 188 * Params: 189 * stockId = the stock id 190 */ 191 public void setStockId(GtkEntryIconPosition iconPos, StockID stockId) 192 { 193 // void gtk_entry_set_icon_from_stock (GtkEntry *entry, GtkEntryIconPosition icon_pos, const gchar *stock_id); 194 gtk_entry_set_icon_from_stock(gtkEntry, iconPos, Str.toStringz(stockId)); 195 } 196 197 /** 198 */ 199 200 /** */ 201 public static GType getType() 202 { 203 return gtk_entry_get_type(); 204 } 205 206 /** 207 * Creates a new entry. 208 * 209 * Returns: a new #GtkEntry. 210 * 211 * Throws: ConstructionException GTK+ fails to create the object. 212 */ 213 public this() 214 { 215 auto p = gtk_entry_new(); 216 217 if(p is null) 218 { 219 throw new ConstructionException("null returned by new"); 220 } 221 222 this(cast(GtkEntry*) p); 223 } 224 225 /** 226 * Creates a new entry with the specified text buffer. 227 * 228 * Params: 229 * buffer = The buffer to use for the new #GtkEntry. 230 * 231 * Returns: a new #GtkEntry 232 * 233 * Since: 2.18 234 * 235 * Throws: ConstructionException GTK+ fails to create the object. 236 */ 237 public this(EntryBuffer buffer) 238 { 239 auto p = gtk_entry_new_with_buffer((buffer is null) ? null : buffer.getEntryBufferStruct()); 240 241 if(p is null) 242 { 243 throw new ConstructionException("null returned by new_with_buffer"); 244 } 245 246 this(cast(GtkEntry*) p); 247 } 248 249 /** 250 * Retrieves the value set by gtk_entry_set_activates_default(). 251 * 252 * Returns: %TRUE if the entry will activate the default widget 253 */ 254 public bool getActivatesDefault() 255 { 256 return gtk_entry_get_activates_default(gtkEntry) != 0; 257 } 258 259 /** 260 * Gets the value set by gtk_entry_set_alignment(). 261 * 262 * Returns: the alignment 263 * 264 * Since: 2.4 265 */ 266 public float getAlignment() 267 { 268 return gtk_entry_get_alignment(gtkEntry); 269 } 270 271 /** 272 * Gets the attribute list that was set on the entry using 273 * gtk_entry_set_attributes(), if any. 274 * 275 * Returns: the attribute list, or %NULL 276 * if none was set. 277 * 278 * Since: 3.6 279 */ 280 public PgAttributeList getAttributes() 281 { 282 auto p = gtk_entry_get_attributes(gtkEntry); 283 284 if(p is null) 285 { 286 return null; 287 } 288 289 return ObjectG.getDObject!(PgAttributeList)(cast(PangoAttrList*) p); 290 } 291 292 /** 293 * Get the #GtkEntryBuffer object which holds the text for 294 * this widget. 295 * 296 * Returns: A #GtkEntryBuffer object. 297 * 298 * Since: 2.18 299 */ 300 public EntryBuffer getBuffer() 301 { 302 auto p = gtk_entry_get_buffer(gtkEntry); 303 304 if(p is null) 305 { 306 return null; 307 } 308 309 return ObjectG.getDObject!(EntryBuffer)(cast(GtkEntryBuffer*) p); 310 } 311 312 /** 313 * Returns the auxiliary completion object currently in use by @entry. 314 * 315 * Returns: The auxiliary completion object currently 316 * in use by @entry. 317 * 318 * Since: 2.4 319 */ 320 public EntryCompletion getCompletion() 321 { 322 auto p = gtk_entry_get_completion(gtkEntry); 323 324 if(p is null) 325 { 326 return null; 327 } 328 329 return ObjectG.getDObject!(EntryCompletion)(cast(GtkEntryCompletion*) p); 330 } 331 332 /** 333 * Returns the index of the icon which is the source of the current 334 * DND operation, or -1. 335 * 336 * This function is meant to be used in a #GtkWidget::drag-data-get 337 * callback. 338 * 339 * Returns: index of the icon which is the source of the current 340 * DND operation, or -1. 341 * 342 * Since: 2.16 343 */ 344 public int getCurrentIconDragSource() 345 { 346 return gtk_entry_get_current_icon_drag_source(gtkEntry); 347 } 348 349 /** 350 * Retrieves the horizontal cursor adjustment for the entry. 351 * See gtk_entry_set_cursor_hadjustment(). 352 * 353 * Returns: the horizontal cursor adjustment, or %NULL 354 * if none has been set. 355 * 356 * Since: 2.12 357 */ 358 public Adjustment getCursorHadjustment() 359 { 360 auto p = gtk_entry_get_cursor_hadjustment(gtkEntry); 361 362 if(p is null) 363 { 364 return null; 365 } 366 367 return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p); 368 } 369 370 /** 371 * Gets the value set by gtk_entry_set_has_frame(). 372 * 373 * Returns: whether the entry has a beveled frame 374 */ 375 public bool getHasFrame() 376 { 377 return gtk_entry_get_has_frame(gtkEntry) != 0; 378 } 379 380 /** 381 * Returns whether the icon is activatable. 382 * 383 * Params: 384 * iconPos = Icon position 385 * 386 * Returns: %TRUE if the icon is activatable. 387 * 388 * Since: 2.16 389 */ 390 public bool getIconActivatable(GtkEntryIconPosition iconPos) 391 { 392 return gtk_entry_get_icon_activatable(gtkEntry, iconPos) != 0; 393 } 394 395 /** 396 * Gets the area where entry’s icon at @icon_pos is drawn. 397 * This function is useful when drawing something to the 398 * entry in a draw callback. 399 * 400 * If the entry is not realized or has no icon at the given position, 401 * @icon_area is filled with zeros. Otherwise, @icon_area will be filled 402 * with the icon’s allocation, relative to @entry’s allocation. 403 * 404 * See also gtk_entry_get_text_area() 405 * 406 * Params: 407 * iconPos = Icon position 408 * iconArea = Return location for the icon’s area 409 * 410 * Since: 3.0 411 */ 412 public void getIconArea(GtkEntryIconPosition iconPos, out GdkRectangle iconArea) 413 { 414 gtk_entry_get_icon_area(gtkEntry, iconPos, &iconArea); 415 } 416 417 /** 418 * Finds the icon at the given position and return its index. The 419 * position’s coordinates are relative to the @entry’s top left corner. 420 * If @x, @y doesn’t lie inside an icon, -1 is returned. 421 * This function is intended for use in a #GtkWidget::query-tooltip 422 * signal handler. 423 * 424 * Params: 425 * x = the x coordinate of the position to find 426 * y = the y coordinate of the position to find 427 * 428 * Returns: the index of the icon at the given position, or -1 429 * 430 * Since: 2.16 431 */ 432 public int getIconAtPos(int x, int y) 433 { 434 return gtk_entry_get_icon_at_pos(gtkEntry, x, y); 435 } 436 437 /** 438 * Retrieves the #GIcon used for the icon, or %NULL if there is 439 * no icon or if the icon was set by some other method (e.g., by 440 * stock, pixbuf, or icon name). 441 * 442 * Params: 443 * iconPos = Icon position 444 * 445 * Returns: A #GIcon, or %NULL if no icon is set 446 * or if the icon is not a #GIcon 447 * 448 * Since: 2.16 449 */ 450 public IconIF getIconGicon(GtkEntryIconPosition iconPos) 451 { 452 auto p = gtk_entry_get_icon_gicon(gtkEntry, iconPos); 453 454 if(p is null) 455 { 456 return null; 457 } 458 459 return ObjectG.getDObject!(IconIF)(cast(GIcon*) p); 460 } 461 462 /** 463 * Retrieves the icon name used for the icon, or %NULL if there is 464 * no icon or if the icon was set by some other method (e.g., by 465 * pixbuf, stock or gicon). 466 * 467 * Params: 468 * iconPos = Icon position 469 * 470 * Returns: An icon name, or %NULL if no icon is set or if the icon 471 * wasn’t set from an icon name 472 * 473 * Since: 2.16 474 */ 475 public string getIconName(GtkEntryIconPosition iconPos) 476 { 477 return Str.toString(gtk_entry_get_icon_name(gtkEntry, iconPos)); 478 } 479 480 /** 481 * Retrieves the image used for the icon. 482 * 483 * Unlike the other methods of setting and getting icon data, this 484 * method will work regardless of whether the icon was set using a 485 * #GdkPixbuf, a #GIcon, a stock item, or an icon name. 486 * 487 * Params: 488 * iconPos = Icon position 489 * 490 * Returns: A #GdkPixbuf, or %NULL if no icon is 491 * set for this position. 492 * 493 * Since: 2.16 494 */ 495 public Pixbuf getIconPixbuf(GtkEntryIconPosition iconPos) 496 { 497 auto p = gtk_entry_get_icon_pixbuf(gtkEntry, iconPos); 498 499 if(p is null) 500 { 501 return null; 502 } 503 504 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 505 } 506 507 /** 508 * Returns whether the icon appears sensitive or insensitive. 509 * 510 * Params: 511 * iconPos = Icon position 512 * 513 * Returns: %TRUE if the icon is sensitive. 514 * 515 * Since: 2.16 516 */ 517 public bool getIconSensitive(GtkEntryIconPosition iconPos) 518 { 519 return gtk_entry_get_icon_sensitive(gtkEntry, iconPos) != 0; 520 } 521 522 /** 523 * Retrieves the stock id used for the icon, or %NULL if there is 524 * no icon or if the icon was set by some other method (e.g., by 525 * pixbuf, icon name or gicon). 526 * 527 * Deprecated: Use gtk_entry_get_icon_name() instead. 528 * 529 * Params: 530 * iconPos = Icon position 531 * 532 * Returns: A stock id, or %NULL if no icon is set or if the icon 533 * wasn’t set from a stock id 534 * 535 * Since: 2.16 536 */ 537 public string getIconStock(GtkEntryIconPosition iconPos) 538 { 539 return Str.toString(gtk_entry_get_icon_stock(gtkEntry, iconPos)); 540 } 541 542 /** 543 * Gets the type of representation being used by the icon 544 * to store image data. If the icon has no image data, 545 * the return value will be %GTK_IMAGE_EMPTY. 546 * 547 * Params: 548 * iconPos = Icon position 549 * 550 * Returns: image representation being used 551 * 552 * Since: 2.16 553 */ 554 public GtkImageType getIconStorageType(GtkEntryIconPosition iconPos) 555 { 556 return gtk_entry_get_icon_storage_type(gtkEntry, iconPos); 557 } 558 559 /** 560 * Gets the contents of the tooltip on the icon at the specified 561 * position in @entry. 562 * 563 * Params: 564 * iconPos = the icon position 565 * 566 * Returns: the tooltip text, or %NULL. Free the returned 567 * string with g_free() when done. 568 * 569 * Since: 2.16 570 */ 571 public string getIconTooltipMarkup(GtkEntryIconPosition iconPos) 572 { 573 auto retStr = gtk_entry_get_icon_tooltip_markup(gtkEntry, iconPos); 574 575 scope(exit) Str.freeString(retStr); 576 return Str.toString(retStr); 577 } 578 579 /** 580 * Gets the contents of the tooltip on the icon at the specified 581 * position in @entry. 582 * 583 * Params: 584 * iconPos = the icon position 585 * 586 * Returns: the tooltip text, or %NULL. Free the returned 587 * string with g_free() when done. 588 * 589 * Since: 2.16 590 */ 591 public string getIconTooltipText(GtkEntryIconPosition iconPos) 592 { 593 auto retStr = gtk_entry_get_icon_tooltip_text(gtkEntry, iconPos); 594 595 scope(exit) Str.freeString(retStr); 596 return Str.toString(retStr); 597 } 598 599 /** 600 * This function returns the entry’s #GtkEntry:inner-border property. See 601 * gtk_entry_set_inner_border() for more information. 602 * 603 * Deprecated: Use the standard border and padding CSS properties (through 604 * objects like #GtkStyleContext and #GtkCssProvider); the value returned by 605 * this function is ignored by #GtkEntry. 606 * 607 * Returns: the entry’s #GtkBorder, or 608 * %NULL if none was set. 609 * 610 * Since: 2.10 611 */ 612 public Border getInnerBorder() 613 { 614 auto p = gtk_entry_get_inner_border(gtkEntry); 615 616 if(p is null) 617 { 618 return null; 619 } 620 621 return ObjectG.getDObject!(Border)(cast(GtkBorder*) p); 622 } 623 624 /** 625 * Gets the value of the #GtkEntry:input-hints property. 626 * 627 * Since: 3.6 628 */ 629 public GtkInputHints getInputHints() 630 { 631 return gtk_entry_get_input_hints(gtkEntry); 632 } 633 634 /** 635 * Gets the value of the #GtkEntry:input-purpose property. 636 * 637 * Since: 3.6 638 */ 639 public GtkInputPurpose getInputPurpose() 640 { 641 return gtk_entry_get_input_purpose(gtkEntry); 642 } 643 644 /** 645 * Retrieves the character displayed in place of the real characters 646 * for entries with visibility set to false. See gtk_entry_set_invisible_char(). 647 * 648 * Returns: the current invisible char, or 0, if the entry does not 649 * show invisible text at all. 650 */ 651 public dchar getInvisibleChar() 652 { 653 return gtk_entry_get_invisible_char(gtkEntry); 654 } 655 656 /** 657 * Gets the #PangoLayout used to display the entry. 658 * The layout is useful to e.g. convert text positions to 659 * pixel positions, in combination with gtk_entry_get_layout_offsets(). 660 * The returned layout is owned by the entry and must not be 661 * modified or freed by the caller. 662 * 663 * Keep in mind that the layout text may contain a preedit string, so 664 * gtk_entry_layout_index_to_text_index() and 665 * gtk_entry_text_index_to_layout_index() are needed to convert byte 666 * indices in the layout to byte indices in the entry contents. 667 * 668 * Returns: the #PangoLayout for this entry 669 */ 670 public PgLayout getLayout() 671 { 672 auto p = gtk_entry_get_layout(gtkEntry); 673 674 if(p is null) 675 { 676 return null; 677 } 678 679 return ObjectG.getDObject!(PgLayout)(cast(PangoLayout*) p); 680 } 681 682 /** 683 * Obtains the position of the #PangoLayout used to render text 684 * in the entry, in widget coordinates. Useful if you want to line 685 * up the text in an entry with some other text, e.g. when using the 686 * entry to implement editable cells in a sheet widget. 687 * 688 * Also useful to convert mouse events into coordinates inside the 689 * #PangoLayout, e.g. to take some action if some part of the entry text 690 * is clicked. 691 * 692 * Note that as the user scrolls around in the entry the offsets will 693 * change; you’ll need to connect to the “notify::scroll-offset” 694 * signal to track this. Remember when using the #PangoLayout 695 * functions you need to convert to and from pixels using 696 * PANGO_PIXELS() or #PANGO_SCALE. 697 * 698 * Keep in mind that the layout text may contain a preedit string, so 699 * gtk_entry_layout_index_to_text_index() and 700 * gtk_entry_text_index_to_layout_index() are needed to convert byte 701 * indices in the layout to byte indices in the entry contents. 702 * 703 * Params: 704 * x = location to store X offset of layout, or %NULL 705 * y = location to store Y offset of layout, or %NULL 706 */ 707 public void getLayoutOffsets(out int x, out int y) 708 { 709 gtk_entry_get_layout_offsets(gtkEntry, &x, &y); 710 } 711 712 /** 713 * Retrieves the maximum allowed length of the text in 714 * @entry. See gtk_entry_set_max_length(). 715 * 716 * This is equivalent to: 717 * 718 * |[<!-- language="C" --> 719 * GtkEntryBuffer *buffer; 720 * buffer = gtk_entry_get_buffer (entry); 721 * gtk_entry_buffer_get_max_length (buffer); 722 * ]| 723 * 724 * Returns: the maximum allowed number of characters 725 * in #GtkEntry, or 0 if there is no maximum. 726 */ 727 public int getMaxLength() 728 { 729 return gtk_entry_get_max_length(gtkEntry); 730 } 731 732 /** 733 * Retrieves the desired maximum width of @entry, in characters. 734 * See gtk_entry_set_max_width_chars(). 735 * 736 * Returns: the maximum width of the entry, in characters 737 * 738 * Since: 3.12 739 */ 740 public int getMaxWidthChars() 741 { 742 return gtk_entry_get_max_width_chars(gtkEntry); 743 } 744 745 /** 746 * Gets the value set by gtk_entry_set_overwrite_mode(). 747 * 748 * Returns: whether the text is overwritten when typing. 749 * 750 * Since: 2.14 751 */ 752 public bool getOverwriteMode() 753 { 754 return gtk_entry_get_overwrite_mode(gtkEntry) != 0; 755 } 756 757 /** 758 * Retrieves the text that will be displayed when @entry is empty and unfocused 759 * 760 * Returns: a pointer to the placeholder text as a string. This string points to internally allocated 761 * storage in the widget and must not be freed, modified or stored. 762 * 763 * Since: 3.2 764 */ 765 public string getPlaceholderText() 766 { 767 return Str.toString(gtk_entry_get_placeholder_text(gtkEntry)); 768 } 769 770 /** 771 * Returns the current fraction of the task that’s been completed. 772 * See gtk_entry_set_progress_fraction(). 773 * 774 * Returns: a fraction from 0.0 to 1.0 775 * 776 * Since: 2.16 777 */ 778 public double getProgressFraction() 779 { 780 return gtk_entry_get_progress_fraction(gtkEntry); 781 } 782 783 /** 784 * Retrieves the pulse step set with gtk_entry_set_progress_pulse_step(). 785 * 786 * Returns: a fraction from 0.0 to 1.0 787 * 788 * Since: 2.16 789 */ 790 public double getProgressPulseStep() 791 { 792 return gtk_entry_get_progress_pulse_step(gtkEntry); 793 } 794 795 /** 796 * Gets the tabstops that were set on the entry using gtk_entry_set_tabs(), if 797 * any. 798 * 799 * Returns: the tabstops, or %NULL if none was set. 800 * 801 * Since: 3.10 802 */ 803 public PgTabArray getTabs() 804 { 805 auto p = gtk_entry_get_tabs(gtkEntry); 806 807 if(p is null) 808 { 809 return null; 810 } 811 812 return ObjectG.getDObject!(PgTabArray)(cast(PangoTabArray*) p); 813 } 814 815 /** 816 * Retrieves the contents of the entry widget. 817 * See also gtk_editable_get_chars(). 818 * 819 * This is equivalent to: 820 * 821 * |[<!-- language="C" --> 822 * GtkEntryBuffer *buffer; 823 * buffer = gtk_entry_get_buffer (entry); 824 * gtk_entry_buffer_get_text (buffer); 825 * ]| 826 * 827 * Returns: a pointer to the contents of the widget as a 828 * string. This string points to internally allocated 829 * storage in the widget and must not be freed, modified or 830 * stored. 831 */ 832 public string getText() 833 { 834 return Str.toString(gtk_entry_get_text(gtkEntry)); 835 } 836 837 /** 838 * Gets the area where the entry’s text is drawn. This function is 839 * useful when drawing something to the entry in a draw callback. 840 * 841 * If the entry is not realized, @text_area is filled with zeros. 842 * 843 * See also gtk_entry_get_icon_area(). 844 * 845 * Params: 846 * textArea = Return location for the text area. 847 * 848 * Since: 3.0 849 */ 850 public void getTextArea(out GdkRectangle textArea) 851 { 852 gtk_entry_get_text_area(gtkEntry, &textArea); 853 } 854 855 /** 856 * Retrieves the current length of the text in 857 * @entry. 858 * 859 * This is equivalent to: 860 * 861 * |[<!-- language="C" --> 862 * GtkEntryBuffer *buffer; 863 * buffer = gtk_entry_get_buffer (entry); 864 * gtk_entry_buffer_get_length (buffer); 865 * ]| 866 * 867 * Returns: the current number of characters 868 * in #GtkEntry, or 0 if there are none. 869 * 870 * Since: 2.14 871 */ 872 public ushort getTextLength() 873 { 874 return gtk_entry_get_text_length(gtkEntry); 875 } 876 877 /** 878 * Retrieves whether the text in @entry is visible. See 879 * gtk_entry_set_visibility(). 880 * 881 * Returns: %TRUE if the text is currently visible 882 */ 883 public bool getVisibility() 884 { 885 return gtk_entry_get_visibility(gtkEntry) != 0; 886 } 887 888 /** 889 * Gets the value set by gtk_entry_set_width_chars(). 890 * 891 * Returns: number of chars to request space for, or negative if unset 892 */ 893 public int getWidthChars() 894 { 895 return gtk_entry_get_width_chars(gtkEntry); 896 } 897 898 /** 899 * Causes @entry to have keyboard focus. 900 * 901 * It behaves like gtk_widget_grab_focus(), 902 * except that it doesn't select the contents of the entry. 903 * You only want to call this on some special entries 904 * which the user usually doesn't want to replace all text in, 905 * such as search-as-you-type entries. 906 * 907 * Since: 3.16 908 */ 909 public void grabFocusWithoutSelecting() 910 { 911 gtk_entry_grab_focus_without_selecting(gtkEntry); 912 } 913 914 /** 915 * Allow the #GtkEntry input method to internally handle key press 916 * and release events. If this function returns %TRUE, then no further 917 * processing should be done for this key event. See 918 * gtk_im_context_filter_keypress(). 919 * 920 * Note that you are expected to call this function from your handler 921 * when overriding key event handling. This is needed in the case when 922 * you need to insert your own key handling between the input method 923 * and the default key event handling of the #GtkEntry. 924 * See gtk_text_view_reset_im_context() for an example of use. 925 * 926 * Params: 927 * event = the key event 928 * 929 * Returns: %TRUE if the input method handled the key event. 930 * 931 * Since: 2.22 932 */ 933 public bool imContextFilterKeypress(GdkEventKey* event) 934 { 935 return gtk_entry_im_context_filter_keypress(gtkEntry, event) != 0; 936 } 937 938 /** 939 * Converts from a position in the entry’s #PangoLayout (returned by 940 * gtk_entry_get_layout()) to a position in the entry contents 941 * (returned by gtk_entry_get_text()). 942 * 943 * Params: 944 * layoutIndex = byte index into the entry layout text 945 * 946 * Returns: byte index into the entry contents 947 */ 948 public int layoutIndexToTextIndex(int layoutIndex) 949 { 950 return gtk_entry_layout_index_to_text_index(gtkEntry, layoutIndex); 951 } 952 953 /** 954 * Indicates that some progress is made, but you don’t know how much. 955 * Causes the entry’s progress indicator to enter “activity mode,” 956 * where a block bounces back and forth. Each call to 957 * gtk_entry_progress_pulse() causes the block to move by a little bit 958 * (the amount of movement per pulse is determined by 959 * gtk_entry_set_progress_pulse_step()). 960 * 961 * Since: 2.16 962 */ 963 public void progressPulse() 964 { 965 gtk_entry_progress_pulse(gtkEntry); 966 } 967 968 /** 969 * Reset the input method context of the entry if needed. 970 * 971 * This can be necessary in the case where modifying the buffer 972 * would confuse on-going input method behavior. 973 * 974 * Since: 2.22 975 */ 976 public void resetImContext() 977 { 978 gtk_entry_reset_im_context(gtkEntry); 979 } 980 981 /** 982 * If @setting is %TRUE, pressing Enter in the @entry will activate the default 983 * widget for the window containing the entry. This usually means that 984 * the dialog box containing the entry will be closed, since the default 985 * widget is usually one of the dialog buttons. 986 * 987 * (For experts: if @setting is %TRUE, the entry calls 988 * gtk_window_activate_default() on the window containing the entry, in 989 * the default handler for the #GtkEntry::activate signal.) 990 * 991 * Params: 992 * setting = %TRUE to activate window’s default widget on Enter keypress 993 */ 994 public void setActivatesDefault(bool setting) 995 { 996 gtk_entry_set_activates_default(gtkEntry, setting); 997 } 998 999 /** 1000 * Sets the alignment for the contents of the entry. This controls 1001 * the horizontal positioning of the contents when the displayed 1002 * text is shorter than the width of the entry. 1003 * 1004 * Params: 1005 * xalign = The horizontal alignment, from 0 (left) to 1 (right). 1006 * Reversed for RTL layouts 1007 * 1008 * Since: 2.4 1009 */ 1010 public void setAlignment(float xalign) 1011 { 1012 gtk_entry_set_alignment(gtkEntry, xalign); 1013 } 1014 1015 /** 1016 * Sets a #PangoAttrList; the attributes in the list are applied to the 1017 * entry text. 1018 * 1019 * Params: 1020 * attrs = a #PangoAttrList 1021 * 1022 * Since: 3.6 1023 */ 1024 public void setAttributes(PgAttributeList attrs) 1025 { 1026 gtk_entry_set_attributes(gtkEntry, (attrs is null) ? null : attrs.getPgAttributeListStruct()); 1027 } 1028 1029 /** 1030 * Set the #GtkEntryBuffer object which holds the text for 1031 * this widget. 1032 * 1033 * Params: 1034 * buffer = a #GtkEntryBuffer 1035 * 1036 * Since: 2.18 1037 */ 1038 public void setBuffer(EntryBuffer buffer) 1039 { 1040 gtk_entry_set_buffer(gtkEntry, (buffer is null) ? null : buffer.getEntryBufferStruct()); 1041 } 1042 1043 /** 1044 * Sets @completion to be the auxiliary completion object to use with @entry. 1045 * All further configuration of the completion mechanism is done on 1046 * @completion using the #GtkEntryCompletion API. Completion is disabled if 1047 * @completion is set to %NULL. 1048 * 1049 * Params: 1050 * completion = The #GtkEntryCompletion or %NULL 1051 * 1052 * Since: 2.4 1053 */ 1054 public void setCompletion(EntryCompletion completion) 1055 { 1056 gtk_entry_set_completion(gtkEntry, (completion is null) ? null : completion.getEntryCompletionStruct()); 1057 } 1058 1059 /** 1060 * Hooks up an adjustment to the cursor position in an entry, so that when 1061 * the cursor is moved, the adjustment is scrolled to show that position. 1062 * See gtk_scrolled_window_get_hadjustment() for a typical way of obtaining 1063 * the adjustment. 1064 * 1065 * The adjustment has to be in pixel units and in the same coordinate system 1066 * as the entry. 1067 * 1068 * Params: 1069 * adjustment = an adjustment which should be adjusted when the cursor 1070 * is moved, or %NULL 1071 * 1072 * Since: 2.12 1073 */ 1074 public void setCursorHadjustment(Adjustment adjustment) 1075 { 1076 gtk_entry_set_cursor_hadjustment(gtkEntry, (adjustment is null) ? null : adjustment.getAdjustmentStruct()); 1077 } 1078 1079 /** 1080 * Sets whether the entry has a beveled frame around it. 1081 * 1082 * Params: 1083 * setting = new value 1084 */ 1085 public void setHasFrame(bool setting) 1086 { 1087 gtk_entry_set_has_frame(gtkEntry, setting); 1088 } 1089 1090 /** 1091 * Sets whether the icon is activatable. 1092 * 1093 * Params: 1094 * iconPos = Icon position 1095 * activatable = %TRUE if the icon should be activatable 1096 * 1097 * Since: 2.16 1098 */ 1099 public void setIconActivatable(GtkEntryIconPosition iconPos, bool activatable) 1100 { 1101 gtk_entry_set_icon_activatable(gtkEntry, iconPos, activatable); 1102 } 1103 1104 /** 1105 * Sets up the icon at the given position so that GTK+ will start a drag 1106 * operation when the user clicks and drags the icon. 1107 * 1108 * To handle the drag operation, you need to connect to the usual 1109 * #GtkWidget::drag-data-get (or possibly #GtkWidget::drag-data-delete) 1110 * signal, and use gtk_entry_get_current_icon_drag_source() in 1111 * your signal handler to find out if the drag was started from 1112 * an icon. 1113 * 1114 * By default, GTK+ uses the icon as the drag icon. You can use the 1115 * #GtkWidget::drag-begin signal to set a different icon. Note that you 1116 * have to use g_signal_connect_after() to ensure that your signal handler 1117 * gets executed after the default handler. 1118 * 1119 * Params: 1120 * iconPos = icon position 1121 * targetList = the targets (data formats) in which the data can be provided 1122 * actions = a bitmask of the allowed drag actions 1123 * 1124 * Since: 2.16 1125 */ 1126 public void setIconDragSource(GtkEntryIconPosition iconPos, TargetList targetList, GdkDragAction actions) 1127 { 1128 gtk_entry_set_icon_drag_source(gtkEntry, iconPos, (targetList is null) ? null : targetList.getTargetListStruct(), actions); 1129 } 1130 1131 /** 1132 * Sets the icon shown in the entry at the specified position 1133 * from the current icon theme. 1134 * If the icon isn’t known, a “broken image” icon will be displayed 1135 * instead. 1136 * 1137 * If @icon is %NULL, no icon will be shown in the specified position. 1138 * 1139 * Params: 1140 * iconPos = The position at which to set the icon 1141 * icon = The icon to set, or %NULL 1142 * 1143 * Since: 2.16 1144 */ 1145 public void setIconFromGicon(GtkEntryIconPosition iconPos, IconIF icon) 1146 { 1147 gtk_entry_set_icon_from_gicon(gtkEntry, iconPos, (icon is null) ? null : icon.getIconStruct()); 1148 } 1149 1150 /** 1151 * Sets the icon shown in the entry at the specified position 1152 * from the current icon theme. 1153 * 1154 * If the icon name isn’t known, a “broken image” icon will be displayed 1155 * instead. 1156 * 1157 * If @icon_name is %NULL, no icon will be shown in the specified position. 1158 * 1159 * Params: 1160 * iconPos = The position at which to set the icon 1161 * iconName = An icon name, or %NULL 1162 * 1163 * Since: 2.16 1164 */ 1165 public void setIconFromIconName(GtkEntryIconPosition iconPos, string iconName) 1166 { 1167 gtk_entry_set_icon_from_icon_name(gtkEntry, iconPos, Str.toStringz(iconName)); 1168 } 1169 1170 /** 1171 * Sets the icon shown in the specified position using a pixbuf. 1172 * 1173 * If @pixbuf is %NULL, no icon will be shown in the specified position. 1174 * 1175 * Params: 1176 * iconPos = Icon position 1177 * pixbuf = A #GdkPixbuf, or %NULL 1178 * 1179 * Since: 2.16 1180 */ 1181 public void setIconFromPixbuf(GtkEntryIconPosition iconPos, Pixbuf pixbuf) 1182 { 1183 gtk_entry_set_icon_from_pixbuf(gtkEntry, iconPos, (pixbuf is null) ? null : pixbuf.getPixbufStruct()); 1184 } 1185 1186 /** 1187 * Sets the icon shown in the entry at the specified position from 1188 * a stock image. 1189 * 1190 * If @stock_id is %NULL, no icon will be shown in the specified position. 1191 * 1192 * Deprecated: Use gtk_entry_set_icon_from_icon_name() instead. 1193 * 1194 * Params: 1195 * iconPos = Icon position 1196 * stockId = The name of the stock item, or %NULL 1197 * 1198 * Since: 2.16 1199 */ 1200 public void setIconFromStock(GtkEntryIconPosition iconPos, string stockId) 1201 { 1202 gtk_entry_set_icon_from_stock(gtkEntry, iconPos, Str.toStringz(stockId)); 1203 } 1204 1205 /** 1206 * Sets the sensitivity for the specified icon. 1207 * 1208 * Params: 1209 * iconPos = Icon position 1210 * sensitive = Specifies whether the icon should appear 1211 * sensitive or insensitive 1212 * 1213 * Since: 2.16 1214 */ 1215 public void setIconSensitive(GtkEntryIconPosition iconPos, bool sensitive) 1216 { 1217 gtk_entry_set_icon_sensitive(gtkEntry, iconPos, sensitive); 1218 } 1219 1220 /** 1221 * Sets @tooltip as the contents of the tooltip for the icon at 1222 * the specified position. @tooltip is assumed to be marked up with 1223 * the [Pango text markup language][PangoMarkupFormat]. 1224 * 1225 * Use %NULL for @tooltip to remove an existing tooltip. 1226 * 1227 * See also gtk_widget_set_tooltip_markup() and 1228 * gtk_entry_set_icon_tooltip_text(). 1229 * 1230 * Params: 1231 * iconPos = the icon position 1232 * tooltip = the contents of the tooltip for the icon, or %NULL 1233 * 1234 * Since: 2.16 1235 */ 1236 public void setIconTooltipMarkup(GtkEntryIconPosition iconPos, string tooltip) 1237 { 1238 gtk_entry_set_icon_tooltip_markup(gtkEntry, iconPos, Str.toStringz(tooltip)); 1239 } 1240 1241 /** 1242 * Sets @tooltip as the contents of the tooltip for the icon 1243 * at the specified position. 1244 * 1245 * Use %NULL for @tooltip to remove an existing tooltip. 1246 * 1247 * See also gtk_widget_set_tooltip_text() and 1248 * gtk_entry_set_icon_tooltip_markup(). 1249 * 1250 * If you unset the widget tooltip via gtk_widget_set_tooltip_text() or 1251 * gtk_widget_set_tooltip_markup(), this sets GtkWidget:has-tooltip to %FALSE, 1252 * which suppresses icon tooltips too. You can resolve this by then calling 1253 * gtk_widget_set_has_tooltip() to set GtkWidget:has-tooltip back to %TRUE, or 1254 * setting at least one non-empty tooltip on any icon achieves the same result. 1255 * 1256 * Params: 1257 * iconPos = the icon position 1258 * tooltip = the contents of the tooltip for the icon, or %NULL 1259 * 1260 * Since: 2.16 1261 */ 1262 public void setIconTooltipText(GtkEntryIconPosition iconPos, string tooltip) 1263 { 1264 gtk_entry_set_icon_tooltip_text(gtkEntry, iconPos, Str.toStringz(tooltip)); 1265 } 1266 1267 /** 1268 * Sets %entry’s inner-border property to @border, or clears it if %NULL 1269 * is passed. The inner-border is the area around the entry’s text, but 1270 * inside its frame. 1271 * 1272 * If set, this property overrides the inner-border style property. 1273 * Overriding the style-provided border is useful when you want to do 1274 * in-place editing of some text in a canvas or list widget, where 1275 * pixel-exact positioning of the entry is important. 1276 * 1277 * Deprecated: Use the standard border and padding CSS properties (through 1278 * objects like #GtkStyleContext and #GtkCssProvider); the value set with 1279 * this function is ignored by #GtkEntry. 1280 * 1281 * Params: 1282 * border = a #GtkBorder, or %NULL 1283 * 1284 * Since: 2.10 1285 */ 1286 public void setInnerBorder(Border border) 1287 { 1288 gtk_entry_set_inner_border(gtkEntry, (border is null) ? null : border.getBorderStruct()); 1289 } 1290 1291 /** 1292 * Sets the #GtkEntry:input-hints property, which 1293 * allows input methods to fine-tune their behaviour. 1294 * 1295 * Params: 1296 * hints = the hints 1297 * 1298 * Since: 3.6 1299 */ 1300 public void setInputHints(GtkInputHints hints) 1301 { 1302 gtk_entry_set_input_hints(gtkEntry, hints); 1303 } 1304 1305 /** 1306 * Sets the #GtkEntry:input-purpose property which 1307 * can be used by on-screen keyboards and other input 1308 * methods to adjust their behaviour. 1309 * 1310 * Params: 1311 * purpose = the purpose 1312 * 1313 * Since: 3.6 1314 */ 1315 public void setInputPurpose(GtkInputPurpose purpose) 1316 { 1317 gtk_entry_set_input_purpose(gtkEntry, purpose); 1318 } 1319 1320 /** 1321 * Sets the character to use in place of the actual text when 1322 * gtk_entry_set_visibility() has been called to set text visibility 1323 * to %FALSE. i.e. this is the character used in “password mode” to 1324 * show the user how many characters have been typed. By default, GTK+ 1325 * picks the best invisible char available in the current font. If you 1326 * set the invisible char to 0, then the user will get no feedback 1327 * at all; there will be no text on the screen as they type. 1328 * 1329 * Params: 1330 * ch = a Unicode character 1331 */ 1332 public void setInvisibleChar(dchar ch) 1333 { 1334 gtk_entry_set_invisible_char(gtkEntry, ch); 1335 } 1336 1337 /** 1338 * Sets the maximum allowed length of the contents of the widget. If 1339 * the current contents are longer than the given length, then they 1340 * will be truncated to fit. 1341 * 1342 * This is equivalent to: 1343 * 1344 * |[<!-- language="C" --> 1345 * GtkEntryBuffer *buffer; 1346 * buffer = gtk_entry_get_buffer (entry); 1347 * gtk_entry_buffer_set_max_length (buffer, max); 1348 * ]| 1349 * 1350 * Params: 1351 * max = the maximum length of the entry, or 0 for no maximum. 1352 * (other than the maximum length of entries.) The value passed in will 1353 * be clamped to the range 0-65536. 1354 */ 1355 public void setMaxLength(int max) 1356 { 1357 gtk_entry_set_max_length(gtkEntry, max); 1358 } 1359 1360 /** 1361 * Sets the desired maximum width in characters of @entry. 1362 * 1363 * Params: 1364 * nChars = the new desired maximum width, in characters 1365 * 1366 * Since: 3.12 1367 */ 1368 public void setMaxWidthChars(int nChars) 1369 { 1370 gtk_entry_set_max_width_chars(gtkEntry, nChars); 1371 } 1372 1373 /** 1374 * Sets whether the text is overwritten when typing in the #GtkEntry. 1375 * 1376 * Params: 1377 * overwrite = new value 1378 * 1379 * Since: 2.14 1380 */ 1381 public void setOverwriteMode(bool overwrite) 1382 { 1383 gtk_entry_set_overwrite_mode(gtkEntry, overwrite); 1384 } 1385 1386 /** 1387 * Sets text to be displayed in @entry when it is empty and unfocused. 1388 * This can be used to give a visual hint of the expected contents of 1389 * the #GtkEntry. 1390 * 1391 * Note that since the placeholder text gets removed when the entry 1392 * received focus, using this feature is a bit problematic if the entry 1393 * is given the initial focus in a window. Sometimes this can be 1394 * worked around by delaying the initial focus setting until the 1395 * first key event arrives. 1396 * 1397 * Params: 1398 * text = a string to be displayed when @entry is empty and unfocused, or %NULL 1399 * 1400 * Since: 3.2 1401 */ 1402 public void setPlaceholderText(string text) 1403 { 1404 gtk_entry_set_placeholder_text(gtkEntry, Str.toStringz(text)); 1405 } 1406 1407 /** 1408 * Causes the entry’s progress indicator to “fill in” the given 1409 * fraction of the bar. The fraction should be between 0.0 and 1.0, 1410 * inclusive. 1411 * 1412 * Params: 1413 * fraction = fraction of the task that’s been completed 1414 * 1415 * Since: 2.16 1416 */ 1417 public void setProgressFraction(double fraction) 1418 { 1419 gtk_entry_set_progress_fraction(gtkEntry, fraction); 1420 } 1421 1422 /** 1423 * Sets the fraction of total entry width to move the progress 1424 * bouncing block for each call to gtk_entry_progress_pulse(). 1425 * 1426 * Params: 1427 * fraction = fraction between 0.0 and 1.0 1428 * 1429 * Since: 2.16 1430 */ 1431 public void setProgressPulseStep(double fraction) 1432 { 1433 gtk_entry_set_progress_pulse_step(gtkEntry, fraction); 1434 } 1435 1436 /** 1437 * Sets a #PangoTabArray; the tabstops in the array are applied to the entry 1438 * text. 1439 * 1440 * Params: 1441 * tabs = a #PangoTabArray 1442 * 1443 * Since: 3.10 1444 */ 1445 public void setTabs(PgTabArray tabs) 1446 { 1447 gtk_entry_set_tabs(gtkEntry, (tabs is null) ? null : tabs.getPgTabArrayStruct()); 1448 } 1449 1450 /** 1451 * Sets the text in the widget to the given 1452 * value, replacing the current contents. 1453 * 1454 * See gtk_entry_buffer_set_text(). 1455 * 1456 * Params: 1457 * text = the new text 1458 */ 1459 public void setText(string text) 1460 { 1461 gtk_entry_set_text(gtkEntry, Str.toStringz(text)); 1462 } 1463 1464 /** 1465 * Sets whether the contents of the entry are visible or not. 1466 * When visibility is set to %FALSE, characters are displayed 1467 * as the invisible char, and will also appear that way when 1468 * the text in the entry widget is copied elsewhere. 1469 * 1470 * By default, GTK+ picks the best invisible character available 1471 * in the current font, but it can be changed with 1472 * gtk_entry_set_invisible_char(). 1473 * 1474 * Note that you probably want to set #GtkEntry:input-purpose 1475 * to %GTK_INPUT_PURPOSE_PASSWORD or %GTK_INPUT_PURPOSE_PIN to 1476 * inform input methods about the purpose of this entry, 1477 * in addition to setting visibility to %FALSE. 1478 * 1479 * Params: 1480 * visible = %TRUE if the contents of the entry are displayed 1481 * as plaintext 1482 */ 1483 public void setVisibility(bool visible) 1484 { 1485 gtk_entry_set_visibility(gtkEntry, visible); 1486 } 1487 1488 /** 1489 * Changes the size request of the entry to be about the right size 1490 * for @n_chars characters. Note that it changes the size 1491 * request, the size can still be affected by 1492 * how you pack the widget into containers. If @n_chars is -1, the 1493 * size reverts to the default entry size. 1494 * 1495 * Params: 1496 * nChars = width in chars 1497 */ 1498 public void setWidthChars(int nChars) 1499 { 1500 gtk_entry_set_width_chars(gtkEntry, nChars); 1501 } 1502 1503 /** 1504 * Converts from a position in the entry contents (returned 1505 * by gtk_entry_get_text()) to a position in the 1506 * entry’s #PangoLayout (returned by gtk_entry_get_layout(), 1507 * with text retrieved via pango_layout_get_text()). 1508 * 1509 * Params: 1510 * textIndex = byte index into the entry contents 1511 * 1512 * Returns: byte index into the entry layout text 1513 */ 1514 public int textIndexToLayoutIndex(int textIndex) 1515 { 1516 return gtk_entry_text_index_to_layout_index(gtkEntry, textIndex); 1517 } 1518 1519 /** 1520 * Unsets the invisible char previously set with 1521 * gtk_entry_set_invisible_char(). So that the 1522 * default invisible char is used again. 1523 * 1524 * Since: 2.16 1525 */ 1526 public void unsetInvisibleChar() 1527 { 1528 gtk_entry_unset_invisible_char(gtkEntry); 1529 } 1530 1531 protected class OnActivateDelegateWrapper 1532 { 1533 void delegate(Entry) dlg; 1534 gulong handlerId; 1535 1536 this(void delegate(Entry) dlg) 1537 { 1538 this.dlg = dlg; 1539 onActivateListeners ~= this; 1540 } 1541 1542 void remove(OnActivateDelegateWrapper source) 1543 { 1544 foreach(index, wrapper; onActivateListeners) 1545 { 1546 if (wrapper.handlerId == source.handlerId) 1547 { 1548 onActivateListeners[index] = null; 1549 onActivateListeners = std.algorithm.remove(onActivateListeners, index); 1550 break; 1551 } 1552 } 1553 } 1554 } 1555 OnActivateDelegateWrapper[] onActivateListeners; 1556 1557 /** 1558 * The ::activate signal is emitted when the user hits 1559 * the Enter key. 1560 * 1561 * While this signal is used as a 1562 * [keybinding signal][GtkBindingSignal], 1563 * it is also commonly used by applications to intercept 1564 * activation of entries. 1565 * 1566 * The default bindings for this signal are all forms of the Enter key. 1567 */ 1568 gulong addOnActivate(void delegate(Entry) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1569 { 1570 auto wrapper = new OnActivateDelegateWrapper(dlg); 1571 wrapper.handlerId = Signals.connectData( 1572 this, 1573 "activate", 1574 cast(GCallback)&callBackActivate, 1575 cast(void*)wrapper, 1576 cast(GClosureNotify)&callBackActivateDestroy, 1577 connectFlags); 1578 return wrapper.handlerId; 1579 } 1580 1581 extern(C) static void callBackActivate(GtkEntry* entryStruct, OnActivateDelegateWrapper wrapper) 1582 { 1583 wrapper.dlg(wrapper.outer); 1584 } 1585 1586 extern(C) static void callBackActivateDestroy(OnActivateDelegateWrapper wrapper, GClosure* closure) 1587 { 1588 wrapper.remove(wrapper); 1589 } 1590 1591 protected class OnBackspaceDelegateWrapper 1592 { 1593 void delegate(Entry) dlg; 1594 gulong handlerId; 1595 1596 this(void delegate(Entry) dlg) 1597 { 1598 this.dlg = dlg; 1599 onBackspaceListeners ~= this; 1600 } 1601 1602 void remove(OnBackspaceDelegateWrapper source) 1603 { 1604 foreach(index, wrapper; onBackspaceListeners) 1605 { 1606 if (wrapper.handlerId == source.handlerId) 1607 { 1608 onBackspaceListeners[index] = null; 1609 onBackspaceListeners = std.algorithm.remove(onBackspaceListeners, index); 1610 break; 1611 } 1612 } 1613 } 1614 } 1615 OnBackspaceDelegateWrapper[] onBackspaceListeners; 1616 1617 /** 1618 * The ::backspace signal is a 1619 * [keybinding signal][GtkBindingSignal] 1620 * which gets emitted when the user asks for it. 1621 * 1622 * The default bindings for this signal are 1623 * Backspace and Shift-Backspace. 1624 */ 1625 gulong addOnBackspace(void delegate(Entry) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1626 { 1627 auto wrapper = new OnBackspaceDelegateWrapper(dlg); 1628 wrapper.handlerId = Signals.connectData( 1629 this, 1630 "backspace", 1631 cast(GCallback)&callBackBackspace, 1632 cast(void*)wrapper, 1633 cast(GClosureNotify)&callBackBackspaceDestroy, 1634 connectFlags); 1635 return wrapper.handlerId; 1636 } 1637 1638 extern(C) static void callBackBackspace(GtkEntry* entryStruct, OnBackspaceDelegateWrapper wrapper) 1639 { 1640 wrapper.dlg(wrapper.outer); 1641 } 1642 1643 extern(C) static void callBackBackspaceDestroy(OnBackspaceDelegateWrapper wrapper, GClosure* closure) 1644 { 1645 wrapper.remove(wrapper); 1646 } 1647 1648 protected class OnCopyClipboardDelegateWrapper 1649 { 1650 void delegate(Entry) dlg; 1651 gulong handlerId; 1652 1653 this(void delegate(Entry) dlg) 1654 { 1655 this.dlg = dlg; 1656 onCopyClipboardListeners ~= this; 1657 } 1658 1659 void remove(OnCopyClipboardDelegateWrapper source) 1660 { 1661 foreach(index, wrapper; onCopyClipboardListeners) 1662 { 1663 if (wrapper.handlerId == source.handlerId) 1664 { 1665 onCopyClipboardListeners[index] = null; 1666 onCopyClipboardListeners = std.algorithm.remove(onCopyClipboardListeners, index); 1667 break; 1668 } 1669 } 1670 } 1671 } 1672 OnCopyClipboardDelegateWrapper[] onCopyClipboardListeners; 1673 1674 /** 1675 * The ::copy-clipboard signal is a 1676 * [keybinding signal][GtkBindingSignal] 1677 * which gets emitted to copy the selection to the clipboard. 1678 * 1679 * The default bindings for this signal are 1680 * Ctrl-c and Ctrl-Insert. 1681 */ 1682 gulong addOnCopyClipboard(void delegate(Entry) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1683 { 1684 auto wrapper = new OnCopyClipboardDelegateWrapper(dlg); 1685 wrapper.handlerId = Signals.connectData( 1686 this, 1687 "copy-clipboard", 1688 cast(GCallback)&callBackCopyClipboard, 1689 cast(void*)wrapper, 1690 cast(GClosureNotify)&callBackCopyClipboardDestroy, 1691 connectFlags); 1692 return wrapper.handlerId; 1693 } 1694 1695 extern(C) static void callBackCopyClipboard(GtkEntry* entryStruct, OnCopyClipboardDelegateWrapper wrapper) 1696 { 1697 wrapper.dlg(wrapper.outer); 1698 } 1699 1700 extern(C) static void callBackCopyClipboardDestroy(OnCopyClipboardDelegateWrapper wrapper, GClosure* closure) 1701 { 1702 wrapper.remove(wrapper); 1703 } 1704 1705 protected class OnCutClipboardDelegateWrapper 1706 { 1707 void delegate(Entry) dlg; 1708 gulong handlerId; 1709 1710 this(void delegate(Entry) dlg) 1711 { 1712 this.dlg = dlg; 1713 onCutClipboardListeners ~= this; 1714 } 1715 1716 void remove(OnCutClipboardDelegateWrapper source) 1717 { 1718 foreach(index, wrapper; onCutClipboardListeners) 1719 { 1720 if (wrapper.handlerId == source.handlerId) 1721 { 1722 onCutClipboardListeners[index] = null; 1723 onCutClipboardListeners = std.algorithm.remove(onCutClipboardListeners, index); 1724 break; 1725 } 1726 } 1727 } 1728 } 1729 OnCutClipboardDelegateWrapper[] onCutClipboardListeners; 1730 1731 /** 1732 * The ::cut-clipboard signal is a 1733 * [keybinding signal][GtkBindingSignal] 1734 * which gets emitted to cut the selection to the clipboard. 1735 * 1736 * The default bindings for this signal are 1737 * Ctrl-x and Shift-Delete. 1738 */ 1739 gulong addOnCutClipboard(void delegate(Entry) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1740 { 1741 auto wrapper = new OnCutClipboardDelegateWrapper(dlg); 1742 wrapper.handlerId = Signals.connectData( 1743 this, 1744 "cut-clipboard", 1745 cast(GCallback)&callBackCutClipboard, 1746 cast(void*)wrapper, 1747 cast(GClosureNotify)&callBackCutClipboardDestroy, 1748 connectFlags); 1749 return wrapper.handlerId; 1750 } 1751 1752 extern(C) static void callBackCutClipboard(GtkEntry* entryStruct, OnCutClipboardDelegateWrapper wrapper) 1753 { 1754 wrapper.dlg(wrapper.outer); 1755 } 1756 1757 extern(C) static void callBackCutClipboardDestroy(OnCutClipboardDelegateWrapper wrapper, GClosure* closure) 1758 { 1759 wrapper.remove(wrapper); 1760 } 1761 1762 protected class OnDeleteFromCursorDelegateWrapper 1763 { 1764 void delegate(GtkDeleteType, int, Entry) dlg; 1765 gulong handlerId; 1766 1767 this(void delegate(GtkDeleteType, int, Entry) dlg) 1768 { 1769 this.dlg = dlg; 1770 onDeleteFromCursorListeners ~= this; 1771 } 1772 1773 void remove(OnDeleteFromCursorDelegateWrapper source) 1774 { 1775 foreach(index, wrapper; onDeleteFromCursorListeners) 1776 { 1777 if (wrapper.handlerId == source.handlerId) 1778 { 1779 onDeleteFromCursorListeners[index] = null; 1780 onDeleteFromCursorListeners = std.algorithm.remove(onDeleteFromCursorListeners, index); 1781 break; 1782 } 1783 } 1784 } 1785 } 1786 OnDeleteFromCursorDelegateWrapper[] onDeleteFromCursorListeners; 1787 1788 /** 1789 * The ::delete-from-cursor signal is a 1790 * [keybinding signal][GtkBindingSignal] 1791 * which gets emitted when the user initiates a text deletion. 1792 * 1793 * If the @type is %GTK_DELETE_CHARS, GTK+ deletes the selection 1794 * if there is one, otherwise it deletes the requested number 1795 * of characters. 1796 * 1797 * The default bindings for this signal are 1798 * Delete for deleting a character and Ctrl-Delete for 1799 * deleting a word. 1800 * 1801 * Params: 1802 * type = the granularity of the deletion, as a #GtkDeleteType 1803 * count = the number of @type units to delete 1804 */ 1805 gulong addOnDeleteFromCursor(void delegate(GtkDeleteType, int, Entry) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1806 { 1807 auto wrapper = new OnDeleteFromCursorDelegateWrapper(dlg); 1808 wrapper.handlerId = Signals.connectData( 1809 this, 1810 "delete-from-cursor", 1811 cast(GCallback)&callBackDeleteFromCursor, 1812 cast(void*)wrapper, 1813 cast(GClosureNotify)&callBackDeleteFromCursorDestroy, 1814 connectFlags); 1815 return wrapper.handlerId; 1816 } 1817 1818 extern(C) static void callBackDeleteFromCursor(GtkEntry* entryStruct, GtkDeleteType type, int count, OnDeleteFromCursorDelegateWrapper wrapper) 1819 { 1820 wrapper.dlg(type, count, wrapper.outer); 1821 } 1822 1823 extern(C) static void callBackDeleteFromCursorDestroy(OnDeleteFromCursorDelegateWrapper wrapper, GClosure* closure) 1824 { 1825 wrapper.remove(wrapper); 1826 } 1827 1828 protected class OnIconPressDelegateWrapper 1829 { 1830 void delegate(GtkEntryIconPosition, GdkEventButton*, Entry) dlg; 1831 gulong handlerId; 1832 1833 this(void delegate(GtkEntryIconPosition, GdkEventButton*, Entry) dlg) 1834 { 1835 this.dlg = dlg; 1836 onIconPressListeners ~= this; 1837 } 1838 1839 void remove(OnIconPressDelegateWrapper source) 1840 { 1841 foreach(index, wrapper; onIconPressListeners) 1842 { 1843 if (wrapper.handlerId == source.handlerId) 1844 { 1845 onIconPressListeners[index] = null; 1846 onIconPressListeners = std.algorithm.remove(onIconPressListeners, index); 1847 break; 1848 } 1849 } 1850 } 1851 } 1852 OnIconPressDelegateWrapper[] onIconPressListeners; 1853 1854 /** 1855 * The ::icon-press signal is emitted when an activatable icon 1856 * is clicked. 1857 * 1858 * Params: 1859 * iconPos = The position of the clicked icon 1860 * event = the button press event 1861 * 1862 * Since: 2.16 1863 */ 1864 gulong addOnIconPress(void delegate(GtkEntryIconPosition, GdkEventButton*, Entry) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1865 { 1866 auto wrapper = new OnIconPressDelegateWrapper(dlg); 1867 wrapper.handlerId = Signals.connectData( 1868 this, 1869 "icon-press", 1870 cast(GCallback)&callBackIconPress, 1871 cast(void*)wrapper, 1872 cast(GClosureNotify)&callBackIconPressDestroy, 1873 connectFlags); 1874 return wrapper.handlerId; 1875 } 1876 1877 extern(C) static void callBackIconPress(GtkEntry* entryStruct, GtkEntryIconPosition iconPos, GdkEventButton* event, OnIconPressDelegateWrapper wrapper) 1878 { 1879 wrapper.dlg(iconPos, event, wrapper.outer); 1880 } 1881 1882 extern(C) static void callBackIconPressDestroy(OnIconPressDelegateWrapper wrapper, GClosure* closure) 1883 { 1884 wrapper.remove(wrapper); 1885 } 1886 1887 protected class OnIconPressGenericDelegateWrapper 1888 { 1889 void delegate(GtkEntryIconPosition, Event, Entry) dlg; 1890 gulong handlerId; 1891 1892 this(void delegate(GtkEntryIconPosition, Event, Entry) dlg) 1893 { 1894 this.dlg = dlg; 1895 onIconPressGenericListeners ~= this; 1896 } 1897 1898 void remove(OnIconPressGenericDelegateWrapper source) 1899 { 1900 foreach(index, wrapper; onIconPressGenericListeners) 1901 { 1902 if (wrapper.handlerId == source.handlerId) 1903 { 1904 onIconPressGenericListeners[index] = null; 1905 onIconPressGenericListeners = std.algorithm.remove(onIconPressGenericListeners, index); 1906 break; 1907 } 1908 } 1909 } 1910 } 1911 OnIconPressGenericDelegateWrapper[] onIconPressGenericListeners; 1912 1913 /** 1914 * The ::icon-press signal is emitted when an activatable icon 1915 * is clicked. 1916 * 1917 * Params: 1918 * iconPos = The position of the clicked icon 1919 * event = the button press event 1920 * 1921 * Since: 2.16 1922 */ 1923 gulong addOnIconPress(void delegate(GtkEntryIconPosition, Event, Entry) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1924 { 1925 auto wrapper = new OnIconPressGenericDelegateWrapper(dlg); 1926 wrapper.handlerId = Signals.connectData( 1927 this, 1928 "icon-press", 1929 cast(GCallback)&callBackIconPressGeneric, 1930 cast(void*)wrapper, 1931 cast(GClosureNotify)&callBackIconPressGenericDestroy, 1932 connectFlags); 1933 return wrapper.handlerId; 1934 } 1935 1936 extern(C) static void callBackIconPressGeneric(GtkEntry* entryStruct, GtkEntryIconPosition iconPos, GdkEvent* event, OnIconPressGenericDelegateWrapper wrapper) 1937 { 1938 wrapper.dlg(iconPos, ObjectG.getDObject!(Event)(event), wrapper.outer); 1939 } 1940 1941 extern(C) static void callBackIconPressGenericDestroy(OnIconPressGenericDelegateWrapper wrapper, GClosure* closure) 1942 { 1943 wrapper.remove(wrapper); 1944 } 1945 1946 protected class OnIconReleaseDelegateWrapper 1947 { 1948 void delegate(GtkEntryIconPosition, GdkEventButton*, Entry) dlg; 1949 gulong handlerId; 1950 1951 this(void delegate(GtkEntryIconPosition, GdkEventButton*, Entry) dlg) 1952 { 1953 this.dlg = dlg; 1954 onIconReleaseListeners ~= this; 1955 } 1956 1957 void remove(OnIconReleaseDelegateWrapper source) 1958 { 1959 foreach(index, wrapper; onIconReleaseListeners) 1960 { 1961 if (wrapper.handlerId == source.handlerId) 1962 { 1963 onIconReleaseListeners[index] = null; 1964 onIconReleaseListeners = std.algorithm.remove(onIconReleaseListeners, index); 1965 break; 1966 } 1967 } 1968 } 1969 } 1970 OnIconReleaseDelegateWrapper[] onIconReleaseListeners; 1971 1972 /** 1973 * The ::icon-release signal is emitted on the button release from a 1974 * mouse click over an activatable icon. 1975 * 1976 * Params: 1977 * iconPos = The position of the clicked icon 1978 * event = the button release event 1979 * 1980 * Since: 2.16 1981 */ 1982 gulong addOnIconRelease(void delegate(GtkEntryIconPosition, GdkEventButton*, Entry) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1983 { 1984 auto wrapper = new OnIconReleaseDelegateWrapper(dlg); 1985 wrapper.handlerId = Signals.connectData( 1986 this, 1987 "icon-release", 1988 cast(GCallback)&callBackIconRelease, 1989 cast(void*)wrapper, 1990 cast(GClosureNotify)&callBackIconReleaseDestroy, 1991 connectFlags); 1992 return wrapper.handlerId; 1993 } 1994 1995 extern(C) static void callBackIconRelease(GtkEntry* entryStruct, GtkEntryIconPosition iconPos, GdkEventButton* event, OnIconReleaseDelegateWrapper wrapper) 1996 { 1997 wrapper.dlg(iconPos, event, wrapper.outer); 1998 } 1999 2000 extern(C) static void callBackIconReleaseDestroy(OnIconReleaseDelegateWrapper wrapper, GClosure* closure) 2001 { 2002 wrapper.remove(wrapper); 2003 } 2004 2005 protected class OnIconReleaseGenericDelegateWrapper 2006 { 2007 void delegate(GtkEntryIconPosition, Event, Entry) dlg; 2008 gulong handlerId; 2009 2010 this(void delegate(GtkEntryIconPosition, Event, Entry) dlg) 2011 { 2012 this.dlg = dlg; 2013 onIconReleaseGenericListeners ~= this; 2014 } 2015 2016 void remove(OnIconReleaseGenericDelegateWrapper source) 2017 { 2018 foreach(index, wrapper; onIconReleaseGenericListeners) 2019 { 2020 if (wrapper.handlerId == source.handlerId) 2021 { 2022 onIconReleaseGenericListeners[index] = null; 2023 onIconReleaseGenericListeners = std.algorithm.remove(onIconReleaseGenericListeners, index); 2024 break; 2025 } 2026 } 2027 } 2028 } 2029 OnIconReleaseGenericDelegateWrapper[] onIconReleaseGenericListeners; 2030 2031 /** 2032 * The ::icon-release signal is emitted on the button release from a 2033 * mouse click over an activatable icon. 2034 * 2035 * Params: 2036 * iconPos = The position of the clicked icon 2037 * event = the button release event 2038 * 2039 * Since: 2.16 2040 */ 2041 gulong addOnIconRelease(void delegate(GtkEntryIconPosition, Event, Entry) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2042 { 2043 auto wrapper = new OnIconReleaseGenericDelegateWrapper(dlg); 2044 wrapper.handlerId = Signals.connectData( 2045 this, 2046 "icon-release", 2047 cast(GCallback)&callBackIconReleaseGeneric, 2048 cast(void*)wrapper, 2049 cast(GClosureNotify)&callBackIconReleaseGenericDestroy, 2050 connectFlags); 2051 return wrapper.handlerId; 2052 } 2053 2054 extern(C) static void callBackIconReleaseGeneric(GtkEntry* entryStruct, GtkEntryIconPosition iconPos, GdkEvent* event, OnIconReleaseGenericDelegateWrapper wrapper) 2055 { 2056 wrapper.dlg(iconPos, ObjectG.getDObject!(Event)(event), wrapper.outer); 2057 } 2058 2059 extern(C) static void callBackIconReleaseGenericDestroy(OnIconReleaseGenericDelegateWrapper wrapper, GClosure* closure) 2060 { 2061 wrapper.remove(wrapper); 2062 } 2063 2064 protected class OnInsertAtCursorDelegateWrapper 2065 { 2066 void delegate(string, Entry) dlg; 2067 gulong handlerId; 2068 2069 this(void delegate(string, Entry) dlg) 2070 { 2071 this.dlg = dlg; 2072 onInsertAtCursorListeners ~= this; 2073 } 2074 2075 void remove(OnInsertAtCursorDelegateWrapper source) 2076 { 2077 foreach(index, wrapper; onInsertAtCursorListeners) 2078 { 2079 if (wrapper.handlerId == source.handlerId) 2080 { 2081 onInsertAtCursorListeners[index] = null; 2082 onInsertAtCursorListeners = std.algorithm.remove(onInsertAtCursorListeners, index); 2083 break; 2084 } 2085 } 2086 } 2087 } 2088 OnInsertAtCursorDelegateWrapper[] onInsertAtCursorListeners; 2089 2090 /** 2091 * The ::insert-at-cursor signal is a 2092 * [keybinding signal][GtkBindingSignal] 2093 * which gets emitted when the user initiates the insertion of a 2094 * fixed string at the cursor. 2095 * 2096 * This signal has no default bindings. 2097 * 2098 * Params: 2099 * str = the string to insert 2100 */ 2101 gulong addOnInsertAtCursor(void delegate(string, Entry) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2102 { 2103 auto wrapper = new OnInsertAtCursorDelegateWrapper(dlg); 2104 wrapper.handlerId = Signals.connectData( 2105 this, 2106 "insert-at-cursor", 2107 cast(GCallback)&callBackInsertAtCursor, 2108 cast(void*)wrapper, 2109 cast(GClosureNotify)&callBackInsertAtCursorDestroy, 2110 connectFlags); 2111 return wrapper.handlerId; 2112 } 2113 2114 extern(C) static void callBackInsertAtCursor(GtkEntry* entryStruct, char* str, OnInsertAtCursorDelegateWrapper wrapper) 2115 { 2116 wrapper.dlg(Str.toString(str), wrapper.outer); 2117 } 2118 2119 extern(C) static void callBackInsertAtCursorDestroy(OnInsertAtCursorDelegateWrapper wrapper, GClosure* closure) 2120 { 2121 wrapper.remove(wrapper); 2122 } 2123 2124 protected class OnMoveCursorDelegateWrapper 2125 { 2126 void delegate(GtkMovementStep, int, bool, Entry) dlg; 2127 gulong handlerId; 2128 2129 this(void delegate(GtkMovementStep, int, bool, Entry) dlg) 2130 { 2131 this.dlg = dlg; 2132 onMoveCursorListeners ~= this; 2133 } 2134 2135 void remove(OnMoveCursorDelegateWrapper source) 2136 { 2137 foreach(index, wrapper; onMoveCursorListeners) 2138 { 2139 if (wrapper.handlerId == source.handlerId) 2140 { 2141 onMoveCursorListeners[index] = null; 2142 onMoveCursorListeners = std.algorithm.remove(onMoveCursorListeners, index); 2143 break; 2144 } 2145 } 2146 } 2147 } 2148 OnMoveCursorDelegateWrapper[] onMoveCursorListeners; 2149 2150 /** 2151 * The ::move-cursor signal is a 2152 * [keybinding signal][GtkBindingSignal] 2153 * which gets emitted when the user initiates a cursor movement. 2154 * If the cursor is not visible in @entry, this signal causes 2155 * the viewport to be moved instead. 2156 * 2157 * Applications should not connect to it, but may emit it with 2158 * g_signal_emit_by_name() if they need to control the cursor 2159 * programmatically. 2160 * 2161 * The default bindings for this signal come in two variants, 2162 * the variant with the Shift modifier extends the selection, 2163 * the variant without the Shift modifer does not. 2164 * There are too many key combinations to list them all here. 2165 * - Arrow keys move by individual characters/lines 2166 * - Ctrl-arrow key combinations move by words/paragraphs 2167 * - Home/End keys move to the ends of the buffer 2168 * 2169 * Params: 2170 * step = the granularity of the move, as a #GtkMovementStep 2171 * count = the number of @step units to move 2172 * extendSelection = %TRUE if the move should extend the selection 2173 */ 2174 gulong addOnMoveCursor(void delegate(GtkMovementStep, int, bool, Entry) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2175 { 2176 auto wrapper = new OnMoveCursorDelegateWrapper(dlg); 2177 wrapper.handlerId = Signals.connectData( 2178 this, 2179 "move-cursor", 2180 cast(GCallback)&callBackMoveCursor, 2181 cast(void*)wrapper, 2182 cast(GClosureNotify)&callBackMoveCursorDestroy, 2183 connectFlags); 2184 return wrapper.handlerId; 2185 } 2186 2187 extern(C) static void callBackMoveCursor(GtkEntry* entryStruct, GtkMovementStep step, int count, bool extendSelection, OnMoveCursorDelegateWrapper wrapper) 2188 { 2189 wrapper.dlg(step, count, extendSelection, wrapper.outer); 2190 } 2191 2192 extern(C) static void callBackMoveCursorDestroy(OnMoveCursorDelegateWrapper wrapper, GClosure* closure) 2193 { 2194 wrapper.remove(wrapper); 2195 } 2196 2197 protected class OnPasteClipboardDelegateWrapper 2198 { 2199 void delegate(Entry) dlg; 2200 gulong handlerId; 2201 2202 this(void delegate(Entry) dlg) 2203 { 2204 this.dlg = dlg; 2205 onPasteClipboardListeners ~= this; 2206 } 2207 2208 void remove(OnPasteClipboardDelegateWrapper source) 2209 { 2210 foreach(index, wrapper; onPasteClipboardListeners) 2211 { 2212 if (wrapper.handlerId == source.handlerId) 2213 { 2214 onPasteClipboardListeners[index] = null; 2215 onPasteClipboardListeners = std.algorithm.remove(onPasteClipboardListeners, index); 2216 break; 2217 } 2218 } 2219 } 2220 } 2221 OnPasteClipboardDelegateWrapper[] onPasteClipboardListeners; 2222 2223 /** 2224 * The ::paste-clipboard signal is a 2225 * [keybinding signal][GtkBindingSignal] 2226 * which gets emitted to paste the contents of the clipboard 2227 * into the text view. 2228 * 2229 * The default bindings for this signal are 2230 * Ctrl-v and Shift-Insert. 2231 */ 2232 gulong addOnPasteClipboard(void delegate(Entry) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2233 { 2234 auto wrapper = new OnPasteClipboardDelegateWrapper(dlg); 2235 wrapper.handlerId = Signals.connectData( 2236 this, 2237 "paste-clipboard", 2238 cast(GCallback)&callBackPasteClipboard, 2239 cast(void*)wrapper, 2240 cast(GClosureNotify)&callBackPasteClipboardDestroy, 2241 connectFlags); 2242 return wrapper.handlerId; 2243 } 2244 2245 extern(C) static void callBackPasteClipboard(GtkEntry* entryStruct, OnPasteClipboardDelegateWrapper wrapper) 2246 { 2247 wrapper.dlg(wrapper.outer); 2248 } 2249 2250 extern(C) static void callBackPasteClipboardDestroy(OnPasteClipboardDelegateWrapper wrapper, GClosure* closure) 2251 { 2252 wrapper.remove(wrapper); 2253 } 2254 2255 protected class OnPopulatePopupDelegateWrapper 2256 { 2257 void delegate(Widget, Entry) dlg; 2258 gulong handlerId; 2259 2260 this(void delegate(Widget, Entry) dlg) 2261 { 2262 this.dlg = dlg; 2263 onPopulatePopupListeners ~= this; 2264 } 2265 2266 void remove(OnPopulatePopupDelegateWrapper source) 2267 { 2268 foreach(index, wrapper; onPopulatePopupListeners) 2269 { 2270 if (wrapper.handlerId == source.handlerId) 2271 { 2272 onPopulatePopupListeners[index] = null; 2273 onPopulatePopupListeners = std.algorithm.remove(onPopulatePopupListeners, index); 2274 break; 2275 } 2276 } 2277 } 2278 } 2279 OnPopulatePopupDelegateWrapper[] onPopulatePopupListeners; 2280 2281 /** 2282 * The ::populate-popup signal gets emitted before showing the 2283 * context menu of the entry. 2284 * 2285 * If you need to add items to the context menu, connect 2286 * to this signal and append your items to the @widget, which 2287 * will be a #GtkMenu in this case. 2288 * 2289 * If #GtkEntry:populate-all is %TRUE, this signal will 2290 * also be emitted to populate touch popups. In this case, 2291 * @widget will be a different container, e.g. a #GtkToolbar. 2292 * The signal handler should not make assumptions about the 2293 * type of @widget. 2294 * 2295 * Params: 2296 * widget = the container that is being populated 2297 */ 2298 gulong addOnPopulatePopup(void delegate(Widget, Entry) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2299 { 2300 auto wrapper = new OnPopulatePopupDelegateWrapper(dlg); 2301 wrapper.handlerId = Signals.connectData( 2302 this, 2303 "populate-popup", 2304 cast(GCallback)&callBackPopulatePopup, 2305 cast(void*)wrapper, 2306 cast(GClosureNotify)&callBackPopulatePopupDestroy, 2307 connectFlags); 2308 return wrapper.handlerId; 2309 } 2310 2311 extern(C) static void callBackPopulatePopup(GtkEntry* entryStruct, GtkWidget* widget, OnPopulatePopupDelegateWrapper wrapper) 2312 { 2313 wrapper.dlg(ObjectG.getDObject!(Widget)(widget), wrapper.outer); 2314 } 2315 2316 extern(C) static void callBackPopulatePopupDestroy(OnPopulatePopupDelegateWrapper wrapper, GClosure* closure) 2317 { 2318 wrapper.remove(wrapper); 2319 } 2320 2321 protected class OnPreeditChangedDelegateWrapper 2322 { 2323 void delegate(string, Entry) dlg; 2324 gulong handlerId; 2325 2326 this(void delegate(string, Entry) dlg) 2327 { 2328 this.dlg = dlg; 2329 onPreeditChangedListeners ~= this; 2330 } 2331 2332 void remove(OnPreeditChangedDelegateWrapper source) 2333 { 2334 foreach(index, wrapper; onPreeditChangedListeners) 2335 { 2336 if (wrapper.handlerId == source.handlerId) 2337 { 2338 onPreeditChangedListeners[index] = null; 2339 onPreeditChangedListeners = std.algorithm.remove(onPreeditChangedListeners, index); 2340 break; 2341 } 2342 } 2343 } 2344 } 2345 OnPreeditChangedDelegateWrapper[] onPreeditChangedListeners; 2346 2347 /** 2348 * If an input method is used, the typed text will not immediately 2349 * be committed to the buffer. So if you are interested in the text, 2350 * connect to this signal. 2351 * 2352 * Params: 2353 * preedit = the current preedit string 2354 * 2355 * Since: 2.20 2356 */ 2357 gulong addOnPreeditChanged(void delegate(string, Entry) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2358 { 2359 auto wrapper = new OnPreeditChangedDelegateWrapper(dlg); 2360 wrapper.handlerId = Signals.connectData( 2361 this, 2362 "preedit-changed", 2363 cast(GCallback)&callBackPreeditChanged, 2364 cast(void*)wrapper, 2365 cast(GClosureNotify)&callBackPreeditChangedDestroy, 2366 connectFlags); 2367 return wrapper.handlerId; 2368 } 2369 2370 extern(C) static void callBackPreeditChanged(GtkEntry* entryStruct, char* preedit, OnPreeditChangedDelegateWrapper wrapper) 2371 { 2372 wrapper.dlg(Str.toString(preedit), wrapper.outer); 2373 } 2374 2375 extern(C) static void callBackPreeditChangedDestroy(OnPreeditChangedDelegateWrapper wrapper, GClosure* closure) 2376 { 2377 wrapper.remove(wrapper); 2378 } 2379 2380 protected class OnToggleOverwriteDelegateWrapper 2381 { 2382 void delegate(Entry) dlg; 2383 gulong handlerId; 2384 2385 this(void delegate(Entry) dlg) 2386 { 2387 this.dlg = dlg; 2388 onToggleOverwriteListeners ~= this; 2389 } 2390 2391 void remove(OnToggleOverwriteDelegateWrapper source) 2392 { 2393 foreach(index, wrapper; onToggleOverwriteListeners) 2394 { 2395 if (wrapper.handlerId == source.handlerId) 2396 { 2397 onToggleOverwriteListeners[index] = null; 2398 onToggleOverwriteListeners = std.algorithm.remove(onToggleOverwriteListeners, index); 2399 break; 2400 } 2401 } 2402 } 2403 } 2404 OnToggleOverwriteDelegateWrapper[] onToggleOverwriteListeners; 2405 2406 /** 2407 * The ::toggle-overwrite signal is a 2408 * [keybinding signal][GtkBindingSignal] 2409 * which gets emitted to toggle the overwrite mode of the entry. 2410 * 2411 * The default bindings for this signal is Insert. 2412 */ 2413 gulong addOnToggleOverwrite(void delegate(Entry) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2414 { 2415 auto wrapper = new OnToggleOverwriteDelegateWrapper(dlg); 2416 wrapper.handlerId = Signals.connectData( 2417 this, 2418 "toggle-overwrite", 2419 cast(GCallback)&callBackToggleOverwrite, 2420 cast(void*)wrapper, 2421 cast(GClosureNotify)&callBackToggleOverwriteDestroy, 2422 connectFlags); 2423 return wrapper.handlerId; 2424 } 2425 2426 extern(C) static void callBackToggleOverwrite(GtkEntry* entryStruct, OnToggleOverwriteDelegateWrapper wrapper) 2427 { 2428 wrapper.dlg(wrapper.outer); 2429 } 2430 2431 extern(C) static void callBackToggleOverwriteDestroy(OnToggleOverwriteDelegateWrapper wrapper, GClosure* closure) 2432 { 2433 wrapper.remove(wrapper); 2434 } 2435 }