[cairo-commit] pycairo/examples/cairo_snippets snippets_ps.py, 1.4, 1.5 snippets_pdf.py, 1.8, 1.9 snippets_gtk.py, 1.11, 1.12

Steve Chaplin commit at pdx.freedesktop.org
Mon Aug 29 12:31:22 EST 2005


Committed by: stevech1097

Update of /cvs/cairo/pycairo/examples/cairo_snippets
In directory gabe:/tmp/cvs-serv753/examples/cairo_snippets

Modified Files:
	snippets_ps.py snippets_pdf.py snippets_gtk.py 
Log Message:
'SC'

Index: snippets_ps.py
===================================================================
RCS file: /cvs/cairo/pycairo/examples/cairo_snippets/snippets_ps.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- snippets_ps.py	18 Jul 2005 08:25:33 -0000	1.4
+++ snippets_ps.py	29 Aug 2005 02:31:19 -0000	1.5
@@ -22,21 +22,21 @@
 def do_snippet (snippet):
     if verbose_mode:
         print 'processing %s' % snippet,
-    
+
     filename = 'snippets/%s.ps' % snippet
     surface = cairo.PSSurface (filename, width_in_points, height_in_points)
     cr = cairo.Context (surface)
 
     cr.save()
-    try:    
+    try:
         execfile ('snippets/%s.py' % snippet, globals(), locals())
     except:
-        exc_type, exc_value = sys.exc_info()[:2] 
+        exc_type, exc_value = sys.exc_info()[:2]
         print >> sys.stderr, exc_type, exc_value
     else:
         cr.restore()
         cr.show_page()
-    
+
     if verbose_mode:
         print
 
@@ -45,7 +45,7 @@
     if len(sys.argv) > 1 and sys.argv[1] == '-s':
         verbose_mode = False
         del sys.argv[1]
-    
+
     if len(sys.argv) > 1: # do specified snippets
         snippet_list = sys.argv[1:]
     else:                 # do all snippets

Index: snippets_pdf.py
===================================================================
RCS file: /cvs/cairo/pycairo/examples/cairo_snippets/snippets_pdf.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- snippets_pdf.py	22 Jun 2005 00:48:07 -0000	1.8
+++ snippets_pdf.py	29 Aug 2005 02:31:19 -0000	1.9
@@ -22,7 +22,7 @@
 def do_snippet (snippet):
     if verbose_mode:
         print 'processing %s' % snippet,
-    
+
     filename = 'snippets/%s.pdf' % snippet
     surface = cairo.PDFSurface (filename, width_in_points, height_in_points)
     cr = cairo.Context (surface)
@@ -31,12 +31,12 @@
     try:
         execfile ('snippets/%s.py' % snippet, globals(), locals())
     except:
-        exc_type, exc_value = sys.exc_info()[:2] 
+        exc_type, exc_value = sys.exc_info()[:2]
         print >> sys.stderr, exc_type, exc_value
     else:
         cr.restore()
         cr.show_page()
-    
+
     if verbose_mode:
         print
 
@@ -45,7 +45,7 @@
     if len(sys.argv) > 1 and sys.argv[1] == '-s':
         verbose_mode = False
         del sys.argv[1]
-    
+
     if len(sys.argv) > 1: # do specified snippets
         snippet_list = sys.argv[1:]
     else:                 # do all snippets

Index: snippets_gtk.py
===================================================================
RCS file: /cvs/cairo/pycairo/examples/cairo_snippets/snippets_gtk.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- snippets_gtk.py	9 Aug 2005 14:37:55 -0000	1.11
+++ snippets_gtk.py	29 Aug 2005 02:31:19 -0000	1.12
@@ -5,10 +5,12 @@
 from math import pi as M_PI  # used by many snippets
 import sys
 
+import cairo
 import gtk
+if gtk.pygtk_version < (2,7,0):
+    import cairo.gtk
+
 import pango
-import cairo
-import cairo.gtk
 
 from snippets import snip_list, snippet_normalize, snippet_set_bg_svg
 
@@ -58,10 +60,12 @@
 
 
     def da_expose_event (self, da, event, data=None):
-        width  = da.allocation.width
-        height = da.allocation.height
+        x, y, width, height = da.allocation
 
-        cr = cairo.gtk.gdk_cairo_create (da.window)
+        if gtk.pygtk_version >= (2,7,0):
+            cr = da.window.cairo_create()
+        else:
+            cr = cairo.gtk.gdk_cairo_create (da.window)
 
         # set window bg
         cr.set_source_rgb (*self._bg_rgb)
@@ -73,7 +77,7 @@
             exec (self.snippet_str, globals(), locals())
         except:
             exc_type, exc_value = sys.exc_info()[:2]
-            print exc_type, exc_value
+            print >> sys.stderr, exc_type, exc_value
 
         return True
 



More information about the cairo-commit mailing list