comparison sat_frontends/primitivus/notify.py @ 4037:524856bd7b19

massive refactoring to switch from camelCase to snake_case: historically, Libervia (SàT before) was using camelCase as allowed by PEP8 when using a pre-PEP8 code, to use the same coding style as in Twisted. However, snake_case is more readable and it's better to follow PEP8 best practices, so it has been decided to move on full snake_case. Because Libervia has a huge codebase, this ended with a ugly mix of camelCase and snake_case. To fix that, this patch does a big refactoring by renaming every function and method (including bridge) that are not coming from Twisted or Wokkel, to use fully snake_case. This is a massive change, and may result in some bugs.
author Goffi <goffi@goffi.org>
date Sat, 08 Apr 2023 13:54:42 +0200
parents be6d91572633
children
comparison
equal deleted inserted replaced
4036:c4464d7ae97b 4037:524856bd7b19
31 31
32 try: 32 try:
33 from Xlib import display as X_display 33 from Xlib import display as X_display
34 34
35 self.display = X_display.Display() 35 self.display = X_display.Display()
36 self.X11_id = self.getFocus() 36 self.X11_id = self.get_focus()
37 except: 37 except:
38 pass 38 pass
39 39
40 # Now we try to connect to Freedesktop D-Bus API 40 # Now we try to connect to Freedesktop D-Bus API
41 try: 41 try:
49 db_object, dbus_interface="org.freedesktop.Notifications" 49 db_object, dbus_interface="org.freedesktop.Notifications"
50 ) 50 )
51 except: 51 except:
52 self.freedesktop_int = None 52 self.freedesktop_int = None
53 53
54 def getFocus(self): 54 def get_focus(self):
55 if not self.display: 55 if not self.display:
56 return 0 56 return 0
57 return self.display.get_input_focus().focus.id 57 return self.display.get_input_focus().focus.id
58 58
59 def hasFocus(self): 59 def has_focus(self):
60 return (self.getFocus() == self.X11_id) if self.display else True 60 return (self.get_focus() == self.X11_id) if self.display else True
61 61
62 def useX11(self): 62 def use_x11(self):
63 return bool(self.display) 63 return bool(self.display)
64 64
65 def sendNotification(self, summ_mess, body_mess=""): 65 def send_notification(self, summ_mess, body_mess=""):
66 """Send notification to the user if possible""" 66 """Send notification to the user if possible"""
67 # TODO: check options before sending notifications 67 # TODO: check options before sending notifications
68 if self.freedesktop_int: 68 if self.freedesktop_int:
69 self.sendFDNotification(summ_mess, body_mess) 69 self.send_fd_notification(summ_mess, body_mess)
70 70
71 def sendFDNotification(self, summ_mess, body_mess=""): 71 def send_fd_notification(self, summ_mess, body_mess=""):
72 """Send notification with the FreeDesktop D-Bus API""" 72 """Send notification with the FreeDesktop D-Bus API"""
73 if self.freedesktop_int: 73 if self.freedesktop_int:
74 app_name = "Primitivus" 74 app_name = "Primitivus"
75 replaces_id = 0 75 replaces_id = 0
76 app_icon = "" 76 app_icon = ""