Skip to content

Commit

Permalink
Let UI targets know when a new item in the progress dialog is startin…
Browse files Browse the repository at this point in the history
…g, so

 the stdio UI can always print a new line of text for each file...otherwise,
 it was printing one line every second, so it would look like you installed
 a handful of files from any package...now it's one line for each file, and
 a big file might take several lines if it writes out over several seconds.

Every other UI just treats the new entry point as a no-op, as they don't need
 the information for these purposes.
  • Loading branch information
icculus committed Feb 20, 2008
1 parent 1826dc1 commit 4789545
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 2 deletions.
5 changes: 4 additions & 1 deletion gui.h
Expand Up @@ -80,7 +80,7 @@ struct MojoGuiSplash
#define MOJOGUI_ENTRY_POINT_STR DEFINE_TO_STR(MOJOGUI_ENTRY_POINT)

// Increment this value when MojoGui's structure changes.
#define MOJOGUI_INTERFACE_REVISION 4
#define MOJOGUI_INTERFACE_REVISION 5

typedef struct MojoGui MojoGui;
struct MojoGui
Expand All @@ -101,6 +101,7 @@ struct MojoGui
char * (*destination)(const char **recommendations, int recnum,
int *command, boolean can_back, boolean can_fwd);
boolean (*insertmedia)(const char *medianame);
void (*progressitem)(void);
boolean (*progress)(const char *type, const char *component,
int percent, const char *item, boolean can_cancel);
void (*final)(const char *msg);
Expand Down Expand Up @@ -152,6 +153,7 @@ static int MojoGui_##module##_options(MojoGuiSetupOptions *opts, \
static char *MojoGui_##module##_destination(const char **r, int recnum, \
int *command, boolean can_back, boolean can_fwd); \
static boolean MojoGui_##module##_insertmedia(const char *medianame); \
static void MojoGui_##module##_progressitem(void); \
static boolean MojoGui_##module##_progress(const char *typ, const char *comp, \
int percent, const char *item, \
boolean can_cancel); \
Expand All @@ -173,6 +175,7 @@ const MojoGui *MojoGuiPlugin_##module(int rev, const MojoSetupEntryPoints *e) \
MojoGui_##module##_options, \
MojoGui_##module##_destination, \
MojoGui_##module##_insertmedia, \
MojoGui_##module##_progressitem, \
MojoGui_##module##_progress, \
MojoGui_##module##_final, \
}; \
Expand Down
6 changes: 6 additions & 0 deletions gui_gtkplus2.c
Expand Up @@ -794,6 +794,12 @@ static boolean MojoGui_gtkplus2_insertmedia(const char *medianame)
} // MojoGui_gtkplus2_insertmedia


static void MojoGui_gtkplus2_progressitem(void)
{
// no-op in this UI target.
} // MojoGui_gtkplus2_progressitem


static boolean MojoGui_gtkplus2_progress(const char *type, const char *component,
int percent, const char *item,
boolean can_cancel)
Expand Down
6 changes: 6 additions & 0 deletions gui_macosx.c
Expand Up @@ -196,6 +196,12 @@ static boolean MojoGui_macosx_insertmedia(const char *medianame)
} // MojoGui_macosx_insertmedia


static void MojoGui_macosx_progressitem(void)
{
STUBBED("macosx progressitem");
} // MojoGui_macosx_progressitem


static int MojoGui_macosx_progress(const char *type, const char *component,
int percent, const char *item,
boolean can_cancel)
Expand Down
6 changes: 6 additions & 0 deletions gui_ncurses.c
Expand Up @@ -1357,6 +1357,12 @@ static boolean MojoGui_ncurses_insertmedia(const char *medianame)
} // MojoGui_ncurses_insertmedia


static void MojoGui_ncurses_progressitem(void)
{
// no-op in this UI target.
} // MojoGui_ncurses_progressitem


static boolean MojoGui_ncurses_progress(const char *type, const char *component,
int percent, const char *item,
boolean can_cancel)
Expand Down
11 changes: 10 additions & 1 deletion gui_stdio.c
Expand Up @@ -599,6 +599,13 @@ static boolean MojoGui_stdio_insertmedia(const char *medianame)
} // MojoGui_stdio_insertmedia


static void MojoGui_stdio_progressitem(void)
{
// force new line of output on next call to MojoGui_stdio_progress()
percentTicks = 0;
} // MojoGui_stdio_progressitem


static boolean MojoGui_stdio_progress(const char *type, const char *component,
int percent, const char *item,
boolean can_cancel)
Expand All @@ -617,7 +624,9 @@ static boolean MojoGui_stdio_progress(const char *type, const char *component,
printf("%s\n%s\n", type, component);
} // if

// limit update spam... will only write every one second, tops.
// limit update spam... will only write every one second, tops,
// on any given filename, but it writes each filename at least once
// so it doesn't look like we only installed a few things.
if (percentTicks <= now)
{
char *fmt = NULL;
Expand Down
6 changes: 6 additions & 0 deletions gui_www.c
Expand Up @@ -1015,6 +1015,12 @@ static boolean MojoGui_www_insertmedia(const char *medianame)
} // MojoGui_www_insertmedia


static void MojoGui_www_progressitem(void)
{
// no-op in this UI target.
} // MojoGui_www_progressitem


static boolean MojoGui_www_progress(const char *type, const char *component,
int percent, const char *item,
boolean can_cancel)
Expand Down
8 changes: 8 additions & 0 deletions lua_glue.c
Expand Up @@ -1491,6 +1491,13 @@ static int luahook_gui_insertmedia(lua_State *L)
} // luahook_gui_insertmedia


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


static int luahook_gui_progress(lua_State *L)
{
const char *type = luaL_checkstring(L, 1);
Expand Down Expand Up @@ -1694,6 +1701,7 @@ boolean MojoLua_initLua(void)
set_cfunc(luaState, luahook_gui_options, "options");
set_cfunc(luaState, luahook_gui_destination, "destination");
set_cfunc(luaState, luahook_gui_insertmedia, "insertmedia");
set_cfunc(luaState, luahook_gui_progressitem, "progressitem");
set_cfunc(luaState, luahook_gui_progress, "progress");
set_cfunc(luaState, luahook_gui_final, "final");
set_cfunc(luaState, luahook_gui_stop, "stop");
Expand Down
3 changes: 3 additions & 0 deletions scripts/mojosetup_mainline.lua
Expand Up @@ -397,6 +397,7 @@ local function install_file(dest, perms, writefn, desc, manifestkey)
-- !!! FIXME: perms may be nil...we need a MojoSetup.defaultPermsString()...
manifest_add(MojoSetup.manifest, dest, manifestkey, "file", perms, nil, nil)

MojoSetup.gui.progressitem()
local written, sums = writefn(callback)
if not written then
if not keepgoing then
Expand Down Expand Up @@ -1456,6 +1457,7 @@ local function do_install(install)
end

MojoSetup.loginfo("Download '" .. url .. "' to '" .. f .. "'")
MojoSetup.gui.progressitem()
local downloaded, sums = MojoSetup.download(url, f, nil, nil, callback)
if not downloaded then
MojoSetup.fatal(_("File download failed!"))
Expand Down Expand Up @@ -1813,6 +1815,7 @@ local function uninstaller()
end

local item = string.gsub(fname, "^.*/", "", 1) -- chop off dirs...
MojoSetup.gui.progressitem()
MojoSetup.gui.progress(ptype, component, percent, item, false)
return true -- !!! FIXME: need to disable cancel button in UI...
end
Expand Down

0 comments on commit 4789545

Please sign in to comment.