-
Notifications
You must be signed in to change notification settings - Fork 3
/
gui.c
77 lines (64 loc) · 2.04 KB
/
gui.c
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
/*
* xAutoClick
*
* Copyright (C) 2020 Arkadiy Illarionov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "gui.h"
#include <stdlib.h>
gui_t* gui_init(int argc, char **argv) {
const spin_param_t spin_params[SPINS_COUNT] = {
{"Pre-delay", "ms", 0},
{"Interval", "ms", 0},
{"Random +/-", "ms", 0},
{"# of clicks", NULL, 1}
};
const char* button_names[BUTTONS_COUNT] = { "Tap", "Stop", "Start" };
gui_t* gui;
gui = calloc(1, sizeof(gui_t));
if (!gui)
return NULL;
gui->is_save_values = true;
init_gui(gui, spin_params, button_names, argc, argv);
if (!gui->ctx) {
free(gui);
return NULL;
}
return gui;
}
void gui_set_button_sensitive(gui_t* gui, button_t button, bool state) {
if (gui && gui->set_button_sensitive)
gui->set_button_sensitive(gui->ctx, button, state);
}
int gui_get_spin_value(const gui_t* gui, spin_t spin) {
if (gui && gui->get_spin_value)
return gui->get_spin_value(gui->ctx, spin);
return -1;
}
void gui_set_spin_value(gui_t* gui, spin_t spin, int value) {
if (gui && gui->set_spin_value)
gui->set_spin_value(gui->ctx, spin, value);
}
void gui_main_loop(gui_t* gui) {
if (gui && gui->main_loop)
gui->main_loop(gui->ctx);
}
void gui_close(gui_t* gui) {
if (gui && gui->close)
gui->close(gui->ctx);
free(gui);
}