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