Exemple #1
0
void
html_cluev_set_style (HTMLClueV *cluev, HTMLStyle *style)
{
	if (style != NULL) {
		if (cluev->border_color)
			html_color_unref (cluev->border_color);

		if (cluev->background_color)
			html_color_unref (cluev->background_color);

		cluev->padding = style->padding;

		cluev->border_style = style->border_style;
		cluev->border_width = style->border_width;
		cluev->border_color = style->border_color;
		if (cluev->border_color)
			html_color_ref (cluev->border_color);

		cluev->background_color = style->bg_color;
		if (cluev->background_color)
			html_color_ref (cluev->background_color);
	} else {
		if (cluev->border_color)
			html_color_unref (cluev->border_color);

		if (cluev->background_color)
			html_color_unref (cluev->background_color);

		cluev->border_style = HTML_BORDER_NONE;
		cluev->border_width = 0;
		cluev->border_color = NULL;
		cluev->background_color = NULL;
	}
}
Exemple #2
0
static void
html_cluev_destroy (HTMLObject *self)
{
	HTMLClueV *cluev = HTML_CLUEV (self);

	if (cluev->border_color)
		html_color_unref (cluev->border_color);
	cluev->border_color = NULL;

	if (cluev->background_color)
		html_color_unref (cluev->background_color);
	cluev->background_color = NULL;

	(* HTML_OBJECT_CLASS (parent_class)->destroy) (self);
}
Exemple #3
0
void
html_style_free (HTMLStyle *style)
{
	if (!style)
		return;

	g_free (style->face);
	g_free (style->bg_image);
	g_free (style->width);
	g_free (style->height);

	if (style->color)
		html_color_unref (style->color);

	if (style->bg_color)
		html_color_unref (style->bg_color);

	if (style->border_color)
		html_color_unref (style->border_color);

	g_free (style);
}
Exemple #4
0
HTMLStyle *
parse_border_color (HTMLStyle *style,const gchar *value)
{
	GdkColor color;

	if (html_parse_color (value, &color)) {
		HTMLColor *hc = html_color_new_from_gdk_color (&color);
		style = html_style_set_border_color (style, hc);
		html_color_unref (hc);
	}

	return style;
}
Exemple #5
0
void
html_colorset_destroy (HTMLColorSet *set)
{
	gint i;

	g_return_if_fail (set != NULL);

	for (i = 0; i < HTMLColors; i++) {
		if (set->color[i] != NULL)
			html_color_unref (set->color[i]);
	}

	if (set->slaves)
		g_slist_free (set->slaves);

	g_free (set);
}
Exemple #6
0
HTMLStyle *
html_style_set_border_color (HTMLStyle *style, HTMLColor *color)
{
	HTMLColor *old;

	if (!style)
		style = html_style_new ();

	old = style->border_color;

	style->border_color = color;

	if (color)
		html_color_ref (color);

	if (old)
		html_color_unref (old);

	return style;
}
Exemple #7
0
HTMLStyle *
html_style_add_background_color (HTMLStyle *style, HTMLColor *color)
{
	HTMLColor *old;

	if (!style)
		style = html_style_new ();

	old = style->bg_color;

	style->bg_color = color;

	if (color)
		html_color_ref (color);

	if (old)
		html_color_unref (old);

	return style;
}
Exemple #8
0
HTMLStyle *
html_style_copy_onlyinherit(HTMLStyle *orig)
{
	HTMLStyle *style;
	if (!orig)
		return NULL;

	style = html_style_copy(orig);

	style->border_width = 0;
	style->border_style = HTML_BORDER_NONE;
	if (style->border_color)
		html_color_unref (style->border_color);
	style->border_color = NULL;
	style->padding = 0;
	style->leftmargin = 0;
	style->rightmargin = 0;
	style->topmargin = 0;
	style->bottommargin = 0;
	return style;
}
Exemple #9
0
/* atributes from style only*/
HTMLStyle *
html_style_add_styleattribute (HTMLStyle *style, const gchar *attr, const gchar *value)
{
	if (!attr)
		return style;
	if (!value)
		return style;

	if (!g_ascii_strcasecmp ("align", attr)) {
		style = html_style_add_text_align (style, parse_halign (value, HTML_VALIGN_NONE));
	} else if (!g_ascii_strcasecmp ("valign", attr)) {
		style = html_style_add_text_valign (style, parse_valign (value, HTML_VALIGN_MIDDLE));
	} else if (!g_ascii_strcasecmp ("width", attr)) {
		style = html_style_add_width (style, value);
	} else if (!g_ascii_strcasecmp ("height", attr)) {
		style = html_style_add_height (style, value);
	} else if (!g_ascii_strcasecmp ("color", attr)) {
		GdkColor color;

		if (html_parse_color (value, &color)) {
			HTMLColor *hc = html_color_new_from_gdk_color (&color);
			style = html_style_add_color (style, hc);
			html_color_unref (hc);

		}
	} else if (!g_ascii_strcasecmp ("face", attr)) {
		style = html_style_add_font_face (style, value);
	} else if (!g_ascii_strcasecmp ("background-image", attr)) {
		style = html_style_add_background_image (style, value);
	} else if (!g_ascii_strcasecmp ("border", attr)) {
		style = parse_border (style, value);
	} else if (!g_ascii_strcasecmp ("border-style", attr)) {
		style = parse_border_style (style, value);
	} else if (!g_ascii_strcasecmp ("dir", attr)) {
		style = html_style_add_dir (style, value);
	} else if (!g_ascii_strcasecmp ("border-color", attr)) {
		style = parse_border_color (style, value);
	} else if (!g_ascii_strcasecmp ("border-width", attr)) {
		style = parse_border_width (style, value);
	} else if (!g_ascii_strcasecmp ("padding", attr)) {
		style = html_style_set_padding (style, atoi (value));
	} else if (!g_ascii_strcasecmp ("bgcolor", attr) ) {
		GdkColor color;

		if (html_parse_color (value, &color)) {
			HTMLColor *hc = html_color_new_from_gdk_color (&color);
			style = html_style_add_background_color (style, hc);
			html_color_unref (hc);
		}
	} else if (!g_ascii_strcasecmp ("white-space", attr)) {
		/* normal, pre, nowrap, pre-wrap, pre-line, inherit  */
		/*
		if (!g_ascii_strcasecmp ("normal", value)) {
			style = html_style_set_white_space (style, HTML_WHITE_SPACE_NORMAL);
		} else if (!g_ascii_strcasecmp ("pre", value)) {
			style = html_style_set_white_space (style, HTML_WHITE_SPACE_PRE);
		} else if (!g_ascii_strcasecmp ("nowrap", value)) {
			style = html_style_set_white_space (style, HTML_WHITE_SPACE_NOWRAP);
		} else if (!g_ascii_strcasecmp ("pre-wrap", value)) {
			style = html_style_set_white_space (style, HTML_WHITE_SPACE_PRE_WRAP);
		} else if (!g_ascii_strcasecmp ("pre-line", value)) {
			style = html_style_set_white_space (style, HTML_WHITE_SPACE_PRE_LINE);
		} else if (!g_ascii_strcasecmp ("inherit", value)) {
			style = html_style_set_white_space (style, HTML_WHITE_SPACE_INHERIT);
		}*/
	} else if (!g_ascii_strcasecmp ("attr-decoration", attr)) {
		if (!g_ascii_strcasecmp ("none", value)) {
			style = html_style_unset_decoration (style, ~GTK_HTML_FONT_STYLE_SIZE_MASK);
		}
	} else if (!g_ascii_strcasecmp ("display", attr)) {
		if (!g_ascii_strcasecmp ("block", value)) {
			style = html_style_set_display (style, HTMLDISPLAY_BLOCK);
		} else if (!g_ascii_strcasecmp ("inline", value)) {
			style = html_style_set_display (style, HTMLDISPLAY_INLINE);
		} else if (!g_ascii_strcasecmp ("none", value)) {
			style = html_style_set_display (style, HTMLDISPLAY_NONE);
		} else if (!g_ascii_strcasecmp ("inline-table", value)) {
			style = html_style_set_display (style, HTMLDISPLAY_INLINE_TABLE);
		}
	} else if (!g_ascii_strcasecmp ("attr-align", attr)) {
		if (!g_ascii_strcasecmp ("center", value)) {
			style = html_style_add_text_align (style, HTML_HALIGN_CENTER);
		}
	} else if (!g_ascii_strcasecmp ("width", attr)) {
		style = html_style_add_width (style, value);
	} else if (!g_ascii_strcasecmp ("height", attr)) {
		style = html_style_add_height (style, value);
	} else if (!g_ascii_strcasecmp ("clear", attr)) {
		if (!g_ascii_strcasecmp ("left", value)) {
			style = html_style_set_clear (style, HTML_CLEAR_LEFT);
		} else if (!g_ascii_strcasecmp ("right", value)) {
			style = html_style_set_clear (style, HTML_CLEAR_RIGHT);
		} else if (!g_ascii_strcasecmp ("both", value)) {
			style = html_style_set_clear (style, HTML_CLEAR_ALL);
		} else if (!g_ascii_strcasecmp ("inherit", value)) {
			style = html_style_set_clear (style, HTML_CLEAR_INHERIT);
		} else if (!g_ascii_strcasecmp ("none", value)) {
			style = html_style_set_clear (style, HTML_CLEAR_NONE);
		}
	} else if (!g_ascii_strcasecmp ("href", attr)) { /*a*/
		if (!style)
			style = html_style_new ();
		if (style->href)
			g_free (style->href);
		style->href = g_strdup(value);
	} else if (!g_ascii_strcasecmp ("src", attr)) { /*iframe, frame, img*/
		if (!style)
			style = html_style_new ();
		if (style->url)
			g_free (style->url);
		style->url = g_strdup(value);
	} else if (!g_ascii_strcasecmp ("target", attr)) {
		if (!style)
			style = html_style_new ();
		if (style->target)
			g_free (style->target);
		style->target = g_strdup(value);
	} else if ( !g_ascii_strcasecmp ("list-style-type", attr)) {
		style = parse_list_type (style, value);
	} else if (!g_ascii_strcasecmp ("leftmargin", attr)) {
		if (!style)
			style = html_style_new ();
		style->leftmargin = atoi (value);
	} else if (!g_ascii_strcasecmp ("rightmargin", attr)) {
		if (!style)
			style = html_style_new ();
		style->rightmargin = atoi (value);
	} else if (!g_ascii_strcasecmp ("topmargin", attr)) {
		if (!style)
			style = html_style_new ();
		style->topmargin = atoi (value);
	} else if (!g_ascii_strcasecmp ("bottommargin", attr)) {
		if (!style)
			style = html_style_new ();
		style->bottommargin = atoi (value);
	} else if (!g_ascii_strcasecmp ("marginwidth", attr)) {
		if (!style)
			style = html_style_new ();
		style->leftmargin = style->rightmargin = atoi (value);
	} else if (!g_ascii_strcasecmp ("marginheight", attr)) {
		if (!style)
			style = html_style_new ();
		style->topmargin = style->bottommargin = atoi (value);
	}
	return style;
}
Exemple #10
0
HTMLStyle *
html_style_add_attribute (HTMLStyle *style,
                          const gchar *attr)
{
	gchar **prop;

	prop = g_strsplit (attr, ";", 100);
	if (prop) {
		gint i;
		for (i = 0; prop[i]; i++) {
			gchar *text;

			text = g_strstrip (prop[i]);
			if (!g_ascii_strncasecmp ("color: ", text, 7)) {
				GdkColor color;

				if (html_parse_color (g_strstrip (text + 7), &color)) {
					HTMLColor *hc = html_color_new_from_gdk_color (&color);
					style = html_style_add_color (style, hc);
					html_color_unref (hc);

				}
			} else if (!g_ascii_strncasecmp ("background: ", text, 12)) {
				GdkColor color;

				if (html_parse_color (text + 12, &color)) {
					HTMLColor *hc = html_color_new_from_gdk_color (&color);
					style = html_style_add_background_color (style, hc);
					html_color_unref (hc);
				}
			} else if (!g_ascii_strncasecmp ("background-color: ", text, 18)) {
				GdkColor color;

				if (html_parse_color (text + 18, &color)) {
					HTMLColor *hc = html_color_new_from_gdk_color (&color);
					style = html_style_add_background_color (style, hc);
					html_color_unref (hc);
				}
			} else if (!g_ascii_strncasecmp ("background-image: ", text, 18)) {
				style = html_style_add_background_image (style, text + 18);

			} else if (!g_ascii_strncasecmp ("border: ", text, 8)) {
				style = parse_border (style, text + 8);
			} else if (!g_ascii_strncasecmp ("border-style: ", text, 14)) {
				style = parse_border_style (style, text + 14);
			} else if (!g_ascii_strncasecmp ("border-color: ", text, 14)) {
				style = parse_border_color (style, text + 14);
			} else if (!g_ascii_strncasecmp ("border-width: ", text, 14)) {
				style = parse_border_width (style, text + 14);
			} else if (!g_ascii_strncasecmp ("padding: ", text, 9)) {
				gchar *value = text + 9;

				style = html_style_set_padding (style, atoi (value));
			} else if (!g_ascii_strncasecmp ("white-space: ", text, 13)) {
				/* normal, pre, nowrap, pre-wrap, pre-line, inherit  */
				/*
				if (!g_ascii_strcasecmp ("normal", text + 13)) {
					style = html_style_set_white_space (style, HTML_WHITE_SPACE_NORMAL);
				} else if (!g_ascii_strcasecmp ("pre", text + 13)) {
					style = html_style_set_white_space (style, HTML_WHITE_SPACE_PRE);
				} else if (!g_ascii_strcasecmp ("nowrap", text + 13)) {
					style = html_style_set_white_space (style, HTML_WHITE_SPACE_NOWRAP);
				} else if (!g_ascii_strcasecmp ("pre-wrap", text + 13)) {
					style = html_style_set_white_space (style, HTML_WHITE_SPACE_PRE_WRAP);
				} else if (!g_ascii_strcasecmp ("pre-line", text + 13)) {
					style = html_style_set_white_space (style, HTML_WHITE_SPACE_PRE_LINE);
				} else if (!g_ascii_strcasecmp ("inherit", text + 13)) {
					style = html_style_set_white_space (style, HTML_WHITE_SPACE_INHERIT);
				}
				*/
			} else if (!g_ascii_strncasecmp ("text-decoration: none", text, 21)) {
				style = html_style_unset_decoration (style, ~GTK_HTML_FONT_STYLE_SIZE_MASK);
			} else if (!g_ascii_strncasecmp ("display: ", text, 9)) {
				gchar *value = text + 9;
				if (!g_ascii_strcasecmp ("block", value)) {
					style = html_style_set_display (style, DISPLAY_BLOCK);
				} else if (!g_ascii_strcasecmp ("inline", value)) {
					style = html_style_set_display (style, DISPLAY_INLINE);
				} else if (!g_ascii_strcasecmp ("none", value)) {
					style = html_style_set_display (style, DISPLAY_NONE);
				} else if (!g_ascii_strcasecmp ("inline-table", value)) {
					style = html_style_set_display (style, DISPLAY_INLINE_TABLE);
				}
			} else if (!g_ascii_strncasecmp ("text-align: center", text, 18)) {
				style = html_style_add_text_align (style, HTML_HALIGN_CENTER);
			} else if (!g_ascii_strncasecmp ("width: ", text, 7)) {
				style = html_style_add_width (style, text + 7);
			} else if (!g_ascii_strncasecmp ("height: ", text, 8)) {
				style = html_style_add_height (style, text + 8);
			} else if (!g_ascii_strncasecmp ("clear: ", text, 7)) {
				gchar *value = text + 7;

				if (!g_ascii_strcasecmp ("left", value)) {
					style = html_style_set_clear (style, HTML_CLEAR_LEFT);
				} else if (!g_ascii_strcasecmp ("right", value)) {
					style = html_style_set_clear (style, HTML_CLEAR_RIGHT);
				} else if (!g_ascii_strcasecmp ("both", value)) {
					style = html_style_set_clear (style, HTML_CLEAR_ALL);
				} else if (!g_ascii_strcasecmp ("inherit", value)) {
					style = html_style_set_clear (style, HTML_CLEAR_INHERIT);
				} else if (!g_ascii_strcasecmp ("none", value)) {
					style = html_style_set_clear (style, HTML_CLEAR_NONE);
				}
			}
		}
		g_strfreev (prop);
	}
	return style;
}