/usr/lib/python2.7/dist-packages/ginga/Mixins.py is in python-ginga 2.7.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | #
# Mixins.py -- Mixin classes for FITS viewer.
#
# This is open-source software licensed under a BSD license.
# Please see the file LICENSE.txt for details.
from ginga.misc.Callback import Callbacks
class UIMixin(object):
def __init__(self):
self.ui_active = False
for name in ('motion', 'button-press', 'button-release',
'key-press', 'key-release', 'drag-drop',
'scroll', 'map', 'focus', 'enter', 'leave',
'cursor-changed'):
self.enable_callback(name)
def ui_is_active(self):
return self.ui_active
def ui_set_active(self, tf):
self.ui_active = tf
## def make_callback(self, name, *args, **kwdargs):
## if hasattr(self, 'objects'):
## # Invoke callbacks on all our layers that have the UI mixin
## for obj in self.objects:
## if isinstance(obj, UIMixin) and obj.ui_isActive():
## obj.make_callback(name, *args, **kwdargs)
## return super(UIMixin, self).make_callback(name, *args, **kwdargs)
def make_ui_callback(self, name, *args, **kwdargs):
"""Invoke callbacks on all objects (i.e. layers) from the top to
the bottom, returning when the first one returns True. If none
returns True, then make the callback on our 'native' layer.
"""
if hasattr(self, 'objects'):
# Invoke callbacks on all our layers that have the UI mixin
num = len(self.objects) - 1
while num >= 0:
obj = self.objects[num]
if isinstance(obj, UIMixin) and obj.ui_isActive():
res = obj.make_ui_callback(name, *args, **kwdargs)
if res:
return res
num -= 1
if self.ui_active:
return super(UIMixin, self).make_callback(name, *args, **kwdargs)
def make_callback_children(self, name, *args, **kwdargs):
"""Invoke callbacks on all objects (i.e. layers) from the top to
the bottom, returning when the first one returns True. If none
returns True, then make the callback on our 'native' layer.
"""
if hasattr(self, 'objects'):
# Invoke callbacks on all our layers that have the UI mixin
num = len(self.objects) - 1
while num >= 0:
obj = self.objects[num]
if isinstance(obj, Callbacks):
obj.make_callback(name, *args, **kwdargs)
num -= 1
return super(UIMixin, self).make_callback(name, *args, **kwdargs)
### NON-PEP8 EQUIVALENTS -- TO BE DEPRECATED ###
ui_isActive = ui_is_active
ui_setActive = ui_set_active
# END
|