~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to plug-ins/pygimp/plug-ins/colorxhtml.py

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
import gimp
26
26
from gimpfu import *
27
27
 
 
28
gettext.install("gimp20-python", gimp.locale_directory, unicode=True)
 
29
 
 
30
(CHARS_SOURCE, CHARS_FILE, CHARS_PARAMETER) = range(3)
 
31
 
28
32
escape_table = {
29
33
    '&': '&amp;',
30
34
    '<': '&lt;',
40
44
}
41
45
"""
42
46
 
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">
44
49
<html>
45
50
<head>
46
 
<title>css color html by The GIMP</title>
 
51
<title>CSS Color XHTML written by GIMP</title>
47
52
%s
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" />
49
54
</head>
50
55
<body>
51
56
<pre>
52
57
"""
53
58
 
54
 
postamble = """\n</pre>\n</html>\n"""
 
59
postamble = """\n</pre>\n</body>\n</html>\n"""
55
60
 
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
60
65
    bpp = drawable.bpp
73
78
 
74
79
        css = file(cssname, 'w')
75
80
 
76
 
    if source_type == 0:
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:
81
86
        chars = characters
82
87
 
83
88
    allchars = string.maketrans('', '')
97
102
    else:
98
103
        data = list('X' * 80)
99
104
 
100
 
    pr = drawable.get_pixel_rgn(0, 0, width, height, FALSE, FALSE)
 
105
    pr = drawable.get_pixel_rgn(0, 0, width, height, False, False)
101
106
 
102
 
    gimp.progress_init("Saving '%s' as COLORXHTML..." % filename)
 
107
    gimp.progress_init(_("Saving as colored XHTML"))
103
108
 
104
109
    style = style_def % size
105
110
 
106
111
    if separate:
107
 
        ss = '<link rel="stylesheet" type="text/css" href="%s">' % cssfile
 
112
        ss = '<link rel="stylesheet" type="text/css" href="%s" />' % cssfile
108
113
        css.write(style)
109
114
    else:
110
115
        ss = '<style type="text/css">\n%s</style>' % style
147
152
        css.close()
148
153
 
149
154
def register_save():
150
 
    gimp.register_save_handler("file_colorxhtml_save", "colorxhtml", "")
 
155
    gimp.register_save_handler("file-colorxhtml-save", "xhtml", "")
151
156
 
152
157
class RowIterator:
153
158
    def __init__(self, row, bpp):
175
180
        return pixel
176
181
 
177
182
register(
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)",
181
 
    "Manish Singh",
182
 
    "Manish Singh",
 
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",
183
188
    "2003",
184
 
    "<Save>/COLORXHTML",
 
189
    N_("Colored XHTML"),
185
190
    "RGB",
186
191
    [
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",
190
 
                  ""),
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"),
 
197
                   ""),
 
198
        (PF_INT,   "font-size",  _("Fo_nt size in pixels"), 10),
 
199
        (PF_BOOL,  "separate",   _("_Write a separate CSS file"),   True)
193
200
    ],
194
201
    [],
195
 
    python_colorxhtml,
196
 
    on_query=register_save)
 
202
    colorxhtml, on_query=register_save,
 
203
    menu="<Save>", domain=("gimp20-python", gimp.locale_directory)
 
204
    )
197
205
 
198
206
main()