/usr/lib/python2.7/dist-packages/mcomix/cursor_handler.py is in mcomix 1.00-1.
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 76 77 78 79 80 81 82 | """cursor_handler.py - Cursor handler."""
import gobject
import gtk
from mcomix import constants
class CursorHandler:
def __init__(self, window):
self._window = window
self._timer_id = None
self._auto_hide = False
self._current_cursor = constants.NORMAL_CURSOR
def set_cursor_type(self, cursor):
"""Set the cursor to type <cursor>. Supported cursor types are
available as constants in this module. If <cursor> is not one of the
cursor constants above, it must be a gtk.gdk.Cursor.
"""
if cursor == constants.NORMAL_CURSOR:
mode = None
elif cursor == constants.GRAB_CURSOR:
mode = gtk.gdk.Cursor(gtk.gdk.FLEUR)
elif cursor == constants.WAIT_CURSOR:
mode = gtk.gdk.Cursor(gtk.gdk.WATCH)
elif cursor == constants.NO_CURSOR:
mode = self._get_hidden_cursor()
else:
mode = cursor
self._window.set_cursor(mode)
self._current_cursor = cursor
if self._auto_hide:
if cursor == constants.NORMAL_CURSOR:
self._set_hide_timer()
else:
self._kill_timer()
def auto_hide_on(self):
"""Signal that the cursor should auto-hide from now on (e.g. that
we are entering fullscreen).
"""
self._auto_hide = True
if self._current_cursor == constants.NORMAL_CURSOR:
self._set_hide_timer()
def auto_hide_off(self):
"""Signal that the cursor should *not* auto-hide from now on."""
self._auto_hide = False
self._kill_timer()
if self._current_cursor == constants.NORMAL_CURSOR:
self.set_cursor_type(constants.NORMAL_CURSOR)
def refresh(self):
"""Refresh the current cursor (i.e. display it and set a new timer in
fullscreen). Used when we move the cursor.
"""
if self._auto_hide:
self.set_cursor_type(self._current_cursor)
def _set_hide_timer(self):
self._kill_timer()
self._timer_id = gobject.timeout_add(2000, self._window.set_cursor,
self._get_hidden_cursor())
def _kill_timer(self):
if self._timer_id is not None:
gobject.source_remove(self._timer_id)
def _get_hidden_cursor(self):
pixmap = gtk.gdk.Pixmap(None, 1, 1, 1)
color = gtk.gdk.Color()
return gtk.gdk.Cursor(pixmap, pixmap, color, color, 0, 0)
# vim: expandtab:sw=4:ts=4
|