~guillaume86/exaile/context-dev

« back to all changes in this revision

Viewing changes to xl/xldbus.py

  • Committer: guillaume86
  • Date: 2009-07-25 14:58:51 UTC
  • mfrom: (2141.1.50 exaile-0.3.0)
  • Revision ID: guillaume86-20090725145851-5mtd72f9ze9u1ma6
Added a little hack to adjust zoom level for the new webkit version (and yeah it's working with the ppa version now!)

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
    """
35
35
    iface = False
36
36
    exaile = None
37
 
    if not options.new:
 
37
    if not options.NewInstance:
38
38
        # TODO: handle dbus stuff
39
39
        bus = dbus.SessionBus()
40
40
        if check_dbus(bus, 'org.exaile.Exaile'):
58
58
        return False
59
59
 
60
60
    comm = False
61
 
    info_commands = (
62
 
            'get_artist', 
63
 
            'get_title', 
64
 
            'get_album',
65
 
            'get_length', 
66
 
            'get_rating'
67
 
            )
 
61
    info_commands = {
 
62
            'GetArtist': 'artist', 
 
63
            'GetTitle': 'title', 
 
64
            'GetAlbum': 'album',
 
65
            'GetLength': '__length', 
 
66
            'GetRating': 'rating',
 
67
            }
68
68
 
69
 
    for command in info_commands:
 
69
    for command, attr in info_commands.iteritems():
70
70
        if getattr(options, command):
71
 
            print iface.GetTrackAttr(command[4:].lower())
 
71
            print iface.GetTrackAttr(attr)
72
72
            comm = True
73
73
 
74
74
    modify_commands = (
75
 
           'set_rating',
 
75
           'SetRating',
76
76
           )
77
77
 
78
78
    for command in modify_commands:
82
82
            comm = True
83
83
 
84
84
    volume_commands = (
85
 
            'inc_vol',
86
 
            'dec_vol',
 
85
            'IncreaseVolume',
 
86
            'DecreaseVolume',
87
87
            )
88
88
 
89
89
    for command in volume_commands:
90
90
        value = getattr(options, command)
91
91
        if value:
92
 
            if command == 'dec_vol': value = -value
 
92
            if command == 'DecreaseVolume': value = -value
93
93
            iface.ChangeVolume(value)
94
94
 
95
95
    run_commands = (
96
 
            'play', 
97
 
            'stop', 
98
 
            'next', 
99
 
            'prev', 
100
 
            'play_pause',
 
96
            'Play', 
 
97
            'Stop', 
 
98
            'Next', 
 
99
            'Prev', 
 
100
            'PlayPause',
101
101
            )
102
102
    for command in run_commands:
103
103
        if getattr(options, command):
105
105
            comm = True
106
106
 
107
107
    query_commands = (
108
 
            'current_position',
109
 
            'get_volume',
 
108
            'CurrentPosition',
 
109
            'GetVolume',
110
110
            )
111
111
 
112
112
    for command in query_commands:
115
115
            comm = True
116
116
 
117
117
    to_implement = (
118
 
            'query',
119
 
            'guiquery',
 
118
            'Query',
 
119
            'GuiQuery',
120
120
            )
121
121
    for command in to_implement:
122
122
        if getattr(options, command):
235
235
        progress = self.exaile.player.get_progress()
236
236
        if progress == -1:
237
237
            return ""
238
 
        return int(progress * 100)
 
238
        return str(int(progress * 100))
239
239
 
240
240
    @dbus.service.method("org.exaile.Exaile", None, "s")
241
241
    def GetVolume(self):
242
242
        """
243
243
            Returns the current volume level (in percent)
244
244
        """
245
 
        return self.exaile.player.get_volume()
 
245
        return str(self.exaile.player.get_volume())
246
246
 
247
247
    @dbus.service.method("org.exaile.Exaile", None, "s")
248
248
    def GetVersion(self):