Skip to content

Latest commit

 

History

History
218 lines (186 loc) · 7.05 KB

gui.h

File metadata and controls

218 lines (186 loc) · 7.05 KB
 
May 12, 2007
May 12, 2007
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,
Mar 27, 2006
Mar 27, 2006
21
MOJOGUI_PRIORITY_USER_REQUESTED,
22
23
MOJOGUI_PRIORITY_TRY_FIRST,
MOJOGUI_PRIORITY_TRY_NORMAL,
Mar 25, 2006
Mar 25, 2006
24
MOJOGUI_PRIORITY_TRY_LAST,
May 18, 2007
May 18, 2007
25
MOJOGUI_PRIORITY_TRY_ABSOLUTELY_LAST,
Mar 25, 2006
Mar 25, 2006
26
MOJOGUI_PRIORITY_TOTAL
27
28
} MojoGuiPluginPriority;
Nov 29, 2006
Nov 29, 2006
29
May 17, 2007
May 17, 2007
30
31
32
33
34
35
36
37
38
39
typedef enum
{
MOJOGUI_NO,
MOJOGUI_YES,
MOJOGUI_ALWAYS,
MOJOGUI_NEVER
} MojoGuiYNAN;
40
41
42
/*
* Abstract GUI interfaces.
*/
Nov 29, 2006
Nov 29, 2006
43
Dec 27, 2006
Dec 27, 2006
44
45
46
47
typedef struct MojoGuiSetupOptions MojoGuiSetupOptions;
struct MojoGuiSetupOptions
{
const char *description;
Jan 11, 2008
Jan 11, 2008
48
const char *tooltip;
Dec 27, 2006
Dec 27, 2006
49
50
51
boolean value;
boolean is_group_parent;
uint64 size;
Dec 27, 2006
Dec 27, 2006
52
int opaque; // GUI drivers shouldn't touch this.
May 12, 2007
May 12, 2007
53
void *guiopaque; // For GUI drivers. App won't touch or free this.
Dec 27, 2006
Dec 27, 2006
54
55
56
57
MojoGuiSetupOptions *next_sibling;
MojoGuiSetupOptions *child;
};
May 17, 2007
May 17, 2007
58
Nov 24, 2007
Nov 24, 2007
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
typedef enum
{
MOJOGUI_SPLASH_NONE,
MOJOGUI_SPLASH_TOP,
MOJOGUI_SPLASH_LEFT,
MOJOGUI_SPLASH_RIGHT,
MOJOGUI_SPLASH_BOTTOM,
MOJOGUI_SPLASH_BACKGROUND,
} MojoGuiSplashPos;
typedef struct MojoGuiSplash MojoGuiSplash;
struct MojoGuiSplash
{
const uint8 *rgba; // framebuffer.
uint32 w; // width in pixels.
uint32 h; // height in pixels.
MojoGuiSplashPos position; // where to put the splash.
};
Nov 29, 2006
Nov 29, 2006
79
80
81
82
#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.
Feb 20, 2008
Feb 20, 2008
83
#define MOJOGUI_INTERFACE_REVISION 5
Nov 29, 2006
Nov 29, 2006
84
85
86
typedef struct MojoGui MojoGui;
struct MojoGui
Nov 21, 2007
Nov 21, 2007
88
uint8 (*priority)(boolean istty);
Dec 7, 2006
Dec 7, 2006
89
90
91
92
const char* (*name)(void);
boolean (*init)(void);
void (*deinit)(void);
void (*msgbox)(const char *title, const char *text);
Jul 2, 2007
Jul 2, 2007
93
94
boolean (*promptyn)(const char *title, const char *text, boolean def);
MojoGuiYNAN (*promptynan)(const char *title, const char *text, boolean def);
Nov 24, 2007
Nov 24, 2007
95
boolean (*start)(const char *title, const MojoGuiSplash *splash);
Dec 20, 2006
Dec 20, 2006
96
void (*stop)(void);
May 10, 2007
May 10, 2007
97
int (*readme)(const char *name, const uint8 *data, size_t len,
May 10, 2007
May 10, 2007
98
boolean can_back, boolean can_fwd);
May 10, 2007
May 10, 2007
99
int (*options)(MojoGuiSetupOptions *opts,
May 10, 2007
May 10, 2007
100
boolean can_back, boolean can_fwd);
May 10, 2007
May 10, 2007
101
102
char * (*destination)(const char **recommendations, int recnum,
int *command, boolean can_back, boolean can_fwd);
Apr 21, 2007
Apr 21, 2007
103
boolean (*insertmedia)(const char *medianame);
Feb 20, 2008
Feb 20, 2008
104
void (*progressitem)(void);
May 7, 2007
May 7, 2007
105
boolean (*progress)(const char *type, const char *component,
Jan 24, 2008
Jan 24, 2008
106
int percent, const char *item, boolean can_cancel);
May 12, 2007
May 12, 2007
107
void (*final)(const char *msg);
108
109
};
Dec 7, 2006
Dec 7, 2006
110
111
typedef const MojoGui* (*MojoGuiEntryPoint)(int revision,
const MojoSetupEntryPoints *e);
Dec 7, 2006
Dec 7, 2006
113
114
115
#if !BUILDING_EXTERNAL_PLUGIN
extern const MojoGui *GGui;
const MojoGui *MojoGui_initGuiPlugin(void);
Mar 27, 2006
Mar 27, 2006
116
117
118
void MojoGui_deinitGuiPlugin(void);
#else
Feb 2, 2008
Feb 2, 2008
119
120
121
122
123
124
125
// can't use normal STUBBED in gui plugins, since it references logDebug
// without entry-> ...
#ifndef DOXYGEN_SHOULD_IGNORE_THIS
#undef STUBBED
#define STUBBED(x) STUBBED2(entry->,x)
#endif
Dec 7, 2006
Dec 7, 2006
126
127
__EXPORT__ const MojoGui *MOJOGUI_ENTRY_POINT(int revision,
const MojoSetupEntryPoints *e);
Mar 27, 2006
Mar 27, 2006
128
Mar 25, 2006
Mar 25, 2006
129
130
131
132
133
/*
* 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.
*/
Mar 27, 2006
Mar 27, 2006
134
#define MOJOGUI_PLUGIN(module) \
Dec 7, 2006
Dec 7, 2006
135
static const MojoSetupEntryPoints *entry = NULL; \
Nov 21, 2007
Nov 21, 2007
136
static uint8 MojoGui_##module##_priority(boolean istty); \
Dec 7, 2006
Dec 7, 2006
137
138
139
140
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); \
Jul 2, 2007
Jul 2, 2007
141
142
static boolean MojoGui_##module##_promptyn(const char *t1, const char *t2, \
boolean d); \
May 17, 2007
May 17, 2007
143
static MojoGuiYNAN MojoGui_##module##_promptynan(const char *t1, \
Jul 2, 2007
Jul 2, 2007
144
const char *t2, boolean d); \
Nov 24, 2007
Nov 24, 2007
145
146
static boolean MojoGui_##module##_start(const char *t, \
const MojoGuiSplash *splash); \
Dec 20, 2006
Dec 20, 2006
147
static void MojoGui_##module##_stop(void); \
May 10, 2007
May 10, 2007
148
static int MojoGui_##module##_readme(const char *name, const uint8 *data, \
May 10, 2007
May 10, 2007
149
150
size_t len, boolean can_back, \
boolean can_fwd); \
May 10, 2007
May 10, 2007
151
static int MojoGui_##module##_options(MojoGuiSetupOptions *opts, \
May 10, 2007
May 10, 2007
152
boolean can_back, boolean can_fwd); \
May 10, 2007
May 10, 2007
153
154
static char *MojoGui_##module##_destination(const char **r, int recnum, \
int *command, boolean can_back, boolean can_fwd); \
Apr 21, 2007
Apr 21, 2007
155
static boolean MojoGui_##module##_insertmedia(const char *medianame); \
Feb 20, 2008
Feb 20, 2008
156
static void MojoGui_##module##_progressitem(void); \
May 7, 2007
May 7, 2007
157
static boolean MojoGui_##module##_progress(const char *typ, const char *comp, \
Jan 24, 2008
Jan 24, 2008
158
159
int percent, const char *item, \
boolean can_cancel); \
May 12, 2007
May 12, 2007
160
static void MojoGui_##module##_final(const char *msg); \
Dec 7, 2006
Dec 7, 2006
161
const MojoGui *MojoGuiPlugin_##module(int rev, const MojoSetupEntryPoints *e) \
Mar 25, 2006
Mar 25, 2006
162
{ \
Dec 7, 2006
Dec 7, 2006
163
164
165
166
167
168
169
170
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, \
May 17, 2007
May 17, 2007
171
MojoGui_##module##_promptynan, \
Dec 20, 2006
Dec 20, 2006
172
173
174
MojoGui_##module##_start, \
MojoGui_##module##_stop, \
MojoGui_##module##_readme, \
Dec 27, 2006
Dec 27, 2006
175
MojoGui_##module##_options, \
Dec 28, 2006
Dec 28, 2006
176
MojoGui_##module##_destination, \
Apr 21, 2007
Apr 21, 2007
177
MojoGui_##module##_insertmedia, \
Feb 20, 2008
Feb 20, 2008
178
MojoGui_##module##_progressitem, \
May 7, 2007
May 7, 2007
179
MojoGui_##module##_progress, \
May 12, 2007
May 12, 2007
180
MojoGui_##module##_final, \
Dec 7, 2006
Dec 7, 2006
181
182
}; \
entry = e; \
Nov 29, 2006
Nov 29, 2006
183
184
185
return &retval; \
} \
return NULL; \
Mar 25, 2006
Mar 25, 2006
186
187
} \
Mar 27, 2006
Mar 27, 2006
188
#define CREATE_MOJOGUI_ENTRY_POINT(module) \
Dec 7, 2006
Dec 7, 2006
189
const MojoGui *MOJOGUI_ENTRY_POINT(int rev, const MojoSetupEntryPoints *e) \
Mar 27, 2006
Mar 27, 2006
190
{ \
Dec 7, 2006
Dec 7, 2006
191
return MojoGuiPlugin_##module(rev, e); \
Mar 27, 2006
Mar 27, 2006
192
193
} \
Mar 25, 2006
Mar 25, 2006
194
#endif
Mar 25, 2006
Mar 25, 2006
195
Nov 29, 2006
Nov 29, 2006
196
197
198
/*
* make some decisions about which GUI plugins to build...
Dec 7, 2006
Dec 7, 2006
199
200
* We list them all here, but some are built, some aren't. Some are DLLs,
* some aren't...
Nov 29, 2006
Nov 29, 2006
201
202
*/
Dec 7, 2006
Dec 7, 2006
203
const MojoGui *MojoGuiPlugin_stdio(int rev, const MojoSetupEntryPoints *e);
May 19, 2007
May 19, 2007
204
const MojoGui *MojoGuiPlugin_ncurses(int rev, const MojoSetupEntryPoints *e);
May 10, 2007
May 10, 2007
205
const MojoGui *MojoGuiPlugin_gtkplus2(int rev, const MojoSetupEntryPoints *e);
Jun 1, 2007
Jun 1, 2007
206
const MojoGui *MojoGuiPlugin_www(int rev, const MojoSetupEntryPoints *e);
Dec 7, 2006
Dec 7, 2006
207
const MojoGui *MojoGuiPlugin_macosx(int rev, const MojoSetupEntryPoints *e);
Dec 1, 2006
Dec 1, 2006
208
Nov 29, 2006
Nov 29, 2006
209
210
// !!! FIXME: Qt? KDE? Gnome? Console? Cocoa?
211
212
213
214
215
216
#ifdef __cplusplus
}
#endif
#endif
Mar 25, 2006
Mar 25, 2006
217
// end of gui.h ...