CinnamonBgList

CinnamonBgList — What every monitor should show

Functions

Properties

CinnamonBgMode mode Read / Write

Signals

void config-changed Run Last
void monitors-changed Run Last
void picture-uri-changed Run Last

Types and Values

Object Hierarchy

    GObject
    ╰── CinnamonBgList

Implemented Interfaces

CinnamonBgList implements GListModel.

Description

A GListModel over the picture-uri-list and background-mode keys of org.cinnamon.desktop.background, holding exactly what should be presented: one CinnamonBgItem per connected monitor in CINNAMON_BG_MODE_INDEPENDENT, exactly one in mirror and spanned, and nothing until the layout has loaded.

There is no stored-versus-resolved split: the items are the configuration. Read them, set properties on them, and call cinnamon_bg_list_save().

The model is rederived whenever either key or the layout moves, matching each monitor to a stored entry by connector, then by logical index, then by inheriting its nearest matched neighbour. Items are reused across rebuilds, so a reference a consumer holds stays live and notifies in place.

::config-changed says the configuration moved, ::picture-uri-changed says a rotating wallpaper advanced and nothing else did. A rebuild that changed nothing is silent.

The layout is shared process-wide, so a list built once it has already loaded arrives fully populated and emits nothing afterwards.

Functions

cinnamon_bg_list_new ()

CinnamonBgList *
cinnamon_bg_list_new (void);

Returns

a new CinnamonBgList.

[transfer full]


cinnamon_bg_list_save ()

void
cinnamon_bg_list_save (CinnamonBgList *self);

Writes the model to picture-uri-list.

The model holds only what is on screen, so entries for monitors that are not currently connected are not written back. Unplugging a monitor does not lose its entry — the model is rebuilt from the key, which still holds it — but a save taken while it is disconnected prunes it.

Parameters

self

a CinnamonBgList

 

cinnamon_bg_list_save_pictures ()

void
cinnamon_bg_list_save_pictures (CinnamonBgList *self);

Writes back only the pictures the model is showing, leaving every other stored entry exactly as it was.

For a rotating wallpaper advancing, which moves a picture and nothing else. Unlike cinnamon_bg_list_save(), this never changes which entries exist: one the model cannot represent - a monitor that is not currently connected, or one the mode does not present - is written back untouched, and one the model has but the key does not is not added. Reshaping the key is what a deliberate edit does, and a rotation is not one.

Parameters

self

a CinnamonBgList

 

cinnamon_bg_list_get_mode ()

CinnamonBgMode
cinnamon_bg_list_get_mode (CinnamonBgList *self);

Parameters

self

a CinnamonBgList

 

Returns

how the background behaves, mirroring the background-mode key


cinnamon_bg_list_set_mode ()

void
cinnamon_bg_list_set_mode (CinnamonBgList *self,
                           CinnamonBgMode mode);

Writes background-mode. The list reloads from the key and rebuilds the model, which resizes it, so wait for “config-changed” rather than reading back immediately.

Parameters

self

a CinnamonBgList

 

mode

the mode to switch to

 

cinnamon_bg_list_get_item_for_monitor ()

CinnamonBgItem *
cinnamon_bg_list_get_item_for_monitor (CinnamonBgList *self,
                                       guint monitor);

What one monitor should show. Mirror and spanned hold a single item, which every monitor shows; independent holds one per monitor, so this indexes straight into the model.

Parameters

self

a CinnamonBgList

 

monitor

a monitor's position in cinnamon_bg_list_get_monitor_infos()

 

Returns

the item, or NULL if the layout has not loaded or monitor is out of range.

[transfer full][nullable]


cinnamon_bg_list_get_monitor_infos ()

GPtrArray *
cinnamon_bg_list_get_monitor_infos (CinnamonBgList *self);

The connected monitors, ordered left-to-right then top-to-bottom.

The layout is built on first use and loads asynchronously, so this is empty until the window manager answers. Read it from “monitors-changed” rather than immediately.

Parameters

self

a CinnamonBgList

 

Returns

the current monitors.

[transfer none][element-type CinnamonBgMonitorInfo]


cinnamon_bg_list_set_single_uri ()

void
cinnamon_bg_list_set_single_uri (const char *uri);

Replaces the entire configuration with one zoomed picture on every monitor. The "set as wallpaper" path an external app reaches through the legacy picture-uri key: it discards any per-monitor layout and resets the mode to CINNAMON_BG_MODE_MIRROR.

Writes the keys and nothing else, so a caller that only ever sets a wallpaper needs no CinnamonBgList of its own.

Parameters

uri

the picture URI to show on every monitor

 

cinnamon_bg_list_has_slideshow ()

gboolean
cinnamon_bg_list_has_slideshow (void);

Whether anything in the stored configuration asks for a rotating wallpaper.

Reads the keys rather than a model, so a caller deciding whether to start the slideshow daemon needs no CinnamonBgList of its own, and gets an answer before any monitor layout has loaded.

Returns

TRUE if any stored entry has the slideshow flag set

Types and Values

CINNAMON_TYPE_BG_LIST

#define CINNAMON_TYPE_BG_LIST (cinnamon_bg_list_get_type ())

CinnamonBgList

typedef struct _CinnamonBgList CinnamonBgList;

Property Details

The “mode” property

  “mode”                     CinnamonBgMode

How the background behaves, mirroring the background-mode GSettings key. Setting it writes the key; the list then reloads and rebuilds the model.

Owner: CinnamonBgList

Flags: Read / Write

Default value: CINNAMON_BG_MODE_MIRROR

Signal Details

The “config-changed” signal

void
user_function (CinnamonBgList *self,
               gpointer        user_data)

Emitted when the configuration moved: a placement, a color, a slideshow being switched on or pointed elsewhere, the mode, or the set of monitors.

Everything except a rotating wallpaper advancing, which is “picture-uri-changed”. A component that reacts to what the user configured wants this one and not that one, so a slideshow's own writes stop coming back to it as though they were edits.

Parameters

self

the CinnamonBgList

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “monitors-changed” signal

void
user_function (CinnamonBgList *self,
               gpointer        user_data)

Emitted when the monitor layout has been reloaded: the initial asynchronous load, a hotplug, or the window manager appearing on the bus. The layout object's own settled signal, forwarded, so a component connects to (and disconnects from) the list alone.

The list starts the layout loading on construction, so this arrives on its own without anything having to ask for it.

Parameters

self

the CinnamonBgList

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “picture-uri-changed” signal

void
user_function (CinnamonBgList *self,
               gpointer        user_data)

Emitted when the only thing that moved is which picture an item shows, which is what a slideshow tick does.

Parameters

self

the CinnamonBgList

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last

See Also

CinnamonBgItem, CinnamonBgMonitorInfo