Fixed up cursor iteration more properly(?)
[automanga.git] / manga / reader.py
CommitLineData
9f1721f1
FT
1import threading
2from gi.repository import Gtk as gtk, GdkPixbuf as gdkpix, Gdk as gdk, GObject as gobject
3cc7937c 3from . import lib, profile
03feea07
FT
4
5class notdone(Exception): pass
6
7class future(threading.Thread):
8 prog = None
9
10 def __init__(self):
11 super(future, self).__init__()
12 self._val = None
13 self._exc = None
c9e2eced 14 self._notlist = []
3cc7937c 15 self._tstarted = False
95213fa6 16 self.setDaemon(True)
c9e2eced
FT
17
18 def start(self):
3cc7937c 19 if not self._tstarted:
c9e2eced 20 super(future, self).start()
3cc7937c 21 self._tstarted = True
03feea07
FT
22
23 def run(self):
24 try:
25 val = self.value()
26 except Exception as e:
c84f095d
FT
27 self._exc = e
28 gobject.idle_add(self._callcbs, True)
03feea07 29 else:
c84f095d
FT
30 self._val = [val]
31 gobject.idle_add(self._callcbs, True)
32
33 def _callcbs(self, final):
34 nls = []
35 for cb in self._notlist:
36 if cb():
37 nls.append(cb)
38 self._notlist = [] if final else nls
c9e2eced
FT
39
40 # Caller must hold GDK lock
41 def notify(self, cb):
42 self.start()
43 if not self.done:
44 self._notlist.append(cb)
45 else:
46 cb()
47
48 def progcb(self):
c84f095d 49 gobject.idle_add(self._callcbs, False)
03feea07
FT
50
51 @property
52 def val(self):
c9e2eced 53 self.start()
03feea07
FT
54 if self._exc is not None:
55 raise self._exc
56 if self._val is None:
57 raise notdone()
58 return self._val[0]
59
60 @property
61 def done(self):
c9e2eced 62 self.start()
03feea07
FT
63 return self._exc != None or self._val != None
64
c9e2eced
FT
65 def wait(self):
66 self.start()
67 while self.is_alive():
68 self.join()
69 return self.val
70
03feea07
FT
71class imgload(future):
72 def __init__(self, page):
c9e2eced 73 super(imgload, self).__init__()
03feea07
FT
74 self.page = page
75 self.st = None
c9e2eced 76 self.start()
03feea07
FT
77
78 def value(self):
9f1721f1 79 buf = gdkpix.PixbufLoader()
4177506b 80 done = False
1aa34ec9
FT
81 try:
82 with self.page.open() as st:
83 self.p = 0
84 self.st = st
85 while True:
86 read = st.read(1024)
3cc7937c 87 if read == b"":
1aa34ec9
FT
88 break
89 self.p += len(read)
90 buf.write(read)
91 self.progcb()
92 self.st = None
4177506b 93 done = True
1aa34ec9 94 finally:
4177506b
FT
95 try:
96 buf.close()
97 except:
98 if done:
99 raise
04f773e3 100 return buf.get_pixbuf()
03feea07
FT
101
102 @property
103 def prog(self):
104 if self.st is None or self.st.clen is None:
105 return None
106 return float(self.p) / float(self.st.clen)
107
c9e2eced
FT
108class pagecache(object):
109 def __init__(self, sz=50):
110 self.sz = sz
111 self.bk = []
112
113 def __getitem__(self, page):
114 idl = page.idlist()
115 for ol, f in self.bk:
116 if ol == idl:
117 return f
118 f = imgload(page)
119 self.bk.append((idl, f))
120 if len(self.bk) > self.sz:
d9163efe 121 self.bk = self.bk[-self.sz:]
c9e2eced
FT
122 return f
123
a133683d
FT
124 def __delitem__(self, page):
125 idl = page.idlist()
126 for i, (ol, f) in enumerate(self.bk):
127 if ol == idl:
128 del self.bk[i]
129 return
130 raise KeyError(idl)
131
c9e2eced
FT
132class relpageget(future):
133 def __init__(self, cur, prev, cache=None):
134 super(relpageget, self).__init__()
135 self.cur = lib.cursor(cur)
136 self.prev = prev
137 self.cache = cache
138 self.start()
139
140 def value(self):
141 try:
142 if self.prev:
143 page = self.cur.prev()
144 else:
145 page = self.cur.next()
146 except StopIteration:
147 page = None
148 else:
149 if self.cache:
150 self.cache[page]
151 return page
152
012c4cae
FT
153class idpageget(future):
154 def __init__(self, base, idlist):
155 super(idpageget, self).__init__()
156 self.bnode = base
157 self.idlist = idlist
158
159 def value(self):
0e3381a2
FT
160 try:
161 return lib.cursor(self.bnode.byidlist(self.idlist)).cur
162 except KeyError:
163 raise KeyError("could not find last read page: " + repr(self.idlist))
012c4cae 164
c9e2eced
FT
165class pageget(future):
166 def __init__(self, fnode):
167 super(pageget, self).__init__()
168 self.fnode = fnode
169 self.start()
170
171 def value(self):
172 return lib.cursor(self.fnode).cur
173
174class ccursor(object):
175 def __init__(self, ob, cache=None):
176 self.cur = lib.cursor(ob)
177 self.prev = relpageget(self.cur, True, cache)
178 self.next = relpageget(self.cur, False, cache)
179
03feea07
FT
180class pageview(gtk.Widget):
181 def __init__(self, pixbuf):
182 super(pageview, self).__init__()
183 self.pixbuf = pixbuf
184 self.zoomed = None, None
185 self.fit = True
186 self.zoom = 1.0
9f1721f1 187 self.interp = gdkpix.InterpType.HYPER
03feea07
FT
188 self.off = 0, 0
189
190 def get_osize(self):
191 return self.pixbuf.get_width(), self.pixbuf.get_height()
192
193 def get_asize(self):
9f1721f1
FT
194 alloc = self.get_allocation()
195 return alloc.width, alloc.height
03feea07
FT
196
197 def do_realize(self):
9f1721f1
FT
198 alloc = self.get_allocation()
199 attr = gdk.WindowAttr()
200 attr.window_type = gdk.WindowType.CHILD
201 attr.x = alloc.x
202 attr.y = alloc.y
203 attr.width = alloc.width
204 attr.height = alloc.height
205 attr.visual = self.get_visual()
206 attr.event_mask = self.get_events() | gdk.EventMask.EXPOSURE_MASK
207 a = gdk.WindowAttributesType
208 wnd = gdk.Window(self.get_parent_window(), attr, a.X | a.Y | a.VISUAL)
209 wnd.set_background_pattern(None)
210 self.set_window(wnd)
211 self.register_window(wnd)
212 self.set_realized(True)
213
214 # XXX: Why don't these actually get called?
215 def get_preferred_width(self):
216 return 0, max(min(self.get_osize()[0], 4096), 0)
217 def get_preferred_height(self):
218 return 0, max(min(self.get_osize()[1], 4096), 0)
03feea07
FT
219
220 def fitzoom(self):
221 w, h = self.get_osize()
9f1721f1 222 alloc = self.get_allocation()
03feea07
FT
223 return min(float(alloc.width) / float(w), float(alloc.height) / float(h))
224
225 def do_size_allocate(self, alloc):
9f1721f1 226 self.set_allocation(alloc)
03feea07
FT
227 if self.fit:
228 self.zoom = self.fitzoom()
5e98c1aa
FT
229 else:
230 aw, ah = self.get_asize()
231 zw, zh = self.get_zsize()
232 ox, oy = self.off
233 if zw >= aw and ox + aw > zw:
234 ox = zw - aw
235 if zh >= ah and oy + ah > zh:
236 oy = zh - ah
237 self.off = ox, oy
9f1721f1
FT
238 if self.get_realized():
239 self.get_window().move_resize(alloc.x, alloc.y, alloc.width, alloc.height)
03feea07
FT
240
241 def get_zoomed(self):
242 zoom = self.zoom
243 pz, zbuf = self.zoomed
244 if pz != zoom:
245 w, h = self.get_osize()
246 zbuf = self.pixbuf.scale_simple(int(w * zoom), int(h * zoom), self.interp)
247 self.zoomed = zoom, zbuf
248 return zbuf
249
250 def get_zsize(self):
251 zbuf = self.get_zoomed()
252 return zbuf.get_width(), zbuf.get_height()
253
9f1721f1 254 def do_draw(self, cr):
03feea07
FT
255 aw, ah = self.get_asize()
256 dw, dh = aw, ah
257 zbuf = self.get_zoomed()
258 zw, zh = self.get_zsize()
259 ox, oy = self.off
260 dx, dy = 0, 0
261 if zw < aw:
262 dx = (aw - zw) / 2
263 dw = zw
264 if zh < ah:
265 dy = (ah - zh) / 2
266 dh = zh
9f1721f1
FT
267 gdk.cairo_set_source_pixbuf(cr, zbuf, dx - ox, dy - oy)
268 cr.paint()
03feea07
FT
269
270 def set_off(self, off):
271 aw, ah = self.get_asize()
272 zw, zh = self.get_zsize()
273 ox, oy = off
274 ox, oy = int(ox), int(oy)
275 if ox > zw - aw: ox = zw - aw
276 if oy > zh - ah: oy = zh - ah
277 if ox < 0: ox = 0
278 if oy < 0: oy = 0
279 self.off = ox, oy
280 self.queue_draw()
281
282 def set_zoom(self, zoom):
283 if zoom is not None: zoom = float(zoom)
284 aw, ah = self.get_asize()
285 zw, zh = self.get_zsize()
286 dw, dh = zw - aw, zh - ah
287 ox, oy = self.off
288 xa = float(ox) / float(dw) if dw > 0 else 0.5
289 ya = float(oy) / float(dh) if dh > 0 else 0.5
290
291 if zoom is None:
292 self.fit = True
293 self.zoom = self.fitzoom()
294 else:
295 self.fit = False
296 self.zoom = zoom
297
298 zw, zh = self.get_zsize()
299 dw, dh = zw - aw, zh - ah
300 ox = int(xa * dw) if dw > 0 else 0
301 oy = int(ya * dh) if dh > 0 else 0
302 self.set_off((ox, oy))
03feea07 303
304250ff 304class msgproc(object):
c9e2eced
FT
305 def attach(self, reader):
306 self.rd = reader
9e49da7a 307 self.msg = gtk.Alignment(xalign=0.0, yalign=0.5, xscale=0.0, yscale=0.0)
c9e2eced 308 self.hlay = gtk.HBox()
304250ff 309 self.lbl = gtk.Label("")
9f1721f1 310 self.hlay.pack_start(self.lbl, True, True, 0)
c9e2eced
FT
311 self.lbl.show()
312 self.msg.add(self.hlay)
313 self.hlay.show()
9f1721f1 314 self.rd.sbar.pack_start(self.msg, True, True, 0)
c9e2eced 315 self.msg.show()
304250ff
FT
316 self._prog = None
317
318 def prog(self, p):
03fdcb32
FT
319 if p is not None:
320 if self._prog is None:
321 self._prog = gtk.ProgressBar()
9f1721f1 322 self.hlay.pack_start(self._prog, True, True, 5)
03fdcb32 323 self._prog.show()
304250ff 324 self._prog.set_fraction(p)
304250ff
FT
325 elif p is None and self._prog is not None:
326 self.hlay.remove(self._prog)
327 self._prog = None
328
329 def abort(self):
330 self.rd.sbar.remove(self.msg)
331
332class pagefetch(msgproc):
333 def __init__(self, fpage, setcb=None):
334 self.pg = fpage
335 self.setcb = setcb
c9e2eced 336
304250ff
FT
337 def attach(self, reader):
338 super(pagefetch, self).attach(reader)
339 self.lbl.set_text("Fetching page...")
c9e2eced
FT
340 self.pg.notify(self.haspage)
341
342 def haspage(self):
343 if self.rd.pagefetch.cur != self: return False
344 if not self.pg.done:
345 return True
346 if self.pg.val is not None:
347 self.rd.setpage(self.pg.val)
95213fa6
FT
348 if self.setcb is not None:
349 self.setcb(self.pg.val)
c9e2eced
FT
350 self.rd.pagefetch.set(None)
351
304250ff 352class imgfetch(msgproc):
c9e2eced
FT
353 def __init__(self, fimage):
354 self.img = fimage
355 self.upd = False
356 self.error = None
357
358 def attach(self, reader):
304250ff
FT
359 super(imgfetch, self).attach(reader)
360 self.lbl.set_text("Fetching image...")
c9e2eced
FT
361 self.img.notify(self.imgprog)
362
363 def imgprog(self):
364 if self.rd.imgfetch.cur != self: return False
365 if self.img.done:
366 try:
367 img = self.img.val
368 except Exception as e:
369 self.error = str(e)
370 else:
371 self.rd.setimg(img)
372 self.upd = True
373 self.rd.imgfetch.set(None)
374 else:
304250ff 375 self.prog(self.img.prog)
c9e2eced
FT
376 return True
377
378 def abort(self):
379 self.rd.sbar.remove(self.msg)
380 if not self.upd:
381 self.rd.setimg(None)
382 if self.error is not None:
383 self.rd.pagelbl.set_text("Error fetching image: " + self.error)
384
304250ff 385class preload(msgproc):
95213fa6
FT
386 def __init__(self, fpage):
387 self.pg = fpage
388
389 def attach(self, reader):
304250ff
FT
390 super(preload, self).attach(reader)
391 self.lbl.set_text("Fetching next page...")
95213fa6
FT
392 self.pg.notify(self.haspage)
393
394 def haspage(self):
395 if self.rd.preload.cur != self: return False
396 if not self.pg.done: return True
397 if self.pg.val is not None:
398 self.img = self.rd.cache[self.pg.val]
95213fa6
FT
399 self.lbl.set_text("Loading next page...")
400 self.img.notify(self.imgprog)
401 else:
402 self.rd.preload.set(None)
403
404 def imgprog(self):
405 if self.rd.preload.cur != self: return False
406 if self.img.done:
407 self.rd.preload.set(None)
408 else:
304250ff 409 self.prog(self.img.prog)
95213fa6
FT
410 return True
411
412 def abort(self):
413 self.rd.sbar.remove(self.msg)
414
c9e2eced
FT
415class procslot(object):
416 __slots__ = ["cur", "p"]
417 def __init__(self, p):
418 self.cur = None
419 self.p = p
420
421 def set(self, proc):
422 if self.cur is not None:
423 self.cur.abort()
424 self.cur = None
425 if proc is not None:
426 self.cur = proc
427 try:
428 proc.attach(self.p)
429 except:
430 self.cur = None
431 raise
432
32b804f2
FT
433class plistget(future):
434 def __init__(self, node):
435 super(plistget, self).__init__()
436 self.node = node
437
438 def value(self):
439 return list(self.node)
440
441class loadplist(object):
442 def __init__(self, pnode):
443 self.pnode = pnode
444 self.flist = plistget(self.pnode)
445
446 def attach(self, sbox):
447 self.sbox = sbox
448 self.flist.notify(self.haslist)
449
450 def haslist(self):
451 if self.sbox.loadlist.cur != self: return False
452 if not self.flist.done: return True
453 self.sbox.setlist(self.flist.val)
454
455class sbox(gtk.ComboBox):
456 def __init__(self, reader, ptnode):
457 super(sbox, self).__init__()
458 self.rd = reader
459 self.node = ptnode
460 self.pnode, self.pidx = self.node.stack[-1]
461
462 self.bk = gtk.ListStore(str)
463 self.set_model(self.bk)
464 cell = gtk.CellRendererText()
465 self.pack_start(cell, True)
466 self.add_attribute(cell, "text", 0)
467 self.set_active(0)
468
469 self.set_sensitive(False)
d9163efe 470 self.set_focus_on_click(False)
32b804f2
FT
471 self.bk.append([ptnode.name])
472 self.loadlist = procslot(self)
473 self.loadlist.set(loadplist(self.pnode))
474
475 def setlist(self, ls):
476 self.bk.clear()
477 for i, ch in enumerate(ls):
d9163efe 478 self.bk.append(["%i/%i: %s" % (i + 1, len(ls), ch.name)])
32b804f2
FT
479 self.set_active(self.pidx)
480 self.set_sensitive(True)
481 self.connect("changed", self.changed_cb)
482
483 def changed_cb(self, wdg, data=None):
484 self.rd.fetchpage(pageget(self.pnode[self.get_active()]))
485
0b60fcf8
FT
486class profprop(object):
487 def __init__(self, key, default=None):
488 self.key = key
489 self.default = default
490
491 def __get__(self, ins, cls):
492 return ins.profile.props.get(self.key, self.default)
493
494 def __set__(self, ins, val):
495 ins.profile.props[self.key] = val
496 ins.profile.save()
497
498 def __delete__(self, ins):
499 del ins.profile.props[self.key]
500 ins.profile.save()
501
43a12498 502class reader(gtk.Window):
43423668 503 def __init__(self, manga, prof=None):
9f1721f1 504 super(reader, self).__init__()
43a12498
FT
505 self.connect("delete_event", lambda wdg, ev, data=None: False)
506 self.connect("destroy", lambda wdg, data=None: self.quit())
507 self.connect("key_press_event", self.key)
c9e2eced
FT
508 self.cache = pagecache()
509 self.pagefetch = procslot(self)
510 self.imgfetch = procslot(self)
95213fa6 511 self.preload = procslot(self)
43423668 512 self.profile = prof if prof else profile.memmanga(None, None, manga.id)
c9e2eced 513
32b804f2
FT
514 self.manga = manga
515 self.page = None
516 self.sboxes = []
517 self.point = None
518
c9e2eced 519 vlay = gtk.VBox()
9f1721f1
FT
520 self.pfr = gtk.Frame()
521 self.pfr.set_shadow_type(gtk.ShadowType.NONE)
522 vlay.pack_start(self.pfr, True, True, 0)
43a12498 523 self.pfr.show()
32b804f2 524 self.sboxbar = gtk.HBox()
9e49da7a 525 algn = gtk.Alignment(xalign=0.0, yalign=0.5, xscale=0.0, yscale=0.0)
3cc7937c 526 sboxlbl = gtk.Label(self.manga.name + ": ")
32b804f2
FT
527 algn.add(sboxlbl)
528 sboxlbl.show()
9f1721f1 529 self.sboxbar.pack_start(algn, False, True, 0)
32b804f2 530 algn.show()
9f1721f1 531 vlay.pack_start(self.sboxbar, False, True, 0)
32b804f2 532 self.sboxbar.show()
c9e2eced
FT
533 self.sbar = gtk.HBox()
534 self.pagelbl = gtk.Label("")
9e49da7a 535 algn = gtk.Alignment(xalign=0.0, yalign=0.5, xscale=0.0, yscale=0.0)
c9e2eced
FT
536 algn.add(self.pagelbl)
537 self.pagelbl.show()
9f1721f1 538 self.sbar.pack_start(algn, True, True, 0)
c9e2eced 539 algn.show()
9f1721f1 540 vlay.pack_end(self.sbar, False, True, 0)
c9e2eced
FT
541 self.sbar.show()
542 self.add(vlay)
543 vlay.show()
43a12498 544
0b60fcf8
FT
545 if self.curpage is not None:
546 self.fetchpage(idpageget(self.manga, self.curpage))
012c4cae
FT
547 else:
548 self.fetchpage(pageget(self.manga))
43a12498
FT
549 self.updtitle()
550
0b60fcf8
FT
551 zmode = profprop("zmode", "fit")
552 curpage = profprop("curpage")
553
c9e2eced
FT
554 def updpagelbl(self):
555 if self.page is None:
556 self.pagelbl.set_text("")
557 else:
558 w, h = self.page.get_osize()
3cc7937c 559 self.pagelbl.set_text("%s\u00d7%s (%d%%)" % (w, h, int(self.page.zoom * 100)))
c9e2eced 560
32b804f2
FT
561 def updsboxes(self, page):
562 nodes = [node for node, idx in page.stack[1:]] + [page]
563 l = min(len(self.sboxes), len(nodes))
564 for i, (pbox, node) in enumerate(zip(self.sboxes, nodes)):
565 if pbox.node != node:
566 l = i
567 break
3cc7937c 568 for i in range(l, len(self.sboxes)):
32b804f2
FT
569 self.sboxbar.remove(self.sboxes[i])
570 self.sboxes = self.sboxes[:l]
3cc7937c 571 for i in range(l, len(nodes)):
32b804f2 572 new = sbox(self, nodes[i])
9f1721f1 573 self.sboxbar.pack_start(new, False, True, 5)
32b804f2
FT
574 self.sboxes.append(new)
575 new.show()
576
c9e2eced 577 def setimg(self, img):
43a12498
FT
578 if self.page is not None:
579 self.pfr.remove(self.page)
580 self.page = None
c9e2eced
FT
581 if img is not None:
582 self.page = pageview(img)
0b60fcf8
FT
583 if self.zmode == "1":
584 self.page.set_zoom(1)
585 self.page.set_off((0, 0))
43a12498
FT
586 self.pfr.add(self.page)
587 self.page.show()
c9e2eced
FT
588 self.updpagelbl()
589
590 def setpage(self, page):
591 if self.point is not None:
592 self.point = None
593 if page is not None:
0b60fcf8 594 self.curpage = page.idlist()
c9e2eced
FT
595 self.point = ccursor(page, self.cache)
596 self.imgfetch.set(imgfetch(self.cache[page]))
597 else:
598 self.setimg(None)
32b804f2 599 self.updsboxes(page)
c9e2eced 600
95213fa6 601 def fetchpage(self, fpage, setcb=None):
c9e2eced 602 self.imgfetch.set(None)
95213fa6
FT
603 proc = pagefetch(fpage, setcb)
604 self.pagefetch.set(proc)
605 return proc
43a12498
FT
606
607 def updtitle(self):
3cc7937c 608 self.set_title("Automanga \u2013 " + self.manga.name)
03feea07
FT
609
610 @property
611 def zoom(self):
612 return self.page.zoom
613 @zoom.setter
614 def zoom(self, zoom):
615 self.page.set_zoom(zoom)
c9e2eced 616 self.updpagelbl()
03feea07
FT
617
618 def pan(self, off):
619 ox, oy = self.page.off
620 px, py = off
621 self.page.set_off((ox + px, oy + py))
622
03feea07 623 def key(self, wdg, ev, data=None):
c9e2eced 624 if ev.keyval in [ord('Q'), ord('q')]:
03feea07 625 self.quit()
c9e2eced
FT
626 elif ev.keyval in [65307]:
627 if self.page is not None:
628 self.pagefetch.set(None)
629 self.imgfetch.set(None)
630 if self.page is not None:
631 if ev.keyval in [ord('O'), ord('o')]:
632 self.zoom = 1.0
0b60fcf8 633 self.zmode = "1"
c9e2eced
FT
634 elif ev.keyval in [ord('P'), ord('p')]:
635 self.zoom = None
0b60fcf8 636 self.zmode = "fit"
c9e2eced
FT
637 elif ev.keyval in [ord('[')]:
638 self.zoom = min(self.zoom * 1.25, 3)
639 elif ev.keyval in [ord(']')]:
640 self.zoom /= 1.25
641 elif ev.keyval in [ord('h')]:
642 self.pan((-100, 0))
643 elif ev.keyval in [ord('j')]:
644 self.pan((0, 100))
645 elif ev.keyval in [ord('k')]:
646 self.pan((0, -100))
647 elif ev.keyval in [ord('l')]:
648 self.pan((100, 0))
649 elif ev.keyval in [ord('H')]:
650 self.page.set_off((0, self.page.off[1]))
651 elif ev.keyval in [ord('J')]:
652 self.page.set_off((self.page.off[0], self.page.get_asize()[1]))
653 elif ev.keyval in [ord('K')]:
654 self.page.set_off((self.page.off[1], 0))
655 elif ev.keyval in [ord('L')]:
656 self.page.set_off((self.page.get_asize()[0], self.page.off[1]))
657 if self.point is not None:
658 if ev.keyval in [ord(' ')]:
dcaf33f5
FT
659 if self.page and self.page.off[1] + self.page.get_asize()[1] < self.page.get_zsize()[1]:
660 self.pan((0, self.page.get_asize()[1] - 50))
661 else:
662 self.fetchpage(self.point.next, lambda page: self.preload.set(preload(relpageget(page, False, self.cache))))
c9e2eced 663 elif ev.keyval in [65288]:
dcaf33f5
FT
664 if self.page and self.page.off[1] > 0:
665 self.pan((0, -(self.page.get_asize()[1] - 50)))
666 else:
667 self.fetchpage(self.point.prev, lambda page: self.preload.set(preload(relpageget(page, True, self.cache))))
a133683d
FT
668 elif ev.keyval in [ord('R'), ord('r')]:
669 page = self.point.cur.cur
670 del self.cache[page]
671 self.imgfetch.set(imgfetch(self.cache[page]))
03feea07
FT
672
673 def quit(self):
674 self.hide()
d9bf4bdb 675 gtk.main_quit()
43a12498 676gobject.type_register(reader)