43
preamble = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
47
preamble = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
48
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
46
<title>css color html by The GIMP</title>
51
<title>CSS Color XHTML written by GIMP</title>
48
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
53
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
54
postamble = """\n</pre>\n</html>\n"""
59
postamble = """\n</pre>\n</body>\n</html>\n"""
56
def python_colorxhtml(img, drawable, filename, raw_filename,
57
source_type, characters, size, separate):
61
def colorxhtml(img, drawable, filename, raw_filename,
62
source_type, characters, size, separate):
58
63
width = drawable.width
59
64
height = drawable.height
74
79
css = file(cssname, 'w')
77
chars = file(inspect.getsourcefile(python_colorxhtml)).read()
78
elif source_type == 1:
81
if source_type == CHARS_SOURCE:
82
chars = file(inspect.getsourcefile(colorxhtml)).read()
83
elif source_type == CHARS_FILE:
79
84
chars = file(characters).read()
80
elif source_type == 2:
85
elif source_type == CHARS_PARAMETER:
83
88
allchars = string.maketrans('', '')
98
103
data = list('X' * 80)
100
pr = drawable.get_pixel_rgn(0, 0, width, height, FALSE, FALSE)
105
pr = drawable.get_pixel_rgn(0, 0, width, height, False, False)
102
gimp.progress_init("Saving '%s' as COLORXHTML..." % filename)
107
gimp.progress_init(_("Saving as colored XHTML"))
104
109
style = style_def % size
107
ss = '<link rel="stylesheet" type="text/css" href="%s">' % cssfile
112
ss = '<link rel="stylesheet" type="text/css" href="%s" />' % cssfile
110
115
ss = '<style type="text/css">\n%s</style>' % style
149
154
def register_save():
150
gimp.register_save_handler("file_colorxhtml_save", "colorxhtml", "")
155
gimp.register_save_handler("file-colorxhtml-save", "xhtml", "")
152
157
class RowIterator:
153
158
def __init__(self, row, bpp):
178
"file_colorxhtml_save",
179
"Saves the image as colored xhtml text",
180
"Saves the image as colored xhtml text (based on perl version by Marc Lehmann)",
183
"file-colorxhtml-save",
184
N_("Save as colored XHTML"),
185
"Saves the image as colored XHTML text (based on Perl version by Marc Lehmann)",
186
"Manish Singh and Carol Spears",
187
"Manish Singh and Carol Spears",
187
(PF_RADIO, "source", "Where to take the characters from", 0,
188
(("sourcecode", 0), ("textfile", 1), ("filename", 2))),
189
(PF_FILE, "characters", "The filename to read or the characters to use",
191
(PF_INT, "font_size", "The font size in pixels", 10),
192
(PF_BOOL, "separate", "Separate CSS file", TRUE)
192
(PF_RADIO, "source", _("Character _source"), 0,
193
((_("Source code"), CHARS_SOURCE),
194
(_("Text file"), CHARS_FILE),
195
(_("Entry box"), CHARS_PARAMETER))),
196
(PF_FILE, "characters", _("_File to read or characters to use"),
198
(PF_INT, "font-size", _("Fo_nt size in pixels"), 10),
199
(PF_BOOL, "separate", _("_Write a separate CSS file"), True)
196
on_query=register_save)
202
colorxhtml, on_query=register_save,
203
menu="<Save>", domain=("gimp20-python", gimp.locale_directory)