Philipp Hörist pushed to branch master at gajim / gajim


Commits:
ea4d6d80 by lovetox at 2022-01-05T23:54:19+01:00
Notifications: Fix unassigned var

- - - - -
b3449635 by lovetox at 2022-01-05T23:54:19+01:00
AccountSideBar: Add type annotations

- - - - -


2 changed files:

- gajim/gtk/account_side_bar.py
- gajim/gtk/notification.py


Changes:

=====================================
gajim/gtk/account_side_bar.py
=====================================
@@ -12,6 +12,8 @@
 # You should have received a copy of the GNU General Public License
 # along with Gajim. If not, see <http://www.gnu.org/licenses/>.
 
+from __future__ import annotations
+
 from typing import List
 from typing import Optional
 
@@ -19,6 +21,7 @@
 
 from gajim.common.const import AvatarSize
 from gajim.common import app
+from gajim.common import types
 from gajim.common.i18n import _
 
 
@@ -45,7 +48,7 @@ def remove_account(self, account: str) -> None:
                 return
 
     @staticmethod
-    def _on_row_activated(_listbox, row):
+    def _on_row_activated(_listbox: AccountSideBar, row: Account) -> None:
         app.window.show_account_page(row.account)
 
     def activate_account_page(self, account: str) -> None:
@@ -112,10 +115,14 @@ def __init__(self, account: str) -> None:
         self.connect('destroy', self._on_destroy)
         self._update_image()
 
-    def _on_presence_update(self, _contact, _signal_name):
+    def _on_presence_update(self,
+                            _contact: types.BareContact,
+                            _signal_name: str) -> None:
         self._update_image()
 
-    def _on_avatar_update(self, _contact, _signal_name):
+    def _on_avatar_update(self,
+                          _contact: types.BareContact,
+                          _signal_name: str) -> None:
         self._update_image()
 
     def _update_image(self) -> None:
@@ -124,6 +131,6 @@ def _update_image(self) -> None:
                                            style='circle')
         self.set_from_surface(surface)
 
-    def _on_destroy(self, *args):
+    def _on_destroy(self, _widget: Gtk.Image) -> None:
         self._contact.disconnect_all_from_obj(self)
         app.check_finalize(self)


=====================================
gajim/gtk/notification.py
=====================================
@@ -27,6 +27,7 @@
 from __future__ import annotations
 
 from typing import Optional
+from typing import Union
 
 import sys
 import logging
@@ -36,6 +37,7 @@
 from gi.repository import Gdk
 from gi.repository import GdkPixbuf
 from gi.repository import Gtk
+from nbxmpp.protocol import JID
 
 from gajim.common import app
 from gajim.common import ged
@@ -112,9 +114,6 @@ def on_proxy_ready(_source: Gio.DBusProxy,
                                   on_proxy_ready)
 
     def _on_notification(self, event: events.Notification) -> None:
-        if event.jid is not None:
-            jid = str(event.jid)
-
         if event.sound is not None:
             play_sound(event.sound, event.account)
 
@@ -131,7 +130,7 @@ def _on_notification(self, event: events.Notification) -> 
None:
         self._issue_notification(
             event.notif_type,
             event.account,
-            jid,
+            event.jid,
             notif_detail=notif_detail,
             title=event.title,
             text=event.text,
@@ -144,7 +143,7 @@ def _on_our_show(self, event: events.ShowChanged) -> None:
     def _issue_notification(self,
                             notif_type: str,
                             account: str,
-                            jid: Optional[str],
+                            jid: Optional[Union[str, JID]],
                             notif_detail: str = '',
                             title: str = '',
                             text: str = '',
@@ -155,6 +154,8 @@ def _issue_notification(self,
         Notify a user of an event using GNotification and GApplication under
         Linux, Use PopupNotificationWindow under Windows
         """
+        if jid is not None:
+            jid = str(jid)
 
         if icon_name is None:
             icon_name = 'mail-message-new'



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/1f94d3810d71dec826e6574845e4f8a4802a7187...b3449635ac737d7c87640d0cdae93f1423571b97

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/1f94d3810d71dec826e6574845e4f8a4802a7187...b3449635ac737d7c87640d0cdae93f1423571b97
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to