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