StatusIcon

The “system tray” or notification area is normally used for transient icons that indicate some special state. For example, a system tray icon might appear to tell the user that they have new mail, or have an incoming instant message, or something along those lines. The basic idea is that creating an icon in the notification area is less annoying than popping up a dialog.

A #GtkStatusIcon object can be used to display an icon in a “system tray”. The icon can have a tooltip, and the user can interact with it by activating it or popping up a context menu.

It is very important to notice that status icons depend on the existence of a notification area being available to the user; you should not use status icons as the only way to convey critical information regarding your application, as the notification area may not exist on the user's environment, or may have been removed. You should always check that a status icon has been embedded into a notification area by using gtk.status_icon.StatusIcon.isEmbedded, and gracefully recover if the function returns false.

On X11, the implementation follows the FreeDesktop System Tray Specification. Implementations of the “tray” side of this specification can be found e.g. in the GNOME 2 and KDE panel applications.

Note that a GtkStatusIcon is not a widget, but just a #GObject. Making it a widget would be impractical, since the system tray on Windows doesn’t allow to embed arbitrary widgets.

GtkStatusIcon has been deprecated in 3.14. You should consider using notifications or more modern platform-specific APIs instead. GLib provides the #GNotification API which works well with #GtkApplication on multiple platforms and environments, and should be the preferred mechanism to notify the users of transient status updates. See this HowDoI for code examples.

class StatusIcon : ObjectWrap {}

Constructors

this
this(void* ptr, Flag!"Take" take)
this
this()

Creates an empty status icon object.

Members

Functions

connectActivate
gulong connectActivate(T callback, Flag!"After" after)

Connect to Activate signal.

connectButtonPressEvent
gulong connectButtonPressEvent(T callback, Flag!"After" after)

Connect to ButtonPressEvent signal.

connectButtonReleaseEvent
gulong connectButtonReleaseEvent(T callback, Flag!"After" after)

Connect to ButtonReleaseEvent signal.

connectPopupMenu
gulong connectPopupMenu(T callback, Flag!"After" after)

Connect to PopupMenu signal.

connectQueryTooltip
gulong connectQueryTooltip(T callback, Flag!"After" after)

Connect to QueryTooltip signal.

connectScrollEvent
gulong connectScrollEvent(T callback, Flag!"After" after)

Connect to ScrollEvent signal.

connectSizeChanged
gulong connectSizeChanged(T callback, Flag!"After" after)

Connect to SizeChanged signal.

getGeometry
bool getGeometry(gdk.screen.Screen screen, gdk.rectangle.Rectangle area, gtk.types.Orientation orientation)

Obtains information about the location of the status icon on screen. This information can be used to e.g. position popups like notification bubbles.

getGicon
gio.icon.Icon getGicon()

Retrieves the #GIcon being displayed by the #GtkStatusIcon. The storage type of the status icon must be gtk.types.ImageType.Empty or gtk.types.ImageType.Gicon (see gtk.status_icon.StatusIcon.getStorageType). The caller of this function does not own a reference to the returned #GIcon.

getHasTooltip
bool getHasTooltip()

Returns the current value of the has-tooltip property. See #GtkStatusIcon:has-tooltip for more information.

getIconName
string getIconName()

Gets the name of the icon being displayed by the #GtkStatusIcon. The storage type of the status icon must be gtk.types.ImageType.Empty or gtk.types.ImageType.IconName (see gtk.status_icon.StatusIcon.getStorageType). The returned string is owned by the #GtkStatusIcon and should not be freed or modified.

getPixbuf
gdkpixbuf.pixbuf.Pixbuf getPixbuf()

Gets the #GdkPixbuf being displayed by the #GtkStatusIcon. The storage type of the status icon must be gtk.types.ImageType.Empty or gtk.types.ImageType.Pixbuf (see gtk.status_icon.StatusIcon.getStorageType). The caller of this function does not own a reference to the returned pixbuf.

getScreen
gdk.screen.Screen getScreen()

Returns the #GdkScreen associated with status_icon.

getSize
int getSize()

Gets the size in pixels that is available for the image. Stock icons and named icons adapt their size automatically if the size of the notification area changes. For other storage types, the size-changed signal can be used to react to size changes.

getStock
string getStock()

Gets the id of the stock icon being displayed by the #GtkStatusIcon. The storage type of the status icon must be gtk.types.ImageType.Empty or gtk.types.ImageType.Stock (see gtk.status_icon.StatusIcon.getStorageType). The returned string is owned by the #GtkStatusIcon and should not be freed or modified.

getStorageType
gtk.types.ImageType getStorageType()

Gets the type of representation being used by the #GtkStatusIcon to store image data. If the #GtkStatusIcon has no image data, the return value will be gtk.types.ImageType.Empty.

getTitle
string getTitle()

Gets the title of this tray icon. See gtk.status_icon.StatusIcon.setTitle.

getTooltipMarkup
string getTooltipMarkup()

Gets the contents of the tooltip for status_icon.

getTooltipText
string getTooltipText()

Gets the contents of the tooltip for status_icon.

getVisible
bool getVisible()

