State Storage

digraph inheritance { rankdir=LR; GObject -> WpState; }

struct WpState

The WpState class saves and loads properties from a file

GObject Properties

name

The file name where the state will be stored.

gchar *

G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY

WpState *wp_state_new(const gchar *name)

Constructs a new state object.

Parameters:
  • name – the state name

Returns:

(transfer full): the new WpState

const gchar *wp_state_get_name(WpState *self)

Gets the name of a state object.

Parameters:
  • self – the state

Returns:

the name of this state

const gchar *wp_state_get_location(WpState *self)

Gets the location of a state object.

Parameters:
  • self – the state

Returns:

the location of this state

void wp_state_clear(WpState *self)

Clears the state removing its file.

Parameters:
  • self – the state

gboolean wp_state_save(WpState *self, WpProperties *props, GError **error)

Saves new properties in the state, overwriting all previous data.

Parameters:
  • self – the state

  • props – (transfer none): the properties to save

  • error – (out)(optional): return location for a GError, or NULL

Returns:

TRUE if the properties could be saved, FALSE otherwise

WpProperties *wp_state_load(WpState *self)

Loads the state data from the file system.

This function will never fail. If it cannot load the state, for any reason, it will simply return an empty WpProperties, behaving as if there was no previous state stored.

Parameters:
  • self – the state

Returns:

(transfer full): a new WpProperties containing the state data

WP_TYPE_STATE (wp_state_get_type ())

The WpState GType.