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.StatusIcon; 26 27 private import gdk.Event; 28 private import gdk.Screen; 29 private import gdkpixbuf.Pixbuf; 30 private import gio.Icon; 31 private import gio.IconIF; 32 private import glib.ConstructionException; 33 private import glib.Str; 34 private import gobject.ObjectG; 35 private import gobject.Signals; 36 private import gtk.Menu; 37 private import gtk.Tooltip; 38 public import gtkc.gdktypes; 39 private import gtkc.gtk; 40 public import gtkc.gtktypes; 41 private import std.algorithm; 42 43 44 /** 45 * The “system tray” or notification area is normally used for transient icons 46 * that indicate some special state. For example, a system tray icon might 47 * appear to tell the user that they have new mail, or have an incoming instant 48 * message, or something along those lines. The basic idea is that creating an 49 * icon in the notification area is less annoying than popping up a dialog. 50 * 51 * A #GtkStatusIcon object can be used to display an icon in a “system tray”. 52 * The icon can have a tooltip, and the user can interact with it by 53 * activating it or popping up a context menu. Critical information should 54 * not solely be displayed in a #GtkStatusIcon, since it may not be 55 * visible (e.g. when the user doesn’t have a notification area on his panel). 56 * This can be checked with gtk_status_icon_is_embedded(). 57 * 58 * On X11, the implementation follows the 59 * [FreeDesktop System Tray Specification](http://www.freedesktop.org/wiki/Specifications/systemtray-spec). 60 * Implementations of the “tray” side of this specification can 61 * be found e.g. in the GNOME 2 and KDE panel applications. 62 * 63 * Note that a GtkStatusIcon is not a widget, but just 64 * a #GObject. Making it a widget would be impractical, since the system tray 65 * on Win32 doesn’t allow to embed arbitrary widgets. 66 * 67 * GtkStatusIcon has been deprecated in 3.14. You should consider using 68 * notifications or more modern platform-specific APIs instead. GLib provides 69 * the #GNotification API which works well with #GtkApplication. Also see this 70 * [HowDoI](https://wiki.gnome.org/HowDoI/GNotification). 71 */ 72 public class StatusIcon : ObjectG 73 { 74 /** the main Gtk struct */ 75 protected GtkStatusIcon* gtkStatusIcon; 76 77 /** Get the main Gtk struct */ 78 public GtkStatusIcon* getStatusIconStruct() 79 { 80 return gtkStatusIcon; 81 } 82 83 /** the main Gtk struct as a void* */ 84 protected override void* getStruct() 85 { 86 return cast(void*)gtkStatusIcon; 87 } 88 89 protected override void setStruct(GObject* obj) 90 { 91 gtkStatusIcon = cast(GtkStatusIcon*)obj; 92 super.setStruct(obj); 93 } 94 95 /** 96 * Sets our main struct and passes it to the parent class. 97 */ 98 public this (GtkStatusIcon* gtkStatusIcon, bool ownedRef = false) 99 { 100 this.gtkStatusIcon = gtkStatusIcon; 101 super(cast(GObject*)gtkStatusIcon, ownedRef); 102 } 103 104 /** 105 * Creates a status icon displaying a stock icon. Sample stock icon 106 * names are StockID.OPEN, StockID.QUIT. You can register your 107 * own stock icon names, see gtk_icon_factory_add_default() and 108 * gtk_icon_factory_add(). 109 * Since 2.10 110 * Params: 111 * stock_id = a stock icon id 112 * Returns: 113 * a new GtkStatusIcon 114 * Throws: ConstructionException GTK+ fails to create the object. 115 */ 116 public this (StockID stockID) 117 { 118 auto p = gtk_status_icon_new_from_stock(Str.toStringz(stockID)); 119 if(p is null) 120 { 121 throw new ConstructionException("null returned by gtk_status_icon_new_from_stock"); 122 } 123 this(cast(GtkStatusIcon*)p); 124 } 125 126 /** 127 * Creates a status icon displaying an icon from the current icon theme. 128 * If the current icon theme is changed, the icon will be updated 129 * appropriately. 130 * Since 2.10 131 * Params: 132 * iconName = an icon name 133 * loadFromFile = treat iconName as a filename and load that image 134 * with gtk_status_icon_new_from_file. 135 * Throws: ConstructionException GTK+ fails to create the object. 136 */ 137 public this (string iconName, bool loadFromFile = false) 138 { 139 //TODO: look at a better way to do this. 140 GtkStatusIcon* p; 141 142 if(loadFromFile) 143 { 144 p = cast(GtkStatusIcon*)gtk_status_icon_new_from_file(Str.toStringz(iconName)); 145 } 146 else 147 { 148 p = cast(GtkStatusIcon*)gtk_status_icon_new_from_icon_name(Str.toStringz(iconName)); 149 } 150 151 if(p is null) 152 { 153 throw new ConstructionException("null returned by gtk_status_icon_new_from_"); 154 } 155 156 this(p); 157 } 158 159 /** 160 */ 161 162 /** */ 163 public static GType getType() 164 { 165 return gtk_status_icon_get_type(); 166 } 167 168 /** 169 * Creates an empty status icon object. 170 * 171 * Deprecated: Use notifications 172 * 173 * Return: a new #GtkStatusIcon 174 * 175 * Since: 2.10 176 * 177 * Throws: ConstructionException GTK+ fails to create the object. 178 */ 179 public this() 180 { 181 auto p = gtk_status_icon_new(); 182 183 if(p is null) 184 { 185 throw new ConstructionException("null returned by new"); 186 } 187 188 this(cast(GtkStatusIcon*) p, true); 189 } 190 191 /** 192 * Creates a status icon displaying a #GIcon. If the icon is a 193 * themed icon, it will be updated when the theme changes. 194 * 195 * Deprecated: Use notifications 196 * 197 * Params: 198 * icon = a #GIcon 199 * 200 * Return: a new #GtkStatusIcon 201 * 202 * Since: 2.14 203 * 204 * Throws: ConstructionException GTK+ fails to create the object. 205 */ 206 public this(IconIF icon) 207 { 208 auto p = gtk_status_icon_new_from_gicon((icon is null) ? null : icon.getIconStruct()); 209 210 if(p is null) 211 { 212 throw new ConstructionException("null returned by new_from_gicon"); 213 } 214 215 this(cast(GtkStatusIcon*) p, true); 216 } 217 218 /** 219 * Creates a status icon displaying @pixbuf. 220 * 221 * The image will be scaled down to fit in the available 222 * space in the notification area, if necessary. 223 * 224 * Deprecated: Use notifications 225 * 226 * Params: 227 * pixbuf = a #GdkPixbuf 228 * 229 * Return: a new #GtkStatusIcon 230 * 231 * Since: 2.10 232 * 233 * Throws: ConstructionException GTK+ fails to create the object. 234 */ 235 public this(Pixbuf pixbuf) 236 { 237 auto p = gtk_status_icon_new_from_pixbuf((pixbuf is null) ? null : pixbuf.getPixbufStruct()); 238 239 if(p is null) 240 { 241 throw new ConstructionException("null returned by new_from_pixbuf"); 242 } 243 244 this(cast(GtkStatusIcon*) p, true); 245 } 246 247 /** 248 * Menu positioning function to use with gtk_menu_popup() 249 * to position @menu aligned to the status icon @user_data. 250 * 251 * Deprecated: Use notifications 252 * 253 * Params: 254 * menu = the #GtkMenu 255 * x = return location for the x position 256 * y = return location for the y position 257 * pushIn = whether the first menu item should be offset 258 * (pushed in) to be aligned with the menu popup position 259 * (only useful for GtkOptionMenu). 260 * userData = the status icon to position the menu on 261 * 262 * Since: 2.10 263 */ 264 public static void positionMenu(Menu menu, ref int x, ref int y, out bool pushIn, StatusIcon userData) 265 { 266 int outpushIn; 267 268 gtk_status_icon_position_menu((menu is null) ? null : menu.getMenuStruct(), &x, &y, &outpushIn, (userData is null) ? null : userData.getStatusIconStruct()); 269 270 pushIn = (outpushIn == 1); 271 } 272 273 /** 274 * Obtains information about the location of the status icon 275 * on screen. This information can be used to e.g. position 276 * popups like notification bubbles. 277 * 278 * See gtk_status_icon_position_menu() for a more convenient 279 * alternative for positioning menus. 280 * 281 * Note that some platforms do not allow GTK+ to provide 282 * this information, and even on platforms that do allow it, 283 * the information is not reliable unless the status icon 284 * is embedded in a notification area, see 285 * gtk_status_icon_is_embedded(). 286 * 287 * Deprecated: Use notifications 288 * 289 * Params: 290 * screen = return location for 291 * the screen, or %NULL if the information is not needed 292 * area = return location for the area occupied by 293 * the status icon, or %NULL 294 * orientation = return location for the 295 * orientation of the panel in which the status icon is embedded, 296 * or %NULL. A panel at the top or bottom of the screen is 297 * horizontal, a panel at the left or right is vertical. 298 * 299 * Return: %TRUE if the location information has 300 * been filled in 301 * 302 * Since: 2.10 303 */ 304 public bool getGeometry(out Screen screen, out GdkRectangle area, out GtkOrientation orientation) 305 { 306 GdkScreen* outscreen = null; 307 308 auto p = gtk_status_icon_get_geometry(gtkStatusIcon, &outscreen, &area, &orientation) != 0; 309 310 screen = ObjectG.getDObject!(Screen)(outscreen); 311 312 return p; 313 } 314 315 /** 316 * Retrieves the #GIcon being displayed by the #GtkStatusIcon. 317 * The storage type of the status icon must be %GTK_IMAGE_EMPTY or 318 * %GTK_IMAGE_GICON (see gtk_status_icon_get_storage_type()). 319 * The caller of this function does not own a reference to the 320 * returned #GIcon. 321 * 322 * If this function fails, @icon is left unchanged; 323 * 324 * Deprecated: Use notifications 325 * 326 * Return: the displayed icon, or %NULL if the image is empty 327 * 328 * Since: 2.14 329 */ 330 public IconIF getGicon() 331 { 332 auto p = gtk_status_icon_get_gicon(gtkStatusIcon); 333 334 if(p is null) 335 { 336 return null; 337 } 338 339 return ObjectG.getDObject!(Icon, IconIF)(cast(GIcon*) p); 340 } 341 342 /** 343 * Returns the current value of the has-tooltip property. 344 * See #GtkStatusIcon:has-tooltip for more information. 345 * 346 * Deprecated: Use notifications 347 * 348 * Return: current value of has-tooltip on @status_icon. 349 * 350 * Since: 2.16 351 */ 352 public bool getHasTooltip() 353 { 354 return gtk_status_icon_get_has_tooltip(gtkStatusIcon) != 0; 355 } 356 357 /** 358 * Gets the name of the icon being displayed by the #GtkStatusIcon. 359 * The storage type of the status icon must be %GTK_IMAGE_EMPTY or 360 * %GTK_IMAGE_ICON_NAME (see gtk_status_icon_get_storage_type()). 361 * The returned string is owned by the #GtkStatusIcon and should not 362 * be freed or modified. 363 * 364 * Deprecated: Use notifications 365 * 366 * Return: name of the displayed icon, or %NULL if the image is empty. 367 * 368 * Since: 2.10 369 */ 370 public string getIconName() 371 { 372 return Str.toString(gtk_status_icon_get_icon_name(gtkStatusIcon)); 373 } 374 375 /** 376 * Gets the #GdkPixbuf being displayed by the #GtkStatusIcon. 377 * The storage type of the status icon must be %GTK_IMAGE_EMPTY or 378 * %GTK_IMAGE_PIXBUF (see gtk_status_icon_get_storage_type()). 379 * The caller of this function does not own a reference to the 380 * returned pixbuf. 381 * 382 * Deprecated: Use notifications 383 * 384 * Return: the displayed pixbuf, 385 * or %NULL if the image is empty. 386 * 387 * Since: 2.10 388 */ 389 public Pixbuf getPixbuf() 390 { 391 auto p = gtk_status_icon_get_pixbuf(gtkStatusIcon); 392 393 if(p is null) 394 { 395 return null; 396 } 397 398 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 399 } 400 401 /** 402 * Returns the #GdkScreen associated with @status_icon. 403 * 404 * Deprecated: Use notifications 405 * 406 * Return: a #GdkScreen. 407 * 408 * Since: 2.12 409 */ 410 public Screen getScreen() 411 { 412 auto p = gtk_status_icon_get_screen(gtkStatusIcon); 413 414 if(p is null) 415 { 416 return null; 417 } 418 419 return ObjectG.getDObject!(Screen)(cast(GdkScreen*) p); 420 } 421 422 /** 423 * Gets the size in pixels that is available for the image. 424 * Stock icons and named icons adapt their size automatically 425 * if the size of the notification area changes. For other 426 * storage types, the size-changed signal can be used to 427 * react to size changes. 428 * 429 * Note that the returned size is only meaningful while the 430 * status icon is embedded (see gtk_status_icon_is_embedded()). 431 * 432 * Deprecated: Use notifications 433 * 434 * Return: the size that is available for the image 435 * 436 * Since: 2.10 437 */ 438 public int getSize() 439 { 440 return gtk_status_icon_get_size(gtkStatusIcon); 441 } 442 443 /** 444 * Gets the id of the stock icon being displayed by the #GtkStatusIcon. 445 * The storage type of the status icon must be %GTK_IMAGE_EMPTY or 446 * %GTK_IMAGE_STOCK (see gtk_status_icon_get_storage_type()). 447 * The returned string is owned by the #GtkStatusIcon and should not 448 * be freed or modified. 449 * 450 * Deprecated: Use gtk_status_icon_get_icon_name() instead. 451 * 452 * Return: stock id of the displayed stock icon, 453 * or %NULL if the image is empty. 454 * 455 * Since: 2.10 456 */ 457 public string getStock() 458 { 459 return Str.toString(gtk_status_icon_get_stock(gtkStatusIcon)); 460 } 461 462 /** 463 * Gets the type of representation being used by the #GtkStatusIcon 464 * to store image data. If the #GtkStatusIcon has no image data, 465 * the return value will be %GTK_IMAGE_EMPTY. 466 * 467 * Deprecated: Use notifications 468 * 469 * Return: the image representation being used 470 * 471 * Since: 2.10 472 */ 473 public GtkImageType getStorageType() 474 { 475 return gtk_status_icon_get_storage_type(gtkStatusIcon); 476 } 477 478 /** 479 * Gets the title of this tray icon. See gtk_status_icon_set_title(). 480 * 481 * Deprecated: Use notifications 482 * 483 * Return: the title of the status icon 484 * 485 * Since: 2.18 486 */ 487 public string getTitle() 488 { 489 return Str.toString(gtk_status_icon_get_title(gtkStatusIcon)); 490 } 491 492 /** 493 * Gets the contents of the tooltip for @status_icon. 494 * 495 * Deprecated: Use notifications 496 * 497 * Return: the tooltip text, or %NULL. You should free the 498 * returned string with g_free() when done. 499 * 500 * Since: 2.16 501 */ 502 public string getTooltipMarkup() 503 { 504 auto retStr = gtk_status_icon_get_tooltip_markup(gtkStatusIcon); 505 506 scope(exit) Str.freeString(retStr); 507 return Str.toString(retStr); 508 } 509 510 /** 511 * Gets the contents of the tooltip for @status_icon. 512 * 513 * Deprecated: Use notifications 514 * 515 * Return: the tooltip text, or %NULL. You should free the 516 * returned string with g_free() when done. 517 * 518 * Since: 2.16 519 */ 520 public string getTooltipText() 521 { 522 auto retStr = gtk_status_icon_get_tooltip_text(gtkStatusIcon); 523 524 scope(exit) Str.freeString(retStr); 525 return Str.toString(retStr); 526 } 527 528 /** 529 * Returns whether the status icon is visible or not. 530 * Note that being visible does not guarantee that 531 * the user can actually see the icon, see also 532 * gtk_status_icon_is_embedded(). 533 * 534 * Deprecated: Use notifications 535 * 536 * Return: %TRUE if the status icon is visible 537 * 538 * Since: 2.10 539 */ 540 public bool getVisible() 541 { 542 return gtk_status_icon_get_visible(gtkStatusIcon) != 0; 543 } 544 545 /** 546 * This function is only useful on the X11/freedesktop.org platform. 547 * It returns a window ID for the widget in the underlying 548 * status icon implementation. This is useful for the Galago 549 * notification service, which can send a window ID in the protocol 550 * in order for the server to position notification windows 551 * pointing to a status icon reliably. 552 * 553 * This function is not intended for other use cases which are 554 * more likely to be met by one of the non-X11 specific methods, such 555 * as gtk_status_icon_position_menu(). 556 * 557 * Deprecated: Use notifications 558 * 559 * Return: An 32 bit unsigned integer identifier for the 560 * underlying X11 Window 561 * 562 * Since: 2.14 563 */ 564 public uint getX11WindowId() 565 { 566 return gtk_status_icon_get_x11_window_id(gtkStatusIcon); 567 } 568 569 /** 570 * Returns whether the status icon is embedded in a notification 571 * area. 572 * 573 * Deprecated: Use notifications 574 * 575 * Return: %TRUE if the status icon is embedded in 576 * a notification area. 577 * 578 * Since: 2.10 579 */ 580 public bool isEmbedded() 581 { 582 return gtk_status_icon_is_embedded(gtkStatusIcon) != 0; 583 } 584 585 /** 586 * Makes @status_icon display the file @filename. 587 * See gtk_status_icon_new_from_file() for details. 588 * 589 * Deprecated: Use notifications 590 * 591 * Params: 592 * filename = a filename 593 * 594 * Since: 2.10 595 */ 596 public void setFromFile(string filename) 597 { 598 gtk_status_icon_set_from_file(gtkStatusIcon, Str.toStringz(filename)); 599 } 600 601 /** 602 * Makes @status_icon display the #GIcon. 603 * See gtk_status_icon_new_from_gicon() for details. 604 * 605 * Deprecated: Use notifications 606 * 607 * Params: 608 * icon = a GIcon 609 * 610 * Since: 2.14 611 */ 612 public void setFromGicon(IconIF icon) 613 { 614 gtk_status_icon_set_from_gicon(gtkStatusIcon, (icon is null) ? null : icon.getIconStruct()); 615 } 616 617 /** 618 * Makes @status_icon display the icon named @icon_name from the 619 * current icon theme. 620 * See gtk_status_icon_new_from_icon_name() for details. 621 * 622 * Deprecated: Use notifications 623 * 624 * Params: 625 * iconName = an icon name 626 * 627 * Since: 2.10 628 */ 629 public void setFromIconName(string iconName) 630 { 631 gtk_status_icon_set_from_icon_name(gtkStatusIcon, Str.toStringz(iconName)); 632 } 633 634 /** 635 * Makes @status_icon display @pixbuf. 636 * See gtk_status_icon_new_from_pixbuf() for details. 637 * 638 * Deprecated: Use notifications 639 * 640 * Params: 641 * pixbuf = a #GdkPixbuf or %NULL 642 * 643 * Since: 2.10 644 */ 645 public void setFromPixbuf(Pixbuf pixbuf) 646 { 647 gtk_status_icon_set_from_pixbuf(gtkStatusIcon, (pixbuf is null) ? null : pixbuf.getPixbufStruct()); 648 } 649 650 /** 651 * Makes @status_icon display the stock icon with the id @stock_id. 652 * See gtk_status_icon_new_from_stock() for details. 653 * 654 * Deprecated: Use gtk_status_icon_set_from_icon_name() instead. 655 * 656 * Params: 657 * stockId = a stock icon id 658 * 659 * Since: 2.10 660 */ 661 public void setFromStock(string stockId) 662 { 663 gtk_status_icon_set_from_stock(gtkStatusIcon, Str.toStringz(stockId)); 664 } 665 666 /** 667 * Sets the has-tooltip property on @status_icon to @has_tooltip. 668 * See #GtkStatusIcon:has-tooltip for more information. 669 * 670 * Deprecated: Use notifications 671 * 672 * Params: 673 * hasTooltip = whether or not @status_icon has a tooltip 674 * 675 * Since: 2.16 676 */ 677 public void setHasTooltip(bool hasTooltip) 678 { 679 gtk_status_icon_set_has_tooltip(gtkStatusIcon, hasTooltip); 680 } 681 682 /** 683 * Sets the name of this tray icon. 684 * This should be a string identifying this icon. It is may be 685 * used for sorting the icons in the tray and will not be shown to 686 * the user. 687 * 688 * Deprecated: Use notifications 689 * 690 * Params: 691 * name = the name 692 * 693 * Since: 2.20 694 */ 695 public void setName(string name) 696 { 697 gtk_status_icon_set_name(gtkStatusIcon, Str.toStringz(name)); 698 } 699 700 /** 701 * Sets the #GdkScreen where @status_icon is displayed; if 702 * the icon is already mapped, it will be unmapped, and 703 * then remapped on the new screen. 704 * 705 * Deprecated: Use notifications 706 * 707 * Params: 708 * screen = a #GdkScreen 709 * 710 * Since: 2.12 711 */ 712 public void setScreen(Screen screen) 713 { 714 gtk_status_icon_set_screen(gtkStatusIcon, (screen is null) ? null : screen.getScreenStruct()); 715 } 716 717 /** 718 * Sets the title of this tray icon. 719 * This should be a short, human-readable, localized string 720 * describing the tray icon. It may be used by tools like screen 721 * readers to render the tray icon. 722 * 723 * Deprecated: Use notifications 724 * 725 * Params: 726 * title = the title 727 * 728 * Since: 2.18 729 */ 730 public void setTitle(string title) 731 { 732 gtk_status_icon_set_title(gtkStatusIcon, Str.toStringz(title)); 733 } 734 735 /** 736 * Sets @markup as the contents of the tooltip, which is marked up with 737 * the [Pango text markup language][PangoMarkupFormat]. 738 * 739 * This function will take care of setting #GtkStatusIcon:has-tooltip to %TRUE 740 * and of the default handler for the #GtkStatusIcon::query-tooltip signal. 741 * 742 * See also the #GtkStatusIcon:tooltip-markup property and 743 * gtk_tooltip_set_markup(). 744 * 745 * Deprecated: Use notifications 746 * 747 * Params: 748 * markup = the contents of the tooltip for @status_icon, or %NULL 749 * 750 * Since: 2.16 751 */ 752 public void setTooltipMarkup(string markup) 753 { 754 gtk_status_icon_set_tooltip_markup(gtkStatusIcon, Str.toStringz(markup)); 755 } 756 757 /** 758 * Sets @text as the contents of the tooltip. 759 * 760 * This function will take care of setting #GtkStatusIcon:has-tooltip to 761 * %TRUE and of the default handler for the #GtkStatusIcon::query-tooltip 762 * signal. 763 * 764 * See also the #GtkStatusIcon:tooltip-text property and 765 * gtk_tooltip_set_text(). 766 * 767 * Deprecated: Use notifications 768 * 769 * Params: 770 * text = the contents of the tooltip for @status_icon 771 * 772 * Since: 2.16 773 */ 774 public void setTooltipText(string text) 775 { 776 gtk_status_icon_set_tooltip_text(gtkStatusIcon, Str.toStringz(text)); 777 } 778 779 /** 780 * Shows or hides a status icon. 781 * 782 * Deprecated: Use notifications 783 * 784 * Params: 785 * visible = %TRUE to show the status icon, %FALSE to hide it 786 * 787 * Since: 2.10 788 */ 789 public void setVisible(bool visible) 790 { 791 gtk_status_icon_set_visible(gtkStatusIcon, visible); 792 } 793 794 protected class OnActivateDelegateWrapper 795 { 796 void delegate(StatusIcon) dlg; 797 gulong handlerId; 798 ConnectFlags flags; 799 this(void delegate(StatusIcon) dlg, gulong handlerId, ConnectFlags flags) 800 { 801 this.dlg = dlg; 802 this.handlerId = handlerId; 803 this.flags = flags; 804 } 805 } 806 protected OnActivateDelegateWrapper[] onActivateListeners; 807 808 /** 809 * Gets emitted when the user activates the status icon. 810 * If and how status icons can activated is platform-dependent. 811 * 812 * Unlike most G_SIGNAL_ACTION signals, this signal is meant to 813 * be used by applications and should be wrapped by language bindings. 814 * 815 * Since: 2.10 816 */ 817 gulong addOnActivate(void delegate(StatusIcon) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 818 { 819 onActivateListeners ~= new OnActivateDelegateWrapper(dlg, 0, connectFlags); 820 onActivateListeners[onActivateListeners.length - 1].handlerId = Signals.connectData( 821 this, 822 "activate", 823 cast(GCallback)&callBackActivate, 824 cast(void*)onActivateListeners[onActivateListeners.length - 1], 825 cast(GClosureNotify)&callBackActivateDestroy, 826 connectFlags); 827 return onActivateListeners[onActivateListeners.length - 1].handlerId; 828 } 829 830 extern(C) static void callBackActivate(GtkStatusIcon* statusiconStruct,OnActivateDelegateWrapper wrapper) 831 { 832 wrapper.dlg(wrapper.outer); 833 } 834 835 extern(C) static void callBackActivateDestroy(OnActivateDelegateWrapper wrapper, GClosure* closure) 836 { 837 wrapper.outer.internalRemoveOnActivate(wrapper); 838 } 839 840 protected void internalRemoveOnActivate(OnActivateDelegateWrapper source) 841 { 842 foreach(index, wrapper; onActivateListeners) 843 { 844 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 845 { 846 onActivateListeners[index] = null; 847 onActivateListeners = std.algorithm.remove(onActivateListeners, index); 848 break; 849 } 850 } 851 } 852 853 854 protected class OnButtonPressDelegateWrapper 855 { 856 bool delegate(GdkEventButton*, StatusIcon) dlg; 857 gulong handlerId; 858 ConnectFlags flags; 859 this(bool delegate(GdkEventButton*, StatusIcon) dlg, gulong handlerId, ConnectFlags flags) 860 { 861 this.dlg = dlg; 862 this.handlerId = handlerId; 863 this.flags = flags; 864 } 865 } 866 protected OnButtonPressDelegateWrapper[] onButtonPressListeners; 867 868 /** 869 * The ::button-press-event signal will be emitted when a button 870 * (typically from a mouse) is pressed. 871 * 872 * Whether this event is emitted is platform-dependent. Use the ::activate 873 * and ::popup-menu signals in preference. 874 * 875 * Params: 876 * event = the #GdkEventButton which triggered 877 * this signal 878 * 879 * Return: %TRUE to stop other handlers from being invoked 880 * for the event. %FALSE to propagate the event further. 881 * 882 * Since: 2.14 883 */ 884 gulong addOnButtonPress(bool delegate(GdkEventButton*, StatusIcon) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 885 { 886 onButtonPressListeners ~= new OnButtonPressDelegateWrapper(dlg, 0, connectFlags); 887 onButtonPressListeners[onButtonPressListeners.length - 1].handlerId = Signals.connectData( 888 this, 889 "button-press-event", 890 cast(GCallback)&callBackButtonPress, 891 cast(void*)onButtonPressListeners[onButtonPressListeners.length - 1], 892 cast(GClosureNotify)&callBackButtonPressDestroy, 893 connectFlags); 894 return onButtonPressListeners[onButtonPressListeners.length - 1].handlerId; 895 } 896 897 extern(C) static int callBackButtonPress(GtkStatusIcon* statusiconStruct, GdkEventButton* event,OnButtonPressDelegateWrapper wrapper) 898 { 899 return wrapper.dlg(event, wrapper.outer); 900 } 901 902 extern(C) static void callBackButtonPressDestroy(OnButtonPressDelegateWrapper wrapper, GClosure* closure) 903 { 904 wrapper.outer.internalRemoveOnButtonPress(wrapper); 905 } 906 907 protected void internalRemoveOnButtonPress(OnButtonPressDelegateWrapper source) 908 { 909 foreach(index, wrapper; onButtonPressListeners) 910 { 911 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 912 { 913 onButtonPressListeners[index] = null; 914 onButtonPressListeners = std.algorithm.remove(onButtonPressListeners, index); 915 break; 916 } 917 } 918 } 919 920 921 protected class OnButtonPressEventGenericDelegateWrapper 922 { 923 bool delegate(Event, StatusIcon) dlg; 924 gulong handlerId; 925 ConnectFlags flags; 926 this(bool delegate(Event, StatusIcon) dlg, gulong handlerId, ConnectFlags flags) 927 { 928 this.dlg = dlg; 929 this.handlerId = handlerId; 930 this.flags = flags; 931 } 932 } 933 protected OnButtonPressEventGenericDelegateWrapper[] onButtonPressEventGenericListeners; 934 935 /** 936 * The ::button-press-event signal will be emitted when a button 937 * (typically from a mouse) is pressed. 938 * 939 * Whether this event is emitted is platform-dependent. Use the ::activate 940 * and ::popup-menu signals in preference. 941 * 942 * Params: 943 * event = the #GdkEventButton which triggered 944 * this signal 945 * 946 * Return: %TRUE to stop other handlers from being invoked 947 * for the event. %FALSE to propagate the event further. 948 * 949 * Since: 2.14 950 */ 951 gulong addOnButtonPress(bool delegate(Event, StatusIcon) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 952 { 953 onButtonPressEventGenericListeners ~= new OnButtonPressEventGenericDelegateWrapper(dlg, 0, connectFlags); 954 onButtonPressEventGenericListeners[onButtonPressEventGenericListeners.length - 1].handlerId = Signals.connectData( 955 this, 956 "button-press-event", 957 cast(GCallback)&callBackButtonPressEventGeneric, 958 cast(void*)onButtonPressEventGenericListeners[onButtonPressEventGenericListeners.length - 1], 959 cast(GClosureNotify)&callBackButtonPressEventGenericDestroy, 960 connectFlags); 961 return onButtonPressEventGenericListeners[onButtonPressEventGenericListeners.length - 1].handlerId; 962 } 963 964 extern(C) static int callBackButtonPressEventGeneric(GtkStatusIcon* statusiconStruct, GdkEvent* event,OnButtonPressEventGenericDelegateWrapper wrapper) 965 { 966 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 967 } 968 969 extern(C) static void callBackButtonPressEventGenericDestroy(OnButtonPressEventGenericDelegateWrapper wrapper, GClosure* closure) 970 { 971 wrapper.outer.internalRemoveOnButtonPressEventGeneric(wrapper); 972 } 973 protected void internalRemoveOnButtonPressEventGeneric(OnButtonPressEventGenericDelegateWrapper source) 974 { 975 foreach(index, wrapper; onButtonPressEventGenericListeners) 976 { 977 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 978 { 979 onButtonPressEventGenericListeners[index] = null; 980 onButtonPressEventGenericListeners = std.algorithm.remove(onButtonPressEventGenericListeners, index); 981 break; 982 } 983 } 984 } 985 986 987 protected class OnButtonReleaseDelegateWrapper 988 { 989 bool delegate(GdkEventButton*, StatusIcon) dlg; 990 gulong handlerId; 991 ConnectFlags flags; 992 this(bool delegate(GdkEventButton*, StatusIcon) dlg, gulong handlerId, ConnectFlags flags) 993 { 994 this.dlg = dlg; 995 this.handlerId = handlerId; 996 this.flags = flags; 997 } 998 } 999 protected OnButtonReleaseDelegateWrapper[] onButtonReleaseListeners; 1000 1001 /** 1002 * The ::button-release-event signal will be emitted when a button 1003 * (typically from a mouse) is released. 1004 * 1005 * Whether this event is emitted is platform-dependent. Use the ::activate 1006 * and ::popup-menu signals in preference. 1007 * 1008 * Params: 1009 * event = the #GdkEventButton which triggered 1010 * this signal 1011 * 1012 * Return: %TRUE to stop other handlers from being invoked 1013 * for the event. %FALSE to propagate the event further. 1014 * 1015 * Since: 2.14 1016 */ 1017 gulong addOnButtonRelease(bool delegate(GdkEventButton*, StatusIcon) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1018 { 1019 onButtonReleaseListeners ~= new OnButtonReleaseDelegateWrapper(dlg, 0, connectFlags); 1020 onButtonReleaseListeners[onButtonReleaseListeners.length - 1].handlerId = Signals.connectData( 1021 this, 1022 "button-release-event", 1023 cast(GCallback)&callBackButtonRelease, 1024 cast(void*)onButtonReleaseListeners[onButtonReleaseListeners.length - 1], 1025 cast(GClosureNotify)&callBackButtonReleaseDestroy, 1026 connectFlags); 1027 return onButtonReleaseListeners[onButtonReleaseListeners.length - 1].handlerId; 1028 } 1029 1030 extern(C) static int callBackButtonRelease(GtkStatusIcon* statusiconStruct, GdkEventButton* event,OnButtonReleaseDelegateWrapper wrapper) 1031 { 1032 return wrapper.dlg(event, wrapper.outer); 1033 } 1034 1035 extern(C) static void callBackButtonReleaseDestroy(OnButtonReleaseDelegateWrapper wrapper, GClosure* closure) 1036 { 1037 wrapper.outer.internalRemoveOnButtonRelease(wrapper); 1038 } 1039 1040 protected void internalRemoveOnButtonRelease(OnButtonReleaseDelegateWrapper source) 1041 { 1042 foreach(index, wrapper; onButtonReleaseListeners) 1043 { 1044 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 1045 { 1046 onButtonReleaseListeners[index] = null; 1047 onButtonReleaseListeners = std.algorithm.remove(onButtonReleaseListeners, index); 1048 break; 1049 } 1050 } 1051 } 1052 1053 1054 protected class OnButtonReleaseEventGenericDelegateWrapper 1055 { 1056 bool delegate(Event, StatusIcon) dlg; 1057 gulong handlerId; 1058 ConnectFlags flags; 1059 this(bool delegate(Event, StatusIcon) dlg, gulong handlerId, ConnectFlags flags) 1060 { 1061 this.dlg = dlg; 1062 this.handlerId = handlerId; 1063 this.flags = flags; 1064 } 1065 } 1066 protected OnButtonReleaseEventGenericDelegateWrapper[] onButtonReleaseEventGenericListeners; 1067 1068 /** 1069 * The ::button-release-event signal will be emitted when a button 1070 * (typically from a mouse) is released. 1071 * 1072 * Whether this event is emitted is platform-dependent. Use the ::activate 1073 * and ::popup-menu signals in preference. 1074 * 1075 * Params: 1076 * event = the #GdkEventButton which triggered 1077 * this signal 1078 * 1079 * Return: %TRUE to stop other handlers from being invoked 1080 * for the event. %FALSE to propagate the event further. 1081 * 1082 * Since: 2.14 1083 */ 1084 gulong addOnButtonRelease(bool delegate(Event, StatusIcon) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1085 { 1086 onButtonReleaseEventGenericListeners ~= new OnButtonReleaseEventGenericDelegateWrapper(dlg, 0, connectFlags); 1087 onButtonReleaseEventGenericListeners[onButtonReleaseEventGenericListeners.length - 1].handlerId = Signals.connectData( 1088 this, 1089 "button-release-event", 1090 cast(GCallback)&callBackButtonReleaseEventGeneric, 1091 cast(void*)onButtonReleaseEventGenericListeners[onButtonReleaseEventGenericListeners.length - 1], 1092 cast(GClosureNotify)&callBackButtonReleaseEventGenericDestroy, 1093 connectFlags); 1094 return onButtonReleaseEventGenericListeners[onButtonReleaseEventGenericListeners.length - 1].handlerId; 1095 } 1096 1097 extern(C) static int callBackButtonReleaseEventGeneric(GtkStatusIcon* statusiconStruct, GdkEvent* event,OnButtonReleaseEventGenericDelegateWrapper wrapper) 1098 { 1099 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 1100 } 1101 1102 extern(C) static void callBackButtonReleaseEventGenericDestroy(OnButtonReleaseEventGenericDelegateWrapper wrapper, GClosure* closure) 1103 { 1104 wrapper.outer.internalRemoveOnButtonReleaseEventGeneric(wrapper); 1105 } 1106 protected void internalRemoveOnButtonReleaseEventGeneric(OnButtonReleaseEventGenericDelegateWrapper source) 1107 { 1108 foreach(index, wrapper; onButtonReleaseEventGenericListeners) 1109 { 1110 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 1111 { 1112 onButtonReleaseEventGenericListeners[index] = null; 1113 onButtonReleaseEventGenericListeners = std.algorithm.remove(onButtonReleaseEventGenericListeners, index); 1114 break; 1115 } 1116 } 1117 } 1118 1119 1120 protected class OnPopupMenuDelegateWrapper 1121 { 1122 void delegate(uint, uint, StatusIcon) dlg; 1123 gulong handlerId; 1124 ConnectFlags flags; 1125 this(void delegate(uint, uint, StatusIcon) dlg, gulong handlerId, ConnectFlags flags) 1126 { 1127 this.dlg = dlg; 1128 this.handlerId = handlerId; 1129 this.flags = flags; 1130 } 1131 } 1132 protected OnPopupMenuDelegateWrapper[] onPopupMenuListeners; 1133 1134 /** 1135 * Gets emitted when the user brings up the context menu 1136 * of the status icon. Whether status icons can have context 1137 * menus and how these are activated is platform-dependent. 1138 * 1139 * The @button and @activate_time parameters should be 1140 * passed as the last to arguments to gtk_menu_popup(). 1141 * 1142 * Unlike most G_SIGNAL_ACTION signals, this signal is meant to 1143 * be used by applications and should be wrapped by language bindings. 1144 * 1145 * Params: 1146 * button = the button that was pressed, or 0 if the 1147 * signal is not emitted in response to a button press event 1148 * activateTime = the timestamp of the event that 1149 * triggered the signal emission 1150 * 1151 * Since: 2.10 1152 */ 1153 gulong addOnPopupMenu(void delegate(uint, uint, StatusIcon) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1154 { 1155 onPopupMenuListeners ~= new OnPopupMenuDelegateWrapper(dlg, 0, connectFlags); 1156 onPopupMenuListeners[onPopupMenuListeners.length - 1].handlerId = Signals.connectData( 1157 this, 1158 "popup-menu", 1159 cast(GCallback)&callBackPopupMenu, 1160 cast(void*)onPopupMenuListeners[onPopupMenuListeners.length - 1], 1161 cast(GClosureNotify)&callBackPopupMenuDestroy, 1162 connectFlags); 1163 return onPopupMenuListeners[onPopupMenuListeners.length - 1].handlerId; 1164 } 1165 1166 extern(C) static void callBackPopupMenu(GtkStatusIcon* statusiconStruct, uint button, uint activateTime,OnPopupMenuDelegateWrapper wrapper) 1167 { 1168 wrapper.dlg(button, activateTime, wrapper.outer); 1169 } 1170 1171 extern(C) static void callBackPopupMenuDestroy(OnPopupMenuDelegateWrapper wrapper, GClosure* closure) 1172 { 1173 wrapper.outer.internalRemoveOnPopupMenu(wrapper); 1174 } 1175 1176 protected void internalRemoveOnPopupMenu(OnPopupMenuDelegateWrapper source) 1177 { 1178 foreach(index, wrapper; onPopupMenuListeners) 1179 { 1180 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 1181 { 1182 onPopupMenuListeners[index] = null; 1183 onPopupMenuListeners = std.algorithm.remove(onPopupMenuListeners, index); 1184 break; 1185 } 1186 } 1187 } 1188 1189 1190 protected class OnQueryTooltipDelegateWrapper 1191 { 1192 bool delegate(int, int, bool, Tooltip, StatusIcon) dlg; 1193 gulong handlerId; 1194 ConnectFlags flags; 1195 this(bool delegate(int, int, bool, Tooltip, StatusIcon) dlg, gulong handlerId, ConnectFlags flags) 1196 { 1197 this.dlg = dlg; 1198 this.handlerId = handlerId; 1199 this.flags = flags; 1200 } 1201 } 1202 protected OnQueryTooltipDelegateWrapper[] onQueryTooltipListeners; 1203 1204 /** 1205 * Emitted when the hover timeout has expired with the 1206 * cursor hovering above @status_icon; or emitted when @status_icon got 1207 * focus in keyboard mode. 1208 * 1209 * Using the given coordinates, the signal handler should determine 1210 * whether a tooltip should be shown for @status_icon. If this is 1211 * the case %TRUE should be returned, %FALSE otherwise. Note that if 1212 * @keyboard_mode is %TRUE, the values of @x and @y are undefined and 1213 * should not be used. 1214 * 1215 * The signal handler is free to manipulate @tooltip with the therefore 1216 * destined function calls. 1217 * 1218 * Whether this signal is emitted is platform-dependent. 1219 * For plain text tooltips, use #GtkStatusIcon:tooltip-text in preference. 1220 * 1221 * Params: 1222 * x = the x coordinate of the cursor position where the request has been 1223 * emitted, relative to @status_icon 1224 * y = the y coordinate of the cursor position where the request has been 1225 * emitted, relative to @status_icon 1226 * keyboardMode = %TRUE if the tooltip was trigged using the keyboard 1227 * tooltip = a #GtkTooltip 1228 * 1229 * Return: %TRUE if @tooltip should be shown right now, %FALSE otherwise. 1230 * 1231 * Since: 2.16 1232 */ 1233 gulong addOnQueryTooltip(bool delegate(int, int, bool, Tooltip, StatusIcon) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1234 { 1235 onQueryTooltipListeners ~= new OnQueryTooltipDelegateWrapper(dlg, 0, connectFlags); 1236 onQueryTooltipListeners[onQueryTooltipListeners.length - 1].handlerId = Signals.connectData( 1237 this, 1238 "query-tooltip", 1239 cast(GCallback)&callBackQueryTooltip, 1240 cast(void*)onQueryTooltipListeners[onQueryTooltipListeners.length - 1], 1241 cast(GClosureNotify)&callBackQueryTooltipDestroy, 1242 connectFlags); 1243 return onQueryTooltipListeners[onQueryTooltipListeners.length - 1].handlerId; 1244 } 1245 1246 extern(C) static int callBackQueryTooltip(GtkStatusIcon* statusiconStruct, int x, int y, bool keyboardMode, GtkTooltip* tooltip,OnQueryTooltipDelegateWrapper wrapper) 1247 { 1248 return wrapper.dlg(x, y, keyboardMode, ObjectG.getDObject!(Tooltip)(tooltip), wrapper.outer); 1249 } 1250 1251 extern(C) static void callBackQueryTooltipDestroy(OnQueryTooltipDelegateWrapper wrapper, GClosure* closure) 1252 { 1253 wrapper.outer.internalRemoveOnQueryTooltip(wrapper); 1254 } 1255 1256 protected void internalRemoveOnQueryTooltip(OnQueryTooltipDelegateWrapper source) 1257 { 1258 foreach(index, wrapper; onQueryTooltipListeners) 1259 { 1260 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 1261 { 1262 onQueryTooltipListeners[index] = null; 1263 onQueryTooltipListeners = std.algorithm.remove(onQueryTooltipListeners, index); 1264 break; 1265 } 1266 } 1267 } 1268 1269 1270 protected class OnScrollDelegateWrapper 1271 { 1272 bool delegate(GdkEventScroll*, StatusIcon) dlg; 1273 gulong handlerId; 1274 ConnectFlags flags; 1275 this(bool delegate(GdkEventScroll*, StatusIcon) dlg, gulong handlerId, ConnectFlags flags) 1276 { 1277 this.dlg = dlg; 1278 this.handlerId = handlerId; 1279 this.flags = flags; 1280 } 1281 } 1282 protected OnScrollDelegateWrapper[] onScrollListeners; 1283 1284 /** 1285 * The ::scroll-event signal is emitted when a button in the 4 to 7 1286 * range is pressed. Wheel mice are usually configured to generate 1287 * button press events for buttons 4 and 5 when the wheel is turned. 1288 * 1289 * Whether this event is emitted is platform-dependent. 1290 * 1291 * Params: 1292 * event = the #GdkEventScroll which triggered 1293 * this signal 1294 * 1295 * Return: %TRUE to stop other handlers from being invoked for the event. 1296 * %FALSE to propagate the event further. 1297 * 1298 * Since: 2.16 1299 */ 1300 gulong addOnScroll(bool delegate(GdkEventScroll*, StatusIcon) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1301 { 1302 onScrollListeners ~= new OnScrollDelegateWrapper(dlg, 0, connectFlags); 1303 onScrollListeners[onScrollListeners.length - 1].handlerId = Signals.connectData( 1304 this, 1305 "scroll-event", 1306 cast(GCallback)&callBackScroll, 1307 cast(void*)onScrollListeners[onScrollListeners.length - 1], 1308 cast(GClosureNotify)&callBackScrollDestroy, 1309 connectFlags); 1310 return onScrollListeners[onScrollListeners.length - 1].handlerId; 1311 } 1312 1313 extern(C) static int callBackScroll(GtkStatusIcon* statusiconStruct, GdkEventScroll* event,OnScrollDelegateWrapper wrapper) 1314 { 1315 return wrapper.dlg(event, wrapper.outer); 1316 } 1317 1318 extern(C) static void callBackScrollDestroy(OnScrollDelegateWrapper wrapper, GClosure* closure) 1319 { 1320 wrapper.outer.internalRemoveOnScroll(wrapper); 1321 } 1322 1323 protected void internalRemoveOnScroll(OnScrollDelegateWrapper source) 1324 { 1325 foreach(index, wrapper; onScrollListeners) 1326 { 1327 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 1328 { 1329 onScrollListeners[index] = null; 1330 onScrollListeners = std.algorithm.remove(onScrollListeners, index); 1331 break; 1332 } 1333 } 1334 } 1335 1336 1337 protected class OnScrollEventGenericDelegateWrapper 1338 { 1339 bool delegate(Event, StatusIcon) dlg; 1340 gulong handlerId; 1341 ConnectFlags flags; 1342 this(bool delegate(Event, StatusIcon) dlg, gulong handlerId, ConnectFlags flags) 1343 { 1344 this.dlg = dlg; 1345 this.handlerId = handlerId; 1346 this.flags = flags; 1347 } 1348 } 1349 protected OnScrollEventGenericDelegateWrapper[] onScrollEventGenericListeners; 1350 1351 /** 1352 * The ::scroll-event signal is emitted when a button in the 4 to 7 1353 * range is pressed. Wheel mice are usually configured to generate 1354 * button press events for buttons 4 and 5 when the wheel is turned. 1355 * 1356 * Whether this event is emitted is platform-dependent. 1357 * 1358 * Params: 1359 * event = the #GdkEventScroll which triggered 1360 * this signal 1361 * 1362 * Return: %TRUE to stop other handlers from being invoked for the event. 1363 * %FALSE to propagate the event further. 1364 * 1365 * Since: 2.16 1366 */ 1367 gulong addOnScroll(bool delegate(Event, StatusIcon) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1368 { 1369 onScrollEventGenericListeners ~= new OnScrollEventGenericDelegateWrapper(dlg, 0, connectFlags); 1370 onScrollEventGenericListeners[onScrollEventGenericListeners.length - 1].handlerId = Signals.connectData( 1371 this, 1372 "scroll-event", 1373 cast(GCallback)&callBackScrollEventGeneric, 1374 cast(void*)onScrollEventGenericListeners[onScrollEventGenericListeners.length - 1], 1375 cast(GClosureNotify)&callBackScrollEventGenericDestroy, 1376 connectFlags); 1377 return onScrollEventGenericListeners[onScrollEventGenericListeners.length - 1].handlerId; 1378 } 1379 1380 extern(C) static int callBackScrollEventGeneric(GtkStatusIcon* statusiconStruct, GdkEvent* event,OnScrollEventGenericDelegateWrapper wrapper) 1381 { 1382 return wrapper.dlg(ObjectG.getDObject!(Event)(event), wrapper.outer); 1383 } 1384 1385 extern(C) static void callBackScrollEventGenericDestroy(OnScrollEventGenericDelegateWrapper wrapper, GClosure* closure) 1386 { 1387 wrapper.outer.internalRemoveOnScrollEventGeneric(wrapper); 1388 } 1389 protected void internalRemoveOnScrollEventGeneric(OnScrollEventGenericDelegateWrapper source) 1390 { 1391 foreach(index, wrapper; onScrollEventGenericListeners) 1392 { 1393 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 1394 { 1395 onScrollEventGenericListeners[index] = null; 1396 onScrollEventGenericListeners = std.algorithm.remove(onScrollEventGenericListeners, index); 1397 break; 1398 } 1399 } 1400 } 1401 1402 1403 protected class OnSizeChangedDelegateWrapper 1404 { 1405 bool delegate(int, StatusIcon) dlg; 1406 gulong handlerId; 1407 ConnectFlags flags; 1408 this(bool delegate(int, StatusIcon) dlg, gulong handlerId, ConnectFlags flags) 1409 { 1410 this.dlg = dlg; 1411 this.handlerId = handlerId; 1412 this.flags = flags; 1413 } 1414 } 1415 protected OnSizeChangedDelegateWrapper[] onSizeChangedListeners; 1416 1417 /** 1418 * Gets emitted when the size available for the image 1419 * changes, e.g. because the notification area got resized. 1420 * 1421 * Params: 1422 * size = the new size 1423 * 1424 * Return: %TRUE if the icon was updated for the new 1425 * size. Otherwise, GTK+ will scale the icon as necessary. 1426 * 1427 * Since: 2.10 1428 */ 1429 gulong addOnSizeChanged(bool delegate(int, StatusIcon) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1430 { 1431 onSizeChangedListeners ~= new OnSizeChangedDelegateWrapper(dlg, 0, connectFlags); 1432 onSizeChangedListeners[onSizeChangedListeners.length - 1].handlerId = Signals.connectData( 1433 this, 1434 "size-changed", 1435 cast(GCallback)&callBackSizeChanged, 1436 cast(void*)onSizeChangedListeners[onSizeChangedListeners.length - 1], 1437 cast(GClosureNotify)&callBackSizeChangedDestroy, 1438 connectFlags); 1439 return onSizeChangedListeners[onSizeChangedListeners.length - 1].handlerId; 1440 } 1441 1442 extern(C) static int callBackSizeChanged(GtkStatusIcon* statusiconStruct, int size,OnSizeChangedDelegateWrapper wrapper) 1443 { 1444 return wrapper.dlg(size, wrapper.outer); 1445 } 1446 1447 extern(C) static void callBackSizeChangedDestroy(OnSizeChangedDelegateWrapper wrapper, GClosure* closure) 1448 { 1449 wrapper.outer.internalRemoveOnSizeChanged(wrapper); 1450 } 1451 1452 protected void internalRemoveOnSizeChanged(OnSizeChangedDelegateWrapper source) 1453 { 1454 foreach(index, wrapper; onSizeChangedListeners) 1455 { 1456 if (wrapper.dlg == source.dlg && wrapper.flags == source.flags && wrapper.handlerId == source.handlerId) 1457 { 1458 onSizeChangedListeners[index] = null; 1459 onSizeChangedListeners = std.algorithm.remove(onSizeChangedListeners, index); 1460 break; 1461 } 1462 } 1463 } 1464 1465 }