Gio.Icon.prototype.to_string

function to_string(): String {
    // Gjs wrapper for g_icon_to_string()
}
  

Generates a textual representation of icon that can be used for serialization such as when passing icon to a different process or saving it to persistent storage. Use Gio.icon_new_for_string to get icon back from the returned string.

The encoding of the returned string is proprietary to Gio.Icon except in the following two cases

- If icon is a Gio.FileIcon, the returned string is a native path (such as `/path/to/my icon.png`) without escaping if the Gio.File for icon is a native file. If the file is not native, the returned string is the result of Gio.File.prototype.get_uri (such as `sftp://path/to/my\%20icon.png`).

- If icon is a Gio.ThemedIcon with exactly one name, the encoding is simply the name (such as `network-server`).

Since 2.20

Returns

An allocated NUL-terminated UTF8 string or null if icon can't be serialized. Use GLib.free to free.