예제 #1
0
 def init(self):
     self.config_dialog = None
     self.artist = self.title = self.source = ''
     self.listener = MusicTrackListener().get()
     if os.name == 'nt':
         self.available_text = _('Plugin can\'t be run under Windows.')
         self.activatable = False
예제 #2
0
 def init(self):
     self.config_dialog = None
     if ERR_MSG:
         self.available_text = ERR_MSG
         self.activatable = False
         return
     self.artist = self.title = self.source = ''
     self.listener = MusicTrackListener().get()
예제 #3
0
 def init(self):
     self.config_dialog = None
     self.artist = self.title = self.source = ''
     self.listener = MusicTrackListener().get()
     if os.name == 'nt':
         self.available_text = _('Plugin can\'t be run under Windows.')
         self.activatable = False
예제 #4
0
 def activate(self):
     if not dbus_support.supported:
         raise GajimPluginException(_('python-dbus is missing!'))
     listener = MusicTrackListener.get()
     if not self.music_track_changed_signal:
         self.music_track_changed_signal = listener.connect(
             'music-track-changed', self.music_track_changed)
     track = listener.get_playing_track()
     self.music_track_changed(listener, track)
예제 #5
0
 def activate(self):
     if not dbus_support.supported:
         raise GajimPluginException(_('python-dbus is missing!'))
     listener = MusicTrackListener.get()
     if not self.music_track_changed_signal:
         self.music_track_changed_signal = listener.connect(
             'music-track-changed', self.music_track_changed)
     track = listener.get_playing_track()
     self.music_track_changed(listener, track)
예제 #6
0
 def deactivate(self):
     if hasattr(self, 'chat_control'):
         gtk.binding_entry_remove(self.chat_control.msg_textview,
                                  gtk.keysyms.n, gtk.gdk.MOD1_MASK)
     self.first_run = True
     if dbus_support.supported:
         listener = MusicTrackListener.get()
         if self.music_track_changed_signal:
             listener.disconnect(self.music_track_changed_signal)
             self.music_track_changed_signal = None
예제 #7
0
 def deactivate(self):
     if hasattr(self, 'chat_control'):
         gtk.binding_entry_remove(self.chat_control.msg_textview,
             gtk.keysyms.n, gtk.gdk.MOD1_MASK)
     self.first_run = True
     if dbus_support.supported:
         listener = MusicTrackListener.get()
         if self.music_track_changed_signal:
             listener.disconnect(self.music_track_changed_signal)
             self.music_track_changed_signal = None
예제 #8
0
class Mpris2Plugin(GajimPlugin):
    @log_calls('Mpris2Plugin')
    def init(self):
        self.config_dialog = None
        if ERR_MSG:
            self.available_text = ERR_MSG
            self.activatable = False
            return
        self.artist = self.title = self.source = ''
        self.listener = MusicTrackListener().get()

    @log_calls('NowListenPlugin')
    def activate(self):
        self._last_playing_music = None
        self.bus = dbus_support.session_bus.SessionBus()
        self.bus.add_signal_receiver(self.properties_changed,
                                     "PropertiesChanged",
                                     "org.freedesktop.DBus.Properties")

    @log_calls('Mpris2Plugin')
    def deactivate(self):
        self.bus.remove_signal_receiver(self.properties_changed,
                                        "PropertiesChanged",
                                        "org.freedesktop.DBus.Properties")

    def properties_changed(self, *args, **kw):
        if args[0] != 'org.mpris.MediaPlayer2.Player':
            return
        if 'PlaybackStatus' in args[1]:
            if args[1]['PlaybackStatus'] in ['Paused', 'Stopped']:
                self.title = self.artist = self.source = ''
                self.listener.emit('music-track-changed', None)
            if args[1]['PlaybackStatus'] == 'Playing':
                self.listener.emit('music-track-changed',
                                   self._last_playing_music)
        if 'Metadata' not in args[1]:
            return

        data = args[1]['Metadata']
        info = MusicTrackInfo()
        info.title = data.get("xesam:title", '')
        info.album = data.get("xesam:album", '')
        info.artist = data.get("xesam:artist", [''])[0]
        info.albumartist = data.get("xesam:albumArtist", [''])[0]
        info.duration = int(data.get('mpris:length', 0))
        info.track_number = int(data.get('xesam:trackNumber', 0))
        info.url = data.get("xesam:url", '')

        self._last_playing_music = info
        self.listener.emit('music-track-changed', info)
예제 #9
0
class Mpris2Plugin(GajimPlugin):
    @log_calls('Mpris2Plugin')
    def init(self):
        self.config_dialog = None
        self.artist = self.title = self.source = ''
        self.listener = MusicTrackListener().get()
        if os.name == 'nt':
            self.available_text = _('Plugin can\'t be run under Windows.')
            self.activatable = False

    @log_calls('NowListenPlugin')
    def activate(self):
        self._last_playing_music = None
        self.bus = dbus_support.session_bus.SessionBus()
        self.bus.add_signal_receiver(self.properties_changed,
            "PropertiesChanged", "org.freedesktop.DBus.Properties")

    @log_calls('Mpris2Plugin')
    def deactivate(self):
        self.bus.remove_signal_receiver(self.properties_changed,
            "PropertiesChanged", "org.freedesktop.DBus.Properties")

    def properties_changed(self,*args,**kw):
        if args[0] != 'org.mpris.MediaPlayer2.Player':
            return
        if 'PlaybackStatus' in args[1]:
            if args[1]['PlaybackStatus'] in ['Paused', 'Stopped']:
                self.title = self.artist = self.source = ''
                self.listener.emit('music-track-changed', None)
            if args[1]['PlaybackStatus'] == 'Playing':
                self.listener.emit('music-track-changed',
                    self._last_playing_music)
        if 'Metadata' not in args[1]:
            return

        data = args[1]['Metadata']
        info = MusicTrackInfo()
        info.title = data.get("xesam:title", '')
        info.album = data.get("xesam:album", '')
        info.artist = data.get("xesam:artist", [''])[0]
        info.albumartist = data.get("xesam:albumArtist", [''])[0]
        info.duration = int(data.get('mpris:length', 0))
        info.track_number = int(data.get('xesam:trackNumber', 0))
        info.url = data.get("xesam:url", '')

        self._last_playing_music = info
        self.listener.emit('music-track-changed', info)