/
gui.h
167 lines (143 loc) · 5.56 KB
1
2
3
4
5
6
7
8
/**
* MojoSetup; a portable, flexible installation application.
*
* Please see the file LICENSE.txt in the source's root directory.
*
* This file written by Ryan C. Gordon.
*/
9
10
11
12
13
14
15
16
17
18
19
20
#ifndef _INCL_GUI_H_
#define _INCL_GUI_H_
#include "universal.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum
{
MOJOGUI_PRIORITY_NEVER_TRY = 0,
21
MOJOGUI_PRIORITY_USER_REQUESTED,
22
23
MOJOGUI_PRIORITY_TRY_FIRST,
MOJOGUI_PRIORITY_TRY_NORMAL,
24
25
MOJOGUI_PRIORITY_TRY_LAST,
MOJOGUI_PRIORITY_TOTAL
26
27
} MojoGuiPluginPriority;
28
29
30
31
/*
* Abstract GUI interfaces.
*/
32
33
34
35
36
37
38
39
typedef struct MojoGuiSetupOptions MojoGuiSetupOptions;
struct MojoGuiSetupOptions
{
const char *description;
boolean value;
boolean is_group_parent;
uint64 size;
40
int opaque; // GUI drivers shouldn't touch this.
41
void *guiopaque; // For GUI drivers. App won't touch or free this.
42
43
44
45
MojoGuiSetupOptions *next_sibling;
MojoGuiSetupOptions *child;
};
46
47
48
49
50
51
52
53
#define MOJOGUI_ENTRY_POINT MojoSetup_Gui_GetInterface
#define MOJOGUI_ENTRY_POINT_STR DEFINE_TO_STR(MOJOGUI_ENTRY_POINT)
// Increment this value when MojoGui's structure changes.
#define MOJOGUI_INTERFACE_REVISION 1
typedef struct MojoGui MojoGui;
struct MojoGui
54
{
55
56
57
58
59
60
uint8 (*priority)(void);
const char* (*name)(void);
boolean (*init)(void);
void (*deinit)(void);
void (*msgbox)(const char *title, const char *text);
boolean (*promptyn)(const char *title, const char *text);
61
62
boolean (*start)(const char *title, const char *splash);
void (*stop)(void);
63
int (*readme)(const char *name, const uint8 *data, size_t len,
64
boolean can_back, boolean can_fwd);
65
int (*options)(MojoGuiSetupOptions *opts,
66
boolean can_back, boolean can_fwd);
67
68
char * (*destination)(const char **recommendations, int recnum,
int *command, boolean can_back, boolean can_fwd);
69
boolean (*insertmedia)(const char *medianame);
70
71
boolean (*progress)(const char *type, const char *component,
int percent, const char *item);
72
void (*final)(const char *msg);
73
74
};
75
76
typedef const MojoGui* (*MojoGuiEntryPoint)(int revision,
const MojoSetupEntryPoints *e);
77
78
79
80
#if !BUILDING_EXTERNAL_PLUGIN
extern const MojoGui *GGui;
const MojoGui *MojoGui_initGuiPlugin(void);
81
82
83
void MojoGui_deinitGuiPlugin(void);
#else
84
85
__EXPORT__ const MojoGui *MOJOGUI_ENTRY_POINT(int revision,
const MojoSetupEntryPoints *e);
86
87
88
89
90
91
/*
* We do this as a macro so we only have to update one place, and it
* enforces some details in the plugins. Without effort, plugins don't
* support anything but the latest version of the interface.
*/
92
#define MOJOGUI_PLUGIN(module) \
93
94
95
96
97
98
99
static const MojoSetupEntryPoints *entry = NULL; \
static uint8 MojoGui_##module##_priority(void); \
static const char* MojoGui_##module##_name(void) { return #module; } \
static boolean MojoGui_##module##_init(void); \
static void MojoGui_##module##_deinit(void); \
static void MojoGui_##module##_msgbox(const char *title, const char *text); \
static boolean MojoGui_##module##_promptyn(const char *t1, const char *t2); \
100
101
static boolean MojoGui_##module##_start(const char *t, const char *s); \
static void MojoGui_##module##_stop(void); \
102
static int MojoGui_##module##_readme(const char *name, const uint8 *data, \
103
104
size_t len, boolean can_back, \
boolean can_fwd); \
105
static int MojoGui_##module##_options(MojoGuiSetupOptions *opts, \
106
boolean can_back, boolean can_fwd); \
107
108
static char *MojoGui_##module##_destination(const char **r, int recnum, \
int *command, boolean can_back, boolean can_fwd); \
109
static boolean MojoGui_##module##_insertmedia(const char *medianame); \
110
111
static boolean MojoGui_##module##_progress(const char *typ, const char *comp, \
int percent, const char *item); \
112
static void MojoGui_##module##_final(const char *msg); \
113
const MojoGui *MojoGuiPlugin_##module(int rev, const MojoSetupEntryPoints *e) \
114
{ \
115
116
117
118
119
120
121
122
if (rev == MOJOGUI_INTERFACE_REVISION) { \
static const MojoGui retval = { \
MojoGui_##module##_priority, \
MojoGui_##module##_name, \
MojoGui_##module##_init, \
MojoGui_##module##_deinit, \
MojoGui_##module##_msgbox, \
MojoGui_##module##_promptyn, \
123
124
125
MojoGui_##module##_start, \
MojoGui_##module##_stop, \
MojoGui_##module##_readme, \
126
MojoGui_##module##_options, \
127
MojoGui_##module##_destination, \
128
MojoGui_##module##_insertmedia, \
129
MojoGui_##module##_progress, \
130
MojoGui_##module##_final, \
131
132
}; \
entry = e; \
133
134
135
return &retval; \
} \
return NULL; \
136
137
} \
138
#define CREATE_MOJOGUI_ENTRY_POINT(module) \
139
const MojoGui *MOJOGUI_ENTRY_POINT(int rev, const MojoSetupEntryPoints *e) \
140
{ \
141
return MojoGuiPlugin_##module(rev, e); \
142
143
} \
144
#endif
145
146
147
148
/*
* make some decisions about which GUI plugins to build...
149
150
* We list them all here, but some are built, some aren't. Some are DLLs,
* some aren't...
151
152
153
*/
// Probably want to support this always, unless explicitly overridden.
154
const MojoGui *MojoGuiPlugin_stdio(int rev, const MojoSetupEntryPoints *e);
155
const MojoGui *MojoGuiPlugin_gtkplus2(int rev, const MojoSetupEntryPoints *e);
156
const MojoGui *MojoGuiPlugin_macosx(int rev, const MojoSetupEntryPoints *e);
157
158
159
// !!! FIXME: Qt? KDE? Gnome? Console? Cocoa?
160
161
162
163
164
165
#ifdef __cplusplus
}
#endif
#endif
166
// end of gui.h ...