~dpm/qreator/snap

« back to all changes in this revision

Viewing changes to qreator/QreatorWindow.py

  • Committer: David Planella
  • Date: 2012-05-27 10:14:16 UTC
  • mto: This revision was merged to the branch mainline in revision 67.
  • Revision ID: david.planella@ubuntu.com-20120527101416-xrtrwwm7g8lzaqhx
Added proper icon for the Software Centre app QR codes. Added texture to the background of the QR code image

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
logger = logging.getLogger('qreator')
32
32
 
33
33
from qreator_lib import Window
 
34
from qreator_lib.helpers import get_media_file as get_media_file
34
35
 
35
36
import sys
36
37
sys.path.insert(0, "/usr/share/software-center/")
124
125
        self.ui.qr_app.attach(complete, 1, 0, 1, 1)
125
126
 
126
127
        self.qr_code_placeholder = 'qreator'
 
128
        
 
129
        self.texture = cairo.ImageSurface.create_from_png(get_media_file("pattern.png"))
127
130
 
128
131
    def on_entryText_changed(self, widget, data=None):
129
132
        self.update_qr_code(widget.get_text(widget.get_start_iter(),
380
383
 
381
384
        # Fill the rounded rectangle with a linear gradient
382
385
        lg = cairo.LinearGradient(0.0, 0.0, 500.0, 500.0)
383
 
        lg.add_color_stop_rgba(0, 1, 1, 1, 1)
384
 
        lg.add_color_stop_rgba(1, 0.678, 0.678, 0.678, 1)
 
386
        lg.add_color_stop_rgba(0, 0.27, 0.27, 0.27, 1) # 1,1,1 is white
 
387
        lg.add_color_stop_rgba(1, 0.22, 0.22, 0.22, 1)
385
388
 
386
389
        ctx.set_source(lg)
387
390
        ctx.fill()
 
391
        
 
392
        # Load a texture and superpose it to the gradient, tiled
 
393
        pattern = cairo.SurfacePattern(self.texture)
 
394
        pattern.set_extend(cairo.EXTEND_REPEAT)
 
395
        ctx.set_source(pattern)
 
396
        ctx.paint()
 
397
        
 
398
        ###image = cairo.ImageSurface.create_from_png(get_media_file('background.png'))
 
399
        ###ctx.set_source_surface(image, 0.0, 0.0)
 
400
        ###ctx.paint()
388
401
 
389
402
        ## Create the QR code
390
403
        qr_code = QRCode()