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