Skip to content

Commit

Permalink
Added a final status screen.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed May 12, 2007
1 parent 96cb5ca commit 06c8872
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 8 deletions.
3 changes: 3 additions & 0 deletions gui.h
Expand Up @@ -61,6 +61,7 @@ struct MojoGui
boolean (*insertmedia)(const char *medianame);
boolean (*progress)(const char *type, const char *component,
int percent, const char *item);
void (*final)(const char *msg);
};

typedef const MojoGui* (*MojoGuiEntryPoint)(int revision,
Expand Down Expand Up @@ -100,6 +101,7 @@ static char *MojoGui_##module##_destination(const char **r, int recnum, \
static boolean MojoGui_##module##_insertmedia(const char *medianame); \
static boolean MojoGui_##module##_progress(const char *typ, const char *comp, \
int percent, const char *item); \
static void MojoGui_##module##_final(const char *msg); \
const MojoGui *MojoGuiPlugin_##module(int rev, const MojoSetupEntryPoints *e) \
{ \
if (rev == MOJOGUI_INTERFACE_REVISION) { \
Expand All @@ -117,6 +119,7 @@ const MojoGui *MojoGuiPlugin_##module(int rev, const MojoSetupEntryPoints *e) \
MojoGui_##module##_destination, \
MojoGui_##module##_insertmedia, \
MojoGui_##module##_progress, \
MojoGui_##module##_final, \
}; \
entry = e; \
return &retval; \
Expand Down
27 changes: 24 additions & 3 deletions gui_gtkplus2.c
Expand Up @@ -29,7 +29,7 @@ typedef enum
PAGE_OPTIONS,
PAGE_DESTINATION,
PAGE_PROGRESS,
PAGE_STATUS
PAGE_FINAL
} WizardPages;

static GtkWidget *gtkwindow = NULL;
Expand All @@ -39,10 +39,12 @@ static GtkWidget *readme = NULL;
static GtkWidget *cancel = NULL;
static GtkWidget *back = NULL;
static GtkWidget *next = NULL;
static GtkWidget *finish = NULL;
static GtkWidget *msgbox = NULL;
static GtkWidget *destination = NULL;
static GtkWidget *progressbar = NULL;
static GtkWidget *progresslabel = NULL;
static GtkWidget *finallabel = NULL;
static GtkWidget *componentlabel = NULL;

static volatile enum
Expand Down Expand Up @@ -134,7 +136,7 @@ static void signal_clicked(GtkButton *_button, gpointer data)
click_value = CLICK_BACK;
else if (button == cancel)
click_value = CLICK_CANCEL;
else if (button == next)
else if ((button == next) || (button == finish))
click_value = CLICK_NEXT;
else
{
Expand Down Expand Up @@ -273,6 +275,8 @@ GtkWidget *create_gtkwindow(const char *title)
cancel = create_button(box, "gtk-cancel", entry->_("Cancel"));
back = create_button(box, "gtk-go-back", entry->_("Back"));
next = create_button(box, "gtk-go-forward", entry->_("Next"));
finish = create_button(box, "gtk-goto-last", entry->_("Finish"));
gtk_widget_hide(finish);

// !!! FIXME: intro page.
widget = gtk_vbox_new(FALSE, 0);
Expand Down Expand Up @@ -343,10 +347,15 @@ GtkWidget *create_gtkwindow(const char *title)
gtk_label_set_line_wrap(GTK_LABEL(progresslabel), FALSE);
gtk_container_add(GTK_CONTAINER(notebook), box);

// !!! FIXME: status page.
// !!! FIXME: final page.
widget = gtk_vbox_new(FALSE, 0);
gtk_widget_show(widget);
gtk_container_add(GTK_CONTAINER(notebook), widget);
finallabel = gtk_label_new("");
gtk_widget_show(finallabel);
gtk_box_pack_start(GTK_BOX(widget), finallabel, FALSE, TRUE, 0);
gtk_label_set_justify(GTK_LABEL(finallabel), GTK_JUSTIFY_LEFT);
gtk_label_set_line_wrap(GTK_LABEL(finallabel), FALSE);

gtk_signal_connect(GTK_OBJECT(window), "delete-event",
GTK_SIGNAL_FUNC(signal_delete), NULL);
Expand All @@ -373,6 +382,7 @@ static void MojoGui_gtkplus2_stop(void)
gtkwindow = NULL;
pagetitle = NULL;
componentlabel = NULL;
finallabel = NULL;
progresslabel = NULL;
progressbar = NULL;
destination = NULL;
Expand All @@ -381,6 +391,7 @@ static void MojoGui_gtkplus2_stop(void)
cancel = NULL;
back = NULL;
next = NULL;
finish = NULL;
} // MojoGui_gtkplus2_stop


Expand Down Expand Up @@ -596,5 +607,15 @@ static boolean MojoGui_gtkplus2_progress(const char *type, const char *component
return (rc != CLICK_CANCEL);
} // MojoGui_gtkplus2_progress


