Package ch.bailu.gtk.gtk
Klasse IconTheme
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.type.PropertyHolder
ch.bailu.gtk.gtk.IconTheme
- Alle implementierten Schnittstellen:
PointerInterface
Loads themed icons.
The main reason for using a name rather than simply providing a filename
is to allow different icons to be used depending on what “icon theme” is
selected by the user. The operation of icon themes on Linux and Unix
follows the [Icon Theme Specification](http://www.freedesktop.org/Standards/icon-theme-spec)
There is a fallback icon theme, named `hicolor`, where applications
should install their icons, but additional icon themes can be installed
as operating system vendors and users choose.
In many cases, named themes are used indirectly, via [class@Gtk.Image]
rather than directly, but looking up icons directly is also simple. The
`GtkIconTheme` object acts as a database of all the icons in the current
theme. You can create new `GtkIconTheme` objects, but it’s much more
efficient to use the standard icon theme of the `GtkWidget` so that the
icon information is shared with other people looking up icons.
```c
GtkIconTheme *icon_theme;
GtkIconPaintable *icon;
GdkPaintable *paintable;
icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (my_widget));
icon = gtk_icon_theme_lookup_icon (icon_theme,
"my-icon-name", // icon name
48, // icon size
1, // scale
0, // flags);
paintable = GDK_PAINTABLE (icon);
// Use the paintable
g_object_unref (icon);
```
The main reason for using a name rather than simply providing a filename
is to allow different icons to be used depending on what “icon theme” is
selected by the user. The operation of icon themes on Linux and Unix
follows the [Icon Theme Specification](http://www.freedesktop.org/Standards/icon-theme-spec)
There is a fallback icon theme, named `hicolor`, where applications
should install their icons, but additional icon themes can be installed
as operating system vendors and users choose.
In many cases, named themes are used indirectly, via [class@Gtk.Image]
rather than directly, but looking up icons directly is also simple. The
`GtkIconTheme` object acts as a database of all the icons in the current
theme. You can create new `GtkIconTheme` objects, but it’s much more
efficient to use the standard icon theme of the `GtkWidget` so that the
icon information is shared with other people looking up icons.
```c
GtkIconTheme *icon_theme;
GtkIconPaintable *icon;
GdkPaintable *paintable;
icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (my_widget));
icon = gtk_icon_theme_lookup_icon (icon_theme,
"my-icon-name", // icon name
48, // icon size
1, // scale
0, // flags);
paintable = GDK_PAINTABLE (icon);
// Use the paintable
g_object_unref (icon);
```
-
Verschachtelte Klassen - Übersicht
Verschachtelte KlassenVon Klasse geerbte verschachtelte Klassen/Schnittstellen ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDestroyNotify, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Feldübersicht
FelderVon Klasse geerbte Felder ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoid
addResourcePath
(Str path) Adds a resource path that will be looked at when looking
for icons, similar to search paths.void
addResourcePath
(String path) Adds a resource path that will be looked at when looking
for icons, similar to search paths.void
addSearchPath
(Str path) Appends a directory to the search path.void
addSearchPath
(String path) Appends a directory to the search path.static ClassHandler
Returns the display that the `GtkIconTheme` object was
created for.static IconTheme
getForDisplay
(Display display) Gets the icon theme object associated with @display.Lists the names of icons in the current icon theme.getIconSizes
(Str icon_name) Returns an array of integers describing the sizes at which
the icon is available without scaling.getIconSizes
(String icon_name) Returns an array of integers describing the sizes at which
the icon is available without scaling.static int
static long
static TypeSystem.TypeSize
Gets the current resource path.Gets the current search path.Gets the current icon theme name.static long
static TypeSystem.TypeSize
boolean
Checks whether an icon theme includes an icon
for a particular `GIcon`.boolean
Checks whether an icon theme includes an icon
for a particular name.boolean
Checks whether an icon theme includes an icon
for a particular name.lookupByGicon
(Icon icon, int size, int scale, int direction, int flags) Looks up a icon for a desired size and window scale.lookupIcon
(Str icon_name, Strs fallbacks, int size, int scale, int direction, int flags) Looks up a named icon for a desired size and window scale,
returning a `GtkIconPaintable`.lookupIcon
(String icon_name, Strs fallbacks, int size, int scale, int direction, int flags) Looks up a named icon for a desired size and window scale,
returning a `GtkIconPaintable`.onChanged
(IconTheme.OnChanged signal) Connect to signal "changed".void
setResourcePath
(Strs path) Sets the resource paths that will be looked at when
looking for icons, similar to search paths.void
setSearchPath
(Strs path) Sets the search path for the icon theme object.void
setThemeName
(Str theme_name) Sets the name of the icon theme that the `GtkIconTheme` object uses
overriding system configuration.void
setThemeName
(String theme_name) Sets the name of the icon theme that the `GtkIconTheme` object uses
overriding system configuration.Von Klasse geerbte Methoden ch.bailu.gtk.type.PropertyHolder
getBooleanProperty, getIntProperty, getObjectProperty, getStringProperty, getStrProperty, setBooleanProperty, setIntProperty, setObjectProperty, setStringProperty, setStrProperty
Von Klasse geerbte Methoden ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Von Klasse geerbte Methoden ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Von Klasse geerbte Methoden ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Von Klasse geerbte Methoden java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Von Schnittstelle geerbte Methoden ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Felddetails
-
SIGNAL_ON_CHANGED
- Siehe auch:
-
-
Konstruktordetails
-
IconTheme
-
IconTheme
public IconTheme()Creates a new icon theme object.
Icon theme objects are used to lookup up an icon by name
in a particular icon theme. Usually, you’ll want to use
[func@Gtk.IconTheme.get_for_display] rather than creating
a new icon theme object for scratch.
-
-
Methodendetails
-
getClassHandler
-
addResourcePath
Adds a resource path that will be looked at when looking
for icons, similar to search paths.
See [method@Gtk.IconTheme.set_resource_path].
This function should be used to make application-specific icons
available as part of the icon theme.- Parameter:
path
- a resource path
-
addResourcePath
Adds a resource path that will be looked at when looking
for icons, similar to search paths.
See [method@Gtk.IconTheme.set_resource_path].
This function should be used to make application-specific icons
available as part of the icon theme.- Parameter:
path
- a resource path
-
addSearchPath
Appends a directory to the search path.
See [method@Gtk.IconTheme.set_search_path].- Parameter:
path
- directory name to append to the icon path
-
addSearchPath
Appends a directory to the search path.
See [method@Gtk.IconTheme.set_search_path].- Parameter:
path
- directory name to append to the icon path
-
getDisplay
Returns the display that the `GtkIconTheme` object was
created for.- Gibt zurück:
- the display of @icon_theme
-
getIconNames
Lists the names of icons in the current icon theme.- Gibt zurück:
- a string array holding the names of all the icons in the theme. You must free the array using g_strfreev().
-
getIconSizes
Returns an array of integers describing the sizes at which
the icon is available without scaling.
A size of -1 means that the icon is available in a scalable
format. The array is zero-terminated.- Parameter:
icon_name
- the name of an icon- Gibt zurück:
- A newly allocated array describing the sizes at which the icon is available. The array should be freed with g_free() when it is no longer needed.
-
getIconSizes
Returns an array of integers describing the sizes at which
the icon is available without scaling.
A size of -1 means that the icon is available in a scalable
format. The array is zero-terminated.- Parameter:
icon_name
- the name of an icon- Gibt zurück:
- A newly allocated array describing the sizes at which the icon is available. The array should be freed with g_free() when it is no longer needed.
-
getResourcePath
Gets the current resource path.
See [method@Gtk.IconTheme.set_resource_path].- Gibt zurück:
- A list of resource paths
-
getSearchPath
Gets the current search path.
See [method@Gtk.IconTheme.set_search_path].- Gibt zurück:
- a list of icon theme path directories
-
getThemeName
Gets the current icon theme name.- Gibt zurück:
- the current icon theme name,
-
hasGicon
Checks whether an icon theme includes an icon
for a particular `GIcon`.- Parameter:
gicon
- a `GIcon`- Gibt zurück:
- %TRUE if @self includes an icon for @gicon
-
hasIcon
Checks whether an icon theme includes an icon
for a particular name.- Parameter:
icon_name
- the name of an icon- Gibt zurück:
- %TRUE if @self includes an icon for @icon_name.
-
hasIcon
Checks whether an icon theme includes an icon
for a particular name.- Parameter:
icon_name
- the name of an icon- Gibt zurück:
- %TRUE if @self includes an icon for @icon_name.
-
lookupByGicon
public IconPaintable lookupByGicon(@Nonnull Icon icon, int size, int scale, int direction, int flags) Looks up a icon for a desired size and window scale.
The icon can then be rendered by using it as a `GdkPaintable`,
or you can get information such as the filename and size.- Parameter:
icon
- the `GIcon` to look upsize
- desired icon size, in application pixelsscale
- the desired scaledirection
- text direction the icon will be displayed inflags
- flags modifying the behavior of the icon lookup- Gibt zurück:
- a `GtkIconPaintable` containing information about the icon. Unref with g_object_unref()
-
lookupIcon
public IconPaintable lookupIcon(@Nonnull Str icon_name, @Nullable Strs fallbacks, int size, int scale, int direction, int flags) Looks up a named icon for a desired size and window scale,
returning a `GtkIconPaintable`.
The icon can then be rendered by using it as a `GdkPaintable`,
or you can get information such as the filename and size.
If the available @icon_name is not available and @fallbacks are
provided, they will be tried in order.
If no matching icon is found, then a paintable that renders the
"missing icon" icon is returned. If you need to do something else
for missing icons you need to use [method@Gtk.IconTheme.has_icon].
Note that you probably want to listen for icon theme changes and
update the icon. This is usually done by overriding the
GtkWidgetClass.css-changed() function.- Parameter:
icon_name
- the name of the icon to lookupfallbacks
- fallback namessize
- desired icon size, in application pixelsscale
- the window scale this will be displayed ondirection
- text direction the icon will be displayed inflags
- flags modifying the behavior of the icon lookup- Gibt zurück:
- a `GtkIconPaintable` object containing the icon.
-
lookupIcon
public IconPaintable lookupIcon(String icon_name, @Nullable Strs fallbacks, int size, int scale, int direction, int flags) Looks up a named icon for a desired size and window scale,
returning a `GtkIconPaintable`.
The icon can then be rendered by using it as a `GdkPaintable`,
or you can get information such as the filename and size.
If the available @icon_name is not available and @fallbacks are
provided, they will be tried in order.
If no matching icon is found, then a paintable that renders the
"missing icon" icon is returned. If you need to do something else
for missing icons you need to use [method@Gtk.IconTheme.has_icon].
Note that you probably want to listen for icon theme changes and
update the icon. This is usually done by overriding the
GtkWidgetClass.css-changed() function.- Parameter:
icon_name
- the name of the icon to lookupfallbacks
- fallback namessize
- desired icon size, in application pixelsscale
- the window scale this will be displayed ondirection
- text direction the icon will be displayed inflags
- flags modifying the behavior of the icon lookup- Gibt zurück:
- a `GtkIconPaintable` object containing the icon.
-
setResourcePath
Sets the resource paths that will be looked at when
looking for icons, similar to search paths.
The resources are considered as part of the hicolor icon theme
and must be located in subdirectories that are defined in the
hicolor icon theme, such as `@path/16x16/actions/run.png`
or `@path/scalable/actions/run.svg`.
Icons that are directly placed in the resource path instead
of a subdirectory are also considered as ultimate fallback,
but they are treated like unthemed icons.- Parameter:
path
- NULL-terminated array of resource paths that are searched for icons
-
setSearchPath
Sets the search path for the icon theme object.
When looking for an icon theme, GTK will search for a subdirectory
of one or more of the directories in @path with the same name
as the icon theme containing an index.theme file. (Themes from
multiple of the path elements are combined to allow themes to be
extended by adding icons in the user’s home directory.)
In addition if an icon found isn’t found either in the current
icon theme or the default icon theme, and an image file with
the right name is found directly in one of the elements of
@path, then that image will be used for the icon name.
(This is legacy feature, and new icons should be put
into the fallback icon theme, which is called hicolor,
rather than directly on the icon path.)- Parameter:
path
- NULL-terminated array of directories that are searched for icon themes
-
setThemeName
Sets the name of the icon theme that the `GtkIconTheme` object uses
overriding system configuration.
This function cannot be called on the icon theme objects returned
from [func@Gtk.IconTheme.get_for_display].- Parameter:
theme_name
- name of icon theme to use instead of configured theme, or %NULL to unset a previously set custom theme
-
setThemeName
Sets the name of the icon theme that the `GtkIconTheme` object uses
overriding system configuration.
This function cannot be called on the icon theme objects returned
from [func@Gtk.IconTheme.get_for_display].- Parameter:
theme_name
- name of icon theme to use instead of configured theme, or %NULL to unset a previously set custom theme
-
onChanged
Connect to signal "changed".
SeeIconTheme.OnChanged.onChanged()
for signal description.
FieldSIGNAL_ON_CHANGED
contains original signal name and can be used as resource reference.- Parameter:
signal
- callback function (lambda).- Gibt zurück:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
getForDisplay
Gets the icon theme object associated with @display.
If this function has not previously been called for the given
display, a new icon theme object will be created and associated
with the display. Icon theme objects are fairly expensive to create,
so using this function is usually a better choice than calling
[ctor@Gtk.IconTheme.new] and setting the display yourself; by using
this function a single icon theme object will be shared between users.- Parameter:
display
- a `GdkDisplay`- Gibt zurück:
- A unique `GtkIconTheme` associated with the given display. This icon theme is associated with the display and can be used as long as the display is open. Do not ref or unref it.
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-