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