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

Commits:

4 changed files:

Changes:

  • gajim/common/client.py
    ... ... @@ -454,6 +454,9 @@ def _finish_connect(self) -> None:
    454 454
             self.get_module('Annotations').request_annotations()
    
    455 455
             self.get_module('Blocking').get_blocking_list()
    
    456 456
     
    
    457
    +        if app.settings.get_account_setting(self._account, 'publish_tune'):
    
    458
    +            self.get_module('UserTune').set_enabled(True)
    
    459
    +
    
    457 460
             self.notify('state-changed', SimpleClientState.CONNECTED)
    
    458 461
     
    
    459 462
             app.ged.raise_event(SignedIn(account=self._account, conn=self))
    

  • gajim/common/dbus/music_track.py
    ... ... @@ -22,6 +22,7 @@
    22 22
     from typing import Optional
    
    23 23
     
    
    24 24
     import logging
    
    25
    +import sys
    
    25 26
     
    
    26 27
     from gi.repository import Gio
    
    27 28
     from gi.repository import GLib
    
    ... ... @@ -49,6 +50,10 @@ def __init__(self):
    49 50
             self.players = {}
    
    50 51
             self.connection = None
    
    51 52
             self._current_tune = None
    
    53
    +        self._running = False
    
    54
    +
    
    55
    +        if sys.platform not in ('win32', 'darwin'):
    
    56
    +            self.start()
    
    52 57
     
    
    53 58
         def _emit(self, info: Optional[TuneData]) -> None:
    
    54 59
             self._current_tune = info
    
    ... ... @@ -59,6 +64,9 @@ def current_tune(self) -> Optional[TuneData]:
    59 64
             return self._current_tune
    
    60 65
     
    
    61 66
         def start(self):
    
    67
    +        if self._running:
    
    68
    +            return
    
    69
    +
    
    62 70
             proxy = Gio.DBusProxy.new_for_bus_sync(
    
    63 71
                 Gio.BusType.SESSION,
    
    64 72
                 Gio.DBusProxyFlags.NONE,
    
    ... ... @@ -96,6 +104,8 @@ def start(self):
    96 104
             for name in list(self.players):
    
    97 105
                 self._get_playing_track(name)
    
    98 106
     
    
    107
    +        self._running = True
    
    108
    +
    
    99 109
         def stop(self):
    
    100 110
             for name in list(self.players):
    
    101 111
                 if name.startswith(MPRIS_PLAYER_PREFIX):
    
    ... ... @@ -203,7 +213,3 @@ def proxy_call_finished(proxy, res):
    203 213
                        None,
    
    204 214
                        proxy_call_finished)
    
    205 215
     
    206
    -
    
    207
    -def enable():
    
    208
    -    listener = MusicTrackListener.get()
    
    209
    -    listener.start()

  • gajim/common/modules/user_tune.py
    ... ... @@ -44,11 +44,6 @@ def __init__(self, con):
    44 44
             self._current_tune: Optional[TuneData] = None
    
    45 45
             self._contact_tunes: dict[JID, TuneData] = {}
    
    46 46
     
    
    47
    -        self.register_events([
    
    48
    -            ('music-track-changed', ged.CORE, self._on_music_track_changed),
    
    49
    -            ('signed-in', ged.CORE, self._on_signed_in),
    
    50
    -        ])
    
    51
    -
    
    52 47
         def get_current_tune(self) -> Optional[TuneData]:
    
    53 48
             return self._current_tune
    
    54 49
     
    
    ... ... @@ -88,8 +83,13 @@ def set_tune(self, tune, force=False):
    88 83
     
    
    89 84
         def set_enabled(self, enable):
    
    90 85
             if enable:
    
    86
    +            self.register_events([
    
    87
    +                ('music-track-changed', ged.CORE, self._on_music_track_changed),
    
    88
    +                ('signed-in', ged.CORE, self._on_signed_in),
    
    89
    +            ])
    
    91 90
                 self._publish_current_tune()
    
    92 91
             else:
    
    92
    +            self.unregister_events()
    
    93 93
                 self.set_tune(None, force=True)
    
    94 94
     
    
    95 95
         def _publish_current_tune(self):
    

  • gajim/gtk/application.py
    ... ... @@ -63,7 +63,6 @@
    63 63
     from gajim.common.application import CoreApplication
    
    64 64
     from gajim.common.const import GAJIM_FAQ_URI
    
    65 65
     from gajim.common.const import GAJIM_WIKI_URI
    
    66
    -from gajim.common.dbus import music_track
    
    67 66
     from gajim.common.exceptions import GajimGeneralException
    
    68 67
     from gajim.common.helpers import load_json
    
    69 68
     from gajim.common.helpers import open_uri
    
    ... ... @@ -239,9 +238,6 @@ def _startup(self, _application: GajimApplication) -> None:
    239 238
             from gajim.gui.status_icon import StatusIcon
    
    240 239
             self.systray = StatusIcon()
    
    241 240
     
    
    242
    -        if sys.platform not in ('win32', 'darwin'):
    
    243
    -            music_track.enable()
    
    244
    -
    
    245 241
             self.add_actions()
    
    246 242
             self._load_shortcuts()
    
    247 243
             menus.build_accounts_menu()