Skip to content

Commit

Permalink
Initial GUI wankery. Nothing of note yet.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Dec 12, 2006
1 parent a0ac563 commit a13f994
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 5 deletions.
6 changes: 6 additions & 0 deletions gui.h
Expand Up @@ -37,6 +37,8 @@ struct MojoGui
void (*deinit)(void);
void (*msgbox)(const char *title, const char *text);
boolean (*promptyn)(const char *title, const char *text);
boolean (*startgui)(const char *title, const char *splash);
void (*endgui)(void);
};

typedef const MojoGui* (*MojoGuiEntryPoint)(int revision,
Expand Down Expand Up @@ -64,6 +66,8 @@ 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); \
static boolean MojoGui_##module##_startgui(const char *t, const char *s); \
static void MojoGui_##module##_endgui(void); \
const MojoGui *MojoGuiPlugin_##module(int rev, const MojoSetupEntryPoints *e) \
{ \
if (rev == MOJOGUI_INTERFACE_REVISION) { \
Expand All @@ -74,6 +78,8 @@ const MojoGui *MojoGuiPlugin_##module(int rev, const MojoSetupEntryPoints *e) \
MojoGui_##module##_deinit, \
MojoGui_##module##_msgbox, \
MojoGui_##module##_promptyn, \
MojoGui_##module##_startgui, \
MojoGui_##module##_endgui, \
}; \
entry = e; \
return &retval; \
Expand Down
22 changes: 22 additions & 0 deletions gui/gui_macosx.c
Expand Up @@ -24,6 +24,17 @@ static uint8 MojoGui_macosx_priority(void)

static boolean MojoGui_macosx_init(void)
{
// This lets a stdio app become a GUI app. Otherwise, you won't get
// GUI events from the system and other things will fail to work.
// Putting the app in an application bundle does the same thing.
// TransformProcessType() is a 10.3+ API. SetFrontProcess() is 10.0+.
if (TransformProcessType != NULL) // check it as a weak symbol.
{
ProcessSerialNumber psn = { 0, kCurrentProcess };
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
SetFrontProcess(&psn);
} // if

return true;
} // MojoGui_macosx_init

Expand Down Expand Up @@ -110,5 +121,16 @@ static boolean MojoGui_macosx_promptyn(const char *title, const char *text)
return do_promptyn(title, text, true);
}

static boolean MojoGui_macosx_startgui(const char *title, const char *splash)
{
return false; // !!! FIXME
} // MojoGui_macosx_startgui


static void MojoGui_macosx_endgui(void)
{
// no-op.
} // MojoGui_macosx_endgui

// end of gui_macosx.c ...

12 changes: 12 additions & 0 deletions gui/gui_stdio.c
Expand Up @@ -56,5 +56,17 @@ static boolean MojoGui_stdio_promptyn(const char *title, const char *text)
return 0;
}

static boolean MojoGui_stdio_startgui(const char *title, const char *splash)
{
printf("%s\n", title);
return true;
} // MojoGui_stdio_startgui


static void MojoGui_stdio_endgui(void)
{
// no-op.
} // MojoGui_stdio_endgui

// end of gui_stdio.c ...

3 changes: 3 additions & 0 deletions lua/localization.lua
Expand Up @@ -56,6 +56,9 @@ MojoSetup.localization = {

["PANIC"] = {
};

["GUI failed to start"] = {
};
};

-- end of localization.lua ...
Expand Down
13 changes: 9 additions & 4 deletions lua/mojosetup_mainline.lua
@@ -1,14 +1,19 @@

local _ = MojoSetup.translate;
local _ = MojoSetup.translate
local saw_an_installer = false

for i in pairs(MojoSetup.installs) do

for k,install in pairs(MojoSetup.installs) do
saw_an_installer = true
if (not MojoSetup.startgui(install.desc, install.splash)) then
MojoSetup.fatal(_("GUI failed to start"))
end


MojoSetup.endgui()
end

if (not saw_an_installer) then
MojoSetup.fatal(_("Nothing to do!"));
MojoSetup.fatal(_("Nothing to do!"))
end

-- end of mojosetup_mainline.lua ...
Expand Down
21 changes: 20 additions & 1 deletion lua_glue.c
Expand Up @@ -185,8 +185,9 @@ static int luahook_debugger(lua_State *L)

lua_pop(L, 1);
printf("exiting debugger...\n");
return 0;
#endif

return 0;
} // luahook_debugger


Expand Down Expand Up @@ -449,6 +450,22 @@ static int luahook_cmdlinestr(lua_State *L)
} // luahook_cmdlinestr


static int luahook_startgui(lua_State *L)
{
const char *title = luaL_checkstring(L, 1);
const char *splash = lua_tostring(L, 2);
lua_pushboolean(L, GGui->startgui(title, splash));
return 1;
} // luahook_startgui


static int luahook_endgui(lua_State *L)
{
GGui->endgui();
return 0;
} // luahook_endgui


// Sets t[sym]=f, where t is on the top of the Lua stack.
static inline void set_cfunc(lua_State *L, lua_CFunction f, const char *sym)
{
Expand Down Expand Up @@ -543,6 +560,8 @@ boolean MojoLua_initLua(void)
set_cfunc(luaState, luahook_cmdlinestr, "cmdlinestr");
set_cfunc(luaState, luahook_collectgarbage, "collectgarbage");
set_cfunc(luaState, luahook_debugger, "debugger");
set_cfunc(luaState, luahook_startgui, "startgui");
set_cfunc(luaState, luahook_endgui, "endgui");
set_string(luaState, locale, "locale");
set_string(luaState, PLATFORM_NAME, "platform");
set_string(luaState, PLATFORM_ARCH, "arch");
Expand Down

0 comments on commit a13f994

Please sign in to comment.