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.Widget; 26 27 private import atk.ImplementorIF; 28 private import atk.ImplementorT; 29 private import atk.ObjectAtk; 30 private import cairo.Context; 31 private import cairo.FontOption; 32 private import cairo.Region; 33 private import gdk.Color; 34 private import gdk.Cursor; 35 private import gdk.Device; 36 private import gdk.Display; 37 private import gdk.DragContext; 38 private import gdk.Event; 39 private import gdk.FrameClock; 40 private import gdk.RGBA; 41 private import gdk.Screen; 42 private import gdk.Visual; 43 private import gdk.Window : GdkWin = Window; 44 private import gdkpixbuf.Pixbuf; 45 private import gio.ActionGroupIF; 46 private import gio.IconIF; 47 private import glib.ConstructionException; 48 private import glib.ListG; 49 private import glib.MemorySlice; 50 private import glib.Str; 51 private import gobject.ObjectG; 52 private import gobject.ParamSpec; 53 private import gobject.Signals; 54 private import gobject.Type; 55 private import gobject.Value; 56 private import gtk.AccelGroup; 57 private import gtk.BuildableIF; 58 private import gtk.BuildableT; 59 private import gtk.Clipboard; 60 private import gtk.RcStyle; 61 private import gtk.Requisition; 62 private import gtk.SelectionData; 63 private import gtk.Settings; 64 private import gtk.Style; 65 private import gtk.StyleContext; 66 private import gtk.TargetEntry; 67 private import gtk.TargetList; 68 private import gtk.Tooltip; 69 private import gtk.WidgetPath; 70 private import gtk.Window; 71 private import gtk.c.functions; 72 public import gtk.c.types; 73 public import gtkc.gtktypes; 74 private import pango.PgContext; 75 private import pango.PgFontDescription; 76 private import pango.PgFontMap; 77 private import pango.PgLayout; 78 private import std.algorithm; 79 private import std.conv; 80 81 82 /** 83 * GtkWidget is the base class all widgets in GTK+ derive from. It manages the 84 * widget lifecycle, states and style. 85 * 86 * # Height-for-width Geometry Management # {#geometry-management} 87 * 88 * GTK+ uses a height-for-width (and width-for-height) geometry management 89 * system. Height-for-width means that a widget can change how much 90 * vertical space it needs, depending on the amount of horizontal space 91 * that it is given (and similar for width-for-height). The most common 92 * example is a label that reflows to fill up the available width, wraps 93 * to fewer lines, and therefore needs less height. 94 * 95 * Height-for-width geometry management is implemented in GTK+ by way 96 * of five virtual methods: 97 * 98 * - #GtkWidgetClass.get_request_mode() 99 * - #GtkWidgetClass.get_preferred_width() 100 * - #GtkWidgetClass.get_preferred_height() 101 * - #GtkWidgetClass.get_preferred_height_for_width() 102 * - #GtkWidgetClass.get_preferred_width_for_height() 103 * - #GtkWidgetClass.get_preferred_height_and_baseline_for_width() 104 * 105 * There are some important things to keep in mind when implementing 106 * height-for-width and when using it in container implementations. 107 * 108 * The geometry management system will query a widget hierarchy in 109 * only one orientation at a time. When widgets are initially queried 110 * for their minimum sizes it is generally done in two initial passes 111 * in the #GtkSizeRequestMode chosen by the toplevel. 112 * 113 * For example, when queried in the normal 114 * %GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH mode: 115 * First, the default minimum and natural width for each widget 116 * in the interface will be computed using gtk_widget_get_preferred_width(). 117 * Because the preferred widths for each container depend on the preferred 118 * widths of their children, this information propagates up the hierarchy, 119 * and finally a minimum and natural width is determined for the entire 120 * toplevel. Next, the toplevel will use the minimum width to query for the 121 * minimum height contextual to that width using 122 * gtk_widget_get_preferred_height_for_width(), which will also be a highly 123 * recursive operation. The minimum height for the minimum width is normally 124 * used to set the minimum size constraint on the toplevel 125 * (unless gtk_window_set_geometry_hints() is explicitly used instead). 126 * 127 * After the toplevel window has initially requested its size in both 128 * dimensions it can go on to allocate itself a reasonable size (or a size 129 * previously specified with gtk_window_set_default_size()). During the 130 * recursive allocation process it’s important to note that request cycles 131 * will be recursively executed while container widgets allocate their children. 132 * Each container widget, once allocated a size, will go on to first share the 133 * space in one orientation among its children and then request each child's 134 * height for its target allocated width or its width for allocated height, 135 * depending. In this way a #GtkWidget will typically be requested its size 136 * a number of times before actually being allocated a size. The size a 137 * widget is finally allocated can of course differ from the size it has 138 * requested. For this reason, #GtkWidget caches a small number of results 139 * to avoid re-querying for the same sizes in one allocation cycle. 140 * 141 * See 142 * [GtkContainer’s geometry management section][container-geometry-management] 143 * to learn more about how height-for-width allocations are performed 144 * by container widgets. 145 * 146 * If a widget does move content around to intelligently use up the 147 * allocated size then it must support the request in both 148 * #GtkSizeRequestModes even if the widget in question only 149 * trades sizes in a single orientation. 150 * 151 * For instance, a #GtkLabel that does height-for-width word wrapping 152 * will not expect to have #GtkWidgetClass.get_preferred_height() called 153 * because that call is specific to a width-for-height request. In this 154 * case the label must return the height required for its own minimum 155 * possible width. By following this rule any widget that handles 156 * height-for-width or width-for-height requests will always be allocated 157 * at least enough space to fit its own content. 158 * 159 * Here are some examples of how a %GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH widget 160 * generally deals with width-for-height requests, for #GtkWidgetClass.get_preferred_height() 161 * it will do: 162 * 163 * |[<!-- language="C" --> 164 * static void 165 * foo_widget_get_preferred_height (GtkWidget *widget, 166 * gint *min_height, 167 * gint *nat_height) 168 * { 169 * if (i_am_in_height_for_width_mode) 170 * { 171 * gint min_width, nat_width; 172 * 173 * GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, 174 * &min_width, 175 * &nat_width); 176 * GTK_WIDGET_GET_CLASS (widget)->get_preferred_height_for_width 177 * (widget, 178 * min_width, 179 * min_height, 180 * nat_height); 181 * } 182 * else 183 * { 184 * ... some widgets do both. For instance, if a GtkLabel is 185 * rotated to 90 degrees it will return the minimum and 186 * natural height for the rotated label here. 187 * } 188 * } 189 * ]| 190 * 191 * And in #GtkWidgetClass.get_preferred_width_for_height() it will simply return 192 * the minimum and natural width: 193 * |[<!-- language="C" --> 194 * static void 195 * foo_widget_get_preferred_width_for_height (GtkWidget *widget, 196 * gint for_height, 197 * gint *min_width, 198 * gint *nat_width) 199 * { 200 * if (i_am_in_height_for_width_mode) 201 * { 202 * GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, 203 * min_width, 204 * nat_width); 205 * } 206 * else 207 * { 208 * ... again if a widget is sometimes operating in 209 * width-for-height mode (like a rotated GtkLabel) it can go 210 * ahead and do its real width for height calculation here. 211 * } 212 * } 213 * ]| 214 * 215 * Often a widget needs to get its own request during size request or 216 * allocation. For example, when computing height it may need to also 217 * compute width. Or when deciding how to use an allocation, the widget 218 * may need to know its natural size. In these cases, the widget should 219 * be careful to call its virtual methods directly, like this: 220 * 221 * |[<!-- language="C" --> 222 * GTK_WIDGET_GET_CLASS(widget)->get_preferred_width (widget, 223 * &min, 224 * &natural); 225 * ]| 226 * 227 * It will not work to use the wrapper functions, such as 228 * gtk_widget_get_preferred_width() inside your own size request 229 * implementation. These return a request adjusted by #GtkSizeGroup 230 * and by the #GtkWidgetClass.adjust_size_request() virtual method. If a 231 * widget used the wrappers inside its virtual method implementations, 232 * then the adjustments (such as widget margins) would be applied 233 * twice. GTK+ therefore does not allow this and will warn if you try 234 * to do it. 235 * 236 * Of course if you are getting the size request for 237 * another widget, such as a child of a 238 * container, you must use the wrapper APIs. 239 * Otherwise, you would not properly consider widget margins, 240 * #GtkSizeGroup, and so forth. 241 * 242 * Since 3.10 GTK+ also supports baseline vertical alignment of widgets. This 243 * means that widgets are positioned such that the typographical baseline of 244 * widgets in the same row are aligned. This happens if a widget supports baselines, 245 * has a vertical alignment of %GTK_ALIGN_BASELINE, and is inside a container 246 * that supports baselines and has a natural “row” that it aligns to the baseline, 247 * or a baseline assigned to it by the grandparent. 248 * 249 * Baseline alignment support for a widget is done by the #GtkWidgetClass.get_preferred_height_and_baseline_for_width() 250 * virtual function. It allows you to report a baseline in combination with the 251 * minimum and natural height. If there is no baseline you can return -1 to indicate 252 * this. The default implementation of this virtual function calls into the 253 * #GtkWidgetClass.get_preferred_height() and #GtkWidgetClass.get_preferred_height_for_width(), 254 * so if baselines are not supported it doesn’t need to be implemented. 255 * 256 * If a widget ends up baseline aligned it will be allocated all the space in the parent 257 * as if it was %GTK_ALIGN_FILL, but the selected baseline can be found via gtk_widget_get_allocated_baseline(). 258 * If this has a value other than -1 you need to align the widget such that the baseline 259 * appears at the position. 260 * 261 * # Style Properties 262 * 263 * #GtkWidget introduces “style 264 * properties” - these are basically object properties that are stored 265 * not on the object, but in the style object associated to the widget. Style 266 * properties are set in [resource files][gtk3-Resource-Files]. 267 * This mechanism is used for configuring such things as the location of the 268 * scrollbar arrows through the theme, giving theme authors more control over the 269 * look of applications without the need to write a theme engine in C. 270 * 271 * Use gtk_widget_class_install_style_property() to install style properties for 272 * a widget class, gtk_widget_class_find_style_property() or 273 * gtk_widget_class_list_style_properties() to get information about existing 274 * style properties and gtk_widget_style_get_property(), gtk_widget_style_get() or 275 * gtk_widget_style_get_valist() to obtain the value of a style property. 276 * 277 * # GtkWidget as GtkBuildable 278 * 279 * The GtkWidget implementation of the GtkBuildable interface supports a 280 * custom <accelerator> element, which has attributes named ”key”, ”modifiers” 281 * and ”signal” and allows to specify accelerators. 282 * 283 * An example of a UI definition fragment specifying an accelerator: 284 * |[ 285 * <object class="GtkButton"> 286 * <accelerator key="q" modifiers="GDK_CONTROL_MASK" signal="clicked"/> 287 * </object> 288 * ]| 289 * 290 * In addition to accelerators, GtkWidget also support a custom <accessible> 291 * element, which supports actions and relations. Properties on the accessible 292 * implementation of an object can be set by accessing the internal child 293 * “accessible” of a #GtkWidget. 294 * 295 * An example of a UI definition fragment specifying an accessible: 296 * |[ 297 * <object class="GtkButton" id="label1"/> 298 * <property name="label">I am a Label for a Button</property> 299 * </object> 300 * <object class="GtkButton" id="button1"> 301 * <accessibility> 302 * <action action_name="click" translatable="yes">Click the button.</action> 303 * <relation target="label1" type="labelled-by"/> 304 * </accessibility> 305 * <child internal-child="accessible"> 306 * <object class="AtkObject" id="a11y-button1"> 307 * <property name="accessible-name">Clickable Button</property> 308 * </object> 309 * </child> 310 * </object> 311 * ]| 312 * 313 * Finally, GtkWidget allows style information such as style classes to 314 * be associated with widgets, using the custom <style> element: 315 * |[ 316 * <object class="GtkButton" id="button1"> 317 * <style> 318 * <class name="my-special-button-class"/> 319 * <class name="dark-button"/> 320 * </style> 321 * </object> 322 * ]| 323 * 324 * # Building composite widgets from template XML ## {#composite-templates} 325 * 326 * GtkWidget exposes some facilities to automate the procedure 327 * of creating composite widgets using #GtkBuilder interface description 328 * language. 329 * 330 * To create composite widgets with #GtkBuilder XML, one must associate 331 * the interface description with the widget class at class initialization 332 * time using gtk_widget_class_set_template(). 333 * 334 * The interface description semantics expected in composite template descriptions 335 * is slightly different from regular #GtkBuilder XML. 336 * 337 * Unlike regular interface descriptions, gtk_widget_class_set_template() will 338 * expect a <template> tag as a direct child of the toplevel <interface> 339 * tag. The <template> tag must specify the “class” attribute which must be 340 * the type name of the widget. Optionally, the “parent” attribute may be 341 * specified to specify the direct parent type of the widget type, this is 342 * ignored by the GtkBuilder but required for Glade to introspect what kind 343 * of properties and internal children exist for a given type when the actual 344 * type does not exist. 345 * 346 * The XML which is contained inside the <template> tag behaves as if it were 347 * added to the <object> tag defining @widget itself. You may set properties 348 * on @widget by inserting <property> tags into the <template> tag, and also 349 * add <child> tags to add children and extend @widget in the normal way you 350 * would with <object> tags. 351 * 352 * Additionally, <object> tags can also be added before and after the initial 353 * <template> tag in the normal way, allowing one to define auxiliary objects 354 * which might be referenced by other widgets declared as children of the 355 * <template> tag. 356 * 357 * An example of a GtkBuilder Template Definition: 358 * |[ 359 * <interface> 360 * <template class="FooWidget" parent="GtkBox"> 361 * <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property> 362 * <property name="spacing">4</property> 363 * <child> 364 * <object class="GtkButton" id="hello_button"> 365 * <property name="label">Hello World</property> 366 * <signal name="clicked" handler="hello_button_clicked" object="FooWidget" swapped="yes"/> 367 * </object> 368 * </child> 369 * <child> 370 * <object class="GtkButton" id="goodbye_button"> 371 * <property name="label">Goodbye World</property> 372 * </object> 373 * </child> 374 * </template> 375 * </interface> 376 * ]| 377 * 378 * Typically, you'll place the template fragment into a file that is 379 * bundled with your project, using #GResource. In order to load the 380 * template, you need to call gtk_widget_class_set_template_from_resource() 381 * from the class initialization of your #GtkWidget type: 382 * 383 * |[<!-- language="C" --> 384 * static void 385 * foo_widget_class_init (FooWidgetClass *klass) 386 * { 387 * // ... 388 * 389 * gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), 390 * "/com/example/ui/foowidget.ui"); 391 * } 392 * ]| 393 * 394 * You will also need to call gtk_widget_init_template() from the instance 395 * initialization function: 396 * 397 * |[<!-- language="C" --> 398 * static void 399 * foo_widget_init (FooWidget *self) 400 * { 401 * // ... 402 * gtk_widget_init_template (GTK_WIDGET (self)); 403 * } 404 * ]| 405 * 406 * You can access widgets defined in the template using the 407 * gtk_widget_get_template_child() function, but you will typically declare 408 * a pointer in the instance private data structure of your type using the same 409 * name as the widget in the template definition, and call 410 * gtk_widget_class_bind_template_child_private() with that name, e.g. 411 * 412 * |[<!-- language="C" --> 413 * typedef struct { 414 * GtkWidget *hello_button; 415 * GtkWidget *goodbye_button; 416 * } FooWidgetPrivate; 417 * 418 * G_DEFINE_TYPE_WITH_PRIVATE (FooWidget, foo_widget, GTK_TYPE_BOX) 419 * 420 * static void 421 * foo_widget_class_init (FooWidgetClass *klass) 422 * { 423 * // ... 424 * gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), 425 * "/com/example/ui/foowidget.ui"); 426 * gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), 427 * FooWidget, hello_button); 428 * gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), 429 * FooWidget, goodbye_button); 430 * } 431 * 432 * static void 433 * foo_widget_init (FooWidget *widget) 434 * { 435 * 436 * } 437 * ]| 438 * 439 * You can also use gtk_widget_class_bind_template_callback() to connect a signal 440 * callback defined in the template with a function visible in the scope of the 441 * class, e.g. 442 * 443 * |[<!-- language="C" --> 444 * // the signal handler has the instance and user data swapped 445 * // because of the swapped="yes" attribute in the template XML 446 * static void 447 * hello_button_clicked (FooWidget *self, 448 * GtkButton *button) 449 * { 450 * g_print ("Hello, world!\n"); 451 * } 452 * 453 * static void 454 * foo_widget_class_init (FooWidgetClass *klass) 455 * { 456 * // ... 457 * gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), 458 * "/com/example/ui/foowidget.ui"); 459 * gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (klass), hello_button_clicked); 460 * } 461 * ]| 462 */ 463 public class Widget : ObjectG, ImplementorIF, BuildableIF 464 { 465 /** the main Gtk struct */ 466 protected GtkWidget* gtkWidget; 467 468 /** Get the main Gtk struct */ 469 public GtkWidget* getWidgetStruct(bool transferOwnership = false) 470 { 471 if (transferOwnership) 472 ownedRef = false; 473 return gtkWidget; 474 } 475 476 /** the main Gtk struct as a void* */ 477 protected override void* getStruct() 478 { 479 return cast(void*)gtkWidget; 480 } 481 482 protected override void setStruct(GObject* obj) 483 { 484 gtkWidget = cast(GtkWidget*)obj; 485 super.setStruct(obj); 486 } 487 488 /** 489 * Sets our main struct and passes it to the parent class. 490 */ 491 public this (GtkWidget* gtkWidget, bool ownedRef = false) 492 { 493 this.gtkWidget = gtkWidget; 494 super(cast(GObject*)gtkWidget, ownedRef); 495 } 496 497 // add the Implementor capabilities 498 mixin ImplementorT!(GtkWidget); 499 500 // add the Buildable capabilities 501 mixin BuildableT!(GtkWidget); 502 503 public GtkWidgetClass* getWidgetClass() 504 { 505 return Type.getInstanceClass!(GtkWidgetClass)(this); 506 } 507 508 /** */ 509 public int getWidth() 510 { 511 int width; 512 gtk_widget_get_size_request(gtkWidget, &width, null); 513 return width; 514 } 515 516 /** */ 517 public int getHeight() 518 { 519 int height; 520 gtk_widget_get_size_request(gtkWidget, null, &height); 521 return height; 522 } 523 524 /** 525 * Sets the cursor. 526 * Params: 527 * cursor = the new cursor 528 * Bugs: the cursor changes to the parent widget also 529 */ 530 void setCursor(Cursor cursor) 531 { 532 getWindow().setCursor(cursor); 533 } 534 535 /** 536 * Resets the cursor. 537 * don't know if this is implemented by GTK+. Seems that it's not 538 * Bugs: does nothing 539 */ 540 public void resetCursor() 541 { 542 getWindow().setCursor(null); 543 } 544 545 /** 546 * Modifies the font for this widget. 547 * This just calls modifyFont(new PgFontDescription(PgFontDescription.fromString(family ~ " " ~ size))); 548 */ 549 public void modifyFont(string family, int size) 550 { 551 if ( size < 0 ) size = -size; // hack to workaround leds bug - TO BE REMOVED 552 553 modifyFont( 554 PgFontDescription.fromString( 555 family ~ " " ~ to!(string)(size) 556 ) 557 ); 558 } 559 560 /** */ 561 public bool onEvent(GdkEvent* event) 562 { 563 return getWidgetClass().event(getWidgetStruct(), event) == 0 ? false : true; 564 } 565 566 /** */ 567 public bool onButtonPressEvent(GdkEventButton* event) 568 { 569 return getWidgetClass().buttonPressEvent(getWidgetStruct(), event) == 0 ? false : true; 570 } 571 572 /** */ 573 public bool onButtonReleaseEvent(GdkEventButton* event) 574 { 575 return getWidgetClass().buttonReleaseEvent(getWidgetStruct(), event) == 0 ? false : true; 576 } 577 578 /** */ 579 public bool onScrollEvent(GdkEventScroll* event) 580 { 581 return getWidgetClass().scrollEvent(getWidgetStruct(), event) == 0 ? false : true; 582 } 583 584 /** */ 585 public bool onMotionNotifyEvent(GdkEventMotion* event) 586 { 587 return getWidgetClass().motionNotifyEvent(getWidgetStruct(), event) == 0 ? false : true; 588 } 589 590 /** */ 591 public bool onDeleteEvent(GdkEventAny* event) 592 { 593 return getWidgetClass().deleteEvent(getWidgetStruct(), event) == 0 ? false : true; 594 } 595 596 /** */ 597 public bool onDestroyEvent(GdkEventAny* event) 598 { 599 return getWidgetClass().destroyEvent(getWidgetStruct(), event) == 0 ? false : true; 600 } 601 602 /** */ 603 public bool onKeyPressEvent(GdkEventKey* event) 604 { 605 return getWidgetClass().keyPressEvent(getWidgetStruct(), event) == 0 ? false : true; 606 } 607 608 /** */ 609 public bool onKeyReleaseEvent(GdkEventKey* event) 610 { 611 return getWidgetClass().keyReleaseEvent(getWidgetStruct(), event) == 0 ? false : true; 612 } 613 614 /** */ 615 public bool onEnterNotifyEvent(GdkEventCrossing* event) 616 { 617 return getWidgetClass().enterNotifyEvent(getWidgetStruct(), event) == 0 ? false : true; 618 } 619 620 /** */ 621 public bool onLeaveNotifyEvent(GdkEventCrossing* event) 622 { 623 return getWidgetClass().leaveNotifyEvent(getWidgetStruct(), event) == 0 ? false : true; 624 } 625 626 /** */ 627 public bool onConfigureEvent(GdkEventConfigure* event) 628 { 629 return getWidgetClass().configureEvent(getWidgetStruct(), event) == 0 ? false : true; 630 } 631 632 /** */ 633 public bool onFocusInEvent(GdkEventFocus* event) 634 { 635 return getWidgetClass().focusInEvent(getWidgetStruct(), event) == 0 ? false : true; 636 } 637 638 /** */ 639 public bool onFocusOutEvent(GdkEventFocus* event) 640 { 641 return getWidgetClass().focusOutEvent(getWidgetStruct(), event) == 0 ? false : true; 642 } 643 644 /** */ 645 public bool onMapEvent(GdkEventAny* event) 646 { 647 return getWidgetClass().mapEvent(getWidgetStruct(), event) == 0 ? false : true; 648 } 649 650 /** */ 651 public bool onUnmapEvent(GdkEventAny* event) 652 { 653 return getWidgetClass().unmapEvent(getWidgetStruct(), event) == 0 ? false : true; 654 } 655 656 /** */ 657 public bool onPropertyNotifyEvent(GdkEventProperty* event) 658 { 659 return getWidgetClass().propertyNotifyEvent(getWidgetStruct(), event) == 0 ? false : true; 660 } 661 662 /** */ 663 public bool onSelectionClearEvent(GdkEventSelection* event) 664 { 665 return getWidgetClass().selectionClearEvent(getWidgetStruct(), event) == 0 ? false : true; 666 } 667 668 /** */ 669 public bool onSelectionRequestEvent(GdkEventSelection* event) 670 { 671 return getWidgetClass().selectionRequestEvent(getWidgetStruct(), event) == 0 ? false : true; 672 } 673 674 /** */ 675 public bool onSelectionNotifyEvent(GdkEventSelection* event) 676 { 677 return getWidgetClass().selectionNotifyEvent(getWidgetStruct(), event) == 0 ? false : true; 678 } 679 680 /** */ 681 public bool onProximityInEvent(GdkEventProximity* event) 682 { 683 return getWidgetClass().proximityInEvent(getWidgetStruct(), event) == 0 ? false : true; 684 } 685 686 /** */ 687 public bool onProximityOutEvent(GdkEventProximity* event) 688 { 689 return getWidgetClass().proximityOutEvent(getWidgetStruct(), event) == 0 ? false : true; 690 } 691 692 /** */ 693 public bool onVisibilityNotifyEvent(GdkEventVisibility* event) 694 { 695 return getWidgetClass().visibilityNotifyEvent(getWidgetStruct(), event) == 0 ? false : true; 696 } 697 698 /** */ 699 public bool onWindowStateEvent(GdkEventWindowState* event) 700 { 701 return getWidgetClass().windowStateEvent(getWidgetStruct(), event) == 0 ? false : true; 702 } 703 704 /** */ 705 public bool onDamageEvent(GdkEventExpose* event) 706 { 707 return getWidgetClass().damageEvent(getWidgetStruct(), event) == 0 ? false : true; 708 } 709 710 /** */ 711 public bool onGrabBrokenEvent(GdkEventGrabBroken* event) 712 { 713 return getWidgetClass().grabBrokenEvent(getWidgetStruct(), event) == 0 ? false : true; 714 } 715 716 /** 717 * Queues an animation frame update and adds a callback to be called 718 * before each frame. Until the tick callback is removed, it will be 719 * called frequently (usually at the frame rate of the output device 720 * or as quickly as the application can be repainted, whichever is 721 * slower). For this reason, is most suitable for handling graphics 722 * that change every frame or every few frames. The tick callback does 723 * not automatically imply a relayout or repaint. If you want a 724 * repaint or relayout, and aren't changing widget properties that 725 * would trigger that (for example, changing the text of a gtk.Label), 726 * then you will have to call queueResize() or queuDrawArea() yourself. 727 * 728 * gdk.FrameClock.FrameClock.getFrameTime() should generally be used for timing 729 * continuous animations and gdk.FrameTimings.FrameTimings.getPredictedPresentationPime() 730 * if you are trying to display isolated frames at particular times. 731 * 732 * This is a more convenient alternative to connecting directly to the 733 * "update" signal of GdkFrameClock, since you don't 734 * have to worry about when a GdkFrameClock is assigned to a widget. 735 * 736 * Params: 737 * callback = function to call for updating animations 738 */ 739 public void addTickCallback(bool delegate(Widget, FrameClock) callback) 740 { 741 tickCallbackListeners ~= callback; 742 static bool connected; 743 744 if ( connected ) 745 { 746 return; 747 } 748 749 addTickCallback(cast(GtkTickCallback)>kTickCallback, cast(void*)this, null); 750 connected = true; 751 } 752 bool delegate(Widget, FrameClock)[] tickCallbackListeners; 753 extern(C) static int gtkTickCallback(GtkWidget* widgetStruct, GdkFrameClock* frameClock, Widget _widget) 754 { 755 foreach ( dlg ; _widget.tickCallbackListeners ) 756 { 757 if(dlg(_widget, new FrameClock(frameClock))) 758 return 1; 759 } 760 return 0; 761 } 762 763 protected class ScopedOnDrawDelegateWrapper 764 { 765 bool delegate(Scoped!Context, Widget) dlg; 766 gulong handlerId; 767 768 this(bool delegate(Scoped!Context, Widget) dlg) 769 { 770 this.dlg = dlg; 771 scopedOnDrawListeners ~= this; 772 } 773 774 void remove(ScopedOnDrawDelegateWrapper source) 775 { 776 foreach(index, wrapper; scopedOnDrawListeners) 777 { 778 if (wrapper.handlerId == source.handlerId) 779 { 780 scopedOnDrawListeners[index] = null; 781 scopedOnDrawListeners = std.algorithm.remove(scopedOnDrawListeners, index); 782 break; 783 } 784 } 785 } 786 } 787 ScopedOnDrawDelegateWrapper[] scopedOnDrawListeners; 788 789 /** 790 * This signal is emitted when a widget is supposed to render itself. 791 * The @widget's top left corner must be painted at the origin of 792 * the passed in context and be sized to the values returned by 793 * gtk_widget_get_allocated_width() and 794 * gtk_widget_get_allocated_height(). 795 * 796 * Signal handlers connected to this signal can modify the cairo 797 * context passed as @cr in any way they like and don't need to 798 * restore it. The signal emission takes care of calling cairo_save() 799 * before and cairo_restore() after invoking the handler. 800 * 801 * The signal handler will get a @cr with a clip region already set to the 802 * widget's dirty region, i.e. to the area that needs repainting. Complicated 803 * widgets that want to avoid redrawing themselves completely can get the full 804 * extents of the clip region with gdk_cairo_get_clip_rectangle(), or they can 805 * get a finer-grained representation of the dirty region with 806 * cairo_copy_clip_rectangle_list(). 807 * 808 * Params: 809 * cr = the cairo context to draw to 810 * 811 * Return: %TRUE to stop other handlers from being invoked for the event. 812 * %FALSE to propagate the event further. 813 * 814 * Since: 3.0 815 */ 816 gulong addOnDraw(bool delegate(Scoped!Context, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 817 { 818 auto wrapper = new ScopedOnDrawDelegateWrapper(dlg); 819 wrapper.handlerId = Signals.connectData( 820 this, 821 "draw", 822 cast(GCallback)&callBackScopedDraw, 823 cast(void*)wrapper, 824 cast(GClosureNotify)&callBackDrawScopedDestroy, 825 connectFlags); 826 return wrapper.handlerId; 827 } 828 829 extern(C) static int callBackScopedDraw(GtkWidget* widgetStruct, cairo_t* cr, ScopedOnDrawDelegateWrapper wrapper) 830 { 831 return wrapper.dlg(getScopedGobject!Context(cr), wrapper.outer); 832 } 833 834 extern(C) static void callBackDrawScopedDestroy(ScopedOnDrawDelegateWrapper wrapper, GClosure* closure) 835 { 836 wrapper.remove(wrapper); 837 } 838 839 protected class OnDrawDelegateWrapper 840 { 841 bool delegate(Context, Widget) dlg; 842 gulong handlerId; 843 844 this(bool delegate(Context, Widget) dlg) 845 { 846 this.dlg = dlg; 847 onDrawListeners ~= this; 848 } 849 850 void remove(OnDrawDelegateWrapper source) 851 { 852 foreach(index, wrapper; onDrawListeners) 853 { 854 if (wrapper.handlerId == source.handlerId) 855 { 856 onDrawListeners[index] = null; 857 onDrawListeners = std.algorithm.remove(onDrawListeners, index); 858 break; 859 } 860 } 861 } 862 } 863 OnDrawDelegateWrapper[] onDrawListeners; 864 865 /** 866 * This signal is emitted when a widget is supposed to render itself. 867 * The @widget's top left corner must be painted at the origin of 868 * the passed in context and be sized to the values returned by 869 * gtk_widget_get_allocated_width() and 870 * gtk_widget_get_allocated_height(). 871 * 872 * Signal handlers connected to this signal can modify the cairo 873 * context passed as @cr in any way they like and don't need to 874 * restore it. The signal emission takes care of calling cairo_save() 875 * before and cairo_restore() after invoking the handler. 876 * 877 * The signal handler will get a @cr with a clip region already set to the 878 * widget's dirty region, i.e. to the area that needs repainting. Complicated 879 * widgets that want to avoid redrawing themselves completely can get the full 880 * extents of the clip region with gdk_cairo_get_clip_rectangle(), or they can 881 * get a finer-grained representation of the dirty region with 882 * cairo_copy_clip_rectangle_list(). 883 * 884 * Params: 885 * cr = the cairo context to draw to 886 * 887 * Return: %TRUE to stop other handlers from being invoked for the event. 888 * %FALSE to propagate the event further. 889 * 890 * Since: 3.0 891 */ 892 deprecated gulong addOnDraw(bool delegate(Context, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 893 { 894 auto wrapper = new OnDrawDelegateWrapper(dlg); 895 wrapper.handlerId = Signals.connectData( 896 this, 897 "draw", 898 cast(GCallback)&callBackDraw, 899 cast(void*)wrapper, 900 cast(GClosureNotify)&callBackDrawDestroy, 901 connectFlags); 902 return wrapper.handlerId; 903 } 904 905 extern(C) static int callBackDraw(GtkWidget* widgetStruct, cairo_t* cr,OnDrawDelegateWrapper wrapper) 906 { 907 return wrapper.dlg(new Context(cr), wrapper.outer); 908 } 909 910 extern(C) static void callBackDrawDestroy(OnDrawDelegateWrapper wrapper, GClosure* closure) 911 { 912 wrapper.remove(wrapper); 913 } 914 915 /** 916 */ 917 918 /** */ 919 public static GType getType() 920 { 921 return gtk_widget_get_type(); 922 } 923 924 /** 925 * Obtains the current default reading direction. See 926 * gtk_widget_set_default_direction(). 927 * 928 * Returns: the current default direction. 929 */ 930 public static GtkTextDirection getDefaultDirection() 931 { 932 return gtk_widget_get_default_direction(); 933 } 934 935 /** 936 * Returns the default style used by all widgets initially. 937 * 938 * Deprecated: Use #GtkStyleContext instead, and 939 * gtk_css_provider_get_default() to obtain a #GtkStyleProvider 940 * with the default widget style information. 941 * 942 * Returns: the default style. This #GtkStyle 943 * object is owned by GTK+ and should not be modified or freed. 944 */ 945 public static Style getDefaultStyle() 946 { 947 auto p = gtk_widget_get_default_style(); 948 949 if(p is null) 950 { 951 return null; 952 } 953 954 return ObjectG.getDObject!(Style)(cast(GtkStyle*) p); 955 } 956 957 /** 958 * Cancels the effect of a previous call to gtk_widget_push_composite_child(). 959 * 960 * Deprecated: Use gtk_widget_class_set_template(), or don’t use this API at all. 961 */ 962 public static void popCompositeChild() 963 { 964 gtk_widget_pop_composite_child(); 965 } 966 967 /** 968 * Makes all newly-created widgets as composite children until 969 * the corresponding gtk_widget_pop_composite_child() call. 970 * 971 * A composite child is a child that’s an implementation detail of the 972 * container it’s inside and should not be visible to people using the 973 * container. Composite children aren’t treated differently by GTK+ (but 974 * see gtk_container_foreach() vs. gtk_container_forall()), but e.g. GUI 975 * builders might want to treat them in a different way. 976 * 977 * Deprecated: This API never really worked well and was mostly unused, now 978 * we have a more complete mechanism for composite children, see gtk_widget_class_set_template(). 979 */ 980 public static void pushCompositeChild() 981 { 982 gtk_widget_push_composite_child(); 983 } 984 985 /** 986 * Sets the default reading direction for widgets where the 987 * direction has not been explicitly set by gtk_widget_set_direction(). 988 * 989 * Params: 990 * dir = the new default direction. This cannot be 991 * %GTK_TEXT_DIR_NONE. 992 */ 993 public static void setDefaultDirection(GtkTextDirection dir) 994 { 995 gtk_widget_set_default_direction(dir); 996 } 997 998 /** 999 * For widgets that can be “activated” (buttons, menu items, etc.) 1000 * this function activates them. Activation is what happens when you 1001 * press Enter on a widget during key navigation. If @widget isn't 1002 * activatable, the function returns %FALSE. 1003 * 1004 * Returns: %TRUE if the widget was activatable 1005 */ 1006 public bool activate() 1007 { 1008 return gtk_widget_activate(gtkWidget) != 0; 1009 } 1010 1011 /** 1012 * Installs an accelerator for this @widget in @accel_group that causes 1013 * @accel_signal to be emitted if the accelerator is activated. 1014 * The @accel_group needs to be added to the widget’s toplevel via 1015 * gtk_window_add_accel_group(), and the signal must be of type %G_SIGNAL_ACTION. 1016 * Accelerators added through this function are not user changeable during 1017 * runtime. If you want to support accelerators that can be changed by the 1018 * user, use gtk_accel_map_add_entry() and gtk_widget_set_accel_path() or 1019 * gtk_menu_item_set_accel_path() instead. 1020 * 1021 * Params: 1022 * accelSignal = widget signal to emit on accelerator activation 1023 * accelGroup = accel group for this widget, added to its toplevel 1024 * accelKey = GDK keyval of the accelerator 1025 * accelMods = modifier key combination of the accelerator 1026 * accelFlags = flag accelerators, e.g. %GTK_ACCEL_VISIBLE 1027 */ 1028 public void addAccelerator(string accelSignal, AccelGroup accelGroup, uint accelKey, GdkModifierType accelMods, GtkAccelFlags accelFlags) 1029 { 1030 gtk_widget_add_accelerator(gtkWidget, Str.toStringz(accelSignal), (accelGroup is null) ? null : accelGroup.getAccelGroupStruct(), accelKey, accelMods, accelFlags); 1031 } 1032 1033 /** 1034 * Adds the device events in the bitfield @events to the event mask for 1035 * @widget. See gtk_widget_set_device_events() for details. 1036 * 1037 * Params: 1038 * device = a #GdkDevice 1039 * events = an event mask, see #GdkEventMask 1040 * 1041 * Since: 3.0 1042 */ 1043 public void addDeviceEvents(Device device, GdkEventMask events) 1044 { 1045 gtk_widget_add_device_events(gtkWidget, (device is null) ? null : device.getDeviceStruct(), events); 1046 } 1047 1048 /** 1049 * Adds the events in the bitfield @events to the event mask for 1050 * @widget. See gtk_widget_set_events() and the 1051 * [input handling overview][event-masks] for details. 1052 * 1053 * Params: 1054 * events = an event mask, see #GdkEventMask 1055 */ 1056 public void addEvents(int events) 1057 { 1058 gtk_widget_add_events(gtkWidget, events); 1059 } 1060 1061 /** 1062 * Adds a widget to the list of mnemonic labels for 1063 * this widget. (See gtk_widget_list_mnemonic_labels()). Note the 1064 * list of mnemonic labels for the widget is cleared when the 1065 * widget is destroyed, so the caller must make sure to update 1066 * its internal state at this point as well, by using a connection 1067 * to the #GtkWidget::destroy signal or a weak notifier. 1068 * 1069 * Params: 1070 * label = a #GtkWidget that acts as a mnemonic label for @widget 1071 * 1072 * Since: 2.4 1073 */ 1074 public void addMnemonicLabel(Widget label) 1075 { 1076 gtk_widget_add_mnemonic_label(gtkWidget, (label is null) ? null : label.getWidgetStruct()); 1077 } 1078 1079 /** 1080 * Queues an animation frame update and adds a callback to be called 1081 * before each frame. Until the tick callback is removed, it will be 1082 * called frequently (usually at the frame rate of the output device 1083 * or as quickly as the application can be repainted, whichever is 1084 * slower). For this reason, is most suitable for handling graphics 1085 * that change every frame or every few frames. The tick callback does 1086 * not automatically imply a relayout or repaint. If you want a 1087 * repaint or relayout, and aren’t changing widget properties that 1088 * would trigger that (for example, changing the text of a #GtkLabel), 1089 * then you will have to call gtk_widget_queue_resize() or 1090 * gtk_widget_queue_draw_area() yourself. 1091 * 1092 * gdk_frame_clock_get_frame_time() should generally be used for timing 1093 * continuous animations and 1094 * gdk_frame_timings_get_predicted_presentation_time() if you are 1095 * trying to display isolated frames at particular times. 1096 * 1097 * This is a more convenient alternative to connecting directly to the 1098 * #GdkFrameClock::update signal of #GdkFrameClock, since you don't 1099 * have to worry about when a #GdkFrameClock is assigned to a widget. 1100 * 1101 * Params: 1102 * callback = function to call for updating animations 1103 * userData = data to pass to @callback 1104 * notify = function to call to free @user_data when the callback is removed. 1105 * 1106 * Returns: an id for the connection of this callback. Remove the callback 1107 * by passing it to gtk_widget_remove_tick_callback() 1108 * 1109 * Since: 3.8 1110 */ 1111 public uint addTickCallback(GtkTickCallback callback, void* userData, GDestroyNotify notify) 1112 { 1113 return gtk_widget_add_tick_callback(gtkWidget, callback, userData, notify); 1114 } 1115 1116 /** 1117 * Determines whether an accelerator that activates the signal 1118 * identified by @signal_id can currently be activated. 1119 * This is done by emitting the #GtkWidget::can-activate-accel 1120 * signal on @widget; if the signal isn’t overridden by a 1121 * handler or in a derived widget, then the default check is 1122 * that the widget must be sensitive, and the widget and all 1123 * its ancestors mapped. 1124 * 1125 * Params: 1126 * signalId = the ID of a signal installed on @widget 1127 * 1128 * Returns: %TRUE if the accelerator can be activated. 1129 * 1130 * Since: 2.4 1131 */ 1132 public bool canActivateAccel(uint signalId) 1133 { 1134 return gtk_widget_can_activate_accel(gtkWidget, signalId) != 0; 1135 } 1136 1137 /** 1138 * This function is used by custom widget implementations; if you're 1139 * writing an app, you’d use gtk_widget_grab_focus() to move the focus 1140 * to a particular widget, and gtk_container_set_focus_chain() to 1141 * change the focus tab order. So you may want to investigate those 1142 * functions instead. 1143 * 1144 * gtk_widget_child_focus() is called by containers as the user moves 1145 * around the window using keyboard shortcuts. @direction indicates 1146 * what kind of motion is taking place (up, down, left, right, tab 1147 * forward, tab backward). gtk_widget_child_focus() emits the 1148 * #GtkWidget::focus signal; widgets override the default handler 1149 * for this signal in order to implement appropriate focus behavior. 1150 * 1151 * The default ::focus handler for a widget should return %TRUE if 1152 * moving in @direction left the focus on a focusable location inside 1153 * that widget, and %FALSE if moving in @direction moved the focus 1154 * outside the widget. If returning %TRUE, widgets normally 1155 * call gtk_widget_grab_focus() to place the focus accordingly; 1156 * if returning %FALSE, they don’t modify the current focus location. 1157 * 1158 * Params: 1159 * direction = direction of focus movement 1160 * 1161 * Returns: %TRUE if focus ended up inside @widget 1162 */ 1163 public bool childFocus(GtkDirectionType direction) 1164 { 1165 return gtk_widget_child_focus(gtkWidget, direction) != 0; 1166 } 1167 1168 /** 1169 * Emits a #GtkWidget::child-notify signal for the 1170 * [child property][child-properties] @child_property 1171 * on @widget. 1172 * 1173 * This is the analogue of g_object_notify() for child properties. 1174 * 1175 * Also see gtk_container_child_notify(). 1176 * 1177 * Params: 1178 * childProperty = the name of a child property installed on the 1179 * class of @widget’s parent 1180 */ 1181 public void childNotify(string childProperty) 1182 { 1183 gtk_widget_child_notify(gtkWidget, Str.toStringz(childProperty)); 1184 } 1185 1186 /** 1187 * Same as gtk_widget_path(), but always uses the name of a widget’s type, 1188 * never uses a custom name set with gtk_widget_set_name(). 1189 * 1190 * Deprecated: Use gtk_widget_get_path() instead 1191 * 1192 * Params: 1193 * pathLength = location to store the length of the 1194 * class path, or %NULL 1195 * path = location to store the class path as an 1196 * allocated string, or %NULL 1197 * pathReversed = location to store the reverse 1198 * class path as an allocated string, or %NULL 1199 */ 1200 public void classPath(out uint pathLength, out string path, out string pathReversed) 1201 { 1202 char* outpath = null; 1203 char* outpathReversed = null; 1204 1205 gtk_widget_class_path(gtkWidget, &pathLength, &outpath, &outpathReversed); 1206 1207 path = Str.toString(outpath); 1208 pathReversed = Str.toString(outpathReversed); 1209 } 1210 1211 /** 1212 * Computes whether a container should give this widget extra space 1213 * when possible. Containers should check this, rather than 1214 * looking at gtk_widget_get_hexpand() or gtk_widget_get_vexpand(). 1215 * 1216 * This function already checks whether the widget is visible, so 1217 * visibility does not need to be checked separately. Non-visible 1218 * widgets are not expanded. 1219 * 1220 * The computed expand value uses either the expand setting explicitly 1221 * set on the widget itself, or, if none has been explicitly set, 1222 * the widget may expand if some of its children do. 1223 * 1224 * Params: 1225 * orientation = expand direction 1226 * 1227 * Returns: whether widget tree rooted here should be expanded 1228 */ 1229 public bool computeExpand(GtkOrientation orientation) 1230 { 1231 return gtk_widget_compute_expand(gtkWidget, orientation) != 0; 1232 } 1233 1234 /** 1235 * Creates a new #PangoContext with the appropriate font map, 1236 * font options, font description, and base direction for drawing 1237 * text for this widget. See also gtk_widget_get_pango_context(). 1238 * 1239 * Returns: the new #PangoContext 1240 */ 1241 public PgContext createPangoContext() 1242 { 1243 auto p = gtk_widget_create_pango_context(gtkWidget); 1244 1245 if(p is null) 1246 { 1247 return null; 1248 } 1249 1250 return ObjectG.getDObject!(PgContext)(cast(PangoContext*) p, true); 1251 } 1252 1253 /** 1254 * Creates a new #PangoLayout with the appropriate font map, 1255 * font description, and base direction for drawing text for 1256 * this widget. 1257 * 1258 * If you keep a #PangoLayout created in this way around, you need 1259 * to re-create it when the widget #PangoContext is replaced. 1260 * This can be tracked by using the #GtkWidget::screen-changed signal 1261 * on the widget. 1262 * 1263 * Params: 1264 * text = text to set on the layout (can be %NULL) 1265 * 1266 * Returns: the new #PangoLayout 1267 */ 1268 public PgLayout createPangoLayout(string text) 1269 { 1270 auto p = gtk_widget_create_pango_layout(gtkWidget, Str.toStringz(text)); 1271 1272 if(p is null) 1273 { 1274 return null; 1275 } 1276 1277 return ObjectG.getDObject!(PgLayout)(cast(PangoLayout*) p, true); 1278 } 1279 1280 /** 1281 * Destroys a widget. 1282 * 1283 * When a widget is destroyed all references it holds on other objects 1284 * will be released: 1285 * 1286 * - if the widget is inside a container, it will be removed from its 1287 * parent 1288 * - if the widget is a container, all its children will be destroyed, 1289 * recursively 1290 * - if the widget is a top level, it will be removed from the list 1291 * of top level widgets that GTK+ maintains internally 1292 * 1293 * It's expected that all references held on the widget will also 1294 * be released; you should connect to the #GtkWidget::destroy signal 1295 * if you hold a reference to @widget and you wish to remove it when 1296 * this function is called. It is not necessary to do so if you are 1297 * implementing a #GtkContainer, as you'll be able to use the 1298 * #GtkContainerClass.remove() virtual function for that. 1299 * 1300 * It's important to notice that gtk_widget_destroy() will only cause 1301 * the @widget to be finalized if no additional references, acquired 1302 * using g_object_ref(), are held on it. In case additional references 1303 * are in place, the @widget will be in an "inert" state after calling 1304 * this function; @widget will still point to valid memory, allowing you 1305 * to release the references you hold, but you may not query the widget's 1306 * own state. 1307 * 1308 * You should typically call this function on top level widgets, and 1309 * rarely on child widgets. 1310 * 1311 * See also: gtk_container_remove() 1312 */ 1313 public void destroy() 1314 { 1315 gtk_widget_destroy(gtkWidget); 1316 } 1317 1318 /** 1319 * This function sets *@widget_pointer to %NULL if @widget_pointer != 1320 * %NULL. It’s intended to be used as a callback connected to the 1321 * “destroy” signal of a widget. You connect gtk_widget_destroyed() 1322 * as a signal handler, and pass the address of your widget variable 1323 * as user data. Then when the widget is destroyed, the variable will 1324 * be set to %NULL. Useful for example to avoid multiple copies 1325 * of the same dialog. 1326 * 1327 * Params: 1328 * widgetPointer = address of a variable that contains @widget 1329 */ 1330 public void destroyed(ref Widget widgetPointer) 1331 { 1332 GtkWidget* outwidgetPointer = widgetPointer.getWidgetStruct(); 1333 1334 gtk_widget_destroyed(gtkWidget, &outwidgetPointer); 1335 1336 widgetPointer = ObjectG.getDObject!(Widget)(outwidgetPointer); 1337 } 1338 1339 /** 1340 * Returns %TRUE if @device has been shadowed by a GTK+ 1341 * device grab on another widget, so it would stop sending 1342 * events to @widget. This may be used in the 1343 * #GtkWidget::grab-notify signal to check for specific 1344 * devices. See gtk_device_grab_add(). 1345 * 1346 * Params: 1347 * device = a #GdkDevice 1348 * 1349 * Returns: %TRUE if there is an ongoing grab on @device 1350 * by another #GtkWidget than @widget. 1351 * 1352 * Since: 3.0 1353 */ 1354 public bool deviceIsShadowed(Device device) 1355 { 1356 return gtk_widget_device_is_shadowed(gtkWidget, (device is null) ? null : device.getDeviceStruct()) != 0; 1357 } 1358 1359 /** 1360 * This function is equivalent to gtk_drag_begin_with_coordinates(), 1361 * passing -1, -1 as coordinates. 1362 * 1363 * Deprecated: Use gtk_drag_begin_with_coordinates() instead 1364 * 1365 * Params: 1366 * targets = The targets (data formats) in which the 1367 * source can provide the data 1368 * actions = A bitmask of the allowed drag actions for this drag 1369 * button = The button the user clicked to start the drag 1370 * event = The event that triggered the start of the drag, 1371 * or %NULL if none can be obtained. 1372 * 1373 * Returns: the context for this drag 1374 */ 1375 public DragContext dragBegin(TargetList targets, GdkDragAction actions, int button, Event event) 1376 { 1377 auto p = gtk_drag_begin(gtkWidget, (targets is null) ? null : targets.getTargetListStruct(), actions, button, (event is null) ? null : event.getEventStruct()); 1378 1379 if(p is null) 1380 { 1381 return null; 1382 } 1383 1384 return ObjectG.getDObject!(DragContext)(cast(GdkDragContext*) p); 1385 } 1386 1387 /** 1388 * Initiates a drag on the source side. The function only needs to be used 1389 * when the application is starting drags itself, and is not needed when 1390 * gtk_drag_source_set() is used. 1391 * 1392 * The @event is used to retrieve the timestamp that will be used internally to 1393 * grab the pointer. If @event is %NULL, then %GDK_CURRENT_TIME will be used. 1394 * However, you should try to pass a real event in all cases, since that can be 1395 * used to get information about the drag. 1396 * 1397 * Generally there are three cases when you want to start a drag by hand by 1398 * calling this function: 1399 * 1400 * 1. During a #GtkWidget::button-press-event handler, if you want to start a drag 1401 * immediately when the user presses the mouse button. Pass the @event 1402 * that you have in your #GtkWidget::button-press-event handler. 1403 * 1404 * 2. During a #GtkWidget::motion-notify-event handler, if you want to start a drag 1405 * when the mouse moves past a certain threshold distance after a button-press. 1406 * Pass the @event that you have in your #GtkWidget::motion-notify-event handler. 1407 * 1408 * 3. During a timeout handler, if you want to start a drag after the mouse 1409 * button is held down for some time. Try to save the last event that you got 1410 * from the mouse, using gdk_event_copy(), and pass it to this function 1411 * (remember to free the event with gdk_event_free() when you are done). 1412 * If you really cannot pass a real event, pass %NULL instead. 1413 * 1414 * Params: 1415 * targets = The targets (data formats) in which the 1416 * source can provide the data 1417 * actions = A bitmask of the allowed drag actions for this drag 1418 * button = The button the user clicked to start the drag 1419 * event = The event that triggered the start of the drag, 1420 * or %NULL if none can be obtained. 1421 * x = The initial x coordinate to start dragging from, in the coordinate space 1422 * of @widget. If -1 is passed, the coordinates are retrieved from @event or 1423 * the current pointer position 1424 * y = The initial y coordinate to start dragging from, in the coordinate space 1425 * of @widget. If -1 is passed, the coordinates are retrieved from @event or 1426 * the current pointer position 1427 * 1428 * Returns: the context for this drag 1429 * 1430 * Since: 3.10 1431 */ 1432 public DragContext dragBeginWithCoordinates(TargetList targets, GdkDragAction actions, int button, Event event, int x, int y) 1433 { 1434 auto p = gtk_drag_begin_with_coordinates(gtkWidget, (targets is null) ? null : targets.getTargetListStruct(), actions, button, (event is null) ? null : event.getEventStruct(), x, y); 1435 1436 if(p is null) 1437 { 1438 return null; 1439 } 1440 1441 return ObjectG.getDObject!(DragContext)(cast(GdkDragContext*) p); 1442 } 1443 1444 /** 1445 * Checks to see if a mouse drag starting at (@start_x, @start_y) and ending 1446 * at (@current_x, @current_y) has passed the GTK+ drag threshold, and thus 1447 * should trigger the beginning of a drag-and-drop operation. 1448 * 1449 * Params: 1450 * startX = X coordinate of start of drag 1451 * startY = Y coordinate of start of drag 1452 * currentX = current X coordinate 1453 * currentY = current Y coordinate 1454 * 1455 * Returns: %TRUE if the drag threshold has been passed. 1456 */ 1457 public bool dragCheckThreshold(int startX, int startY, int currentX, int currentY) 1458 { 1459 return gtk_drag_check_threshold(gtkWidget, startX, startY, currentX, currentY) != 0; 1460 } 1461 1462 /** 1463 * Add the image targets supported by #GtkSelectionData to 1464 * the target list of the drag destination. The targets 1465 * are added with @info = 0. If you need another value, 1466 * use gtk_target_list_add_image_targets() and 1467 * gtk_drag_dest_set_target_list(). 1468 * 1469 * Since: 2.6 1470 */ 1471 public void dragDestAddImageTargets() 1472 { 1473 gtk_drag_dest_add_image_targets(gtkWidget); 1474 } 1475 1476 /** 1477 * Add the text targets supported by #GtkSelectionData to 1478 * the target list of the drag destination. The targets 1479 * are added with @info = 0. If you need another value, 1480 * use gtk_target_list_add_text_targets() and 1481 * gtk_drag_dest_set_target_list(). 1482 * 1483 * Since: 2.6 1484 */ 1485 public void dragDestAddTextTargets() 1486 { 1487 gtk_drag_dest_add_text_targets(gtkWidget); 1488 } 1489 1490 /** 1491 * Add the URI targets supported by #GtkSelectionData to 1492 * the target list of the drag destination. The targets 1493 * are added with @info = 0. If you need another value, 1494 * use gtk_target_list_add_uri_targets() and 1495 * gtk_drag_dest_set_target_list(). 1496 * 1497 * Since: 2.6 1498 */ 1499 public void dragDestAddUriTargets() 1500 { 1501 gtk_drag_dest_add_uri_targets(gtkWidget); 1502 } 1503 1504 /** 1505 * Looks for a match between the supported targets of @context and the 1506 * @dest_target_list, returning the first matching target, otherwise 1507 * returning %GDK_NONE. @dest_target_list should usually be the return 1508 * value from gtk_drag_dest_get_target_list(), but some widgets may 1509 * have different valid targets for different parts of the widget; in 1510 * that case, they will have to implement a drag_motion handler that 1511 * passes the correct target list to this function. 1512 * 1513 * Params: 1514 * context = drag context 1515 * targetList = list of droppable targets, or %NULL to use 1516 * gtk_drag_dest_get_target_list (@widget). 1517 * 1518 * Returns: first target that the source offers 1519 * and the dest can accept, or %GDK_NONE 1520 */ 1521 public GdkAtom dragDestFindTarget(DragContext context, TargetList targetList) 1522 { 1523 return gtk_drag_dest_find_target(gtkWidget, (context is null) ? null : context.getDragContextStruct(), (targetList is null) ? null : targetList.getTargetListStruct()); 1524 } 1525 1526 /** 1527 * Returns the list of targets this widget can accept from 1528 * drag-and-drop. 1529 * 1530 * Returns: the #GtkTargetList, or %NULL if none 1531 */ 1532 public TargetList dragDestGetTargetList() 1533 { 1534 auto p = gtk_drag_dest_get_target_list(gtkWidget); 1535 1536 if(p is null) 1537 { 1538 return null; 1539 } 1540 1541 return ObjectG.getDObject!(TargetList)(cast(GtkTargetList*) p); 1542 } 1543 1544 /** 1545 * Returns whether the widget has been configured to always 1546 * emit #GtkWidget::drag-motion signals. 1547 * 1548 * Returns: %TRUE if the widget always emits 1549 * #GtkWidget::drag-motion events 1550 * 1551 * Since: 2.10 1552 */ 1553 public bool dragDestGetTrackMotion() 1554 { 1555 return gtk_drag_dest_get_track_motion(gtkWidget) != 0; 1556 } 1557 1558 /** 1559 * Sets a widget as a potential drop destination, and adds default behaviors. 1560 * 1561 * The default behaviors listed in @flags have an effect similar 1562 * to installing default handlers for the widget’s drag-and-drop signals 1563 * (#GtkWidget::drag-motion, #GtkWidget::drag-drop, ...). They all exist 1564 * for convenience. When passing #GTK_DEST_DEFAULT_ALL for instance it is 1565 * sufficient to connect to the widget’s #GtkWidget::drag-data-received 1566 * signal to get primitive, but consistent drag-and-drop support. 1567 * 1568 * Things become more complicated when you try to preview the dragged data, 1569 * as described in the documentation for #GtkWidget::drag-motion. The default 1570 * behaviors described by @flags make some assumptions, that can conflict 1571 * with your own signal handlers. For instance #GTK_DEST_DEFAULT_DROP causes 1572 * invokations of gdk_drag_status() in the context of #GtkWidget::drag-motion, 1573 * and invokations of gtk_drag_finish() in #GtkWidget::drag-data-received. 1574 * Especially the later is dramatic, when your own #GtkWidget::drag-motion 1575 * handler calls gtk_drag_get_data() to inspect the dragged data. 1576 * 1577 * There’s no way to set a default action here, you can use the 1578 * #GtkWidget::drag-motion callback for that. Here’s an example which selects 1579 * the action to use depending on whether the control key is pressed or not: 1580 * |[<!-- language="C" --> 1581 * static void 1582 * drag_motion (GtkWidget *widget, 1583 * GdkDragContext *context, 1584 * gint x, 1585 * gint y, 1586 * guint time) 1587 * { 1588 * GdkModifierType mask; 1589 * 1590 * gdk_window_get_pointer (gtk_widget_get_window (widget), 1591 * NULL, NULL, &mask); 1592 * if (mask & GDK_CONTROL_MASK) 1593 * gdk_drag_status (context, GDK_ACTION_COPY, time); 1594 * else 1595 * gdk_drag_status (context, GDK_ACTION_MOVE, time); 1596 * } 1597 * ]| 1598 * 1599 * Params: 1600 * flags = which types of default drag behavior to use 1601 * targets = a pointer to an array of 1602 * #GtkTargetEntrys indicating the drop types that this @widget will 1603 * accept, or %NULL. Later you can access the list with 1604 * gtk_drag_dest_get_target_list() and gtk_drag_dest_find_target(). 1605 * actions = a bitmask of possible actions for a drop onto this @widget. 1606 */ 1607 public void dragDestSet(GtkDestDefaults flags, TargetEntry[] targets, GdkDragAction actions) 1608 { 1609 GtkTargetEntry[] targetsArray = new GtkTargetEntry[targets.length]; 1610 for ( int i = 0; i < targets.length; i++ ) 1611 { 1612 targetsArray[i] = *(targets[i].getTargetEntryStruct()); 1613 } 1614 1615 gtk_drag_dest_set(gtkWidget, flags, targetsArray.ptr, cast(int)targets.length, actions); 1616 } 1617 1618 /** 1619 * Sets this widget as a proxy for drops to another window. 1620 * 1621 * Params: 1622 * proxyWindow = the window to which to forward drag events 1623 * protocol = the drag protocol which the @proxy_window accepts 1624 * (You can use gdk_drag_get_protocol() to determine this) 1625 * useCoordinates = If %TRUE, send the same coordinates to the 1626 * destination, because it is an embedded 1627 * subwindow. 1628 */ 1629 public void dragDestSetProxy(GdkWin proxyWindow, GdkDragProtocol protocol, bool useCoordinates) 1630 { 1631 gtk_drag_dest_set_proxy(gtkWidget, (proxyWindow is null) ? null : proxyWindow.getWindowStruct(), protocol, useCoordinates); 1632 } 1633 1634 /** 1635 * Sets the target types that this widget can accept from drag-and-drop. 1636 * The widget must first be made into a drag destination with 1637 * gtk_drag_dest_set(). 1638 * 1639 * Params: 1640 * targetList = list of droppable targets, or %NULL for none 1641 */ 1642 public void dragDestSetTargetList(TargetList targetList) 1643 { 1644 gtk_drag_dest_set_target_list(gtkWidget, (targetList is null) ? null : targetList.getTargetListStruct()); 1645 } 1646 1647 /** 1648 * Tells the widget to emit #GtkWidget::drag-motion and 1649 * #GtkWidget::drag-leave events regardless of the targets and the 1650 * %GTK_DEST_DEFAULT_MOTION flag. 1651 * 1652 * This may be used when a widget wants to do generic 1653 * actions regardless of the targets that the source offers. 1654 * 1655 * Params: 1656 * trackMotion = whether to accept all targets 1657 * 1658 * Since: 2.10 1659 */ 1660 public void dragDestSetTrackMotion(bool trackMotion) 1661 { 1662 gtk_drag_dest_set_track_motion(gtkWidget, trackMotion); 1663 } 1664 1665 /** 1666 * Clears information about a drop destination set with 1667 * gtk_drag_dest_set(). The widget will no longer receive 1668 * notification of drags. 1669 */ 1670 public void dragDestUnset() 1671 { 1672 gtk_drag_dest_unset(gtkWidget); 1673 } 1674 1675 /** 1676 * Gets the data associated with a drag. When the data 1677 * is received or the retrieval fails, GTK+ will emit a 1678 * #GtkWidget::drag-data-received signal. Failure of the retrieval 1679 * is indicated by the length field of the @selection_data 1680 * signal parameter being negative. However, when gtk_drag_get_data() 1681 * is called implicitely because the %GTK_DEST_DEFAULT_DROP was set, 1682 * then the widget will not receive notification of failed 1683 * drops. 1684 * 1685 * Params: 1686 * context = the drag context 1687 * target = the target (form of the data) to retrieve 1688 * time = a timestamp for retrieving the data. This will 1689 * generally be the time received in a #GtkWidget::drag-motion 1690 * or #GtkWidget::drag-drop signal 1691 */ 1692 public void dragGetData(DragContext context, GdkAtom target, uint time) 1693 { 1694 gtk_drag_get_data(gtkWidget, (context is null) ? null : context.getDragContextStruct(), target, time); 1695 } 1696 1697 /** 1698 * Highlights a widget as a currently hovered drop target. 1699 * To end the highlight, call gtk_drag_unhighlight(). 1700 * GTK+ calls this automatically if %GTK_DEST_DEFAULT_HIGHLIGHT is set. 1701 */ 1702 public void dragHighlight() 1703 { 1704 gtk_drag_highlight(gtkWidget); 1705 } 1706 1707 /** 1708 * Add the writable image targets supported by #GtkSelectionData to 1709 * the target list of the drag source. The targets 1710 * are added with @info = 0. If you need another value, 1711 * use gtk_target_list_add_image_targets() and 1712 * gtk_drag_source_set_target_list(). 1713 * 1714 * Since: 2.6 1715 */ 1716 public void dragSourceAddImageTargets() 1717 { 1718 gtk_drag_source_add_image_targets(gtkWidget); 1719 } 1720 1721 /** 1722 * Add the text targets supported by #GtkSelectionData to 1723 * the target list of the drag source. The targets 1724 * are added with @info = 0. If you need another value, 1725 * use gtk_target_list_add_text_targets() and 1726 * gtk_drag_source_set_target_list(). 1727 * 1728 * Since: 2.6 1729 */ 1730 public void dragSourceAddTextTargets() 1731 { 1732 gtk_drag_source_add_text_targets(gtkWidget); 1733 } 1734 1735 /** 1736 * Add the URI targets supported by #GtkSelectionData to 1737 * the target list of the drag source. The targets 1738 * are added with @info = 0. If you need another value, 1739 * use gtk_target_list_add_uri_targets() and 1740 * gtk_drag_source_set_target_list(). 1741 * 1742 * Since: 2.6 1743 */ 1744 public void dragSourceAddUriTargets() 1745 { 1746 gtk_drag_source_add_uri_targets(gtkWidget); 1747 } 1748 1749 /** 1750 * Gets the list of targets this widget can provide for 1751 * drag-and-drop. 1752 * 1753 * Returns: the #GtkTargetList, or %NULL if none 1754 * 1755 * Since: 2.4 1756 */ 1757 public TargetList dragSourceGetTargetList() 1758 { 1759 auto p = gtk_drag_source_get_target_list(gtkWidget); 1760 1761 if(p is null) 1762 { 1763 return null; 1764 } 1765 1766 return ObjectG.getDObject!(TargetList)(cast(GtkTargetList*) p); 1767 } 1768 1769 /** 1770 * Sets up a widget so that GTK+ will start a drag operation when the user 1771 * clicks and drags on the widget. The widget must have a window. 1772 * 1773 * Params: 1774 * startButtonMask = the bitmask of buttons that can start the drag 1775 * targets = the table of targets 1776 * that the drag will support, may be %NULL 1777 * actions = the bitmask of possible actions for a drag from this widget 1778 */ 1779 public void dragSourceSet(GdkModifierType startButtonMask, TargetEntry[] targets, GdkDragAction actions) 1780 { 1781 GtkTargetEntry[] targetsArray = new GtkTargetEntry[targets.length]; 1782 for ( int i = 0; i < targets.length; i++ ) 1783 { 1784 targetsArray[i] = *(targets[i].getTargetEntryStruct()); 1785 } 1786 1787 gtk_drag_source_set(gtkWidget, startButtonMask, targetsArray.ptr, cast(int)targets.length, actions); 1788 } 1789 1790 /** 1791 * Sets the icon that will be used for drags from a particular source 1792 * to @icon. See the docs for #GtkIconTheme for more details. 1793 * 1794 * Params: 1795 * icon = A #GIcon 1796 * 1797 * Since: 3.2 1798 */ 1799 public void dragSourceSetIconGicon(IconIF icon) 1800 { 1801 gtk_drag_source_set_icon_gicon(gtkWidget, (icon is null) ? null : icon.getIconStruct()); 1802 } 1803 1804 /** 1805 * Sets the icon that will be used for drags from a particular source 1806 * to a themed icon. See the docs for #GtkIconTheme for more details. 1807 * 1808 * Params: 1809 * iconName = name of icon to use 1810 * 1811 * Since: 2.8 1812 */ 1813 public void dragSourceSetIconName(string iconName) 1814 { 1815 gtk_drag_source_set_icon_name(gtkWidget, Str.toStringz(iconName)); 1816 } 1817 1818 /** 1819 * Sets the icon that will be used for drags from a particular widget 1820 * from a #GdkPixbuf. GTK+ retains a reference for @pixbuf and will 1821 * release it when it is no longer needed. 1822 * 1823 * Params: 1824 * pixbuf = the #GdkPixbuf for the drag icon 1825 */ 1826 public void dragSourceSetIconPixbuf(Pixbuf pixbuf) 1827 { 1828 gtk_drag_source_set_icon_pixbuf(gtkWidget, (pixbuf is null) ? null : pixbuf.getPixbufStruct()); 1829 } 1830 1831 /** 1832 * Sets the icon that will be used for drags from a particular source 1833 * to a stock icon. 1834 * 1835 * Deprecated: Use gtk_drag_source_set_icon_name() instead. 1836 * 1837 * Params: 1838 * stockId = the ID of the stock icon to use 1839 */ 1840 public void dragSourceSetIconStock(string stockId) 1841 { 1842 gtk_drag_source_set_icon_stock(gtkWidget, Str.toStringz(stockId)); 1843 } 1844 1845 /** 1846 * Changes the target types that this widget offers for drag-and-drop. 1847 * The widget must first be made into a drag source with 1848 * gtk_drag_source_set(). 1849 * 1850 * Params: 1851 * targetList = list of draggable targets, or %NULL for none 1852 * 1853 * Since: 2.4 1854 */ 1855 public void dragSourceSetTargetList(TargetList targetList) 1856 { 1857 gtk_drag_source_set_target_list(gtkWidget, (targetList is null) ? null : targetList.getTargetListStruct()); 1858 } 1859 1860 /** 1861 * Undoes the effects of gtk_drag_source_set(). 1862 */ 1863 public void dragSourceUnset() 1864 { 1865 gtk_drag_source_unset(gtkWidget); 1866 } 1867 1868 /** 1869 * Removes a highlight set by gtk_drag_highlight() from 1870 * a widget. 1871 */ 1872 public void dragUnhighlight() 1873 { 1874 gtk_drag_unhighlight(gtkWidget); 1875 } 1876 1877 /** 1878 * Draws @widget to @cr. The top left corner of the widget will be 1879 * drawn to the currently set origin point of @cr. 1880 * 1881 * You should pass a cairo context as @cr argument that is in an 1882 * original state. Otherwise the resulting drawing is undefined. For 1883 * example changing the operator using cairo_set_operator() or the 1884 * line width using cairo_set_line_width() might have unwanted side 1885 * effects. 1886 * You may however change the context’s transform matrix - like with 1887 * cairo_scale(), cairo_translate() or cairo_set_matrix() and clip 1888 * region with cairo_clip() prior to calling this function. Also, it 1889 * is fine to modify the context with cairo_save() and 1890 * cairo_push_group() prior to calling this function. 1891 * 1892 * Note that special-purpose widgets may contain special code for 1893 * rendering to the screen and might appear differently on screen 1894 * and when rendered using gtk_widget_draw(). 1895 * 1896 * Params: 1897 * cr = a cairo context to draw to 1898 * 1899 * Since: 3.0 1900 */ 1901 public void draw(Context cr) 1902 { 1903 gtk_widget_draw(gtkWidget, (cr is null) ? null : cr.getContextStruct()); 1904 } 1905 1906 /** 1907 * Ensures that @widget has a style (@widget->style). 1908 * 1909 * Not a very useful function; most of the time, if you 1910 * want the style, the widget is realized, and realized 1911 * widgets are guaranteed to have a style already. 1912 * 1913 * Deprecated: Use #GtkStyleContext instead 1914 */ 1915 public void ensureStyle() 1916 { 1917 gtk_widget_ensure_style(gtkWidget); 1918 } 1919 1920 /** 1921 * Notifies the user about an input-related error on this widget. 1922 * If the #GtkSettings:gtk-error-bell setting is %TRUE, it calls 1923 * gdk_window_beep(), otherwise it does nothing. 1924 * 1925 * Note that the effect of gdk_window_beep() can be configured in many 1926 * ways, depending on the windowing backend and the desktop environment 1927 * or window manager that is used. 1928 * 1929 * Since: 2.12 1930 */ 1931 public void errorBell() 1932 { 1933 gtk_widget_error_bell(gtkWidget); 1934 } 1935 1936 /** 1937 * Rarely-used function. This function is used to emit 1938 * the event signals on a widget (those signals should never 1939 * be emitted without using this function to do so). 1940 * If you want to synthesize an event though, don’t use this function; 1941 * instead, use gtk_main_do_event() so the event will behave as if 1942 * it were in the event queue. Don’t synthesize expose events; instead, 1943 * use gdk_window_invalidate_rect() to invalidate a region of the 1944 * window. 1945 * 1946 * Params: 1947 * event = a #GdkEvent 1948 * 1949 * Returns: return from the event signal emission (%TRUE if 1950 * the event was handled) 1951 */ 1952 public bool event(Event event) 1953 { 1954 return gtk_widget_event(gtkWidget, (event is null) ? null : event.getEventStruct()) != 0; 1955 } 1956 1957 /** 1958 * Stops emission of #GtkWidget::child-notify signals on @widget. The 1959 * signals are queued until gtk_widget_thaw_child_notify() is called 1960 * on @widget. 1961 * 1962 * This is the analogue of g_object_freeze_notify() for child properties. 1963 */ 1964 public void freezeChildNotify() 1965 { 1966 gtk_widget_freeze_child_notify(gtkWidget); 1967 } 1968 1969 /** 1970 * Returns the accessible object that describes the widget to an 1971 * assistive technology. 1972 * 1973 * If accessibility support is not available, this #AtkObject 1974 * instance may be a no-op. Likewise, if no class-specific #AtkObject 1975 * implementation is available for the widget instance in question, 1976 * it will inherit an #AtkObject implementation from the first ancestor 1977 * class for which such an implementation is defined. 1978 * 1979 * The documentation of the 1980 * [ATK](http://developer.gnome.org/atk/stable/) 1981 * library contains more information about accessible objects and their uses. 1982 * 1983 * Returns: the #AtkObject associated with @widget 1984 */ 1985 public ObjectAtk getAccessible() 1986 { 1987 auto p = gtk_widget_get_accessible(gtkWidget); 1988 1989 if(p is null) 1990 { 1991 return null; 1992 } 1993 1994 return ObjectG.getDObject!(ObjectAtk)(cast(AtkObject*) p); 1995 } 1996 1997 /** 1998 * Retrieves the #GActionGroup that was registered using @prefix. The resulting 1999 * #GActionGroup may have been registered to @widget or any #GtkWidget in its 2000 * ancestry. 2001 * 2002 * If no action group was found matching @prefix, then %NULL is returned. 2003 * 2004 * Params: 2005 * prefix = The “prefix” of the action group. 2006 * 2007 * Returns: A #GActionGroup or %NULL. 2008 * 2009 * Since: 3.16 2010 */ 2011 public ActionGroupIF getActionGroup(string prefix) 2012 { 2013 auto p = gtk_widget_get_action_group(gtkWidget, Str.toStringz(prefix)); 2014 2015 if(p is null) 2016 { 2017 return null; 2018 } 2019 2020 return ObjectG.getDObject!(ActionGroupIF)(cast(GActionGroup*) p); 2021 } 2022 2023 /** 2024 * Returns the baseline that has currently been allocated to @widget. 2025 * This function is intended to be used when implementing handlers 2026 * for the #GtkWidget::draw function, and when allocating child 2027 * widgets in #GtkWidget::size_allocate. 2028 * 2029 * Returns: the baseline of the @widget, or -1 if none 2030 * 2031 * Since: 3.10 2032 */ 2033 public int getAllocatedBaseline() 2034 { 2035 return gtk_widget_get_allocated_baseline(gtkWidget); 2036 } 2037 2038 /** 2039 * Returns the height that has currently been allocated to @widget. 2040 * This function is intended to be used when implementing handlers 2041 * for the #GtkWidget::draw function. 2042 * 2043 * Returns: the height of the @widget 2044 */ 2045 public int getAllocatedHeight() 2046 { 2047 return gtk_widget_get_allocated_height(gtkWidget); 2048 } 2049 2050 /** 2051 * Retrieves the widget’s allocated size. 2052 * 2053 * This function returns the last values passed to 2054 * gtk_widget_size_allocate_with_baseline(). The value differs from 2055 * the size returned in gtk_widget_get_allocation() in that functions 2056 * like gtk_widget_set_halign() can adjust the allocation, but not 2057 * the value returned by this function. 2058 * 2059 * If a widget is not visible, its allocated size is 0. 2060 * 2061 * Params: 2062 * allocation = a pointer to a #GtkAllocation to copy to 2063 * baseline = a pointer to an integer to copy to 2064 * 2065 * Since: 3.20 2066 */ 2067 public void getAllocatedSize(out GtkAllocation allocation, out int baseline) 2068 { 2069 gtk_widget_get_allocated_size(gtkWidget, &allocation, &baseline); 2070 } 2071 2072 /** 2073 * Returns the width that has currently been allocated to @widget. 2074 * This function is intended to be used when implementing handlers 2075 * for the #GtkWidget::draw function. 2076 * 2077 * Returns: the width of the @widget 2078 */ 2079 public int getAllocatedWidth() 2080 { 2081 return gtk_widget_get_allocated_width(gtkWidget); 2082 } 2083 2084 /** 2085 * Retrieves the widget’s allocation. 2086 * 2087 * Note, when implementing a #GtkContainer: a widget’s allocation will 2088 * be its “adjusted” allocation, that is, the widget’s parent 2089 * container typically calls gtk_widget_size_allocate() with an 2090 * allocation, and that allocation is then adjusted (to handle margin 2091 * and alignment for example) before assignment to the widget. 2092 * gtk_widget_get_allocation() returns the adjusted allocation that 2093 * was actually assigned to the widget. The adjusted allocation is 2094 * guaranteed to be completely contained within the 2095 * gtk_widget_size_allocate() allocation, however. So a #GtkContainer 2096 * is guaranteed that its children stay inside the assigned bounds, 2097 * but not that they have exactly the bounds the container assigned. 2098 * There is no way to get the original allocation assigned by 2099 * gtk_widget_size_allocate(), since it isn’t stored; if a container 2100 * implementation needs that information it will have to track it itself. 2101 * 2102 * Params: 2103 * allocation = a pointer to a #GtkAllocation to copy to 2104 * 2105 * Since: 2.18 2106 */ 2107 public void getAllocation(out GtkAllocation allocation) 2108 { 2109 gtk_widget_get_allocation(gtkWidget, &allocation); 2110 } 2111 2112 /** 2113 * Gets the first ancestor of @widget with type @widget_type. For example, 2114 * `gtk_widget_get_ancestor (widget, GTK_TYPE_BOX)` gets 2115 * the first #GtkBox that’s an ancestor of @widget. No reference will be 2116 * added to the returned widget; it should not be unreferenced. See note 2117 * about checking for a toplevel #GtkWindow in the docs for 2118 * gtk_widget_get_toplevel(). 2119 * 2120 * Note that unlike gtk_widget_is_ancestor(), gtk_widget_get_ancestor() 2121 * considers @widget to be an ancestor of itself. 2122 * 2123 * Params: 2124 * widgetType = ancestor type 2125 * 2126 * Returns: the ancestor widget, or %NULL if not found 2127 */ 2128 public Widget getAncestor(GType widgetType) 2129 { 2130 auto p = gtk_widget_get_ancestor(gtkWidget, widgetType); 2131 2132 if(p is null) 2133 { 2134 return null; 2135 } 2136 2137 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 2138 } 2139 2140 /** 2141 * Determines whether the application intends to draw on the widget in 2142 * an #GtkWidget::draw handler. 2143 * 2144 * See gtk_widget_set_app_paintable() 2145 * 2146 * Returns: %TRUE if the widget is app paintable 2147 * 2148 * Since: 2.18 2149 */ 2150 public bool getAppPaintable() 2151 { 2152 return gtk_widget_get_app_paintable(gtkWidget) != 0; 2153 } 2154 2155 /** 2156 * Determines whether @widget can be a default widget. See 2157 * gtk_widget_set_can_default(). 2158 * 2159 * Returns: %TRUE if @widget can be a default widget, %FALSE otherwise 2160 * 2161 * Since: 2.18 2162 */ 2163 public bool getCanDefault() 2164 { 2165 return gtk_widget_get_can_default(gtkWidget) != 0; 2166 } 2167 2168 /** 2169 * Determines whether @widget can own the input focus. See 2170 * gtk_widget_set_can_focus(). 2171 * 2172 * Returns: %TRUE if @widget can own the input focus, %FALSE otherwise 2173 * 2174 * Since: 2.18 2175 */ 2176 public bool getCanFocus() 2177 { 2178 return gtk_widget_get_can_focus(gtkWidget) != 0; 2179 } 2180 2181 /** 2182 * This function is only for use in widget implementations. Obtains 2183 * @widget->requisition, unless someone has forced a particular 2184 * geometry on the widget (e.g. with gtk_widget_set_size_request()), 2185 * in which case it returns that geometry instead of the widget's 2186 * requisition. 2187 * 2188 * This function differs from gtk_widget_size_request() in that 2189 * it retrieves the last size request value from @widget->requisition, 2190 * while gtk_widget_size_request() actually calls the "size_request" method 2191 * on @widget to compute the size request and fill in @widget->requisition, 2192 * and only then returns @widget->requisition. 2193 * 2194 * Because this function does not call the “size_request” method, it 2195 * can only be used when you know that @widget->requisition is 2196 * up-to-date, that is, gtk_widget_size_request() has been called 2197 * since the last time a resize was queued. In general, only container 2198 * implementations have this information; applications should use 2199 * gtk_widget_size_request(). 2200 * 2201 * Deprecated: Use gtk_widget_get_preferred_size() instead. 2202 * 2203 * Params: 2204 * requisition = a #GtkRequisition to be filled in 2205 */ 2206 public void getChildRequisition(out Requisition requisition) 2207 { 2208 GtkRequisition* outrequisition = sliceNew!GtkRequisition(); 2209 2210 gtk_widget_get_child_requisition(gtkWidget, outrequisition); 2211 2212 requisition = ObjectG.getDObject!(Requisition)(outrequisition, true); 2213 } 2214 2215 /** 2216 * Gets the value set with gtk_widget_set_child_visible(). 2217 * If you feel a need to use this function, your code probably 2218 * needs reorganization. 2219 * 2220 * This function is only useful for container implementations and 2221 * never should be called by an application. 2222 * 2223 * Returns: %TRUE if the widget is mapped with the parent. 2224 */ 2225 public bool getChildVisible() 2226 { 2227 return gtk_widget_get_child_visible(gtkWidget) != 0; 2228 } 2229 2230 /** 2231 * Retrieves the widget’s clip area. 2232 * 2233 * The clip area is the area in which all of @widget's drawing will 2234 * happen. Other toolkits call it the bounding box. 2235 * 2236 * Historically, in GTK+ the clip area has been equal to the allocation 2237 * retrieved via gtk_widget_get_allocation(). 2238 * 2239 * Params: 2240 * clip = a pointer to a #GtkAllocation to copy to 2241 * 2242 * Since: 3.14 2243 */ 2244 public void getClip(out GtkAllocation clip) 2245 { 2246 gtk_widget_get_clip(gtkWidget, &clip); 2247 } 2248 2249 /** 2250 * Returns the clipboard object for the given selection to 2251 * be used with @widget. @widget must have a #GdkDisplay 2252 * associated with it, so must be attached to a toplevel 2253 * window. 2254 * 2255 * Params: 2256 * selection = a #GdkAtom which identifies the clipboard 2257 * to use. %GDK_SELECTION_CLIPBOARD gives the 2258 * default clipboard. Another common value 2259 * is %GDK_SELECTION_PRIMARY, which gives 2260 * the primary X selection. 2261 * 2262 * Returns: the appropriate clipboard object. If no 2263 * clipboard already exists, a new one will 2264 * be created. Once a clipboard object has 2265 * been created, it is persistent for all time. 2266 * 2267 * Since: 2.2 2268 */ 2269 public Clipboard getClipboard(GdkAtom selection) 2270 { 2271 auto p = gtk_widget_get_clipboard(gtkWidget, selection); 2272 2273 if(p is null) 2274 { 2275 return null; 2276 } 2277 2278 return ObjectG.getDObject!(Clipboard)(cast(GtkClipboard*) p); 2279 } 2280 2281 /** 2282 * Obtains the composite name of a widget. 2283 * 2284 * Deprecated: Use gtk_widget_class_set_template(), or don’t use this API at all. 2285 * 2286 * Returns: the composite name of @widget, or %NULL if @widget is not 2287 * a composite child. The string should be freed when it is no 2288 * longer needed. 2289 */ 2290 public string getCompositeName() 2291 { 2292 auto retStr = gtk_widget_get_composite_name(gtkWidget); 2293 2294 scope(exit) Str.freeString(retStr); 2295 return Str.toString(retStr); 2296 } 2297 2298 /** 2299 * Returns whether @device can interact with @widget and its 2300 * children. See gtk_widget_set_device_enabled(). 2301 * 2302 * Params: 2303 * device = a #GdkDevice 2304 * 2305 * Returns: %TRUE is @device is enabled for @widget 2306 * 2307 * Since: 3.0 2308 */ 2309 public bool getDeviceEnabled(Device device) 2310 { 2311 return gtk_widget_get_device_enabled(gtkWidget, (device is null) ? null : device.getDeviceStruct()) != 0; 2312 } 2313 2314 /** 2315 * Returns the events mask for the widget corresponding to an specific device. These 2316 * are the events that the widget will receive when @device operates on it. 2317 * 2318 * Params: 2319 * device = a #GdkDevice 2320 * 2321 * Returns: device event mask for @widget 2322 * 2323 * Since: 3.0 2324 */ 2325 public GdkEventMask getDeviceEvents(Device device) 2326 { 2327 return gtk_widget_get_device_events(gtkWidget, (device is null) ? null : device.getDeviceStruct()); 2328 } 2329 2330 /** 2331 * Gets the reading direction for a particular widget. See 2332 * gtk_widget_set_direction(). 2333 * 2334 * Returns: the reading direction for the widget. 2335 */ 2336 public GtkTextDirection getDirection() 2337 { 2338 return gtk_widget_get_direction(gtkWidget); 2339 } 2340 2341 /** 2342 * Get the #GdkDisplay for the toplevel window associated with 2343 * this widget. This function can only be called after the widget 2344 * has been added to a widget hierarchy with a #GtkWindow at the top. 2345 * 2346 * In general, you should only create display specific 2347 * resources when a widget has been realized, and you should 2348 * free those resources when the widget is unrealized. 2349 * 2350 * Returns: the #GdkDisplay for the toplevel for this widget. 2351 * 2352 * Since: 2.2 2353 */ 2354 public Display getDisplay() 2355 { 2356 auto p = gtk_widget_get_display(gtkWidget); 2357 2358 if(p is null) 2359 { 2360 return null; 2361 } 2362 2363 return ObjectG.getDObject!(Display)(cast(GdkDisplay*) p); 2364 } 2365 2366 /** 2367 * Determines whether the widget is double buffered. 2368 * 2369 * See gtk_widget_set_double_buffered() 2370 * 2371 * Returns: %TRUE if the widget is double buffered 2372 * 2373 * Since: 2.18 2374 */ 2375 public bool getDoubleBuffered() 2376 { 2377 return gtk_widget_get_double_buffered(gtkWidget) != 0; 2378 } 2379 2380 /** 2381 * Returns the event mask (see #GdkEventMask) for the widget. These are the 2382 * events that the widget will receive. 2383 * 2384 * Note: Internally, the widget event mask will be the logical OR of the event 2385 * mask set through gtk_widget_set_events() or gtk_widget_add_events(), and the 2386 * event mask necessary to cater for every #GtkEventController created for the 2387 * widget. 2388 * 2389 * Returns: event mask for @widget 2390 */ 2391 public int getEvents() 2392 { 2393 return gtk_widget_get_events(gtkWidget); 2394 } 2395 2396 /** 2397 * Returns whether the widget should grab focus when it is clicked with the mouse. 2398 * See gtk_widget_set_focus_on_click(). 2399 * 2400 * Returns: %TRUE if the widget should grab focus when it is clicked with 2401 * the mouse. 2402 * 2403 * Since: 3.20 2404 */ 2405 public bool getFocusOnClick() 2406 { 2407 return gtk_widget_get_focus_on_click(gtkWidget) != 0; 2408 } 2409 2410 /** 2411 * Gets the font map that has been set with gtk_widget_set_font_map(). 2412 * 2413 * Returns: A #PangoFontMap, or %NULL 2414 * 2415 * Since: 3.18 2416 */ 2417 public PgFontMap getFontMap() 2418 { 2419 auto p = gtk_widget_get_font_map(gtkWidget); 2420 2421 if(p is null) 2422 { 2423 return null; 2424 } 2425 2426 return ObjectG.getDObject!(PgFontMap)(cast(PangoFontMap*) p); 2427 } 2428 2429 /** 2430 * Returns the #cairo_font_options_t used for Pango rendering. When not set, 2431 * the defaults font options for the #GdkScreen will be used. 2432 * 2433 * Returns: the #cairo_font_options_t or %NULL if not set 2434 * 2435 * Since: 3.18 2436 */ 2437 public FontOption getFontOptions() 2438 { 2439 auto p = gtk_widget_get_font_options(gtkWidget); 2440 2441 if(p is null) 2442 { 2443 return null; 2444 } 2445 2446 return new FontOption(cast(cairo_font_options_t*) p); 2447 } 2448 2449 /** 2450 * Obtains the frame clock for a widget. The frame clock is a global 2451 * “ticker” that can be used to drive animations and repaints. The 2452 * most common reason to get the frame clock is to call 2453 * gdk_frame_clock_get_frame_time(), in order to get a time to use for 2454 * animating. For example you might record the start of the animation 2455 * with an initial value from gdk_frame_clock_get_frame_time(), and 2456 * then update the animation by calling 2457 * gdk_frame_clock_get_frame_time() again during each repaint. 2458 * 2459 * gdk_frame_clock_request_phase() will result in a new frame on the 2460 * clock, but won’t necessarily repaint any widgets. To repaint a 2461 * widget, you have to use gtk_widget_queue_draw() which invalidates 2462 * the widget (thus scheduling it to receive a draw on the next 2463 * frame). gtk_widget_queue_draw() will also end up requesting a frame 2464 * on the appropriate frame clock. 2465 * 2466 * A widget’s frame clock will not change while the widget is 2467 * mapped. Reparenting a widget (which implies a temporary unmap) can 2468 * change the widget’s frame clock. 2469 * 2470 * Unrealized widgets do not have a frame clock. 2471 * 2472 * Returns: a #GdkFrameClock, 2473 * or %NULL if widget is unrealized 2474 * 2475 * Since: 3.8 2476 */ 2477 public FrameClock getFrameClock() 2478 { 2479 auto p = gtk_widget_get_frame_clock(gtkWidget); 2480 2481 if(p is null) 2482 { 2483 return null; 2484 } 2485 2486 return ObjectG.getDObject!(FrameClock)(cast(GdkFrameClock*) p); 2487 } 2488 2489 /** 2490 * Gets the value of the #GtkWidget:halign property. 2491 * 2492 * For backwards compatibility reasons this method will never return 2493 * %GTK_ALIGN_BASELINE, but instead it will convert it to 2494 * %GTK_ALIGN_FILL. Baselines are not supported for horizontal 2495 * alignment. 2496 * 2497 * Returns: the horizontal alignment of @widget 2498 */ 2499 public GtkAlign getHalign() 2500 { 2501 return gtk_widget_get_halign(gtkWidget); 2502 } 2503 2504 /** 2505 * Returns the current value of the has-tooltip property. See 2506 * #GtkWidget:has-tooltip for more information. 2507 * 2508 * Returns: current value of has-tooltip on @widget. 2509 * 2510 * Since: 2.12 2511 */ 2512 public bool getHasTooltip() 2513 { 2514 return gtk_widget_get_has_tooltip(gtkWidget) != 0; 2515 } 2516 2517 /** 2518 * Determines whether @widget has a #GdkWindow of its own. See 2519 * gtk_widget_set_has_window(). 2520 * 2521 * Returns: %TRUE if @widget has a window, %FALSE otherwise 2522 * 2523 * Since: 2.18 2524 */ 2525 public bool getHasWindow() 2526 { 2527 return gtk_widget_get_has_window(gtkWidget) != 0; 2528 } 2529 2530 /** 2531 * Gets whether the widget would like any available extra horizontal 2532 * space. When a user resizes a #GtkWindow, widgets with expand=TRUE 2533 * generally receive the extra space. For example, a list or 2534 * scrollable area or document in your window would often be set to 2535 * expand. 2536 * 2537 * Containers should use gtk_widget_compute_expand() rather than 2538 * this function, to see whether a widget, or any of its children, 2539 * has the expand flag set. If any child of a widget wants to 2540 * expand, the parent may ask to expand also. 2541 * 2542 * This function only looks at the widget’s own hexpand flag, rather 2543 * than computing whether the entire widget tree rooted at this widget 2544 * wants to expand. 2545 * 2546 * Returns: whether hexpand flag is set 2547 */ 2548 public bool getHexpand() 2549 { 2550 return gtk_widget_get_hexpand(gtkWidget) != 0; 2551 } 2552 2553 /** 2554 * Gets whether gtk_widget_set_hexpand() has been used to 2555 * explicitly set the expand flag on this widget. 2556 * 2557 * If hexpand is set, then it overrides any computed 2558 * expand value based on child widgets. If hexpand is not 2559 * set, then the expand value depends on whether any 2560 * children of the widget would like to expand. 2561 * 2562 * There are few reasons to use this function, but it’s here 2563 * for completeness and consistency. 2564 * 2565 * Returns: whether hexpand has been explicitly set 2566 */ 2567 public bool getHexpandSet() 2568 { 2569 return gtk_widget_get_hexpand_set(gtkWidget) != 0; 2570 } 2571 2572 /** 2573 * Whether the widget is mapped. 2574 * 2575 * Returns: %TRUE if the widget is mapped, %FALSE otherwise. 2576 * 2577 * Since: 2.20 2578 */ 2579 public bool getMapped() 2580 { 2581 return gtk_widget_get_mapped(gtkWidget) != 0; 2582 } 2583 2584 /** 2585 * Gets the value of the #GtkWidget:margin-bottom property. 2586 * 2587 * Returns: The bottom margin of @widget 2588 * 2589 * Since: 3.0 2590 */ 2591 public int getMarginBottom() 2592 { 2593 return gtk_widget_get_margin_bottom(gtkWidget); 2594 } 2595 2596 /** 2597 * Gets the value of the #GtkWidget:margin-end property. 2598 * 2599 * Returns: The end margin of @widget 2600 * 2601 * Since: 3.12 2602 */ 2603 public int getMarginEnd() 2604 { 2605 return gtk_widget_get_margin_end(gtkWidget); 2606 } 2607 2608 /** 2609 * Gets the value of the #GtkWidget:margin-left property. 2610 * 2611 * Deprecated: Use gtk_widget_get_margin_start() instead. 2612 * 2613 * Returns: The left margin of @widget 2614 * 2615 * Since: 3.0 2616 */ 2617 public int getMarginLeft() 2618 { 2619 return gtk_widget_get_margin_left(gtkWidget); 2620 } 2621 2622 /** 2623 * Gets the value of the #GtkWidget:margin-right property. 2624 * 2625 * Deprecated: Use gtk_widget_get_margin_end() instead. 2626 * 2627 * Returns: The right margin of @widget 2628 * 2629 * Since: 3.0 2630 */ 2631 public int getMarginRight() 2632 { 2633 return gtk_widget_get_margin_right(gtkWidget); 2634 } 2635 2636 /** 2637 * Gets the value of the #GtkWidget:margin-start property. 2638 * 2639 * Returns: The start margin of @widget 2640 * 2641 * Since: 3.12 2642 */ 2643 public int getMarginStart() 2644 { 2645 return gtk_widget_get_margin_start(gtkWidget); 2646 } 2647 2648 /** 2649 * Gets the value of the #GtkWidget:margin-top property. 2650 * 2651 * Returns: The top margin of @widget 2652 * 2653 * Since: 3.0 2654 */ 2655 public int getMarginTop() 2656 { 2657 return gtk_widget_get_margin_top(gtkWidget); 2658 } 2659 2660 /** 2661 * Returns the modifier mask the @widget’s windowing system backend 2662 * uses for a particular purpose. 2663 * 2664 * See gdk_keymap_get_modifier_mask(). 2665 * 2666 * Params: 2667 * intent = the use case for the modifier mask 2668 * 2669 * Returns: the modifier mask used for @intent. 2670 * 2671 * Since: 3.4 2672 */ 2673 public GdkModifierType getModifierMask(GdkModifierIntent intent) 2674 { 2675 return gtk_widget_get_modifier_mask(gtkWidget, intent); 2676 } 2677 2678 /** 2679 * Returns the current modifier style for the widget. (As set by 2680 * gtk_widget_modify_style().) If no style has previously set, a new 2681 * #GtkRcStyle will be created with all values unset, and set as the 2682 * modifier style for the widget. If you make changes to this rc 2683 * style, you must call gtk_widget_modify_style(), passing in the 2684 * returned rc style, to make sure that your changes take effect. 2685 * 2686 * Caution: passing the style back to gtk_widget_modify_style() will 2687 * normally end up destroying it, because gtk_widget_modify_style() copies 2688 * the passed-in style and sets the copy as the new modifier style, 2689 * thus dropping any reference to the old modifier style. Add a reference 2690 * to the modifier style if you want to keep it alive. 2691 * 2692 * Deprecated: Use #GtkStyleContext with a custom #GtkStyleProvider instead 2693 * 2694 * Returns: the modifier style for the widget. 2695 * This rc style is owned by the widget. If you want to keep a 2696 * pointer to value this around, you must add a refcount using 2697 * g_object_ref(). 2698 */ 2699 public RcStyle getModifierStyle() 2700 { 2701 auto p = gtk_widget_get_modifier_style(gtkWidget); 2702 2703 if(p is null) 2704 { 2705 return null; 2706 } 2707 2708 return ObjectG.getDObject!(RcStyle)(cast(GtkRcStyle*) p); 2709 } 2710 2711 /** 2712 * Retrieves the name of a widget. See gtk_widget_set_name() for the 2713 * significance of widget names. 2714 * 2715 * Returns: name of the widget. This string is owned by GTK+ and 2716 * should not be modified or freed 2717 */ 2718 public string getName() 2719 { 2720 return Str.toString(gtk_widget_get_name(gtkWidget)); 2721 } 2722 2723 /** 2724 * Returns the current value of the #GtkWidget:no-show-all property, 2725 * which determines whether calls to gtk_widget_show_all() 2726 * will affect this widget. 2727 * 2728 * Returns: the current value of the “no-show-all” property. 2729 * 2730 * Since: 2.4 2731 */ 2732 public bool getNoShowAll() 2733 { 2734 return gtk_widget_get_no_show_all(gtkWidget) != 0; 2735 } 2736 2737 /** 2738 * Fetches the requested opacity for this widget. 2739 * See gtk_widget_set_opacity(). 2740 * 2741 * Returns: the requested opacity for this widget. 2742 * 2743 * Since: 3.8 2744 */ 2745 public double getOpacity() 2746 { 2747 return gtk_widget_get_opacity(gtkWidget); 2748 } 2749 2750 /** 2751 * Gets a #PangoContext with the appropriate font map, font description, 2752 * and base direction for this widget. Unlike the context returned 2753 * by gtk_widget_create_pango_context(), this context is owned by 2754 * the widget (it can be used until the screen for the widget changes 2755 * or the widget is removed from its toplevel), and will be updated to 2756 * match any changes to the widget’s attributes. This can be tracked 2757 * by using the #GtkWidget::screen-changed signal on the widget. 2758 * 2759 * Returns: the #PangoContext for the widget. 2760 */ 2761 public PgContext getPangoContext() 2762 { 2763 auto p = gtk_widget_get_pango_context(gtkWidget); 2764 2765 if(p is null) 2766 { 2767 return null; 2768 } 2769 2770 return ObjectG.getDObject!(PgContext)(cast(PangoContext*) p); 2771 } 2772 2773 /** 2774 * Returns the parent container of @widget. 2775 * 2776 * Returns: the parent container of @widget, or %NULL 2777 */ 2778 public Widget getParent() 2779 { 2780 auto p = gtk_widget_get_parent(gtkWidget); 2781 2782 if(p is null) 2783 { 2784 return null; 2785 } 2786 2787 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 2788 } 2789 2790 /** 2791 * Gets @widget’s parent window, or %NULL if it does not have one. 2792 * 2793 * Returns: the parent window of @widget, or %NULL 2794 * if it does not have a parent window. 2795 */ 2796 public GdkWin getParentWindow() 2797 { 2798 auto p = gtk_widget_get_parent_window(gtkWidget); 2799 2800 if(p is null) 2801 { 2802 return null; 2803 } 2804 2805 return ObjectG.getDObject!(GdkWin)(cast(GdkWindow*) p); 2806 } 2807 2808 /** 2809 * Returns the #GtkWidgetPath representing @widget, if the widget 2810 * is not connected to a toplevel widget, a partial path will be 2811 * created. 2812 * 2813 * Returns: The #GtkWidgetPath representing @widget 2814 */ 2815 public WidgetPath getPath() 2816 { 2817 auto p = gtk_widget_get_path(gtkWidget); 2818 2819 if(p is null) 2820 { 2821 return null; 2822 } 2823 2824 return ObjectG.getDObject!(WidgetPath)(cast(GtkWidgetPath*) p); 2825 } 2826 2827 /** 2828 * Obtains the location of the mouse pointer in widget coordinates. 2829 * Widget coordinates are a bit odd; for historical reasons, they are 2830 * defined as @widget->window coordinates for widgets that return %TRUE for 2831 * gtk_widget_get_has_window(); and are relative to @widget->allocation.x, 2832 * @widget->allocation.y otherwise. 2833 * 2834 * Deprecated: Use gdk_window_get_device_position() instead. 2835 * 2836 * Params: 2837 * x = return location for the X coordinate, or %NULL 2838 * y = return location for the Y coordinate, or %NULL 2839 */ 2840 public void getPointer(out int x, out int y) 2841 { 2842 gtk_widget_get_pointer(gtkWidget, &x, &y); 2843 } 2844 2845 /** 2846 * Retrieves a widget’s initial minimum and natural height. 2847 * 2848 * This call is specific to width-for-height requests. 2849 * 2850 * The returned request will be modified by the 2851 * GtkWidgetClass::adjust_size_request virtual method and by any 2852 * #GtkSizeGroups that have been applied. That is, the returned request 2853 * is the one that should be used for layout, not necessarily the one 2854 * returned by the widget itself. 2855 * 2856 * Params: 2857 * minimumHeight = location to store the minimum height, or %NULL 2858 * naturalHeight = location to store the natural height, or %NULL 2859 * 2860 * Since: 3.0 2861 */ 2862 public void getPreferredHeight(out int minimumHeight, out int naturalHeight) 2863 { 2864 gtk_widget_get_preferred_height(gtkWidget, &minimumHeight, &naturalHeight); 2865 } 2866 2867 /** 2868 * Retrieves a widget’s minimum and natural height and the corresponding baselines if it would be given 2869 * the specified @width, or the default height if @width is -1. The baselines may be -1 which means 2870 * that no baseline is requested for this widget. 2871 * 2872 * The returned request will be modified by the 2873 * GtkWidgetClass::adjust_size_request and GtkWidgetClass::adjust_baseline_request virtual methods 2874 * and by any #GtkSizeGroups that have been applied. That is, the returned request 2875 * is the one that should be used for layout, not necessarily the one 2876 * returned by the widget itself. 2877 * 2878 * Params: 2879 * width = the width which is available for allocation, or -1 if none 2880 * minimumHeight = location for storing the minimum height, or %NULL 2881 * naturalHeight = location for storing the natural height, or %NULL 2882 * minimumBaseline = location for storing the baseline for the minimum height, or %NULL 2883 * naturalBaseline = location for storing the baseline for the natural height, or %NULL 2884 * 2885 * Since: 3.10 2886 */ 2887 public void getPreferredHeightAndBaselineForWidth(int width, out int minimumHeight, out int naturalHeight, out int minimumBaseline, out int naturalBaseline) 2888 { 2889 gtk_widget_get_preferred_height_and_baseline_for_width(gtkWidget, width, &minimumHeight, &naturalHeight, &minimumBaseline, &naturalBaseline); 2890 } 2891 2892 /** 2893 * Retrieves a widget’s minimum and natural height if it would be given 2894 * the specified @width. 2895 * 2896 * The returned request will be modified by the 2897 * GtkWidgetClass::adjust_size_request virtual method and by any 2898 * #GtkSizeGroups that have been applied. That is, the returned request 2899 * is the one that should be used for layout, not necessarily the one 2900 * returned by the widget itself. 2901 * 2902 * Params: 2903 * width = the width which is available for allocation 2904 * minimumHeight = location for storing the minimum height, or %NULL 2905 * naturalHeight = location for storing the natural height, or %NULL 2906 * 2907 * Since: 3.0 2908 */ 2909 public void getPreferredHeightForWidth(int width, out int minimumHeight, out int naturalHeight) 2910 { 2911 gtk_widget_get_preferred_height_for_width(gtkWidget, width, &minimumHeight, &naturalHeight); 2912 } 2913 2914 /** 2915 * Retrieves the minimum and natural size of a widget, taking 2916 * into account the widget’s preference for height-for-width management. 2917 * 2918 * This is used to retrieve a suitable size by container widgets which do 2919 * not impose any restrictions on the child placement. It can be used 2920 * to deduce toplevel window and menu sizes as well as child widgets in 2921 * free-form containers such as GtkLayout. 2922 * 2923 * Handle with care. Note that the natural height of a height-for-width 2924 * widget will generally be a smaller size than the minimum height, since the required 2925 * height for the natural width is generally smaller than the required height for 2926 * the minimum width. 2927 * 2928 * Use gtk_widget_get_preferred_height_and_baseline_for_width() if you want to support 2929 * baseline alignment. 2930 * 2931 * Params: 2932 * minimumSize = location for storing the minimum size, or %NULL 2933 * naturalSize = location for storing the natural size, or %NULL 2934 * 2935 * Since: 3.0 2936 */ 2937 public void getPreferredSize(out Requisition minimumSize, out Requisition naturalSize) 2938 { 2939 GtkRequisition* outminimumSize = sliceNew!GtkRequisition(); 2940 GtkRequisition* outnaturalSize = sliceNew!GtkRequisition(); 2941 2942 gtk_widget_get_preferred_size(gtkWidget, outminimumSize, outnaturalSize); 2943 2944 minimumSize = ObjectG.getDObject!(Requisition)(outminimumSize, true); 2945 naturalSize = ObjectG.getDObject!(Requisition)(outnaturalSize, true); 2946 } 2947 2948 /** 2949 * Retrieves a widget’s initial minimum and natural width. 2950 * 2951 * This call is specific to height-for-width requests. 2952 * 2953 * The returned request will be modified by the 2954 * GtkWidgetClass::adjust_size_request virtual method and by any 2955 * #GtkSizeGroups that have been applied. That is, the returned request 2956 * is the one that should be used for layout, not necessarily the one 2957 * returned by the widget itself. 2958 * 2959 * Params: 2960 * minimumWidth = location to store the minimum width, or %NULL 2961 * naturalWidth = location to store the natural width, or %NULL 2962 * 2963 * Since: 3.0 2964 */ 2965 public void getPreferredWidth(out int minimumWidth, out int naturalWidth) 2966 { 2967 gtk_widget_get_preferred_width(gtkWidget, &minimumWidth, &naturalWidth); 2968 } 2969 2970 /** 2971 * Retrieves a widget’s minimum and natural width if it would be given 2972 * the specified @height. 2973 * 2974 * The returned request will be modified by the 2975 * GtkWidgetClass::adjust_size_request virtual method and by any 2976 * #GtkSizeGroups that have been applied. That is, the returned request 2977 * is the one that should be used for layout, not necessarily the one 2978 * returned by the widget itself. 2979 * 2980 * Params: 2981 * height = the height which is available for allocation 2982 * minimumWidth = location for storing the minimum width, or %NULL 2983 * naturalWidth = location for storing the natural width, or %NULL 2984 * 2985 * Since: 3.0 2986 */ 2987 public void getPreferredWidthForHeight(int height, out int minimumWidth, out int naturalWidth) 2988 { 2989 gtk_widget_get_preferred_width_for_height(gtkWidget, height, &minimumWidth, &naturalWidth); 2990 } 2991 2992 /** 2993 * Determines whether @widget is realized. 2994 * 2995 * Returns: %TRUE if @widget is realized, %FALSE otherwise 2996 * 2997 * Since: 2.20 2998 */ 2999 public bool getRealized() 3000 { 3001 return gtk_widget_get_realized(gtkWidget) != 0; 3002 } 3003 3004 /** 3005 * Determines whether @widget is always treated as the default widget 3006 * within its toplevel when it has the focus, even if another widget 3007 * is the default. 3008 * 3009 * See gtk_widget_set_receives_default(). 3010 * 3011 * Returns: %TRUE if @widget acts as the default widget when focused, 3012 * %FALSE otherwise 3013 * 3014 * Since: 2.18 3015 */ 3016 public bool getReceivesDefault() 3017 { 3018 return gtk_widget_get_receives_default(gtkWidget) != 0; 3019 } 3020 3021 /** 3022 * Gets whether the widget prefers a height-for-width layout 3023 * or a width-for-height layout. 3024 * 3025 * #GtkBin widgets generally propagate the preference of 3026 * their child, container widgets need to request something either in 3027 * context of their children or in context of their allocation 3028 * capabilities. 3029 * 3030 * Returns: The #GtkSizeRequestMode preferred by @widget. 3031 * 3032 * Since: 3.0 3033 */ 3034 public GtkSizeRequestMode getRequestMode() 3035 { 3036 return gtk_widget_get_request_mode(gtkWidget); 3037 } 3038 3039 /** 3040 * Retrieves the widget’s requisition. 3041 * 3042 * This function should only be used by widget implementations in 3043 * order to figure whether the widget’s requisition has actually 3044 * changed after some internal state change (so that they can call 3045 * gtk_widget_queue_resize() instead of gtk_widget_queue_draw()). 3046 * 3047 * Normally, gtk_widget_size_request() should be used. 3048 * 3049 * Deprecated: The #GtkRequisition cache on the widget was 3050 * removed, If you need to cache sizes across requests and allocations, 3051 * add an explicit cache to the widget in question instead. 3052 * 3053 * Params: 3054 * requisition = a pointer to a #GtkRequisition to copy to 3055 * 3056 * Since: 2.20 3057 */ 3058 public void getRequisition(out Requisition requisition) 3059 { 3060 GtkRequisition* outrequisition = sliceNew!GtkRequisition(); 3061 3062 gtk_widget_get_requisition(gtkWidget, outrequisition); 3063 3064 requisition = ObjectG.getDObject!(Requisition)(outrequisition, true); 3065 } 3066 3067 /** 3068 * Get the root window where this widget is located. This function can 3069 * only be called after the widget has been added to a widget 3070 * hierarchy with #GtkWindow at the top. 3071 * 3072 * The root window is useful for such purposes as creating a popup 3073 * #GdkWindow associated with the window. In general, you should only 3074 * create display specific resources when a widget has been realized, 3075 * and you should free those resources when the widget is unrealized. 3076 * 3077 * Deprecated: Use gdk_screen_get_root_window() instead 3078 * 3079 * Returns: the #GdkWindow root window for the toplevel for this widget. 3080 * 3081 * Since: 2.2 3082 */ 3083 public GdkWin getRootWindow() 3084 { 3085 auto p = gtk_widget_get_root_window(gtkWidget); 3086 3087 if(p is null) 3088 { 3089 return null; 3090 } 3091 3092 return ObjectG.getDObject!(GdkWin)(cast(GdkWindow*) p); 3093 } 3094 3095 /** 3096 * Retrieves the internal scale factor that maps from window coordinates 3097 * to the actual device pixels. On traditional systems this is 1, on 3098 * high density outputs, it can be a higher value (typically 2). 3099 * 3100 * See gdk_window_get_scale_factor(). 3101 * 3102 * Returns: the scale factor for @widget 3103 * 3104 * Since: 3.10 3105 */ 3106 public int getScaleFactor() 3107 { 3108 return gtk_widget_get_scale_factor(gtkWidget); 3109 } 3110 3111 /** 3112 * Get the #GdkScreen from the toplevel window associated with 3113 * this widget. This function can only be called after the widget 3114 * has been added to a widget hierarchy with a #GtkWindow 3115 * at the top. 3116 * 3117 * In general, you should only create screen specific 3118 * resources when a widget has been realized, and you should 3119 * free those resources when the widget is unrealized. 3120 * 3121 * Returns: the #GdkScreen for the toplevel for this widget. 3122 * 3123 * Since: 2.2 3124 */ 3125 public Screen getScreen() 3126 { 3127 auto p = gtk_widget_get_screen(gtkWidget); 3128 3129 if(p is null) 3130 { 3131 return null; 3132 } 3133 3134 return ObjectG.getDObject!(Screen)(cast(GdkScreen*) p); 3135 } 3136 3137 /** 3138 * Returns the widget’s sensitivity (in the sense of returning 3139 * the value that has been set using gtk_widget_set_sensitive()). 3140 * 3141 * The effective sensitivity of a widget is however determined by both its 3142 * own and its parent widget’s sensitivity. See gtk_widget_is_sensitive(). 3143 * 3144 * Returns: %TRUE if the widget is sensitive 3145 * 3146 * Since: 2.18 3147 */ 3148 public bool getSensitive() 3149 { 3150 return gtk_widget_get_sensitive(gtkWidget) != 0; 3151 } 3152 3153 /** 3154 * Gets the settings object holding the settings used for this widget. 3155 * 3156 * Note that this function can only be called when the #GtkWidget 3157 * is attached to a toplevel, since the settings object is specific 3158 * to a particular #GdkScreen. 3159 * 3160 * Returns: the relevant #GtkSettings object 3161 */ 3162 public Settings getSettings() 3163 { 3164 auto p = gtk_widget_get_settings(gtkWidget); 3165 3166 if(p is null) 3167 { 3168 return null; 3169 } 3170 3171 return ObjectG.getDObject!(Settings)(cast(GtkSettings*) p); 3172 } 3173 3174 /** 3175 * Gets the size request that was explicitly set for the widget using 3176 * gtk_widget_set_size_request(). A value of -1 stored in @width or 3177 * @height indicates that that dimension has not been set explicitly 3178 * and the natural requisition of the widget will be used instead. See 3179 * gtk_widget_set_size_request(). To get the size a widget will 3180 * actually request, call gtk_widget_get_preferred_size() instead of 3181 * this function. 3182 * 3183 * Params: 3184 * width = return location for width, or %NULL 3185 * height = return location for height, or %NULL 3186 */ 3187 public void getSizeRequest(out int width, out int height) 3188 { 3189 gtk_widget_get_size_request(gtkWidget, &width, &height); 3190 } 3191 3192 /** 3193 * Returns the widget state as a flag set. It is worth mentioning 3194 * that the effective %GTK_STATE_FLAG_INSENSITIVE state will be 3195 * returned, that is, also based on parent insensitivity, even if 3196 * @widget itself is sensitive. 3197 * 3198 * Also note that if you are looking for a way to obtain the 3199 * #GtkStateFlags to pass to a #GtkStyleContext method, you 3200 * should look at gtk_style_context_get_state(). 3201 * 3202 * Returns: The state flags for widget 3203 * 3204 * Since: 3.0 3205 */ 3206 public GtkStateFlags getStateFlags() 3207 { 3208 return gtk_widget_get_state_flags(gtkWidget); 3209 } 3210 3211 /** 3212 * Simply an accessor function that returns @widget->style. 3213 * 3214 * Deprecated: Use #GtkStyleContext instead 3215 * 3216 * Returns: the widget’s #GtkStyle 3217 */ 3218 public Style getStyle() 3219 { 3220 auto p = gtk_widget_get_style(gtkWidget); 3221 3222 if(p is null) 3223 { 3224 return null; 3225 } 3226 3227 return ObjectG.getDObject!(Style)(cast(GtkStyle*) p); 3228 } 3229 3230 /** 3231 * Returns the style context associated to @widget. The returned object is 3232 * guaranteed to be the same for the lifetime of @widget. 3233 * 3234 * Returns: a #GtkStyleContext. This memory is owned by @widget and 3235 * must not be freed. 3236 */ 3237 public StyleContext getStyleContext() 3238 { 3239 auto p = gtk_widget_get_style_context(gtkWidget); 3240 3241 if(p is null) 3242 { 3243 return null; 3244 } 3245 3246 return ObjectG.getDObject!(StyleContext)(cast(GtkStyleContext*) p); 3247 } 3248 3249 /** 3250 * Returns %TRUE if @widget is multiple pointer aware. See 3251 * gtk_widget_set_support_multidevice() for more information. 3252 * 3253 * Returns: %TRUE if @widget is multidevice aware. 3254 */ 3255 public bool getSupportMultidevice() 3256 { 3257 return gtk_widget_get_support_multidevice(gtkWidget) != 0; 3258 } 3259 3260 /** 3261 * Fetch an object build from the template XML for @widget_type in this @widget instance. 3262 * 3263 * This will only report children which were previously declared with 3264 * gtk_widget_class_bind_template_child_full() or one of its 3265 * variants. 3266 * 3267 * This function is only meant to be called for code which is private to the @widget_type which 3268 * declared the child and is meant for language bindings which cannot easily make use 3269 * of the GObject structure offsets. 3270 * 3271 * Params: 3272 * widgetType = The #GType to get a template child for 3273 * name = The “id” of the child defined in the template XML 3274 * 3275 * Returns: The object built in the template XML with the id @name 3276 */ 3277 public ObjectG getTemplateChild(GType widgetType, string name) 3278 { 3279 auto p = gtk_widget_get_template_child(gtkWidget, widgetType, Str.toStringz(name)); 3280 3281 if(p is null) 3282 { 3283 return null; 3284 } 3285 3286 return ObjectG.getDObject!(ObjectG)(cast(GObject*) p); 3287 } 3288 3289 /** 3290 * Gets the contents of the tooltip for @widget. 3291 * 3292 * Returns: the tooltip text, or %NULL. You should free the 3293 * returned string with g_free() when done. 3294 * 3295 * Since: 2.12 3296 */ 3297 public string getTooltipMarkup() 3298 { 3299 auto retStr = gtk_widget_get_tooltip_markup(gtkWidget); 3300 3301 scope(exit) Str.freeString(retStr); 3302 return Str.toString(retStr); 3303 } 3304 3305 /** 3306 * Gets the contents of the tooltip for @widget. 3307 * 3308 * Returns: the tooltip text, or %NULL. You should free the 3309 * returned string with g_free() when done. 3310 * 3311 * Since: 2.12 3312 */ 3313 public string getTooltipText() 3314 { 3315 auto retStr = gtk_widget_get_tooltip_text(gtkWidget); 3316 3317 scope(exit) Str.freeString(retStr); 3318 return Str.toString(retStr); 3319 } 3320 3321 /** 3322 * Returns the #GtkWindow of the current tooltip. This can be the 3323 * GtkWindow created by default, or the custom tooltip window set 3324 * using gtk_widget_set_tooltip_window(). 3325 * 3326 * Returns: The #GtkWindow of the current tooltip. 3327 * 3328 * Since: 2.12 3329 */ 3330 public Window getTooltipWindow() 3331 { 3332 auto p = gtk_widget_get_tooltip_window(gtkWidget); 3333 3334 if(p is null) 3335 { 3336 return null; 3337 } 3338 3339 return ObjectG.getDObject!(Window)(cast(GtkWindow*) p); 3340 } 3341 3342 /** 3343 * This function returns the topmost widget in the container hierarchy 3344 * @widget is a part of. If @widget has no parent widgets, it will be 3345 * returned as the topmost widget. No reference will be added to the 3346 * returned widget; it should not be unreferenced. 3347 * 3348 * Note the difference in behavior vs. gtk_widget_get_ancestor(); 3349 * `gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW)` 3350 * would return 3351 * %NULL if @widget wasn’t inside a toplevel window, and if the 3352 * window was inside a #GtkWindow-derived widget which was in turn 3353 * inside the toplevel #GtkWindow. While the second case may 3354 * seem unlikely, it actually happens when a #GtkPlug is embedded 3355 * inside a #GtkSocket within the same application. 3356 * 3357 * To reliably find the toplevel #GtkWindow, use 3358 * gtk_widget_get_toplevel() and call GTK_IS_WINDOW() 3359 * on the result. For instance, to get the title of a widget's toplevel 3360 * window, one might use: 3361 * |[<!-- language="C" --> 3362 * static const char * 3363 * get_widget_toplevel_title (GtkWidget *widget) 3364 * { 3365 * GtkWidget *toplevel = gtk_widget_get_toplevel (widget); 3366 * if (GTK_IS_WINDOW (toplevel)) 3367 * { 3368 * return gtk_window_get_title (GTK_WINDOW (toplevel)); 3369 * } 3370 * 3371 * return NULL; 3372 * } 3373 * ]| 3374 * 3375 * Returns: the topmost ancestor of @widget, or @widget itself 3376 * if there’s no ancestor. 3377 */ 3378 public Widget getToplevel() 3379 { 3380 auto p = gtk_widget_get_toplevel(gtkWidget); 3381 3382 if(p is null) 3383 { 3384 return null; 3385 } 3386 3387 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 3388 } 3389 3390 /** 3391 * Gets the value of the #GtkWidget:valign property. 3392 * 3393 * For backwards compatibility reasons this method will never return 3394 * %GTK_ALIGN_BASELINE, but instead it will convert it to 3395 * %GTK_ALIGN_FILL. If your widget want to support baseline aligned 3396 * children it must use gtk_widget_get_valign_with_baseline(), or 3397 * `g_object_get (widget, "valign", &value, NULL)`, which will 3398 * also report the true value. 3399 * 3400 * Returns: the vertical alignment of @widget, ignoring baseline alignment 3401 */ 3402 public GtkAlign getValign() 3403 { 3404 return gtk_widget_get_valign(gtkWidget); 3405 } 3406 3407 /** 3408 * Gets the value of the #GtkWidget:valign property, including 3409 * %GTK_ALIGN_BASELINE. 3410 * 3411 * Returns: the vertical alignment of @widget 3412 * 3413 * Since: 3.10 3414 */ 3415 public GtkAlign getValignWithBaseline() 3416 { 3417 return gtk_widget_get_valign_with_baseline(gtkWidget); 3418 } 3419 3420 /** 3421 * Gets whether the widget would like any available extra vertical 3422 * space. 3423 * 3424 * See gtk_widget_get_hexpand() for more detail. 3425 * 3426 * Returns: whether vexpand flag is set 3427 */ 3428 public bool getVexpand() 3429 { 3430 return gtk_widget_get_vexpand(gtkWidget) != 0; 3431 } 3432 3433 /** 3434 * Gets whether gtk_widget_set_vexpand() has been used to 3435 * explicitly set the expand flag on this widget. 3436 * 3437 * See gtk_widget_get_hexpand_set() for more detail. 3438 * 3439 * Returns: whether vexpand has been explicitly set 3440 */ 3441 public bool getVexpandSet() 3442 { 3443 return gtk_widget_get_vexpand_set(gtkWidget) != 0; 3444 } 3445 3446 /** 3447 * Determines whether the widget is visible. If you want to 3448 * take into account whether the widget’s parent is also marked as 3449 * visible, use gtk_widget_is_visible() instead. 3450 * 3451 * This function does not check if the widget is obscured in any way. 3452 * 3453 * See gtk_widget_set_visible(). 3454 * 3455 * Returns: %TRUE if the widget is visible 3456 * 3457 * Since: 2.18 3458 */ 3459 public bool getVisible() 3460 { 3461 return gtk_widget_get_visible(gtkWidget) != 0; 3462 } 3463 3464 /** 3465 * Gets the visual that will be used to render @widget. 3466 * 3467 * Returns: the visual for @widget 3468 */ 3469 public Visual getVisual() 3470 { 3471 auto p = gtk_widget_get_visual(gtkWidget); 3472 3473 if(p is null) 3474 { 3475 return null; 3476 } 3477 3478 return ObjectG.getDObject!(Visual)(cast(GdkVisual*) p); 3479 } 3480 3481 /** 3482 * Returns the widget’s window if it is realized, %NULL otherwise 3483 * 3484 * Returns: @widget’s window. 3485 * 3486 * Since: 2.14 3487 */ 3488 public GdkWin getWindow() 3489 { 3490 auto p = gtk_widget_get_window(gtkWidget); 3491 3492 if(p is null) 3493 { 3494 return null; 3495 } 3496 3497 return ObjectG.getDObject!(GdkWin)(cast(GdkWindow*) p); 3498 } 3499 3500 /** 3501 * Makes @widget the current grabbed widget. 3502 * 3503 * This means that interaction with other widgets in the same 3504 * application is blocked and mouse as well as keyboard events 3505 * are delivered to this widget. 3506 * 3507 * If @widget is not sensitive, it is not set as the current 3508 * grabbed widget and this function does nothing. 3509 */ 3510 public void grabAdd() 3511 { 3512 gtk_grab_add(gtkWidget); 3513 } 3514 3515 /** 3516 * Causes @widget to become the default widget. @widget must be able to be 3517 * a default widget; typically you would ensure this yourself 3518 * by calling gtk_widget_set_can_default() with a %TRUE value. 3519 * The default widget is activated when 3520 * the user presses Enter in a window. Default widgets must be 3521 * activatable, that is, gtk_widget_activate() should affect them. Note 3522 * that #GtkEntry widgets require the “activates-default” property 3523 * set to %TRUE before they activate the default widget when Enter 3524 * is pressed and the #GtkEntry is focused. 3525 */ 3526 public void grabDefault() 3527 { 3528 gtk_widget_grab_default(gtkWidget); 3529 } 3530 3531 /** 3532 * Causes @widget to have the keyboard focus for the #GtkWindow it's 3533 * inside. @widget must be a focusable widget, such as a #GtkEntry; 3534 * something like #GtkFrame won’t work. 3535 * 3536 * More precisely, it must have the %GTK_CAN_FOCUS flag set. Use 3537 * gtk_widget_set_can_focus() to modify that flag. 3538 * 3539 * The widget also needs to be realized and mapped. This is indicated by the 3540 * related signals. Grabbing the focus immediately after creating the widget 3541 * will likely fail and cause critical warnings. 3542 */ 3543 public void grabFocus() 3544 { 3545 gtk_widget_grab_focus(gtkWidget); 3546 } 3547 3548 /** 3549 * Removes the grab from the given widget. 3550 * 3551 * You have to pair calls to gtk_grab_add() and gtk_grab_remove(). 3552 * 3553 * If @widget does not have the grab, this function does nothing. 3554 */ 3555 public void grabRemove() 3556 { 3557 gtk_grab_remove(gtkWidget); 3558 } 3559 3560 /** 3561 * Determines whether @widget is the current default widget within its 3562 * toplevel. See gtk_widget_set_can_default(). 3563 * 3564 * Returns: %TRUE if @widget is the current default widget within 3565 * its toplevel, %FALSE otherwise 3566 * 3567 * Since: 2.18 3568 */ 3569 public bool hasDefault() 3570 { 3571 return gtk_widget_has_default(gtkWidget) != 0; 3572 } 3573 3574 /** 3575 * Determines if the widget has the global input focus. See 3576 * gtk_widget_is_focus() for the difference between having the global 3577 * input focus, and only having the focus within a toplevel. 3578 * 3579 * Returns: %TRUE if the widget has the global input focus. 3580 * 3581 * Since: 2.18 3582 */ 3583 public bool hasFocus() 3584 { 3585 return gtk_widget_has_focus(gtkWidget) != 0; 3586 } 3587 3588 /** 3589 * Determines whether the widget is currently grabbing events, so it 3590 * is the only widget receiving input events (keyboard and mouse). 3591 * 3592 * See also gtk_grab_add(). 3593 * 3594 * Returns: %TRUE if the widget is in the grab_widgets stack 3595 * 3596 * Since: 2.18 3597 */ 3598 public bool hasGrab() 3599 { 3600 return gtk_widget_has_grab(gtkWidget) != 0; 3601 } 3602 3603 /** 3604 * Determines if the widget style has been looked up through the rc mechanism. 3605 * 3606 * Deprecated: Use #GtkStyleContext instead 3607 * 3608 * Returns: %TRUE if the widget has been looked up through the rc 3609 * mechanism, %FALSE otherwise. 3610 * 3611 * Since: 2.20 3612 */ 3613 public bool hasRcStyle() 3614 { 3615 return gtk_widget_has_rc_style(gtkWidget) != 0; 3616 } 3617 3618 /** 3619 * Checks whether there is a #GdkScreen is associated with 3620 * this widget. All toplevel widgets have an associated 3621 * screen, and all widgets added into a hierarchy with a toplevel 3622 * window at the top. 3623 * 3624 * Returns: %TRUE if there is a #GdkScreen associated 3625 * with the widget. 3626 * 3627 * Since: 2.2 3628 */ 3629 public bool hasScreen() 3630 { 3631 return gtk_widget_has_screen(gtkWidget) != 0; 3632 } 3633 3634 /** 3635 * Determines if the widget should show a visible indication that 3636 * it has the global input focus. This is a convenience function for 3637 * use in ::draw handlers that takes into account whether focus 3638 * indication should currently be shown in the toplevel window of 3639 * @widget. See gtk_window_get_focus_visible() for more information 3640 * about focus indication. 3641 * 3642 * To find out if the widget has the global input focus, use 3643 * gtk_widget_has_focus(). 3644 * 3645 * Returns: %TRUE if the widget should display a “focus rectangle” 3646 * 3647 * Since: 3.2 3648 */ 3649 public bool hasVisibleFocus() 3650 { 3651 return gtk_widget_has_visible_focus(gtkWidget) != 0; 3652 } 3653 3654 /** 3655 * Reverses the effects of gtk_widget_show(), causing the widget to be 3656 * hidden (invisible to the user). 3657 */ 3658 public void hide() 3659 { 3660 gtk_widget_hide(gtkWidget); 3661 } 3662 3663 /** 3664 * Utility function; intended to be connected to the #GtkWidget::delete-event 3665 * signal on a #GtkWindow. The function calls gtk_widget_hide() on its 3666 * argument, then returns %TRUE. If connected to ::delete-event, the 3667 * result is that clicking the close button for a window (on the 3668 * window frame, top right corner usually) will hide but not destroy 3669 * the window. By default, GTK+ destroys windows when ::delete-event 3670 * is received. 3671 * 3672 * Returns: %TRUE 3673 */ 3674 public bool hideOnDelete() 3675 { 3676 return gtk_widget_hide_on_delete(gtkWidget) != 0; 3677 } 3678 3679 /** 3680 * Returns whether the widget is currently being destroyed. 3681 * This information can sometimes be used to avoid doing 3682 * unnecessary work. 3683 * 3684 * Returns: %TRUE if @widget is being destroyed 3685 */ 3686 public bool inDestruction() 3687 { 3688 return gtk_widget_in_destruction(gtkWidget) != 0; 3689 } 3690 3691 /** 3692 * Creates and initializes child widgets defined in templates. This 3693 * function must be called in the instance initializer for any 3694 * class which assigned itself a template using gtk_widget_class_set_template() 3695 * 3696 * It is important to call this function in the instance initializer 3697 * of a #GtkWidget subclass and not in #GObject.constructed() or 3698 * #GObject.constructor() for two reasons. 3699 * 3700 * One reason is that generally derived widgets will assume that parent 3701 * class composite widgets have been created in their instance 3702 * initializers. 3703 * 3704 * Another reason is that when calling g_object_new() on a widget with 3705 * composite templates, it’s important to build the composite widgets 3706 * before the construct properties are set. Properties passed to g_object_new() 3707 * should take precedence over properties set in the private template XML. 3708 * 3709 * Since: 3.10 3710 */ 3711 public void initTemplate() 3712 { 3713 gtk_widget_init_template(gtkWidget); 3714 } 3715 3716 /** 3717 * Sets an input shape for this widget’s GDK window. This allows for 3718 * windows which react to mouse click in a nonrectangular region, see 3719 * gdk_window_input_shape_combine_region() for more information. 3720 * 3721 * Params: 3722 * region = shape to be added, or %NULL to remove an existing shape 3723 * 3724 * Since: 3.0 3725 */ 3726 public void inputShapeCombineRegion(Region region) 3727 { 3728 gtk_widget_input_shape_combine_region(gtkWidget, (region is null) ? null : region.getRegionStruct()); 3729 } 3730 3731 /** 3732 * Inserts @group into @widget. Children of @widget that implement 3733 * #GtkActionable can then be associated with actions in @group by 3734 * setting their “action-name” to 3735 * @prefix.`action-name`. 3736 * 3737 * If @group is %NULL, a previously inserted group for @name is removed 3738 * from @widget. 3739 * 3740 * Params: 3741 * name = the prefix for actions in @group 3742 * group = a #GActionGroup, or %NULL 3743 * 3744 * Since: 3.6 3745 */ 3746 public void insertActionGroup(string name, ActionGroupIF group) 3747 { 3748 gtk_widget_insert_action_group(gtkWidget, Str.toStringz(name), (group is null) ? null : group.getActionGroupStruct()); 3749 } 3750 3751 /** 3752 * Computes the intersection of a @widget’s area and @area, storing 3753 * the intersection in @intersection, and returns %TRUE if there was 3754 * an intersection. @intersection may be %NULL if you’re only 3755 * interested in whether there was an intersection. 3756 * 3757 * Params: 3758 * area = a rectangle 3759 * intersection = rectangle to store 3760 * intersection of @widget and @area 3761 * 3762 * Returns: %TRUE if there was an intersection 3763 */ 3764 public bool intersect(GdkRectangle* area, out GdkRectangle intersection) 3765 { 3766 return gtk_widget_intersect(gtkWidget, area, &intersection) != 0; 3767 } 3768 3769 /** 3770 * Determines whether @widget is somewhere inside @ancestor, possibly with 3771 * intermediate containers. 3772 * 3773 * Params: 3774 * ancestor = another #GtkWidget 3775 * 3776 * Returns: %TRUE if @ancestor contains @widget as a child, 3777 * grandchild, great grandchild, etc. 3778 */ 3779 public bool isAncestor(Widget ancestor) 3780 { 3781 return gtk_widget_is_ancestor(gtkWidget, (ancestor is null) ? null : ancestor.getWidgetStruct()) != 0; 3782 } 3783 3784 /** 3785 * Whether @widget can rely on having its alpha channel 3786 * drawn correctly. On X11 this function returns whether a 3787 * compositing manager is running for @widget’s screen. 3788 * 3789 * Please note that the semantics of this call will change 3790 * in the future if used on a widget that has a composited 3791 * window in its hierarchy (as set by gdk_window_set_composited()). 3792 * 3793 * Deprecated: Use gdk_screen_is_composited() instead. 3794 * 3795 * Returns: %TRUE if the widget can rely on its alpha 3796 * channel being drawn correctly. 3797 * 3798 * Since: 2.10 3799 */ 3800 public bool isComposited() 3801 { 3802 return gtk_widget_is_composited(gtkWidget) != 0; 3803 } 3804 3805 /** 3806 * Determines whether @widget can be drawn to. A widget can be drawn 3807 * to if it is mapped and visible. 3808 * 3809 * Returns: %TRUE if @widget is drawable, %FALSE otherwise 3810 * 3811 * Since: 2.18 3812 */ 3813 public bool isDrawable() 3814 { 3815 return gtk_widget_is_drawable(gtkWidget) != 0; 3816 } 3817 3818 /** 3819 * Determines if the widget is the focus widget within its 3820 * toplevel. (This does not mean that the #GtkWidget:has-focus property is 3821 * necessarily set; #GtkWidget:has-focus will only be set if the 3822 * toplevel widget additionally has the global input focus.) 3823 * 3824 * Returns: %TRUE if the widget is the focus widget. 3825 */ 3826 public bool isFocus() 3827 { 3828 return gtk_widget_is_focus(gtkWidget) != 0; 3829 } 3830 3831 /** 3832 * Returns the widget’s effective sensitivity, which means 3833 * it is sensitive itself and also its parent widget is sensitive 3834 * 3835 * Returns: %TRUE if the widget is effectively sensitive 3836 * 3837 * Since: 2.18 3838 */ 3839 public bool isSensitive() 3840 { 3841 return gtk_widget_is_sensitive(gtkWidget) != 0; 3842 } 3843 3844 /** 3845 * Determines whether @widget is a toplevel widget. 3846 * 3847 * Currently only #GtkWindow and #GtkInvisible (and out-of-process 3848 * #GtkPlugs) are toplevel widgets. Toplevel widgets have no parent 3849 * widget. 3850 * 3851 * Returns: %TRUE if @widget is a toplevel, %FALSE otherwise 3852 * 3853 * Since: 2.18 3854 */ 3855 public bool isToplevel() 3856 { 3857 return gtk_widget_is_toplevel(gtkWidget) != 0; 3858 } 3859 3860 /** 3861 * Determines whether the widget and all its parents are marked as 3862 * visible. 3863 * 3864 * This function does not check if the widget is obscured in any way. 3865 * 3866 * See also gtk_widget_get_visible() and gtk_widget_set_visible() 3867 * 3868 * Returns: %TRUE if the widget and all its parents are visible 3869 * 3870 * Since: 3.8 3871 */ 3872 public bool isVisible() 3873 { 3874 return gtk_widget_is_visible(gtkWidget) != 0; 3875 } 3876 3877 /** 3878 * This function should be called whenever keyboard navigation within 3879 * a single widget hits a boundary. The function emits the 3880 * #GtkWidget::keynav-failed signal on the widget and its return 3881 * value should be interpreted in a way similar to the return value of 3882 * gtk_widget_child_focus(): 3883 * 3884 * When %TRUE is returned, stay in the widget, the failed keyboard 3885 * navigation is OK and/or there is nowhere we can/should move the 3886 * focus to. 3887 * 3888 * When %FALSE is returned, the caller should continue with keyboard 3889 * navigation outside the widget, e.g. by calling 3890 * gtk_widget_child_focus() on the widget’s toplevel. 3891 * 3892 * The default ::keynav-failed handler returns %TRUE for 3893 * %GTK_DIR_TAB_FORWARD and %GTK_DIR_TAB_BACKWARD. For the other 3894 * values of #GtkDirectionType it returns %FALSE. 3895 * 3896 * Whenever the default handler returns %TRUE, it also calls 3897 * gtk_widget_error_bell() to notify the user of the failed keyboard 3898 * navigation. 3899 * 3900 * A use case for providing an own implementation of ::keynav-failed 3901 * (either by connecting to it or by overriding it) would be a row of 3902 * #GtkEntry widgets where the user should be able to navigate the 3903 * entire row with the cursor keys, as e.g. known from user interfaces 3904 * that require entering license keys. 3905 * 3906 * Params: 3907 * direction = direction of focus movement 3908 * 3909 * Returns: %TRUE if stopping keyboard navigation is fine, %FALSE 3910 * if the emitting widget should try to handle the keyboard 3911 * navigation attempt in its parent container(s). 3912 * 3913 * Since: 2.12 3914 */ 3915 public bool keynavFailed(GtkDirectionType direction) 3916 { 3917 return gtk_widget_keynav_failed(gtkWidget, direction) != 0; 3918 } 3919 3920 /** 3921 * Lists the closures used by @widget for accelerator group connections 3922 * with gtk_accel_group_connect_by_path() or gtk_accel_group_connect(). 3923 * The closures can be used to monitor accelerator changes on @widget, 3924 * by connecting to the @GtkAccelGroup::accel-changed signal of the 3925 * #GtkAccelGroup of a closure which can be found out with 3926 * gtk_accel_group_from_accel_closure(). 3927 * 3928 * Returns: a newly allocated #GList of closures 3929 */ 3930 public ListG listAccelClosures() 3931 { 3932 auto p = gtk_widget_list_accel_closures(gtkWidget); 3933 3934 if(p is null) 3935 { 3936 return null; 3937 } 3938 3939 return new ListG(cast(GList*) p); 3940 } 3941 3942 /** 3943 * Retrieves a %NULL-terminated array of strings containing the prefixes of 3944 * #GActionGroup's available to @widget. 3945 * 3946 * Returns: a %NULL-terminated array of strings. 3947 * 3948 * Since: 3.16 3949 */ 3950 public string[] listActionPrefixes() 3951 { 3952 return Str.toStringArray(gtk_widget_list_action_prefixes(gtkWidget)); 3953 } 3954 3955 /** 3956 * Returns a newly allocated list of the widgets, normally labels, for 3957 * which this widget is the target of a mnemonic (see for example, 3958 * gtk_label_set_mnemonic_widget()). 3959 * 3960 * The widgets in the list are not individually referenced. If you 3961 * want to iterate through the list and perform actions involving 3962 * callbacks that might destroy the widgets, you 3963 * must call `g_list_foreach (result, 3964 * (GFunc)g_object_ref, NULL)` first, and then unref all the 3965 * widgets afterwards. 3966 * 3967 * Returns: the list of 3968 * mnemonic labels; free this list 3969 * with g_list_free() when you are done with it. 3970 * 3971 * Since: 2.4 3972 */ 3973 public ListG listMnemonicLabels() 3974 { 3975 auto p = gtk_widget_list_mnemonic_labels(gtkWidget); 3976 3977 if(p is null) 3978 { 3979 return null; 3980 } 3981 3982 return new ListG(cast(GList*) p); 3983 } 3984 3985 /** 3986 * This function is only for use in widget implementations. Causes 3987 * a widget to be mapped if it isn’t already. 3988 */ 3989 public void map() 3990 { 3991 gtk_widget_map(gtkWidget); 3992 } 3993 3994 /** 3995 * Emits the #GtkWidget::mnemonic-activate signal. 3996 * 3997 * Params: 3998 * groupCycling = %TRUE if there are other widgets with the same mnemonic 3999 * 4000 * Returns: %TRUE if the signal has been handled 4001 */ 4002 public bool mnemonicActivate(bool groupCycling) 4003 { 4004 return gtk_widget_mnemonic_activate(gtkWidget, groupCycling) != 0; 4005 } 4006 4007 /** 4008 * Sets the base color for a widget in a particular state. 4009 * All other style values are left untouched. The base color 4010 * is the background color used along with the text color 4011 * (see gtk_widget_modify_text()) for widgets such as #GtkEntry 4012 * and #GtkTextView. See also gtk_widget_modify_style(). 4013 * 4014 * > Note that “no window” widgets (which have the %GTK_NO_WINDOW 4015 * > flag set) draw on their parent container’s window and thus may 4016 * > not draw any background themselves. This is the case for e.g. 4017 * > #GtkLabel. 4018 * > 4019 * > To modify the background of such widgets, you have to set the 4020 * > base color on their parent; if you want to set the background 4021 * > of a rectangular area around a label, try placing the label in 4022 * > a #GtkEventBox widget and setting the base color on that. 4023 * 4024 * Deprecated: Use gtk_widget_override_background_color() instead 4025 * 4026 * Params: 4027 * state = the state for which to set the base color 4028 * color = the color to assign (does not need to 4029 * be allocated), or %NULL to undo the effect of previous 4030 * calls to of gtk_widget_modify_base(). 4031 */ 4032 public void modifyBase(GtkStateType state, Color color) 4033 { 4034 gtk_widget_modify_base(gtkWidget, state, (color is null) ? null : color.getColorStruct()); 4035 } 4036 4037 /** 4038 * Sets the background color for a widget in a particular state. 4039 * 4040 * All other style values are left untouched. 4041 * See also gtk_widget_modify_style(). 4042 * 4043 * > Note that “no window” widgets (which have the %GTK_NO_WINDOW 4044 * > flag set) draw on their parent container’s window and thus may 4045 * > not draw any background themselves. This is the case for e.g. 4046 * > #GtkLabel. 4047 * > 4048 * > To modify the background of such widgets, you have to set the 4049 * > background color on their parent; if you want to set the background 4050 * > of a rectangular area around a label, try placing the label in 4051 * > a #GtkEventBox widget and setting the background color on that. 4052 * 4053 * Deprecated: Use gtk_widget_override_background_color() instead 4054 * 4055 * Params: 4056 * state = the state for which to set the background color 4057 * color = the color to assign (does not need 4058 * to be allocated), or %NULL to undo the effect of previous 4059 * calls to of gtk_widget_modify_bg(). 4060 */ 4061 public void modifyBg(GtkStateType state, Color color) 4062 { 4063 gtk_widget_modify_bg(gtkWidget, state, (color is null) ? null : color.getColorStruct()); 4064 } 4065 4066 /** 4067 * Sets the cursor color to use in a widget, overriding the #GtkWidget 4068 * cursor-color and secondary-cursor-color 4069 * style properties. 4070 * 4071 * All other style values are left untouched. 4072 * See also gtk_widget_modify_style(). 4073 * 4074 * Deprecated: Use gtk_widget_override_cursor() instead. 4075 * 4076 * Params: 4077 * primary = the color to use for primary cursor (does not 4078 * need to be allocated), or %NULL to undo the effect of previous 4079 * calls to of gtk_widget_modify_cursor(). 4080 * secondary = the color to use for secondary cursor (does 4081 * not need to be allocated), or %NULL to undo the effect of 4082 * previous calls to of gtk_widget_modify_cursor(). 4083 * 4084 * Since: 2.12 4085 */ 4086 public void modifyCursor(Color primary, Color secondary) 4087 { 4088 gtk_widget_modify_cursor(gtkWidget, (primary is null) ? null : primary.getColorStruct(), (secondary is null) ? null : secondary.getColorStruct()); 4089 } 4090 4091 /** 4092 * Sets the foreground color for a widget in a particular state. 4093 * 4094 * All other style values are left untouched. 4095 * See also gtk_widget_modify_style(). 4096 * 4097 * Deprecated: Use gtk_widget_override_color() instead 4098 * 4099 * Params: 4100 * state = the state for which to set the foreground color 4101 * color = the color to assign (does not need to be allocated), 4102 * or %NULL to undo the effect of previous calls to 4103 * of gtk_widget_modify_fg(). 4104 */ 4105 public void modifyFg(GtkStateType state, Color color) 4106 { 4107 gtk_widget_modify_fg(gtkWidget, state, (color is null) ? null : color.getColorStruct()); 4108 } 4109 4110 /** 4111 * Sets the font to use for a widget. 4112 * 4113 * All other style values are left untouched. 4114 * See also gtk_widget_modify_style(). 4115 * 4116 * Deprecated: Use gtk_widget_override_font() instead 4117 * 4118 * Params: 4119 * fontDesc = the font description to use, or %NULL 4120 * to undo the effect of previous calls to gtk_widget_modify_font() 4121 */ 4122 public void modifyFont(PgFontDescription fontDesc) 4123 { 4124 gtk_widget_modify_font(gtkWidget, (fontDesc is null) ? null : fontDesc.getPgFontDescriptionStruct()); 4125 } 4126 4127 /** 4128 * Modifies style values on the widget. 4129 * 4130 * Modifications made using this technique take precedence over 4131 * style values set via an RC file, however, they will be overridden 4132 * if a style is explicitly set on the widget using gtk_widget_set_style(). 4133 * The #GtkRcStyle-struct is designed so each field can either be 4134 * set or unset, so it is possible, using this function, to modify some 4135 * style values and leave the others unchanged. 4136 * 4137 * Note that modifications made with this function are not cumulative 4138 * with previous calls to gtk_widget_modify_style() or with such 4139 * functions as gtk_widget_modify_fg(). If you wish to retain 4140 * previous values, you must first call gtk_widget_get_modifier_style(), 4141 * make your modifications to the returned style, then call 4142 * gtk_widget_modify_style() with that style. On the other hand, 4143 * if you first call gtk_widget_modify_style(), subsequent calls 4144 * to such functions gtk_widget_modify_fg() will have a cumulative 4145 * effect with the initial modifications. 4146 * 4147 * Deprecated: Use #GtkStyleContext with a custom #GtkStyleProvider instead 4148 * 4149 * Params: 4150 * style = the #GtkRcStyle-struct holding the style modifications 4151 */ 4152 public void modifyStyle(RcStyle style) 4153 { 4154 gtk_widget_modify_style(gtkWidget, (style is null) ? null : style.getRcStyleStruct()); 4155 } 4156 4157 /** 4158 * Sets the text color for a widget in a particular state. 4159 * 4160 * All other style values are left untouched. 4161 * The text color is the foreground color used along with the 4162 * base color (see gtk_widget_modify_base()) for widgets such 4163 * as #GtkEntry and #GtkTextView. 4164 * See also gtk_widget_modify_style(). 4165 * 4166 * Deprecated: Use gtk_widget_override_color() instead 4167 * 4168 * Params: 4169 * state = the state for which to set the text color 4170 * color = the color to assign (does not need to 4171 * be allocated), or %NULL to undo the effect of previous 4172 * calls to of gtk_widget_modify_text(). 4173 */ 4174 public void modifyText(GtkStateType state, Color color) 4175 { 4176 gtk_widget_modify_text(gtkWidget, state, (color is null) ? null : color.getColorStruct()); 4177 } 4178 4179 /** 4180 * Sets the background color to use for a widget. 4181 * 4182 * All other style values are left untouched. 4183 * See gtk_widget_override_color(). 4184 * 4185 * Deprecated: This function is not useful in the context of CSS-based 4186 * rendering. If you wish to change the way a widget renders its background 4187 * you should use a custom CSS style, through an application-specific 4188 * #GtkStyleProvider and a CSS style class. You can also override the default 4189 * drawing of a widget through the #GtkWidget::draw signal, and use Cairo to 4190 * draw a specific color, regardless of the CSS style. 4191 * 4192 * Params: 4193 * state = the state for which to set the background color 4194 * color = the color to assign, or %NULL to undo the effect 4195 * of previous calls to gtk_widget_override_background_color() 4196 * 4197 * Since: 3.0 4198 */ 4199 public void overrideBackgroundColor(GtkStateFlags state, RGBA color) 4200 { 4201 gtk_widget_override_background_color(gtkWidget, state, (color is null) ? null : color.getRGBAStruct()); 4202 } 4203 4204 /** 4205 * Sets the color to use for a widget. 4206 * 4207 * All other style values are left untouched. 4208 * 4209 * This function does not act recursively. Setting the color of a 4210 * container does not affect its children. Note that some widgets that 4211 * you may not think of as containers, for instance #GtkButtons, 4212 * are actually containers. 4213 * 4214 * This API is mostly meant as a quick way for applications to 4215 * change a widget appearance. If you are developing a widgets 4216 * library and intend this change to be themeable, it is better 4217 * done by setting meaningful CSS classes in your 4218 * widget/container implementation through gtk_style_context_add_class(). 4219 * 4220 * This way, your widget library can install a #GtkCssProvider 4221 * with the %GTK_STYLE_PROVIDER_PRIORITY_FALLBACK priority in order 4222 * to provide a default styling for those widgets that need so, and 4223 * this theming may fully overridden by the user’s theme. 4224 * 4225 * Note that for complex widgets this may bring in undesired 4226 * results (such as uniform background color everywhere), in 4227 * these cases it is better to fully style such widgets through a 4228 * #GtkCssProvider with the %GTK_STYLE_PROVIDER_PRIORITY_APPLICATION 4229 * priority. 4230 * 4231 * Deprecated: Use a custom style provider and style classes instead 4232 * 4233 * Params: 4234 * state = the state for which to set the color 4235 * color = the color to assign, or %NULL to undo the effect 4236 * of previous calls to gtk_widget_override_color() 4237 * 4238 * Since: 3.0 4239 */ 4240 public void overrideColor(GtkStateFlags state, RGBA color) 4241 { 4242 gtk_widget_override_color(gtkWidget, state, (color is null) ? null : color.getRGBAStruct()); 4243 } 4244 4245 /** 4246 * Sets the cursor color to use in a widget, overriding the 4247 * cursor-color and secondary-cursor-color 4248 * style properties. All other style values are left untouched. 4249 * See also gtk_widget_modify_style(). 4250 * 4251 * Note that the underlying properties have the #GdkColor type, 4252 * so the alpha value in @primary and @secondary will be ignored. 4253 * 4254 * Deprecated: This function is not useful in the context of CSS-based 4255 * rendering. If you wish to change the color used to render the primary 4256 * and secondary cursors you should use a custom CSS style, through an 4257 * application-specific #GtkStyleProvider and a CSS style class. 4258 * 4259 * Params: 4260 * cursor = the color to use for primary cursor (does not need to be 4261 * allocated), or %NULL to undo the effect of previous calls to 4262 * of gtk_widget_override_cursor(). 4263 * secondaryCursor = the color to use for secondary cursor (does not 4264 * need to be allocated), or %NULL to undo the effect of previous 4265 * calls to of gtk_widget_override_cursor(). 4266 * 4267 * Since: 3.0 4268 */ 4269 public void overrideCursor(RGBA cursor, RGBA secondaryCursor) 4270 { 4271 gtk_widget_override_cursor(gtkWidget, (cursor is null) ? null : cursor.getRGBAStruct(), (secondaryCursor is null) ? null : secondaryCursor.getRGBAStruct()); 4272 } 4273 4274 /** 4275 * Sets the font to use for a widget. All other style values are 4276 * left untouched. See gtk_widget_override_color(). 4277 * 4278 * Deprecated: This function is not useful in the context of CSS-based 4279 * rendering. If you wish to change the font a widget uses to render its text 4280 * you should use a custom CSS style, through an application-specific 4281 * #GtkStyleProvider and a CSS style class. 4282 * 4283 * Params: 4284 * fontDesc = the font description to use, or %NULL to undo 4285 * the effect of previous calls to gtk_widget_override_font() 4286 * 4287 * Since: 3.0 4288 */ 4289 public void overrideFont(PgFontDescription fontDesc) 4290 { 4291 gtk_widget_override_font(gtkWidget, (fontDesc is null) ? null : fontDesc.getPgFontDescriptionStruct()); 4292 } 4293 4294 /** 4295 * Sets a symbolic color for a widget. 4296 * 4297 * All other style values are left untouched. 4298 * See gtk_widget_override_color() for overriding the foreground 4299 * or background color. 4300 * 4301 * Deprecated: This function is not useful in the context of CSS-based 4302 * rendering. If you wish to change the color used to render symbolic icons 4303 * you should use a custom CSS style, through an application-specific 4304 * #GtkStyleProvider and a CSS style class. 4305 * 4306 * Params: 4307 * name = the name of the symbolic color to modify 4308 * color = the color to assign (does not need 4309 * to be allocated), or %NULL to undo the effect of previous 4310 * calls to gtk_widget_override_symbolic_color() 4311 * 4312 * Since: 3.0 4313 */ 4314 public void overrideSymbolicColor(string name, RGBA color) 4315 { 4316 gtk_widget_override_symbolic_color(gtkWidget, Str.toStringz(name), (color is null) ? null : color.getRGBAStruct()); 4317 } 4318 4319 /** 4320 * Obtains the full path to @widget. The path is simply the name of a 4321 * widget and all its parents in the container hierarchy, separated by 4322 * periods. The name of a widget comes from 4323 * gtk_widget_get_name(). Paths are used to apply styles to a widget 4324 * in gtkrc configuration files. Widget names are the type of the 4325 * widget by default (e.g. “GtkButton”) or can be set to an 4326 * application-specific value with gtk_widget_set_name(). By setting 4327 * the name of a widget, you allow users or theme authors to apply 4328 * styles to that specific widget in their gtkrc 4329 * file. @path_reversed_p fills in the path in reverse order, 4330 * i.e. starting with @widget’s name instead of starting with the name 4331 * of @widget’s outermost ancestor. 4332 * 4333 * Deprecated: Use gtk_widget_get_path() instead 4334 * 4335 * Params: 4336 * pathLength = location to store length of the path, 4337 * or %NULL 4338 * path = location to store allocated path string, 4339 * or %NULL 4340 * pathReversed = location to store allocated reverse 4341 * path string, or %NULL 4342 */ 4343 public void path(out uint pathLength, out string path, out string pathReversed) 4344 { 4345 char* outpath = null; 4346 char* outpathReversed = null; 4347 4348 gtk_widget_path(gtkWidget, &pathLength, &outpath, &outpathReversed); 4349 4350 path = Str.toString(outpath); 4351 pathReversed = Str.toString(outpathReversed); 4352 } 4353 4354 /** 4355 * This function is only for use in widget implementations. 4356 * 4357 * Flags the widget for a rerun of the GtkWidgetClass::size_allocate 4358 * function. Use this function instead of gtk_widget_queue_resize() 4359 * when the @widget's size request didn't change but it wants to 4360 * reposition its contents. 4361 * 4362 * An example user of this function is gtk_widget_set_halign(). 4363 * 4364 * Since: 3.20 4365 */ 4366 public void queueAllocate() 4367 { 4368 gtk_widget_queue_allocate(gtkWidget); 4369 } 4370 4371 /** 4372 * Mark @widget as needing to recompute its expand flags. Call 4373 * this function when setting legacy expand child properties 4374 * on the child of a container. 4375 * 4376 * See gtk_widget_compute_expand(). 4377 */ 4378 public void queueComputeExpand() 4379 { 4380 gtk_widget_queue_compute_expand(gtkWidget); 4381 } 4382 4383 /** 4384 * Equivalent to calling gtk_widget_queue_draw_area() for the 4385 * entire area of a widget. 4386 */ 4387 public void queueDraw() 4388 { 4389 gtk_widget_queue_draw(gtkWidget); 4390 } 4391 4392 /** 4393 * Convenience function that calls gtk_widget_queue_draw_region() on 4394 * the region created from the given coordinates. 4395 * 4396 * The region here is specified in widget coordinates. 4397 * Widget coordinates are a bit odd; for historical reasons, they are 4398 * defined as @widget->window coordinates for widgets that return %TRUE for 4399 * gtk_widget_get_has_window(), and are relative to @widget->allocation.x, 4400 * @widget->allocation.y otherwise. 4401 * 4402 * @width or @height may be 0, in this case this function does 4403 * nothing. Negative values for @width and @height are not allowed. 4404 * 4405 * Params: 4406 * x = x coordinate of upper-left corner of rectangle to redraw 4407 * y = y coordinate of upper-left corner of rectangle to redraw 4408 * width = width of region to draw 4409 * height = height of region to draw 4410 */ 4411 public void queueDrawArea(int x, int y, int width, int height) 4412 { 4413 gtk_widget_queue_draw_area(gtkWidget, x, y, width, height); 4414 } 4415 4416 /** 4417 * Invalidates the area of @widget defined by @region by calling 4418 * gdk_window_invalidate_region() on the widget’s window and all its 4419 * child windows. Once the main loop becomes idle (after the current 4420 * batch of events has been processed, roughly), the window will 4421 * receive expose events for the union of all regions that have been 4422 * invalidated. 4423 * 4424 * Normally you would only use this function in widget 4425 * implementations. You might also use it to schedule a redraw of a 4426 * #GtkDrawingArea or some portion thereof. 4427 * 4428 * Params: 4429 * region = region to draw 4430 * 4431 * Since: 3.0 4432 */ 4433 public void queueDrawRegion(Region region) 4434 { 4435 gtk_widget_queue_draw_region(gtkWidget, (region is null) ? null : region.getRegionStruct()); 4436 } 4437 4438 /** 4439 * This function is only for use in widget implementations. 4440 * Flags a widget to have its size renegotiated; should 4441 * be called when a widget for some reason has a new size request. 4442 * For example, when you change the text in a #GtkLabel, #GtkLabel 4443 * queues a resize to ensure there’s enough space for the new text. 4444 * 4445 * Note that you cannot call gtk_widget_queue_resize() on a widget 4446 * from inside its implementation of the GtkWidgetClass::size_allocate 4447 * virtual method. Calls to gtk_widget_queue_resize() from inside 4448 * GtkWidgetClass::size_allocate will be silently ignored. 4449 */ 4450 public void queueResize() 4451 { 4452 gtk_widget_queue_resize(gtkWidget); 4453 } 4454 4455 /** 4456 * This function works like gtk_widget_queue_resize(), 4457 * except that the widget is not invalidated. 4458 * 4459 * Since: 2.4 4460 */ 4461 public void queueResizeNoRedraw() 4462 { 4463 gtk_widget_queue_resize_no_redraw(gtkWidget); 4464 } 4465 4466 /** 4467 * Creates the GDK (windowing system) resources associated with a 4468 * widget. For example, @widget->window will be created when a widget 4469 * is realized. Normally realization happens implicitly; if you show 4470 * a widget and all its parent containers, then the widget will be 4471 * realized and mapped automatically. 4472 * 4473 * Realizing a widget requires all 4474 * the widget’s parent widgets to be realized; calling 4475 * gtk_widget_realize() realizes the widget’s parents in addition to 4476 * @widget itself. If a widget is not yet inside a toplevel window 4477 * when you realize it, bad things will happen. 4478 * 4479 * This function is primarily used in widget implementations, and 4480 * isn’t very useful otherwise. Many times when you think you might 4481 * need it, a better approach is to connect to a signal that will be 4482 * called after the widget is realized automatically, such as 4483 * #GtkWidget::draw. Or simply g_signal_connect () to the 4484 * #GtkWidget::realize signal. 4485 */ 4486 public void realize() 4487 { 4488 gtk_widget_realize(gtkWidget); 4489 } 4490 4491 /** 4492 * Computes the intersection of a @widget’s area and @region, returning 4493 * the intersection. The result may be empty, use cairo_region_is_empty() to 4494 * check. 4495 * 4496 * Deprecated: Use gtk_widget_get_allocation() and 4497 * cairo_region_intersect_rectangle() to get the same behavior. 4498 * 4499 * Params: 4500 * region = a #cairo_region_t, in the same coordinate system as 4501 * @widget->allocation. That is, relative to @widget->window 4502 * for widgets which return %FALSE from gtk_widget_get_has_window(); 4503 * relative to the parent window of @widget->window otherwise. 4504 * 4505 * Returns: A newly allocated region holding the intersection of @widget 4506 * and @region. 4507 */ 4508 public Region regionIntersect(Region region) 4509 { 4510 auto p = gtk_widget_region_intersect(gtkWidget, (region is null) ? null : region.getRegionStruct()); 4511 4512 if(p is null) 4513 { 4514 return null; 4515 } 4516 4517 return new Region(cast(cairo_region_t*) p); 4518 } 4519 4520 /** 4521 * Registers a #GdkWindow with the widget and sets it up so that 4522 * the widget receives events for it. Call gtk_widget_unregister_window() 4523 * when destroying the window. 4524 * 4525 * Before 3.8 you needed to call gdk_window_set_user_data() directly to set 4526 * this up. This is now deprecated and you should use gtk_widget_register_window() 4527 * instead. Old code will keep working as is, although some new features like 4528 * transparency might not work perfectly. 4529 * 4530 * Params: 4531 * window = a #GdkWindow 4532 * 4533 * Since: 3.8 4534 */ 4535 public void registerWindow(GdkWin window) 4536 { 4537 gtk_widget_register_window(gtkWidget, (window is null) ? null : window.getWindowStruct()); 4538 } 4539 4540 /** 4541 * Removes an accelerator from @widget, previously installed with 4542 * gtk_widget_add_accelerator(). 4543 * 4544 * Params: 4545 * accelGroup = accel group for this widget 4546 * accelKey = GDK keyval of the accelerator 4547 * accelMods = modifier key combination of the accelerator 4548 * 4549 * Returns: whether an accelerator was installed and could be removed 4550 */ 4551 public bool removeAccelerator(AccelGroup accelGroup, uint accelKey, GdkModifierType accelMods) 4552 { 4553 return gtk_widget_remove_accelerator(gtkWidget, (accelGroup is null) ? null : accelGroup.getAccelGroupStruct(), accelKey, accelMods) != 0; 4554 } 4555 4556 /** 4557 * Removes a widget from the list of mnemonic labels for 4558 * this widget. (See gtk_widget_list_mnemonic_labels()). The widget 4559 * must have previously been added to the list with 4560 * gtk_widget_add_mnemonic_label(). 4561 * 4562 * Params: 4563 * label = a #GtkWidget that was previously set as a mnemonic label for 4564 * @widget with gtk_widget_add_mnemonic_label(). 4565 * 4566 * Since: 2.4 4567 */ 4568 public void removeMnemonicLabel(Widget label) 4569 { 4570 gtk_widget_remove_mnemonic_label(gtkWidget, (label is null) ? null : label.getWidgetStruct()); 4571 } 4572 4573 /** 4574 * Removes a tick callback previously registered with 4575 * gtk_widget_add_tick_callback(). 4576 * 4577 * Params: 4578 * id = an id returned by gtk_widget_add_tick_callback() 4579 * 4580 * Since: 3.8 4581 */ 4582 public void removeTickCallback(uint id) 4583 { 4584 gtk_widget_remove_tick_callback(gtkWidget, id); 4585 } 4586 4587 /** 4588 * A convenience function that uses the theme settings for @widget 4589 * to look up @stock_id and render it to a pixbuf. @stock_id should 4590 * be a stock icon ID such as #GTK_STOCK_OPEN or #GTK_STOCK_OK. @size 4591 * should be a size such as #GTK_ICON_SIZE_MENU. @detail should be a 4592 * string that identifies the widget or code doing the rendering, so 4593 * that theme engines can special-case rendering for that widget or 4594 * code. 4595 * 4596 * The pixels in the returned #GdkPixbuf are shared with the rest of 4597 * the application and should not be modified. The pixbuf should be 4598 * freed after use with g_object_unref(). 4599 * 4600 * Deprecated: Use gtk_widget_render_icon_pixbuf() instead. 4601 * 4602 * Params: 4603 * stockId = a stock ID 4604 * size = a stock size (#GtkIconSize). A size of `(GtkIconSize)-1` 4605 * means render at the size of the source and don’t scale (if there are 4606 * multiple source sizes, GTK+ picks one of the available sizes). 4607 * detail = render detail to pass to theme engine 4608 * 4609 * Returns: a new pixbuf, or %NULL if the 4610 * stock ID wasn’t known 4611 */ 4612 public Pixbuf renderIcon(string stockId, GtkIconSize size, string detail) 4613 { 4614 auto p = gtk_widget_render_icon(gtkWidget, Str.toStringz(stockId), size, Str.toStringz(detail)); 4615 4616 if(p is null) 4617 { 4618 return null; 4619 } 4620 4621 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true); 4622 } 4623 4624 /** 4625 * A convenience function that uses the theme engine and style 4626 * settings for @widget to look up @stock_id and render it to 4627 * a pixbuf. @stock_id should be a stock icon ID such as 4628 * #GTK_STOCK_OPEN or #GTK_STOCK_OK. @size should be a size 4629 * such as #GTK_ICON_SIZE_MENU. 4630 * 4631 * The pixels in the returned #GdkPixbuf are shared with the rest of 4632 * the application and should not be modified. The pixbuf should be freed 4633 * after use with g_object_unref(). 4634 * 4635 * Deprecated: Use gtk_icon_theme_load_icon() instead. 4636 * 4637 * Params: 4638 * stockId = a stock ID 4639 * size = a stock size (#GtkIconSize). A size of `(GtkIconSize)-1` 4640 * means render at the size of the source and don’t scale (if there are 4641 * multiple source sizes, GTK+ picks one of the available sizes). 4642 * 4643 * Returns: a new pixbuf, or %NULL if the 4644 * stock ID wasn’t known 4645 * 4646 * Since: 3.0 4647 */ 4648 public Pixbuf renderIconPixbuf(string stockId, GtkIconSize size) 4649 { 4650 auto p = gtk_widget_render_icon_pixbuf(gtkWidget, Str.toStringz(stockId), size); 4651 4652 if(p is null) 4653 { 4654 return null; 4655 } 4656 4657 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p, true); 4658 } 4659 4660 /** 4661 * Moves a widget from one #GtkContainer to another, handling reference 4662 * count issues to avoid destroying the widget. 4663 * 4664 * Deprecated: Use gtk_container_remove() and gtk_container_add(). 4665 * 4666 * Params: 4667 * newParent = a #GtkContainer to move the widget into 4668 */ 4669 public void reparent(Widget newParent) 4670 { 4671 gtk_widget_reparent(gtkWidget, (newParent is null) ? null : newParent.getWidgetStruct()); 4672 } 4673 4674 /** 4675 * Reset the styles of @widget and all descendents, so when 4676 * they are looked up again, they get the correct values 4677 * for the currently loaded RC file settings. 4678 * 4679 * This function is not useful for applications. 4680 * 4681 * Deprecated: Use #GtkStyleContext instead, and gtk_widget_reset_style() 4682 */ 4683 public void resetRcStyles() 4684 { 4685 gtk_widget_reset_rc_styles(gtkWidget); 4686 } 4687 4688 /** 4689 * Updates the style context of @widget and all descendants 4690 * by updating its widget path. #GtkContainers may want 4691 * to use this on a child when reordering it in a way that a different 4692 * style might apply to it. See also gtk_container_get_path_for_child(). 4693 * 4694 * Since: 3.0 4695 */ 4696 public void resetStyle() 4697 { 4698 gtk_widget_reset_style(gtkWidget); 4699 } 4700 4701 /** 4702 * Very rarely-used function. This function is used to emit 4703 * an expose event on a widget. This function is not normally used 4704 * directly. The only time it is used is when propagating an expose 4705 * event to a windowless child widget (gtk_widget_get_has_window() is %FALSE), 4706 * and that is normally done using gtk_container_propagate_draw(). 4707 * 4708 * If you want to force an area of a window to be redrawn, 4709 * use gdk_window_invalidate_rect() or gdk_window_invalidate_region(). 4710 * To cause the redraw to be done immediately, follow that call 4711 * with a call to gdk_window_process_updates(). 4712 * 4713 * Deprecated: Application and widget code should not handle 4714 * expose events directly; invalidation should use the #GtkWidget 4715 * API, and drawing should only happen inside #GtkWidget::draw 4716 * implementations 4717 * 4718 * Params: 4719 * event = a expose #GdkEvent 4720 * 4721 * Returns: return from the event signal emission (%TRUE if 4722 * the event was handled) 4723 */ 4724 public int sendExpose(Event event) 4725 { 4726 return gtk_widget_send_expose(gtkWidget, (event is null) ? null : event.getEventStruct()); 4727 } 4728 4729 /** 4730 * Sends the focus change @event to @widget 4731 * 4732 * This function is not meant to be used by applications. The only time it 4733 * should be used is when it is necessary for a #GtkWidget to assign focus 4734 * to a widget that is semantically owned by the first widget even though 4735 * it’s not a direct child - for instance, a search entry in a floating 4736 * window similar to the quick search in #GtkTreeView. 4737 * 4738 * An example of its usage is: 4739 * 4740 * |[<!-- language="C" --> 4741 * GdkEvent *fevent = gdk_event_new (GDK_FOCUS_CHANGE); 4742 * 4743 * fevent->focus_change.type = GDK_FOCUS_CHANGE; 4744 * fevent->focus_change.in = TRUE; 4745 * fevent->focus_change.window = _gtk_widget_get_window (widget); 4746 * if (fevent->focus_change.window != NULL) 4747 * g_object_ref (fevent->focus_change.window); 4748 * 4749 * gtk_widget_send_focus_change (widget, fevent); 4750 * 4751 * gdk_event_free (event); 4752 * ]| 4753 * 4754 * Params: 4755 * event = a #GdkEvent of type GDK_FOCUS_CHANGE 4756 * 4757 * Returns: the return value from the event signal emission: %TRUE 4758 * if the event was handled, and %FALSE otherwise 4759 * 4760 * Since: 2.20 4761 */ 4762 public bool sendFocusChange(Event event) 4763 { 4764 return gtk_widget_send_focus_change(gtkWidget, (event is null) ? null : event.getEventStruct()) != 0; 4765 } 4766 4767 /** 4768 * Given an accelerator group, @accel_group, and an accelerator path, 4769 * @accel_path, sets up an accelerator in @accel_group so whenever the 4770 * key binding that is defined for @accel_path is pressed, @widget 4771 * will be activated. This removes any accelerators (for any 4772 * accelerator group) installed by previous calls to 4773 * gtk_widget_set_accel_path(). Associating accelerators with 4774 * paths allows them to be modified by the user and the modifications 4775 * to be saved for future use. (See gtk_accel_map_save().) 4776 * 4777 * This function is a low level function that would most likely 4778 * be used by a menu creation system like #GtkUIManager. If you 4779 * use #GtkUIManager, setting up accelerator paths will be done 4780 * automatically. 4781 * 4782 * Even when you you aren’t using #GtkUIManager, if you only want to 4783 * set up accelerators on menu items gtk_menu_item_set_accel_path() 4784 * provides a somewhat more convenient interface. 4785 * 4786 * Note that @accel_path string will be stored in a #GQuark. Therefore, if you 4787 * pass a static string, you can save some memory by interning it first with 4788 * g_intern_static_string(). 4789 * 4790 * Params: 4791 * accelPath = path used to look up the accelerator 4792 * accelGroup = a #GtkAccelGroup. 4793 */ 4794 public void setAccelPath(string accelPath, AccelGroup accelGroup) 4795 { 4796 gtk_widget_set_accel_path(gtkWidget, Str.toStringz(accelPath), (accelGroup is null) ? null : accelGroup.getAccelGroupStruct()); 4797 } 4798 4799 /** 4800 * Sets the widget’s allocation. This should not be used 4801 * directly, but from within a widget’s size_allocate method. 4802 * 4803 * The allocation set should be the “adjusted” or actual 4804 * allocation. If you’re implementing a #GtkContainer, you want to use 4805 * gtk_widget_size_allocate() instead of gtk_widget_set_allocation(). 4806 * The GtkWidgetClass::adjust_size_allocation virtual method adjusts the 4807 * allocation inside gtk_widget_size_allocate() to create an adjusted 4808 * allocation. 4809 * 4810 * Params: 4811 * allocation = a pointer to a #GtkAllocation to copy from 4812 * 4813 * Since: 2.18 4814 */ 4815 public void setAllocation(GtkAllocation* allocation) 4816 { 4817 gtk_widget_set_allocation(gtkWidget, allocation); 4818 } 4819 4820 /** 4821 * Sets whether the application intends to draw on the widget in 4822 * an #GtkWidget::draw handler. 4823 * 4824 * This is a hint to the widget and does not affect the behavior of 4825 * the GTK+ core; many widgets ignore this flag entirely. For widgets 4826 * that do pay attention to the flag, such as #GtkEventBox and #GtkWindow, 4827 * the effect is to suppress default themed drawing of the widget's 4828 * background. (Children of the widget will still be drawn.) The application 4829 * is then entirely responsible for drawing the widget background. 4830 * 4831 * Note that the background is still drawn when the widget is mapped. 4832 * 4833 * Params: 4834 * appPaintable = %TRUE if the application will paint on the widget 4835 */ 4836 public void setAppPaintable(bool appPaintable) 4837 { 4838 gtk_widget_set_app_paintable(gtkWidget, appPaintable); 4839 } 4840 4841 /** 4842 * Specifies whether @widget can be a default widget. See 4843 * gtk_widget_grab_default() for details about the meaning of 4844 * “default”. 4845 * 4846 * Params: 4847 * canDefault = whether or not @widget can be a default widget. 4848 * 4849 * Since: 2.18 4850 */ 4851 public void setCanDefault(bool canDefault) 4852 { 4853 gtk_widget_set_can_default(gtkWidget, canDefault); 4854 } 4855 4856 /** 4857 * Specifies whether @widget can own the input focus. See 4858 * gtk_widget_grab_focus() for actually setting the input focus on a 4859 * widget. 4860 * 4861 * Params: 4862 * canFocus = whether or not @widget can own the input focus. 4863 * 4864 * Since: 2.18 4865 */ 4866 public void setCanFocus(bool canFocus) 4867 { 4868 gtk_widget_set_can_focus(gtkWidget, canFocus); 4869 } 4870 4871 /** 4872 * Sets whether @widget should be mapped along with its when its parent 4873 * is mapped and @widget has been shown with gtk_widget_show(). 4874 * 4875 * The child visibility can be set for widget before it is added to 4876 * a container with gtk_widget_set_parent(), to avoid mapping 4877 * children unnecessary before immediately unmapping them. However 4878 * it will be reset to its default state of %TRUE when the widget 4879 * is removed from a container. 4880 * 4881 * Note that changing the child visibility of a widget does not 4882 * queue a resize on the widget. Most of the time, the size of 4883 * a widget is computed from all visible children, whether or 4884 * not they are mapped. If this is not the case, the container 4885 * can queue a resize itself. 4886 * 4887 * This function is only useful for container implementations and 4888 * never should be called by an application. 4889 * 4890 * Params: 4891 * isVisible = if %TRUE, @widget should be mapped along with its parent. 4892 */ 4893 public void setChildVisible(bool isVisible) 4894 { 4895 gtk_widget_set_child_visible(gtkWidget, isVisible); 4896 } 4897 4898 /** 4899 * Sets the widget’s clip. This must not be used directly, 4900 * but from within a widget’s size_allocate method. 4901 * It must be called after gtk_widget_set_allocation() (or after chaining up 4902 * to the parent class), because that function resets the clip. 4903 * 4904 * The clip set should be the area that @widget draws on. If @widget is a 4905 * #GtkContainer, the area must contain all children's clips. 4906 * 4907 * If this function is not called by @widget during a ::size-allocate handler, 4908 * the clip will be set to @widget's allocation. 4909 * 4910 * Params: 4911 * clip = a pointer to a #GtkAllocation to copy from 4912 * 4913 * Since: 3.14 4914 */ 4915 public void setClip(GtkAllocation* clip) 4916 { 4917 gtk_widget_set_clip(gtkWidget, clip); 4918 } 4919 4920 /** 4921 * Sets a widgets composite name. The widget must be 4922 * a composite child of its parent; see gtk_widget_push_composite_child(). 4923 * 4924 * Deprecated: Use gtk_widget_class_set_template(), or don’t use this API at all. 4925 * 4926 * Params: 4927 * name = the name to set 4928 */ 4929 public void setCompositeName(string name) 4930 { 4931 gtk_widget_set_composite_name(gtkWidget, Str.toStringz(name)); 4932 } 4933 4934 /** 4935 * Enables or disables a #GdkDevice to interact with @widget 4936 * and all its children. 4937 * 4938 * It does so by descending through the #GdkWindow hierarchy 4939 * and enabling the same mask that is has for core events 4940 * (i.e. the one that gdk_window_get_events() returns). 4941 * 4942 * Params: 4943 * device = a #GdkDevice 4944 * enabled = whether to enable the device 4945 * 4946 * Since: 3.0 4947 */ 4948 public void setDeviceEnabled(Device device, bool enabled) 4949 { 4950 gtk_widget_set_device_enabled(gtkWidget, (device is null) ? null : device.getDeviceStruct(), enabled); 4951 } 4952 4953 /** 4954 * Sets the device event mask (see #GdkEventMask) for a widget. The event 4955 * mask determines which events a widget will receive from @device. Keep 4956 * in mind that different widgets have different default event masks, and by 4957 * changing the event mask you may disrupt a widget’s functionality, 4958 * so be careful. This function must be called while a widget is 4959 * unrealized. Consider gtk_widget_add_device_events() for widgets that are 4960 * already realized, or if you want to preserve the existing event 4961 * mask. This function can’t be used with windowless widgets (which return 4962 * %FALSE from gtk_widget_get_has_window()); 4963 * to get events on those widgets, place them inside a #GtkEventBox 4964 * and receive events on the event box. 4965 * 4966 * Params: 4967 * device = a #GdkDevice 4968 * events = event mask 4969 * 4970 * Since: 3.0 4971 */ 4972 public void setDeviceEvents(Device device, GdkEventMask events) 4973 { 4974 gtk_widget_set_device_events(gtkWidget, (device is null) ? null : device.getDeviceStruct(), events); 4975 } 4976 4977 /** 4978 * Sets the reading direction on a particular widget. This direction 4979 * controls the primary direction for widgets containing text, 4980 * and also the direction in which the children of a container are 4981 * packed. The ability to set the direction is present in order 4982 * so that correct localization into languages with right-to-left 4983 * reading directions can be done. Generally, applications will 4984 * let the default reading direction present, except for containers 4985 * where the containers are arranged in an order that is explicitly 4986 * visual rather than logical (such as buttons for text justification). 4987 * 4988 * If the direction is set to %GTK_TEXT_DIR_NONE, then the value 4989 * set by gtk_widget_set_default_direction() will be used. 4990 * 4991 * Params: 4992 * dir = the new direction 4993 */ 4994 public void setDirection(GtkTextDirection dir) 4995 { 4996 gtk_widget_set_direction(gtkWidget, dir); 4997 } 4998 4999 /** 5000 * Widgets are double buffered by default; you can use this function 5001 * to turn off the buffering. “Double buffered” simply means that 5002 * gdk_window_begin_draw_frame() and gdk_window_end_draw_frame() are called 5003 * automatically around expose events sent to the 5004 * widget. gdk_window_begin_draw_frame() diverts all drawing to a widget's 5005 * window to an offscreen buffer, and gdk_window_end_draw_frame() draws the 5006 * buffer to the screen. The result is that users see the window 5007 * update in one smooth step, and don’t see individual graphics 5008 * primitives being rendered. 5009 * 5010 * In very simple terms, double buffered widgets don’t flicker, 5011 * so you would only use this function to turn off double buffering 5012 * if you had special needs and really knew what you were doing. 5013 * 5014 * Note: if you turn off double-buffering, you have to handle 5015 * expose events, since even the clearing to the background color or 5016 * pixmap will not happen automatically (as it is done in 5017 * gdk_window_begin_draw_frame()). 5018 * 5019 * In 3.10 GTK and GDK have been restructured for translucent drawing. Since 5020 * then expose events for double-buffered widgets are culled into a single 5021 * event to the toplevel GDK window. If you now unset double buffering, you 5022 * will cause a separate rendering pass for every widget. This will likely 5023 * cause rendering problems - in particular related to stacking - and usually 5024 * increases rendering times significantly. 5025 * 5026 * Deprecated: This function does not work under non-X11 backends or with 5027 * non-native windows. 5028 * It should not be used in newly written code. 5029 * 5030 * Params: 5031 * doubleBuffered = %TRUE to double-buffer a widget 5032 */ 5033 public void setDoubleBuffered(bool doubleBuffered) 5034 { 5035 gtk_widget_set_double_buffered(gtkWidget, doubleBuffered); 5036 } 5037 5038 /** 5039 * Sets the event mask (see #GdkEventMask) for a widget. The event 5040 * mask determines which events a widget will receive. Keep in mind 5041 * that different widgets have different default event masks, and by 5042 * changing the event mask you may disrupt a widget’s functionality, 5043 * so be careful. This function must be called while a widget is 5044 * unrealized. Consider gtk_widget_add_events() for widgets that are 5045 * already realized, or if you want to preserve the existing event 5046 * mask. This function can’t be used with widgets that have no window. 5047 * (See gtk_widget_get_has_window()). To get events on those widgets, 5048 * place them inside a #GtkEventBox and receive events on the event 5049 * box. 5050 * 5051 * Params: 5052 * events = event mask 5053 */ 5054 public void setEvents(int events) 5055 { 5056 gtk_widget_set_events(gtkWidget, events); 5057 } 5058 5059 /** 5060 * Sets whether the widget should grab focus when it is clicked with the mouse. 5061 * Making mouse clicks not grab focus is useful in places like toolbars where 5062 * you don’t want the keyboard focus removed from the main area of the 5063 * application. 5064 * 5065 * Params: 5066 * focusOnClick = whether the widget should grab focus when clicked with the mouse 5067 * 5068 * Since: 3.20 5069 */ 5070 public void setFocusOnClick(bool focusOnClick) 5071 { 5072 gtk_widget_set_focus_on_click(gtkWidget, focusOnClick); 5073 } 5074 5075 /** 5076 * Sets the font map to use for Pango rendering. When not set, the widget 5077 * will inherit the font map from its parent. 5078 * 5079 * Params: 5080 * fontMap = a #PangoFontMap, or %NULL to unset any previously 5081 * set font map 5082 * 5083 * Since: 3.18 5084 */ 5085 public void setFontMap(PgFontMap fontMap) 5086 { 5087 gtk_widget_set_font_map(gtkWidget, (fontMap is null) ? null : fontMap.getPgFontMapStruct()); 5088 } 5089 5090 /** 5091 * Sets the #cairo_font_options_t used for Pango rendering in this widget. 5092 * When not set, the default font options for the #GdkScreen will be used. 5093 * 5094 * Params: 5095 * options = a #cairo_font_options_t, or %NULL to unset any 5096 * previously set default font options. 5097 * 5098 * Since: 3.18 5099 */ 5100 public void setFontOptions(FontOption options) 5101 { 5102 gtk_widget_set_font_options(gtkWidget, (options is null) ? null : options.getFontOptionStruct()); 5103 } 5104 5105 /** 5106 * Sets the horizontal alignment of @widget. 5107 * See the #GtkWidget:halign property. 5108 * 5109 * Params: 5110 * alig = the horizontal alignment 5111 */ 5112 public void setHalign(GtkAlign alig) 5113 { 5114 gtk_widget_set_halign(gtkWidget, alig); 5115 } 5116 5117 /** 5118 * Sets the has-tooltip property on @widget to @has_tooltip. See 5119 * #GtkWidget:has-tooltip for more information. 5120 * 5121 * Params: 5122 * hasTooltip = whether or not @widget has a tooltip. 5123 * 5124 * Since: 2.12 5125 */ 5126 public void setHasTooltip(bool hasTooltip) 5127 { 5128 gtk_widget_set_has_tooltip(gtkWidget, hasTooltip); 5129 } 5130 5131 /** 5132 * Specifies whether @widget has a #GdkWindow of its own. Note that 5133 * all realized widgets have a non-%NULL “window” pointer 5134 * (gtk_widget_get_window() never returns a %NULL window when a widget 5135 * is realized), but for many of them it’s actually the #GdkWindow of 5136 * one of its parent widgets. Widgets that do not create a %window for 5137 * themselves in #GtkWidget::realize must announce this by 5138 * calling this function with @has_window = %FALSE. 5139 * 5140 * This function should only be called by widget implementations, 5141 * and they should call it in their init() function. 5142 * 5143 * Params: 5144 * hasWindow = whether or not @widget has a window. 5145 * 5146 * Since: 2.18 5147 */ 5148 public void setHasWindow(bool hasWindow) 5149 { 5150 gtk_widget_set_has_window(gtkWidget, hasWindow); 5151 } 5152 5153 /** 5154 * Sets whether the widget would like any available extra horizontal 5155 * space. When a user resizes a #GtkWindow, widgets with expand=TRUE 5156 * generally receive the extra space. For example, a list or 5157 * scrollable area or document in your window would often be set to 5158 * expand. 5159 * 5160 * Call this function to set the expand flag if you would like your 5161 * widget to become larger horizontally when the window has extra 5162 * room. 5163 * 5164 * By default, widgets automatically expand if any of their children 5165 * want to expand. (To see if a widget will automatically expand given 5166 * its current children and state, call gtk_widget_compute_expand(). A 5167 * container can decide how the expandability of children affects the 5168 * expansion of the container by overriding the compute_expand virtual 5169 * method on #GtkWidget.). 5170 * 5171 * Setting hexpand explicitly with this function will override the 5172 * automatic expand behavior. 5173 * 5174 * This function forces the widget to expand or not to expand, 5175 * regardless of children. The override occurs because 5176 * gtk_widget_set_hexpand() sets the hexpand-set property (see 5177 * gtk_widget_set_hexpand_set()) which causes the widget’s hexpand 5178 * value to be used, rather than looking at children and widget state. 5179 * 5180 * Params: 5181 * expand = whether to expand 5182 */ 5183 public void setHexpand(bool expand) 5184 { 5185 gtk_widget_set_hexpand(gtkWidget, expand); 5186 } 5187 5188 /** 5189 * Sets whether the hexpand flag (see gtk_widget_get_hexpand()) will 5190 * be used. 5191 * 5192 * The hexpand-set property will be set automatically when you call 5193 * gtk_widget_set_hexpand() to set hexpand, so the most likely 5194 * reason to use this function would be to unset an explicit expand 5195 * flag. 5196 * 5197 * If hexpand is set, then it overrides any computed 5198 * expand value based on child widgets. If hexpand is not 5199 * set, then the expand value depends on whether any 5200 * children of the widget would like to expand. 5201 * 5202 * There are few reasons to use this function, but it’s here 5203 * for completeness and consistency. 5204 * 5205 * Params: 5206 * set = value for hexpand-set property 5207 */ 5208 public void setHexpandSet(bool set) 5209 { 5210 gtk_widget_set_hexpand_set(gtkWidget, set); 5211 } 5212 5213 /** 5214 * Marks the widget as being mapped. 5215 * 5216 * This function should only ever be called in a derived widget's 5217 * “map” or “unmap” implementation. 5218 * 5219 * Params: 5220 * mapped = %TRUE to mark the widget as mapped 5221 * 5222 * Since: 2.20 5223 */ 5224 public void setMapped(bool mapped) 5225 { 5226 gtk_widget_set_mapped(gtkWidget, mapped); 5227 } 5228 5229 /** 5230 * Sets the bottom margin of @widget. 5231 * See the #GtkWidget:margin-bottom property. 5232 * 5233 * Params: 5234 * margin = the bottom margin 5235 * 5236 * Since: 3.0 5237 */ 5238 public void setMarginBottom(int margin) 5239 { 5240 gtk_widget_set_margin_bottom(gtkWidget, margin); 5241 } 5242 5243 /** 5244 * Sets the end margin of @widget. 5245 * See the #GtkWidget:margin-end property. 5246 * 5247 * Params: 5248 * margin = the end margin 5249 * 5250 * Since: 3.12 5251 */ 5252 public void setMarginEnd(int margin) 5253 { 5254 gtk_widget_set_margin_end(gtkWidget, margin); 5255 } 5256 5257 /** 5258 * Sets the left margin of @widget. 5259 * See the #GtkWidget:margin-left property. 5260 * 5261 * Deprecated: Use gtk_widget_set_margin_start() instead. 5262 * 5263 * Params: 5264 * margin = the left margin 5265 * 5266 * Since: 3.0 5267 */ 5268 public void setMarginLeft(int margin) 5269 { 5270 gtk_widget_set_margin_left(gtkWidget, margin); 5271 } 5272 5273 /** 5274 * Sets the right margin of @widget. 5275 * See the #GtkWidget:margin-right property. 5276 * 5277 * Deprecated: Use gtk_widget_set_margin_end() instead. 5278 * 5279 * Params: 5280 * margin = the right margin 5281 * 5282 * Since: 3.0 5283 */ 5284 public void setMarginRight(int margin) 5285 { 5286 gtk_widget_set_margin_right(gtkWidget, margin); 5287 } 5288 5289 /** 5290 * Sets the start margin of @widget. 5291 * See the #GtkWidget:margin-start property. 5292 * 5293 * Params: 5294 * margin = the start margin 5295 * 5296 * Since: 3.12 5297 */ 5298 public void setMarginStart(int margin) 5299 { 5300 gtk_widget_set_margin_start(gtkWidget, margin); 5301 } 5302 5303 /** 5304 * Sets the top margin of @widget. 5305 * See the #GtkWidget:margin-top property. 5306 * 5307 * Params: 5308 * margin = the top margin 5309 * 5310 * Since: 3.0 5311 */ 5312 public void setMarginTop(int margin) 5313 { 5314 gtk_widget_set_margin_top(gtkWidget, margin); 5315 } 5316 5317 /** 5318 * Widgets can be named, which allows you to refer to them from a 5319 * CSS file. You can apply a style to widgets with a particular name 5320 * in the CSS file. See the documentation for the CSS syntax (on the 5321 * same page as the docs for #GtkStyleContext). 5322 * 5323 * Note that the CSS syntax has certain special characters to delimit 5324 * and represent elements in a selector (period, #, >, *...), so using 5325 * these will make your widget impossible to match by name. Any combination 5326 * of alphanumeric symbols, dashes and underscores will suffice. 5327 * 5328 * Params: 5329 * name = name for the widget 5330 */ 5331 public void setName(string name) 5332 { 5333 gtk_widget_set_name(gtkWidget, Str.toStringz(name)); 5334 } 5335 5336 /** 5337 * Sets the #GtkWidget:no-show-all property, which determines whether 5338 * calls to gtk_widget_show_all() will affect this widget. 5339 * 5340 * This is mostly for use in constructing widget hierarchies with externally 5341 * controlled visibility, see #GtkUIManager. 5342 * 5343 * Params: 5344 * noShowAll = the new value for the “no-show-all” property 5345 * 5346 * Since: 2.4 5347 */ 5348 public void setNoShowAll(bool noShowAll) 5349 { 5350 gtk_widget_set_no_show_all(gtkWidget, noShowAll); 5351 } 5352 5353 /** 5354 * Request the @widget to be rendered partially transparent, 5355 * with opacity 0 being fully transparent and 1 fully opaque. (Opacity values 5356 * are clamped to the [0,1] range.). 5357 * This works on both toplevel widget, and child widgets, although there 5358 * are some limitations: 5359 * 5360 * For toplevel widgets this depends on the capabilities of the windowing 5361 * system. On X11 this has any effect only on X screens with a compositing manager 5362 * running. See gtk_widget_is_composited(). On Windows it should work 5363 * always, although setting a window’s opacity after the window has been 5364 * shown causes it to flicker once on Windows. 5365 * 5366 * For child widgets it doesn’t work if any affected widget has a native window, or 5367 * disables double buffering. 5368 * 5369 * Params: 5370 * opacity = desired opacity, between 0 and 1 5371 * 5372 * Since: 3.8 5373 */ 5374 public void setOpacity(double opacity) 5375 { 5376 gtk_widget_set_opacity(gtkWidget, opacity); 5377 } 5378 5379 /** 5380 * This function is useful only when implementing subclasses of 5381 * #GtkContainer. 5382 * Sets the container as the parent of @widget, and takes care of 5383 * some details such as updating the state and style of the child 5384 * to reflect its new location. The opposite function is 5385 * gtk_widget_unparent(). 5386 * 5387 * Params: 5388 * parent = parent container 5389 */ 5390 public void setParent(Widget parent) 5391 { 5392 gtk_widget_set_parent(gtkWidget, (parent is null) ? null : parent.getWidgetStruct()); 5393 } 5394 5395 /** 5396 * Sets a non default parent window for @widget. 5397 * 5398 * For #GtkWindow classes, setting a @parent_window effects whether 5399 * the window is a toplevel window or can be embedded into other 5400 * widgets. 5401 * 5402 * For #GtkWindow classes, this needs to be called before the 5403 * window is realized. 5404 * 5405 * Params: 5406 * parentWindow = the new parent window. 5407 */ 5408 public void setParentWindow(GdkWin parentWindow) 5409 { 5410 gtk_widget_set_parent_window(gtkWidget, (parentWindow is null) ? null : parentWindow.getWindowStruct()); 5411 } 5412 5413 /** 5414 * Marks the widget as being realized. This function must only be 5415 * called after all #GdkWindows for the @widget have been created 5416 * and registered. 5417 * 5418 * This function should only ever be called in a derived widget's 5419 * “realize” or “unrealize” implementation. 5420 * 5421 * Params: 5422 * realized = %TRUE to mark the widget as realized 5423 * 5424 * Since: 2.20 5425 */ 5426 public void setRealized(bool realized) 5427 { 5428 gtk_widget_set_realized(gtkWidget, realized); 5429 } 5430 5431 /** 5432 * Specifies whether @widget will be treated as the default widget 5433 * within its toplevel when it has the focus, even if another widget 5434 * is the default. 5435 * 5436 * See gtk_widget_grab_default() for details about the meaning of 5437 * “default”. 5438 * 5439 * Params: 5440 * receivesDefault = whether or not @widget can be a default widget. 5441 * 5442 * Since: 2.18 5443 */ 5444 public void setReceivesDefault(bool receivesDefault) 5445 { 5446 gtk_widget_set_receives_default(gtkWidget, receivesDefault); 5447 } 5448 5449 /** 5450 * Sets whether the entire widget is queued for drawing when its size 5451 * allocation changes. By default, this setting is %TRUE and 5452 * the entire widget is redrawn on every size change. If your widget 5453 * leaves the upper left unchanged when made bigger, turning this 5454 * setting off will improve performance. 5455 * 5456 * Note that for widgets where gtk_widget_get_has_window() is %FALSE 5457 * setting this flag to %FALSE turns off all allocation on resizing: 5458 * the widget will not even redraw if its position changes; this is to 5459 * allow containers that don’t draw anything to avoid excess 5460 * invalidations. If you set this flag on a widget with no window that 5461 * does draw on @widget->window, you are 5462 * responsible for invalidating both the old and new allocation of the 5463 * widget when the widget is moved and responsible for invalidating 5464 * regions newly when the widget increases size. 5465 * 5466 * Params: 5467 * redrawOnAllocate = if %TRUE, the entire widget will be redrawn 5468 * when it is allocated to a new size. Otherwise, only the 5469 * new portion of the widget will be redrawn. 5470 */ 5471 public void setRedrawOnAllocate(bool redrawOnAllocate) 5472 { 5473 gtk_widget_set_redraw_on_allocate(gtkWidget, redrawOnAllocate); 5474 } 5475 5476 /** 5477 * Sets the sensitivity of a widget. A widget is sensitive if the user 5478 * can interact with it. Insensitive widgets are “grayed out” and the 5479 * user can’t interact with them. Insensitive widgets are known as 5480 * “inactive”, “disabled”, or “ghosted” in some other toolkits. 5481 * 5482 * Params: 5483 * sensitive = %TRUE to make the widget sensitive 5484 */ 5485 public void setSensitive(bool sensitive) 5486 { 5487 gtk_widget_set_sensitive(gtkWidget, sensitive); 5488 } 5489 5490 /** 5491 * Sets the minimum size of a widget; that is, the widget’s size 5492 * request will be at least @width by @height. You can use this 5493 * function to force a widget to be larger than it normally would be. 5494 * 5495 * In most cases, gtk_window_set_default_size() is a better choice for 5496 * toplevel windows than this function; setting the default size will 5497 * still allow users to shrink the window. Setting the size request 5498 * will force them to leave the window at least as large as the size 5499 * request. When dealing with window sizes, 5500 * gtk_window_set_geometry_hints() can be a useful function as well. 5501 * 5502 * Note the inherent danger of setting any fixed size - themes, 5503 * translations into other languages, different fonts, and user action 5504 * can all change the appropriate size for a given widget. So, it's 5505 * basically impossible to hardcode a size that will always be 5506 * correct. 5507 * 5508 * The size request of a widget is the smallest size a widget can 5509 * accept while still functioning well and drawing itself correctly. 5510 * However in some strange cases a widget may be allocated less than 5511 * its requested size, and in many cases a widget may be allocated more 5512 * space than it requested. 5513 * 5514 * If the size request in a given direction is -1 (unset), then 5515 * the “natural” size request of the widget will be used instead. 5516 * 5517 * The size request set here does not include any margin from the 5518 * #GtkWidget properties margin-left, margin-right, margin-top, and 5519 * margin-bottom, but it does include pretty much all other padding 5520 * or border properties set by any subclass of #GtkWidget. 5521 * 5522 * Params: 5523 * width = width @widget should request, or -1 to unset 5524 * height = height @widget should request, or -1 to unset 5525 */ 5526 public void setSizeRequest(int width, int height) 5527 { 5528 gtk_widget_set_size_request(gtkWidget, width, height); 5529 } 5530 5531 /** 5532 * This function is for use in widget implementations. Turns on flag 5533 * values in the current widget state (insensitive, prelighted, etc.). 5534 * 5535 * This function accepts the values %GTK_STATE_FLAG_DIR_LTR and 5536 * %GTK_STATE_FLAG_DIR_RTL but ignores them. If you want to set the widget's 5537 * direction, use gtk_widget_set_direction(). 5538 * 5539 * It is worth mentioning that any other state than %GTK_STATE_FLAG_INSENSITIVE, 5540 * will be propagated down to all non-internal children if @widget is a 5541 * #GtkContainer, while %GTK_STATE_FLAG_INSENSITIVE itself will be propagated 5542 * down to all #GtkContainer children by different means than turning on the 5543 * state flag down the hierarchy, both gtk_widget_get_state_flags() and 5544 * gtk_widget_is_sensitive() will make use of these. 5545 * 5546 * Params: 5547 * flags = State flags to turn on 5548 * clear = Whether to clear state before turning on @flags 5549 * 5550 * Since: 3.0 5551 */ 5552 public void setStateFlags(GtkStateFlags flags, bool clear) 5553 { 5554 gtk_widget_set_state_flags(gtkWidget, flags, clear); 5555 } 5556 5557 /** 5558 * Used to set the #GtkStyle for a widget (@widget->style). Since 5559 * GTK 3, this function does nothing, the passed in style is ignored. 5560 * 5561 * Deprecated: Use #GtkStyleContext instead 5562 * 5563 * Params: 5564 * style = a #GtkStyle, or %NULL to remove the effect 5565 * of a previous call to gtk_widget_set_style() and go back to 5566 * the default style 5567 */ 5568 public void setStyle(Style style) 5569 { 5570 gtk_widget_set_style(gtkWidget, (style is null) ? null : style.getStyleStruct()); 5571 } 5572 5573 /** 5574 * Enables or disables multiple pointer awareness. If this setting is %TRUE, 5575 * @widget will start receiving multiple, per device enter/leave events. Note 5576 * that if custom #GdkWindows are created in #GtkWidget::realize, 5577 * gdk_window_set_support_multidevice() will have to be called manually on them. 5578 * 5579 * Params: 5580 * supportMultidevice = %TRUE to support input from multiple devices. 5581 * 5582 * Since: 3.0 5583 */ 5584 public void setSupportMultidevice(bool supportMultidevice) 5585 { 5586 gtk_widget_set_support_multidevice(gtkWidget, supportMultidevice); 5587 } 5588 5589 /** 5590 * Sets @markup as the contents of the tooltip, which is marked up with 5591 * the [Pango text markup language][PangoMarkupFormat]. 5592 * 5593 * This function will take care of setting #GtkWidget:has-tooltip to %TRUE 5594 * and of the default handler for the #GtkWidget::query-tooltip signal. 5595 * 5596 * See also the #GtkWidget:tooltip-markup property and 5597 * gtk_tooltip_set_markup(). 5598 * 5599 * Params: 5600 * markup = the contents of the tooltip for @widget, or %NULL 5601 * 5602 * Since: 2.12 5603 */ 5604 public void setTooltipMarkup(string markup) 5605 { 5606 gtk_widget_set_tooltip_markup(gtkWidget, Str.toStringz(markup)); 5607 } 5608 5609 /** 5610 * Sets @text as the contents of the tooltip. This function will take 5611 * care of setting #GtkWidget:has-tooltip to %TRUE and of the default 5612 * handler for the #GtkWidget::query-tooltip signal. 5613 * 5614 * See also the #GtkWidget:tooltip-text property and gtk_tooltip_set_text(). 5615 * 5616 * Params: 5617 * text = the contents of the tooltip for @widget 5618 * 5619 * Since: 2.12 5620 */ 5621 public void setTooltipText(string text) 5622 { 5623 gtk_widget_set_tooltip_text(gtkWidget, Str.toStringz(text)); 5624 } 5625 5626 /** 5627 * Replaces the default window used for displaying 5628 * tooltips with @custom_window. GTK+ will take care of showing and 5629 * hiding @custom_window at the right moment, to behave likewise as 5630 * the default tooltip window. If @custom_window is %NULL, the default 5631 * tooltip window will be used. 5632 * 5633 * Params: 5634 * customWindow = a #GtkWindow, or %NULL 5635 * 5636 * Since: 2.12 5637 */ 5638 public void setTooltipWindow(Window customWindow) 5639 { 5640 gtk_widget_set_tooltip_window(gtkWidget, (customWindow is null) ? null : customWindow.getWindowStruct()); 5641 } 5642 5643 /** 5644 * Sets the vertical alignment of @widget. 5645 * See the #GtkWidget:valign property. 5646 * 5647 * Params: 5648 * alig = the vertical alignment 5649 */ 5650 public void setValign(GtkAlign alig) 5651 { 5652 gtk_widget_set_valign(gtkWidget, alig); 5653 } 5654 5655 /** 5656 * Sets whether the widget would like any available extra vertical 5657 * space. 5658 * 5659 * See gtk_widget_set_hexpand() for more detail. 5660 * 5661 * Params: 5662 * expand = whether to expand 5663 */ 5664 public void setVexpand(bool expand) 5665 { 5666 gtk_widget_set_vexpand(gtkWidget, expand); 5667 } 5668 5669 /** 5670 * Sets whether the vexpand flag (see gtk_widget_get_vexpand()) will 5671 * be used. 5672 * 5673 * See gtk_widget_set_hexpand_set() for more detail. 5674 * 5675 * Params: 5676 * set = value for vexpand-set property 5677 */ 5678 public void setVexpandSet(bool set) 5679 { 5680 gtk_widget_set_vexpand_set(gtkWidget, set); 5681 } 5682 5683 /** 5684 * Sets the visibility state of @widget. Note that setting this to 5685 * %TRUE doesn’t mean the widget is actually viewable, see 5686 * gtk_widget_get_visible(). 5687 * 5688 * This function simply calls gtk_widget_show() or gtk_widget_hide() 5689 * but is nicer to use when the visibility of the widget depends on 5690 * some condition. 5691 * 5692 * Params: 5693 * visible = whether the widget should be shown or not 5694 * 5695 * Since: 2.18 5696 */ 5697 public void setVisible(bool visible) 5698 { 5699 gtk_widget_set_visible(gtkWidget, visible); 5700 } 5701 5702 /** 5703 * Sets the visual that should be used for by widget and its children for 5704 * creating #GdkWindows. The visual must be on the same #GdkScreen as 5705 * returned by gtk_widget_get_screen(), so handling the 5706 * #GtkWidget::screen-changed signal is necessary. 5707 * 5708 * Setting a new @visual will not cause @widget to recreate its windows, 5709 * so you should call this function before @widget is realized. 5710 * 5711 * Params: 5712 * visual = visual to be used or %NULL to unset a previous one 5713 */ 5714 public void setVisual(Visual visual) 5715 { 5716 gtk_widget_set_visual(gtkWidget, (visual is null) ? null : visual.getVisualStruct()); 5717 } 5718 5719 /** 5720 * Sets a widget’s window. This function should only be used in a 5721 * widget’s #GtkWidget::realize implementation. The %window passed is 5722 * usually either new window created with gdk_window_new(), or the 5723 * window of its parent widget as returned by 5724 * gtk_widget_get_parent_window(). 5725 * 5726 * Widgets must indicate whether they will create their own #GdkWindow 5727 * by calling gtk_widget_set_has_window(). This is usually done in the 5728 * widget’s init() function. 5729 * 5730 * Note that this function does not add any reference to @window. 5731 * 5732 * Params: 5733 * window = a #GdkWindow 5734 * 5735 * Since: 2.18 5736 */ 5737 public void setWindow(GdkWin window) 5738 { 5739 gtk_widget_set_window(gtkWidget, (window is null) ? null : window.getWindowStruct()); 5740 } 5741 5742 /** 5743 * Sets a shape for this widget’s GDK window. This allows for 5744 * transparent windows etc., see gdk_window_shape_combine_region() 5745 * for more information. 5746 * 5747 * Params: 5748 * region = shape to be added, or %NULL to remove an existing shape 5749 * 5750 * Since: 3.0 5751 */ 5752 public void shapeCombineRegion(Region region) 5753 { 5754 gtk_widget_shape_combine_region(gtkWidget, (region is null) ? null : region.getRegionStruct()); 5755 } 5756 5757 /** 5758 * Flags a widget to be displayed. Any widget that isn’t shown will 5759 * not appear on the screen. If you want to show all the widgets in a 5760 * container, it’s easier to call gtk_widget_show_all() on the 5761 * container, instead of individually showing the widgets. 5762 * 5763 * Remember that you have to show the containers containing a widget, 5764 * in addition to the widget itself, before it will appear onscreen. 5765 * 5766 * When a toplevel container is shown, it is immediately realized and 5767 * mapped; other shown widgets are realized and mapped when their 5768 * toplevel container is realized and mapped. 5769 */ 5770 public void show() 5771 { 5772 gtk_widget_show(gtkWidget); 5773 } 5774 5775 /** 5776 * Recursively shows a widget, and any child widgets (if the widget is 5777 * a container). 5778 */ 5779 public void showAll() 5780 { 5781 gtk_widget_show_all(gtkWidget); 5782 } 5783 5784 /** 5785 * Shows a widget. If the widget is an unmapped toplevel widget 5786 * (i.e. a #GtkWindow that has not yet been shown), enter the main 5787 * loop and wait for the window to actually be mapped. Be careful; 5788 * because the main loop is running, anything can happen during 5789 * this function. 5790 */ 5791 public void showNow() 5792 { 5793 gtk_widget_show_now(gtkWidget); 5794 } 5795 5796 /** 5797 * This function is only used by #GtkContainer subclasses, to assign a size 5798 * and position to their child widgets. 5799 * 5800 * In this function, the allocation may be adjusted. It will be forced 5801 * to a 1x1 minimum size, and the adjust_size_allocation virtual 5802 * method on the child will be used to adjust the allocation. Standard 5803 * adjustments include removing the widget’s margins, and applying the 5804 * widget’s #GtkWidget:halign and #GtkWidget:valign properties. 5805 * 5806 * For baseline support in containers you need to use gtk_widget_size_allocate_with_baseline() 5807 * instead. 5808 * 5809 * Params: 5810 * allocation = position and size to be allocated to @widget 5811 */ 5812 public void sizeAllocate(GtkAllocation* allocation) 5813 { 5814 gtk_widget_size_allocate(gtkWidget, allocation); 5815 } 5816 5817 /** 5818 * This function is only used by #GtkContainer subclasses, to assign a size, 5819 * position and (optionally) baseline to their child widgets. 5820 * 5821 * In this function, the allocation and baseline may be adjusted. It 5822 * will be forced to a 1x1 minimum size, and the 5823 * adjust_size_allocation virtual and adjust_baseline_allocation 5824 * methods on the child will be used to adjust the allocation and 5825 * baseline. Standard adjustments include removing the widget's 5826 * margins, and applying the widget’s #GtkWidget:halign and 5827 * #GtkWidget:valign properties. 5828 * 5829 * If the child widget does not have a valign of %GTK_ALIGN_BASELINE the 5830 * baseline argument is ignored and -1 is used instead. 5831 * 5832 * Params: 5833 * allocation = position and size to be allocated to @widget 5834 * baseline = The baseline of the child, or -1 5835 * 5836 * Since: 3.10 5837 */ 5838 public void sizeAllocateWithBaseline(GtkAllocation* allocation, int baseline) 5839 { 5840 gtk_widget_size_allocate_with_baseline(gtkWidget, allocation, baseline); 5841 } 5842 5843 /** 5844 * This function is typically used when implementing a #GtkContainer 5845 * subclass. Obtains the preferred size of a widget. The container 5846 * uses this information to arrange its child widgets and decide what 5847 * size allocations to give them with gtk_widget_size_allocate(). 5848 * 5849 * You can also call this function from an application, with some 5850 * caveats. Most notably, getting a size request requires the widget 5851 * to be associated with a screen, because font information may be 5852 * needed. Multihead-aware applications should keep this in mind. 5853 * 5854 * Also remember that the size request is not necessarily the size 5855 * a widget will actually be allocated. 5856 * 5857 * Deprecated: Use gtk_widget_get_preferred_size() instead. 5858 * 5859 * Params: 5860 * requisition = a #GtkRequisition to be filled in 5861 */ 5862 public void sizeRequest(out Requisition requisition) 5863 { 5864 GtkRequisition* outrequisition = sliceNew!GtkRequisition(); 5865 5866 gtk_widget_size_request(gtkWidget, outrequisition); 5867 5868 requisition = ObjectG.getDObject!(Requisition)(outrequisition, true); 5869 } 5870 5871 /** 5872 * This function attaches the widget’s #GtkStyle to the widget's 5873 * #GdkWindow. It is a replacement for 5874 * 5875 * |[ 5876 * widget->style = gtk_style_attach (widget->style, widget->window); 5877 * ]| 5878 * 5879 * and should only ever be called in a derived widget’s “realize” 5880 * implementation which does not chain up to its parent class' 5881 * “realize” implementation, because one of the parent classes 5882 * (finally #GtkWidget) would attach the style itself. 5883 * 5884 * Deprecated: This step is unnecessary with #GtkStyleContext. 5885 * 5886 * Since: 2.20 5887 */ 5888 public void styleAttach() 5889 { 5890 gtk_widget_style_attach(gtkWidget); 5891 } 5892 5893 /** 5894 * Gets the value of a style property of @widget. 5895 * 5896 * Params: 5897 * propertyName = the name of a style property 5898 * value = location to return the property value 5899 */ 5900 public void styleGetProperty(string propertyName, Value value) 5901 { 5902 gtk_widget_style_get_property(gtkWidget, Str.toStringz(propertyName), (value is null) ? null : value.getValueStruct()); 5903 } 5904 5905 /** 5906 * Non-vararg variant of gtk_widget_style_get(). Used primarily by language 5907 * bindings. 5908 * 5909 * Params: 5910 * firstPropertyName = the name of the first property to get 5911 * varArgs = a va_list of pairs of property names and 5912 * locations to return the property values, starting with the location 5913 * for @first_property_name. 5914 */ 5915 public void styleGetValist(string firstPropertyName, void* varArgs) 5916 { 5917 gtk_widget_style_get_valist(gtkWidget, Str.toStringz(firstPropertyName), varArgs); 5918 } 5919 5920 /** 5921 * Reverts the effect of a previous call to gtk_widget_freeze_child_notify(). 5922 * This causes all queued #GtkWidget::child-notify signals on @widget to be 5923 * emitted. 5924 */ 5925 public void thawChildNotify() 5926 { 5927 gtk_widget_thaw_child_notify(gtkWidget); 5928 } 5929 5930 /** 5931 * Translate coordinates relative to @src_widget’s allocation to coordinates 5932 * relative to @dest_widget’s allocations. In order to perform this 5933 * operation, both widgets must be realized, and must share a common 5934 * toplevel. 5935 * 5936 * Params: 5937 * destWidget = a #GtkWidget 5938 * srcX = X position relative to @src_widget 5939 * srcY = Y position relative to @src_widget 5940 * destX = location to store X position relative to @dest_widget 5941 * destY = location to store Y position relative to @dest_widget 5942 * 5943 * Returns: %FALSE if either widget was not realized, or there 5944 * was no common ancestor. In this case, nothing is stored in 5945 * *@dest_x and *@dest_y. Otherwise %TRUE. 5946 */ 5947 public bool translateCoordinates(Widget destWidget, int srcX, int srcY, out int destX, out int destY) 5948 { 5949 return gtk_widget_translate_coordinates(gtkWidget, (destWidget is null) ? null : destWidget.getWidgetStruct(), srcX, srcY, &destX, &destY) != 0; 5950 } 5951 5952 /** 5953 * Triggers a tooltip query on the display where the toplevel of @widget 5954 * is located. See gtk_tooltip_trigger_tooltip_query() for more 5955 * information. 5956 * 5957 * Since: 2.12 5958 */ 5959 public void triggerTooltipQuery() 5960 { 5961 gtk_widget_trigger_tooltip_query(gtkWidget); 5962 } 5963 5964 /** 5965 * This function is only for use in widget implementations. Causes 5966 * a widget to be unmapped if it’s currently mapped. 5967 */ 5968 public void unmap() 5969 { 5970 gtk_widget_unmap(gtkWidget); 5971 } 5972 5973 /** 5974 * This function is only for use in widget implementations. 5975 * Should be called by implementations of the remove method 5976 * on #GtkContainer, to dissociate a child from the container. 5977 */ 5978 public void unparent() 5979 { 5980 gtk_widget_unparent(gtkWidget); 5981 } 5982 5983 /** 5984 * This function is only useful in widget implementations. 5985 * Causes a widget to be unrealized (frees all GDK resources 5986 * associated with the widget, such as @widget->window). 5987 */ 5988 public void unrealize() 5989 { 5990 gtk_widget_unrealize(gtkWidget); 5991 } 5992 5993 /** 5994 * Unregisters a #GdkWindow from the widget that was previously set up with 5995 * gtk_widget_register_window(). You need to call this when the window is 5996 * no longer used by the widget, such as when you destroy it. 5997 * 5998 * Params: 5999 * window = a #GdkWindow 6000 * 6001 * Since: 3.8 6002 */ 6003 public void unregisterWindow(GdkWin window) 6004 { 6005 gtk_widget_unregister_window(gtkWidget, (window is null) ? null : window.getWindowStruct()); 6006 } 6007 6008 /** 6009 * This function is for use in widget implementations. Turns off flag 6010 * values for the current widget state (insensitive, prelighted, etc.). 6011 * See gtk_widget_set_state_flags(). 6012 * 6013 * Params: 6014 * flags = State flags to turn off 6015 * 6016 * Since: 3.0 6017 */ 6018 public void unsetStateFlags(GtkStateFlags flags) 6019 { 6020 gtk_widget_unset_state_flags(gtkWidget, flags); 6021 } 6022 6023 protected class OnAccelClosuresChangedDelegateWrapper 6024 { 6025 void delegate(Widget) dlg; 6026 gulong handlerId; 6027 6028 this(void delegate(Widget) dlg) 6029 { 6030 this.dlg = dlg; 6031 onAccelClosuresChangedListeners ~= this; 6032 } 6033 6034 void remove(OnAccelClosuresChangedDelegateWrapper source) 6035 { 6036 foreach(index, wrapper; onAccelClosuresChangedListeners) 6037 { 6038 if (wrapper.handlerId == source.handlerId) 6039 { 6040 onAccelClosuresChangedListeners[index] = null; 6041 onAccelClosuresChangedListeners = std.algorithm.remove(onAccelClosuresChangedListeners, index); 6042 break; 6043 } 6044 } 6045 } 6046 } 6047 OnAccelClosuresChangedDelegateWrapper[] onAccelClosuresChangedListeners; 6048 6049 /** */ 6050 gulong addOnAccelClosuresChanged(void delegate(Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 6051 { 6052 auto wrapper = new OnAccelClosuresChangedDelegateWrapper(dlg); 6053 wrapper.handlerId = Signals.connectData( 6054 this, 6055 "accel-closures-changed", 6056 cast(GCallback)&callBackAccelClosuresChanged, 6057 cast(void*)wrapper, 6058 cast(GClosureNotify)&callBackAccelClosuresChangedDestroy, 6059 connectFlags); 6060 return wrapper.handlerId; 6061 } 6062 6063 extern(C) static void callBackAccelClosuresChanged(GtkWidget* widgetStruct, OnAccelClosuresChangedDelegateWrapper wrapper) 6064 { 6065 wrapper.dlg(wrapper.outer); 6066 } 6067 6068 extern(C) static void callBackAccelClosuresChangedDestroy(OnAccelClosuresChangedDelegateWrapper wrapper, GClosure* closure) 6069 { 6070 wrapper.remove(wrapper); 6071 } 6072 6073 protected class OnButtonPressDelegateWrapper 6074 { 6075 bool delegate(GdkEventButton*, Widget) dlg; 6076 gulong handlerId; 6077 6078 this(bool delegate(GdkEventButton*, Widget) dlg) 6079 { 6080 this.dlg = dlg; 6081 onButtonPressListeners ~= this; 6082 } 6083 6084 void remove(OnButtonPressDelegateWrapper source) 6085 { 6086 foreach(index, wrapper; onButtonPressListeners) 6087 { 6088 if (wrapper.handlerId == source.handlerId) 6089 { 6090 onButtonPressListeners[index] = null; 6091 onButtonPressListeners = std.algorithm.remove(onButtonPressListeners, index); 6092 break; 6093 } 6094 } 6095 } 6096 } 6097 OnButtonPressDelegateWrapper[] onButtonPressListeners; 6098 6099 /** 6100 * The ::button-press-event signal will be emitted when a button 6101 * (typically from a mouse) is pressed. 6102 * 6103 * To receive this signal, the #GdkWindow associated to the 6104 * widget needs to enable the #GDK_BUTTON_PRESS_MASK mask. 6105 * 6106 * This signal will be sent to the grab widget if there is one. 6107 * 6108 * Params: 6109 * event = the #GdkEventButton which triggered 6110 * this signal. 6111 * 6112 * Returns: %TRUE to stop other handlers from being invoked for the event. 6113 * %FALSE to propagate the event further. 6114 */ 6115 gulong addOnButtonPress(bool delegate(GdkEventButton*, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 6116 { 6117 addEvents(EventMask.BUTTON_PRESS_MASK); 6118 auto wrapper = new OnButtonPressDelegateWrapper(dlg); 6119 wrapper.handlerId = Signals.connectData( 6120 this, 6121 "button-press-event", 6122 cast(GCallback)&callBackButtonPress, 6123 cast(void*)wrapper, 6124 cast(GClosureNotify)&callBackButtonPressDestroy, 6125 connectFlags); 6126 return wrapper.handlerId; 6127 } 6128 6129 extern(C) static int callBackButtonPress(GtkWidget* widgetStruct, GdkEventButton* event, OnButtonPressDelegateWrapper wrapper) 6130 { 6131 return wrapper.dlg(event, wrapper.outer); 6132 } 6133 6134 extern(C) static void callBackButtonPressDestroy(OnButtonPressDelegateWrapper wrapper, GClosure* closure) 6135 { 6136 wrapper.remove(wrapper); 6137 } 6138 6139 protected class OnButtonPressEventGenericDelegateWrapper 6140 { 6141 bool delegate(Event, Widget) dlg; 6142 gulong handlerId; 6143 6144 this(bool delegate(Event, Widget) dlg) 6145 { 6146 this.dlg = dlg; 6147 onButtonPressEventGenericListeners ~= this; 6148 } 6149 6150 void remove(OnButtonPressEventGenericDelegateWrapper source) 6151 { 6152 foreach(index, wrapper; onButtonPressEventGenericListeners) 6153 { 6154 if (wrapper.handlerId == source.handlerId) 6155 { 6156 onButtonPressEventGenericListeners[index] = null; 6157 onButtonPressEventGenericListeners = std.algorithm.remove(onButtonPressEventGenericListeners, index); 6158 break; 6159 } 6160 } 6161 } 6162 } 6163 OnButtonPressEventGenericDelegateWrapper[] onButtonPressEventGenericListeners; 6164 6165 /** 6166 * The ::button-press-event signal will be emitted when a button 6167 * (typically from a mouse) is pressed. 6168 * 6169 * To receive this signal, the #GdkWindow associated to the 6170 * widget needs to enable the #GDK_BUTTON_PRESS_MASK mask. 6171 * 6172 * This signal will be sent to the grab widget if there is one. 6173 * 6174 * Params: 6175 * event = the #GdkEventButton which triggered 6176 * this signal. 6177 * 6178 * Returns: %TRUE to stop other handlers from being invoked for the event. 6179 * %FALSE to propagate the event further. 6180 */ 6181 gulong addOnButtonPress(bool delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 6182 { 6183 addEvents(EventMask.BUTTON_PRESS_MASK); 6184 auto wrapper = new OnButtonPressEventGenericDelegateWrapper(dlg); 6185 wrapper.handlerId = Signals.connectData( 6186 this, 6187 "button-press-event", 6188 cast(GCallback)&callBackButtonPressEventGeneric, 6189 cast(void*)wrapper, 6190 cast(GClosureNotify)&callBackButtonPressEventGenericDestroy, 6191 connectFlags); 6192 return wrapper.handlerId; 6193 } 6194 6195 extern(C) static int callBackButtonPressEventGeneric(GtkWidget* widgetStruct, GdkEvent* event, OnButtonPressEventGenericDelegateWrapper wrapper) 6196 { 6197 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 6198 } 6199 6200 extern(C) static void callBackButtonPressEventGenericDestroy(OnButtonPressEventGenericDelegateWrapper wrapper, GClosure* closure) 6201 { 6202 wrapper.remove(wrapper); 6203 } 6204 6205 protected class OnButtonReleaseDelegateWrapper 6206 { 6207 bool delegate(GdkEventButton*, Widget) dlg; 6208 gulong handlerId; 6209 6210 this(bool delegate(GdkEventButton*, Widget) dlg) 6211 { 6212 this.dlg = dlg; 6213 onButtonReleaseListeners ~= this; 6214 } 6215 6216 void remove(OnButtonReleaseDelegateWrapper source) 6217 { 6218 foreach(index, wrapper; onButtonReleaseListeners) 6219 { 6220 if (wrapper.handlerId == source.handlerId) 6221 { 6222 onButtonReleaseListeners[index] = null; 6223 onButtonReleaseListeners = std.algorithm.remove(onButtonReleaseListeners, index); 6224 break; 6225 } 6226 } 6227 } 6228 } 6229 OnButtonReleaseDelegateWrapper[] onButtonReleaseListeners; 6230 6231 /** 6232 * The ::button-release-event signal will be emitted when a button 6233 * (typically from a mouse) is released. 6234 * 6235 * To receive this signal, the #GdkWindow associated to the 6236 * widget needs to enable the #GDK_BUTTON_RELEASE_MASK mask. 6237 * 6238 * This signal will be sent to the grab widget if there is one. 6239 * 6240 * Params: 6241 * event = the #GdkEventButton which triggered 6242 * this signal. 6243 * 6244 * Returns: %TRUE to stop other handlers from being invoked for the event. 6245 * %FALSE to propagate the event further. 6246 */ 6247 gulong addOnButtonRelease(bool delegate(GdkEventButton*, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 6248 { 6249 addEvents(EventMask.BUTTON_RELEASE_MASK); 6250 auto wrapper = new OnButtonReleaseDelegateWrapper(dlg); 6251 wrapper.handlerId = Signals.connectData( 6252 this, 6253 "button-release-event", 6254 cast(GCallback)&callBackButtonRelease, 6255 cast(void*)wrapper, 6256 cast(GClosureNotify)&callBackButtonReleaseDestroy, 6257 connectFlags); 6258 return wrapper.handlerId; 6259 } 6260 6261 extern(C) static int callBackButtonRelease(GtkWidget* widgetStruct, GdkEventButton* event, OnButtonReleaseDelegateWrapper wrapper) 6262 { 6263 return wrapper.dlg(event, wrapper.outer); 6264 } 6265 6266 extern(C) static void callBackButtonReleaseDestroy(OnButtonReleaseDelegateWrapper wrapper, GClosure* closure) 6267 { 6268 wrapper.remove(wrapper); 6269 } 6270 6271 protected class OnButtonReleaseEventGenericDelegateWrapper 6272 { 6273 bool delegate(Event, Widget) dlg; 6274 gulong handlerId; 6275 6276 this(bool delegate(Event, Widget) dlg) 6277 { 6278 this.dlg = dlg; 6279 onButtonReleaseEventGenericListeners ~= this; 6280 } 6281 6282 void remove(OnButtonReleaseEventGenericDelegateWrapper source) 6283 { 6284 foreach(index, wrapper; onButtonReleaseEventGenericListeners) 6285 { 6286 if (wrapper.handlerId == source.handlerId) 6287 { 6288 onButtonReleaseEventGenericListeners[index] = null; 6289 onButtonReleaseEventGenericListeners = std.algorithm.remove(onButtonReleaseEventGenericListeners, index); 6290 break; 6291 } 6292 } 6293 } 6294 } 6295 OnButtonReleaseEventGenericDelegateWrapper[] onButtonReleaseEventGenericListeners; 6296 6297 /** 6298 * The ::button-release-event signal will be emitted when a button 6299 * (typically from a mouse) is released. 6300 * 6301 * To receive this signal, the #GdkWindow associated to the 6302 * widget needs to enable the #GDK_BUTTON_RELEASE_MASK mask. 6303 * 6304 * This signal will be sent to the grab widget if there is one. 6305 * 6306 * Params: 6307 * event = the #GdkEventButton which triggered 6308 * this signal. 6309 * 6310 * Returns: %TRUE to stop other handlers from being invoked for the event. 6311 * %FALSE to propagate the event further. 6312 */ 6313 gulong addOnButtonRelease(bool delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 6314 { 6315 addEvents(EventMask.BUTTON_RELEASE_MASK); 6316 auto wrapper = new OnButtonReleaseEventGenericDelegateWrapper(dlg); 6317 wrapper.handlerId = Signals.connectData( 6318 this, 6319 "button-release-event", 6320 cast(GCallback)&callBackButtonReleaseEventGeneric, 6321 cast(void*)wrapper, 6322 cast(GClosureNotify)&callBackButtonReleaseEventGenericDestroy, 6323 connectFlags); 6324 return wrapper.handlerId; 6325 } 6326 6327 extern(C) static int callBackButtonReleaseEventGeneric(GtkWidget* widgetStruct, GdkEvent* event, OnButtonReleaseEventGenericDelegateWrapper wrapper) 6328 { 6329 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 6330 } 6331 6332 extern(C) static void callBackButtonReleaseEventGenericDestroy(OnButtonReleaseEventGenericDelegateWrapper wrapper, GClosure* closure) 6333 { 6334 wrapper.remove(wrapper); 6335 } 6336 6337 protected class OnCanActivateAccelDelegateWrapper 6338 { 6339 bool delegate(uint, Widget) dlg; 6340 gulong handlerId; 6341 6342 this(bool delegate(uint, Widget) dlg) 6343 { 6344 this.dlg = dlg; 6345 onCanActivateAccelListeners ~= this; 6346 } 6347 6348 void remove(OnCanActivateAccelDelegateWrapper source) 6349 { 6350 foreach(index, wrapper; onCanActivateAccelListeners) 6351 { 6352 if (wrapper.handlerId == source.handlerId) 6353 { 6354 onCanActivateAccelListeners[index] = null; 6355 onCanActivateAccelListeners = std.algorithm.remove(onCanActivateAccelListeners, index); 6356 break; 6357 } 6358 } 6359 } 6360 } 6361 OnCanActivateAccelDelegateWrapper[] onCanActivateAccelListeners; 6362 6363 /** 6364 * Determines whether an accelerator that activates the signal 6365 * identified by @signal_id can currently be activated. 6366 * This signal is present to allow applications and derived 6367 * widgets to override the default #GtkWidget handling 6368 * for determining whether an accelerator can be activated. 6369 * 6370 * Params: 6371 * signalId = the ID of a signal installed on @widget 6372 * 6373 * Returns: %TRUE if the signal can be activated. 6374 */ 6375 gulong addOnCanActivateAccel(bool delegate(uint, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 6376 { 6377 auto wrapper = new OnCanActivateAccelDelegateWrapper(dlg); 6378 wrapper.handlerId = Signals.connectData( 6379 this, 6380 "can-activate-accel", 6381 cast(GCallback)&callBackCanActivateAccel, 6382 cast(void*)wrapper, 6383 cast(GClosureNotify)&callBackCanActivateAccelDestroy, 6384 connectFlags); 6385 return wrapper.handlerId; 6386 } 6387 6388 extern(C) static int callBackCanActivateAccel(GtkWidget* widgetStruct, uint signalId, OnCanActivateAccelDelegateWrapper wrapper) 6389 { 6390 return wrapper.dlg(signalId, wrapper.outer); 6391 } 6392 6393 extern(C) static void callBackCanActivateAccelDestroy(OnCanActivateAccelDelegateWrapper wrapper, GClosure* closure) 6394 { 6395 wrapper.remove(wrapper); 6396 } 6397 6398 protected class OnChildNotifyDelegateWrapper 6399 { 6400 void delegate(ParamSpec, Widget) dlg; 6401 gulong handlerId; 6402 6403 this(void delegate(ParamSpec, Widget) dlg) 6404 { 6405 this.dlg = dlg; 6406 onChildNotifyListeners ~= this; 6407 } 6408 6409 void remove(OnChildNotifyDelegateWrapper source) 6410 { 6411 foreach(index, wrapper; onChildNotifyListeners) 6412 { 6413 if (wrapper.handlerId == source.handlerId) 6414 { 6415 onChildNotifyListeners[index] = null; 6416 onChildNotifyListeners = std.algorithm.remove(onChildNotifyListeners, index); 6417 break; 6418 } 6419 } 6420 } 6421 } 6422 OnChildNotifyDelegateWrapper[] onChildNotifyListeners; 6423 6424 /** 6425 * The ::child-notify signal is emitted for each 6426 * [child property][child-properties] that has 6427 * changed on an object. The signal's detail holds the property name. 6428 * 6429 * Params: 6430 * childProperty = the #GParamSpec of the changed child property 6431 */ 6432 gulong addOnChildNotify(void delegate(ParamSpec, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 6433 { 6434 auto wrapper = new OnChildNotifyDelegateWrapper(dlg); 6435 wrapper.handlerId = Signals.connectData( 6436 this, 6437 "child-notify", 6438 cast(GCallback)&callBackChildNotify, 6439 cast(void*)wrapper, 6440 cast(GClosureNotify)&callBackChildNotifyDestroy, 6441 connectFlags); 6442 return wrapper.handlerId; 6443 } 6444 6445 extern(C) static void callBackChildNotify(GtkWidget* widgetStruct, GParamSpec* childProperty, OnChildNotifyDelegateWrapper wrapper) 6446 { 6447 wrapper.dlg(ObjectG.getDObject!(ParamSpec)(childProperty), wrapper.outer); 6448 } 6449 6450 extern(C) static void callBackChildNotifyDestroy(OnChildNotifyDelegateWrapper wrapper, GClosure* closure) 6451 { 6452 wrapper.remove(wrapper); 6453 } 6454 6455 protected class OnCompositedChangedDelegateWrapper 6456 { 6457 void delegate(Widget) dlg; 6458 gulong handlerId; 6459 6460 this(void delegate(Widget) dlg) 6461 { 6462 this.dlg = dlg; 6463 onCompositedChangedListeners ~= this; 6464 } 6465 6466 void remove(OnCompositedChangedDelegateWrapper source) 6467 { 6468 foreach(index, wrapper; onCompositedChangedListeners) 6469 { 6470 if (wrapper.handlerId == source.handlerId) 6471 { 6472 onCompositedChangedListeners[index] = null; 6473 onCompositedChangedListeners = std.algorithm.remove(onCompositedChangedListeners, index); 6474 break; 6475 } 6476 } 6477 } 6478 } 6479 OnCompositedChangedDelegateWrapper[] onCompositedChangedListeners; 6480 6481 /** 6482 * The ::composited-changed signal is emitted when the composited 6483 * status of @widgets screen changes. 6484 * See gdk_screen_is_composited(). 6485 * 6486 * Deprecated: Use GdkScreen::composited-changed instead. 6487 */ 6488 gulong addOnCompositedChanged(void delegate(Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 6489 { 6490 auto wrapper = new OnCompositedChangedDelegateWrapper(dlg); 6491 wrapper.handlerId = Signals.connectData( 6492 this, 6493 "composited-changed", 6494 cast(GCallback)&callBackCompositedChanged, 6495 cast(void*)wrapper, 6496 cast(GClosureNotify)&callBackCompositedChangedDestroy, 6497 connectFlags); 6498 return wrapper.handlerId; 6499 } 6500 6501 extern(C) static void callBackCompositedChanged(GtkWidget* widgetStruct, OnCompositedChangedDelegateWrapper wrapper) 6502 { 6503 wrapper.dlg(wrapper.outer); 6504 } 6505 6506 extern(C) static void callBackCompositedChangedDestroy(OnCompositedChangedDelegateWrapper wrapper, GClosure* closure) 6507 { 6508 wrapper.remove(wrapper); 6509 } 6510 6511 protected class OnConfigureDelegateWrapper 6512 { 6513 bool delegate(GdkEventConfigure*, Widget) dlg; 6514 gulong handlerId; 6515 6516 this(bool delegate(GdkEventConfigure*, Widget) dlg) 6517 { 6518 this.dlg = dlg; 6519 onConfigureListeners ~= this; 6520 } 6521 6522 void remove(OnConfigureDelegateWrapper source) 6523 { 6524 foreach(index, wrapper; onConfigureListeners) 6525 { 6526 if (wrapper.handlerId == source.handlerId) 6527 { 6528 onConfigureListeners[index] = null; 6529 onConfigureListeners = std.algorithm.remove(onConfigureListeners, index); 6530 break; 6531 } 6532 } 6533 } 6534 } 6535 OnConfigureDelegateWrapper[] onConfigureListeners; 6536 6537 /** 6538 * The ::configure-event signal will be emitted when the size, position or 6539 * stacking of the @widget's window has changed. 6540 * 6541 * To receive this signal, the #GdkWindow associated to the widget needs 6542 * to enable the #GDK_STRUCTURE_MASK mask. GDK will enable this mask 6543 * automatically for all new windows. 6544 * 6545 * Params: 6546 * event = the #GdkEventConfigure which triggered 6547 * this signal. 6548 * 6549 * Returns: %TRUE to stop other handlers from being invoked for the event. 6550 * %FALSE to propagate the event further. 6551 */ 6552 gulong addOnConfigure(bool delegate(GdkEventConfigure*, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 6553 { 6554 auto wrapper = new OnConfigureDelegateWrapper(dlg); 6555 wrapper.handlerId = Signals.connectData( 6556 this, 6557 "configure-event", 6558 cast(GCallback)&callBackConfigure, 6559 cast(void*)wrapper, 6560 cast(GClosureNotify)&callBackConfigureDestroy, 6561 connectFlags); 6562 return wrapper.handlerId; 6563 } 6564 6565 extern(C) static int callBackConfigure(GtkWidget* widgetStruct, GdkEventConfigure* event, OnConfigureDelegateWrapper wrapper) 6566 { 6567 return wrapper.dlg(event, wrapper.outer); 6568 } 6569 6570 extern(C) static void callBackConfigureDestroy(OnConfigureDelegateWrapper wrapper, GClosure* closure) 6571 { 6572 wrapper.remove(wrapper); 6573 } 6574 6575 protected class OnConfigureEventGenericDelegateWrapper 6576 { 6577 bool delegate(Event, Widget) dlg; 6578 gulong handlerId; 6579 6580 this(bool delegate(Event, Widget) dlg) 6581 { 6582 this.dlg = dlg; 6583 onConfigureEventGenericListeners ~= this; 6584 } 6585 6586 void remove(OnConfigureEventGenericDelegateWrapper source) 6587 { 6588 foreach(index, wrapper; onConfigureEventGenericListeners) 6589 { 6590 if (wrapper.handlerId == source.handlerId) 6591 { 6592 onConfigureEventGenericListeners[index] = null; 6593 onConfigureEventGenericListeners = std.algorithm.remove(onConfigureEventGenericListeners, index); 6594 break; 6595 } 6596 } 6597 } 6598 } 6599 OnConfigureEventGenericDelegateWrapper[] onConfigureEventGenericListeners; 6600 6601 /** 6602 * The ::configure-event signal will be emitted when the size, position or 6603 * stacking of the @widget's window has changed. 6604 * 6605 * To receive this signal, the #GdkWindow associated to the widget needs 6606 * to enable the #GDK_STRUCTURE_MASK mask. GDK will enable this mask 6607 * automatically for all new windows. 6608 * 6609 * Params: 6610 * event = the #GdkEventConfigure which triggered 6611 * this signal. 6612 * 6613 * Returns: %TRUE to stop other handlers from being invoked for the event. 6614 * %FALSE to propagate the event further. 6615 */ 6616 gulong addOnConfigure(bool delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 6617 { 6618 auto wrapper = new OnConfigureEventGenericDelegateWrapper(dlg); 6619 wrapper.handlerId = Signals.connectData( 6620 this, 6621 "configure-event", 6622 cast(GCallback)&callBackConfigureEventGeneric, 6623 cast(void*)wrapper, 6624 cast(GClosureNotify)&callBackConfigureEventGenericDestroy, 6625 connectFlags); 6626 return wrapper.handlerId; 6627 } 6628 6629 extern(C) static int callBackConfigureEventGeneric(GtkWidget* widgetStruct, GdkEvent* event, OnConfigureEventGenericDelegateWrapper wrapper) 6630 { 6631 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 6632 } 6633 6634 extern(C) static void callBackConfigureEventGenericDestroy(OnConfigureEventGenericDelegateWrapper wrapper, GClosure* closure) 6635 { 6636 wrapper.remove(wrapper); 6637 } 6638 6639 protected class OnDamageDelegateWrapper 6640 { 6641 bool delegate(GdkEventExpose*, Widget) dlg; 6642 gulong handlerId; 6643 6644 this(bool delegate(GdkEventExpose*, Widget) dlg) 6645 { 6646 this.dlg = dlg; 6647 onDamageListeners ~= this; 6648 } 6649 6650 void remove(OnDamageDelegateWrapper source) 6651 { 6652 foreach(index, wrapper; onDamageListeners) 6653 { 6654 if (wrapper.handlerId == source.handlerId) 6655 { 6656 onDamageListeners[index] = null; 6657 onDamageListeners = std.algorithm.remove(onDamageListeners, index); 6658 break; 6659 } 6660 } 6661 } 6662 } 6663 OnDamageDelegateWrapper[] onDamageListeners; 6664 6665 /** 6666 * Emitted when a redirected window belonging to @widget gets drawn into. 6667 * The region/area members of the event shows what area of the redirected 6668 * drawable was drawn into. 6669 * 6670 * Params: 6671 * event = the #GdkEventExpose event 6672 * 6673 * Returns: %TRUE to stop other handlers from being invoked for the event. 6674 * %FALSE to propagate the event further. 6675 * 6676 * Since: 2.14 6677 */ 6678 gulong addOnDamage(bool delegate(GdkEventExpose*, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 6679 { 6680 auto wrapper = new OnDamageDelegateWrapper(dlg); 6681 wrapper.handlerId = Signals.connectData( 6682 this, 6683 "damage-event", 6684 cast(GCallback)&callBackDamage, 6685 cast(void*)wrapper, 6686 cast(GClosureNotify)&callBackDamageDestroy, 6687 connectFlags); 6688 return wrapper.handlerId; 6689 } 6690 6691 extern(C) static int callBackDamage(GtkWidget* widgetStruct, GdkEventExpose* event, OnDamageDelegateWrapper wrapper) 6692 { 6693 return wrapper.dlg(event, wrapper.outer); 6694 } 6695 6696 extern(C) static void callBackDamageDestroy(OnDamageDelegateWrapper wrapper, GClosure* closure) 6697 { 6698 wrapper.remove(wrapper); 6699 } 6700 6701 protected class OnDamageEventGenericDelegateWrapper 6702 { 6703 bool delegate(Event, Widget) dlg; 6704 gulong handlerId; 6705 6706 this(bool delegate(Event, Widget) dlg) 6707 { 6708 this.dlg = dlg; 6709 onDamageEventGenericListeners ~= this; 6710 } 6711 6712 void remove(OnDamageEventGenericDelegateWrapper source) 6713 { 6714 foreach(index, wrapper; onDamageEventGenericListeners) 6715 { 6716 if (wrapper.handlerId == source.handlerId) 6717 { 6718 onDamageEventGenericListeners[index] = null; 6719 onDamageEventGenericListeners = std.algorithm.remove(onDamageEventGenericListeners, index); 6720 break; 6721 } 6722 } 6723 } 6724 } 6725 OnDamageEventGenericDelegateWrapper[] onDamageEventGenericListeners; 6726 6727 /** 6728 * Emitted when a redirected window belonging to @widget gets drawn into. 6729 * The region/area members of the event shows what area of the redirected 6730 * drawable was drawn into. 6731 * 6732 * Params: 6733 * event = the #GdkEventExpose event 6734 * 6735 * Returns: %TRUE to stop other handlers from being invoked for the event. 6736 * %FALSE to propagate the event further. 6737 * 6738 * Since: 2.14 6739 */ 6740 gulong addOnDamage(bool delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 6741 { 6742 auto wrapper = new OnDamageEventGenericDelegateWrapper(dlg); 6743 wrapper.handlerId = Signals.connectData( 6744 this, 6745 "damage-event", 6746 cast(GCallback)&callBackDamageEventGeneric, 6747 cast(void*)wrapper, 6748 cast(GClosureNotify)&callBackDamageEventGenericDestroy, 6749 connectFlags); 6750 return wrapper.handlerId; 6751 } 6752 6753 extern(C) static int callBackDamageEventGeneric(GtkWidget* widgetStruct, GdkEvent* event, OnDamageEventGenericDelegateWrapper wrapper) 6754 { 6755 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 6756 } 6757 6758 extern(C) static void callBackDamageEventGenericDestroy(OnDamageEventGenericDelegateWrapper wrapper, GClosure* closure) 6759 { 6760 wrapper.remove(wrapper); 6761 } 6762 6763 protected class OnDeleteDelegateWrapper 6764 { 6765 bool delegate(Event, Widget) dlg; 6766 gulong handlerId; 6767 6768 this(bool delegate(Event, Widget) dlg) 6769 { 6770 this.dlg = dlg; 6771 onDeleteListeners ~= this; 6772 } 6773 6774 void remove(OnDeleteDelegateWrapper source) 6775 { 6776 foreach(index, wrapper; onDeleteListeners) 6777 { 6778 if (wrapper.handlerId == source.handlerId) 6779 { 6780 onDeleteListeners[index] = null; 6781 onDeleteListeners = std.algorithm.remove(onDeleteListeners, index); 6782 break; 6783 } 6784 } 6785 } 6786 } 6787 OnDeleteDelegateWrapper[] onDeleteListeners; 6788 6789 /** 6790 * The ::delete-event signal is emitted if a user requests that 6791 * a toplevel window is closed. The default handler for this signal 6792 * destroys the window. Connecting gtk_widget_hide_on_delete() to 6793 * this signal will cause the window to be hidden instead, so that 6794 * it can later be shown again without reconstructing it. 6795 * 6796 * Params: 6797 * event = the event which triggered this signal 6798 * 6799 * Returns: %TRUE to stop other handlers from being invoked for the event. 6800 * %FALSE to propagate the event further. 6801 */ 6802 gulong addOnDelete(bool delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 6803 { 6804 auto wrapper = new OnDeleteDelegateWrapper(dlg); 6805 wrapper.handlerId = Signals.connectData( 6806 this, 6807 "delete-event", 6808 cast(GCallback)&callBackDelete, 6809 cast(void*)wrapper, 6810 cast(GClosureNotify)&callBackDeleteDestroy, 6811 connectFlags); 6812 return wrapper.handlerId; 6813 } 6814 6815 extern(C) static int callBackDelete(GtkWidget* widgetStruct, GdkEvent* event, OnDeleteDelegateWrapper wrapper) 6816 { 6817 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 6818 } 6819 6820 extern(C) static void callBackDeleteDestroy(OnDeleteDelegateWrapper wrapper, GClosure* closure) 6821 { 6822 wrapper.remove(wrapper); 6823 } 6824 6825 protected class OnDestroyDelegateWrapper 6826 { 6827 void delegate(Widget) dlg; 6828 gulong handlerId; 6829 6830 this(void delegate(Widget) dlg) 6831 { 6832 this.dlg = dlg; 6833 onDestroyListeners ~= this; 6834 } 6835 6836 void remove(OnDestroyDelegateWrapper source) 6837 { 6838 foreach(index, wrapper; onDestroyListeners) 6839 { 6840 if (wrapper.handlerId == source.handlerId) 6841 { 6842 onDestroyListeners[index] = null; 6843 onDestroyListeners = std.algorithm.remove(onDestroyListeners, index); 6844 break; 6845 } 6846 } 6847 } 6848 } 6849 OnDestroyDelegateWrapper[] onDestroyListeners; 6850 6851 /** 6852 * Signals that all holders of a reference to the widget should release 6853 * the reference that they hold. May result in finalization of the widget 6854 * if all references are released. 6855 * 6856 * This signal is not suitable for saving widget state. 6857 */ 6858 gulong addOnDestroy(void delegate(Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 6859 { 6860 auto wrapper = new OnDestroyDelegateWrapper(dlg); 6861 wrapper.handlerId = Signals.connectData( 6862 this, 6863 "destroy", 6864 cast(GCallback)&callBackDestroy, 6865 cast(void*)wrapper, 6866 cast(GClosureNotify)&callBackDestroyDestroy, 6867 connectFlags); 6868 return wrapper.handlerId; 6869 } 6870 6871 extern(C) static void callBackDestroy(GtkWidget* widgetStruct, OnDestroyDelegateWrapper wrapper) 6872 { 6873 wrapper.dlg(wrapper.outer); 6874 } 6875 6876 extern(C) static void callBackDestroyDestroy(OnDestroyDelegateWrapper wrapper, GClosure* closure) 6877 { 6878 wrapper.remove(wrapper); 6879 } 6880 6881 protected class OnDestroyEventDelegateWrapper 6882 { 6883 bool delegate(Event, Widget) dlg; 6884 gulong handlerId; 6885 6886 this(bool delegate(Event, Widget) dlg) 6887 { 6888 this.dlg = dlg; 6889 onDestroyEventListeners ~= this; 6890 } 6891 6892 void remove(OnDestroyEventDelegateWrapper source) 6893 { 6894 foreach(index, wrapper; onDestroyEventListeners) 6895 { 6896 if (wrapper.handlerId == source.handlerId) 6897 { 6898 onDestroyEventListeners[index] = null; 6899 onDestroyEventListeners = std.algorithm.remove(onDestroyEventListeners, index); 6900 break; 6901 } 6902 } 6903 } 6904 } 6905 OnDestroyEventDelegateWrapper[] onDestroyEventListeners; 6906 6907 /** 6908 * The ::destroy-event signal is emitted when a #GdkWindow is destroyed. 6909 * You rarely get this signal, because most widgets disconnect themselves 6910 * from their window before they destroy it, so no widget owns the 6911 * window at destroy time. 6912 * 6913 * To receive this signal, the #GdkWindow associated to the widget needs 6914 * to enable the #GDK_STRUCTURE_MASK mask. GDK will enable this mask 6915 * automatically for all new windows. 6916 * 6917 * Params: 6918 * event = the event which triggered this signal 6919 * 6920 * Returns: %TRUE to stop other handlers from being invoked for the event. 6921 * %FALSE to propagate the event further. 6922 */ 6923 gulong addOnDestroyEvent(bool delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 6924 { 6925 auto wrapper = new OnDestroyEventDelegateWrapper(dlg); 6926 wrapper.handlerId = Signals.connectData( 6927 this, 6928 "destroy-event", 6929 cast(GCallback)&callBackDestroyEvent, 6930 cast(void*)wrapper, 6931 cast(GClosureNotify)&callBackDestroyEventDestroy, 6932 connectFlags); 6933 return wrapper.handlerId; 6934 } 6935 6936 extern(C) static int callBackDestroyEvent(GtkWidget* widgetStruct, GdkEvent* event, OnDestroyEventDelegateWrapper wrapper) 6937 { 6938 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 6939 } 6940 6941 extern(C) static void callBackDestroyEventDestroy(OnDestroyEventDelegateWrapper wrapper, GClosure* closure) 6942 { 6943 wrapper.remove(wrapper); 6944 } 6945 6946 protected class OnDirectionChangedDelegateWrapper 6947 { 6948 void delegate(GtkTextDirection, Widget) dlg; 6949 gulong handlerId; 6950 6951 this(void delegate(GtkTextDirection, Widget) dlg) 6952 { 6953 this.dlg = dlg; 6954 onDirectionChangedListeners ~= this; 6955 } 6956 6957 void remove(OnDirectionChangedDelegateWrapper source) 6958 { 6959 foreach(index, wrapper; onDirectionChangedListeners) 6960 { 6961 if (wrapper.handlerId == source.handlerId) 6962 { 6963 onDirectionChangedListeners[index] = null; 6964 onDirectionChangedListeners = std.algorithm.remove(onDirectionChangedListeners, index); 6965 break; 6966 } 6967 } 6968 } 6969 } 6970 OnDirectionChangedDelegateWrapper[] onDirectionChangedListeners; 6971 6972 /** 6973 * The ::direction-changed signal is emitted when the text direction 6974 * of a widget changes. 6975 * 6976 * Params: 6977 * previousDirection = the previous text direction of @widget 6978 */ 6979 gulong addOnDirectionChanged(void delegate(GtkTextDirection, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 6980 { 6981 auto wrapper = new OnDirectionChangedDelegateWrapper(dlg); 6982 wrapper.handlerId = Signals.connectData( 6983 this, 6984 "direction-changed", 6985 cast(GCallback)&callBackDirectionChanged, 6986 cast(void*)wrapper, 6987 cast(GClosureNotify)&callBackDirectionChangedDestroy, 6988 connectFlags); 6989 return wrapper.handlerId; 6990 } 6991 6992 extern(C) static void callBackDirectionChanged(GtkWidget* widgetStruct, GtkTextDirection previousDirection, OnDirectionChangedDelegateWrapper wrapper) 6993 { 6994 wrapper.dlg(previousDirection, wrapper.outer); 6995 } 6996 6997 extern(C) static void callBackDirectionChangedDestroy(OnDirectionChangedDelegateWrapper wrapper, GClosure* closure) 6998 { 6999 wrapper.remove(wrapper); 7000 } 7001 7002 protected class OnDragBeginDelegateWrapper 7003 { 7004 void delegate(DragContext, Widget) dlg; 7005 gulong handlerId; 7006 7007 this(void delegate(DragContext, Widget) dlg) 7008 { 7009 this.dlg = dlg; 7010 onDragBeginListeners ~= this; 7011 } 7012 7013 void remove(OnDragBeginDelegateWrapper source) 7014 { 7015 foreach(index, wrapper; onDragBeginListeners) 7016 { 7017 if (wrapper.handlerId == source.handlerId) 7018 { 7019 onDragBeginListeners[index] = null; 7020 onDragBeginListeners = std.algorithm.remove(onDragBeginListeners, index); 7021 break; 7022 } 7023 } 7024 } 7025 } 7026 OnDragBeginDelegateWrapper[] onDragBeginListeners; 7027 7028 /** 7029 * The ::drag-begin signal is emitted on the drag source when a drag is 7030 * started. A typical reason to connect to this signal is to set up a 7031 * custom drag icon with e.g. gtk_drag_source_set_icon_pixbuf(). 7032 * 7033 * Note that some widgets set up a drag icon in the default handler of 7034 * this signal, so you may have to use g_signal_connect_after() to 7035 * override what the default handler did. 7036 * 7037 * Params: 7038 * context = the drag context 7039 */ 7040 gulong addOnDragBegin(void delegate(DragContext, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 7041 { 7042 auto wrapper = new OnDragBeginDelegateWrapper(dlg); 7043 wrapper.handlerId = Signals.connectData( 7044 this, 7045 "drag-begin", 7046 cast(GCallback)&callBackDragBegin, 7047 cast(void*)wrapper, 7048 cast(GClosureNotify)&callBackDragBeginDestroy, 7049 connectFlags); 7050 return wrapper.handlerId; 7051 } 7052 7053 extern(C) static void callBackDragBegin(GtkWidget* widgetStruct, GdkDragContext* context, OnDragBeginDelegateWrapper wrapper) 7054 { 7055 wrapper.dlg(ObjectG.getDObject!(DragContext)(context), wrapper.outer); 7056 } 7057 7058 extern(C) static void callBackDragBeginDestroy(OnDragBeginDelegateWrapper wrapper, GClosure* closure) 7059 { 7060 wrapper.remove(wrapper); 7061 } 7062 7063 protected class OnDragDataDeleteDelegateWrapper 7064 { 7065 void delegate(DragContext, Widget) dlg; 7066 gulong handlerId; 7067 7068 this(void delegate(DragContext, Widget) dlg) 7069 { 7070 this.dlg = dlg; 7071 onDragDataDeleteListeners ~= this; 7072 } 7073 7074 void remove(OnDragDataDeleteDelegateWrapper source) 7075 { 7076 foreach(index, wrapper; onDragDataDeleteListeners) 7077 { 7078 if (wrapper.handlerId == source.handlerId) 7079 { 7080 onDragDataDeleteListeners[index] = null; 7081 onDragDataDeleteListeners = std.algorithm.remove(onDragDataDeleteListeners, index); 7082 break; 7083 } 7084 } 7085 } 7086 } 7087 OnDragDataDeleteDelegateWrapper[] onDragDataDeleteListeners; 7088 7089 /** 7090 * The ::drag-data-delete signal is emitted on the drag source when a drag 7091 * with the action %GDK_ACTION_MOVE is successfully completed. The signal 7092 * handler is responsible for deleting the data that has been dropped. What 7093 * "delete" means depends on the context of the drag operation. 7094 * 7095 * Params: 7096 * context = the drag context 7097 */ 7098 gulong addOnDragDataDelete(void delegate(DragContext, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 7099 { 7100 auto wrapper = new OnDragDataDeleteDelegateWrapper(dlg); 7101 wrapper.handlerId = Signals.connectData( 7102 this, 7103 "drag-data-delete", 7104 cast(GCallback)&callBackDragDataDelete, 7105 cast(void*)wrapper, 7106 cast(GClosureNotify)&callBackDragDataDeleteDestroy, 7107 connectFlags); 7108 return wrapper.handlerId; 7109 } 7110 7111 extern(C) static void callBackDragDataDelete(GtkWidget* widgetStruct, GdkDragContext* context, OnDragDataDeleteDelegateWrapper wrapper) 7112 { 7113 wrapper.dlg(ObjectG.getDObject!(DragContext)(context), wrapper.outer); 7114 } 7115 7116 extern(C) static void callBackDragDataDeleteDestroy(OnDragDataDeleteDelegateWrapper wrapper, GClosure* closure) 7117 { 7118 wrapper.remove(wrapper); 7119 } 7120 7121 protected class OnDragDataGetDelegateWrapper 7122 { 7123 void delegate(DragContext, SelectionData, uint, uint, Widget) dlg; 7124 gulong handlerId; 7125 7126 this(void delegate(DragContext, SelectionData, uint, uint, Widget) dlg) 7127 { 7128 this.dlg = dlg; 7129 onDragDataGetListeners ~= this; 7130 } 7131 7132 void remove(OnDragDataGetDelegateWrapper source) 7133 { 7134 foreach(index, wrapper; onDragDataGetListeners) 7135 { 7136 if (wrapper.handlerId == source.handlerId) 7137 { 7138 onDragDataGetListeners[index] = null; 7139 onDragDataGetListeners = std.algorithm.remove(onDragDataGetListeners, index); 7140 break; 7141 } 7142 } 7143 } 7144 } 7145 OnDragDataGetDelegateWrapper[] onDragDataGetListeners; 7146 7147 /** 7148 * The ::drag-data-get signal is emitted on the drag source when the drop 7149 * site requests the data which is dragged. It is the responsibility of 7150 * the signal handler to fill @data with the data in the format which 7151 * is indicated by @info. See gtk_selection_data_set() and 7152 * gtk_selection_data_set_text(). 7153 * 7154 * Params: 7155 * context = the drag context 7156 * data = the #GtkSelectionData to be filled with the dragged data 7157 * info = the info that has been registered with the target in the 7158 * #GtkTargetList 7159 * time = the timestamp at which the data was requested 7160 */ 7161 gulong addOnDragDataGet(void delegate(DragContext, SelectionData, uint, uint, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 7162 { 7163 auto wrapper = new OnDragDataGetDelegateWrapper(dlg); 7164 wrapper.handlerId = Signals.connectData( 7165 this, 7166 "drag-data-get", 7167 cast(GCallback)&callBackDragDataGet, 7168 cast(void*)wrapper, 7169 cast(GClosureNotify)&callBackDragDataGetDestroy, 7170 connectFlags); 7171 return wrapper.handlerId; 7172 } 7173 7174 extern(C) static void callBackDragDataGet(GtkWidget* widgetStruct, GdkDragContext* context, GtkSelectionData* data, uint info, uint time, OnDragDataGetDelegateWrapper wrapper) 7175 { 7176 wrapper.dlg(ObjectG.getDObject!(DragContext)(context), ObjectG.getDObject!(SelectionData)(data), info, time, wrapper.outer); 7177 } 7178 7179 extern(C) static void callBackDragDataGetDestroy(OnDragDataGetDelegateWrapper wrapper, GClosure* closure) 7180 { 7181 wrapper.remove(wrapper); 7182 } 7183 7184 protected class OnDragDataReceivedDelegateWrapper 7185 { 7186 void delegate(DragContext, int, int, SelectionData, uint, uint, Widget) dlg; 7187 gulong handlerId; 7188 7189 this(void delegate(DragContext, int, int, SelectionData, uint, uint, Widget) dlg) 7190 { 7191 this.dlg = dlg; 7192 onDragDataReceivedListeners ~= this; 7193 } 7194 7195 void remove(OnDragDataReceivedDelegateWrapper source) 7196 { 7197 foreach(index, wrapper; onDragDataReceivedListeners) 7198 { 7199 if (wrapper.handlerId == source.handlerId) 7200 { 7201 onDragDataReceivedListeners[index] = null; 7202 onDragDataReceivedListeners = std.algorithm.remove(onDragDataReceivedListeners, index); 7203 break; 7204 } 7205 } 7206 } 7207 } 7208 OnDragDataReceivedDelegateWrapper[] onDragDataReceivedListeners; 7209 7210 /** 7211 * The ::drag-data-received signal is emitted on the drop site when the 7212 * dragged data has been received. If the data was received in order to 7213 * determine whether the drop will be accepted, the handler is expected 7214 * to call gdk_drag_status() and not finish the drag. 7215 * If the data was received in response to a #GtkWidget::drag-drop signal 7216 * (and this is the last target to be received), the handler for this 7217 * signal is expected to process the received data and then call 7218 * gtk_drag_finish(), setting the @success parameter depending on 7219 * whether the data was processed successfully. 7220 * 7221 * Applications must create some means to determine why the signal was emitted 7222 * and therefore whether to call gdk_drag_status() or gtk_drag_finish(). 7223 * 7224 * The handler may inspect the selected action with 7225 * gdk_drag_context_get_selected_action() before calling 7226 * gtk_drag_finish(), e.g. to implement %GDK_ACTION_ASK as 7227 * shown in the following example: 7228 * |[<!-- language="C" --> 7229 * void 7230 * drag_data_received (GtkWidget *widget, 7231 * GdkDragContext *context, 7232 * gint x, 7233 * gint y, 7234 * GtkSelectionData *data, 7235 * guint info, 7236 * guint time) 7237 * { 7238 * if ((data->length >= 0) && (data->format == 8)) 7239 * { 7240 * GdkDragAction action; 7241 * 7242 * // handle data here 7243 * 7244 * action = gdk_drag_context_get_selected_action (context); 7245 * if (action == GDK_ACTION_ASK) 7246 * { 7247 * GtkWidget *dialog; 7248 * gint response; 7249 * 7250 * dialog = gtk_message_dialog_new (NULL, 7251 * GTK_DIALOG_MODAL | 7252 * GTK_DIALOG_DESTROY_WITH_PARENT, 7253 * GTK_MESSAGE_INFO, 7254 * GTK_BUTTONS_YES_NO, 7255 * "Move the data ?\n"); 7256 * response = gtk_dialog_run (GTK_DIALOG (dialog)); 7257 * gtk_widget_destroy (dialog); 7258 * 7259 * if (response == GTK_RESPONSE_YES) 7260 * action = GDK_ACTION_MOVE; 7261 * else 7262 * action = GDK_ACTION_COPY; 7263 * } 7264 * 7265 * gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time); 7266 * } 7267 * else 7268 * gtk_drag_finish (context, FALSE, FALSE, time); 7269 * } 7270 * ]| 7271 * 7272 * Params: 7273 * context = the drag context 7274 * x = where the drop happened 7275 * y = where the drop happened 7276 * data = the received data 7277 * info = the info that has been registered with the target in the 7278 * #GtkTargetList 7279 * time = the timestamp at which the data was received 7280 */ 7281 gulong addOnDragDataReceived(void delegate(DragContext, int, int, SelectionData, uint, uint, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 7282 { 7283 auto wrapper = new OnDragDataReceivedDelegateWrapper(dlg); 7284 wrapper.handlerId = Signals.connectData( 7285 this, 7286 "drag-data-received", 7287 cast(GCallback)&callBackDragDataReceived, 7288 cast(void*)wrapper, 7289 cast(GClosureNotify)&callBackDragDataReceivedDestroy, 7290 connectFlags); 7291 return wrapper.handlerId; 7292 } 7293 7294 extern(C) static void callBackDragDataReceived(GtkWidget* widgetStruct, GdkDragContext* context, int x, int y, GtkSelectionData* data, uint info, uint time, OnDragDataReceivedDelegateWrapper wrapper) 7295 { 7296 wrapper.dlg(ObjectG.getDObject!(DragContext)(context), x, y, ObjectG.getDObject!(SelectionData)(data), info, time, wrapper.outer); 7297 } 7298 7299 extern(C) static void callBackDragDataReceivedDestroy(OnDragDataReceivedDelegateWrapper wrapper, GClosure* closure) 7300 { 7301 wrapper.remove(wrapper); 7302 } 7303 7304 protected class OnDragDropDelegateWrapper 7305 { 7306 bool delegate(DragContext, int, int, uint, Widget) dlg; 7307 gulong handlerId; 7308 7309 this(bool delegate(DragContext, int, int, uint, Widget) dlg) 7310 { 7311 this.dlg = dlg; 7312 onDragDropListeners ~= this; 7313 } 7314 7315 void remove(OnDragDropDelegateWrapper source) 7316 { 7317 foreach(index, wrapper; onDragDropListeners) 7318 { 7319 if (wrapper.handlerId == source.handlerId) 7320 { 7321 onDragDropListeners[index] = null; 7322 onDragDropListeners = std.algorithm.remove(onDragDropListeners, index); 7323 break; 7324 } 7325 } 7326 } 7327 } 7328 OnDragDropDelegateWrapper[] onDragDropListeners; 7329 7330 /** 7331 * The ::drag-drop signal is emitted on the drop site when the user drops 7332 * the data onto the widget. The signal handler must determine whether 7333 * the cursor position is in a drop zone or not. If it is not in a drop 7334 * zone, it returns %FALSE and no further processing is necessary. 7335 * Otherwise, the handler returns %TRUE. In this case, the handler must 7336 * ensure that gtk_drag_finish() is called to let the source know that 7337 * the drop is done. The call to gtk_drag_finish() can be done either 7338 * directly or in a #GtkWidget::drag-data-received handler which gets 7339 * triggered by calling gtk_drag_get_data() to receive the data for one 7340 * or more of the supported targets. 7341 * 7342 * Params: 7343 * context = the drag context 7344 * x = the x coordinate of the current cursor position 7345 * y = the y coordinate of the current cursor position 7346 * time = the timestamp of the motion event 7347 * 7348 * Returns: whether the cursor position is in a drop zone 7349 */ 7350 gulong addOnDragDrop(bool delegate(DragContext, int, int, uint, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 7351 { 7352 auto wrapper = new OnDragDropDelegateWrapper(dlg); 7353 wrapper.handlerId = Signals.connectData( 7354 this, 7355 "drag-drop", 7356 cast(GCallback)&callBackDragDrop, 7357 cast(void*)wrapper, 7358 cast(GClosureNotify)&callBackDragDropDestroy, 7359 connectFlags); 7360 return wrapper.handlerId; 7361 } 7362 7363 extern(C) static int callBackDragDrop(GtkWidget* widgetStruct, GdkDragContext* context, int x, int y, uint time, OnDragDropDelegateWrapper wrapper) 7364 { 7365 return wrapper.dlg(ObjectG.getDObject!(DragContext)(context), x, y, time, wrapper.outer); 7366 } 7367 7368 extern(C) static void callBackDragDropDestroy(OnDragDropDelegateWrapper wrapper, GClosure* closure) 7369 { 7370 wrapper.remove(wrapper); 7371 } 7372 7373 protected class OnDragEndDelegateWrapper 7374 { 7375 void delegate(DragContext, Widget) dlg; 7376 gulong handlerId; 7377 7378 this(void delegate(DragContext, Widget) dlg) 7379 { 7380 this.dlg = dlg; 7381 onDragEndListeners ~= this; 7382 } 7383 7384 void remove(OnDragEndDelegateWrapper source) 7385 { 7386 foreach(index, wrapper; onDragEndListeners) 7387 { 7388 if (wrapper.handlerId == source.handlerId) 7389 { 7390 onDragEndListeners[index] = null; 7391 onDragEndListeners = std.algorithm.remove(onDragEndListeners, index); 7392 break; 7393 } 7394 } 7395 } 7396 } 7397 OnDragEndDelegateWrapper[] onDragEndListeners; 7398 7399 /** 7400 * The ::drag-end signal is emitted on the drag source when a drag is 7401 * finished. A typical reason to connect to this signal is to undo 7402 * things done in #GtkWidget::drag-begin. 7403 * 7404 * Params: 7405 * context = the drag context 7406 */ 7407 gulong addOnDragEnd(void delegate(DragContext, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 7408 { 7409 auto wrapper = new OnDragEndDelegateWrapper(dlg); 7410 wrapper.handlerId = Signals.connectData( 7411 this, 7412 "drag-end", 7413 cast(GCallback)&callBackDragEnd, 7414 cast(void*)wrapper, 7415 cast(GClosureNotify)&callBackDragEndDestroy, 7416 connectFlags); 7417 return wrapper.handlerId; 7418 } 7419 7420 extern(C) static void callBackDragEnd(GtkWidget* widgetStruct, GdkDragContext* context, OnDragEndDelegateWrapper wrapper) 7421 { 7422 wrapper.dlg(ObjectG.getDObject!(DragContext)(context), wrapper.outer); 7423 } 7424 7425 extern(C) static void callBackDragEndDestroy(OnDragEndDelegateWrapper wrapper, GClosure* closure) 7426 { 7427 wrapper.remove(wrapper); 7428 } 7429 7430 protected class OnDragFailedDelegateWrapper 7431 { 7432 bool delegate(DragContext, GtkDragResult, Widget) dlg; 7433 gulong handlerId; 7434 7435 this(bool delegate(DragContext, GtkDragResult, Widget) dlg) 7436 { 7437 this.dlg = dlg; 7438 onDragFailedListeners ~= this; 7439 } 7440 7441 void remove(OnDragFailedDelegateWrapper source) 7442 { 7443 foreach(index, wrapper; onDragFailedListeners) 7444 { 7445 if (wrapper.handlerId == source.handlerId) 7446 { 7447 onDragFailedListeners[index] = null; 7448 onDragFailedListeners = std.algorithm.remove(onDragFailedListeners, index); 7449 break; 7450 } 7451 } 7452 } 7453 } 7454 OnDragFailedDelegateWrapper[] onDragFailedListeners; 7455 7456 /** 7457 * The ::drag-failed signal is emitted on the drag source when a drag has 7458 * failed. The signal handler may hook custom code to handle a failed DnD 7459 * operation based on the type of error, it returns %TRUE is the failure has 7460 * been already handled (not showing the default "drag operation failed" 7461 * animation), otherwise it returns %FALSE. 7462 * 7463 * Params: 7464 * context = the drag context 7465 * result = the result of the drag operation 7466 * 7467 * Returns: %TRUE if the failed drag operation has been already handled. 7468 * 7469 * Since: 2.12 7470 */ 7471 gulong addOnDragFailed(bool delegate(DragContext, GtkDragResult, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 7472 { 7473 auto wrapper = new OnDragFailedDelegateWrapper(dlg); 7474 wrapper.handlerId = Signals.connectData( 7475 this, 7476 "drag-failed", 7477 cast(GCallback)&callBackDragFailed, 7478 cast(void*)wrapper, 7479 cast(GClosureNotify)&callBackDragFailedDestroy, 7480 connectFlags); 7481 return wrapper.handlerId; 7482 } 7483 7484 extern(C) static int callBackDragFailed(GtkWidget* widgetStruct, GdkDragContext* context, GtkDragResult result, OnDragFailedDelegateWrapper wrapper) 7485 { 7486 return wrapper.dlg(ObjectG.getDObject!(DragContext)(context), result, wrapper.outer); 7487 } 7488 7489 extern(C) static void callBackDragFailedDestroy(OnDragFailedDelegateWrapper wrapper, GClosure* closure) 7490 { 7491 wrapper.remove(wrapper); 7492 } 7493 7494 protected class OnDragLeaveDelegateWrapper 7495 { 7496 void delegate(DragContext, uint, Widget) dlg; 7497 gulong handlerId; 7498 7499 this(void delegate(DragContext, uint, Widget) dlg) 7500 { 7501 this.dlg = dlg; 7502 onDragLeaveListeners ~= this; 7503 } 7504 7505 void remove(OnDragLeaveDelegateWrapper source) 7506 { 7507 foreach(index, wrapper; onDragLeaveListeners) 7508 { 7509 if (wrapper.handlerId == source.handlerId) 7510 { 7511 onDragLeaveListeners[index] = null; 7512 onDragLeaveListeners = std.algorithm.remove(onDragLeaveListeners, index); 7513 break; 7514 } 7515 } 7516 } 7517 } 7518 OnDragLeaveDelegateWrapper[] onDragLeaveListeners; 7519 7520 /** 7521 * The ::drag-leave signal is emitted on the drop site when the cursor 7522 * leaves the widget. A typical reason to connect to this signal is to 7523 * undo things done in #GtkWidget::drag-motion, e.g. undo highlighting 7524 * with gtk_drag_unhighlight(). 7525 * 7526 * 7527 * Likewise, the #GtkWidget::drag-leave signal is also emitted before the 7528 * ::drag-drop signal, for instance to allow cleaning up of a preview item 7529 * created in the #GtkWidget::drag-motion signal handler. 7530 * 7531 * Params: 7532 * context = the drag context 7533 * time = the timestamp of the motion event 7534 */ 7535 gulong addOnDragLeave(void delegate(DragContext, uint, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 7536 { 7537 auto wrapper = new OnDragLeaveDelegateWrapper(dlg); 7538 wrapper.handlerId = Signals.connectData( 7539 this, 7540 "drag-leave", 7541 cast(GCallback)&callBackDragLeave, 7542 cast(void*)wrapper, 7543 cast(GClosureNotify)&callBackDragLeaveDestroy, 7544 connectFlags); 7545 return wrapper.handlerId; 7546 } 7547 7548 extern(C) static void callBackDragLeave(GtkWidget* widgetStruct, GdkDragContext* context, uint time, OnDragLeaveDelegateWrapper wrapper) 7549 { 7550 wrapper.dlg(ObjectG.getDObject!(DragContext)(context), time, wrapper.outer); 7551 } 7552 7553 extern(C) static void callBackDragLeaveDestroy(OnDragLeaveDelegateWrapper wrapper, GClosure* closure) 7554 { 7555 wrapper.remove(wrapper); 7556 } 7557 7558 protected class OnDragMotionDelegateWrapper 7559 { 7560 bool delegate(DragContext, int, int, uint, Widget) dlg; 7561 gulong handlerId; 7562 7563 this(bool delegate(DragContext, int, int, uint, Widget) dlg) 7564 { 7565 this.dlg = dlg; 7566 onDragMotionListeners ~= this; 7567 } 7568 7569 void remove(OnDragMotionDelegateWrapper source) 7570 { 7571 foreach(index, wrapper; onDragMotionListeners) 7572 { 7573 if (wrapper.handlerId == source.handlerId) 7574 { 7575 onDragMotionListeners[index] = null; 7576 onDragMotionListeners = std.algorithm.remove(onDragMotionListeners, index); 7577 break; 7578 } 7579 } 7580 } 7581 } 7582 OnDragMotionDelegateWrapper[] onDragMotionListeners; 7583 7584 /** 7585 * The ::drag-motion signal is emitted on the drop site when the user 7586 * moves the cursor over the widget during a drag. The signal handler 7587 * must determine whether the cursor position is in a drop zone or not. 7588 * If it is not in a drop zone, it returns %FALSE and no further processing 7589 * is necessary. Otherwise, the handler returns %TRUE. In this case, the 7590 * handler is responsible for providing the necessary information for 7591 * displaying feedback to the user, by calling gdk_drag_status(). 7592 * 7593 * If the decision whether the drop will be accepted or rejected can't be 7594 * made based solely on the cursor position and the type of the data, the 7595 * handler may inspect the dragged data by calling gtk_drag_get_data() and 7596 * defer the gdk_drag_status() call to the #GtkWidget::drag-data-received 7597 * handler. Note that you must pass #GTK_DEST_DEFAULT_DROP, 7598 * #GTK_DEST_DEFAULT_MOTION or #GTK_DEST_DEFAULT_ALL to gtk_drag_dest_set() 7599 * when using the drag-motion signal that way. 7600 * 7601 * Also note that there is no drag-enter signal. The drag receiver has to 7602 * keep track of whether he has received any drag-motion signals since the 7603 * last #GtkWidget::drag-leave and if not, treat the drag-motion signal as 7604 * an "enter" signal. Upon an "enter", the handler will typically highlight 7605 * the drop site with gtk_drag_highlight(). 7606 * |[<!-- language="C" --> 7607 * static void 7608 * drag_motion (GtkWidget *widget, 7609 * GdkDragContext *context, 7610 * gint x, 7611 * gint y, 7612 * guint time) 7613 * { 7614 * GdkAtom target; 7615 * 7616 * PrivateData *private_data = GET_PRIVATE_DATA (widget); 7617 * 7618 * if (!private_data->drag_highlight) 7619 * { 7620 * private_data->drag_highlight = 1; 7621 * gtk_drag_highlight (widget); 7622 * } 7623 * 7624 * target = gtk_drag_dest_find_target (widget, context, NULL); 7625 * if (target == GDK_NONE) 7626 * gdk_drag_status (context, 0, time); 7627 * else 7628 * { 7629 * private_data->pending_status 7630 * = gdk_drag_context_get_suggested_action (context); 7631 * gtk_drag_get_data (widget, context, target, time); 7632 * } 7633 * 7634 * return TRUE; 7635 * } 7636 * 7637 * static void 7638 * drag_data_received (GtkWidget *widget, 7639 * GdkDragContext *context, 7640 * gint x, 7641 * gint y, 7642 * GtkSelectionData *selection_data, 7643 * guint info, 7644 * guint time) 7645 * { 7646 * PrivateData *private_data = GET_PRIVATE_DATA (widget); 7647 * 7648 * if (private_data->suggested_action) 7649 * { 7650 * private_data->suggested_action = 0; 7651 * 7652 * // We are getting this data due to a request in drag_motion, 7653 * // rather than due to a request in drag_drop, so we are just 7654 * // supposed to call gdk_drag_status(), not actually paste in 7655 * // the data. 7656 * 7657 * str = gtk_selection_data_get_text (selection_data); 7658 * if (!data_is_acceptable (str)) 7659 * gdk_drag_status (context, 0, time); 7660 * else 7661 * gdk_drag_status (context, 7662 * private_data->suggested_action, 7663 * time); 7664 * } 7665 * else 7666 * { 7667 * // accept the drop 7668 * } 7669 * } 7670 * ]| 7671 * 7672 * Params: 7673 * context = the drag context 7674 * x = the x coordinate of the current cursor position 7675 * y = the y coordinate of the current cursor position 7676 * time = the timestamp of the motion event 7677 * 7678 * Returns: whether the cursor position is in a drop zone 7679 */ 7680 gulong addOnDragMotion(bool delegate(DragContext, int, int, uint, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 7681 { 7682 auto wrapper = new OnDragMotionDelegateWrapper(dlg); 7683 wrapper.handlerId = Signals.connectData( 7684 this, 7685 "drag-motion", 7686 cast(GCallback)&callBackDragMotion, 7687 cast(void*)wrapper, 7688 cast(GClosureNotify)&callBackDragMotionDestroy, 7689 connectFlags); 7690 return wrapper.handlerId; 7691 } 7692 7693 extern(C) static int callBackDragMotion(GtkWidget* widgetStruct, GdkDragContext* context, int x, int y, uint time, OnDragMotionDelegateWrapper wrapper) 7694 { 7695 return wrapper.dlg(ObjectG.getDObject!(DragContext)(context), x, y, time, wrapper.outer); 7696 } 7697 7698 extern(C) static void callBackDragMotionDestroy(OnDragMotionDelegateWrapper wrapper, GClosure* closure) 7699 { 7700 wrapper.remove(wrapper); 7701 } 7702 7703 protected class OnEnterNotifyDelegateWrapper 7704 { 7705 bool delegate(GdkEventCrossing*, Widget) dlg; 7706 gulong handlerId; 7707 7708 this(bool delegate(GdkEventCrossing*, Widget) dlg) 7709 { 7710 this.dlg = dlg; 7711 onEnterNotifyListeners ~= this; 7712 } 7713 7714 void remove(OnEnterNotifyDelegateWrapper source) 7715 { 7716 foreach(index, wrapper; onEnterNotifyListeners) 7717 { 7718 if (wrapper.handlerId == source.handlerId) 7719 { 7720 onEnterNotifyListeners[index] = null; 7721 onEnterNotifyListeners = std.algorithm.remove(onEnterNotifyListeners, index); 7722 break; 7723 } 7724 } 7725 } 7726 } 7727 OnEnterNotifyDelegateWrapper[] onEnterNotifyListeners; 7728 7729 /** 7730 * The ::enter-notify-event will be emitted when the pointer enters 7731 * the @widget's window. 7732 * 7733 * To receive this signal, the #GdkWindow associated to the widget needs 7734 * to enable the #GDK_ENTER_NOTIFY_MASK mask. 7735 * 7736 * This signal will be sent to the grab widget if there is one. 7737 * 7738 * Params: 7739 * event = the #GdkEventCrossing which triggered 7740 * this signal. 7741 * 7742 * Returns: %TRUE to stop other handlers from being invoked for the event. 7743 * %FALSE to propagate the event further. 7744 */ 7745 gulong addOnEnterNotify(bool delegate(GdkEventCrossing*, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 7746 { 7747 addEvents(EventMask.ENTER_NOTIFY_MASK); 7748 auto wrapper = new OnEnterNotifyDelegateWrapper(dlg); 7749 wrapper.handlerId = Signals.connectData( 7750 this, 7751 "enter-notify-event", 7752 cast(GCallback)&callBackEnterNotify, 7753 cast(void*)wrapper, 7754 cast(GClosureNotify)&callBackEnterNotifyDestroy, 7755 connectFlags); 7756 return wrapper.handlerId; 7757 } 7758 7759 extern(C) static int callBackEnterNotify(GtkWidget* widgetStruct, GdkEventCrossing* event, OnEnterNotifyDelegateWrapper wrapper) 7760 { 7761 return wrapper.dlg(event, wrapper.outer); 7762 } 7763 7764 extern(C) static void callBackEnterNotifyDestroy(OnEnterNotifyDelegateWrapper wrapper, GClosure* closure) 7765 { 7766 wrapper.remove(wrapper); 7767 } 7768 7769 protected class OnEnterNotifyEventGenericDelegateWrapper 7770 { 7771 bool delegate(Event, Widget) dlg; 7772 gulong handlerId; 7773 7774 this(bool delegate(Event, Widget) dlg) 7775 { 7776 this.dlg = dlg; 7777 onEnterNotifyEventGenericListeners ~= this; 7778 } 7779 7780 void remove(OnEnterNotifyEventGenericDelegateWrapper source) 7781 { 7782 foreach(index, wrapper; onEnterNotifyEventGenericListeners) 7783 { 7784 if (wrapper.handlerId == source.handlerId) 7785 { 7786 onEnterNotifyEventGenericListeners[index] = null; 7787 onEnterNotifyEventGenericListeners = std.algorithm.remove(onEnterNotifyEventGenericListeners, index); 7788 break; 7789 } 7790 } 7791 } 7792 } 7793 OnEnterNotifyEventGenericDelegateWrapper[] onEnterNotifyEventGenericListeners; 7794 7795 /** 7796 * The ::enter-notify-event will be emitted when the pointer enters 7797 * the @widget's window. 7798 * 7799 * To receive this signal, the #GdkWindow associated to the widget needs 7800 * to enable the #GDK_ENTER_NOTIFY_MASK mask. 7801 * 7802 * This signal will be sent to the grab widget if there is one. 7803 * 7804 * Params: 7805 * event = the #GdkEventCrossing which triggered 7806 * this signal. 7807 * 7808 * Returns: %TRUE to stop other handlers from being invoked for the event. 7809 * %FALSE to propagate the event further. 7810 */ 7811 gulong addOnEnterNotify(bool delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 7812 { 7813 addEvents(EventMask.ENTER_NOTIFY_MASK); 7814 auto wrapper = new OnEnterNotifyEventGenericDelegateWrapper(dlg); 7815 wrapper.handlerId = Signals.connectData( 7816 this, 7817 "enter-notify-event", 7818 cast(GCallback)&callBackEnterNotifyEventGeneric, 7819 cast(void*)wrapper, 7820 cast(GClosureNotify)&callBackEnterNotifyEventGenericDestroy, 7821 connectFlags); 7822 return wrapper.handlerId; 7823 } 7824 7825 extern(C) static int callBackEnterNotifyEventGeneric(GtkWidget* widgetStruct, GdkEvent* event, OnEnterNotifyEventGenericDelegateWrapper wrapper) 7826 { 7827 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 7828 } 7829 7830 extern(C) static void callBackEnterNotifyEventGenericDestroy(OnEnterNotifyEventGenericDelegateWrapper wrapper, GClosure* closure) 7831 { 7832 wrapper.remove(wrapper); 7833 } 7834 7835 protected class OnEventDelegateWrapper 7836 { 7837 bool delegate(Event, Widget) dlg; 7838 gulong handlerId; 7839 7840 this(bool delegate(Event, Widget) dlg) 7841 { 7842 this.dlg = dlg; 7843 onEventListeners ~= this; 7844 } 7845 7846 void remove(OnEventDelegateWrapper source) 7847 { 7848 foreach(index, wrapper; onEventListeners) 7849 { 7850 if (wrapper.handlerId == source.handlerId) 7851 { 7852 onEventListeners[index] = null; 7853 onEventListeners = std.algorithm.remove(onEventListeners, index); 7854 break; 7855 } 7856 } 7857 } 7858 } 7859 OnEventDelegateWrapper[] onEventListeners; 7860 7861 /** 7862 * The GTK+ main loop will emit three signals for each GDK event delivered 7863 * to a widget: one generic ::event signal, another, more specific, 7864 * signal that matches the type of event delivered (e.g. 7865 * #GtkWidget::key-press-event) and finally a generic 7866 * #GtkWidget::event-after signal. 7867 * 7868 * Params: 7869 * event = the #GdkEvent which triggered this signal 7870 * 7871 * Returns: %TRUE to stop other handlers from being invoked for the event 7872 * and to cancel the emission of the second specific ::event signal. 7873 * %FALSE to propagate the event further and to allow the emission of 7874 * the second signal. The ::event-after signal is emitted regardless of 7875 * the return value. 7876 */ 7877 gulong addOnEvent(bool delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 7878 { 7879 auto wrapper = new OnEventDelegateWrapper(dlg); 7880 wrapper.handlerId = Signals.connectData( 7881 this, 7882 "event", 7883 cast(GCallback)&callBackEvent, 7884 cast(void*)wrapper, 7885 cast(GClosureNotify)&callBackEventDestroy, 7886 connectFlags); 7887 return wrapper.handlerId; 7888 } 7889 7890 extern(C) static int callBackEvent(GtkWidget* widgetStruct, GdkEvent* event, OnEventDelegateWrapper wrapper) 7891 { 7892 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 7893 } 7894 7895 extern(C) static void callBackEventDestroy(OnEventDelegateWrapper wrapper, GClosure* closure) 7896 { 7897 wrapper.remove(wrapper); 7898 } 7899 7900 protected class OnEventAfterDelegateWrapper 7901 { 7902 void delegate(Event, Widget) dlg; 7903 gulong handlerId; 7904 7905 this(void delegate(Event, Widget) dlg) 7906 { 7907 this.dlg = dlg; 7908 onEventAfterListeners ~= this; 7909 } 7910 7911 void remove(OnEventAfterDelegateWrapper source) 7912 { 7913 foreach(index, wrapper; onEventAfterListeners) 7914 { 7915 if (wrapper.handlerId == source.handlerId) 7916 { 7917 onEventAfterListeners[index] = null; 7918 onEventAfterListeners = std.algorithm.remove(onEventAfterListeners, index); 7919 break; 7920 } 7921 } 7922 } 7923 } 7924 OnEventAfterDelegateWrapper[] onEventAfterListeners; 7925 7926 /** 7927 * After the emission of the #GtkWidget::event signal and (optionally) 7928 * the second more specific signal, ::event-after will be emitted 7929 * regardless of the previous two signals handlers return values. 7930 * 7931 * Params: 7932 * event = the #GdkEvent which triggered this signal 7933 */ 7934 gulong addOnEventAfter(void delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 7935 { 7936 auto wrapper = new OnEventAfterDelegateWrapper(dlg); 7937 wrapper.handlerId = Signals.connectData( 7938 this, 7939 "event-after", 7940 cast(GCallback)&callBackEventAfter, 7941 cast(void*)wrapper, 7942 cast(GClosureNotify)&callBackEventAfterDestroy, 7943 connectFlags); 7944 return wrapper.handlerId; 7945 } 7946 7947 extern(C) static void callBackEventAfter(GtkWidget* widgetStruct, GdkEvent* event, OnEventAfterDelegateWrapper wrapper) 7948 { 7949 wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 7950 } 7951 7952 extern(C) static void callBackEventAfterDestroy(OnEventAfterDelegateWrapper wrapper, GClosure* closure) 7953 { 7954 wrapper.remove(wrapper); 7955 } 7956 7957 protected class OnFocusDelegateWrapper 7958 { 7959 bool delegate(GtkDirectionType, Widget) dlg; 7960 gulong handlerId; 7961 7962 this(bool delegate(GtkDirectionType, Widget) dlg) 7963 { 7964 this.dlg = dlg; 7965 onFocusListeners ~= this; 7966 } 7967 7968 void remove(OnFocusDelegateWrapper source) 7969 { 7970 foreach(index, wrapper; onFocusListeners) 7971 { 7972 if (wrapper.handlerId == source.handlerId) 7973 { 7974 onFocusListeners[index] = null; 7975 onFocusListeners = std.algorithm.remove(onFocusListeners, index); 7976 break; 7977 } 7978 } 7979 } 7980 } 7981 OnFocusDelegateWrapper[] onFocusListeners; 7982 7983 /** 7984 * Returns: %TRUE to stop other handlers from being invoked for the event. %FALSE to propagate the event further. 7985 */ 7986 gulong addOnFocus(bool delegate(GtkDirectionType, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 7987 { 7988 auto wrapper = new OnFocusDelegateWrapper(dlg); 7989 wrapper.handlerId = Signals.connectData( 7990 this, 7991 "focus", 7992 cast(GCallback)&callBackFocus, 7993 cast(void*)wrapper, 7994 cast(GClosureNotify)&callBackFocusDestroy, 7995 connectFlags); 7996 return wrapper.handlerId; 7997 } 7998 7999 extern(C) static int callBackFocus(GtkWidget* widgetStruct, GtkDirectionType direction, OnFocusDelegateWrapper wrapper) 8000 { 8001 return wrapper.dlg(direction, wrapper.outer); 8002 } 8003 8004 extern(C) static void callBackFocusDestroy(OnFocusDelegateWrapper wrapper, GClosure* closure) 8005 { 8006 wrapper.remove(wrapper); 8007 } 8008 8009 protected class OnFocusInDelegateWrapper 8010 { 8011 bool delegate(GdkEventFocus*, Widget) dlg; 8012 gulong handlerId; 8013 8014 this(bool delegate(GdkEventFocus*, Widget) dlg) 8015 { 8016 this.dlg = dlg; 8017 onFocusInListeners ~= this; 8018 } 8019 8020 void remove(OnFocusInDelegateWrapper source) 8021 { 8022 foreach(index, wrapper; onFocusInListeners) 8023 { 8024 if (wrapper.handlerId == source.handlerId) 8025 { 8026 onFocusInListeners[index] = null; 8027 onFocusInListeners = std.algorithm.remove(onFocusInListeners, index); 8028 break; 8029 } 8030 } 8031 } 8032 } 8033 OnFocusInDelegateWrapper[] onFocusInListeners; 8034 8035 /** 8036 * The ::focus-in-event signal will be emitted when the keyboard focus 8037 * enters the @widget's window. 8038 * 8039 * To receive this signal, the #GdkWindow associated to the widget needs 8040 * to enable the #GDK_FOCUS_CHANGE_MASK mask. 8041 * 8042 * Params: 8043 * event = the #GdkEventFocus which triggered 8044 * this signal. 8045 * 8046 * Returns: %TRUE to stop other handlers from being invoked for the event. 8047 * %FALSE to propagate the event further. 8048 */ 8049 gulong addOnFocusIn(bool delegate(GdkEventFocus*, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 8050 { 8051 addEvents(EventMask.FOCUS_CHANGE_MASK); 8052 auto wrapper = new OnFocusInDelegateWrapper(dlg); 8053 wrapper.handlerId = Signals.connectData( 8054 this, 8055 "focus-in-event", 8056 cast(GCallback)&callBackFocusIn, 8057 cast(void*)wrapper, 8058 cast(GClosureNotify)&callBackFocusInDestroy, 8059 connectFlags); 8060 return wrapper.handlerId; 8061 } 8062 8063 extern(C) static int callBackFocusIn(GtkWidget* widgetStruct, GdkEventFocus* event, OnFocusInDelegateWrapper wrapper) 8064 { 8065 return wrapper.dlg(event, wrapper.outer); 8066 } 8067 8068 extern(C) static void callBackFocusInDestroy(OnFocusInDelegateWrapper wrapper, GClosure* closure) 8069 { 8070 wrapper.remove(wrapper); 8071 } 8072 8073 protected class OnFocusInEventGenericDelegateWrapper 8074 { 8075 bool delegate(Event, Widget) dlg; 8076 gulong handlerId; 8077 8078 this(bool delegate(Event, Widget) dlg) 8079 { 8080 this.dlg = dlg; 8081 onFocusInEventGenericListeners ~= this; 8082 } 8083 8084 void remove(OnFocusInEventGenericDelegateWrapper source) 8085 { 8086 foreach(index, wrapper; onFocusInEventGenericListeners) 8087 { 8088 if (wrapper.handlerId == source.handlerId) 8089 { 8090 onFocusInEventGenericListeners[index] = null; 8091 onFocusInEventGenericListeners = std.algorithm.remove(onFocusInEventGenericListeners, index); 8092 break; 8093 } 8094 } 8095 } 8096 } 8097 OnFocusInEventGenericDelegateWrapper[] onFocusInEventGenericListeners; 8098 8099 /** 8100 * The ::focus-in-event signal will be emitted when the keyboard focus 8101 * enters the @widget's window. 8102 * 8103 * To receive this signal, the #GdkWindow associated to the widget needs 8104 * to enable the #GDK_FOCUS_CHANGE_MASK mask. 8105 * 8106 * Params: 8107 * event = the #GdkEventFocus which triggered 8108 * this signal. 8109 * 8110 * Returns: %TRUE to stop other handlers from being invoked for the event. 8111 * %FALSE to propagate the event further. 8112 */ 8113 gulong addOnFocusIn(bool delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 8114 { 8115 addEvents(EventMask.FOCUS_CHANGE_MASK); 8116 auto wrapper = new OnFocusInEventGenericDelegateWrapper(dlg); 8117 wrapper.handlerId = Signals.connectData( 8118 this, 8119 "focus-in-event", 8120 cast(GCallback)&callBackFocusInEventGeneric, 8121 cast(void*)wrapper, 8122 cast(GClosureNotify)&callBackFocusInEventGenericDestroy, 8123 connectFlags); 8124 return wrapper.handlerId; 8125 } 8126 8127 extern(C) static int callBackFocusInEventGeneric(GtkWidget* widgetStruct, GdkEvent* event, OnFocusInEventGenericDelegateWrapper wrapper) 8128 { 8129 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 8130 } 8131 8132 extern(C) static void callBackFocusInEventGenericDestroy(OnFocusInEventGenericDelegateWrapper wrapper, GClosure* closure) 8133 { 8134 wrapper.remove(wrapper); 8135 } 8136 8137 protected class OnFocusOutDelegateWrapper 8138 { 8139 bool delegate(GdkEventFocus*, Widget) dlg; 8140 gulong handlerId; 8141 8142 this(bool delegate(GdkEventFocus*, Widget) dlg) 8143 { 8144 this.dlg = dlg; 8145 onFocusOutListeners ~= this; 8146 } 8147 8148 void remove(OnFocusOutDelegateWrapper source) 8149 { 8150 foreach(index, wrapper; onFocusOutListeners) 8151 { 8152 if (wrapper.handlerId == source.handlerId) 8153 { 8154 onFocusOutListeners[index] = null; 8155 onFocusOutListeners = std.algorithm.remove(onFocusOutListeners, index); 8156 break; 8157 } 8158 } 8159 } 8160 } 8161 OnFocusOutDelegateWrapper[] onFocusOutListeners; 8162 8163 /** 8164 * The ::focus-out-event signal will be emitted when the keyboard focus 8165 * leaves the @widget's window. 8166 * 8167 * To receive this signal, the #GdkWindow associated to the widget needs 8168 * to enable the #GDK_FOCUS_CHANGE_MASK mask. 8169 * 8170 * Params: 8171 * event = the #GdkEventFocus which triggered this 8172 * signal. 8173 * 8174 * Returns: %TRUE to stop other handlers from being invoked for the event. 8175 * %FALSE to propagate the event further. 8176 */ 8177 gulong addOnFocusOut(bool delegate(GdkEventFocus*, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 8178 { 8179 addEvents(EventMask.FOCUS_CHANGE_MASK); 8180 auto wrapper = new OnFocusOutDelegateWrapper(dlg); 8181 wrapper.handlerId = Signals.connectData( 8182 this, 8183 "focus-out-event", 8184 cast(GCallback)&callBackFocusOut, 8185 cast(void*)wrapper, 8186 cast(GClosureNotify)&callBackFocusOutDestroy, 8187 connectFlags); 8188 return wrapper.handlerId; 8189 } 8190 8191 extern(C) static int callBackFocusOut(GtkWidget* widgetStruct, GdkEventFocus* event, OnFocusOutDelegateWrapper wrapper) 8192 { 8193 return wrapper.dlg(event, wrapper.outer); 8194 } 8195 8196 extern(C) static void callBackFocusOutDestroy(OnFocusOutDelegateWrapper wrapper, GClosure* closure) 8197 { 8198 wrapper.remove(wrapper); 8199 } 8200 8201 protected class OnFocusOutEventGenericDelegateWrapper 8202 { 8203 bool delegate(Event, Widget) dlg; 8204 gulong handlerId; 8205 8206 this(bool delegate(Event, Widget) dlg) 8207 { 8208 this.dlg = dlg; 8209 onFocusOutEventGenericListeners ~= this; 8210 } 8211 8212 void remove(OnFocusOutEventGenericDelegateWrapper source) 8213 { 8214 foreach(index, wrapper; onFocusOutEventGenericListeners) 8215 { 8216 if (wrapper.handlerId == source.handlerId) 8217 { 8218 onFocusOutEventGenericListeners[index] = null; 8219 onFocusOutEventGenericListeners = std.algorithm.remove(onFocusOutEventGenericListeners, index); 8220 break; 8221 } 8222 } 8223 } 8224 } 8225 OnFocusOutEventGenericDelegateWrapper[] onFocusOutEventGenericListeners; 8226 8227 /** 8228 * The ::focus-out-event signal will be emitted when the keyboard focus 8229 * leaves the @widget's window. 8230 * 8231 * To receive this signal, the #GdkWindow associated to the widget needs 8232 * to enable the #GDK_FOCUS_CHANGE_MASK mask. 8233 * 8234 * Params: 8235 * event = the #GdkEventFocus which triggered this 8236 * signal. 8237 * 8238 * Returns: %TRUE to stop other handlers from being invoked for the event. 8239 * %FALSE to propagate the event further. 8240 */ 8241 gulong addOnFocusOut(bool delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 8242 { 8243 addEvents(EventMask.FOCUS_CHANGE_MASK); 8244 auto wrapper = new OnFocusOutEventGenericDelegateWrapper(dlg); 8245 wrapper.handlerId = Signals.connectData( 8246 this, 8247 "focus-out-event", 8248 cast(GCallback)&callBackFocusOutEventGeneric, 8249 cast(void*)wrapper, 8250 cast(GClosureNotify)&callBackFocusOutEventGenericDestroy, 8251 connectFlags); 8252 return wrapper.handlerId; 8253 } 8254 8255 extern(C) static int callBackFocusOutEventGeneric(GtkWidget* widgetStruct, GdkEvent* event, OnFocusOutEventGenericDelegateWrapper wrapper) 8256 { 8257 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 8258 } 8259 8260 extern(C) static void callBackFocusOutEventGenericDestroy(OnFocusOutEventGenericDelegateWrapper wrapper, GClosure* closure) 8261 { 8262 wrapper.remove(wrapper); 8263 } 8264 8265 protected class OnGrabBrokenDelegateWrapper 8266 { 8267 bool delegate(GdkEventGrabBroken*, Widget) dlg; 8268 gulong handlerId; 8269 8270 this(bool delegate(GdkEventGrabBroken*, Widget) dlg) 8271 { 8272 this.dlg = dlg; 8273 onGrabBrokenListeners ~= this; 8274 } 8275 8276 void remove(OnGrabBrokenDelegateWrapper source) 8277 { 8278 foreach(index, wrapper; onGrabBrokenListeners) 8279 { 8280 if (wrapper.handlerId == source.handlerId) 8281 { 8282 onGrabBrokenListeners[index] = null; 8283 onGrabBrokenListeners = std.algorithm.remove(onGrabBrokenListeners, index); 8284 break; 8285 } 8286 } 8287 } 8288 } 8289 OnGrabBrokenDelegateWrapper[] onGrabBrokenListeners; 8290 8291 /** 8292 * Emitted when a pointer or keyboard grab on a window belonging 8293 * to @widget gets broken. 8294 * 8295 * On X11, this happens when the grab window becomes unviewable 8296 * (i.e. it or one of its ancestors is unmapped), or if the same 8297 * application grabs the pointer or keyboard again. 8298 * 8299 * Params: 8300 * event = the #GdkEventGrabBroken event 8301 * 8302 * Returns: %TRUE to stop other handlers from being invoked for 8303 * the event. %FALSE to propagate the event further. 8304 * 8305 * Since: 2.8 8306 */ 8307 gulong addOnGrabBroken(bool delegate(GdkEventGrabBroken*, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 8308 { 8309 auto wrapper = new OnGrabBrokenDelegateWrapper(dlg); 8310 wrapper.handlerId = Signals.connectData( 8311 this, 8312 "grab-broken-event", 8313 cast(GCallback)&callBackGrabBroken, 8314 cast(void*)wrapper, 8315 cast(GClosureNotify)&callBackGrabBrokenDestroy, 8316 connectFlags); 8317 return wrapper.handlerId; 8318 } 8319 8320 extern(C) static int callBackGrabBroken(GtkWidget* widgetStruct, GdkEventGrabBroken* event, OnGrabBrokenDelegateWrapper wrapper) 8321 { 8322 return wrapper.dlg(event, wrapper.outer); 8323 } 8324 8325 extern(C) static void callBackGrabBrokenDestroy(OnGrabBrokenDelegateWrapper wrapper, GClosure* closure) 8326 { 8327 wrapper.remove(wrapper); 8328 } 8329 8330 protected class OnGrabBrokenEventGenericDelegateWrapper 8331 { 8332 bool delegate(Event, Widget) dlg; 8333 gulong handlerId; 8334 8335 this(bool delegate(Event, Widget) dlg) 8336 { 8337 this.dlg = dlg; 8338 onGrabBrokenEventGenericListeners ~= this; 8339 } 8340 8341 void remove(OnGrabBrokenEventGenericDelegateWrapper source) 8342 { 8343 foreach(index, wrapper; onGrabBrokenEventGenericListeners) 8344 { 8345 if (wrapper.handlerId == source.handlerId) 8346 { 8347 onGrabBrokenEventGenericListeners[index] = null; 8348 onGrabBrokenEventGenericListeners = std.algorithm.remove(onGrabBrokenEventGenericListeners, index); 8349 break; 8350 } 8351 } 8352 } 8353 } 8354 OnGrabBrokenEventGenericDelegateWrapper[] onGrabBrokenEventGenericListeners; 8355 8356 /** 8357 * Emitted when a pointer or keyboard grab on a window belonging 8358 * to @widget gets broken. 8359 * 8360 * On X11, this happens when the grab window becomes unviewable 8361 * (i.e. it or one of its ancestors is unmapped), or if the same 8362 * application grabs the pointer or keyboard again. 8363 * 8364 * Params: 8365 * event = the #GdkEventGrabBroken event 8366 * 8367 * Returns: %TRUE to stop other handlers from being invoked for 8368 * the event. %FALSE to propagate the event further. 8369 * 8370 * Since: 2.8 8371 */ 8372 gulong addOnGrabBroken(bool delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 8373 { 8374 auto wrapper = new OnGrabBrokenEventGenericDelegateWrapper(dlg); 8375 wrapper.handlerId = Signals.connectData( 8376 this, 8377 "grab-broken-event", 8378 cast(GCallback)&callBackGrabBrokenEventGeneric, 8379 cast(void*)wrapper, 8380 cast(GClosureNotify)&callBackGrabBrokenEventGenericDestroy, 8381 connectFlags); 8382 return wrapper.handlerId; 8383 } 8384 8385 extern(C) static int callBackGrabBrokenEventGeneric(GtkWidget* widgetStruct, GdkEvent* event, OnGrabBrokenEventGenericDelegateWrapper wrapper) 8386 { 8387 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 8388 } 8389 8390 extern(C) static void callBackGrabBrokenEventGenericDestroy(OnGrabBrokenEventGenericDelegateWrapper wrapper, GClosure* closure) 8391 { 8392 wrapper.remove(wrapper); 8393 } 8394 8395 protected class OnGrabFocusDelegateWrapper 8396 { 8397 void delegate(Widget) dlg; 8398 gulong handlerId; 8399 8400 this(void delegate(Widget) dlg) 8401 { 8402 this.dlg = dlg; 8403 onGrabFocusListeners ~= this; 8404 } 8405 8406 void remove(OnGrabFocusDelegateWrapper source) 8407 { 8408 foreach(index, wrapper; onGrabFocusListeners) 8409 { 8410 if (wrapper.handlerId == source.handlerId) 8411 { 8412 onGrabFocusListeners[index] = null; 8413 onGrabFocusListeners = std.algorithm.remove(onGrabFocusListeners, index); 8414 break; 8415 } 8416 } 8417 } 8418 } 8419 OnGrabFocusDelegateWrapper[] onGrabFocusListeners; 8420 8421 /** */ 8422 gulong addOnGrabFocus(void delegate(Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 8423 { 8424 auto wrapper = new OnGrabFocusDelegateWrapper(dlg); 8425 wrapper.handlerId = Signals.connectData( 8426 this, 8427 "grab-focus", 8428 cast(GCallback)&callBackGrabFocus, 8429 cast(void*)wrapper, 8430 cast(GClosureNotify)&callBackGrabFocusDestroy, 8431 connectFlags); 8432 return wrapper.handlerId; 8433 } 8434 8435 extern(C) static void callBackGrabFocus(GtkWidget* widgetStruct, OnGrabFocusDelegateWrapper wrapper) 8436 { 8437 wrapper.dlg(wrapper.outer); 8438 } 8439 8440 extern(C) static void callBackGrabFocusDestroy(OnGrabFocusDelegateWrapper wrapper, GClosure* closure) 8441 { 8442 wrapper.remove(wrapper); 8443 } 8444 8445 protected class OnGrabNotifyDelegateWrapper 8446 { 8447 void delegate(bool, Widget) dlg; 8448 gulong handlerId; 8449 8450 this(void delegate(bool, Widget) dlg) 8451 { 8452 this.dlg = dlg; 8453 onGrabNotifyListeners ~= this; 8454 } 8455 8456 void remove(OnGrabNotifyDelegateWrapper source) 8457 { 8458 foreach(index, wrapper; onGrabNotifyListeners) 8459 { 8460 if (wrapper.handlerId == source.handlerId) 8461 { 8462 onGrabNotifyListeners[index] = null; 8463 onGrabNotifyListeners = std.algorithm.remove(onGrabNotifyListeners, index); 8464 break; 8465 } 8466 } 8467 } 8468 } 8469 OnGrabNotifyDelegateWrapper[] onGrabNotifyListeners; 8470 8471 /** 8472 * The ::grab-notify signal is emitted when a widget becomes 8473 * shadowed by a GTK+ grab (not a pointer or keyboard grab) on 8474 * another widget, or when it becomes unshadowed due to a grab 8475 * being removed. 8476 * 8477 * A widget is shadowed by a gtk_grab_add() when the topmost 8478 * grab widget in the grab stack of its window group is not 8479 * its ancestor. 8480 * 8481 * Params: 8482 * wasGrabbed = %FALSE if the widget becomes shadowed, %TRUE 8483 * if it becomes unshadowed 8484 */ 8485 gulong addOnGrabNotify(void delegate(bool, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 8486 { 8487 auto wrapper = new OnGrabNotifyDelegateWrapper(dlg); 8488 wrapper.handlerId = Signals.connectData( 8489 this, 8490 "grab-notify", 8491 cast(GCallback)&callBackGrabNotify, 8492 cast(void*)wrapper, 8493 cast(GClosureNotify)&callBackGrabNotifyDestroy, 8494 connectFlags); 8495 return wrapper.handlerId; 8496 } 8497 8498 extern(C) static void callBackGrabNotify(GtkWidget* widgetStruct, bool wasGrabbed, OnGrabNotifyDelegateWrapper wrapper) 8499 { 8500 wrapper.dlg(wasGrabbed, wrapper.outer); 8501 } 8502 8503 extern(C) static void callBackGrabNotifyDestroy(OnGrabNotifyDelegateWrapper wrapper, GClosure* closure) 8504 { 8505 wrapper.remove(wrapper); 8506 } 8507 8508 protected class OnHideDelegateWrapper 8509 { 8510 void delegate(Widget) dlg; 8511 gulong handlerId; 8512 8513 this(void delegate(Widget) dlg) 8514 { 8515 this.dlg = dlg; 8516 onHideListeners ~= this; 8517 } 8518 8519 void remove(OnHideDelegateWrapper source) 8520 { 8521 foreach(index, wrapper; onHideListeners) 8522 { 8523 if (wrapper.handlerId == source.handlerId) 8524 { 8525 onHideListeners[index] = null; 8526 onHideListeners = std.algorithm.remove(onHideListeners, index); 8527 break; 8528 } 8529 } 8530 } 8531 } 8532 OnHideDelegateWrapper[] onHideListeners; 8533 8534 /** 8535 * The ::hide signal is emitted when @widget is hidden, for example with 8536 * gtk_widget_hide(). 8537 */ 8538 gulong addOnHide(void delegate(Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 8539 { 8540 auto wrapper = new OnHideDelegateWrapper(dlg); 8541 wrapper.handlerId = Signals.connectData( 8542 this, 8543 "hide", 8544 cast(GCallback)&callBackHide, 8545 cast(void*)wrapper, 8546 cast(GClosureNotify)&callBackHideDestroy, 8547 connectFlags); 8548 return wrapper.handlerId; 8549 } 8550 8551 extern(C) static void callBackHide(GtkWidget* widgetStruct, OnHideDelegateWrapper wrapper) 8552 { 8553 wrapper.dlg(wrapper.outer); 8554 } 8555 8556 extern(C) static void callBackHideDestroy(OnHideDelegateWrapper wrapper, GClosure* closure) 8557 { 8558 wrapper.remove(wrapper); 8559 } 8560 8561 protected class OnHierarchyChangedDelegateWrapper 8562 { 8563 void delegate(Widget, Widget) dlg; 8564 gulong handlerId; 8565 8566 this(void delegate(Widget, Widget) dlg) 8567 { 8568 this.dlg = dlg; 8569 onHierarchyChangedListeners ~= this; 8570 } 8571 8572 void remove(OnHierarchyChangedDelegateWrapper source) 8573 { 8574 foreach(index, wrapper; onHierarchyChangedListeners) 8575 { 8576 if (wrapper.handlerId == source.handlerId) 8577 { 8578 onHierarchyChangedListeners[index] = null; 8579 onHierarchyChangedListeners = std.algorithm.remove(onHierarchyChangedListeners, index); 8580 break; 8581 } 8582 } 8583 } 8584 } 8585 OnHierarchyChangedDelegateWrapper[] onHierarchyChangedListeners; 8586 8587 /** 8588 * The ::hierarchy-changed signal is emitted when the 8589 * anchored state of a widget changes. A widget is 8590 * “anchored” when its toplevel 8591 * ancestor is a #GtkWindow. This signal is emitted when 8592 * a widget changes from un-anchored to anchored or vice-versa. 8593 * 8594 * Params: 8595 * previousToplevel = the previous toplevel ancestor, or %NULL 8596 * if the widget was previously unanchored 8597 */ 8598 gulong addOnHierarchyChanged(void delegate(Widget, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 8599 { 8600 auto wrapper = new OnHierarchyChangedDelegateWrapper(dlg); 8601 wrapper.handlerId = Signals.connectData( 8602 this, 8603 "hierarchy-changed", 8604 cast(GCallback)&callBackHierarchyChanged, 8605 cast(void*)wrapper, 8606 cast(GClosureNotify)&callBackHierarchyChangedDestroy, 8607 connectFlags); 8608 return wrapper.handlerId; 8609 } 8610 8611 extern(C) static void callBackHierarchyChanged(GtkWidget* widgetStruct, GtkWidget* previousToplevel, OnHierarchyChangedDelegateWrapper wrapper) 8612 { 8613 wrapper.dlg(ObjectG.getDObject!(Widget)(previousToplevel), wrapper.outer); 8614 } 8615 8616 extern(C) static void callBackHierarchyChangedDestroy(OnHierarchyChangedDelegateWrapper wrapper, GClosure* closure) 8617 { 8618 wrapper.remove(wrapper); 8619 } 8620 8621 protected class OnKeyPressDelegateWrapper 8622 { 8623 bool delegate(GdkEventKey*, Widget) dlg; 8624 gulong handlerId; 8625 8626 this(bool delegate(GdkEventKey*, Widget) dlg) 8627 { 8628 this.dlg = dlg; 8629 onKeyPressListeners ~= this; 8630 } 8631 8632 void remove(OnKeyPressDelegateWrapper source) 8633 { 8634 foreach(index, wrapper; onKeyPressListeners) 8635 { 8636 if (wrapper.handlerId == source.handlerId) 8637 { 8638 onKeyPressListeners[index] = null; 8639 onKeyPressListeners = std.algorithm.remove(onKeyPressListeners, index); 8640 break; 8641 } 8642 } 8643 } 8644 } 8645 OnKeyPressDelegateWrapper[] onKeyPressListeners; 8646 8647 /** 8648 * The ::key-press-event signal is emitted when a key is pressed. The signal 8649 * emission will reoccur at the key-repeat rate when the key is kept pressed. 8650 * 8651 * To receive this signal, the #GdkWindow associated to the widget needs 8652 * to enable the #GDK_KEY_PRESS_MASK mask. 8653 * 8654 * This signal will be sent to the grab widget if there is one. 8655 * 8656 * Params: 8657 * event = the #GdkEventKey which triggered this signal. 8658 * 8659 * Returns: %TRUE to stop other handlers from being invoked for the event. 8660 * %FALSE to propagate the event further. 8661 */ 8662 gulong addOnKeyPress(bool delegate(GdkEventKey*, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 8663 { 8664 addEvents(EventMask.KEY_PRESS_MASK); 8665 auto wrapper = new OnKeyPressDelegateWrapper(dlg); 8666 wrapper.handlerId = Signals.connectData( 8667 this, 8668 "key-press-event", 8669 cast(GCallback)&callBackKeyPress, 8670 cast(void*)wrapper, 8671 cast(GClosureNotify)&callBackKeyPressDestroy, 8672 connectFlags); 8673 return wrapper.handlerId; 8674 } 8675 8676 extern(C) static int callBackKeyPress(GtkWidget* widgetStruct, GdkEventKey* event, OnKeyPressDelegateWrapper wrapper) 8677 { 8678 return wrapper.dlg(event, wrapper.outer); 8679 } 8680 8681 extern(C) static void callBackKeyPressDestroy(OnKeyPressDelegateWrapper wrapper, GClosure* closure) 8682 { 8683 wrapper.remove(wrapper); 8684 } 8685 8686 protected class OnKeyPressEventGenericDelegateWrapper 8687 { 8688 bool delegate(Event, Widget) dlg; 8689 gulong handlerId; 8690 8691 this(bool delegate(Event, Widget) dlg) 8692 { 8693 this.dlg = dlg; 8694 onKeyPressEventGenericListeners ~= this; 8695 } 8696 8697 void remove(OnKeyPressEventGenericDelegateWrapper source) 8698 { 8699 foreach(index, wrapper; onKeyPressEventGenericListeners) 8700 { 8701 if (wrapper.handlerId == source.handlerId) 8702 { 8703 onKeyPressEventGenericListeners[index] = null; 8704 onKeyPressEventGenericListeners = std.algorithm.remove(onKeyPressEventGenericListeners, index); 8705 break; 8706 } 8707 } 8708 } 8709 } 8710 OnKeyPressEventGenericDelegateWrapper[] onKeyPressEventGenericListeners; 8711 8712 /** 8713 * The ::key-press-event signal is emitted when a key is pressed. The signal 8714 * emission will reoccur at the key-repeat rate when the key is kept pressed. 8715 * 8716 * To receive this signal, the #GdkWindow associated to the widget needs 8717 * to enable the #GDK_KEY_PRESS_MASK mask. 8718 * 8719 * This signal will be sent to the grab widget if there is one. 8720 * 8721 * Params: 8722 * event = the #GdkEventKey which triggered this signal. 8723 * 8724 * Returns: %TRUE to stop other handlers from being invoked for the event. 8725 * %FALSE to propagate the event further. 8726 */ 8727 gulong addOnKeyPress(bool delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 8728 { 8729 addEvents(EventMask.KEY_PRESS_MASK); 8730 auto wrapper = new OnKeyPressEventGenericDelegateWrapper(dlg); 8731 wrapper.handlerId = Signals.connectData( 8732 this, 8733 "key-press-event", 8734 cast(GCallback)&callBackKeyPressEventGeneric, 8735 cast(void*)wrapper, 8736 cast(GClosureNotify)&callBackKeyPressEventGenericDestroy, 8737 connectFlags); 8738 return wrapper.handlerId; 8739 } 8740 8741 extern(C) static int callBackKeyPressEventGeneric(GtkWidget* widgetStruct, GdkEvent* event, OnKeyPressEventGenericDelegateWrapper wrapper) 8742 { 8743 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 8744 } 8745 8746 extern(C) static void callBackKeyPressEventGenericDestroy(OnKeyPressEventGenericDelegateWrapper wrapper, GClosure* closure) 8747 { 8748 wrapper.remove(wrapper); 8749 } 8750 8751 protected class OnKeyReleaseDelegateWrapper 8752 { 8753 bool delegate(GdkEventKey*, Widget) dlg; 8754 gulong handlerId; 8755 8756 this(bool delegate(GdkEventKey*, Widget) dlg) 8757 { 8758 this.dlg = dlg; 8759 onKeyReleaseListeners ~= this; 8760 } 8761 8762 void remove(OnKeyReleaseDelegateWrapper source) 8763 { 8764 foreach(index, wrapper; onKeyReleaseListeners) 8765 { 8766 if (wrapper.handlerId == source.handlerId) 8767 { 8768 onKeyReleaseListeners[index] = null; 8769 onKeyReleaseListeners = std.algorithm.remove(onKeyReleaseListeners, index); 8770 break; 8771 } 8772 } 8773 } 8774 } 8775 OnKeyReleaseDelegateWrapper[] onKeyReleaseListeners; 8776 8777 /** 8778 * The ::key-release-event signal is emitted when a key is released. 8779 * 8780 * To receive this signal, the #GdkWindow associated to the widget needs 8781 * to enable the #GDK_KEY_RELEASE_MASK mask. 8782 * 8783 * This signal will be sent to the grab widget if there is one. 8784 * 8785 * Params: 8786 * event = the #GdkEventKey which triggered this signal. 8787 * 8788 * Returns: %TRUE to stop other handlers from being invoked for the event. 8789 * %FALSE to propagate the event further. 8790 */ 8791 gulong addOnKeyRelease(bool delegate(GdkEventKey*, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 8792 { 8793 addEvents(EventMask.KEY_RELEASE_MASK); 8794 auto wrapper = new OnKeyReleaseDelegateWrapper(dlg); 8795 wrapper.handlerId = Signals.connectData( 8796 this, 8797 "key-release-event", 8798 cast(GCallback)&callBackKeyRelease, 8799 cast(void*)wrapper, 8800 cast(GClosureNotify)&callBackKeyReleaseDestroy, 8801 connectFlags); 8802 return wrapper.handlerId; 8803 } 8804 8805 extern(C) static int callBackKeyRelease(GtkWidget* widgetStruct, GdkEventKey* event, OnKeyReleaseDelegateWrapper wrapper) 8806 { 8807 return wrapper.dlg(event, wrapper.outer); 8808 } 8809 8810 extern(C) static void callBackKeyReleaseDestroy(OnKeyReleaseDelegateWrapper wrapper, GClosure* closure) 8811 { 8812 wrapper.remove(wrapper); 8813 } 8814 8815 protected class OnKeyReleaseEventGenericDelegateWrapper 8816 { 8817 bool delegate(Event, Widget) dlg; 8818 gulong handlerId; 8819 8820 this(bool delegate(Event, Widget) dlg) 8821 { 8822 this.dlg = dlg; 8823 onKeyReleaseEventGenericListeners ~= this; 8824 } 8825 8826 void remove(OnKeyReleaseEventGenericDelegateWrapper source) 8827 { 8828 foreach(index, wrapper; onKeyReleaseEventGenericListeners) 8829 { 8830 if (wrapper.handlerId == source.handlerId) 8831 { 8832 onKeyReleaseEventGenericListeners[index] = null; 8833 onKeyReleaseEventGenericListeners = std.algorithm.remove(onKeyReleaseEventGenericListeners, index); 8834 break; 8835 } 8836 } 8837 } 8838 } 8839 OnKeyReleaseEventGenericDelegateWrapper[] onKeyReleaseEventGenericListeners; 8840 8841 /** 8842 * The ::key-release-event signal is emitted when a key is released. 8843 * 8844 * To receive this signal, the #GdkWindow associated to the widget needs 8845 * to enable the #GDK_KEY_RELEASE_MASK mask. 8846 * 8847 * This signal will be sent to the grab widget if there is one. 8848 * 8849 * Params: 8850 * event = the #GdkEventKey which triggered this signal. 8851 * 8852 * Returns: %TRUE to stop other handlers from being invoked for the event. 8853 * %FALSE to propagate the event further. 8854 */ 8855 gulong addOnKeyRelease(bool delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 8856 { 8857 addEvents(EventMask.KEY_RELEASE_MASK); 8858 auto wrapper = new OnKeyReleaseEventGenericDelegateWrapper(dlg); 8859 wrapper.handlerId = Signals.connectData( 8860 this, 8861 "key-release-event", 8862 cast(GCallback)&callBackKeyReleaseEventGeneric, 8863 cast(void*)wrapper, 8864 cast(GClosureNotify)&callBackKeyReleaseEventGenericDestroy, 8865 connectFlags); 8866 return wrapper.handlerId; 8867 } 8868 8869 extern(C) static int callBackKeyReleaseEventGeneric(GtkWidget* widgetStruct, GdkEvent* event, OnKeyReleaseEventGenericDelegateWrapper wrapper) 8870 { 8871 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 8872 } 8873 8874 extern(C) static void callBackKeyReleaseEventGenericDestroy(OnKeyReleaseEventGenericDelegateWrapper wrapper, GClosure* closure) 8875 { 8876 wrapper.remove(wrapper); 8877 } 8878 8879 protected class OnKeynavFailedDelegateWrapper 8880 { 8881 bool delegate(GtkDirectionType, Widget) dlg; 8882 gulong handlerId; 8883 8884 this(bool delegate(GtkDirectionType, Widget) dlg) 8885 { 8886 this.dlg = dlg; 8887 onKeynavFailedListeners ~= this; 8888 } 8889 8890 void remove(OnKeynavFailedDelegateWrapper source) 8891 { 8892 foreach(index, wrapper; onKeynavFailedListeners) 8893 { 8894 if (wrapper.handlerId == source.handlerId) 8895 { 8896 onKeynavFailedListeners[index] = null; 8897 onKeynavFailedListeners = std.algorithm.remove(onKeynavFailedListeners, index); 8898 break; 8899 } 8900 } 8901 } 8902 } 8903 OnKeynavFailedDelegateWrapper[] onKeynavFailedListeners; 8904 8905 /** 8906 * Gets emitted if keyboard navigation fails. 8907 * See gtk_widget_keynav_failed() for details. 8908 * 8909 * Params: 8910 * direction = the direction of movement 8911 * 8912 * Returns: %TRUE if stopping keyboard navigation is fine, %FALSE 8913 * if the emitting widget should try to handle the keyboard 8914 * navigation attempt in its parent container(s). 8915 * 8916 * Since: 2.12 8917 */ 8918 gulong addOnKeynavFailed(bool delegate(GtkDirectionType, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 8919 { 8920 auto wrapper = new OnKeynavFailedDelegateWrapper(dlg); 8921 wrapper.handlerId = Signals.connectData( 8922 this, 8923 "keynav-failed", 8924 cast(GCallback)&callBackKeynavFailed, 8925 cast(void*)wrapper, 8926 cast(GClosureNotify)&callBackKeynavFailedDestroy, 8927 connectFlags); 8928 return wrapper.handlerId; 8929 } 8930 8931 extern(C) static int callBackKeynavFailed(GtkWidget* widgetStruct, GtkDirectionType direction, OnKeynavFailedDelegateWrapper wrapper) 8932 { 8933 return wrapper.dlg(direction, wrapper.outer); 8934 } 8935 8936 extern(C) static void callBackKeynavFailedDestroy(OnKeynavFailedDelegateWrapper wrapper, GClosure* closure) 8937 { 8938 wrapper.remove(wrapper); 8939 } 8940 8941 protected class OnLeaveNotifyDelegateWrapper 8942 { 8943 bool delegate(GdkEventCrossing*, Widget) dlg; 8944 gulong handlerId; 8945 8946 this(bool delegate(GdkEventCrossing*, Widget) dlg) 8947 { 8948 this.dlg = dlg; 8949 onLeaveNotifyListeners ~= this; 8950 } 8951 8952 void remove(OnLeaveNotifyDelegateWrapper source) 8953 { 8954 foreach(index, wrapper; onLeaveNotifyListeners) 8955 { 8956 if (wrapper.handlerId == source.handlerId) 8957 { 8958 onLeaveNotifyListeners[index] = null; 8959 onLeaveNotifyListeners = std.algorithm.remove(onLeaveNotifyListeners, index); 8960 break; 8961 } 8962 } 8963 } 8964 } 8965 OnLeaveNotifyDelegateWrapper[] onLeaveNotifyListeners; 8966 8967 /** 8968 * The ::leave-notify-event will be emitted when the pointer leaves 8969 * the @widget's window. 8970 * 8971 * To receive this signal, the #GdkWindow associated to the widget needs 8972 * to enable the #GDK_LEAVE_NOTIFY_MASK mask. 8973 * 8974 * This signal will be sent to the grab widget if there is one. 8975 * 8976 * Params: 8977 * event = the #GdkEventCrossing which triggered 8978 * this signal. 8979 * 8980 * Returns: %TRUE to stop other handlers from being invoked for the event. 8981 * %FALSE to propagate the event further. 8982 */ 8983 gulong addOnLeaveNotify(bool delegate(GdkEventCrossing*, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 8984 { 8985 addEvents(EventMask.LEAVE_NOTIFY_MASK); 8986 auto wrapper = new OnLeaveNotifyDelegateWrapper(dlg); 8987 wrapper.handlerId = Signals.connectData( 8988 this, 8989 "leave-notify-event", 8990 cast(GCallback)&callBackLeaveNotify, 8991 cast(void*)wrapper, 8992 cast(GClosureNotify)&callBackLeaveNotifyDestroy, 8993 connectFlags); 8994 return wrapper.handlerId; 8995 } 8996 8997 extern(C) static int callBackLeaveNotify(GtkWidget* widgetStruct, GdkEventCrossing* event, OnLeaveNotifyDelegateWrapper wrapper) 8998 { 8999 return wrapper.dlg(event, wrapper.outer); 9000 } 9001 9002 extern(C) static void callBackLeaveNotifyDestroy(OnLeaveNotifyDelegateWrapper wrapper, GClosure* closure) 9003 { 9004 wrapper.remove(wrapper); 9005 } 9006 9007 protected class OnLeaveNotifyEventGenericDelegateWrapper 9008 { 9009 bool delegate(Event, Widget) dlg; 9010 gulong handlerId; 9011 9012 this(bool delegate(Event, Widget) dlg) 9013 { 9014 this.dlg = dlg; 9015 onLeaveNotifyEventGenericListeners ~= this; 9016 } 9017 9018 void remove(OnLeaveNotifyEventGenericDelegateWrapper source) 9019 { 9020 foreach(index, wrapper; onLeaveNotifyEventGenericListeners) 9021 { 9022 if (wrapper.handlerId == source.handlerId) 9023 { 9024 onLeaveNotifyEventGenericListeners[index] = null; 9025 onLeaveNotifyEventGenericListeners = std.algorithm.remove(onLeaveNotifyEventGenericListeners, index); 9026 break; 9027 } 9028 } 9029 } 9030 } 9031 OnLeaveNotifyEventGenericDelegateWrapper[] onLeaveNotifyEventGenericListeners; 9032 9033 /** 9034 * The ::leave-notify-event will be emitted when the pointer leaves 9035 * the @widget's window. 9036 * 9037 * To receive this signal, the #GdkWindow associated to the widget needs 9038 * to enable the #GDK_LEAVE_NOTIFY_MASK mask. 9039 * 9040 * This signal will be sent to the grab widget if there is one. 9041 * 9042 * Params: 9043 * event = the #GdkEventCrossing which triggered 9044 * this signal. 9045 * 9046 * Returns: %TRUE to stop other handlers from being invoked for the event. 9047 * %FALSE to propagate the event further. 9048 */ 9049 gulong addOnLeaveNotify(bool delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 9050 { 9051 addEvents(EventMask.LEAVE_NOTIFY_MASK); 9052 auto wrapper = new OnLeaveNotifyEventGenericDelegateWrapper(dlg); 9053 wrapper.handlerId = Signals.connectData( 9054 this, 9055 "leave-notify-event", 9056 cast(GCallback)&callBackLeaveNotifyEventGeneric, 9057 cast(void*)wrapper, 9058 cast(GClosureNotify)&callBackLeaveNotifyEventGenericDestroy, 9059 connectFlags); 9060 return wrapper.handlerId; 9061 } 9062 9063 extern(C) static int callBackLeaveNotifyEventGeneric(GtkWidget* widgetStruct, GdkEvent* event, OnLeaveNotifyEventGenericDelegateWrapper wrapper) 9064 { 9065 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 9066 } 9067 9068 extern(C) static void callBackLeaveNotifyEventGenericDestroy(OnLeaveNotifyEventGenericDelegateWrapper wrapper, GClosure* closure) 9069 { 9070 wrapper.remove(wrapper); 9071 } 9072 9073 protected class OnMapDelegateWrapper 9074 { 9075 void delegate(Widget) dlg; 9076 gulong handlerId; 9077 9078 this(void delegate(Widget) dlg) 9079 { 9080 this.dlg = dlg; 9081 onMapListeners ~= this; 9082 } 9083 9084 void remove(OnMapDelegateWrapper source) 9085 { 9086 foreach(index, wrapper; onMapListeners) 9087 { 9088 if (wrapper.handlerId == source.handlerId) 9089 { 9090 onMapListeners[index] = null; 9091 onMapListeners = std.algorithm.remove(onMapListeners, index); 9092 break; 9093 } 9094 } 9095 } 9096 } 9097 OnMapDelegateWrapper[] onMapListeners; 9098 9099 /** 9100 * The ::map signal is emitted when @widget is going to be mapped, that is 9101 * when the widget is visible (which is controlled with 9102 * gtk_widget_set_visible()) and all its parents up to the toplevel widget 9103 * are also visible. Once the map has occurred, #GtkWidget::map-event will 9104 * be emitted. 9105 * 9106 * The ::map signal can be used to determine whether a widget will be drawn, 9107 * for instance it can resume an animation that was stopped during the 9108 * emission of #GtkWidget::unmap. 9109 */ 9110 gulong addOnMap(void delegate(Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 9111 { 9112 auto wrapper = new OnMapDelegateWrapper(dlg); 9113 wrapper.handlerId = Signals.connectData( 9114 this, 9115 "map", 9116 cast(GCallback)&callBackMap, 9117 cast(void*)wrapper, 9118 cast(GClosureNotify)&callBackMapDestroy, 9119 connectFlags); 9120 return wrapper.handlerId; 9121 } 9122 9123 extern(C) static void callBackMap(GtkWidget* widgetStruct, OnMapDelegateWrapper wrapper) 9124 { 9125 wrapper.dlg(wrapper.outer); 9126 } 9127 9128 extern(C) static void callBackMapDestroy(OnMapDelegateWrapper wrapper, GClosure* closure) 9129 { 9130 wrapper.remove(wrapper); 9131 } 9132 9133 protected class OnMapEventDelegateWrapper 9134 { 9135 bool delegate(GdkEventAny*, Widget) dlg; 9136 gulong handlerId; 9137 9138 this(bool delegate(GdkEventAny*, Widget) dlg) 9139 { 9140 this.dlg = dlg; 9141 onMapEventListeners ~= this; 9142 } 9143 9144 void remove(OnMapEventDelegateWrapper source) 9145 { 9146 foreach(index, wrapper; onMapEventListeners) 9147 { 9148 if (wrapper.handlerId == source.handlerId) 9149 { 9150 onMapEventListeners[index] = null; 9151 onMapEventListeners = std.algorithm.remove(onMapEventListeners, index); 9152 break; 9153 } 9154 } 9155 } 9156 } 9157 OnMapEventDelegateWrapper[] onMapEventListeners; 9158 9159 /** 9160 * The ::map-event signal will be emitted when the @widget's window is 9161 * mapped. A window is mapped when it becomes visible on the screen. 9162 * 9163 * To receive this signal, the #GdkWindow associated to the widget needs 9164 * to enable the #GDK_STRUCTURE_MASK mask. GDK will enable this mask 9165 * automatically for all new windows. 9166 * 9167 * Params: 9168 * event = the #GdkEventAny which triggered this signal. 9169 * 9170 * Returns: %TRUE to stop other handlers from being invoked for the event. 9171 * %FALSE to propagate the event further. 9172 */ 9173 gulong addOnMapEvent(bool delegate(GdkEventAny*, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 9174 { 9175 auto wrapper = new OnMapEventDelegateWrapper(dlg); 9176 wrapper.handlerId = Signals.connectData( 9177 this, 9178 "map-event", 9179 cast(GCallback)&callBackMapEvent, 9180 cast(void*)wrapper, 9181 cast(GClosureNotify)&callBackMapEventDestroy, 9182 connectFlags); 9183 return wrapper.handlerId; 9184 } 9185 9186 extern(C) static int callBackMapEvent(GtkWidget* widgetStruct, GdkEventAny* event, OnMapEventDelegateWrapper wrapper) 9187 { 9188 return wrapper.dlg(event, wrapper.outer); 9189 } 9190 9191 extern(C) static void callBackMapEventDestroy(OnMapEventDelegateWrapper wrapper, GClosure* closure) 9192 { 9193 wrapper.remove(wrapper); 9194 } 9195 9196 protected class OnMapEventGenericDelegateWrapper 9197 { 9198 bool delegate(Event, Widget) dlg; 9199 gulong handlerId; 9200 9201 this(bool delegate(Event, Widget) dlg) 9202 { 9203 this.dlg = dlg; 9204 onMapEventGenericListeners ~= this; 9205 } 9206 9207 void remove(OnMapEventGenericDelegateWrapper source) 9208 { 9209 foreach(index, wrapper; onMapEventGenericListeners) 9210 { 9211 if (wrapper.handlerId == source.handlerId) 9212 { 9213 onMapEventGenericListeners[index] = null; 9214 onMapEventGenericListeners = std.algorithm.remove(onMapEventGenericListeners, index); 9215 break; 9216 } 9217 } 9218 } 9219 } 9220 OnMapEventGenericDelegateWrapper[] onMapEventGenericListeners; 9221 9222 /** 9223 * The ::map-event signal will be emitted when the @widget's window is 9224 * mapped. A window is mapped when it becomes visible on the screen. 9225 * 9226 * To receive this signal, the #GdkWindow associated to the widget needs 9227 * to enable the #GDK_STRUCTURE_MASK mask. GDK will enable this mask 9228 * automatically for all new windows. 9229 * 9230 * Params: 9231 * event = the #GdkEventAny which triggered this signal. 9232 * 9233 * Returns: %TRUE to stop other handlers from being invoked for the event. 9234 * %FALSE to propagate the event further. 9235 */ 9236 gulong addOnMapEvent(bool delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 9237 { 9238 auto wrapper = new OnMapEventGenericDelegateWrapper(dlg); 9239 wrapper.handlerId = Signals.connectData( 9240 this, 9241 "map-event", 9242 cast(GCallback)&callBackMapEventGeneric, 9243 cast(void*)wrapper, 9244 cast(GClosureNotify)&callBackMapEventGenericDestroy, 9245 connectFlags); 9246 return wrapper.handlerId; 9247 } 9248 9249 extern(C) static int callBackMapEventGeneric(GtkWidget* widgetStruct, GdkEvent* event, OnMapEventGenericDelegateWrapper wrapper) 9250 { 9251 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 9252 } 9253 9254 extern(C) static void callBackMapEventGenericDestroy(OnMapEventGenericDelegateWrapper wrapper, GClosure* closure) 9255 { 9256 wrapper.remove(wrapper); 9257 } 9258 9259 protected class OnMnemonicActivateDelegateWrapper 9260 { 9261 bool delegate(bool, Widget) dlg; 9262 gulong handlerId; 9263 9264 this(bool delegate(bool, Widget) dlg) 9265 { 9266 this.dlg = dlg; 9267 onMnemonicActivateListeners ~= this; 9268 } 9269 9270 void remove(OnMnemonicActivateDelegateWrapper source) 9271 { 9272 foreach(index, wrapper; onMnemonicActivateListeners) 9273 { 9274 if (wrapper.handlerId == source.handlerId) 9275 { 9276 onMnemonicActivateListeners[index] = null; 9277 onMnemonicActivateListeners = std.algorithm.remove(onMnemonicActivateListeners, index); 9278 break; 9279 } 9280 } 9281 } 9282 } 9283 OnMnemonicActivateDelegateWrapper[] onMnemonicActivateListeners; 9284 9285 /** 9286 * The default handler for this signal activates @widget if @group_cycling 9287 * is %FALSE, or just makes @widget grab focus if @group_cycling is %TRUE. 9288 * 9289 * Params: 9290 * groupCycling = %TRUE if there are other widgets with the same mnemonic 9291 * 9292 * Returns: %TRUE to stop other handlers from being invoked for the event. 9293 * %FALSE to propagate the event further. 9294 */ 9295 gulong addOnMnemonicActivate(bool delegate(bool, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 9296 { 9297 auto wrapper = new OnMnemonicActivateDelegateWrapper(dlg); 9298 wrapper.handlerId = Signals.connectData( 9299 this, 9300 "mnemonic-activate", 9301 cast(GCallback)&callBackMnemonicActivate, 9302 cast(void*)wrapper, 9303 cast(GClosureNotify)&callBackMnemonicActivateDestroy, 9304 connectFlags); 9305 return wrapper.handlerId; 9306 } 9307 9308 extern(C) static int callBackMnemonicActivate(GtkWidget* widgetStruct, bool groupCycling, OnMnemonicActivateDelegateWrapper wrapper) 9309 { 9310 return wrapper.dlg(groupCycling, wrapper.outer); 9311 } 9312 9313 extern(C) static void callBackMnemonicActivateDestroy(OnMnemonicActivateDelegateWrapper wrapper, GClosure* closure) 9314 { 9315 wrapper.remove(wrapper); 9316 } 9317 9318 protected class OnMotionNotifyDelegateWrapper 9319 { 9320 bool delegate(GdkEventMotion*, Widget) dlg; 9321 gulong handlerId; 9322 9323 this(bool delegate(GdkEventMotion*, Widget) dlg) 9324 { 9325 this.dlg = dlg; 9326 onMotionNotifyListeners ~= this; 9327 } 9328 9329 void remove(OnMotionNotifyDelegateWrapper source) 9330 { 9331 foreach(index, wrapper; onMotionNotifyListeners) 9332 { 9333 if (wrapper.handlerId == source.handlerId) 9334 { 9335 onMotionNotifyListeners[index] = null; 9336 onMotionNotifyListeners = std.algorithm.remove(onMotionNotifyListeners, index); 9337 break; 9338 } 9339 } 9340 } 9341 } 9342 OnMotionNotifyDelegateWrapper[] onMotionNotifyListeners; 9343 9344 /** 9345 * The ::motion-notify-event signal is emitted when the pointer moves 9346 * over the widget's #GdkWindow. 9347 * 9348 * To receive this signal, the #GdkWindow associated to the widget 9349 * needs to enable the #GDK_POINTER_MOTION_MASK mask. 9350 * 9351 * This signal will be sent to the grab widget if there is one. 9352 * 9353 * Params: 9354 * event = the #GdkEventMotion which triggered 9355 * this signal. 9356 * 9357 * Returns: %TRUE to stop other handlers from being invoked for the event. 9358 * %FALSE to propagate the event further. 9359 */ 9360 gulong addOnMotionNotify(bool delegate(GdkEventMotion*, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 9361 { 9362 addEvents(EventMask.POINTER_MOTION_MASK); 9363 auto wrapper = new OnMotionNotifyDelegateWrapper(dlg); 9364 wrapper.handlerId = Signals.connectData( 9365 this, 9366 "motion-notify-event", 9367 cast(GCallback)&callBackMotionNotify, 9368 cast(void*)wrapper, 9369 cast(GClosureNotify)&callBackMotionNotifyDestroy, 9370 connectFlags); 9371 return wrapper.handlerId; 9372 } 9373 9374 extern(C) static int callBackMotionNotify(GtkWidget* widgetStruct, GdkEventMotion* event, OnMotionNotifyDelegateWrapper wrapper) 9375 { 9376 return wrapper.dlg(event, wrapper.outer); 9377 } 9378 9379 extern(C) static void callBackMotionNotifyDestroy(OnMotionNotifyDelegateWrapper wrapper, GClosure* closure) 9380 { 9381 wrapper.remove(wrapper); 9382 } 9383 9384 protected class OnMotionNotifyEventGenericDelegateWrapper 9385 { 9386 bool delegate(Event, Widget) dlg; 9387 gulong handlerId; 9388 9389 this(bool delegate(Event, Widget) dlg) 9390 { 9391 this.dlg = dlg; 9392 onMotionNotifyEventGenericListeners ~= this; 9393 } 9394 9395 void remove(OnMotionNotifyEventGenericDelegateWrapper source) 9396 { 9397 foreach(index, wrapper; onMotionNotifyEventGenericListeners) 9398 { 9399 if (wrapper.handlerId == source.handlerId) 9400 { 9401 onMotionNotifyEventGenericListeners[index] = null; 9402 onMotionNotifyEventGenericListeners = std.algorithm.remove(onMotionNotifyEventGenericListeners, index); 9403 break; 9404 } 9405 } 9406 } 9407 } 9408 OnMotionNotifyEventGenericDelegateWrapper[] onMotionNotifyEventGenericListeners; 9409 9410 /** 9411 * The ::motion-notify-event signal is emitted when the pointer moves 9412 * over the widget's #GdkWindow. 9413 * 9414 * To receive this signal, the #GdkWindow associated to the widget 9415 * needs to enable the #GDK_POINTER_MOTION_MASK mask. 9416 * 9417 * This signal will be sent to the grab widget if there is one. 9418 * 9419 * Params: 9420 * event = the #GdkEventMotion which triggered 9421 * this signal. 9422 * 9423 * Returns: %TRUE to stop other handlers from being invoked for the event. 9424 * %FALSE to propagate the event further. 9425 */ 9426 gulong addOnMotionNotify(bool delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 9427 { 9428 addEvents(EventMask.POINTER_MOTION_MASK); 9429 auto wrapper = new OnMotionNotifyEventGenericDelegateWrapper(dlg); 9430 wrapper.handlerId = Signals.connectData( 9431 this, 9432 "motion-notify-event", 9433 cast(GCallback)&callBackMotionNotifyEventGeneric, 9434 cast(void*)wrapper, 9435 cast(GClosureNotify)&callBackMotionNotifyEventGenericDestroy, 9436 connectFlags); 9437 return wrapper.handlerId; 9438 } 9439 9440 extern(C) static int callBackMotionNotifyEventGeneric(GtkWidget* widgetStruct, GdkEvent* event, OnMotionNotifyEventGenericDelegateWrapper wrapper) 9441 { 9442 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 9443 } 9444 9445 extern(C) static void callBackMotionNotifyEventGenericDestroy(OnMotionNotifyEventGenericDelegateWrapper wrapper, GClosure* closure) 9446 { 9447 wrapper.remove(wrapper); 9448 } 9449 9450 protected class OnMoveFocusDelegateWrapper 9451 { 9452 void delegate(GtkDirectionType, Widget) dlg; 9453 gulong handlerId; 9454 9455 this(void delegate(GtkDirectionType, Widget) dlg) 9456 { 9457 this.dlg = dlg; 9458 onMoveFocusListeners ~= this; 9459 } 9460 9461 void remove(OnMoveFocusDelegateWrapper source) 9462 { 9463 foreach(index, wrapper; onMoveFocusListeners) 9464 { 9465 if (wrapper.handlerId == source.handlerId) 9466 { 9467 onMoveFocusListeners[index] = null; 9468 onMoveFocusListeners = std.algorithm.remove(onMoveFocusListeners, index); 9469 break; 9470 } 9471 } 9472 } 9473 } 9474 OnMoveFocusDelegateWrapper[] onMoveFocusListeners; 9475 9476 /** */ 9477 gulong addOnMoveFocus(void delegate(GtkDirectionType, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 9478 { 9479 auto wrapper = new OnMoveFocusDelegateWrapper(dlg); 9480 wrapper.handlerId = Signals.connectData( 9481 this, 9482 "move-focus", 9483 cast(GCallback)&callBackMoveFocus, 9484 cast(void*)wrapper, 9485 cast(GClosureNotify)&callBackMoveFocusDestroy, 9486 connectFlags); 9487 return wrapper.handlerId; 9488 } 9489 9490 extern(C) static void callBackMoveFocus(GtkWidget* widgetStruct, GtkDirectionType direction, OnMoveFocusDelegateWrapper wrapper) 9491 { 9492 wrapper.dlg(direction, wrapper.outer); 9493 } 9494 9495 extern(C) static void callBackMoveFocusDestroy(OnMoveFocusDelegateWrapper wrapper, GClosure* closure) 9496 { 9497 wrapper.remove(wrapper); 9498 } 9499 9500 protected class OnParentSetDelegateWrapper 9501 { 9502 void delegate(Widget, Widget) dlg; 9503 gulong handlerId; 9504 9505 this(void delegate(Widget, Widget) dlg) 9506 { 9507 this.dlg = dlg; 9508 onParentSetListeners ~= this; 9509 } 9510 9511 void remove(OnParentSetDelegateWrapper source) 9512 { 9513 foreach(index, wrapper; onParentSetListeners) 9514 { 9515 if (wrapper.handlerId == source.handlerId) 9516 { 9517 onParentSetListeners[index] = null; 9518 onParentSetListeners = std.algorithm.remove(onParentSetListeners, index); 9519 break; 9520 } 9521 } 9522 } 9523 } 9524 OnParentSetDelegateWrapper[] onParentSetListeners; 9525 9526 /** 9527 * The ::parent-set signal is emitted when a new parent 9528 * has been set on a widget. 9529 * 9530 * Params: 9531 * oldParent = the previous parent, or %NULL if the widget 9532 * just got its initial parent. 9533 */ 9534 gulong addOnParentSet(void delegate(Widget, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 9535 { 9536 auto wrapper = new OnParentSetDelegateWrapper(dlg); 9537 wrapper.handlerId = Signals.connectData( 9538 this, 9539 "parent-set", 9540 cast(GCallback)&callBackParentSet, 9541 cast(void*)wrapper, 9542 cast(GClosureNotify)&callBackParentSetDestroy, 9543 connectFlags); 9544 return wrapper.handlerId; 9545 } 9546 9547 extern(C) static void callBackParentSet(GtkWidget* widgetStruct, GtkWidget* oldParent, OnParentSetDelegateWrapper wrapper) 9548 { 9549 wrapper.dlg(ObjectG.getDObject!(Widget)(oldParent), wrapper.outer); 9550 } 9551 9552 extern(C) static void callBackParentSetDestroy(OnParentSetDelegateWrapper wrapper, GClosure* closure) 9553 { 9554 wrapper.remove(wrapper); 9555 } 9556 9557 protected class OnPopupMenuDelegateWrapper 9558 { 9559 bool delegate(Widget) dlg; 9560 gulong handlerId; 9561 9562 this(bool delegate(Widget) dlg) 9563 { 9564 this.dlg = dlg; 9565 onPopupMenuListeners ~= this; 9566 } 9567 9568 void remove(OnPopupMenuDelegateWrapper source) 9569 { 9570 foreach(index, wrapper; onPopupMenuListeners) 9571 { 9572 if (wrapper.handlerId == source.handlerId) 9573 { 9574 onPopupMenuListeners[index] = null; 9575 onPopupMenuListeners = std.algorithm.remove(onPopupMenuListeners, index); 9576 break; 9577 } 9578 } 9579 } 9580 } 9581 OnPopupMenuDelegateWrapper[] onPopupMenuListeners; 9582 9583 /** 9584 * This signal gets emitted whenever a widget should pop up a context 9585 * menu. This usually happens through the standard key binding mechanism; 9586 * by pressing a certain key while a widget is focused, the user can cause 9587 * the widget to pop up a menu. For example, the #GtkEntry widget creates 9588 * a menu with clipboard commands. See the 9589 * [Popup Menu Migration Checklist][checklist-popup-menu] 9590 * for an example of how to use this signal. 9591 * 9592 * Returns: %TRUE if a menu was activated 9593 */ 9594 gulong addOnPopupMenu(bool delegate(Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 9595 { 9596 auto wrapper = new OnPopupMenuDelegateWrapper(dlg); 9597 wrapper.handlerId = Signals.connectData( 9598 this, 9599 "popup-menu", 9600 cast(GCallback)&callBackPopupMenu, 9601 cast(void*)wrapper, 9602 cast(GClosureNotify)&callBackPopupMenuDestroy, 9603 connectFlags); 9604 return wrapper.handlerId; 9605 } 9606 9607 extern(C) static int callBackPopupMenu(GtkWidget* widgetStruct, OnPopupMenuDelegateWrapper wrapper) 9608 { 9609 return wrapper.dlg(wrapper.outer); 9610 } 9611 9612 extern(C) static void callBackPopupMenuDestroy(OnPopupMenuDelegateWrapper wrapper, GClosure* closure) 9613 { 9614 wrapper.remove(wrapper); 9615 } 9616 9617 protected class OnPropertyNotifyDelegateWrapper 9618 { 9619 bool delegate(GdkEventProperty*, Widget) dlg; 9620 gulong handlerId; 9621 9622 this(bool delegate(GdkEventProperty*, Widget) dlg) 9623 { 9624 this.dlg = dlg; 9625 onPropertyNotifyListeners ~= this; 9626 } 9627 9628 void remove(OnPropertyNotifyDelegateWrapper source) 9629 { 9630 foreach(index, wrapper; onPropertyNotifyListeners) 9631 { 9632 if (wrapper.handlerId == source.handlerId) 9633 { 9634 onPropertyNotifyListeners[index] = null; 9635 onPropertyNotifyListeners = std.algorithm.remove(onPropertyNotifyListeners, index); 9636 break; 9637 } 9638 } 9639 } 9640 } 9641 OnPropertyNotifyDelegateWrapper[] onPropertyNotifyListeners; 9642 9643 /** 9644 * The ::property-notify-event signal will be emitted when a property on 9645 * the @widget's window has been changed or deleted. 9646 * 9647 * To receive this signal, the #GdkWindow associated to the widget needs 9648 * to enable the #GDK_PROPERTY_CHANGE_MASK mask. 9649 * 9650 * Params: 9651 * event = the #GdkEventProperty which triggered 9652 * this signal. 9653 * 9654 * Returns: %TRUE to stop other handlers from being invoked for the event. 9655 * %FALSE to propagate the event further. 9656 */ 9657 gulong addOnPropertyNotify(bool delegate(GdkEventProperty*, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 9658 { 9659 addEvents(EventMask.PROPERTY_CHANGE_MASK); 9660 auto wrapper = new OnPropertyNotifyDelegateWrapper(dlg); 9661 wrapper.handlerId = Signals.connectData( 9662 this, 9663 "property-notify-event", 9664 cast(GCallback)&callBackPropertyNotify, 9665 cast(void*)wrapper, 9666 cast(GClosureNotify)&callBackPropertyNotifyDestroy, 9667 connectFlags); 9668 return wrapper.handlerId; 9669 } 9670 9671 extern(C) static int callBackPropertyNotify(GtkWidget* widgetStruct, GdkEventProperty* event, OnPropertyNotifyDelegateWrapper wrapper) 9672 { 9673 return wrapper.dlg(event, wrapper.outer); 9674 } 9675 9676 extern(C) static void callBackPropertyNotifyDestroy(OnPropertyNotifyDelegateWrapper wrapper, GClosure* closure) 9677 { 9678 wrapper.remove(wrapper); 9679 } 9680 9681 protected class OnPropertyNotifyEventGenericDelegateWrapper 9682 { 9683 bool delegate(Event, Widget) dlg; 9684 gulong handlerId; 9685 9686 this(bool delegate(Event, Widget) dlg) 9687 { 9688 this.dlg = dlg; 9689 onPropertyNotifyEventGenericListeners ~= this; 9690 } 9691 9692 void remove(OnPropertyNotifyEventGenericDelegateWrapper source) 9693 { 9694 foreach(index, wrapper; onPropertyNotifyEventGenericListeners) 9695 { 9696 if (wrapper.handlerId == source.handlerId) 9697 { 9698 onPropertyNotifyEventGenericListeners[index] = null; 9699 onPropertyNotifyEventGenericListeners = std.algorithm.remove(onPropertyNotifyEventGenericListeners, index); 9700 break; 9701 } 9702 } 9703 } 9704 } 9705 OnPropertyNotifyEventGenericDelegateWrapper[] onPropertyNotifyEventGenericListeners; 9706 9707 /** 9708 * The ::property-notify-event signal will be emitted when a property on 9709 * the @widget's window has been changed or deleted. 9710 * 9711 * To receive this signal, the #GdkWindow associated to the widget needs 9712 * to enable the #GDK_PROPERTY_CHANGE_MASK mask. 9713 * 9714 * Params: 9715 * event = the #GdkEventProperty which triggered 9716 * this signal. 9717 * 9718 * Returns: %TRUE to stop other handlers from being invoked for the event. 9719 * %FALSE to propagate the event further. 9720 */ 9721 gulong addOnPropertyNotify(bool delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 9722 { 9723 addEvents(EventMask.PROPERTY_CHANGE_MASK); 9724 auto wrapper = new OnPropertyNotifyEventGenericDelegateWrapper(dlg); 9725 wrapper.handlerId = Signals.connectData( 9726 this, 9727 "property-notify-event", 9728 cast(GCallback)&callBackPropertyNotifyEventGeneric, 9729 cast(void*)wrapper, 9730 cast(GClosureNotify)&callBackPropertyNotifyEventGenericDestroy, 9731 connectFlags); 9732 return wrapper.handlerId; 9733 } 9734 9735 extern(C) static int callBackPropertyNotifyEventGeneric(GtkWidget* widgetStruct, GdkEvent* event, OnPropertyNotifyEventGenericDelegateWrapper wrapper) 9736 { 9737 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 9738 } 9739 9740 extern(C) static void callBackPropertyNotifyEventGenericDestroy(OnPropertyNotifyEventGenericDelegateWrapper wrapper, GClosure* closure) 9741 { 9742 wrapper.remove(wrapper); 9743 } 9744 9745 protected class OnProximityInDelegateWrapper 9746 { 9747 bool delegate(GdkEventProximity*, Widget) dlg; 9748 gulong handlerId; 9749 9750 this(bool delegate(GdkEventProximity*, Widget) dlg) 9751 { 9752 this.dlg = dlg; 9753 onProximityInListeners ~= this; 9754 } 9755 9756 void remove(OnProximityInDelegateWrapper source) 9757 { 9758 foreach(index, wrapper; onProximityInListeners) 9759 { 9760 if (wrapper.handlerId == source.handlerId) 9761 { 9762 onProximityInListeners[index] = null; 9763 onProximityInListeners = std.algorithm.remove(onProximityInListeners, index); 9764 break; 9765 } 9766 } 9767 } 9768 } 9769 OnProximityInDelegateWrapper[] onProximityInListeners; 9770 9771 /** 9772 * To receive this signal the #GdkWindow associated to the widget needs 9773 * to enable the #GDK_PROXIMITY_IN_MASK mask. 9774 * 9775 * This signal will be sent to the grab widget if there is one. 9776 * 9777 * Params: 9778 * event = the #GdkEventProximity which triggered 9779 * this signal. 9780 * 9781 * Returns: %TRUE to stop other handlers from being invoked for the event. 9782 * %FALSE to propagate the event further. 9783 */ 9784 gulong addOnProximityIn(bool delegate(GdkEventProximity*, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 9785 { 9786 addEvents(EventMask.PROXIMITY_IN_MASK); 9787 auto wrapper = new OnProximityInDelegateWrapper(dlg); 9788 wrapper.handlerId = Signals.connectData( 9789 this, 9790 "proximity-in-event", 9791 cast(GCallback)&callBackProximityIn, 9792 cast(void*)wrapper, 9793 cast(GClosureNotify)&callBackProximityInDestroy, 9794 connectFlags); 9795 return wrapper.handlerId; 9796 } 9797 9798 extern(C) static int callBackProximityIn(GtkWidget* widgetStruct, GdkEventProximity* event, OnProximityInDelegateWrapper wrapper) 9799 { 9800 return wrapper.dlg(event, wrapper.outer); 9801 } 9802 9803 extern(C) static void callBackProximityInDestroy(OnProximityInDelegateWrapper wrapper, GClosure* closure) 9804 { 9805 wrapper.remove(wrapper); 9806 } 9807 9808 protected class OnProximityInEventGenericDelegateWrapper 9809 { 9810 bool delegate(Event, Widget) dlg; 9811 gulong handlerId; 9812 9813 this(bool delegate(Event, Widget) dlg) 9814 { 9815 this.dlg = dlg; 9816 onProximityInEventGenericListeners ~= this; 9817 } 9818 9819 void remove(OnProximityInEventGenericDelegateWrapper source) 9820 { 9821 foreach(index, wrapper; onProximityInEventGenericListeners) 9822 { 9823 if (wrapper.handlerId == source.handlerId) 9824 { 9825 onProximityInEventGenericListeners[index] = null; 9826 onProximityInEventGenericListeners = std.algorithm.remove(onProximityInEventGenericListeners, index); 9827 break; 9828 } 9829 } 9830 } 9831 } 9832 OnProximityInEventGenericDelegateWrapper[] onProximityInEventGenericListeners; 9833 9834 /** 9835 * To receive this signal the #GdkWindow associated to the widget needs 9836 * to enable the #GDK_PROXIMITY_IN_MASK mask. 9837 * 9838 * This signal will be sent to the grab widget if there is one. 9839 * 9840 * Params: 9841 * event = the #GdkEventProximity which triggered 9842 * this signal. 9843 * 9844 * Returns: %TRUE to stop other handlers from being invoked for the event. 9845 * %FALSE to propagate the event further. 9846 */ 9847 gulong addOnProximityIn(bool delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 9848 { 9849 addEvents(EventMask.PROXIMITY_IN_MASK); 9850 auto wrapper = new OnProximityInEventGenericDelegateWrapper(dlg); 9851 wrapper.handlerId = Signals.connectData( 9852 this, 9853 "proximity-in-event", 9854 cast(GCallback)&callBackProximityInEventGeneric, 9855 cast(void*)wrapper, 9856 cast(GClosureNotify)&callBackProximityInEventGenericDestroy, 9857 connectFlags); 9858 return wrapper.handlerId; 9859 } 9860 9861 extern(C) static int callBackProximityInEventGeneric(GtkWidget* widgetStruct, GdkEvent* event, OnProximityInEventGenericDelegateWrapper wrapper) 9862 { 9863 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 9864 } 9865 9866 extern(C) static void callBackProximityInEventGenericDestroy(OnProximityInEventGenericDelegateWrapper wrapper, GClosure* closure) 9867 { 9868 wrapper.remove(wrapper); 9869 } 9870 9871 protected class OnProximityOutDelegateWrapper 9872 { 9873 bool delegate(GdkEventProximity*, Widget) dlg; 9874 gulong handlerId; 9875 9876 this(bool delegate(GdkEventProximity*, Widget) dlg) 9877 { 9878 this.dlg = dlg; 9879 onProximityOutListeners ~= this; 9880 } 9881 9882 void remove(OnProximityOutDelegateWrapper source) 9883 { 9884 foreach(index, wrapper; onProximityOutListeners) 9885 { 9886 if (wrapper.handlerId == source.handlerId) 9887 { 9888 onProximityOutListeners[index] = null; 9889 onProximityOutListeners = std.algorithm.remove(onProximityOutListeners, index); 9890 break; 9891 } 9892 } 9893 } 9894 } 9895 OnProximityOutDelegateWrapper[] onProximityOutListeners; 9896 9897 /** 9898 * To receive this signal the #GdkWindow associated to the widget needs 9899 * to enable the #GDK_PROXIMITY_OUT_MASK mask. 9900 * 9901 * This signal will be sent to the grab widget if there is one. 9902 * 9903 * Params: 9904 * event = the #GdkEventProximity which triggered 9905 * this signal. 9906 * 9907 * Returns: %TRUE to stop other handlers from being invoked for the event. 9908 * %FALSE to propagate the event further. 9909 */ 9910 gulong addOnProximityOut(bool delegate(GdkEventProximity*, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 9911 { 9912 addEvents(EventMask.PROXIMITY_OUT_MASK); 9913 auto wrapper = new OnProximityOutDelegateWrapper(dlg); 9914 wrapper.handlerId = Signals.connectData( 9915 this, 9916 "proximity-out-event", 9917 cast(GCallback)&callBackProximityOut, 9918 cast(void*)wrapper, 9919 cast(GClosureNotify)&callBackProximityOutDestroy, 9920 connectFlags); 9921 return wrapper.handlerId; 9922 } 9923 9924 extern(C) static int callBackProximityOut(GtkWidget* widgetStruct, GdkEventProximity* event, OnProximityOutDelegateWrapper wrapper) 9925 { 9926 return wrapper.dlg(event, wrapper.outer); 9927 } 9928 9929 extern(C) static void callBackProximityOutDestroy(OnProximityOutDelegateWrapper wrapper, GClosure* closure) 9930 { 9931 wrapper.remove(wrapper); 9932 } 9933 9934 protected class OnProximityOutEventGenericDelegateWrapper 9935 { 9936 bool delegate(Event, Widget) dlg; 9937 gulong handlerId; 9938 9939 this(bool delegate(Event, Widget) dlg) 9940 { 9941 this.dlg = dlg; 9942 onProximityOutEventGenericListeners ~= this; 9943 } 9944 9945 void remove(OnProximityOutEventGenericDelegateWrapper source) 9946 { 9947 foreach(index, wrapper; onProximityOutEventGenericListeners) 9948 { 9949 if (wrapper.handlerId == source.handlerId) 9950 { 9951 onProximityOutEventGenericListeners[index] = null; 9952 onProximityOutEventGenericListeners = std.algorithm.remove(onProximityOutEventGenericListeners, index); 9953 break; 9954 } 9955 } 9956 } 9957 } 9958 OnProximityOutEventGenericDelegateWrapper[] onProximityOutEventGenericListeners; 9959 9960 /** 9961 * To receive this signal the #GdkWindow associated to the widget needs 9962 * to enable the #GDK_PROXIMITY_OUT_MASK mask. 9963 * 9964 * This signal will be sent to the grab widget if there is one. 9965 * 9966 * Params: 9967 * event = the #GdkEventProximity which triggered 9968 * this signal. 9969 * 9970 * Returns: %TRUE to stop other handlers from being invoked for the event. 9971 * %FALSE to propagate the event further. 9972 */ 9973 gulong addOnProximityOut(bool delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 9974 { 9975 addEvents(EventMask.PROXIMITY_OUT_MASK); 9976 auto wrapper = new OnProximityOutEventGenericDelegateWrapper(dlg); 9977 wrapper.handlerId = Signals.connectData( 9978 this, 9979 "proximity-out-event", 9980 cast(GCallback)&callBackProximityOutEventGeneric, 9981 cast(void*)wrapper, 9982 cast(GClosureNotify)&callBackProximityOutEventGenericDestroy, 9983 connectFlags); 9984 return wrapper.handlerId; 9985 } 9986 9987 extern(C) static int callBackProximityOutEventGeneric(GtkWidget* widgetStruct, GdkEvent* event, OnProximityOutEventGenericDelegateWrapper wrapper) 9988 { 9989 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 9990 } 9991 9992 extern(C) static void callBackProximityOutEventGenericDestroy(OnProximityOutEventGenericDelegateWrapper wrapper, GClosure* closure) 9993 { 9994 wrapper.remove(wrapper); 9995 } 9996 9997 protected class OnQueryTooltipDelegateWrapper 9998 { 9999 bool delegate(int, int, bool, Tooltip, Widget) dlg; 10000 gulong handlerId; 10001 10002 this(bool delegate(int, int, bool, Tooltip, Widget) dlg) 10003 { 10004 this.dlg = dlg; 10005 onQueryTooltipListeners ~= this; 10006 } 10007 10008 void remove(OnQueryTooltipDelegateWrapper source) 10009 { 10010 foreach(index, wrapper; onQueryTooltipListeners) 10011 { 10012 if (wrapper.handlerId == source.handlerId) 10013 { 10014 onQueryTooltipListeners[index] = null; 10015 onQueryTooltipListeners = std.algorithm.remove(onQueryTooltipListeners, index); 10016 break; 10017 } 10018 } 10019 } 10020 } 10021 OnQueryTooltipDelegateWrapper[] onQueryTooltipListeners; 10022 10023 /** 10024 * Emitted when #GtkWidget:has-tooltip is %TRUE and the hover timeout 10025 * has expired with the cursor hovering "above" @widget; or emitted when @widget got 10026 * focus in keyboard mode. 10027 * 10028 * Using the given coordinates, the signal handler should determine 10029 * whether a tooltip should be shown for @widget. If this is the case 10030 * %TRUE should be returned, %FALSE otherwise. Note that if 10031 * @keyboard_mode is %TRUE, the values of @x and @y are undefined and 10032 * should not be used. 10033 * 10034 * The signal handler is free to manipulate @tooltip with the therefore 10035 * destined function calls. 10036 * 10037 * Params: 10038 * x = the x coordinate of the cursor position where the request has 10039 * been emitted, relative to @widget's left side 10040 * y = the y coordinate of the cursor position where the request has 10041 * been emitted, relative to @widget's top 10042 * keyboardMode = %TRUE if the tooltip was triggered using the keyboard 10043 * tooltip = a #GtkTooltip 10044 * 10045 * Returns: %TRUE if @tooltip should be shown right now, %FALSE otherwise. 10046 * 10047 * Since: 2.12 10048 */ 10049 gulong addOnQueryTooltip(bool delegate(int, int, bool, Tooltip, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 10050 { 10051 auto wrapper = new OnQueryTooltipDelegateWrapper(dlg); 10052 wrapper.handlerId = Signals.connectData( 10053 this, 10054 "query-tooltip", 10055 cast(GCallback)&callBackQueryTooltip, 10056 cast(void*)wrapper, 10057 cast(GClosureNotify)&callBackQueryTooltipDestroy, 10058 connectFlags); 10059 return wrapper.handlerId; 10060 } 10061 10062 extern(C) static int callBackQueryTooltip(GtkWidget* widgetStruct, int x, int y, bool keyboardMode, GtkTooltip* tooltip, OnQueryTooltipDelegateWrapper wrapper) 10063 { 10064 return wrapper.dlg(x, y, keyboardMode, ObjectG.getDObject!(Tooltip)(tooltip), wrapper.outer); 10065 } 10066 10067 extern(C) static void callBackQueryTooltipDestroy(OnQueryTooltipDelegateWrapper wrapper, GClosure* closure) 10068 { 10069 wrapper.remove(wrapper); 10070 } 10071 10072 protected class OnRealizeDelegateWrapper 10073 { 10074 void delegate(Widget) dlg; 10075 gulong handlerId; 10076 10077 this(void delegate(Widget) dlg) 10078 { 10079 this.dlg = dlg; 10080 onRealizeListeners ~= this; 10081 } 10082 10083 void remove(OnRealizeDelegateWrapper source) 10084 { 10085 foreach(index, wrapper; onRealizeListeners) 10086 { 10087 if (wrapper.handlerId == source.handlerId) 10088 { 10089 onRealizeListeners[index] = null; 10090 onRealizeListeners = std.algorithm.remove(onRealizeListeners, index); 10091 break; 10092 } 10093 } 10094 } 10095 } 10096 OnRealizeDelegateWrapper[] onRealizeListeners; 10097 10098 /** 10099 * The ::realize signal is emitted when @widget is associated with a 10100 * #GdkWindow, which means that gtk_widget_realize() has been called or the 10101 * widget has been mapped (that is, it is going to be drawn). 10102 */ 10103 gulong addOnRealize(void delegate(Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 10104 { 10105 auto wrapper = new OnRealizeDelegateWrapper(dlg); 10106 wrapper.handlerId = Signals.connectData( 10107 this, 10108 "realize", 10109 cast(GCallback)&callBackRealize, 10110 cast(void*)wrapper, 10111 cast(GClosureNotify)&callBackRealizeDestroy, 10112 connectFlags); 10113 return wrapper.handlerId; 10114 } 10115 10116 extern(C) static void callBackRealize(GtkWidget* widgetStruct, OnRealizeDelegateWrapper wrapper) 10117 { 10118 wrapper.dlg(wrapper.outer); 10119 } 10120 10121 extern(C) static void callBackRealizeDestroy(OnRealizeDelegateWrapper wrapper, GClosure* closure) 10122 { 10123 wrapper.remove(wrapper); 10124 } 10125 10126 protected class OnScreenChangedDelegateWrapper 10127 { 10128 void delegate(Screen, Widget) dlg; 10129 gulong handlerId; 10130 10131 this(void delegate(Screen, Widget) dlg) 10132 { 10133 this.dlg = dlg; 10134 onScreenChangedListeners ~= this; 10135 } 10136 10137 void remove(OnScreenChangedDelegateWrapper source) 10138 { 10139 foreach(index, wrapper; onScreenChangedListeners) 10140 { 10141 if (wrapper.handlerId == source.handlerId) 10142 { 10143 onScreenChangedListeners[index] = null; 10144 onScreenChangedListeners = std.algorithm.remove(onScreenChangedListeners, index); 10145 break; 10146 } 10147 } 10148 } 10149 } 10150 OnScreenChangedDelegateWrapper[] onScreenChangedListeners; 10151 10152 /** 10153 * The ::screen-changed signal gets emitted when the 10154 * screen of a widget has changed. 10155 * 10156 * Params: 10157 * previousScreen = the previous screen, or %NULL if the 10158 * widget was not associated with a screen before 10159 */ 10160 gulong addOnScreenChanged(void delegate(Screen, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 10161 { 10162 auto wrapper = new OnScreenChangedDelegateWrapper(dlg); 10163 wrapper.handlerId = Signals.connectData( 10164 this, 10165 "screen-changed", 10166 cast(GCallback)&callBackScreenChanged, 10167 cast(void*)wrapper, 10168 cast(GClosureNotify)&callBackScreenChangedDestroy, 10169 connectFlags); 10170 return wrapper.handlerId; 10171 } 10172 10173 extern(C) static void callBackScreenChanged(GtkWidget* widgetStruct, GdkScreen* previousScreen, OnScreenChangedDelegateWrapper wrapper) 10174 { 10175 wrapper.dlg(ObjectG.getDObject!(Screen)(previousScreen), wrapper.outer); 10176 } 10177 10178 extern(C) static void callBackScreenChangedDestroy(OnScreenChangedDelegateWrapper wrapper, GClosure* closure) 10179 { 10180 wrapper.remove(wrapper); 10181 } 10182 10183 protected class OnScrollDelegateWrapper 10184 { 10185 bool delegate(GdkEventScroll*, Widget) dlg; 10186 gulong handlerId; 10187 10188 this(bool delegate(GdkEventScroll*, Widget) dlg) 10189 { 10190 this.dlg = dlg; 10191 onScrollListeners ~= this; 10192 } 10193 10194 void remove(OnScrollDelegateWrapper source) 10195 { 10196 foreach(index, wrapper; onScrollListeners) 10197 { 10198 if (wrapper.handlerId == source.handlerId) 10199 { 10200 onScrollListeners[index] = null; 10201 onScrollListeners = std.algorithm.remove(onScrollListeners, index); 10202 break; 10203 } 10204 } 10205 } 10206 } 10207 OnScrollDelegateWrapper[] onScrollListeners; 10208 10209 /** 10210 * The ::scroll-event signal is emitted when a button in the 4 to 7 10211 * range is pressed. Wheel mice are usually configured to generate 10212 * button press events for buttons 4 and 5 when the wheel is turned. 10213 * 10214 * To receive this signal, the #GdkWindow associated to the widget needs 10215 * to enable the #GDK_SCROLL_MASK mask. 10216 * 10217 * This signal will be sent to the grab widget if there is one. 10218 * 10219 * Params: 10220 * event = the #GdkEventScroll which triggered 10221 * this signal. 10222 * 10223 * Returns: %TRUE to stop other handlers from being invoked for the event. 10224 * %FALSE to propagate the event further. 10225 */ 10226 gulong addOnScroll(bool delegate(GdkEventScroll*, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 10227 { 10228 addEvents(EventMask.SCROLL_MASK); 10229 auto wrapper = new OnScrollDelegateWrapper(dlg); 10230 wrapper.handlerId = Signals.connectData( 10231 this, 10232 "scroll-event", 10233 cast(GCallback)&callBackScroll, 10234 cast(void*)wrapper, 10235 cast(GClosureNotify)&callBackScrollDestroy, 10236 connectFlags); 10237 return wrapper.handlerId; 10238 } 10239 10240 extern(C) static int callBackScroll(GtkWidget* widgetStruct, GdkEventScroll* event, OnScrollDelegateWrapper wrapper) 10241 { 10242 return wrapper.dlg(event, wrapper.outer); 10243 } 10244 10245 extern(C) static void callBackScrollDestroy(OnScrollDelegateWrapper wrapper, GClosure* closure) 10246 { 10247 wrapper.remove(wrapper); 10248 } 10249 10250 protected class OnScrollEventGenericDelegateWrapper 10251 { 10252 bool delegate(Event, Widget) dlg; 10253 gulong handlerId; 10254 10255 this(bool delegate(Event, Widget) dlg) 10256 { 10257 this.dlg = dlg; 10258 onScrollEventGenericListeners ~= this; 10259 } 10260 10261 void remove(OnScrollEventGenericDelegateWrapper source) 10262 { 10263 foreach(index, wrapper; onScrollEventGenericListeners) 10264 { 10265 if (wrapper.handlerId == source.handlerId) 10266 { 10267 onScrollEventGenericListeners[index] = null; 10268 onScrollEventGenericListeners = std.algorithm.remove(onScrollEventGenericListeners, index); 10269 break; 10270 } 10271 } 10272 } 10273 } 10274 OnScrollEventGenericDelegateWrapper[] onScrollEventGenericListeners; 10275 10276 /** 10277 * The ::scroll-event signal is emitted when a button in the 4 to 7 10278 * range is pressed. Wheel mice are usually configured to generate 10279 * button press events for buttons 4 and 5 when the wheel is turned. 10280 * 10281 * To receive this signal, the #GdkWindow associated to the widget needs 10282 * to enable the #GDK_SCROLL_MASK mask. 10283 * 10284 * This signal will be sent to the grab widget if there is one. 10285 * 10286 * Params: 10287 * event = the #GdkEventScroll which triggered 10288 * this signal. 10289 * 10290 * Returns: %TRUE to stop other handlers from being invoked for the event. 10291 * %FALSE to propagate the event further. 10292 */ 10293 gulong addOnScroll(bool delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 10294 { 10295 addEvents(EventMask.SCROLL_MASK); 10296 auto wrapper = new OnScrollEventGenericDelegateWrapper(dlg); 10297 wrapper.handlerId = Signals.connectData( 10298 this, 10299 "scroll-event", 10300 cast(GCallback)&callBackScrollEventGeneric, 10301 cast(void*)wrapper, 10302 cast(GClosureNotify)&callBackScrollEventGenericDestroy, 10303 connectFlags); 10304 return wrapper.handlerId; 10305 } 10306 10307 extern(C) static int callBackScrollEventGeneric(GtkWidget* widgetStruct, GdkEvent* event, OnScrollEventGenericDelegateWrapper wrapper) 10308 { 10309 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 10310 } 10311 10312 extern(C) static void callBackScrollEventGenericDestroy(OnScrollEventGenericDelegateWrapper wrapper, GClosure* closure) 10313 { 10314 wrapper.remove(wrapper); 10315 } 10316 10317 protected class OnSelectionClearDelegateWrapper 10318 { 10319 bool delegate(GdkEventSelection*, Widget) dlg; 10320 gulong handlerId; 10321 10322 this(bool delegate(GdkEventSelection*, Widget) dlg) 10323 { 10324 this.dlg = dlg; 10325 onSelectionClearListeners ~= this; 10326 } 10327 10328 void remove(OnSelectionClearDelegateWrapper source) 10329 { 10330 foreach(index, wrapper; onSelectionClearListeners) 10331 { 10332 if (wrapper.handlerId == source.handlerId) 10333 { 10334 onSelectionClearListeners[index] = null; 10335 onSelectionClearListeners = std.algorithm.remove(onSelectionClearListeners, index); 10336 break; 10337 } 10338 } 10339 } 10340 } 10341 OnSelectionClearDelegateWrapper[] onSelectionClearListeners; 10342 10343 /** 10344 * The ::selection-clear-event signal will be emitted when the 10345 * the @widget's window has lost ownership of a selection. 10346 * 10347 * Params: 10348 * event = the #GdkEventSelection which triggered 10349 * this signal. 10350 * 10351 * Returns: %TRUE to stop other handlers from being invoked for the event. 10352 * %FALSE to propagate the event further. 10353 */ 10354 gulong addOnSelectionClear(bool delegate(GdkEventSelection*, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 10355 { 10356 auto wrapper = new OnSelectionClearDelegateWrapper(dlg); 10357 wrapper.handlerId = Signals.connectData( 10358 this, 10359 "selection-clear-event", 10360 cast(GCallback)&callBackSelectionClear, 10361 cast(void*)wrapper, 10362 cast(GClosureNotify)&callBackSelectionClearDestroy, 10363 connectFlags); 10364 return wrapper.handlerId; 10365 } 10366 10367 extern(C) static int callBackSelectionClear(GtkWidget* widgetStruct, GdkEventSelection* event, OnSelectionClearDelegateWrapper wrapper) 10368 { 10369 return wrapper.dlg(event, wrapper.outer); 10370 } 10371 10372 extern(C) static void callBackSelectionClearDestroy(OnSelectionClearDelegateWrapper wrapper, GClosure* closure) 10373 { 10374 wrapper.remove(wrapper); 10375 } 10376 10377 protected class OnSelectionClearEventGenericDelegateWrapper 10378 { 10379 bool delegate(Event, Widget) dlg; 10380 gulong handlerId; 10381 10382 this(bool delegate(Event, Widget) dlg) 10383 { 10384 this.dlg = dlg; 10385 onSelectionClearEventGenericListeners ~= this; 10386 } 10387 10388 void remove(OnSelectionClearEventGenericDelegateWrapper source) 10389 { 10390 foreach(index, wrapper; onSelectionClearEventGenericListeners) 10391 { 10392 if (wrapper.handlerId == source.handlerId) 10393 { 10394 onSelectionClearEventGenericListeners[index] = null; 10395 onSelectionClearEventGenericListeners = std.algorithm.remove(onSelectionClearEventGenericListeners, index); 10396 break; 10397 } 10398 } 10399 } 10400 } 10401 OnSelectionClearEventGenericDelegateWrapper[] onSelectionClearEventGenericListeners; 10402 10403 /** 10404 * The ::selection-clear-event signal will be emitted when the 10405 * the @widget's window has lost ownership of a selection. 10406 * 10407 * Params: 10408 * event = the #GdkEventSelection which triggered 10409 * this signal. 10410 * 10411 * Returns: %TRUE to stop other handlers from being invoked for the event. 10412 * %FALSE to propagate the event further. 10413 */ 10414 gulong addOnSelectionClear(bool delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 10415 { 10416 auto wrapper = new OnSelectionClearEventGenericDelegateWrapper(dlg); 10417 wrapper.handlerId = Signals.connectData( 10418 this, 10419 "selection-clear-event", 10420 cast(GCallback)&callBackSelectionClearEventGeneric, 10421 cast(void*)wrapper, 10422 cast(GClosureNotify)&callBackSelectionClearEventGenericDestroy, 10423 connectFlags); 10424 return wrapper.handlerId; 10425 } 10426 10427 extern(C) static int callBackSelectionClearEventGeneric(GtkWidget* widgetStruct, GdkEvent* event, OnSelectionClearEventGenericDelegateWrapper wrapper) 10428 { 10429 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 10430 } 10431 10432 extern(C) static void callBackSelectionClearEventGenericDestroy(OnSelectionClearEventGenericDelegateWrapper wrapper, GClosure* closure) 10433 { 10434 wrapper.remove(wrapper); 10435 } 10436 10437 protected class OnSelectionGetDelegateWrapper 10438 { 10439 void delegate(SelectionData, uint, uint, Widget) dlg; 10440 gulong handlerId; 10441 10442 this(void delegate(SelectionData, uint, uint, Widget) dlg) 10443 { 10444 this.dlg = dlg; 10445 onSelectionGetListeners ~= this; 10446 } 10447 10448 void remove(OnSelectionGetDelegateWrapper source) 10449 { 10450 foreach(index, wrapper; onSelectionGetListeners) 10451 { 10452 if (wrapper.handlerId == source.handlerId) 10453 { 10454 onSelectionGetListeners[index] = null; 10455 onSelectionGetListeners = std.algorithm.remove(onSelectionGetListeners, index); 10456 break; 10457 } 10458 } 10459 } 10460 } 10461 OnSelectionGetDelegateWrapper[] onSelectionGetListeners; 10462 10463 /** */ 10464 gulong addOnSelectionGet(void delegate(SelectionData, uint, uint, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 10465 { 10466 auto wrapper = new OnSelectionGetDelegateWrapper(dlg); 10467 wrapper.handlerId = Signals.connectData( 10468 this, 10469 "selection-get", 10470 cast(GCallback)&callBackSelectionGet, 10471 cast(void*)wrapper, 10472 cast(GClosureNotify)&callBackSelectionGetDestroy, 10473 connectFlags); 10474 return wrapper.handlerId; 10475 } 10476 10477 extern(C) static void callBackSelectionGet(GtkWidget* widgetStruct, GtkSelectionData* data, uint info, uint time, OnSelectionGetDelegateWrapper wrapper) 10478 { 10479 wrapper.dlg(ObjectG.getDObject!(SelectionData)(data), info, time, wrapper.outer); 10480 } 10481 10482 extern(C) static void callBackSelectionGetDestroy(OnSelectionGetDelegateWrapper wrapper, GClosure* closure) 10483 { 10484 wrapper.remove(wrapper); 10485 } 10486 10487 protected class OnSelectionNotifyDelegateWrapper 10488 { 10489 bool delegate(GdkEventSelection*, Widget) dlg; 10490 gulong handlerId; 10491 10492 this(bool delegate(GdkEventSelection*, Widget) dlg) 10493 { 10494 this.dlg = dlg; 10495 onSelectionNotifyListeners ~= this; 10496 } 10497 10498 void remove(OnSelectionNotifyDelegateWrapper source) 10499 { 10500 foreach(index, wrapper; onSelectionNotifyListeners) 10501 { 10502 if (wrapper.handlerId == source.handlerId) 10503 { 10504 onSelectionNotifyListeners[index] = null; 10505 onSelectionNotifyListeners = std.algorithm.remove(onSelectionNotifyListeners, index); 10506 break; 10507 } 10508 } 10509 } 10510 } 10511 OnSelectionNotifyDelegateWrapper[] onSelectionNotifyListeners; 10512 10513 /** 10514 * Returns: %TRUE to stop other handlers from being invoked for the event. %FALSE to propagate the event further. 10515 */ 10516 gulong addOnSelectionNotify(bool delegate(GdkEventSelection*, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 10517 { 10518 auto wrapper = new OnSelectionNotifyDelegateWrapper(dlg); 10519 wrapper.handlerId = Signals.connectData( 10520 this, 10521 "selection-notify-event", 10522 cast(GCallback)&callBackSelectionNotify, 10523 cast(void*)wrapper, 10524 cast(GClosureNotify)&callBackSelectionNotifyDestroy, 10525 connectFlags); 10526 return wrapper.handlerId; 10527 } 10528 10529 extern(C) static int callBackSelectionNotify(GtkWidget* widgetStruct, GdkEventSelection* event, OnSelectionNotifyDelegateWrapper wrapper) 10530 { 10531 return wrapper.dlg(event, wrapper.outer); 10532 } 10533 10534 extern(C) static void callBackSelectionNotifyDestroy(OnSelectionNotifyDelegateWrapper wrapper, GClosure* closure) 10535 { 10536 wrapper.remove(wrapper); 10537 } 10538 10539 protected class OnSelectionNotifyEventGenericDelegateWrapper 10540 { 10541 bool delegate(Event, Widget) dlg; 10542 gulong handlerId; 10543 10544 this(bool delegate(Event, Widget) dlg) 10545 { 10546 this.dlg = dlg; 10547 onSelectionNotifyEventGenericListeners ~= this; 10548 } 10549 10550 void remove(OnSelectionNotifyEventGenericDelegateWrapper source) 10551 { 10552 foreach(index, wrapper; onSelectionNotifyEventGenericListeners) 10553 { 10554 if (wrapper.handlerId == source.handlerId) 10555 { 10556 onSelectionNotifyEventGenericListeners[index] = null; 10557 onSelectionNotifyEventGenericListeners = std.algorithm.remove(onSelectionNotifyEventGenericListeners, index); 10558 break; 10559 } 10560 } 10561 } 10562 } 10563 OnSelectionNotifyEventGenericDelegateWrapper[] onSelectionNotifyEventGenericListeners; 10564 10565 /** 10566 * Returns: %TRUE to stop other handlers from being invoked for the event. %FALSE to propagate the event further. 10567 */ 10568 gulong addOnSelectionNotify(bool delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 10569 { 10570 auto wrapper = new OnSelectionNotifyEventGenericDelegateWrapper(dlg); 10571 wrapper.handlerId = Signals.connectData( 10572 this, 10573 "selection-notify-event", 10574 cast(GCallback)&callBackSelectionNotifyEventGeneric, 10575 cast(void*)wrapper, 10576 cast(GClosureNotify)&callBackSelectionNotifyEventGenericDestroy, 10577 connectFlags); 10578 return wrapper.handlerId; 10579 } 10580 10581 extern(C) static int callBackSelectionNotifyEventGeneric(GtkWidget* widgetStruct, GdkEvent* event, OnSelectionNotifyEventGenericDelegateWrapper wrapper) 10582 { 10583 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 10584 } 10585 10586 extern(C) static void callBackSelectionNotifyEventGenericDestroy(OnSelectionNotifyEventGenericDelegateWrapper wrapper, GClosure* closure) 10587 { 10588 wrapper.remove(wrapper); 10589 } 10590 10591 protected class OnSelectionReceivedDelegateWrapper 10592 { 10593 void delegate(SelectionData, uint, Widget) dlg; 10594 gulong handlerId; 10595 10596 this(void delegate(SelectionData, uint, Widget) dlg) 10597 { 10598 this.dlg = dlg; 10599 onSelectionReceivedListeners ~= this; 10600 } 10601 10602 void remove(OnSelectionReceivedDelegateWrapper source) 10603 { 10604 foreach(index, wrapper; onSelectionReceivedListeners) 10605 { 10606 if (wrapper.handlerId == source.handlerId) 10607 { 10608 onSelectionReceivedListeners[index] = null; 10609 onSelectionReceivedListeners = std.algorithm.remove(onSelectionReceivedListeners, index); 10610 break; 10611 } 10612 } 10613 } 10614 } 10615 OnSelectionReceivedDelegateWrapper[] onSelectionReceivedListeners; 10616 10617 /** */ 10618 gulong addOnSelectionReceived(void delegate(SelectionData, uint, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 10619 { 10620 auto wrapper = new OnSelectionReceivedDelegateWrapper(dlg); 10621 wrapper.handlerId = Signals.connectData( 10622 this, 10623 "selection-received", 10624 cast(GCallback)&callBackSelectionReceived, 10625 cast(void*)wrapper, 10626 cast(GClosureNotify)&callBackSelectionReceivedDestroy, 10627 connectFlags); 10628 return wrapper.handlerId; 10629 } 10630 10631 extern(C) static void callBackSelectionReceived(GtkWidget* widgetStruct, GtkSelectionData* data, uint time, OnSelectionReceivedDelegateWrapper wrapper) 10632 { 10633 wrapper.dlg(ObjectG.getDObject!(SelectionData)(data), time, wrapper.outer); 10634 } 10635 10636 extern(C) static void callBackSelectionReceivedDestroy(OnSelectionReceivedDelegateWrapper wrapper, GClosure* closure) 10637 { 10638 wrapper.remove(wrapper); 10639 } 10640 10641 protected class OnSelectionRequestDelegateWrapper 10642 { 10643 bool delegate(GdkEventSelection*, Widget) dlg; 10644 gulong handlerId; 10645 10646 this(bool delegate(GdkEventSelection*, Widget) dlg) 10647 { 10648 this.dlg = dlg; 10649 onSelectionRequestListeners ~= this; 10650 } 10651 10652 void remove(OnSelectionRequestDelegateWrapper source) 10653 { 10654 foreach(index, wrapper; onSelectionRequestListeners) 10655 { 10656 if (wrapper.handlerId == source.handlerId) 10657 { 10658 onSelectionRequestListeners[index] = null; 10659 onSelectionRequestListeners = std.algorithm.remove(onSelectionRequestListeners, index); 10660 break; 10661 } 10662 } 10663 } 10664 } 10665 OnSelectionRequestDelegateWrapper[] onSelectionRequestListeners; 10666 10667 /** 10668 * The ::selection-request-event signal will be emitted when 10669 * another client requests ownership of the selection owned by 10670 * the @widget's window. 10671 * 10672 * Params: 10673 * event = the #GdkEventSelection which triggered 10674 * this signal. 10675 * 10676 * Returns: %TRUE to stop other handlers from being invoked for the event. 10677 * %FALSE to propagate the event further. 10678 */ 10679 gulong addOnSelectionRequest(bool delegate(GdkEventSelection*, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 10680 { 10681 auto wrapper = new OnSelectionRequestDelegateWrapper(dlg); 10682 wrapper.handlerId = Signals.connectData( 10683 this, 10684 "selection-request-event", 10685 cast(GCallback)&callBackSelectionRequest, 10686 cast(void*)wrapper, 10687 cast(GClosureNotify)&callBackSelectionRequestDestroy, 10688 connectFlags); 10689 return wrapper.handlerId; 10690 } 10691 10692 extern(C) static int callBackSelectionRequest(GtkWidget* widgetStruct, GdkEventSelection* event, OnSelectionRequestDelegateWrapper wrapper) 10693 { 10694 return wrapper.dlg(event, wrapper.outer); 10695 } 10696 10697 extern(C) static void callBackSelectionRequestDestroy(OnSelectionRequestDelegateWrapper wrapper, GClosure* closure) 10698 { 10699 wrapper.remove(wrapper); 10700 } 10701 10702 protected class OnSelectionRequestEventGenericDelegateWrapper 10703 { 10704 bool delegate(Event, Widget) dlg; 10705 gulong handlerId; 10706 10707 this(bool delegate(Event, Widget) dlg) 10708 { 10709 this.dlg = dlg; 10710 onSelectionRequestEventGenericListeners ~= this; 10711 } 10712 10713 void remove(OnSelectionRequestEventGenericDelegateWrapper source) 10714 { 10715 foreach(index, wrapper; onSelectionRequestEventGenericListeners) 10716 { 10717 if (wrapper.handlerId == source.handlerId) 10718 { 10719 onSelectionRequestEventGenericListeners[index] = null; 10720 onSelectionRequestEventGenericListeners = std.algorithm.remove(onSelectionRequestEventGenericListeners, index); 10721 break; 10722 } 10723 } 10724 } 10725 } 10726 OnSelectionRequestEventGenericDelegateWrapper[] onSelectionRequestEventGenericListeners; 10727 10728 /** 10729 * The ::selection-request-event signal will be emitted when 10730 * another client requests ownership of the selection owned by 10731 * the @widget's window. 10732 * 10733 * Params: 10734 * event = the #GdkEventSelection which triggered 10735 * this signal. 10736 * 10737 * Returns: %TRUE to stop other handlers from being invoked for the event. 10738 * %FALSE to propagate the event further. 10739 */ 10740 gulong addOnSelectionRequest(bool delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 10741 { 10742 auto wrapper = new OnSelectionRequestEventGenericDelegateWrapper(dlg); 10743 wrapper.handlerId = Signals.connectData( 10744 this, 10745 "selection-request-event", 10746 cast(GCallback)&callBackSelectionRequestEventGeneric, 10747 cast(void*)wrapper, 10748 cast(GClosureNotify)&callBackSelectionRequestEventGenericDestroy, 10749 connectFlags); 10750 return wrapper.handlerId; 10751 } 10752 10753 extern(C) static int callBackSelectionRequestEventGeneric(GtkWidget* widgetStruct, GdkEvent* event, OnSelectionRequestEventGenericDelegateWrapper wrapper) 10754 { 10755 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 10756 } 10757 10758 extern(C) static void callBackSelectionRequestEventGenericDestroy(OnSelectionRequestEventGenericDelegateWrapper wrapper, GClosure* closure) 10759 { 10760 wrapper.remove(wrapper); 10761 } 10762 10763 protected class OnShowDelegateWrapper 10764 { 10765 void delegate(Widget) dlg; 10766 gulong handlerId; 10767 10768 this(void delegate(Widget) dlg) 10769 { 10770 this.dlg = dlg; 10771 onShowListeners ~= this; 10772 } 10773 10774 void remove(OnShowDelegateWrapper source) 10775 { 10776 foreach(index, wrapper; onShowListeners) 10777 { 10778 if (wrapper.handlerId == source.handlerId) 10779 { 10780 onShowListeners[index] = null; 10781 onShowListeners = std.algorithm.remove(onShowListeners, index); 10782 break; 10783 } 10784 } 10785 } 10786 } 10787 OnShowDelegateWrapper[] onShowListeners; 10788 10789 /** 10790 * The ::show signal is emitted when @widget is shown, for example with 10791 * gtk_widget_show(). 10792 */ 10793 gulong addOnShow(void delegate(Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 10794 { 10795 auto wrapper = new OnShowDelegateWrapper(dlg); 10796 wrapper.handlerId = Signals.connectData( 10797 this, 10798 "show", 10799 cast(GCallback)&callBackShow, 10800 cast(void*)wrapper, 10801 cast(GClosureNotify)&callBackShowDestroy, 10802 connectFlags); 10803 return wrapper.handlerId; 10804 } 10805 10806 extern(C) static void callBackShow(GtkWidget* widgetStruct, OnShowDelegateWrapper wrapper) 10807 { 10808 wrapper.dlg(wrapper.outer); 10809 } 10810 10811 extern(C) static void callBackShowDestroy(OnShowDelegateWrapper wrapper, GClosure* closure) 10812 { 10813 wrapper.remove(wrapper); 10814 } 10815 10816 protected class OnShowHelpDelegateWrapper 10817 { 10818 bool delegate(GtkWidgetHelpType, Widget) dlg; 10819 gulong handlerId; 10820 10821 this(bool delegate(GtkWidgetHelpType, Widget) dlg) 10822 { 10823 this.dlg = dlg; 10824 onShowHelpListeners ~= this; 10825 } 10826 10827 void remove(OnShowHelpDelegateWrapper source) 10828 { 10829 foreach(index, wrapper; onShowHelpListeners) 10830 { 10831 if (wrapper.handlerId == source.handlerId) 10832 { 10833 onShowHelpListeners[index] = null; 10834 onShowHelpListeners = std.algorithm.remove(onShowHelpListeners, index); 10835 break; 10836 } 10837 } 10838 } 10839 } 10840 OnShowHelpDelegateWrapper[] onShowHelpListeners; 10841 10842 /** 10843 * Returns: %TRUE to stop other handlers from being invoked for the event. 10844 * %FALSE to propagate the event further. 10845 */ 10846 gulong addOnShowHelp(bool delegate(GtkWidgetHelpType, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 10847 { 10848 auto wrapper = new OnShowHelpDelegateWrapper(dlg); 10849 wrapper.handlerId = Signals.connectData( 10850 this, 10851 "show-help", 10852 cast(GCallback)&callBackShowHelp, 10853 cast(void*)wrapper, 10854 cast(GClosureNotify)&callBackShowHelpDestroy, 10855 connectFlags); 10856 return wrapper.handlerId; 10857 } 10858 10859 extern(C) static int callBackShowHelp(GtkWidget* widgetStruct, GtkWidgetHelpType helpType, OnShowHelpDelegateWrapper wrapper) 10860 { 10861 return wrapper.dlg(helpType, wrapper.outer); 10862 } 10863 10864 extern(C) static void callBackShowHelpDestroy(OnShowHelpDelegateWrapper wrapper, GClosure* closure) 10865 { 10866 wrapper.remove(wrapper); 10867 } 10868 10869 protected class OnSizeAllocateDelegateWrapper 10870 { 10871 void delegate(Allocation, Widget) dlg; 10872 gulong handlerId; 10873 10874 this(void delegate(Allocation, Widget) dlg) 10875 { 10876 this.dlg = dlg; 10877 onSizeAllocateListeners ~= this; 10878 } 10879 10880 void remove(OnSizeAllocateDelegateWrapper source) 10881 { 10882 foreach(index, wrapper; onSizeAllocateListeners) 10883 { 10884 if (wrapper.handlerId == source.handlerId) 10885 { 10886 onSizeAllocateListeners[index] = null; 10887 onSizeAllocateListeners = std.algorithm.remove(onSizeAllocateListeners, index); 10888 break; 10889 } 10890 } 10891 } 10892 } 10893 OnSizeAllocateDelegateWrapper[] onSizeAllocateListeners; 10894 10895 /** */ 10896 gulong addOnSizeAllocate(void delegate(Allocation, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 10897 { 10898 auto wrapper = new OnSizeAllocateDelegateWrapper(dlg); 10899 wrapper.handlerId = Signals.connectData( 10900 this, 10901 "size-allocate", 10902 cast(GCallback)&callBackSizeAllocate, 10903 cast(void*)wrapper, 10904 cast(GClosureNotify)&callBackSizeAllocateDestroy, 10905 connectFlags); 10906 return wrapper.handlerId; 10907 } 10908 10909 extern(C) static void callBackSizeAllocate(GtkWidget* widgetStruct, Allocation allocation, OnSizeAllocateDelegateWrapper wrapper) 10910 { 10911 wrapper.dlg(allocation, wrapper.outer); 10912 } 10913 10914 extern(C) static void callBackSizeAllocateDestroy(OnSizeAllocateDelegateWrapper wrapper, GClosure* closure) 10915 { 10916 wrapper.remove(wrapper); 10917 } 10918 10919 protected class OnStateChangedDelegateWrapper 10920 { 10921 void delegate(GtkStateType, Widget) dlg; 10922 gulong handlerId; 10923 10924 this(void delegate(GtkStateType, Widget) dlg) 10925 { 10926 this.dlg = dlg; 10927 onStateChangedListeners ~= this; 10928 } 10929 10930 void remove(OnStateChangedDelegateWrapper source) 10931 { 10932 foreach(index, wrapper; onStateChangedListeners) 10933 { 10934 if (wrapper.handlerId == source.handlerId) 10935 { 10936 onStateChangedListeners[index] = null; 10937 onStateChangedListeners = std.algorithm.remove(onStateChangedListeners, index); 10938 break; 10939 } 10940 } 10941 } 10942 } 10943 OnStateChangedDelegateWrapper[] onStateChangedListeners; 10944 10945 /** 10946 * The ::state-changed signal is emitted when the widget state changes. 10947 * See gtk_widget_get_state(). 10948 * 10949 * Deprecated: Use #GtkWidget::state-flags-changed instead. 10950 * 10951 * Params: 10952 * state = the previous state 10953 */ 10954 gulong addOnStateChanged(void delegate(GtkStateType, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 10955 { 10956 auto wrapper = new OnStateChangedDelegateWrapper(dlg); 10957 wrapper.handlerId = Signals.connectData( 10958 this, 10959 "state-changed", 10960 cast(GCallback)&callBackStateChanged, 10961 cast(void*)wrapper, 10962 cast(GClosureNotify)&callBackStateChangedDestroy, 10963 connectFlags); 10964 return wrapper.handlerId; 10965 } 10966 10967 extern(C) static void callBackStateChanged(GtkWidget* widgetStruct, GtkStateType state, OnStateChangedDelegateWrapper wrapper) 10968 { 10969 wrapper.dlg(state, wrapper.outer); 10970 } 10971 10972 extern(C) static void callBackStateChangedDestroy(OnStateChangedDelegateWrapper wrapper, GClosure* closure) 10973 { 10974 wrapper.remove(wrapper); 10975 } 10976 10977 protected class OnStateFlagsChangedDelegateWrapper 10978 { 10979 void delegate(GtkStateFlags, Widget) dlg; 10980 gulong handlerId; 10981 10982 this(void delegate(GtkStateFlags, Widget) dlg) 10983 { 10984 this.dlg = dlg; 10985 onStateFlagsChangedListeners ~= this; 10986 } 10987 10988 void remove(OnStateFlagsChangedDelegateWrapper source) 10989 { 10990 foreach(index, wrapper; onStateFlagsChangedListeners) 10991 { 10992 if (wrapper.handlerId == source.handlerId) 10993 { 10994 onStateFlagsChangedListeners[index] = null; 10995 onStateFlagsChangedListeners = std.algorithm.remove(onStateFlagsChangedListeners, index); 10996 break; 10997 } 10998 } 10999 } 11000 } 11001 OnStateFlagsChangedDelegateWrapper[] onStateFlagsChangedListeners; 11002 11003 /** 11004 * The ::state-flags-changed signal is emitted when the widget state 11005 * changes, see gtk_widget_get_state_flags(). 11006 * 11007 * Params: 11008 * flags = The previous state flags. 11009 * 11010 * Since: 3.0 11011 */ 11012 gulong addOnStateFlagsChanged(void delegate(GtkStateFlags, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 11013 { 11014 auto wrapper = new OnStateFlagsChangedDelegateWrapper(dlg); 11015 wrapper.handlerId = Signals.connectData( 11016 this, 11017 "state-flags-changed", 11018 cast(GCallback)&callBackStateFlagsChanged, 11019 cast(void*)wrapper, 11020 cast(GClosureNotify)&callBackStateFlagsChangedDestroy, 11021 connectFlags); 11022 return wrapper.handlerId; 11023 } 11024 11025 extern(C) static void callBackStateFlagsChanged(GtkWidget* widgetStruct, GtkStateFlags flags, OnStateFlagsChangedDelegateWrapper wrapper) 11026 { 11027 wrapper.dlg(flags, wrapper.outer); 11028 } 11029 11030 extern(C) static void callBackStateFlagsChangedDestroy(OnStateFlagsChangedDelegateWrapper wrapper, GClosure* closure) 11031 { 11032 wrapper.remove(wrapper); 11033 } 11034 11035 protected class OnStyleSetDelegateWrapper 11036 { 11037 void delegate(Style, Widget) dlg; 11038 gulong handlerId; 11039 11040 this(void delegate(Style, Widget) dlg) 11041 { 11042 this.dlg = dlg; 11043 onStyleSetListeners ~= this; 11044 } 11045 11046 void remove(OnStyleSetDelegateWrapper source) 11047 { 11048 foreach(index, wrapper; onStyleSetListeners) 11049 { 11050 if (wrapper.handlerId == source.handlerId) 11051 { 11052 onStyleSetListeners[index] = null; 11053 onStyleSetListeners = std.algorithm.remove(onStyleSetListeners, index); 11054 break; 11055 } 11056 } 11057 } 11058 } 11059 OnStyleSetDelegateWrapper[] onStyleSetListeners; 11060 11061 /** 11062 * The ::style-set signal is emitted when a new style has been set 11063 * on a widget. Note that style-modifying functions like 11064 * gtk_widget_modify_base() also cause this signal to be emitted. 11065 * 11066 * Note that this signal is emitted for changes to the deprecated 11067 * #GtkStyle. To track changes to the #GtkStyleContext associated 11068 * with a widget, use the #GtkWidget::style-updated signal. 11069 * 11070 * Deprecated: Use the #GtkWidget::style-updated signal 11071 * 11072 * Params: 11073 * previousStyle = the previous style, or %NULL if the widget 11074 * just got its initial style 11075 */ 11076 gulong addOnStyleSet(void delegate(Style, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 11077 { 11078 auto wrapper = new OnStyleSetDelegateWrapper(dlg); 11079 wrapper.handlerId = Signals.connectData( 11080 this, 11081 "style-set", 11082 cast(GCallback)&callBackStyleSet, 11083 cast(void*)wrapper, 11084 cast(GClosureNotify)&callBackStyleSetDestroy, 11085 connectFlags); 11086 return wrapper.handlerId; 11087 } 11088 11089 extern(C) static void callBackStyleSet(GtkWidget* widgetStruct, GtkStyle* previousStyle, OnStyleSetDelegateWrapper wrapper) 11090 { 11091 wrapper.dlg(ObjectG.getDObject!(Style)(previousStyle), wrapper.outer); 11092 } 11093 11094 extern(C) static void callBackStyleSetDestroy(OnStyleSetDelegateWrapper wrapper, GClosure* closure) 11095 { 11096 wrapper.remove(wrapper); 11097 } 11098 11099 protected class OnStyleUpdatedDelegateWrapper 11100 { 11101 void delegate(Widget) dlg; 11102 gulong handlerId; 11103 11104 this(void delegate(Widget) dlg) 11105 { 11106 this.dlg = dlg; 11107 onStyleUpdatedListeners ~= this; 11108 } 11109 11110 void remove(OnStyleUpdatedDelegateWrapper source) 11111 { 11112 foreach(index, wrapper; onStyleUpdatedListeners) 11113 { 11114 if (wrapper.handlerId == source.handlerId) 11115 { 11116 onStyleUpdatedListeners[index] = null; 11117 onStyleUpdatedListeners = std.algorithm.remove(onStyleUpdatedListeners, index); 11118 break; 11119 } 11120 } 11121 } 11122 } 11123 OnStyleUpdatedDelegateWrapper[] onStyleUpdatedListeners; 11124 11125 /** 11126 * The ::style-updated signal is a convenience signal that is emitted when the 11127 * #GtkStyleContext::changed signal is emitted on the @widget's associated 11128 * #GtkStyleContext as returned by gtk_widget_get_style_context(). 11129 * 11130 * Note that style-modifying functions like gtk_widget_override_color() also 11131 * cause this signal to be emitted. 11132 * 11133 * Since: 3.0 11134 */ 11135 gulong addOnStyleUpdated(void delegate(Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 11136 { 11137 auto wrapper = new OnStyleUpdatedDelegateWrapper(dlg); 11138 wrapper.handlerId = Signals.connectData( 11139 this, 11140 "style-updated", 11141 cast(GCallback)&callBackStyleUpdated, 11142 cast(void*)wrapper, 11143 cast(GClosureNotify)&callBackStyleUpdatedDestroy, 11144 connectFlags); 11145 return wrapper.handlerId; 11146 } 11147 11148 extern(C) static void callBackStyleUpdated(GtkWidget* widgetStruct, OnStyleUpdatedDelegateWrapper wrapper) 11149 { 11150 wrapper.dlg(wrapper.outer); 11151 } 11152 11153 extern(C) static void callBackStyleUpdatedDestroy(OnStyleUpdatedDelegateWrapper wrapper, GClosure* closure) 11154 { 11155 wrapper.remove(wrapper); 11156 } 11157 11158 protected class OnTouchDelegateWrapper 11159 { 11160 bool delegate(Event, Widget) dlg; 11161 gulong handlerId; 11162 11163 this(bool delegate(Event, Widget) dlg) 11164 { 11165 this.dlg = dlg; 11166 onTouchListeners ~= this; 11167 } 11168 11169 void remove(OnTouchDelegateWrapper source) 11170 { 11171 foreach(index, wrapper; onTouchListeners) 11172 { 11173 if (wrapper.handlerId == source.handlerId) 11174 { 11175 onTouchListeners[index] = null; 11176 onTouchListeners = std.algorithm.remove(onTouchListeners, index); 11177 break; 11178 } 11179 } 11180 } 11181 } 11182 OnTouchDelegateWrapper[] onTouchListeners; 11183 11184 /** */ 11185 gulong addOnTouch(bool delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 11186 { 11187 auto wrapper = new OnTouchDelegateWrapper(dlg); 11188 wrapper.handlerId = Signals.connectData( 11189 this, 11190 "touch-event", 11191 cast(GCallback)&callBackTouch, 11192 cast(void*)wrapper, 11193 cast(GClosureNotify)&callBackTouchDestroy, 11194 connectFlags); 11195 return wrapper.handlerId; 11196 } 11197 11198 extern(C) static int callBackTouch(GtkWidget* widgetStruct, GdkEvent* object, OnTouchDelegateWrapper wrapper) 11199 { 11200 return wrapper.dlg(ObjectG.getDObject!(Event)(object), wrapper.outer); 11201 } 11202 11203 extern(C) static void callBackTouchDestroy(OnTouchDelegateWrapper wrapper, GClosure* closure) 11204 { 11205 wrapper.remove(wrapper); 11206 } 11207 11208 protected class OnUnmapDelegateWrapper 11209 { 11210 void delegate(Widget) dlg; 11211 gulong handlerId; 11212 11213 this(void delegate(Widget) dlg) 11214 { 11215 this.dlg = dlg; 11216 onUnmapListeners ~= this; 11217 } 11218 11219 void remove(OnUnmapDelegateWrapper source) 11220 { 11221 foreach(index, wrapper; onUnmapListeners) 11222 { 11223 if (wrapper.handlerId == source.handlerId) 11224 { 11225 onUnmapListeners[index] = null; 11226 onUnmapListeners = std.algorithm.remove(onUnmapListeners, index); 11227 break; 11228 } 11229 } 11230 } 11231 } 11232 OnUnmapDelegateWrapper[] onUnmapListeners; 11233 11234 /** 11235 * The ::unmap signal is emitted when @widget is going to be unmapped, which 11236 * means that either it or any of its parents up to the toplevel widget have 11237 * been set as hidden. 11238 * 11239 * As ::unmap indicates that a widget will not be shown any longer, it can be 11240 * used to, for example, stop an animation on the widget. 11241 */ 11242 gulong addOnUnmap(void delegate(Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 11243 { 11244 auto wrapper = new OnUnmapDelegateWrapper(dlg); 11245 wrapper.handlerId = Signals.connectData( 11246 this, 11247 "unmap", 11248 cast(GCallback)&callBackUnmap, 11249 cast(void*)wrapper, 11250 cast(GClosureNotify)&callBackUnmapDestroy, 11251 connectFlags); 11252 return wrapper.handlerId; 11253 } 11254 11255 extern(C) static void callBackUnmap(GtkWidget* widgetStruct, OnUnmapDelegateWrapper wrapper) 11256 { 11257 wrapper.dlg(wrapper.outer); 11258 } 11259 11260 extern(C) static void callBackUnmapDestroy(OnUnmapDelegateWrapper wrapper, GClosure* closure) 11261 { 11262 wrapper.remove(wrapper); 11263 } 11264 11265 protected class OnUnmapEventDelegateWrapper 11266 { 11267 bool delegate(GdkEventAny*, Widget) dlg; 11268 gulong handlerId; 11269 11270 this(bool delegate(GdkEventAny*, Widget) dlg) 11271 { 11272 this.dlg = dlg; 11273 onUnmapEventListeners ~= this; 11274 } 11275 11276 void remove(OnUnmapEventDelegateWrapper source) 11277 { 11278 foreach(index, wrapper; onUnmapEventListeners) 11279 { 11280 if (wrapper.handlerId == source.handlerId) 11281 { 11282 onUnmapEventListeners[index] = null; 11283 onUnmapEventListeners = std.algorithm.remove(onUnmapEventListeners, index); 11284 break; 11285 } 11286 } 11287 } 11288 } 11289 OnUnmapEventDelegateWrapper[] onUnmapEventListeners; 11290 11291 /** 11292 * The ::unmap-event signal will be emitted when the @widget's window is 11293 * unmapped. A window is unmapped when it becomes invisible on the screen. 11294 * 11295 * To receive this signal, the #GdkWindow associated to the widget needs 11296 * to enable the #GDK_STRUCTURE_MASK mask. GDK will enable this mask 11297 * automatically for all new windows. 11298 * 11299 * Params: 11300 * event = the #GdkEventAny which triggered this signal 11301 * 11302 * Returns: %TRUE to stop other handlers from being invoked for the event. 11303 * %FALSE to propagate the event further. 11304 */ 11305 gulong addOnUnmapEvent(bool delegate(GdkEventAny*, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 11306 { 11307 auto wrapper = new OnUnmapEventDelegateWrapper(dlg); 11308 wrapper.handlerId = Signals.connectData( 11309 this, 11310 "unmap-event", 11311 cast(GCallback)&callBackUnmapEvent, 11312 cast(void*)wrapper, 11313 cast(GClosureNotify)&callBackUnmapEventDestroy, 11314 connectFlags); 11315 return wrapper.handlerId; 11316 } 11317 11318 extern(C) static int callBackUnmapEvent(GtkWidget* widgetStruct, GdkEventAny* event, OnUnmapEventDelegateWrapper wrapper) 11319 { 11320 return wrapper.dlg(event, wrapper.outer); 11321 } 11322 11323 extern(C) static void callBackUnmapEventDestroy(OnUnmapEventDelegateWrapper wrapper, GClosure* closure) 11324 { 11325 wrapper.remove(wrapper); 11326 } 11327 11328 protected class OnUnmapEventGenericDelegateWrapper 11329 { 11330 bool delegate(Event, Widget) dlg; 11331 gulong handlerId; 11332 11333 this(bool delegate(Event, Widget) dlg) 11334 { 11335 this.dlg = dlg; 11336 onUnmapEventGenericListeners ~= this; 11337 } 11338 11339 void remove(OnUnmapEventGenericDelegateWrapper source) 11340 { 11341 foreach(index, wrapper; onUnmapEventGenericListeners) 11342 { 11343 if (wrapper.handlerId == source.handlerId) 11344 { 11345 onUnmapEventGenericListeners[index] = null; 11346 onUnmapEventGenericListeners = std.algorithm.remove(onUnmapEventGenericListeners, index); 11347 break; 11348 } 11349 } 11350 } 11351 } 11352 OnUnmapEventGenericDelegateWrapper[] onUnmapEventGenericListeners; 11353 11354 /** 11355 * The ::unmap-event signal will be emitted when the @widget's window is 11356 * unmapped. A window is unmapped when it becomes invisible on the screen. 11357 * 11358 * To receive this signal, the #GdkWindow associated to the widget needs 11359 * to enable the #GDK_STRUCTURE_MASK mask. GDK will enable this mask 11360 * automatically for all new windows. 11361 * 11362 * Params: 11363 * event = the #GdkEventAny which triggered this signal 11364 * 11365 * Returns: %TRUE to stop other handlers from being invoked for the event. 11366 * %FALSE to propagate the event further. 11367 */ 11368 gulong addOnUnmapEvent(bool delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 11369 { 11370 auto wrapper = new OnUnmapEventGenericDelegateWrapper(dlg); 11371 wrapper.handlerId = Signals.connectData( 11372 this, 11373 "unmap-event", 11374 cast(GCallback)&callBackUnmapEventGeneric, 11375 cast(void*)wrapper, 11376 cast(GClosureNotify)&callBackUnmapEventGenericDestroy, 11377 connectFlags); 11378 return wrapper.handlerId; 11379 } 11380 11381 extern(C) static int callBackUnmapEventGeneric(GtkWidget* widgetStruct, GdkEvent* event, OnUnmapEventGenericDelegateWrapper wrapper) 11382 { 11383 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 11384 } 11385 11386 extern(C) static void callBackUnmapEventGenericDestroy(OnUnmapEventGenericDelegateWrapper wrapper, GClosure* closure) 11387 { 11388 wrapper.remove(wrapper); 11389 } 11390 11391 protected class OnUnrealizeDelegateWrapper 11392 { 11393 void delegate(Widget) dlg; 11394 gulong handlerId; 11395 11396 this(void delegate(Widget) dlg) 11397 { 11398 this.dlg = dlg; 11399 onUnrealizeListeners ~= this; 11400 } 11401 11402 void remove(OnUnrealizeDelegateWrapper source) 11403 { 11404 foreach(index, wrapper; onUnrealizeListeners) 11405 { 11406 if (wrapper.handlerId == source.handlerId) 11407 { 11408 onUnrealizeListeners[index] = null; 11409 onUnrealizeListeners = std.algorithm.remove(onUnrealizeListeners, index); 11410 break; 11411 } 11412 } 11413 } 11414 } 11415 OnUnrealizeDelegateWrapper[] onUnrealizeListeners; 11416 11417 /** 11418 * The ::unrealize signal is emitted when the #GdkWindow associated with 11419 * @widget is destroyed, which means that gtk_widget_unrealize() has been 11420 * called or the widget has been unmapped (that is, it is going to be 11421 * hidden). 11422 */ 11423 gulong addOnUnrealize(void delegate(Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 11424 { 11425 auto wrapper = new OnUnrealizeDelegateWrapper(dlg); 11426 wrapper.handlerId = Signals.connectData( 11427 this, 11428 "unrealize", 11429 cast(GCallback)&callBackUnrealize, 11430 cast(void*)wrapper, 11431 cast(GClosureNotify)&callBackUnrealizeDestroy, 11432 connectFlags); 11433 return wrapper.handlerId; 11434 } 11435 11436 extern(C) static void callBackUnrealize(GtkWidget* widgetStruct, OnUnrealizeDelegateWrapper wrapper) 11437 { 11438 wrapper.dlg(wrapper.outer); 11439 } 11440 11441 extern(C) static void callBackUnrealizeDestroy(OnUnrealizeDelegateWrapper wrapper, GClosure* closure) 11442 { 11443 wrapper.remove(wrapper); 11444 } 11445 11446 protected class OnVisibilityNotifyDelegateWrapper 11447 { 11448 bool delegate(GdkEventVisibility*, Widget) dlg; 11449 gulong handlerId; 11450 11451 this(bool delegate(GdkEventVisibility*, Widget) dlg) 11452 { 11453 this.dlg = dlg; 11454 onVisibilityNotifyListeners ~= this; 11455 } 11456 11457 void remove(OnVisibilityNotifyDelegateWrapper source) 11458 { 11459 foreach(index, wrapper; onVisibilityNotifyListeners) 11460 { 11461 if (wrapper.handlerId == source.handlerId) 11462 { 11463 onVisibilityNotifyListeners[index] = null; 11464 onVisibilityNotifyListeners = std.algorithm.remove(onVisibilityNotifyListeners, index); 11465 break; 11466 } 11467 } 11468 } 11469 } 11470 OnVisibilityNotifyDelegateWrapper[] onVisibilityNotifyListeners; 11471 11472 /** 11473 * The ::visibility-notify-event will be emitted when the @widget's 11474 * window is obscured or unobscured. 11475 * 11476 * To receive this signal the #GdkWindow associated to the widget needs 11477 * to enable the #GDK_VISIBILITY_NOTIFY_MASK mask. 11478 * 11479 * Deprecated: Modern composited windowing systems with pervasive 11480 * transparency make it impossible to track the visibility of a window 11481 * reliably, so this signal can not be guaranteed to provide useful 11482 * information. 11483 * 11484 * Params: 11485 * event = the #GdkEventVisibility which 11486 * triggered this signal. 11487 * 11488 * Returns: %TRUE to stop other handlers from being invoked for the event. 11489 * %FALSE to propagate the event further. 11490 */ 11491 gulong addOnVisibilityNotify(bool delegate(GdkEventVisibility*, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 11492 { 11493 addEvents(EventMask.VISIBILITY_NOTIFY_MASK); 11494 auto wrapper = new OnVisibilityNotifyDelegateWrapper(dlg); 11495 wrapper.handlerId = Signals.connectData( 11496 this, 11497 "visibility-notify-event", 11498 cast(GCallback)&callBackVisibilityNotify, 11499 cast(void*)wrapper, 11500 cast(GClosureNotify)&callBackVisibilityNotifyDestroy, 11501 connectFlags); 11502 return wrapper.handlerId; 11503 } 11504 11505 extern(C) static int callBackVisibilityNotify(GtkWidget* widgetStruct, GdkEventVisibility* event, OnVisibilityNotifyDelegateWrapper wrapper) 11506 { 11507 return wrapper.dlg(event, wrapper.outer); 11508 } 11509 11510 extern(C) static void callBackVisibilityNotifyDestroy(OnVisibilityNotifyDelegateWrapper wrapper, GClosure* closure) 11511 { 11512 wrapper.remove(wrapper); 11513 } 11514 11515 protected class OnVisibilityNotifyEventGenericDelegateWrapper 11516 { 11517 bool delegate(Event, Widget) dlg; 11518 gulong handlerId; 11519 11520 this(bool delegate(Event, Widget) dlg) 11521 { 11522 this.dlg = dlg; 11523 onVisibilityNotifyEventGenericListeners ~= this; 11524 } 11525 11526 void remove(OnVisibilityNotifyEventGenericDelegateWrapper source) 11527 { 11528 foreach(index, wrapper; onVisibilityNotifyEventGenericListeners) 11529 { 11530 if (wrapper.handlerId == source.handlerId) 11531 { 11532 onVisibilityNotifyEventGenericListeners[index] = null; 11533 onVisibilityNotifyEventGenericListeners = std.algorithm.remove(onVisibilityNotifyEventGenericListeners, index); 11534 break; 11535 } 11536 } 11537 } 11538 } 11539 OnVisibilityNotifyEventGenericDelegateWrapper[] onVisibilityNotifyEventGenericListeners; 11540 11541 /** 11542 * The ::visibility-notify-event will be emitted when the @widget's 11543 * window is obscured or unobscured. 11544 * 11545 * To receive this signal the #GdkWindow associated to the widget needs 11546 * to enable the #GDK_VISIBILITY_NOTIFY_MASK mask. 11547 * 11548 * Deprecated: Modern composited windowing systems with pervasive 11549 * transparency make it impossible to track the visibility of a window 11550 * reliably, so this signal can not be guaranteed to provide useful 11551 * information. 11552 * 11553 * Params: 11554 * event = the #GdkEventVisibility which 11555 * triggered this signal. 11556 * 11557 * Returns: %TRUE to stop other handlers from being invoked for the event. 11558 * %FALSE to propagate the event further. 11559 */ 11560 gulong addOnVisibilityNotify(bool delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 11561 { 11562 addEvents(EventMask.VISIBILITY_NOTIFY_MASK); 11563 auto wrapper = new OnVisibilityNotifyEventGenericDelegateWrapper(dlg); 11564 wrapper.handlerId = Signals.connectData( 11565 this, 11566 "visibility-notify-event", 11567 cast(GCallback)&callBackVisibilityNotifyEventGeneric, 11568 cast(void*)wrapper, 11569 cast(GClosureNotify)&callBackVisibilityNotifyEventGenericDestroy, 11570 connectFlags); 11571 return wrapper.handlerId; 11572 } 11573 11574 extern(C) static int callBackVisibilityNotifyEventGeneric(GtkWidget* widgetStruct, GdkEvent* event, OnVisibilityNotifyEventGenericDelegateWrapper wrapper) 11575 { 11576 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 11577 } 11578 11579 extern(C) static void callBackVisibilityNotifyEventGenericDestroy(OnVisibilityNotifyEventGenericDelegateWrapper wrapper, GClosure* closure) 11580 { 11581 wrapper.remove(wrapper); 11582 } 11583 11584 protected class OnWindowStateDelegateWrapper 11585 { 11586 bool delegate(GdkEventWindowState*, Widget) dlg; 11587 gulong handlerId; 11588 11589 this(bool delegate(GdkEventWindowState*, Widget) dlg) 11590 { 11591 this.dlg = dlg; 11592 onWindowStateListeners ~= this; 11593 } 11594 11595 void remove(OnWindowStateDelegateWrapper source) 11596 { 11597 foreach(index, wrapper; onWindowStateListeners) 11598 { 11599 if (wrapper.handlerId == source.handlerId) 11600 { 11601 onWindowStateListeners[index] = null; 11602 onWindowStateListeners = std.algorithm.remove(onWindowStateListeners, index); 11603 break; 11604 } 11605 } 11606 } 11607 } 11608 OnWindowStateDelegateWrapper[] onWindowStateListeners; 11609 11610 /** 11611 * The ::window-state-event will be emitted when the state of the 11612 * toplevel window associated to the @widget changes. 11613 * 11614 * To receive this signal the #GdkWindow associated to the widget 11615 * needs to enable the #GDK_STRUCTURE_MASK mask. GDK will enable 11616 * this mask automatically for all new windows. 11617 * 11618 * Params: 11619 * event = the #GdkEventWindowState which 11620 * triggered this signal. 11621 * 11622 * Returns: %TRUE to stop other handlers from being invoked for the 11623 * event. %FALSE to propagate the event further. 11624 */ 11625 gulong addOnWindowState(bool delegate(GdkEventWindowState*, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 11626 { 11627 auto wrapper = new OnWindowStateDelegateWrapper(dlg); 11628 wrapper.handlerId = Signals.connectData( 11629 this, 11630 "window-state-event", 11631 cast(GCallback)&callBackWindowState, 11632 cast(void*)wrapper, 11633 cast(GClosureNotify)&callBackWindowStateDestroy, 11634 connectFlags); 11635 return wrapper.handlerId; 11636 } 11637 11638 extern(C) static int callBackWindowState(GtkWidget* widgetStruct, GdkEventWindowState* event, OnWindowStateDelegateWrapper wrapper) 11639 { 11640 return wrapper.dlg(event, wrapper.outer); 11641 } 11642 11643 extern(C) static void callBackWindowStateDestroy(OnWindowStateDelegateWrapper wrapper, GClosure* closure) 11644 { 11645 wrapper.remove(wrapper); 11646 } 11647 11648 protected class OnWindowStateEventGenericDelegateWrapper 11649 { 11650 bool delegate(Event, Widget) dlg; 11651 gulong handlerId; 11652 11653 this(bool delegate(Event, Widget) dlg) 11654 { 11655 this.dlg = dlg; 11656 onWindowStateEventGenericListeners ~= this; 11657 } 11658 11659 void remove(OnWindowStateEventGenericDelegateWrapper source) 11660 { 11661 foreach(index, wrapper; onWindowStateEventGenericListeners) 11662 { 11663 if (wrapper.handlerId == source.handlerId) 11664 { 11665 onWindowStateEventGenericListeners[index] = null; 11666 onWindowStateEventGenericListeners = std.algorithm.remove(onWindowStateEventGenericListeners, index); 11667 break; 11668 } 11669 } 11670 } 11671 } 11672 OnWindowStateEventGenericDelegateWrapper[] onWindowStateEventGenericListeners; 11673 11674 /** 11675 * The ::window-state-event will be emitted when the state of the 11676 * toplevel window associated to the @widget changes. 11677 * 11678 * To receive this signal the #GdkWindow associated to the widget 11679 * needs to enable the #GDK_STRUCTURE_MASK mask. GDK will enable 11680 * this mask automatically for all new windows. 11681 * 11682 * Params: 11683 * event = the #GdkEventWindowState which 11684 * triggered this signal. 11685 * 11686 * Returns: %TRUE to stop other handlers from being invoked for the 11687 * event. %FALSE to propagate the event further. 11688 */ 11689 gulong addOnWindowState(bool delegate(Event, Widget) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 11690 { 11691 auto wrapper = new OnWindowStateEventGenericDelegateWrapper(dlg); 11692 wrapper.handlerId = Signals.connectData( 11693 this, 11694 "window-state-event", 11695 cast(GCallback)&callBackWindowStateEventGeneric, 11696 cast(void*)wrapper, 11697 cast(GClosureNotify)&callBackWindowStateEventGenericDestroy, 11698 connectFlags); 11699 return wrapper.handlerId; 11700 } 11701 11702 extern(C) static int callBackWindowStateEventGeneric(GtkWidget* widgetStruct, GdkEvent* event, OnWindowStateEventGenericDelegateWrapper wrapper) 11703 { 11704 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 11705 } 11706 11707 extern(C) static void callBackWindowStateEventGenericDestroy(OnWindowStateEventGenericDelegateWrapper wrapper, GClosure* closure) 11708 { 11709 wrapper.remove(wrapper); 11710 } 11711 11712 /** 11713 * This function is supposed to be called in #GtkWidget::draw 11714 * implementations for widgets that support multiple windows. 11715 * @cr must be untransformed from invoking of the draw function. 11716 * This function will return %TRUE if the contents of the given 11717 * @window are supposed to be drawn and %FALSE otherwise. Note 11718 * that when the drawing was not initiated by the windowing 11719 * system this function will return %TRUE for all windows, so 11720 * you need to draw the bottommost window first. Also, do not 11721 * use “else if” statements to check which window should be drawn. 11722 * 11723 * Params: 11724 * cr = a cairo context 11725 * window = the window to check. @window may not be an input-only 11726 * window. 11727 * 11728 * Returns: %TRUE if @window should be drawn 11729 * 11730 * Since: 3.0 11731 */ 11732 public static bool cairoShouldDrawWindow(Context cr, GdkWin window) 11733 { 11734 return gtk_cairo_should_draw_window((cr is null) ? null : cr.getContextStruct(), (window is null) ? null : window.getWindowStruct()) != 0; 11735 } 11736 11737 /** 11738 * Transforms the given cairo context @cr that from @widget-relative 11739 * coordinates to @window-relative coordinates. 11740 * If the @widget’s window is not an ancestor of @window, no 11741 * modification will be applied. 11742 * 11743 * This is the inverse to the transformation GTK applies when 11744 * preparing an expose event to be emitted with the #GtkWidget::draw 11745 * signal. It is intended to help porting multiwindow widgets from 11746 * GTK+ 2 to the rendering architecture of GTK+ 3. 11747 * 11748 * Params: 11749 * cr = the cairo context to transform 11750 * widget = the widget the context is currently centered for 11751 * window = the window to transform the context to 11752 * 11753 * Since: 3.0 11754 */ 11755 public static void cairoTransformToWindow(Context cr, Widget widget, GdkWin window) 11756 { 11757 gtk_cairo_transform_to_window((cr is null) ? null : cr.getContextStruct(), (widget is null) ? null : widget.getWidgetStruct(), (window is null) ? null : window.getWindowStruct()); 11758 } 11759 11760 /** 11761 * Distributes @extra_space to child @sizes by bringing smaller 11762 * children up to natural size first. 11763 * 11764 * The remaining space will be added to the @minimum_size member of the 11765 * GtkRequestedSize struct. If all sizes reach their natural size then 11766 * the remaining space is returned. 11767 * 11768 * Params: 11769 * extraSpace = Extra space to redistribute among children after subtracting 11770 * minimum sizes and any child padding from the overall allocation 11771 * nRequestedSizes = Number of requests to fit into the allocation 11772 * sizes = An array of structs with a client pointer and a minimum/natural size 11773 * in the orientation of the allocation. 11774 * 11775 * Returns: The remainder of @extra_space after redistributing space 11776 * to @sizes. 11777 */ 11778 public static int distributeNaturalAllocation(int extraSpace, uint nRequestedSizes, GtkRequestedSize* sizes) 11779 { 11780 return gtk_distribute_natural_allocation(extraSpace, nRequestedSizes, sizes); 11781 } 11782 }