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