Skip to content

Commit

Permalink
Added first shot at GUI "insertmedia" entry point. Untested!
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Apr 21, 2007
1 parent b93bfcb commit ecaaff2
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 6 deletions.
3 changes: 3 additions & 0 deletions gui.h
Expand Up @@ -57,6 +57,7 @@ struct MojoGui
boolean can_go_back, boolean can_go_forward);
char * (*destination)(const char **recommendations, int reccount,
boolean can_go_back, boolean can_go_forward);
boolean (*insertmedia)(const char *medianame);
};

typedef const MojoGui* (*MojoGuiEntryPoint)(int revision,
Expand Down Expand Up @@ -93,6 +94,7 @@ static boolean MojoGui_##module##_options(MojoGuiSetupOptions *opts, \
boolean can_go_back, boolean can_go_forward); \
static char *MojoGui_##module##_destination(const char **r, int reccount, \
boolean can_go_back, boolean can_go_forward); \
static boolean MojoGui_##module##_insertmedia(const char *medianame); \
const MojoGui *MojoGuiPlugin_##module(int rev, const MojoSetupEntryPoints *e) \
{ \
if (rev == MOJOGUI_INTERFACE_REVISION) { \
Expand All @@ -108,6 +110,7 @@ const MojoGui *MojoGuiPlugin_##module(int rev, const MojoSetupEntryPoints *e) \
MojoGui_##module##_readme, \
MojoGui_##module##_options, \
MojoGui_##module##_destination, \
MojoGui_##module##_insertmedia, \
}; \
entry = e; \
return &retval; \
Expand Down
22 changes: 16 additions & 6 deletions gui/gui_macosx.c
Expand Up @@ -83,7 +83,8 @@ static void MojoGui_macosx_msgbox(const char *title, const char *text)
} // MojoGui_macosx_msgbox


static boolean do_promptyn(const char *title, const char *text, boolean yes)
static boolean do_prompt(const char *title, const char *text,
boolean yes, const char *yesstr, const char *nostr)
{
boolean retval = false;
OSStatus err = noErr;
Expand All @@ -95,8 +96,8 @@ static boolean do_promptyn(const char *title, const char *text, boolean yes)
DialogItemIndex item;
CFStringRef yes, no;
const CFStringEncoding enc = kCFStringEncodingUTF8;
yes = CFStringCreateWithCString(NULL, entry->_("Yes"), enc);
no = CFStringCreateWithCString(NULL, entry->_("No"), enc);
yes = CFStringCreateWithCString(NULL, yesstr, enc);
no = CFStringCreateWithCString(NULL, nostr, enc);

params.movable = TRUE;
params.helpButton = FALSE;
Expand All @@ -118,13 +119,13 @@ static boolean do_promptyn(const char *title, const char *text, boolean yes)

static boolean MojoGui_macosx_promptyn(const char *title, const char *text)
{
return do_promptyn(title, text, true);
}
return do_prompt(title, text, true, entry->_("Yes"), entry->_("No"));
} // MojoGui_macosx_promptyn


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


Expand Down Expand Up @@ -159,5 +160,14 @@ static char *MojoGui_macosx_destination(const char **recommends, int reccount,
return entry->xstrdup("/Applications");
} // MojoGui_macosx_destination


static boolean MojoGui_macosx_insertmedia(const char *medianame)
{
// !!! FIXME: "please insert '%s' ..."
// !!! FIXME: localization.
return do_prompt("Please insert", medianame, true,
entry->_("OK"), entry->_("Cancel"));
} // MojoGui_macosx_insertmedia

// end of gui_macosx.c ...

8 changes: 8 additions & 0 deletions gui/gui_stdio.c
Expand Up @@ -308,5 +308,13 @@ static char *MojoGui_stdio_destination(const char **recommends, int reccount,
return retval;
} // MojoGui_stdio_destination


static boolean MojoGui_stdio_insertmedia(const char *medianame)
{
char buf[32];
printf(entry->_("Please insert '%s'\n"), medianame);
return readstr(NULL, buf, sizeof (buf), false, true) > 0;
} // MojoGui_stdio_insertmedia

// end of gui_stdio.c ...

9 changes: 9 additions & 0 deletions lua/localization.lua
Expand Up @@ -56,6 +56,12 @@ MojoSetup.localization = {
["No"] = {
};

["OK"] = {
};

["Cancel"] = {
};

["Press enter to continue."] = {
};

Expand Down Expand Up @@ -111,6 +117,9 @@ MojoSetup.localization = {

["failed to load file '%s'"] = {
};

["Please insert '%s'\n"] = {
};
};

-- end of localization.lua ...
Expand Down
8 changes: 8 additions & 0 deletions lua_glue.c
Expand Up @@ -804,6 +804,13 @@ static int luahook_gui_destination(lua_State *L)
} // luahook_gui_destination


static int luahook_gui_insertmedia(lua_State *L)
{
lua_pushboolean(L, GGui->insertmedia(luaL_checkstring(L, 1)));
return 1;
} // luahook_gui_insertmedia


// 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 @@ -919,6 +926,7 @@ boolean MojoLua_initLua(void)
set_cfunc(luaState, luahook_gui_options, "options");
set_cfunc(luaState, luahook_gui_destination, "destination");
set_cfunc(luaState, luahook_gui_stop, "stop");
set_cfunc(luaState, luahook_gui_insertmedia, "insertmedia");
lua_setfield(luaState, -2, "gui");
lua_setglobal(luaState, MOJOSETUP_NAMESPACE);

Expand Down

0 comments on commit ecaaff2

Please sign in to comment.