Returns whether the status icon is visible or not. Note that being visible does not guarantee that the user can actually see the icon, see also gtk.status_icon.StatusIcon.isEmbedded.

getX11WindowId
uint getX11WindowId()

This function is only useful on the X11/freedesktop.org platform.

isEmbedded
bool isEmbedded()

Returns whether the status icon is embedded in a notification area.

self
StatusIcon self()

Returns this, for use in with statements.

setFromFile
void setFromFile(string filename)

Makes status_icon display the file filename. See gtk.status_icon.StatusIcon.newFromFile for details.

setFromGicon
void setFromGicon(gio.icon.Icon icon)

Makes status_icon display the #GIcon. See gtk.status_icon.StatusIcon.newFromGicon for details.

setFromIconName
void setFromIconName(string iconName)

Makes status_icon display the icon named icon_name from the current icon theme. See gtk.status_icon.StatusIcon.newFromIconName for details.

setFromPixbuf
void setFromPixbuf(gdkpixbuf.pixbuf.Pixbuf pixbuf)

Makes status_icon display pixbuf. See gtk.status_icon.StatusIcon.newFromPixbuf for details.

setFromStock
void setFromStock(string stockId)

Makes status_icon display the stock icon with the id stock_id. See gtk.status_icon.StatusIcon.newFromStock for details.

setHasTooltip
void setHasTooltip(bool hasTooltip)

Sets the has-tooltip property on status_icon to has_tooltip. See #GtkStatusIcon:has-tooltip for more information.

setName
void setName(string name)

Sets the name of this tray icon. This should be a string identifying this icon. It is may be used for sorting the icons in the tray and will not be shown to the user.

setScreen
void setScreen(gdk.screen.Screen screen)

Sets the #GdkScreen where status_icon is displayed; if the icon is already mapped, it will be unmapped, and then remapped on the new screen.

setTitle
void setTitle(string title)

Sets the title of this tray icon. This should be a short, human-readable, localized string describing the tray icon. It may be used by tools like screen readers to render the tray icon.

setTooltipMarkup
void setTooltipMarkup(string markup)

Sets markup as the contents of the tooltip, which is marked up with the [Pango text markup language]PangoMarkupFormat.

setTooltipText
void setTooltipText(string text)

Sets text as the contents of the tooltip.

setVisible
void setVisible(bool visible)

Shows or hides a status icon.

Properties

_gType
GType _gType [@property getter]
embedded
bool embedded [@property getter]

Get embedded property.

file
string file [@property setter]
gicon
gio.icon.Icon gicon [@property getter]

Get gicon property.

gicon
gio.icon.Icon gicon [@property setter]

Set gicon property.

hasTooltip
bool hasTooltip [@property getter]

Get hasTooltip property.

hasTooltip
bool hasTooltip [@property setter]

Set hasTooltip property.

iconName
string iconName [@property getter]
iconName
string iconName [@property setter]
orientation
gtk.types.Orientation orientation [@property getter]

Get orientation property.

pixbuf
gdkpixbuf.pixbuf.Pixbuf pixbuf [@property getter]
pixbuf
gdkpixbuf.pixbuf.Pixbuf pixbuf [@property setter]
screen
gdk.screen.Screen screen [@property getter]
screen
gdk.screen.Screen screen [@property setter]
size
int size [@property getter]
stock
string stock [@property getter]
stock
string stock [@property setter]
storageType
gtk.types.ImageType storageType [@property getter]
title
string title [@property getter]

Get title property.

title
string title [@property setter]

Set title property.

tooltipMarkup
string tooltipMarkup [@property getter]

Get tooltipMarkup property.

tooltipMarkup
string tooltipMarkup [@property setter]

Set tooltipMarkup property.

tooltipText
string tooltipText [@property getter]

Get tooltipText property.

tooltipText
string tooltipText [@property setter]

Set tooltipText property.

visible
bool visible [@property getter]
visible
bool visible [@property setter]

Static functions

_getGType
GType _getGType()
builder
StatusIconGidBuilder builder()

Get builder for gtk.status_icon.StatusIcon

newFromFile
gtk.status_icon.StatusIcon newFromFile(string filename)

Creates a status icon displaying the file filename.

newFromGicon
gtk.status_icon.StatusIcon newFromGicon(gio.icon.Icon icon)

Creates a status icon displaying a #GIcon. If the icon is a themed icon, it will be updated when the theme changes.

newFromIconName
gtk.status_icon.StatusIcon newFromIconName(string iconName)

Creates a status icon displaying an icon from the current icon theme. If the current icon theme is changed, the icon will be updated appropriately.

newFromPixbuf
gtk.status_icon.StatusIcon newFromPixbuf(gdkpixbuf.pixbuf.Pixbuf pixbuf)

Creates a status icon displaying pixbuf.

newFromStock
gtk.status_icon.StatusIcon newFromStock(string stockId)

Creates a status icon displaying a stock icon. Sample stock icon names are #GTK_STOCK_OPEN, #GTK_STOCK_QUIT. You can register your own stock icon names, see gtk.icon_factory.IconFactory.addDefault and gtk.icon_factory.IconFactory.add.

