Exemple #1
0
void ro_gui_menu_selection(wimp_selection *selection) {
	wimp_pointer pointer;

	wimp_get_pointer_info(&pointer);

	if (current_menu == iconbar_menu) {
		switch (selection->items[0]) {
			case 0: /* Info */
				ro_gui_create_menu((wimp_menu *) dialog_info,
						pointer.pos.x, pointer.pos.y);
				break;
			case 1: /* Help */
				xos_cli("Filer_Run <NSTheme$Dir>.!Help");
				break;
			case 2: /* Quit */
				application_quit = true;
				break;
		}

	} else if (current_menu == main_menu) {
		switch (selection->items[0]) {
			case 2:	/* Help */
				xos_cli("Filer_Run <NSTheme$Dir>.!Help");
				break;
		}
	} else if (current_menu == colour_menu) {
		ro_gui_set_icon_background_colour(dialog_main, menu_icon - 1,
				selection->items[0]);
	}

	if (pointer.buttons == wimp_CLICK_ADJUST) {
		ro_gui_create_menu(current_menu, 0, 0);
	}

}
Exemple #2
0
void __assert2(const char *expr, const char *function, const char *file,
		int line)
{
	static const os_error error = { 1, "NetSurf has detected a serious "
			"error and must exit. Please submit a bug report, "
			"attaching the browser log file." };

	fprintf(stderr, "\n\"%s\", line %d: %s%sAssertion failed: %s\n",
			file, line,
			function ? function : "",
			function ? ": " : "",
			expr);
	fflush(stderr);

	xwimp_report_error_by_category(&error,
			wimp_ERROR_BOX_GIVEN_CATEGORY |
			wimp_ERROR_BOX_CATEGORY_ERROR <<
				wimp_ERROR_BOX_CATEGORY_SHIFT,
			"NetSurf", "!netsurf",
			(osspriteop_area *) 1, "Quit", 0);

	xos_cli("Filer_Run <Wimp$ScrapDir>.WWW.NetSurf.Log");

	abort();
}
Exemple #3
0
bool ro_gui_download_click(wimp_pointer *pointer)
{
  	struct gui_download_window *dw;

	dw = (struct gui_download_window *)ro_gui_wimp_event_get_user_data(pointer->w);
	if ((pointer->buttons & (wimp_DRAG_SELECT | wimp_DRAG_ADJUST)) &&
			pointer->i == ICON_DOWNLOAD_ICON && 
			!dw->error && !dw->saved) {
		const char *sprite = ro_gui_get_icon_string(pointer->w, pointer->i);
		int x = pointer->pos.x, y = pointer->pos.y;
		wimp_window_state wstate;
		wimp_icon_state istate;
		/* start the drag from the icon's exact location, rather than the pointer */
		istate.w = wstate.w = pointer->w;
		istate.i = pointer->i;
		if (!xwimp_get_window_state(&wstate) && !xwimp_get_icon_state(&istate)) {
			x = (istate.icon.extent.x1 + istate.icon.extent.x0)/2 +
					wstate.visible.x0 - wstate.xscroll;
			y = (istate.icon.extent.y1 + istate.icon.extent.y0)/2 +
					wstate.visible.y1 - wstate.yscroll;
		}
		ro_mouse_drag_start(ro_gui_download_drag_end, NULL, NULL, NULL);
		download_window_current = dw;
		ro_gui_drag_icon(x, y, sprite);

	} else if (pointer->i == ICON_DOWNLOAD_DESTINATION) {
		char command[256] = "Filer_OpenDir ";
		char *dot;

		strncpy(command + 14, dw->path, 242);
		command[255] = 0;
		dot = strrchr(command, '.');
		if (dot) {
			os_error *error;
			*dot = 0;
			error = xos_cli(command);
			if (error) {
				LOG("xos_cli: 0x%x: %s", error->errnum, error->errmess);
				ro_warn_user("MiscError", error->errmess);
			}
		}
	}
	return true;
}
Exemple #4
0
bool artworks_convert(struct content *c)
{
	artworks_content *aw = (artworks_content *) c;
	union content_msg_data msg_data;
	const char *source_data;
	unsigned long source_size;
	void *init_workspace;
	void *init_routine;
	os_error *error;
	int used = -1;  /* slightly better with older OSLib versions */
	char *title;

	/* check whether AWViewer has been seen and we can therefore
		locate the ArtWorks rendering modules */
	xos_read_var_val_size("Alias$LoadArtWorksModules", 0, os_VARTYPE_STRING,
				&used, NULL, NULL);
	if (used >= 0) {
		LOG("Alias$LoadArtWorksModules not defined");
		msg_data.error = messages_get("AWNotSeen");
		content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
		return false;
	}

	/* load the modules, or do nothing if they're already loaded */
	error = xos_cli("LoadArtWorksModules");
	if (error) {
		LOG("xos_cli: 0x%x: %s", error->errnum, error->errmess);
		msg_data.error = error->errmess;
		content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
		return false;
	}

	/* lookup the addresses of the init and render routines */
	error = (os_error*)_swix(AWRender_FileInitAddress, _OUT(0) | _OUT(1),
				&init_routine, &init_workspace);
	if (error) {
		LOG("AWRender_FileInitAddress: 0x%x: %s", error->errnum, error->errmess);
		msg_data.error = error->errmess;
		content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
		return false;
	}

	error = (os_error*)_swix(AWRender_RenderAddress, _OUT(0) | _OUT(1),
				&aw->render_routine,
				&aw->render_workspace);
	if (error) {
		LOG("AWRender_RenderAddress: 0x%x: %s", error->errnum, error->errmess);
		msg_data.error = error->errmess;
		content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
		return false;
	}

	source_data = content__get_source_data(c, &source_size);

	/* initialise (convert file to new format if required) */
	error = awrender_init(&source_data, &source_size,
			init_routine, init_workspace);
	if (error) {
		LOG("awrender_init: 0x%x : %s", error->errnum, error->errmess);
		msg_data.error = error->errmess;
		content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
		return false;
	}

	error = (os_error*)_swix(AWRender_DocBounds, 
			_IN(0) | _OUT(2) | _OUT(3) | _OUT(4) | _OUT(5),
			source_data,
			&aw->x0,
			&aw->y0,
			&aw->x1,
			&aw->y1);

	if (error) {
		LOG("AWRender_DocBounds: 0x%x: %s", error->errnum, error->errmess);
		msg_data.error = error->errmess;
		content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
		return false;
	}

	LOG("bounding box: %d,%d,%d,%d", aw->x0, aw->y0, aw->x1, aw->y1);

	/* create the resizable workspace required by the
		ArtWorksRenderer rendering routine */

	aw->size = INITIAL_BLOCK_SIZE;
	aw->block = malloc(INITIAL_BLOCK_SIZE);
	if (!aw->block) {
		LOG("failed to create block for ArtworksRenderer");
		msg_data.error = messages_get("NoMemory");
		content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
		return false;
	}

	c->width  = (aw->x1 - aw->x0) / 512;
	c->height = (aw->y1 - aw->y0) / 512;

	title = messages_get_buff("ArtWorksTitle",
			nsurl_access_leaf(llcache_handle_get_url(c->llcache)),
			c->width, c->height);
	if (title != NULL) {
		content__set_title(c, title);
		free(title);
	}
	content_set_ready(c);
	content_set_done(c);
	/* Done: update status bar */
	content_set_status(c, "");
	return true;
}
Exemple #5
0
void ro_gui_dialog_main_report(void) {
	char name[16];
	char name2[16];
  	const char *lookup_name;
  	const char *pushed_name;
	unsigned int i;
	int j, n;
	unsigned int err;
  	int warn_count = 0;
  	bool found;
  	int throb_frames = -1;
	FILE *fp;
	fp = fopen("<Wimp$Scrap>", "w");
	if (!fp) {
		warn_user("ReportError", 0);
		LOG(("failed to open file '<Wimp$Scrap>' for writing"));
		return;
	}
	fprintf(fp, messages_get("Title"));
	fprintf(fp, "\n");
	for (i = 0; i < strlen(messages_get("Title")); i++) {
		fprintf(fp, "=");
	}
	fprintf(fp, "\n");
	if (theme_sprites) {
		i = 0;
		while (theme_sprite_name[i]) {
			err = ro_gui_dialog_test_sprite(theme_sprite_name[i]);
			if (err & 1) {
				warn_count++;
				lookup_name = messages_get(theme_sprite_name[i & ~1]);
				if (i & 1) {
					pushed_name = messages_get("pushed");
				} else {
				  	pushed_name = "";
				}
				fprintf(fp, messages_get("WarnNoSpr"),
					theme_sprite_name[i],
					lookup_name, pushed_name);
				fprintf(fp, "\n");
			}
			if (err & 2) {
				warn_count++;
				fprintf(fp, messages_get("WarnHighSpr"),
					theme_sprite_name[i]);
				fprintf(fp, "\n");
			}
			if (err & 4) {
				warn_count++;
				fprintf(fp, messages_get("WarnAlphaSpr"),
					theme_sprite_name[i]);
				fprintf(fp, "\n");
			}
			i++;
		}
		for (j = 1; j <= theme_sprites->sprite_count; j++) {
		  	found = false;
			osspriteop_return_name(osspriteop_USER_AREA,
					theme_sprites, name, 16, j);
			if (strncmp(name, "throbber", 8) == 0) {
				n = atoi(name + 8);
				sprintf(name2, "throbber%i", n);
				if (strcmp(name, name2) == 0) {
					found = true;
					throb_frames = n;
				}
			} else {
				i = 0;
				while (!found && theme_sprite_name[i]) {
					if (strcmp(name, theme_sprite_name[i]) == 0) {
						found = true;
					}
					i++;
			  	}
			}
			
			if (!found) {
				warn_count++;
				fprintf(fp, messages_get("WarnExtraSpr"),
					name);
				fprintf(fp, "\n");
				err = ro_gui_dialog_test_sprite(name);
				if (err & 2) {
					warn_count++;
					fprintf(fp, messages_get("WarnHighSpr"),
						name);
					fprintf(fp, "\n");
				}
				if (err & 4) {
					warn_count++;
					fprintf(fp, messages_get("WarnAlphaSpr"),
						name);
					fprintf(fp, "\n");
				}
			}
		}
		if (throb_frames == -1) {
			fprintf(fp, messages_get("WarnNoThrob"));
			fprintf(fp, "\n");
		  
		} else {
			for (j = 0; j < throb_frames; j++) {
				sprintf(name, "throbber%i", j);
				err = ro_gui_dialog_test_sprite(name);
				if (err & 1) {
					warn_count++;
					fprintf(fp, messages_get("WarnMissThrob"),
						name);
					fprintf(fp, "\n");
				}
				if (err & 2) {
					warn_count++;
					fprintf(fp, messages_get("WarnHighSpr"),
						name);
					fprintf(fp, "\n");
				}
				if (err & 4) {
					warn_count++;
					fprintf(fp, messages_get("WarnAlphaSpr"),
						name);
					fprintf(fp, "\n");
				}
			}
		}
		
	} else {
		warn_count++;
		fprintf(fp, messages_get("WarnNoFile"));
		fprintf(fp, "\n");
	}
	if (warn_count > 0) {
		fprintf(fp, "\n");
		fprintf(fp, messages_get("CompleteErr"), warn_count);
		fprintf(fp, "\n");
	} else {
		fprintf(fp, messages_get("CompleteOK"));
		fprintf(fp, "\n");
	}
	
	fclose(fp);
	xosfile_set_type("<Wimp$Scrap>", 0xfff);
	xos_cli("Filer_Run <Wimp$Scrap>");
}