Next: , Previous: The Main Event Loop, Up: Top


6 Miscellaneous Utility Functions

a selection of portable utility functions.

6.1 Overview

These are portable utility functions.

6.2 Usage

— Function: g-get-application-name ⇒  (ret mchars)

Gets a human-readable name for the application, as set by g-set-application-name. This name should be localized if possible, and is intended for display to the user. Contrast with g-get-prgname, which gets a non-localized name. If g-set-application-name has not been called, returns the result of g-get-prgname (which may be ‘#f’ if g-set-prgname has also not been called).

ret
human-readable application name. may return ‘#f

Since 2.2

— Function: g-set-application-name (application_name mchars)

Sets a human-readable name for the application. This name should be localized if possible, and is intended for display to the user. Contrast with g-set-prgname, which sets a non-localized name. g-set-prgname will be called automatically by gtk-init, but g-set-application-name will not.

Note that for thread safety reasons, this function can only be called once.

The application name will be used in contexts such as error messages, or when displaying an application's name in the task list.

application-name
localized name of the application
— Function: g-get-prgname ⇒  (ret mchars)

Gets the name of the program. This name should not be localized, contrast with g-get-application-name. (If you are using GDK or GTK+ the program name is set in gdk-init, which is called by gtk-init. The program name is found by taking the last component of ‘argv[0]’.)

ret
the name of the program. The returned string belongs to GLib and must not be modified or freed.
— Function: g-set-prgname (prgname mchars)

Sets the name of the program. This name should not be localized, contrast with g-set-application-name. Note that for thread-safety reasons this function can only be called once.

prgname
the name of the program.
— Function: g-get-user-name ⇒  (ret mchars)

Gets the user name of the current user. The encoding of the returned string is system-defined. On UNIX, it might be the preferred file name encoding, or something else, and there is no guarantee that it is even consistent on a machine. On Windows, it is always UTF-8.

ret
the user name of the current user.
— Function: g-get-real-name ⇒  (ret mchars)

Gets the real name of the user. This usually comes from the user's entry in the passwd file. The encoding of the returned string is system-defined. (On Windows, it is, however, always UTF-8.) If the real user name cannot be determined, the string "Unknown" is returned.

ret
the user's real name.
— Function: g-get-user-cache-dir ⇒  (ret mchars)

Returns a base directory in which to store non-essential, cached data specific to particular user.

On UNIX platforms this is determined using the mechanisms described in the XDG Base Directory Specification

ret
a string owned by GLib that must not be modified or freed.

Since 2.6

— Function: g-get-user-data-dir ⇒  (ret mchars)

Returns a base directory in which to access application data such as icons that is customized for a particular user.

On UNIX platforms this is determined using the mechanisms described in the XDG Base Directory Specification

ret
a string owned by GLib that must not be modified or freed.

Since 2.6

— Function: g-get-user-config-dir ⇒  (ret mchars)

Returns a base directory in which to store user-specific application configuration information such as user preferences and settings.

On UNIX platforms this is determined using the mechanisms described in the XDG Base Directory Specification

ret
a string owned by GLib that must not be modified or freed.

Since 2.6

— Function: g-get-host-name ⇒  (ret mchars)

Return a name for the machine.

The returned name is not necessarily a fully-qualified domain name, or even present in DNS or some other name service at all. It need not even be unique on your local network or site, but usually it is. Callers should not rely on the return value having any specific properties like uniqueness for security purposes. Even if the name of the machine is changed while an application is running, the return value from this function does not change. The returned string is owned by GLib and should not be modified or freed. If no name can be determined, a default fixed string "localhost" is returned.

ret
the host name of the machine.

Since 2.8

— Function: g-get-home-dir ⇒  (ret mchars)

Gets the current user's home directory.

Note that in contrast to traditional UNIX tools, this function prefers passwd entries over the HOME environment variable.

ret
the current user's home directory.
— Function: g-get-tmp-dir ⇒  (ret mchars)

Gets the directory to use for temporary files. This is found from inspecting the environment variables TMPDIR, TMP, and TEMP in that order. If none of those are defined "/tmp" is returned on UNIX and "C:\" on Windows. The encoding of the returned string is system-defined. On Windows, it is always UTF-8. The return value is never ‘#f’.

ret
the directory to use for temporary files.