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