commented definitions
This commit is contained in:
parent
103177d79f
commit
cbf3b48903
@ -2,7 +2,7 @@
|
||||
|
||||
"""pywmreceived.py
|
||||
WindowMaker dockapp pidgin messages
|
||||
Copyright (C) 2006 Mario Frasca
|
||||
Copyright (C) 2025 Fredrick W. Warren
|
||||
Licensed under the GNU General Public License.
|
||||
"""
|
||||
|
||||
@ -22,8 +22,14 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Application(wmoo.Application):
|
||||
"""
|
||||
Display dockapp and respond to libpurple dbus
|
||||
messages ReceivedImMsg and SentImMsg
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""
|
||||
"""
|
||||
wmoo.Application.__init__(self, *args, **kwargs)
|
||||
self._count = 0
|
||||
self._flasher = 0
|
||||
@ -40,6 +46,9 @@ class Application(wmoo.Application):
|
||||
self.register_dbus()
|
||||
|
||||
def register_dbus(self):
|
||||
"""
|
||||
Register im.pidgin.purple dbus to listen for messages
|
||||
"""
|
||||
try:
|
||||
# Set up the D-Bus main loop
|
||||
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
|
||||
@ -79,7 +88,7 @@ class Application(wmoo.Application):
|
||||
"""
|
||||
Callback function that handles the ReceivedIMMsg signal.
|
||||
Prints the sender and message.
|
||||
|
||||
|
||||
Parameters:
|
||||
account (str): The account from which the message was received.
|
||||
sender (str): The sender's identifier.
|
||||
@ -99,7 +108,7 @@ class Application(wmoo.Application):
|
||||
"""
|
||||
Callback function that handles the SentImMsg signal.
|
||||
Prints the sender and message.
|
||||
|
||||
|
||||
Parameters:
|
||||
recepient (str): The recepien's identifier.
|
||||
message (str): The message content.
|
||||
@ -109,6 +118,14 @@ class Application(wmoo.Application):
|
||||
ic(f"message: {message}")
|
||||
|
||||
def draw_string(self, xstart, ystart, text):
|
||||
"""
|
||||
Draw text in dockapp with normal or backlit backround
|
||||
|
||||
Parameters:
|
||||
xstart (int): pixels from left edge of dockapp
|
||||
ystart (int): pixels from top edge of dockapp
|
||||
text (str): text to display, will be trundicated
|
||||
"""
|
||||
for char in text:
|
||||
if char >= "A" and char <="Z":
|
||||
x = (ord(char) -65) * 6
|
||||
@ -146,24 +163,42 @@ class Application(wmoo.Application):
|
||||
xstart += 6
|
||||
|
||||
def draw_background(self):
|
||||
"""
|
||||
Redraw background of dockapp
|
||||
"""
|
||||
self.putPattern(0 + (self.backlit * 62), 36, 64, 64, 0, 0)
|
||||
|
||||
def draw_all_text(self):
|
||||
"""
|
||||
Redraw all text
|
||||
"""
|
||||
for index, line in enumerate(self.lines[:6]):
|
||||
self.draw_string(9, 6 + (index * line_height), line[0])
|
||||
|
||||
def toggle_backlight(self, event):
|
||||
"""
|
||||
Toggle the state of the dockapp background
|
||||
|
||||
Parameters:
|
||||
"""
|
||||
self.backlit = 1 - self.backlit
|
||||
self.draw_background()
|
||||
self.draw_all_text()
|
||||
|
||||
def backlight_off(self, event):
|
||||
"""
|
||||
Turn off the backlight mode in response to a mouseclick
|
||||
|
||||
Parameters:
|
||||
"""
|
||||
self._flasher = 0
|
||||
if self.backlit:
|
||||
self.toggle_backlight(True)
|
||||
|
||||
|
||||
def update(self):
|
||||
"""
|
||||
Update display
|
||||
"""
|
||||
wmoo.Application.update(self)
|
||||
self._count += 1
|
||||
if self._count <= 3:
|
||||
@ -188,6 +223,8 @@ def run_glib_mainloop():
|
||||
def main():
|
||||
"""
|
||||
The main entry point of the application.
|
||||
|
||||
Parameters:
|
||||
"""
|
||||
app = Application(font_name='5x8',
|
||||
margin = 3,
|
||||
|
Loading…
Reference in New Issue
Block a user