Exemple #1
0
END_HANDLER

BUTTON_CLICKED(setDefaultExportOptions)
{
	nsoption_set_int(margin_top, DEFAULT_MARGIN_TOP_MM);
	nsoption_set_int(margin_bottom, DEFAULT_MARGIN_BOTTOM_MM);
	nsoption_set_int(margin_left, DEFAULT_MARGIN_LEFT_MM);
	nsoption_set_int(margin_right, DEFAULT_MARGIN_RIGHT_MM);
	nsoption_set_int(export_scale, DEFAULT_EXPORT_SCALE * 100);		
	nsoption_set_bool(suppress_images, false);
	nsoption_set_bool(remove_backgrounds, false);
	nsoption_set_bool(enable_loosening, true);
	nsoption_set_bool(enable_PDF_compression, true);
	nsoption_set_bool(enable_PDF_password, false);
			
	SET_SPIN(spinMarginTop, nsoption_int(margin_top));
	SET_SPIN(spinMarginBottom, nsoption_int(margin_bottom));
	SET_SPIN(spinMarginLeft, nsoption_int(margin_left));
	SET_SPIN(spinMarginRight, nsoption_int(margin_right));
	SET_SPIN(spinExportScale, nsoption_int(export_scale));
	SET_CHECK(checkSuppressImages, nsoption_bool(suppress_images));
	SET_CHECK(checkRemoveBackgrounds, nsoption_bool(remove_backgrounds));
	SET_CHECK(checkCompressPDF, nsoption_bool(enable_PDF_compression));
	SET_CHECK(checkPasswordPDF, nsoption_bool(enable_PDF_password));
	SET_CHECK(checkFitPage, nsoption_bool(enable_loosening));
}
Exemple #2
0
struct NewMenu *ami_create_menu(struct gui_window_2 *gwin)
{
	int i;

	gwin->menu = AllocVecTags(sizeof(struct NewMenu) * (AMI_MENU_AREXX_MAX + 1),
					AVT_ClearWithValue, 0, TAG_DONE);
	ami_init_menulabs(gwin);
	ami_menu_scan(ami_tree_get_tree(hotlist_window), gwin);
	ami_menu_arexx_scan(gwin);
	gwin = ami_menu_layout(gwin);

#if defined(WITH_JS) || defined(WITH_MOZJS)
	gwin->menu[M_JS].nm_Flags = CHECKIT | MENUTOGGLE;
	if(nsoption_bool(enable_javascript) == true)
		gwin->menu[M_JS].nm_Flags |= CHECKED;
#endif

	gwin->menu[M_PRINT].nm_Flags = NM_ITEMDISABLED;

	gwin->menu[M_IMGFORE].nm_Flags = CHECKIT | MENUTOGGLE;
	if(nsoption_bool(foreground_images) == true)
		gwin->menu[M_IMGFORE].nm_Flags |= CHECKED;
	gwin->menu[M_IMGBACK].nm_Flags = CHECKIT | MENUTOGGLE;
	if(nsoption_bool(background_images) == true)
		gwin->menu[M_IMGBACK].nm_Flags |= CHECKED;

	/* Set up scheduler to refresh the hotlist menu */
	if(nsoption_int(menu_refresh) > 0)
		schedule(nsoption_int(menu_refresh), (void *)ami_menu_refresh, gwin);

	return(gwin->menu);
}
Exemple #3
0
END_HANDLER

