4 # Copyright (C) 2010 Stefanos Harhalakis
6 # This file is part of wifieye.
8 # wifieye is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # wifieye is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with wifieye. If not, see <http://www.gnu.org/licenses/>.
21 # $Id: 0.py 2265 2010-02-21 19:16:26Z v13 $
23 __version__ = "$Id: 0.py 2265 2010-02-21 19:16:26Z v13 $"
25 from icon import Icon, getIcon
33 class IconWidget(gtk.Widget):
34 def __init__(self, isconfig, config):
35 gtk.Widget.__init__(self)
38 self.icon=Icon(isconfig, config)
40 def getMaxIconSizeFull(self):
42 w=c.getIconSizeRange()[1] + 2*c.getIconPaddingRange()[1] + \
43 2*c.getIconMarginRange()[1]
48 w=self.getMaxIconSizeFull()
49 self.set_size_request(2*w, 2*w)
52 screen=self.get_screen()
53 self.set_colormap(screen.get_rgba_colormap())
54 self.set_app_paintable(True)
56 self.set_flags(self.flags() | gtk.REALIZED)
58 self.window=gdk.Window(
59 self.get_parent_window(),
60 width=self.allocation.width,
61 height=self.allocation.height,
62 window_type=gdk.WINDOW_CHILD,
63 wclass=gdk.INPUT_OUTPUT,
64 event_mask=self.get_events() | gdk.EXPOSURE_MASK)
66 self.window.set_user_data(self)
68 self.window.move_resize(*self.allocation)
70 # style=self.get_style()
71 # style.set_background(self.window, gtk.STATE_NORMAL)
72 # self.gc=style.bg_gc[gtk.STATE_NORMAL]
74 self.icon.setWindow(self.window)
77 def do_unrealize(self):
79 self.window.set_user_data(None)
81 def do_expose_event(self, event):
82 cr=self.window.cairo_create()
84 cr.rectangle(event.area.x, event.area.y,
85 event.area.width, event.area.height)
90 # Paint the background
91 style=self.get_style()
92 col=style.bg[gtk.STATE_NORMAL]
93 cr.set_source_color(col)
96 x2=self.config.getIconSizeFull()
98 # col=style.fg[gtk.STATE_ACTIVE]
99 # cr.set_source_color(col)
100 # #cr.set_source_rgba(0,1,1,0.5)
101 # cr.rectangle(1,1,x2+x2+2,x2+2)
105 self.icon.draw(cr, 0, 0)
106 self.icon.draw(cr, x2, 0)
107 self.icon.draw(cr, 0, x2)
108 self.icon.draw(cr, x2, x2)
110 def setApp(self, app):
116 app=apps.readOne(self.app)
117 app['icon2']=getIcon(app['icon'], self.config.getIconSize())
118 self.icon.setApp(app)
122 gobject.type_register(IconWidget)
124 # vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent: