forked from stsaz/phiola
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui.h
75 lines (63 loc) · 1.33 KB
/
gui.h
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/** phiola: executor: 'gui' command
2023, Simon Zolin */
static int gui_help()
{
static const char s[] = "\
Show graphical interface:\n\
phiola gui [INPUT...]\n\
\n\
INPUT File name, directory or URL\n\
";
ffstdout_write(s, FFS_LEN(s));
x->exit_code = 0;
return 1;
}
struct cmd_gui {
ffvec input; // ffstr[]
};
static int gui_input(struct cmd_gui *g, ffstr s)
{
*ffvec_pushT(&g->input, ffstr) = s;
return 0;
}
static int gui_action(struct cmd_gui *g)
{
struct phi_queue_conf qc = {
.first_filter = &phi_guard_gui,
.ui_module = "gui.track",
};
x->queue->create(&qc);
ffstr *it;
FFSLICE_WALK(&g->input, it) {
struct phi_queue_entry qe = {
.conf.ifile.name = ffsz_dupstr(it),
};
if (0 == x->queue->add(NULL, &qe))
x->queue->play(NULL, x->queue->at(NULL, 0));
}
ffvec_free(&g->input);
x->core->mod("gui");
if (!x->debug) {
// show logs inside Logs window
x->log.use_color = 0;
x->log.func = x->core->mod("gui.log");
}
return 0;
}
static int gui_open()
{
return 0;
}
static const struct ffarg cmd_gui[] = {
{ "-help", 0, gui_help },
{ "\0\1", 'S', gui_input },
{ "", 0, gui_open },
};
static void cmd_gui_free(struct cmd_gui *g)
{
ffmem_free(g);
}
static struct ffarg_ctx cmd_gui_init(void *obj)
{
return SUBCMD_INIT(ffmem_new(struct cmd_gui), cmd_gui_free, gui_action, cmd_gui);
}