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