COMBO_CHANGED(comboProxyType, http_proxy_auth)
{
	LOG(("proxy auth: %d", nsoption_int(http_proxy_auth)));
	switch (nsoption_int(http_proxy_auth)) {
	case 0:
		nsoption_set_bool(http_proxy, false);
		nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_NONE);
		break;
	case 1:
		nsoption_set_bool(http_proxy, true);
		nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_NONE);
		break;
	case 2:
		nsoption_set_bool(http_proxy, true);
		nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_BASIC);
		break;
	case 3:
		nsoption_set_bool(http_proxy, true);
		nsoption_set_int(http_proxy_auth, OPTION_HTTP_PROXY_AUTH_NTLM);
		break;
	}
	gboolean sensitive = (!proxy_type == 0);
	gtk_widget_set_sensitive(entryProxyHost, sensitive);
	gtk_widget_set_sensitive(entryProxyPort, sensitive);
	gtk_widget_set_sensitive(entryProxyUser, sensitive);
	gtk_widget_set_sensitive(entryProxyPassword, sensitive);
}	
Exemple #4
0
struct gui_window *
gui_create_browser_window(struct browser_window *bw,
			  struct browser_window *clone,
			  bool new_tab)
{
	struct gui_window *gw;

	gw = calloc(1, sizeof(struct gui_window));

	if (gw == NULL)
		return NULL;

	/* seems we need to associate the gui window with the underlying
	 * browser window
	 */
	gw->bw = bw;

	create_normal_browser_window(gw, nsoption_int(fb_furniture_size));
	gw->localhistory = fb_create_localhistory(bw, fbtk, nsoption_int(fb_furniture_size));

	/* map and request redraw of gui window */
	fbtk_set_mapping(gw->window, true);

	return gw;
}
Exemple #5
0
/* exported function documented in render/font_internal.h */
void font_plot_style_from_css(const css_computed_style *css,
		plot_font_style_t *fstyle)
{
	lwc_string **families;
	css_fixed length = 0;
	css_unit unit = CSS_UNIT_PX;
	css_color col;

	fstyle->family = plot_font_generic_family(
			css_computed_font_family(css, &families));

	css_computed_font_size(css, &length, &unit);
	fstyle->size = FIXTOINT(FMUL(nscss_len2pt(length, unit),
				      INTTOFIX(FONT_SIZE_SCALE)));

	/* Clamp font size to configured minimum */
	if (fstyle->size < (nsoption_int(font_min_size) * FONT_SIZE_SCALE) / 10)
		fstyle->size = (nsoption_int(font_min_size) * FONT_SIZE_SCALE) / 10;

	fstyle->weight = plot_font_weight(css_computed_font_weight(css));
	fstyle->flags = plot_font_flags(css_computed_font_style(css),
			css_computed_font_variant(css));

	css_computed_color(css, &col);
	fstyle->foreground = nscss_color_to_ns(col);
	fstyle->background = 0;
}
Exemple #6
0
/* Get a font style for a text input */
static inline void
fb_text_font_style(fbtk_widget_t *widget, int *font_height, int *padding,
		plot_font_style_t *font_style)
{
	if (widget->u.text.outline)
		*padding = 1;
	else
		*padding = 0;

//#ifdef FB_USE_FREETYPE
	if (!nsoption_bool(bitmap_fonts)) {
		*padding += widget->height / 6;	
		*font_height = widget->height - *padding - *padding;
	}
	else {
		*font_height = FB_FONT_HEIGHT;
		*padding = (widget->height - *padding - *font_height) / 2;
	}

	font_style->family = PLOT_FONT_FAMILY_SANS_SERIF;
	if (!nsoption_bool(bitmap_fonts))
#ifdef AGA
		font_style->size = (nsoption_int(gui_font_size))*(790-nsoption_int(browser_dpi));
#else
		font_style->size = nsoption_int(gui_font_size)*(790-nsoption_int(browser_dpi));
#endif
	else
void Proxy(struct Hook *h, Object *o)
{
	int num;
	
	get(obj->CY_Proxy_type, MUIA_Cycle_Active, &var);
		num = (int)var;

	if (num == 0)
	{
		set(obj->STR_Host, MUIA_Disabled, TRUE);
		set(obj->STR_Port, MUIA_Disabled, TRUE);		
		set(obj->STR_Username, MUIA_Disabled, TRUE);
		set(obj->STR_Password, MUIA_Disabled, TRUE);
		set(obj->STR_Bypass, MUIA_Disabled, TRUE);
		nsoption_bool(http_proxy) = false;
		nsoption_int(http_proxy_auth) = OPTION_HTTP_PROXY_AUTH_NONE;		
	}		
	else if (num == 1)
	{
		set(obj->STR_Username, MUIA_Disabled, TRUE);
		set(obj->STR_Password, MUIA_Disabled, TRUE);
		nsoption_bool(http_proxy) = true;
		nsoption_int(http_proxy_auth) = OPTION_HTTP_PROXY_AUTH_NONE;		
	}
	else if (num == 2)
	{
		nsoption_bool(http_proxy) = true;
		nsoption_int(http_proxy_auth) = OPTION_HTTP_PROXY_AUTH_BASIC;
	}
	
}
Exemple #8
0
static nserror
ami_history_global_create_window(struct ami_history_global_window *history_win)
{
	struct ami_corewindow *ami_cw = (struct ami_corewindow *)&history_win->core;
	ULONG refresh_mode = WA_SmartRefresh;

	if(nsoption_bool(window_simple_refresh) == true) {
		refresh_mode = WA_SimpleRefresh;
	}

	ami_cw->objects[GID_CW_WIN] = WindowObj,
  	    WA_ScreenTitle, ami_gui_get_screen_title(),
       	WA_Title, ami_cw->wintitle,
       	WA_Activate, TRUE,
       	WA_DepthGadget, TRUE,
       	WA_DragBar, TRUE,
       	WA_CloseGadget, TRUE,
       	WA_SizeGadget, TRUE,
		WA_SizeBRight, TRUE,
		WA_Top, nsoption_int(history_window_ypos),
		WA_Left, nsoption_int(history_window_xpos),
		WA_Width, nsoption_int(history_window_xsize),
		WA_Height, nsoption_int(history_window_ysize),
		WA_PubScreen, scrn,
		WA_ReportMouse, TRUE,
		refresh_mode, TRUE,
		WA_IDCMP, IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE |
				IDCMP_RAWKEY | IDCMP_GADGETUP | IDCMP_IDCMPUPDATE |
				IDCMP_EXTENDEDMOUSE | IDCMP_SIZEVERIFY | IDCMP_REFRESHWINDOW,
		WINDOW_IDCMPHook, &ami_cw->idcmp_hook,
		WINDOW_IDCMPHookBits, IDCMP_IDCMPUPDATE | IDCMP_EXTENDEDMOUSE |
				IDCMP_SIZEVERIFY | IDCMP_REFRESHWINDOW,
		WINDOW_SharedPort, sport,
		WINDOW_HorizProp, 1,
		WINDOW_VertProp, 1,
		WINDOW_UserData, history_win,
		WINDOW_MenuStrip, ami_history_global_menu_create(history_win),
		WINDOW_MenuUserData, WGUD_HOOK,
		WINDOW_IconifyGadget, FALSE,
		WINDOW_Position, WPOS_CENTERSCREEN,
		WINDOW_ParentGroup, ami_cw->objects[GID_CW_MAIN] = LayoutVObj,
			LAYOUT_AddChild, ami_cw->objects[GID_CW_DRAW] = SpaceObj,
				GA_ID, GID_CW_DRAW,
				SPACE_Transparent, TRUE,
				SPACE_BevelStyle, BVS_DISPLAY,
				GA_RelVerify, TRUE,
   			SpaceEnd,
		EndGroup,
	EndWindow;

	if(ami_cw->objects[GID_CW_WIN] == NULL) {
		return NSERROR_NOMEM;
	}

	return NSERROR_OK;
}
Exemple #9
0
bool ro_gui_options_image_initialise(wimp_w w)
{
	int i;

	/* load the sprite file */
	if (example_users == 0) {
		char pathname[256];
		snprintf(pathname, 256, "%s.Resources.Image", NETSURF_DIR);
		pathname[255] = '\0';
		example_images = ro_gui_load_sprite_file(pathname);
		if (!example_images)
			return false;
	}
	example_users++;

	/* set the current values */
	for (i = 0; (i < 4); i++) {
		if ((unsigned int)nsoption_int(plot_fg_quality) == tinct_options[i])
			ro_gui_set_icon_string(w, IMAGE_FOREGROUND_FIELD,
					image_quality_menu->entries[i].
						data.indirected_text.text, true);
		if ((unsigned int)nsoption_int(plot_bg_quality) == tinct_options[i])
			ro_gui_set_icon_string(w, IMAGE_BACKGROUND_FIELD,
					image_quality_menu->entries[i].
						data.indirected_text.text, true);
	}
	ro_gui_set_icon_decimal(w, IMAGE_SPEED_FIELD,
				nsoption_int(minimum_gif_delay), 2);
	ro_gui_set_icon_selected_state(w, IMAGE_DISABLE_ANIMATION,
				       !nsoption_bool(animate_images));
	ro_gui_options_update_shading(w);

	/* register icons */
	ro_gui_wimp_event_register_menu_gright(w, IMAGE_FOREGROUND_FIELD,
			IMAGE_FOREGROUND_MENU, image_quality_menu);
	ro_gui_wimp_event_register_menu_gright(w, IMAGE_BACKGROUND_FIELD,
			IMAGE_BACKGROUND_MENU, image_quality_menu);
	ro_gui_wimp_event_register_text_field(w, IMAGE_SPEED_TEXT);
	ro_gui_wimp_event_register_numeric_field(w, IMAGE_SPEED_FIELD,
			IMAGE_SPEED_INC, IMAGE_SPEED_DEC, 0, 6000, 10, 2);
	ro_gui_wimp_event_register_checkbox(w, IMAGE_DISABLE_ANIMATION);
	ro_gui_wimp_event_register_text_field(w, IMAGE_SPEED_CS);
	ro_gui_wimp_event_register_redraw_window(w,
			ro_gui_options_image_redraw);
	ro_gui_wimp_event_register_mouse_click(w,
			ro_gui_options_image_click);
	ro_gui_wimp_event_register_menu_selection(w,
			ro_gui_options_image_update);
	ro_gui_wimp_event_register_cancel(w, IMAGE_CANCEL_BUTTON);
	ro_gui_wimp_event_register_ok(w, IMAGE_OK_BUTTON,
			ro_gui_options_image_ok);
	ro_gui_wimp_event_set_help_prefix(w, "HelpImageConfig");
	ro_gui_wimp_event_memorise(w);

	return true;
}
Exemple #10
0
void ami_print(struct hlcache_handle *c, int copies)
{
	double height;
	float scale = nsoption_int(print_scale) / 100.0;

	if(ami_print_info.msgport == NULL)
		ami_print_init();
#ifdef __amigaos4__
	if(!(ami_print_info.PReq =
			(struct IODRPTagsReq *)AllocSysObjectTags(ASOT_IOREQUEST,
				ASOIOR_Size, sizeof(struct IODRPTagsReq),
				ASOIOR_ReplyPort, ami_print_info.msgport,
				ASO_NoTrack, FALSE,
				TAG_DONE))) return;
#else
	if(!(ami_print_info.PReq =
			(struct IODRPTagsReq *)CreateIORequest(ami_print_info.msgport,
				sizeof(struct IODRPTagsReq)))) return;
#endif

	if(OpenDevice("printer.device", nsoption_int(printer_unit),
			(struct IORequest *)ami_print_info.PReq, 0))
	{
		amiga_warn_user("CompError","printer.device");
		return;
	}

	ami_print_info.PD = (struct PrinterData *)ami_print_info.PReq->io_Device;
	ami_print_info.PED = &ami_print_info.PD->pd_SegmentData->ps_PED;

	ami_print_info.ps = print_make_settings(PRINT_DEFAULT, nsurl_access(hlcache_handle_get_url(c)), ami_layout_table);
	ami_print_info.ps->page_width = ami_print_info.PED->ped_MaxXDots;
	ami_print_info.ps->page_height = ami_print_info.PED->ped_MaxYDots;
	ami_print_info.ps->scale = scale;

	if(!print_set_up(c, &amiprinter, ami_print_info.ps, &height))
	{
		amiga_warn_user("PrintError","print_set_up() returned false");
		ami_print_close_device();
		return;
	}

	height *= ami_print_info.ps->scale;
	ami_print_info.pages = height / ami_print_info.ps->page_height;
	ami_print_info.c = c;

	ami_print_progress();

	while(ami_print_cont()); /* remove while() for async printing */
}
Exemple #11
0
bool ro_gui_options_image_ok(wimp_w w)
{
	ro_gui_options_image_read(w, 
				  (unsigned int *)&nsoption_int(plot_bg_quality),
				  (unsigned int *)&nsoption_int(plot_fg_quality));

	nsoption_set_int(minimum_gif_delay,
			 ro_gui_get_icon_decimal(w, IMAGE_SPEED_FIELD, 2));

	nsoption_set_bool(animate_images,
			  !ro_gui_get_icon_selected_state(w,
					IMAGE_DISABLE_ANIMATION));
	ro_gui_save_options();

	return true;
}
Exemple #12
0
/**
 * Choose and dispatch a single job. Return false if we failed to dispatch
 * anything.
 *
 * We don't check the overall dispatch size here because we're not called unless
 * there is room in the fetch queue for us.
 */
static bool fetch_choose_and_dispatch(void)
{
	bool same_host;
	struct fetch *queueitem;
	queueitem = queue_ring;
	do {
		/* We can dispatch the selected item if there is room in the
		 * fetch ring
		 */
		int countbyhost;
		RING_COUNTBYLWCHOST(struct fetch, fetch_ring, countbyhost,
				    queueitem->host);
		if (countbyhost < nsoption_int(max_fetchers_per_host)) {
			/* We can dispatch this item in theory */
			return fetch_dispatch_job(queueitem);
		}
		/* skip over other items with the same host */
		same_host = true;
		while (same_host == true && queueitem->r_next != queue_ring) {
			if (lwc_string_isequal(queueitem->host,
					       queueitem->r_next->host, &same_host) ==
			    lwc_error_ok && same_host == true) {
				queueitem = queueitem->r_next;
			}
		}
		queueitem = queueitem->r_next;
	} while (queueitem != queue_ring);
	return false;
}
Exemple #13
0
END_HANDLER

COMBO_CHANGED(combotheme, current_theme)
{
	nsgtk_scaffolding *current = scaf_list;
	char *name;
	if (nsoption_int(current_theme) != 0) {
		if (nsgtk_theme_name() != NULL)
			free(nsgtk_theme_name());
		name = nsgtk_combo_box_text_get_active_text(combotheme);
		if (name != NULL) {
			nsgtk_theme_set_name(name);
			nsgtk_theme_prepare();
			/* possible name leak */
		}
	} else if (nsgtk_theme_name() != NULL) {
		free(nsgtk_theme_name());
		nsgtk_theme_set_name(NULL);
	}

	while (current)	{
		nsgtk_theme_implement(current);
		current = nsgtk_scaffolding_iterate(current);
	}		
}
Exemple #14
0
/**
 * Tests whether a bitmap has an opaque alpha channel
 *
 * \param  bitmap  a bitmap, as returned by bitmap_create()
 * \return whether the bitmap is opaque
 */
bool bitmap_test_opaque(void *bitmap)
{
	int tst;
	struct bitmap *bm = bitmap;

	if (bitmap == NULL) {
		LOG(("NULL bitmap!"));
		return false;
	}

    if( nsoption_int(atari_transparency) == 0 ){
        return( true );
    }

	tst = bm->width * bm->height;

	while (tst-- > 0) {
		if (bm->pixdata[(tst << 2) + 3] != 0xff) {
				LOG(("bitmap %p has transparency",bm));
					return false;
		}
	}
	LOG(("bitmap %p is opaque", bm));
	return true;
}
Exemple #15
0
static nserror nsgtk_option_init(int *pargc, char** argv)
{
	nserror ret;
	char *choices = NULL;

	/* user options setup */
	ret = nsoption_init(set_defaults, &nsoptions, &nsoptions_default);
	if (ret != NSERROR_OK) {
		return ret;
	}

	/* Attempt to load the user choices */
	ret = netsurf_mkpath(&choices, NULL, 2, nsgtk_config_home, "Choices");
	if (ret == NSERROR_OK) {
		nsoption_read(choices, nsoptions);
		free(choices);
	}

	/* overide loaded options with those from commandline */
	nsoption_commandline(pargc, argv, nsoptions);

	/* ensure all options fall within sensible bounds */

	/* Attempt to handle nonsense status bar widths.  These may exist
	 * in people's Choices as the GTK front end used to abuse the
	 * status bar width option by using it for an absolute value in px.
	 * The GTK front end now correctly uses it as a proportion of window
	 * width.  Here we assume that a value of less than 15% is wrong
	 * and set to the default two thirds. */
	if (nsoption_int(toolbar_status_size) < 1500) {
		nsoption_set_int(toolbar_status_size, 6667);
	}

	return NSERROR_OK;
}
Exemple #16
0
END_HANDLER

COMBO_CHANGED(comboButtonType, button_type)
{
	nsgtk_scaffolding *current = scaf_list;
	nsoption_set_int(button_type, nsoption_int(button_type) + 1);

	/* value of 0 is reserved for 'unset' */
	while (current)	{
		nsgtk_scaffolding_reset_offset(current);
		switch(nsoption_int(button_type)) {
		case 1:
			gtk_toolbar_set_style(
				GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
				GTK_TOOLBAR_ICONS);
			gtk_toolbar_set_icon_size(
				GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
				GTK_ICON_SIZE_SMALL_TOOLBAR);
			break;
		case 2:
			gtk_toolbar_set_style(
				GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
				GTK_TOOLBAR_ICONS);
			gtk_toolbar_set_icon_size(
				GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
				GTK_ICON_SIZE_LARGE_TOOLBAR);
			break;
		case 3:
			gtk_toolbar_set_style(
				GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
				GTK_TOOLBAR_BOTH);
			gtk_toolbar_set_icon_size(
				GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
				GTK_ICON_SIZE_LARGE_TOOLBAR);
			break;
		case 4:
			gtk_toolbar_set_style(
				GTK_TOOLBAR(nsgtk_scaffolding_toolbar(current)),
				GTK_TOOLBAR_TEXT);
		default:
			break;
		}
		current = nsgtk_scaffolding_iterate(current);
	}
}
Exemple #17
0
bool ro_gui_options_fonts_ok(wimp_w w)
{
	unsigned int i;

	nsoption_set_int(font_size,
			 ro_gui_get_icon_decimal(w, FONT_DEFAULT_SIZE, 1));

	nsoption_set_int(font_min_size,
			 ro_gui_get_icon_decimal(w, FONT_MINIMUM_SIZE, 1));

	if (nsoption_int(font_size) < nsoption_int(font_min_size)) {
		nsoption_set_int(font_size, nsoption_int(font_min_size));
		ro_gui_set_icon_decimal(w, FONT_DEFAULT_SIZE, nsoption_int(font_size), 1);
	
}

	nsoption_set_charp(font_sans,
			   strdup(ro_gui_get_icon_string(w, FONT_SANS_FIELD)));

	nsoption_set_charp(font_serif,
			   strdup(ro_gui_get_icon_string(w, FONT_SERIF_FIELD)));

	nsoption_set_charp(font_mono,
			   strdup(ro_gui_get_icon_string(w, FONT_MONOSPACE_FIELD)));

	nsoption_set_charp(font_cursive,
			   strdup(ro_gui_get_icon_string(w, FONT_CURSIVE_FIELD)));

	nsoption_set_charp(font_fantasy,
			   strdup(ro_gui_get_icon_string(w, FONT_FANTASY_FIELD)));

	for (i = 0; i != 5; i++) {
		if (!strcmp(font_names[i], ro_gui_get_icon_string(w,
				FONT_DEFAULT_FIELD)))
			break;
	}
	if (i == 5)
		/* this should never happen, but still */
		i = 0;

	nsoption_set_int(font_default, i);

	ro_gui_save_options();
	return true;
}
Exemple #18
0
bool ro_gui_options_fonts_initialise(wimp_w w)
{
	/* set the current values */
	ro_gui_set_icon_decimal(w, FONT_DEFAULT_SIZE, nsoption_int(font_size), 1);
	ro_gui_set_icon_decimal(w, FONT_MINIMUM_SIZE, nsoption_int(font_min_size), 1);
	ro_gui_set_icon_string(w, FONT_SANS_FIELD, nsoption_charp(font_sans), true);
	ro_gui_set_icon_string(w, FONT_SERIF_FIELD, nsoption_charp(font_serif), true);
	ro_gui_set_icon_string(w, FONT_MONOSPACE_FIELD, nsoption_charp(font_mono), true);
	ro_gui_set_icon_string(w, FONT_CURSIVE_FIELD, nsoption_charp(font_cursive), true);
	ro_gui_set_icon_string(w, FONT_FANTASY_FIELD, nsoption_charp(font_fantasy), true);
	ro_gui_set_icon_string(w, FONT_DEFAULT_FIELD,
			       font_names[nsoption_int(font_default)], true);

	if (!ro_gui_options_fonts_init_menu())
		return false;

	/* initialise all functions for a newly created window */
	ro_gui_wimp_event_register_menu_gright(w, FONT_SANS_FIELD,
			FONT_SANS_MENU, rufl_family_menu);
	ro_gui_wimp_event_register_menu_gright(w, FONT_SERIF_FIELD,
			FONT_SERIF_MENU, rufl_family_menu);
	ro_gui_wimp_event_register_menu_gright(w, FONT_MONOSPACE_FIELD,
			FONT_MONOSPACE_MENU, rufl_family_menu);
	ro_gui_wimp_event_register_menu_gright(w, FONT_CURSIVE_FIELD,
			FONT_CURSIVE_MENU, rufl_family_menu);
	ro_gui_wimp_event_register_menu_gright(w, FONT_FANTASY_FIELD,
			FONT_FANTASY_MENU, rufl_family_menu);
	ro_gui_wimp_event_register_menu_gright(w, FONT_DEFAULT_FIELD,
			FONT_DEFAULT_MENU, default_menu);
	ro_gui_wimp_event_register_numeric_field(w, FONT_DEFAULT_SIZE,
			FONT_DEFAULT_INC, FONT_DEFAULT_DEC, 50, 1000, 1, 1);
	ro_gui_wimp_event_register_numeric_field(w, FONT_MINIMUM_SIZE,
			FONT_MINIMUM_INC, FONT_MINIMUM_DEC, 10, 500, 1, 1);
	ro_gui_wimp_event_register_button(w, FONT_DEFAULT_BUTTON,
			ro_gui_options_fonts_default);
	ro_gui_wimp_event_register_cancel(w, FONT_CANCEL_BUTTON);
	ro_gui_wimp_event_register_ok(w, FONT_OK_BUTTON,
			ro_gui_options_fonts_ok);
	ro_gui_wimp_event_set_help_prefix(w, "HelpFontConfig");
	ro_gui_wimp_event_memorise(w);
	return true;

}
Exemple #19
0
/**
 * Plot an image at the given coordinates using the method specified
 *
 * \param area              The sprite area containing the sprite
 * \param x                 Left edge of sprite
 * \param y                 Top edge of sprite
 * \param req_width         The requested width of the sprite
 * \param req_height        The requested height of the sprite
 * \param width             The actual width of the sprite
 * \param height            The actual height of the sprite
 * \param background_colour The background colour to blend to
 * \param repeatx           Repeat the image in the x direction
 * \param repeaty           Repeat the image in the y direction
 * \param background	    Use background image settings (otherwise foreground)
 * \param type              The plot method to use
 * \return true on success, false otherwise
 */
bool image_redraw(osspriteop_area *area, int x, int y, int req_width,
		int req_height, int width, int height,
		colour background_colour,
		bool repeatx, bool repeaty, bool background, image_type type)
{
	unsigned int tinct_options;

	/* failed decompression/loading can result in no image being present */
	if (!area)
		return false;

	osspriteop_id header = (osspriteop_id)
			((char*) area + area->first);
	req_width *= 2;
	req_height *= 2;
	width *= 2;
	height *= 2;
	tinct_options = background ? nsoption_int(bg_plot_style) :
		nsoption_int(fg_plot_style);
	switch (type) {
		case IMAGE_PLOT_TINCT_ALPHA:
			return image_redraw_tinct(header, x, y,
						req_width, req_height,
						width, height,
						background_colour,
						repeatx, repeaty, true,
						tinct_options);
		case IMAGE_PLOT_TINCT_OPAQUE:
			return image_redraw_tinct(header, x, y,
						req_width, req_height,
						width, height,
						background_colour,
						repeatx, repeaty, false,
						tinct_options);
		case IMAGE_PLOT_OS:
			return image_redraw_os(header, x, y, req_width,
						req_height, width, height);
		default:
			break;
	}

	return false;
}
Exemple #20
0
/**
 * Initialize font handling.
 *
 * Exits through die() on error.
 */
void nsfont_init(void)
{
	const char *fallback;
	rufl_code code;

	nsfont_check_fonts();

	LOG("Initialise RUfl");
	code = rufl_init();
	if (code != rufl_OK) {
		if (code == rufl_FONT_MANAGER_ERROR)
			LOG("rufl_init: rufl_FONT_MANAGER_ERROR: 0x%x: %s", rufl_fm_error->errnum, rufl_fm_error->errmess);
		else
			LOG("rufl_init: 0x%x", code);
		die("The Unicode font library could not be initialized. "
				"Please report this to the developers.");
	}
	LOG("RUfl initialised");

	if (rufl_family_list_entries == 0)
		die("No fonts could be found. At least one font must be "
				"installed.");

	fallback = nsfont_fallback_font();

	nsfont_check_option(&nsoption_charp(font_sans), "Homerton", fallback);
	nsfont_check_option(&nsoption_charp(font_serif), "Trinity", fallback);
	nsfont_check_option(&nsoption_charp(font_mono), "Corpus", fallback);
	nsfont_check_option(&nsoption_charp(font_cursive), "Churchill", fallback);
	nsfont_check_option(&nsoption_charp(font_fantasy), "Sassoon", fallback);

	if (nsoption_int(font_default) != PLOT_FONT_FAMILY_SANS_SERIF &&
            nsoption_int(font_default) != PLOT_FONT_FAMILY_SERIF &&
            nsoption_int(font_default) != PLOT_FONT_FAMILY_MONOSPACE &&
            nsoption_int(font_default) != PLOT_FONT_FAMILY_CURSIVE &&
            nsoption_int(font_default) != PLOT_FONT_FAMILY_FANTASY) {
            nsoption_set_int(font_default, PLOT_FONT_FAMILY_SANS_SERIF);
        }
}
Exemple #21
0
void nsgtk_theme_init(void)
{
	size_t len;
	if (nsoption_int(current_theme) == 0) {
		return;
	}

	len = SLEN("themelist") + strlen(res_dir_location) + 1;
	char themefile[len];
	snprintf(themefile, len, "%s%s", res_dir_location, "themelist");
	nsgtk_scaffolding *list = scaf_list;
	nsgtk_theme_verify(NULL);
	FILE *fp = fopen(themefile, "r");
	if (fp == NULL)
		return;
	char buf[50];
	int row_count = 0;
	while (fgets(buf, sizeof(buf), fp) != NULL) {
		if (buf[0] == '\0')
			continue;

		if (row_count++ == nsoption_int(current_theme)) {
			if (current_theme_name != NULL)
				free(current_theme_name);
			/* clear the '\n' ["\n\0"->"\0\0"] */
			buf[strlen(buf) - 1] = '\0';
			current_theme_name = strdup(buf);
			break;
		}
	}
	fclose(fp);

	while (list != NULL) {
		nsgtk_theme_implement(list);
		list = nsgtk_scaffolding_iterate(list);
	}
}
Exemple #22
0
static struct gui_window *
gui_window_create(struct browser_window *bw,
		struct gui_window *existing,
		gui_window_create_flags flags)
{
	struct gui_window *gw;

	gw = calloc(1, sizeof(struct gui_window));

	if (gw == NULL)
		return NULL;

	/* associate the gui window with the underlying browser window
	 */
	gw->bw = bw;

	create_normal_browser_window(gw, nsoption_int(fb_furniture_size));
	gw->localhistory = fb_create_localhistory(bw, fbtk, nsoption_int(fb_furniture_size));

	/* map and request redraw of gui window */
	fbtk_set_mapping(gw->window, true);

	return gw;
}
Exemple #23
0
/**
 * Dispatch as many jobs as we have room to dispatch.
 */
static void fetch_dispatch_jobs(void)
{
	int all_active, all_queued;
#ifdef DEBUG_FETCH_VERBOSE
	struct fetch *q;
	struct fetch *f;
#endif

	if (!queue_ring)
		return; /* Nothing to do, the queue is empty */
	RING_GETSIZE(struct fetch, queue_ring, all_queued);
	RING_GETSIZE(struct fetch, fetch_ring, all_active);

#ifdef DEBUG_FETCH_VERBOSE
	LOG(("queue_ring %i, fetch_ring %i", all_queued, all_active));

	q = queue_ring;
	if (q) {
		do {
			LOG(("queue_ring: %s", q->url));
			q = q->r_next;
		} while (q != queue_ring);
	}
	f = fetch_ring;
	if (f) {
		do {
			LOG(("fetch_ring: %s", f->url));
			f = f->r_next;
		} while (f != fetch_ring);
	}
#endif

	while ( all_queued && all_active < nsoption_int(max_fetchers) ) {
		/*LOG(("%d queued, %d fetching", all_queued, all_active));*/
		if (fetch_choose_and_dispatch()) {
			all_queued--;
			all_active++;
		} else {
			/* Either a dispatch failed or we ran out. Just stop */
			break;
		}
	}
	fetch_active = (all_active > 0);
#ifdef DEBUG_FETCH_VERBOSE
	LOG(("Fetch ring is now %d elements.", all_active));
	LOG(("Queue ring is now %d elements.", all_queued));
#endif
}
Exemple #24
0
END_HANDLER

COMBO_CHANGED(comboTabPosition, position_tab)
{
	nsgtk_scaffolding *current = scaf_list;
	nsoption_set_int(button_type, nsoption_int(button_type) + 1);

	/* value of 0 is reserved for 'unset' */
	while (current)	{
		nsgtk_scaffolding_reset_offset(current);

		nsgtk_reflow_all_windows();

		current = nsgtk_scaffolding_iterate(current);
	}
}
Exemple #25
0
/**
 * Cache a CURL handle for the provided host (if wanted)
 */
static void fetch_curl_cache_handle(CURL *handle, lwc_string *host)
{
#if LIBCURL_VERSION_NUM >= 0x071e00
	/* 7.30.0 or later has its own connection caching; suppress ours */
	curl_easy_cleanup(handle);
	return;
#else
	struct cache_handle *h = 0;
	int c;
	RING_FINDBYLWCHOST(curl_handle_ring, h, host);
	if (h) {
		/* Already have a handle cached for this hostname */
		curl_easy_cleanup(handle);
		return;
	}
	/* We do not have a handle cached, first up determine if the cache is full */
	RING_GETSIZE(struct cache_handle, curl_handle_ring, c);
	if (c >= nsoption_int(max_cached_fetch_handles)) {
		/* Cache is full, so, we rotate the ring by one and
		 * replace the oldest handle with this one. We do this
		 * without freeing/allocating memory (except the
		 * hostname) and without removing the entry from the
		 * ring and then re-inserting it, in order to be as
		 * efficient as we can.
		 */
		if (curl_handle_ring != NULL) {
			h = curl_handle_ring;
			curl_handle_ring = h->r_next;
			curl_easy_cleanup(h->handle);
			h->handle = handle;
			lwc_string_unref(h->host);
			h->host = lwc_string_ref(host);
		} else {
			/* Actually, we don't want to cache any handles */
			curl_easy_cleanup(handle);
		}

		return;
	}
	/* The table isn't full yet, so make a shiny new handle to add to the ring */
	h = (struct cache_handle*)malloc(sizeof(struct cache_handle));
	h->handle = handle;
	h->host = lwc_string_ref(host);
	RING_INSERT(curl_handle_ring, h);
#endif
}
Exemple #26
0
gboolean on_entryProxyPort_changed(GtkWidget *widget, gpointer data)
{
	long port;

	errno = 0;
	port = strtol((char *)gtk_entry_get_text(GTK_ENTRY(entryProxyPort)),
			NULL, 10) & 0xffff;
	if ((port != 0) && (errno == 0)) {
		nsoption_set_int(http_proxy_port, port);
	} else {
		char buf[32];
		snprintf(buf, sizeof(buf), "%d", nsoption_int(http_proxy_port));
		SET_ENTRY(entryProxyPort, buf);
	}

	return FALSE;
}
Exemple #27
0
struct gui_window *
gui_create_browser_window(struct browser_window *bw,
			  struct browser_window *clone,
			  bool new_tab)
{
	struct gui_window *gw;
	LOG(("GCBW calloc"));
	
	gw = calloc(1, sizeof(struct gui_window));

	if (gw == NULL)
		return NULL;

	/* seems we need to associate the gui window with the underlying
	 * browser window
	 */
	LOG(("GCBW next.."));
	
	
	gw->bw = bw;

	LOG(("fb_furn_size is STUB now!..."));
	
	 //nsoption_int(fb_furniture_size);
	LOG(("GCBW create normal window..."));
	
	
	create_normal_browser_window(gw, 18); //nsoption_int(fb_furniture_size));
	LOG(("GCBW create local history..."));
	
	gw->localhistory = fb_create_localhistory(bw, fbtk, nsoption_int(fb_furniture_size));

	/* map and request redraw of gui window */
	LOG(("GCBW set mapping"));
	
	fbtk_set_mapping(gw->window, true);
	LOG(("GCBW OK!"));
	

	return gw;
}
Exemple #28
0
/**
 * Callback to retrieve the User-Agent defaults for a CSS property.
 *
 * \param pw        HTML document
 * \param property  Property to retrieve defaults for
 * \param hint      Pointer to hint object to populate
 * \return CSS_OK       on success,
 *         CSS_INVALID  if the property should not have a user-agent default.
 */
css_error ua_default_for_property(void *pw, uint32_t property, css_hint *hint)
{
	if (property == CSS_PROP_COLOR) {
		hint->data.color = 0xff000000;
		hint->status = CSS_COLOR_COLOR;
	} else if (property == CSS_PROP_FONT_FAMILY) {
		hint->data.strings = NULL;
		switch (nsoption_int(font_default)) {
		case PLOT_FONT_FAMILY_SANS_SERIF:
			hint->status = CSS_FONT_FAMILY_SANS_SERIF;
			break;
		case PLOT_FONT_FAMILY_SERIF:
			hint->status = CSS_FONT_FAMILY_SERIF;
			break;
		case PLOT_FONT_FAMILY_MONOSPACE:
			hint->status = CSS_FONT_FAMILY_MONOSPACE;
			break;
		case PLOT_FONT_FAMILY_CURSIVE:
			hint->status = CSS_FONT_FAMILY_CURSIVE;
			break;
		case PLOT_FONT_FAMILY_FANTASY:
			hint->status = CSS_FONT_FAMILY_FANTASY;
			break;
		}
	} else if (property == CSS_PROP_QUOTES) {
		/** \todo Not exactly useful :) */
		hint->data.strings = NULL;
		hint->status = CSS_QUOTES_NONE;
	} else if (property == CSS_PROP_VOICE_FAMILY) {
		/** \todo Fix this when we have voice-family done */
		hint->data.strings = NULL;
		hint->status = 0;
	} else {
		return CSS_INVALID;
	}

	return CSS_OK;
}
Exemple #29
0
bool ro_gui_options_security_initialise(wimp_w w)
{
	/* set the current values */
	ro_gui_set_icon_selected_state(w, SECURITY_REFERRER,
                                       nsoption_bool(send_referer));
	ro_gui_set_icon_integer(w, SECURITY_DURATION_FIELD,
                                nsoption_int(expire_url));

	/* initialise all functions for a newly created window */
	ro_gui_wimp_event_register_checkbox(w, SECURITY_REFERRER);
	ro_gui_wimp_event_register_numeric_field(w, SECURITY_DURATION_FIELD,
			SECURITY_DURATION_DEC, SECURITY_DURATION_INC,
			0, 365, 1, 0);
	ro_gui_wimp_event_register_button(w, SECURITY_DEFAULT_BUTTON,
			ro_gui_options_security_default);
	ro_gui_wimp_event_register_cancel(w, SECURITY_CANCEL_BUTTON);
	ro_gui_wimp_event_register_ok(w, SECURITY_OK_BUTTON,
			ro_gui_options_security_ok);
	ro_gui_wimp_event_set_help_prefix(w, "HelpSecurityConfig");
	ro_gui_wimp_event_memorise(w);
	return true;

}
Exemple #30
0
static void nsgtk_options_theme_combo(void) {
/* populate theme combo from themelist file */
	GtkBox *box = GTK_BOX(gtk_builder_get_object(gladeFile, "themehbox"));
	char buf[50];
	size_t len = SLEN("themelist") + strlen(res_dir_location) + 1;
	char themefile[len];

	combotheme = nsgtk_combo_box_text_new();

	if ((combotheme == NULL) || (box == NULL)) {
		warn_user(messages_get("NoMemory"), 0);
		return;
	}
	snprintf(themefile, len, "%sthemelist", res_dir_location);
	FILE *fp = fopen((const char *)themefile, "r");
	if (fp == NULL) {
		LOG(("Failed opening themes file"));
		warn_user("FileError", (const char *) themefile);
		return;
	}
	while (fgets(buf, sizeof(buf), fp) != NULL) {
		/* Ignore blank lines */
		if (buf[0] == '\0')
			continue;
		
		/* Remove trailing \n */
		buf[strlen(buf) - 1] = '\0';
		
		nsgtk_combo_box_text_append_text(combotheme, buf);
	}
	fclose(fp);
	gtk_combo_box_set_active(GTK_COMBO_BOX(combotheme), 
				 nsoption_int(current_theme));
	gtk_box_pack_start(box, combotheme, FALSE, TRUE, 0);
	gtk_widget_show(combotheme);		
}