positionMenu
void positionMenu(gtk.menu.Menu menu, int x, int y, bool pushIn, gtk.status_icon.StatusIcon userData)

Menu positioning function to use with gtk.menu.Menu.popup to position menu aligned to the status icon user_data.

Inherited Members

From ObjectWrap

_setGObject
void _setGObject(void* cObj, Flag!"Take" take)

Set the GObject of a D ObjectWrap wrapper.

_cPtr
void* _cPtr(Flag!"Dup" dup)

Get a pointer to the underlying C object.

_ref
void* _ref(void* gObj)

Calls g_object_ref() on a GObject.

_unref
_unref(void* gObj)

Calls g_object_unref() on a GObject.

_getGType
GType _getGType()

Get the GType of an object.

_gType
GType _gType [@property getter]

GObject GType property.

self
ObjectWrap self()

Convenience method to return this cast to a type. For use in D with statements.

_getDObject
T _getDObject(void* cptr, Flag!"Take" take)

Template to get the D object from a C GObject and cast it to the given D object type.

connectSignalClosure
gulong connectSignalClosure(string signalDetail, DClosure closure, Flag!"After" after)

Connect a D closure to an object signal.

setProperty
void setProperty(string propertyName, T val)

Template for setting a GObject property.

getProperty
T getProperty(string propertyName)

Template for getting a GObject property.

compatControl
size_t compatControl(size_t what, void* data)
bindProperty
gobject.binding.Binding bindProperty(string sourceProperty, gobject.object.ObjectWrap target, string targetProperty, gobject.types.BindingFlags flags)

Creates a binding between source_property on source and target_property on target.

bindPropertyFull
gobject.binding.Binding bindPropertyFull(string sourceProperty, gobject.object.ObjectWrap target, string targetProperty, gobject.types.BindingFlags flags, gobject.closure.Closure transformTo, gobject.closure.Closure transformFrom)

Creates a binding between source_property on source and target_property on target, allowing you to set the transformation functions to be used by the binding.

forceFloating
void forceFloating()

This function is intended for #GObject implementations to re-enforce a floating[floating-ref] object reference. Doing this is seldom required: all #GInitiallyUnowneds are created with a floating reference which usually just needs to be sunken by calling gobject.object.ObjectWrap.refSink.

freezeNotify
void freezeNotify()

Increases the freeze count on object. If the freeze count is non-zero, the emission of "notify" signals on object is stopped. The signals are queued until the freeze count is decreased to zero. Duplicate notifications are squashed so that at most one #GObject::notify signal is emitted for each property modified while the object is frozen.

getData
void* getData(string key)

Gets a named field from the objects table of associations (see gobject.object.ObjectWrap.setData).

getProperty
void getProperty(string propertyName, gobject.value.Value value)

Gets a property of an object.

getQdata
void* getQdata(glib.types.Quark quark)

This function gets back user data pointers stored via gobject.object.ObjectWrap.setQdata.

getv
void getv(string[] names, gobject.value.Value[] values)

Gets n_properties properties for an object. Obtained properties will be set to values. All properties must be valid. Warnings will be emitted and undefined behaviour may result if invalid properties are passed in.

isFloating
bool isFloating()

Checks whether object has a floating[floating-ref] reference.

notify
void notify(string propertyName)

Emits a "notify" signal for the property property_name on object.

notifyByPspec
void notifyByPspec(gobject.param_spec.ParamSpec pspec)

Emits a "notify" signal for the property specified by pspec on object.

refSink
gobject.object.ObjectWrap refSink()

Increase the reference count of object, and possibly remove the floating[floating-ref] reference, if object has a floating reference.

runDispose
void runDispose()

Releases all references to other objects. This can be used to break reference cycles.

setData
void setData(string key, void* data)

Each object carries around a table of associations from strings to pointers. This function lets you set an association.

setProperty
void setProperty(string propertyName, gobject.value.Value value)

Sets a property on an object.

stealData
void* stealData(string key)

Remove a specified datum from the object's data associations, without invoking the association's destroy handler.

stealQdata
void* stealQdata(glib.types.Quark quark)

This function gets back user data pointers stored via gobject.object.ObjectWrap.setQdata and removes the data from object without invoking its destroy() function (if any was set). Usually, calling this function is only required to update user data pointers with a destroy notifier, for example:

thawNotify
void thawNotify()

Reverts the effect of a previous call to gobject.object.ObjectWrap.freezeNotify. The freeze count is decreased on object and when it reaches zero, queued "notify" signals are emitted.

watchClosure
void watchClosure(gobject.closure.Closure closure)

This function essentially limits the life time of the closure to the life time of the object. That is, when the object is finalized, the closure is invalidated by calling gobject.closure.Closure.invalidate on it, in order to prevent invocations of the closure with a finalized (nonexisting) object. Also, gobject.object.ObjectWrap.ref_ and gobject.object.ObjectWrap.unref are added as marshal guards to the closure, to ensure that an extra reference count is held on object during invocation of the closure. Usually, this function will be called on closures that use this object as closure data.

connectNotify
gulong connectNotify(string detail, T callback, Flag!"After" after)

Connect to Notify signal.