/usr/share/pyshared/plwm/modestatus.py is in python-plwm 2.6a+20080530-1.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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | #
# modestatus.py -- display various status information in xmodewin
#
# Copyright (C) 2000-2001 Peter Liljenberg <petli@ctrl-c.liu.se>
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import modewindow, wmanager, moveresize, wmevents
from Xlib import X, Xatom
# Screen mixin, requires ModeWindow
class ModeStatus:
def __screen_client_init__(self):
self.modestatus_modes = [ModeText(self, '')]
self.modestatus_message = modewindow.Message(.5, modewindow.CENTER)
self.modewindow_add_message(self.modestatus_message)
def modestatus_new(self, text = ''):
"""Creates and returns a new ModeText object.
The object will be put on top of the display stack.
TEXT is the initial message of the object, an empty string if omitted.
"""
mt = ModeText(self, text)
self.modestatus_modes.append(mt)
self.modestatus_message.set_text(text)
return mt
def modestatus_set_default(self, text):
"""Set the default status message to TEXT.
"""
self.modestatus_modes[0].set(text)
### Internal functions below
def modestatus_update(self, modetext):
"""Internal function, called by MODETEXT when it has changed.
"""
if modetext is self.modestatus_modes[-1]:
self.modestatus_message.set_text(modetext.text)
def modestatus_remove(self, modetext):
"""Internal function, called by MODETEXT when it is popped.
"""
try:
self.modestatus_modes.remove(modetext)
except ValueError:
pass
self.modestatus_message.set_text(self.modestatus_modes[-1].text)
class ModeText:
"""Class representing a mode status message.
Don't instantiate it directly, use the modestatus_new()
method of the screen instead.
"""
def __init__(self, screen, text):
self.screen = screen
self.text = text
def set(self, text):
"""Change the message to TEXT.
"""
self.text = text
self.screen.modestatus_update(self)
def pop(self):
"""Remove this message from the display stack.
"""
self.screen.modestatus_remove(self)
#
# Various mode functions
#
# Client mixin
class ModeFocusedTitleClient:
def __client_init__(self):
self.dispatch.add_handler(X.PropertyNotify, self.modefocusedtitle_property_notify)
def modefocusedtitle_property_notify(self, event):
if self.current and event.atom == Xatom.WM_NAME:
self.screen.modestatus_set_default(self.get_title())
# Screen mixin
class ModeFocusedTitleScreen:
def __screen_init__(self):
self.dispatch.add_handler(wmevents.CurrentClientChange,
self.modefocusedtitle_change)
def modefocusedtitle_change(self, evt):
if evt.client:
# Reset modewindow on other screen
if evt.screen and evt.screen != evt.client:
evt.screen.modestatus_set_default('')
# Set modewindow on this screen
self.modestatus_set_default(evt.client.get_title())
# Reset this modewindow
else:
self.modestatus_set_default('')
# Screen mixin
class ModeMoveResize:
def __screen_init__(self):
res = '.moveResize.modeFormat'
cls = '.MoveResize.ModeFormat'
default = '%(title)s [%(geometry)s]'
self.modemoveresize_format = self.wm.rdb_get(res, cls, default)
self.modemoveresize_text = None
self.modemoveresize_tags = {}
self.modemoveresize_hints = None
self.dispatch.add_handler(moveresize.MoveResizeStart,
self.modemoveresize_start)
self.dispatch.add_handler(moveresize.MoveResizeDo,
self.modemoveresize_do)
self.dispatch.add_handler(moveresize.MoveResizeEnd,
self.modemoveresize_end)
self.dispatch.add_handler(moveresize.MoveResizeAbort,
self.modemoveresize_end)
def modemoveresize_start(self, ev):
self.modemoveresize_tags['title'] = ev.client.get_title()
self.modemoveresize_hints = ev.client.resize_increment() + ev.client.base_size()
x, y, w, h = ev.client.geometry()[0:4]
msg = self.modemoveresize_format_text(x, y, w, h)
self.modemoveresize_text = self.modestatus_new(msg)
def modemoveresize_do(self, ev):
if self.modemoveresize_text:
msg = self.modemoveresize_format_text(ev.x, ev.y, ev.width, ev.height)
self.modemoveresize_text.set(msg)
def modemoveresize_end(self, ev):
if self.modemoveresize_text:
self.modemoveresize_text.pop()
self.modemoveresize_text = None
self.modemoveresize_title = None
self.modemoveresize_hints = None
def modemoveresize_format_text(self, x, y, w, h):
wi, hi, wb, hb = self.modemoveresize_hints
if wi and wi > 1:
w = (w - wb) / wi
if hi and hi > 1:
h = (h - hb) / hi
self.modemoveresize_tags['geometry'] = '%dx%d+%d+%d' % (w, h, x, y)
return self.modemoveresize_format % self.modemoveresize_tags
|