summaryrefslogtreecommitdiffstats
path: root/src/eulogium.h
blob: d6d59d356e2362ce518684b0c853c1842c20fb07 (plain)
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/* TODO COPYRIGHT */

#ifndef _EULOGIUM_H
#define _EULOGIUM_H

#include <Evas.h>
#include <Eldbus.h>
#include <stdint.h>

enum screen_type {
	NONE,
	FUNC,
	MATERIAL,
	PROGRESS,
	END, /* sentinel */
};

enum printer_status {
	UNKNOWN,
	DISCONNECTED,
	ERROR,
	FIRST_RUN_WIZZARD,
	IDLE,
	SLICING,
	HEATING,
	PRINTING,
	COOLING,
	WAIT_FOR_REMOVAL,
	PAUSED,
};

char *griffin_print_status[] = {
	"Unknown",
	"Disconnected",
	"Error",
	"First Run Wizard",
	"IDLE",
	"Slicing",
	"Heating",
	"Printing:",
	"Cooling down",
	"Wait for Removal",
	"Paused",
};

struct printer_data {
	enum printer_status status;
	char **file_handlers;
	uint_fast8_t hotend_count;
	double *hotend_temp;
	double *hotend_target_temp;
	double bed_temp;
	double bed_target_temp;
};

struct print_data {
	uint_fast32_t time;
	double progress;
	char *file;
	char *name;
	Eina_Bool name_changed;
	char *flags;
	double material;
};

enum proxy_idx {
	HARMA,
	LED,
	PRINTER,
	LAST /* sentinel */
};

struct dbus_data {
	Eldbus_Connection *conn;
	Eldbus_Pending *pending;
	Eldbus_Proxy *proxy[LAST];
};

struct mount_data {
	char *id;
	Eldbus_Proxy *proxy;
	Eeze_Disk *disk;
	Eina_List **mounts;
};

struct eulogium_data {
	Evas_Object *navi;
	Evas_Object *time;
	Evas_Object *name;
	Evas_Object *status;
	Evas_Object *progress;
	Ecore_Timer *progress_data_refresh;
	Evas_Object *footer; /* XXX this really shows why we need per window persistent data */
	struct printer_data printer;
	struct print_data print;
	struct dbus_data dbus;
	Eina_List *mounts;
	void *data;
};

struct button_cb {
	void (*func)(void *data, Evas_Object *object, void *event_info);
	void *data;
	const char *info;
};

struct button_def {
	const char *text;
	struct button_cb cb;
	void *data;
};

struct menu_entry_def {
	const char *icon;
	const char *label;
	Evas_Object *end;
	const char *footer; /* Primary footer */
	const char *footer_alt; /* Alternating footer */
	Ecore_Timer *toggle_timer;
	void (*func)(void *data, Evas_Object *object, void *event_info);
	void *data;
};

struct menu_def {
	const char *title;
	void *data;
	struct menu_entry_def entry[];
};

struct multi_text {
	uint_fast8_t count;
	const char *button_text;
	const char *text[];
};

struct multi_screen {
	enum screen_type type;
	char *text;
	void (*func)(void *data);
	void *data;
	char *prev_button;
	char *next_button;
	/* TODO consider adding a button_def for the buttons */
};

struct multi_screen_data {
	uint_fast8_t count;
	struct multi_screen *screen;
};

Evas_Object *eulogium_generic_error(struct eulogium_data *eulogium, uint8_t eulogium_error);

void eulogium_print_data_set(struct eulogium_data *eulogium, char *filepath);

void eulogium_button_cb_set(struct button_def *button, struct button_cb *cb);
void eulogium_button_cb_data_set(struct button_def *button, void *data);
void eulogium_button_data_set(struct button_def *button, void *data);

Evas_Object *eulogium_main_menu(Evas_Object *window, struct eulogium_data *eulogium);
Evas_Object *eulogium_split_screen(Evas_Object *parent, Evas_Object *top, Evas_Object *bottom);
Evas_Object *eulogium_tripple_button_menu(Evas_Object *parent, const struct button_def *left, const struct button_def *right, const struct button_def *bottom);
Evas_Object *eulogium_dual_button_add(Evas_Object *parent, const struct button_def *left, const struct button_def *right);
Evas_Object *eulogium_print_menu(struct eulogium_data *eulogium, char *filepath);
Evas_Object *eulogium_print_progress(struct eulogium_data *eulogium);
Evas_Object *eulogium_multi_text_menu(struct eulogium_data *eulogium, Evas_Object *parent, struct button_def *button, struct multi_text *data, const uint_fast8_t pagenum, Eina_Bool pageindex);
Evas_Object *menu_widget_list(struct eulogium_data *eulogium, Evas_Object *parent, struct menu_def *menu);
Evas_Object *eulogium_multi_screen_menu(struct eulogium_data *eulogium, Evas_Object *parent, struct multi_screen_data *screen_data, const uint_fast8_t pagenum, Eina_Bool pageindex);

#endif /* _EULOGIUM_H */