/usr/share/minirok/minirok/dbusface.py is in minirok 2.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | #! /usr/bin/env python
## vim: fileencoding=utf-8
#
# Copyright (c) 2007-2008 Adeodato Simó (dato@net.com.org.es)
# Licensed under the terms of the MIT license.
import dbus
import dbus.service
import minirok
from minirok import util
##
DBUS_SERVICE_NAME = 'org.kde.minirok'
##
class Player(dbus.service.Object):
def __init__(self):
dbus.service.Object.__init__(self, dbus.SessionBus(), '/Player')
@staticmethod
def get_action(action_name):
"""Returns the trigger method of a named action."""
action = minirok.Globals.action_collection.action(action_name)
if action is None:
minirok.logger.error('action %r not found', action_name)
return lambda: None
else:
return action.trigger
##
decorator = dbus.service.method(DBUS_SERVICE_NAME)
decorator_as = dbus.service.method(DBUS_SERVICE_NAME, 'as')
decorator_s_s = dbus.service.method(DBUS_SERVICE_NAME, 's', 's')
@decorator
def Play(self):
self.get_action('action_play')()
@decorator
def Pause(self):
self.get_action('action_pause')()
@decorator
def PlayPause(self):
self.get_action('action_play_pause')()
@decorator
def Stop(self):
self.get_action('action_stop')()
@decorator
def Next(self):
self.get_action('action_next')()
@decorator
def Previous(self):
self.get_action('action_previous')()
@decorator
def StopAfterCurrent(self):
self.get_action('action_toggle_stop_after_current')()
@decorator_as
def AppendToPlaylist(self, paths):
files = map(util.kurl_to_path, paths)
minirok.Globals.playlist.add_files_untrusted(files)
@decorator_s_s
def NowPlaying(self, format=None):
tags = minirok.Globals.playlist.get_current_tags()
if not tags:
formatted = ''
else:
if format is not None:
try:
formatted = format % tags
except (KeyError, ValueError, TypeError), e:
formatted = '>> Error when formatting string: %s' % e
else:
title = tags['Title']
artist = tags['Artist']
if artist is not None:
formatted = u'%s - %s' % (artist, title)
else:
formatted = title
return formatted
|