[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ff-cvs] fenfire/org/fenfire/fenpdf importpdf.py actions...
From: |
Tuomas J. Lukka |
Subject: |
[ff-cvs] fenfire/org/fenfire/fenpdf importpdf.py actions... |
Date: |
Tue, 26 Aug 2003 06:06:39 -0400 |
CVSROOT: /cvsroot/fenfire
Module name: fenfire
Branch:
Changes by: Tuomas J. Lukka <address@hidden> 03/08/26 06:06:39
Modified files:
org/fenfire/fenpdf: importpdf.py
org/fenfire/fenpdf/actions: keyboard.py
Log message:
When importing PDF, transclude them instead of moving to them. Easier
to get collections of files into system.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/fenpdf/importpdf.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/fenfire/fenfire/org/fenfire/fenpdf/actions/keyboard.py.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
Patches:
Index: fenfire/org/fenfire/fenpdf/actions/keyboard.py
diff -u fenfire/org/fenfire/fenpdf/actions/keyboard.py:1.10
fenfire/org/fenfire/fenpdf/actions/keyboard.py:1.11
--- fenfire/org/fenfire/fenpdf/actions/keyboard.py:1.10 Mon Aug 25 20:34:28 2003
+++ fenfire/org/fenfire/fenpdf/actions/keyboard.py Tue Aug 26 06:06:39 2003
@@ -7,6 +7,7 @@
# Therefore, we'll just use a single class.
import vob
+import alph
from org.fenfire.swamp import Nodes
from org import fenfire as ff
@@ -154,16 +155,45 @@
self.fenPDF.animation.regenerateVS()
- def importPDF(self):
+ def importPDF(self, main = None):
"""Show the dialog for importing new PDF files.
+
+ If the given (or upper) main node is on a canvas,
+ transclude from all PDF files the topmost part
+ of the first page.
"""
- scrollBlock = ff.fenpdf.importpdf.importPDF_select(
+ self.fenPDF.animation.regenerateVS()
+ scrollBlocks = ff.fenpdf.importpdf.importPDF_select(
self.fenPDF.fen,
self.fenPDF.structure.treeTime)
- p('sc: ',scrollBlock,'id: ', scrollBlock.getID())
- if scrollBlock != None:
+ p('sc: ',scrollBlocks)
+ if not len(scrollBlocks): return
+ if not main:
+ main = self.fenPDF.views.getBuoyManager().singles[0].mainNode
+ if isinstance(main.getPlane(), alph.PageScrollBlock):
self.moveTo(None, scrollBlock)
- self.fenPDF.animation.regenerateVS()
+ return
+ #
+ # Now transclude.
+ #
+ x = main.getFocus().getPanX()
+ y = main.getFocus().getPanY()
+ for sb in scrollBlocks:
+ node = self.fenPDF.actions.abstract.createNewNode(
+ main.getPlane(),
+ x,
+ y,
+ )
+ page = sb.getPage(0);
+ size = page.getSize();
+ self.fenPDF.fen.txt.set(
+ node,
+ self.fenPDF.fen.enfMaker.makeEnfilade(
+ page.subArea(0, 0, size.width, size.height / 3)
+ ))
+ x += 100
+ y += 200
+
def newCanvas(self):
canvas = Nodes.N()
Index: fenfire/org/fenfire/fenpdf/importpdf.py
diff -u fenfire/org/fenfire/fenpdf/importpdf.py:1.3
fenfire/org/fenfire/fenpdf/importpdf.py:1.4
--- fenfire/org/fenfire/fenpdf/importpdf.py:1.3 Mon Aug 18 16:07:19 2003
+++ fenfire/org/fenfire/fenpdf/importpdf.py Tue Aug 26 06:06:38 2003
@@ -11,6 +11,8 @@
def importPDF_select(fen, treetime):
"""Show a file selection dialog and import a file.
+
+ Returns a sequence of ScrollBlock objects imported.
"""
file = selectFile("Select PS/PDF file to import, or directory for all
files in it")
@@ -19,14 +21,19 @@
lastFile = None
if file.isDirectory():
+ blocks = []
for f in file.listFiles():
try:
if f.isDirectory(): continue
- importPDF(fen, treetime, f)
+ blocks.append(
+ importPDF(fen, treetime, f)
+ )
except exception:
print "EXCEPTION LOADING",f,":",sys.exc_info()
+ blocks = [b for b in blocks if b != None ]
+ return blocks
else:
- return importPDF(fen, treetime, file)
+ return [importPDF(fen, treetime, file)]
def selectFile(string):
"""Select a file using an AWT dialog, with the given prompt.
@@ -63,6 +70,8 @@
elif type.startswith('GIF'): p('GIF not yet supported!'); scrollBlock =
None
# XXX JPEG?!?
elif type.startswith('\xff\xd8\xff\xe0'): p('JPEG not yet supported!');
scrollBlock = None
+
+ if scrollBlock == None: return
if treetime != None:
try:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [ff-cvs] fenfire/org/fenfire/fenpdf importpdf.py actions...,
Tuomas J. Lukka <=