File: module.h

package info (click to toggle)
yambar 1.11.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,224 kB
  • sloc: ansic: 17,135; xml: 679; sh: 155; yacc: 108; lex: 79; makefile: 9
file content (43 lines) | stat: -rw-r--r-- 1,474 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#pragma once

#include <threads.h>

#include "particle.h"

struct bar;

struct module {
    const struct bar *bar;

    int abort_fd;
    mtx_t lock;

    void *private;

    int (*run)(struct module *mod);
    void (*destroy)(struct module *module);

    /*
     * Called by module_begin_expose(). Should return an
     * exposable (an instantiated particle).
     */
    struct exposable *(*content)(struct module *mod);

    /* refresh_in() should schedule a module content refresh after the
     * specified number of milliseconds */
    bool (*refresh_in)(struct module *mod, long milli_seconds);

    const char *(*description)(const struct module *mod);
};

struct module *module_common_new(void);
void module_default_destroy(struct module *mod);
struct exposable *module_begin_expose(struct module *mod);

/* List of attributes *all* modules implement */
#define MODULE_COMMON_ATTRS                                                                                            \
    {"content", true, &conf_verify_particle}, {"anchors", false, NULL}, {"font", false, &conf_verify_font},            \
        {"foreground", false, &conf_verify_color},                                                                     \
    {                                                                                                                  \
        NULL, false, NULL                                                                                              \
    }