示例#1
0
void status_bar_inc()
{
	if(done)
		return;

	IupSetInt(status_prog, "VALUE", IupGetInt(status_prog, "VALUE")+1);
	IupLoopStep();
}
int progressCb(long total, long now, double kBps){
	double progress = (double)now/(double)total;
	IupSetDouble(pb, "VALUE", progress);
	IupSetStrf(status, "TITLE", "Total file size: %dKb, downloaded: %dKb\n(progress: %d%%, average speed: %dkBps)", total/1000, now/1000, (int)(progress*100), (int)kBps);
	IupRefresh(downloaderGui);
	IupLoopStep();
	return stop;
}
示例#3
0
void status_bar_count(int iterations)
{
	if(done)
		return;

	IupSetInt(status_prog, "MAX", iterations);
	IupLoopStep();
}
示例#4
0
int L_sleep(lua_State *L) {
	uint32_t i;
	uint32_t n = (uint32_t)luaL_checklong(L, 1);
	for (i = 0; i < n * 100; i++) {
		usleep(1000);
		if (IupLoopStep() == IUP_CLOSE) break;
	}
	return 0;
}
示例#5
0
void status_bar_done()
{
	if(done)
		return;

	IupSetAttribute(status_msg, "TITLE", "Ready");
	IupSetAttribute(status_prog, "EXPAND", "NO");
	done = 1;

	IupRefresh(status_prog);
	IupLoopStep();
}
示例#6
0
static int counter_inc(void)
{
  IupSetAttribute(counter_dlg, "INC", NULL);
//  IupSetInt(counter_dlg, "COUNT", count);

  if (strcmp(IupGetAttribute(counter_dlg, "STATE"), "ABORTED") == 0)
  {
    printf("Interrupted\n");
    return 0;
  }

  IupLoopStep();

//  Ihandle* main_window = IupGetHandle("MainWindow");
//  IupSetInt(main_window, "TASKBARPROGRESSVALUE", (IupGetInt(counter_dlg, "COUNT") * 100) / IupGetInt(counter_dlg, "TOTALCOUNT"));

  printf("Step\n");
  return 1;
}
示例#7
0
void status_bar_init(const char* description)
{
	//Return if not done
	//Hopefully will never happen
	if(!done)
		return;

	//We're using this now
	done = 0;

	//Set the message
	IupSetAttribute(status_msg, "TITLE", description);

	//Set the progress bar
	IupSetInt(status_prog, "VALUE", 0);
	IupSetAttribute(status_prog, "EXPAND", "HORIZONTAL");

	//Update
	IupRefresh(status_prog);
	IupRefresh(status_msg);
	IupLoopStep();
}
示例#8
0
文件: iuplua_api.c 项目: LuaDist/iup
static int LoopStep(lua_State *L)
{
  lua_pushinteger(L,IupLoopStep());
  return 1;
}
int downloadCb(){
	IupSetFunction("IDLE_ACTION", NULL);
	IupLoopStep();
	char *cachePath = path_get_nwjs_cache();
	char *indexJsonPath = string_concat(2, cachePath, "../index.json");
	recursiveMkdir(cachePath, 0755); //Create directories if they don't already exist
	indexJsonFile_t versionIndex = {};
	if(download(INDEXJSON_URL, indexJsonPath, genericCb) != DOWNLOAD_SUCCESS){
		printf("[nwjsmanager][DEBUG] Failed to download version index at URL '%s'. Cached version will be used if available.\n", INDEXJSON_URL);
	}
	indexJson_file_parse(indexJsonPath, &versionIndex);
	if(versionIndex.nwjsVersionCount != 0){
		if(update_required(&versionIndex)){
			Ihandle *info = IupGetHandle("info");
			IupSetStrf(info, "TITLE", "Downloading nwjsmanager update (you are running v%s, but v%d.%d.%d is available).", NWJSMANAGER_VERSION, versionIndex.nwjsmanagerLatestVersion.major, versionIndex.nwjsmanagerLatestVersion.minor, versionIndex.nwjsmanagerLatestVersion.patch);
			if(!update_install(&versionIndex, progressCb, _argc, _argv)){
				IupMessage(app->name, "Failed to install update!");
				return IUP_CLOSE;
			}
		}
		nwjsVersion_t *launchVersion = NULL;
		for(int i = 0; i < versionIndex.nwjsVersionCount; i++)
			if(packageJson_file_is_nw_version_OK(app, versionIndex.nwjsVersions[i].version) && (!launchVersion || semver_gt(versionIndex.nwjsVersions[i].version, launchVersion->version)))
				launchVersion = &versionIndex.nwjsVersions[i];
		if(!launchVersion){
			IupMessage(app->name, "Error: no nw.js version compatible with the application was found. Please try to reinstall the application, or contact the developer if the problem persists.");
		}else{
			printf("[nwjsmanager][DEBUG] Downloading nw.js %d.%d.%d\n", launchVersion->version.major, launchVersion->version.minor, launchVersion->version.patch);
			char *versionName = malloc(255); //Using 255 as max length (see https://github.com/mojombo/semver/blob/master/semver.md#does-semver-have-a-size-limit-on-the-version-string)
			sprintf(versionName, "v%d.%d.%d", launchVersion->version.major, launchVersion->version.minor, launchVersion->version.patch);
			nwjsDownload_t *downloads = &launchVersion->defaultDownloads;
			char *url;
			#ifdef _WIN32
				//Actually on Windows only a 32-bit binary is distributed since it will work out-of-the box thanks to Wow64. The IsWow64 function (see win-only/IsWow64.c) is used to detect at runtime if we are on a 64-bit system and properly select the nw.js architecture.
				if(IsWow64())
					url = downloads->win64;
				else
					url = downloads->win32;
			#else
				//On linux, architecture is detected at compile time because two different binaries are distributed (i386 and x86_64)
				#ifdef __x86_64__
					url = downloads->linux64;
				#else
					url = downloads->linux32;
				#endif
			#endif
			char *file = string_concat(2, cachePath, "download");
			int result = download(url, file, progressCb);
			if(result == DOWNLOAD_SUCCESS){
				result = extractArchive(file, cachePath);
				remove(file);
				char *oldName = strrchr(url, '/') + sizeof(char);
				char *oldNameEnd = strstr(oldName, ".zip");
				if(!oldNameEnd)
					oldNameEnd = strstr(oldName, ".tar.gz");
				*oldNameEnd = '\0';
				char *oldPath = string_concat(2, cachePath, oldName);
				*oldNameEnd = '.';
				char *newPath = string_concat(2, cachePath, versionName);
				rename(oldPath, newPath);
				free(oldPath);
				#ifndef _WIN32
					recursiveChmod(newPath, S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IXOTH);
				#endif
				free(newPath);
				globalResult = DOWNLOADERGUI_SUCCESS;
			}
			free(file);
			free(versionName);
		}
	}else
		IupMessage(app->name, "Error: this application requires the nw.js runtime, but a suitable version of the runtime files isn't installed. An attempt was done to download it, but it wasn't possible to retrive the version index.\nPlease check your Internet connection (this is necessary only for the first run of the application). Also, be sure the current user is allowed to write to the nw.js binary cache directory.");
	indexJson_file_free(&versionIndex);
	free(indexJsonPath);
	free(cachePath);
	return IUP_CLOSE;
}
int genericCb(long total, long now, double kBps){
	IupRefresh(downloaderGui);
	IupLoopStep();
	return 0;
}
示例#11
0
static void LoopStep(void)
{
  lua_pushnumber(IupLoopStep());
}