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

Commits:

2 changed files:

Changes:

  • gajim/common/application.py
    ... ... @@ -83,6 +83,8 @@ def _log(self) -> logging.Logger:
    83 83
             return app.log('gajim.application')
    
    84 84
     
    
    85 85
         def start_shutdown(self, *args: Any, **kwargs: Any) -> None:
    
    86
    +        app.app.systray.shutdown()
    
    87
    +
    
    86 88
             accounts_to_disconnect: dict[str, Client] = {}
    
    87 89
     
    
    88 90
             for account, client in app.connections.items():
    

  • gajim/gtk/status_icon.py
    ... ... @@ -93,6 +93,9 @@ def _on_unread_count_changed(self, *args: Any) -> None:
    93 93
         def is_visible(self) -> bool:
    
    94 94
             return self._backend.is_visible()
    
    95 95
     
    
    96
    +    def shutdown(self) -> None:
    
    97
    +        self._backend.shutdown()
    
    98
    +
    
    96 99
     
    
    97 100
     class NoneBackend:
    
    98 101
         def update_state(self, count: int = 0) -> None:
    
    ... ... @@ -101,6 +104,9 @@ def update_state(self, count: int = 0) -> None:
    101 104
         def is_visible(self) -> bool:
    
    102 105
             return False
    
    103 106
     
    
    107
    +    def shutdown(self) -> None:
    
    108
    +        pass
    
    109
    +
    
    104 110
     
    
    105 111
     class GtkMenuBackend(EventHelper):
    
    106 112
         def __init__(self) -> None:
    
    ... ... @@ -215,6 +221,7 @@ class GtkStatusIcon(GtkMenuBackend):
    215 221
         def __init__(self) -> None:
    
    216 222
             GtkMenuBackend.__init__(self)
    
    217 223
             self._hide_menuitem_added = False
    
    224
    +        self._shutdown = False
    
    218 225
     
    
    219 226
             self._status_icon = Gtk.StatusIcon()
    
    220 227
             self._status_icon.set_tooltip_text('Gajim')  # Needed for Windows
    
    ... ... @@ -225,6 +232,10 @@ def __init__(self) -> None:
    225 232
             self.update_state()
    
    226 233
     
    
    227 234
         def update_state(self, count: int = 0) -> None:
    
    235
    +        if self._shutdown:
    
    236
    +            # Shutdown in progress, don't update icon
    
    237
    +            return
    
    238
    +
    
    228 239
             if app.settings.get('trayicon') == 'never':
    
    229 240
                 self._status_icon.set_visible(False)
    
    230 241
                 return
    
    ... ... @@ -242,6 +253,11 @@ def update_state(self, count: int = 0) -> None:
    242 253
         def is_visible(self) -> bool:
    
    243 254
             return self._status_icon.get_visible()
    
    244 255
     
    
    256
    +    def shutdown(self) -> None:
    
    257
    +        # Necessary on Windows in order to remove icon from tray on shutdown
    
    258
    +        self._shutdown = True
    
    259
    +        self._status_icon.set_visible(False)
    
    260
    +
    
    245 261
         def _on_size_changed(self,
    
    246 262
                              _status_icon: Gtk.StatusIcon,
    
    247 263
                              size: int) -> None:
    
    ... ... @@ -317,3 +333,6 @@ def update_state(self, count: int = 0) -> None:
    317 333
         def is_visible(self) -> bool:
    
    318 334
             status = self._status_icon.get_status()
    
    319 335
             return status == appindicator.IndicatorStatus.ACTIVE
    
    336
    +
    
    337
    +    def shutdown(self) -> None:
    
    338
    +        pass