#ifndef C8_SETTINGS_H
#define C8_SETTINGS_H
#include <c8ui/c8ui-wayland.h>
#include <stdbool.h>
#include "stealth.h" // stealth mode: what pages show of the user and the PC
struct entry {
char *section, *key, *value;
};
/* Each page builds its content into a box, and keeps it up to date when
* the settings change */
struct page {
const char *name; // for --page
const char *title;
void (*build)(struct c8ui_widget *box);
void (*refresh)(void); // optional
};
extern const struct page page_personalise, page_displays, page_mouse,
page_keyboard, page_shortcuts, page_startup, page_power, page_general,
page_network, page_bluetooth, page_sound, page_defaults, page_accounts,
page_xr, page_info;
struct app {
struct c8ui_app *ui;
struct c8ui_window *window;
struct c8ui_root *root;
struct c8_settings_v1 *settings;
struct entry *entries, *incoming;
int count, incoming_count;
bool ready;
struct c8ui_widget *nav_pane; // the page list, for the theme
struct c8ui_widget *content; // the page showing, NULL on the list
const struct page *page;
};
extern struct app app;
/* The settings, as the compositor last sent them */
const char *setting(const char *section, const char *key);
const char *setting_or(const char *section, const char *key, const char *def);
bool setting_bool(const char *section, const char *key, bool def);
double setting_double(const char *section, const char *key, double def);
/* Every entry of a key, or of a whole section with key NULL */
int setting_all(const char *section, const char *key, const struct entry **out);
/* Changes, sent and applied straight away */
void setting_set(const char *section, const char *key, const char *value);
void setting_set_list(const char *section, const char *key,
const char *const *values, int count);
/* For larger edits: these, then setting_commit() */
void setting_queue_set(const char *section, const char *key, const char *value);
void setting_queue_add(const char *section, const char *key, const char *value);
void setting_queue_remove(const char *section, const char *key);
void setting_commit(void);
/* Controls tied to a setting: they change it, and follow it */
struct c8ui_widget *bound_toggle(const char *section, const char *key,
const char *header, const char *caption, bool def);
struct c8ui_widget *bound_slider(const char *section, const char *key,
const char *header, double min, double max, double step, double def,
const char *format);
struct c8ui_widget *bound_entry(const char *section, const char *key,
const char *header, const char *placeholder);
/* A combo: item i saves values[i]; def is shown for unset or unknown */
struct c8ui_widget *bound_choice(const char *section, const char *key,
const char *header, const char *const *values,
const char *const *labels, int count, int def);
/* A combo the page made itself, kept at item index() as settings change */
struct c8ui_widget *bound_combo(struct c8ui_widget *combo, int (*index)(void));
/* Page building */
struct c8ui_widget *section_title(const char *text);
struct c8ui_widget *caption(const char *text);
/* powermode.c: the Power page's Power mode (power-profiles-daemon) */
struct c8ui_widget *power_mode_new(void);
void add(struct c8ui_widget *box, struct c8ui_widget *w);
void show_error(const char *title, const char *message);
/* night.c: Night light, at the foot of the Displays page */
void night_build(struct c8ui_widget *box);
void night_refresh(void);
/* Displays use wlr-output-management, which lives outside the page */
void displays_init(void);
#endif