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