static void MojoGui_gtkplus2_final(const char *msg)
{
gtk_widget_hide(next);
gtk_widget_show(finish);
gtk_widget_set_sensitive(cancel, FALSE);
gtk_label_set_text(GTK_LABEL(finallabel), msg);
run_wizard(entry->_("Finish"), PAGE_FINAL, false, true);
} // MojoGui_gtkplus2_final

// end of gui_gtkplus2.c ...

8 changes: 8 additions & 0 deletions gui_macosx.c
Expand Up @@ -171,6 +171,7 @@ static boolean MojoGui_macosx_insertmedia(const char *medianame)
entry->_("OK"), entry->_("Cancel"));
} // MojoGui_macosx_insertmedia


static int MojoGui_macosx_progress(const char *type, const char *component,
int percent, const char *item)
{
Expand All @@ -179,5 +180,12 @@ static int MojoGui_macosx_progress(const char *type, const char *component,
return 1;
} // MojoGui_macosx_progress


static void MojoGui_macosx_final(const char *msg)
{
// !!! FIXME: write me.
STUBBED(__FUNCTION__)
} // MojoGui_macosx_final

// end of gui_macosx.c ...

12 changes: 9 additions & 3 deletions gui_stdio.c
Expand Up @@ -73,16 +73,15 @@ static uint8 MojoGui_stdio_priority(void)

static boolean MojoGui_stdio_init(void)
{
free(lastComponent);
lastComponent = NULL;
percentTicks = 0;
return true; // always succeeds.
} // MojoGui_stdio_init


static void MojoGui_stdio_deinit(void)
{
// no-op
free(lastComponent);
lastComponent = NULL;
} // MojoGui_stdio_deinit


Expand Down Expand Up @@ -356,5 +355,12 @@ static boolean MojoGui_stdio_progress(const char *type, const char *component,
return true;
} // MojoGui_stdio_progress


static void MojoGui_stdio_final(const char *msg)
{
printf("%s\n\n", msg);
fflush(stdout);
} // MojoGui_stdio_final

// end of gui_stdio.c ...

9 changes: 9 additions & 0 deletions lua_glue.c
Expand Up @@ -1163,6 +1163,14 @@ static int luahook_gui_progress(lua_State *L)
} // luahook_gui_progress


static int luahook_gui_final(lua_State *L)
{
const char *msg = luaL_checkstring(L, 1);
GGui->final(msg);
return 0;
} // luahook_gui_final


static const char *logLevelString(void)
{
switch (MojoLog_logLevel)
Expand Down Expand Up @@ -1339,6 +1347,7 @@ boolean MojoLua_initLua(void)
set_cfunc(luaState, luahook_gui_destination, "destination");
set_cfunc(luaState, luahook_gui_insertmedia, "insertmedia");
set_cfunc(luaState, luahook_gui_progress, "progress");
set_cfunc(luaState, luahook_gui_final, "final");
set_cfunc(luaState, luahook_gui_stop, "stop");
lua_setfield(luaState, -2, "gui");

Expand Down
1 change: 0 additions & 1 deletion mojosetup.c
Expand Up @@ -348,7 +348,6 @@ int fatal(const char *fmt, ...)
GGui->msgbox(_("Fatal error"), buf);
free(buf);

//GGui->status(_("There were errors. Click 'OK' to clean up and exit."));
MojoLua_callProcedure("revertinstall");

deinitEverything();
Expand Down
17 changes: 16 additions & 1 deletion scripts/mojosetup_mainline.lua
Expand Up @@ -68,8 +68,14 @@ end

-- This gets called by fatal()...must be a global function.
function MojoSetup.revertinstall()
-- !!! FIXME: language.
if MojoSetup.gui_started then
MojoSetup.gui.final(_("There were errors. We will now put things back how we found them and exit."));
end

MojoSetup.loginfo("Cleaning up half-finished installation...");

-- !!! FIXME: callbacks here.
delete_files(MojoSetup.downloads)
delete_files(MojoSetup.installed_files)
do_rollbacks()
Expand Down Expand Up @@ -748,13 +754,21 @@ local function do_install(install)

run_config_defined_hook(install.postinstall, install)

-- Next stage: show results gui (!!! FIXME: write me.)
-- Next stage: show results gui
stages[#stages+1] = function(thisstage, maxstage)
-- !!! FIXME: language.
MojoSetup.gui.final(_("Installation was successful."))
return 1 -- go forward.
end


-- Now make all this happen.
if not MojoSetup.gui.start(install.description, install.splash) then
MojoSetup.fatal(_("GUI failed to start"))
end

MojoSetup.gui_started = true

-- Make the stages available elsewhere.
MojoSetup.stages = stages

Expand Down Expand Up @@ -800,6 +814,7 @@ local function do_install(install)
MojoSetup.rollbacks = nil

MojoSetup.gui.stop()
MojoSetup.gui_started = nil

-- Done with these things. Make them eligible for garbage collection.
stages = nil
Expand Down

0 comments on commit 06c8872

Please sign in to comment.