зеркало из https://github.com/mozilla/pjs.git
Progress bar and message changes. [b=38035]
This commit is contained in:
Родитель
17bd94e435
Коммит
90cb4e1cf6
|
@ -52,7 +52,9 @@
|
|||
#define DOWNLOADING "Downloading..."
|
||||
#define PREPARING "Preparing installer modules..."
|
||||
#define EXTRACTING "Extracting installer files..."
|
||||
#define INSTALLING "Installing"
|
||||
#define INSTALLING "Installing..."
|
||||
#define INSTALLING_XPI "Installing %s..."
|
||||
#define PROCESSING_FILE "Processing file %d of %d..."
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------*
|
||||
|
|
|
@ -114,6 +114,7 @@ nsInstallDlg::Next(GtkWidget *aWidget, gpointer aData)
|
|||
|
||||
*me = pthread_self();
|
||||
pthread_create(&ength, NULL, WorkDammitWork, (void*) me);
|
||||
pthread_detach(ength);
|
||||
|
||||
gtk_timeout_add(1, ProgressUpdater, NULL);
|
||||
|
||||
|
@ -321,10 +322,13 @@ nsInstallDlg::WorkDammitWork(void *arg)
|
|||
|
||||
// destroy xpiengine
|
||||
XI_IF_DELETE(xpiengine);
|
||||
|
||||
// XXX call gCtx->me->Shutdown(); ???
|
||||
gtk_main_quit();
|
||||
exit(0);
|
||||
|
||||
gCtx->bDone = TRUE;
|
||||
gCtx->threadTurn = nsXIContext::UI_THREAD;
|
||||
pthread_cond_signal(&gCtx->prog_cv);
|
||||
pthread_mutex_unlock(&gCtx->prog_mutex);
|
||||
pthread_exit((void *) 0);
|
||||
return ((void *) 0); // XXX which one?
|
||||
|
||||
BAIL:
|
||||
// destroy xpiengine
|
||||
|
@ -344,6 +348,15 @@ nsInstallDlg::ProgressUpdater(gpointer aData)
|
|||
while (gtk_events_pending())
|
||||
gtk_main_iteration();
|
||||
|
||||
if (gCtx->bDone)
|
||||
{
|
||||
pthread_cond_destroy(&gCtx->prog_cv);
|
||||
pthread_mutex_destroy(&gCtx->prog_mutex);
|
||||
|
||||
gtk_main_quit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (sActivity)
|
||||
{
|
||||
case nsInstallDlg::ACT_DOWNLOAD:
|
||||
|
@ -367,14 +380,14 @@ nsInstallDlg::ProgressUpdater(gpointer aData)
|
|||
// DUMP("Installing...");
|
||||
if (!bInstallStarted)
|
||||
{
|
||||
gtk_label_set_text(GTK_LABEL(sMajorLabel), "Installing...");
|
||||
gtk_label_set_text(GTK_LABEL(sMajorLabel), INSTALLING);
|
||||
gtk_widget_show(sMajorLabel);
|
||||
|
||||
bInstallStarted = TRUE;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&gCtx->prog_mutex);
|
||||
while (gCtx->threadTurn != nsXIContext::UI_THREAD)
|
||||
while (gCtx->threadTurn != nsXIContext::UI_THREAD && !gCtx->bDone)
|
||||
pthread_cond_wait(&gCtx->prog_cv, &gCtx->prog_mutex);
|
||||
|
||||
gtk_widget_show(sMinorLabel);
|
||||
|
@ -382,7 +395,9 @@ nsInstallDlg::ProgressUpdater(gpointer aData)
|
|||
gtk_widget_draw(sMinorLabel, NULL);
|
||||
gtk_widget_draw(sMinorProgBar, NULL);
|
||||
|
||||
gCtx->threadTurn = nsXIContext::ENGINE_THREAD;
|
||||
if (!gCtx->bDone)
|
||||
gCtx->threadTurn = nsXIContext::ENGINE_THREAD;
|
||||
|
||||
pthread_mutex_unlock(&gCtx->prog_mutex);
|
||||
|
||||
status = 1;
|
||||
|
@ -400,20 +415,21 @@ nsInstallDlg::XPIProgressCB(const char *aMsg, int aVal, int aMax)
|
|||
{
|
||||
// DUMP("XPIProgressCB");
|
||||
|
||||
char msg[32];
|
||||
char msg[64];
|
||||
char *colon = NULL, *lastSlash = NULL;
|
||||
memset(msg, 0, 64);
|
||||
|
||||
if (aMax != 0)
|
||||
if (aMax > 0)
|
||||
{
|
||||
gfloat percent = aVal/aMax;
|
||||
gfloat percent = (gfloat)((gfloat)aVal/(gfloat)aMax);
|
||||
#ifdef DEBUG
|
||||
printf("progress percent: %f\n", percent);
|
||||
printf("progress percent: %f\taVal: %d\taMax: %d\n", percent, aVal, aMax);
|
||||
#endif
|
||||
gtk_progress_set_activity_mode(GTK_PROGRESS(sMinorProgBar), FALSE);
|
||||
gtk_progress_bar_update(GTK_PROGRESS_BAR(sMinorProgBar), percent);
|
||||
gtk_widget_show(sMinorProgBar);
|
||||
|
||||
sprintf(msg, "Processing file %d of %d", aVal, aMax);
|
||||
gtk_label_set_text(GTK_LABEL(sMinorLabel), msg);
|
||||
sprintf(msg, PROCESSING_FILE, aVal, aMax);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -421,10 +437,23 @@ nsInstallDlg::XPIProgressCB(const char *aMsg, int aVal, int aMax)
|
|||
gtk_progress_bar_update(GTK_PROGRESS_BAR(sMinorProgBar), 1);
|
||||
gtk_widget_show(sMinorProgBar);
|
||||
|
||||
gtk_label_set_text(GTK_LABEL(sMinorLabel), aMsg);
|
||||
/* tack on XPInstall action */
|
||||
colon = strchr(aMsg, ':');
|
||||
if (colon)
|
||||
strncpy(msg, aMsg, colon - aMsg);
|
||||
|
||||
strncat(msg, " ", 1);
|
||||
|
||||
/* tack on leaf name */
|
||||
lastSlash = strrchr(aMsg, '/');
|
||||
if (lastSlash)
|
||||
strncat(msg, lastSlash + 1, strlen(lastSlash) - 1);
|
||||
|
||||
strncat(msg, "\0", 1);
|
||||
}
|
||||
|
||||
gtk_widget_show(sMinorLabel);
|
||||
gtk_label_set_text(GTK_LABEL(sMinorLabel), msg);
|
||||
gtk_widget_draw(sMinorLabel, NULL);
|
||||
|
||||
while (gtk_events_pending())
|
||||
gtk_main_iteration();
|
||||
|
@ -441,15 +470,17 @@ nsInstallDlg::MajorProgressCB(char *aCompName, int aCompNum, int aTotalComps)
|
|||
return;
|
||||
|
||||
memset(msg, 0, 256);
|
||||
sprintf(msg, "%s %s...", INSTALLING, aCompName);
|
||||
|
||||
sprintf(msg, INSTALLING_XPI, aCompName);
|
||||
|
||||
gtk_label_set_text(GTK_LABEL(sMajorLabel), "");
|
||||
gtk_widget_show(sMajorLabel);
|
||||
gtk_label_set_text(GTK_LABEL(sMajorLabel), msg);
|
||||
gtk_widget_show(sMajorLabel);
|
||||
|
||||
if (aTotalComps <= 0)
|
||||
return;
|
||||
|
||||
gfloat percent = aCompNum/aTotalComps;
|
||||
gfloat percent = (gfloat)((gfloat)aCompNum/(gfloat)aTotalComps);
|
||||
gtk_progress_bar_update(GTK_PROGRESS_BAR(sMajorProgBar), percent);
|
||||
gtk_widget_show(sMajorProgBar);
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@ static gint sBrowseBtnID;
|
|||
static GtkWidget *sFolder;
|
||||
static GSList *sGroup;
|
||||
static GtkWidget *sCreateDestDlg;
|
||||
static int sFilePickerUp = FALSE;
|
||||
static int sConfirmCreateUp = FALSE;
|
||||
|
||||
nsSetupTypeDlg::nsSetupTypeDlg() :
|
||||
mMsg0(NULL),
|
||||
|
@ -80,6 +82,10 @@ nsSetupTypeDlg::Next(GtkWidget *aWidget, gpointer aData)
|
|||
return;
|
||||
}
|
||||
|
||||
// creation confirmation dlg still up
|
||||
if (sConfirmCreateUp)
|
||||
return;
|
||||
|
||||
// verify selected destination directory exists
|
||||
if (OK != nsSetupTypeDlg::VerifyDestination())
|
||||
return;
|
||||
|
@ -529,13 +535,10 @@ nsSetupTypeDlg::SelectFolder(GtkWidget *aWidget, gpointer aData)
|
|||
"clicked", (GtkSignalFunc) SelectFolderOK, fileSel);
|
||||
gtk_signal_connect_object(GTK_OBJECT(
|
||||
GTK_FILE_SELECTION(fileSel)->cancel_button),
|
||||
"clicked", (GtkSignalFunc) gtk_widget_destroy,
|
||||
"clicked", (GtkSignalFunc) SelectFolderCancel,
|
||||
GTK_OBJECT(fileSel));
|
||||
gtk_widget_show(fileSel);
|
||||
|
||||
|
||||
|
||||
// XXX very much incomplete...
|
||||
sFilePickerUp = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -558,6 +561,16 @@ nsSetupTypeDlg::SelectFolderOK(GtkWidget *aWidget, GtkFileSelection *aFileSel)
|
|||
|
||||
// tear down file sel dlg
|
||||
gtk_object_destroy(GTK_OBJECT(aFileSel));
|
||||
sFilePickerUp = FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
nsSetupTypeDlg::SelectFolderCancel(GtkWidget *aWidget,
|
||||
GtkFileSelection *aFileSel)
|
||||
{
|
||||
// tear down file sel dlg
|
||||
gtk_object_destroy(GTK_OBJECT(aFileSel));
|
||||
sFilePickerUp = FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -602,6 +615,7 @@ nsSetupTypeDlg::VerifyDestination()
|
|||
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(sCreateDestDlg)->vbox), label);
|
||||
|
||||
gtk_widget_show_all(sCreateDestDlg);
|
||||
sConfirmCreateUp = TRUE;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
@ -613,6 +627,7 @@ nsSetupTypeDlg::CreateDestYes(GtkWidget *aWidget, gpointer aData)
|
|||
int err = 0;
|
||||
err = mkdir(gCtx->opt->mDestination, 0755);
|
||||
gtk_widget_destroy(sCreateDestDlg);
|
||||
sConfirmCreateUp = FALSE;
|
||||
|
||||
if (err != 0)
|
||||
{
|
||||
|
@ -641,4 +656,5 @@ nsSetupTypeDlg::CreateDestNo(GtkWidget *aWidget, gpointer aData)
|
|||
DUMP("CreateDestNo");
|
||||
|
||||
gtk_widget_destroy(sCreateDestDlg);
|
||||
sConfirmCreateUp = FALSE;
|
||||
}
|
||||
|
|
|
@ -49,6 +49,8 @@ public:
|
|||
static void SelectFolder(GtkWidget *aWidget, gpointer aData);
|
||||
static void SelectFolderOK(GtkWidget *aWidget,
|
||||
GtkFileSelection *aFileSel);
|
||||
static void SelectFolderCancel(GtkWidget *aWidget,
|
||||
GtkFileSelection *aFileSel);
|
||||
static void RadBtnToggled(GtkWidget *aWidget, gpointer aData);
|
||||
static int VerifyDestination();
|
||||
static void CreateDestYes(GtkWidget *aWidget, gpointer aData);
|
||||
|
|
|
@ -50,6 +50,7 @@ nsXIContext::nsXIContext()
|
|||
backID = 0;
|
||||
nextID = 0;
|
||||
bMoving = FALSE;
|
||||
bDone = FALSE;
|
||||
|
||||
threadTurn = nsXIContext::UI_THREAD;
|
||||
}
|
||||
|
@ -69,6 +70,7 @@ nsXIContext::~nsXIContext()
|
|||
XI_IF_FREE(window);
|
||||
XI_IF_FREE(back);
|
||||
XI_IF_FREE(next);
|
||||
XI_IF_FREE(cancel);
|
||||
XI_IF_FREE(nextLabel);
|
||||
XI_IF_FREE(backLabel);
|
||||
XI_IF_FREE(acceptLabel);
|
||||
|
|
|
@ -77,6 +77,8 @@ public:
|
|||
int nextID; /* signal handler id for next btn */
|
||||
int bMoving; /* when moving between dlgs signals are
|
||||
emitted twice; this notes the state */
|
||||
int bDone; /* engine thread sets boolean when done
|
||||
so that ui/main thread can exit */
|
||||
|
||||
pthread_mutex_t prog_mutex; /* mutex for sync between ui and eng th */
|
||||
pthread_cond_t prog_cv; /* cond var for ui/eng th communication */
|
||||
|
|
|
@ -49,11 +49,13 @@ nsXIEngine::~nsXIEngine()
|
|||
{
|
||||
DUMP("~nsXIEngine");
|
||||
|
||||
// rm tmp dir
|
||||
char cmd[1024];
|
||||
char cwd[1024];
|
||||
memset(cwd, 0, 1024);
|
||||
DUMP(cwd);
|
||||
|
||||
sprintf(cmd, "rm -rf %s", mTmp);
|
||||
system(cmd);
|
||||
// rm tmp dir
|
||||
chdir("../..");
|
||||
rmdir(mTmp);
|
||||
|
||||
XI_IF_FREE(mTmp);
|
||||
}
|
||||
|
@ -148,7 +150,6 @@ nsXIEngine::Install(int aCustom, nsComponentList *aComps, char *aDestination)
|
|||
|
||||
int err = OK;
|
||||
xpistub_t stub;
|
||||
char cmd[1024];
|
||||
char *old_LD_LIBRARY_PATH = NULL;
|
||||
char new_LD_LIBRARY_PATH[256];
|
||||
int i;
|
||||
|
@ -200,16 +201,6 @@ nsXIEngine::Install(int aCustom, nsComponentList *aComps, char *aDestination)
|
|||
// restore LD_LIBRARY_PATH settings
|
||||
setenv("LD_LIBRARY_PATH", old_LD_LIBRARY_PATH, 1);
|
||||
|
||||
// rm tmp dir --> now in {ROOT}/
|
||||
chdir("../..");
|
||||
sprintf(cmd, "rm -rf %s", mTmp);
|
||||
DUMP(cmd);
|
||||
system(cmd);
|
||||
|
||||
// XXX call gCtx->me->Shutdown();
|
||||
gtk_main_quit();
|
||||
exit(err);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
|
@ -155,9 +155,8 @@ BAIL:
|
|||
gint
|
||||
nsXInstaller::Kill(GtkWidget *widget, GtkWidget *event, gpointer data)
|
||||
{
|
||||
// XXX call Shutdown() ?
|
||||
|
||||
gtk_main_quit();
|
||||
XI_IF_DELETE(gCtx);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -301,6 +300,8 @@ main(int argc, char **argv)
|
|||
err = E_MEM;
|
||||
|
||||
XI_IF_DELETE(installer);
|
||||
DUMP("post nsXInstaller instance deletion");
|
||||
|
||||
exit(err);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче