Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell/view/OverlayWindow.py
blob: 93719a7c770da2b97b63d02c2e16cb5f8c14e624 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Copyright (C) 2006, Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

import gtk
import cairo


class OverlayWindow(gtk.Window):
	def __init__(self, lower_window):
		gtk.Window.__init__(self)

		colormap = self.get_screen().get_rgba_colormap()
		colormap=None
		if not colormap:
			raise RuntimeError("The window manager doesn't support compositing.")
		self.set_colormap(colormap)

		self.realize()

		self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
		self.window.set_accept_focus(False)
		self.window.set_transient_for(lower_window)

		self.set_decorated(False)
		self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
		self.set_default_size(gtk.gdk.screen_width(), gtk.gdk.screen_height())
		self.set_app_paintable(True)

		self.connect('expose-event', self._expose_cb)

	def _expose_cb(self, widget, event):
		cr = widget.window.cairo_create()
		cr.set_source_rgba(0.0, 0.0, 0.0, 0.4) # Transparent
		cr.set_operator(cairo.OPERATOR_SOURCE)
		cr.paint()
		return False