title: Python GTK - DrawingArea with opacity
body: <p>I'm working on a transparent window which includes a DrawingArea widget, which gets on top with a solid background color, but I want to keep it transparent. I've tried everything, unfortunately the docs are a bit dated (with PyGTK on the top results). Other things I've done is connecting its <code>draw</code> event as I'm doing it with the window, but with no success.</p>
  
  <p>Of course I need the square to be shown, so I just need the background color to transparent. I've also tried with <code>modify_bg</code>, but I only manage to set it to solid colors.</p>
  
  <p>Here's what I have so far.</p>
  
  <pre><code>#!/usr/bin/env python
  
  from gi.repository import Gtk, Gdk
  import cairo
  
  class GWin (Gtk.Window):
    def __init__(self):
      super(GWin, self).__init__()
      self.set_position(Gtk.WindowPosition.CENTER)
      self.screen = self.get_screen()
      self.visual = self.screen.get_rgba_visual()
      if self.visual != None and self.screen.is_composited():
        self.set_visual(self.visual)
      self.connect("draw", self.on_win_draw)
      self.set_app_paintable(True)
      self.show_all()
      self.draw_area = Gtk.DrawingArea()
      self.draw_area.add_events(Gdk.EventMask.BUTTON_PRESS_MASK) 
      self.draw_area.connect('draw', self.begin_draw)
      self.draw_area.show()
      self.add(self.draw_area)
  
    def begin_draw(self, draw_area, cairo_context):
      cairo_context.rectangle(20, 20, 120, 120)
      cairo_context.stroke()
  
    def on_win_draw(self, widget, cr):
      cr.set_source_rgba(1, 1, 1, 0.1)
      cr.set_operator(cairo.OPERATOR_SOURCE)
      cr.paint()
      cr.set_operator(cairo.OPERATOR_OVER)
  
  win = GWin()
  win.connect('delete-event', Gtk.main_quit)
  Gtk.main()
  </code></pre>