Struct libxdgkit::icon_theme::Directory[][src]

pub struct Directory {
    pub name: Option<String>,
    pub size: Option<i32>,
    pub scale: Option<i32>,
    pub context: Option<IconContext>,
    pub xdg_type: Option<DirectoryType>,
    pub max_size: Option<i32>,
    pub min_size: Option<i32>,
    pub threshold: Option<i32>,
}
Expand description

Overview

An icon theme is a set of icons that share a common look and feel. The user can then select the icon theme that they want to use, and all apps use icons from the theme. The initial user of icon themes is the icon field of the desktop file specification, but in the future it can have other uses (such as mimetype icons).

From a programmer perspective an icon theme is just a mapping. Given a set of directories to look for icons in and a theme name it maps from icon name and nominal icon size to an icon filename.

Definitions

Icon Theme

An icon theme is a named set of icons. It is used to map from an iconname and size to a file. Themes may inherit from other themes as a way to extend them.

Base Directory

Icons and themes are searched for in a set of directories, called base directories. The themes are stored in subdirectories of the base directories.

Icon scale

On very high density (high dpi) screens the UI is often scaled to avoid the UI being so small it is hard to see. In order to support this icons can have a target scale, describing what scale factor they are designed for.

For instance, an icon with a directory size of 48 but scale 2x would be 96x96 pixels, but designed to have the same level of detail as a 48x48 icon at scale 1x. This can be used on high density displays where a 48x48 icon would be too small (or ugly upscaled) and a normal 96x96 icon would have a lot of detail that is hard to see.

Directory Layout

Icons and themes are looked for in a set of directories. By default, apps should look in $HOME/.icons (for backwards compatibility), in $XDG_DATA_DIRS/icons and in /usr/share/pixmaps (in that order). Applications may further add their own icon directories to this list, and users may extend or change the list (in application/desktop specific ways).In each of these directories themes are stored as subdirectories. A theme can be spread across several base directories by having subdirectories of the same name. This way users can extend and override system themes.

In order to have a place for third party applications to install their icons there should always exist a theme called (“hicolor”)[https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html#ftn.idm44938525353648]. The data for the hicolor theme is available for download at: http://www.freedesktop.org/software/icon-theme/. Implementations are required to look in the “hicolor” theme if an icon was not found in the current theme.

Each theme is stored as subdirectories of the base directories. The internal name of the theme is the name of the subdirectory, although the user-visible name as specified by the theme may be different. Hence, theme names are case sensitive, and are limited to ASCII characters. Theme names may also not contain comma or space.

In at least one of the theme directories there must be a file called index.theme that describes the theme. The first index.theme found while searching the base directories in order is used. This file describes the general attributes of the theme.

In the theme directory are also a set of subdirectories containing image files. Each directory contains icons designed for a certain nominal icon size and scale, as described by the index.theme file. The subdirectories are allowed to be several levels deep, e.g. the subdirectory “48x48/apps” in the theme “hicolor” would end up at $basedir/hicolor/48x48/apps.

The image files must be one of the types: PNG, XPM, or SVG, and the extension must be “.png”, “.xpm”, or “.svg” (lower case). The support for SVG files is optional. Implementations that do not support SVGs should just ignore any “.svg” files. In addition to this there may be an additional file with extra icon-data for each file. It should have the same basename as the image file, with the extension “.icon”. e.g. if the icon file is called “mime_source_c.png” the corresponding file would be named “mime_source_c.icon”. #File Formats Both the icon theme description file and the icon data files are ini-style text files, as described in the desktop file specification. They don’t have any encoding field. Instead, they must always be stored in UTF-8 encoding.

The index.theme file must start with a section called [Icon Theme], with contents according to the items below. All lists in the ini file, are to be comma-separated.

Fields

name: Option<String>

[REQUIRED BY SPECS] directory name

size: Option<i32>

Nominal (unscaled) size of the icons in this directory.

scale: Option<i32>

[REQUIRED BY SPECS] Target scale of of the icons in this directory. Defaults to the value 1 if not present. Any directory with a scale other than 1 should be listed in the ScaledDirectories list rather than Directories for backwards compatibility.

context: Option<IconContext>

The context the icon is normally used in. See: https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html#context

xdg_type: Option<DirectoryType>

The type of icon sizes for the icons in this directory. Valid types are Fixed, Scalable and Threshold. The type decides what other keys in the section are used. If not specified, the default is Threshold.

max_size: Option<i32>

Specifies the maximum (unscaled) size that the icons in this directory can be scaled to. Defaults to the value of Size if not present.

min_size: Option<i32>

Specifies the minimum (unscaled) size that the icons in this directory can be scaled to. Defaults to the value of Size if not present.

threshold: Option<i32>

The icons in this directory can be used if the size differ at most this much from the desired (unscaled) size. Defaults to 2 if not present.

Implementations

impl Directory[src]

pub fn convert_xdg_type(directory_type: Option<String>) -> Option<DirectoryType>[src]

Convert an Option<String> to a DirectoryType

pub fn string_xdg_type(dt: DirectoryType) -> Option<String>[src]

This function will return a Some(String) from a DirectoryType Threshold is returned by default

pub fn context(icon_context: Option<String>) -> Option<IconContext>[src]

Convert an Option<String> to an Option

Trait Implementations

impl Debug for Directory[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.