CSSU's portrait mode support - WIP
[drlaunch] / drlaunch / src / sig.py
1 #!/usr/bin/env python
2 # coding=UTF-8
3
4 # Copyright (C) 2010 Stefanos Harhalakis
5 #
6 # This file is part of wifieye.
7 #
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.
12 #
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.
17 #
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/>.
20 #
21 # $Id: 0.py 2265 2010-02-21 19:16:26Z v13 $
22
23 __version__ = "$Id: 0.py 2265 2010-02-21 19:16:26Z v13 $"
24
25 import gtk
26
27 class Disconnector(object):
28     def __init__(self):
29         self.chandles=[]
30         if isinstance(self, gtk.Widget):
31             self.c(self, 'delete-event', self.slotDiscDeleteEvent)
32
33     def c(self, obj, signal, slot, *args):
34         h=obj.connect(signal, slot, *args)
35         self.chandles.append((obj, h))
36
37         return(h)
38
39     def slotDiscDeleteEvent(self, sender, event):
40 #       print "sig-delete-event"
41         self.dis_finish()
42         return(False)
43
44     def dis_finish(self, obj=None):
45         """ Disconnect all signals. If obj is specified the only disconnect
46         signals from that object """
47         for i in self.chandles:
48             if obj!=None and i[0]!=obj:
49                 continue
50             #print i[0], i[1]
51             i[0].disconnect(i[1])
52         
53         if obj==None:
54             self.chandles=[]
55         else:
56             self.chandles=[a for a in self.chandles if a[0]!=obj]
57
58 # vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent:
59