This file is indexed.

/usr/lib/exaile/xlgui/tray.py is in exaile 3.3.2-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
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# Copyright (C) 2008-2010 Adam Olsen
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
#
#
# The developers of the Exaile media player hereby grant permission
# for non-GPL compatible GStreamer and Exaile plugins to be used and
# distributed together with GStreamer and Exaile. This permission is
# above and beyond the permissions granted by the GPL license by which
# Exaile is covered. If you modify this code, you may extend this
# exception to your version of the code, but you are not obligated to
# do so. If you do not wish to do so, delete this exception statement
# from your version.

import glib
import gobject
import gtk

from xl import (
    event,
    player,
    providers,
    settings,
    xdg
)
from xl.nls import gettext as _
from xlgui import guiutil
from xlgui.widgets.info import TrackToolTip
from xlgui.widgets import rating, menu, menuitems, playlist, playback


def __create_tray_context_menu():
    sep = menu.simple_separator
    items = []
    # Play/Pause
    items.append(playback.PlayPauseMenuItem('playback-playpause', player.PLAYER, after=[]))
    # Next
    items.append(playback.NextMenuItem('playback-next', player.PLAYER, after=[items[-1].name]))
    # Prev
    items.append(playback.PrevMenuItem('playback-prev', player.PLAYER, after=[items[-1].name]))
    # Stop
    items.append(playback.StopMenuItem('playback-stop', player.PLAYER, after=[items[-1].name]))
    # ----
    items.append(sep('playback-sep', [items[-1].name]))
    # Shuffle
    items.append(playlist.ShuffleModesMenuItem('playlist-mode-shuffle', after=[items[-1].name]))
    # Repeat
    items.append(playlist.RepeatModesMenuItem('playlist-mode-repeat', after=[items[-1].name]))
    # Dynamic
    items.append(playlist.DynamicModesMenuItem('playlist-mode-dynamic', after=[items[-1].name]))
    # ----
    items.append(sep('playlist-mode-sep', [items[-1].name]))
    # Rating
    def rating_get_tracks_func(parent, context):
        current = player.PLAYER.current
        if current:
            return [current]
        else:
            return []
    items.append(menuitems.RatingMenuItem('rating', [items[-1].name],
        rating_get_tracks_func))
    # Remove
    items.append(playlist.RemoveCurrentMenuItem([items[-1].name]))
    # ----
    items.append(sep('misc-actions-sep', [items[-1].name]))
    # Quit
    def quit_cb(*args):
        from xl import main
        main.exaile().quit()
    items.append(menu.simple_menu_item('quit-application', [items[-1].name],
        icon_name=gtk.STOCK_QUIT, callback=quit_cb))
    for item in items:
        providers.register('tray-icon-context', item)
__create_tray_context_menu()


class BaseTrayIcon(object):
    """
        Trayicon base, needs to be derived from
    """
    def __init__(self, main):
        self.main = main
        self.VOLUME_STEP = 0.05

        self.tooltip = TrackToolTip(self, player.PLAYER)
        self.tooltip.set_auto_update(True)
        self.tooltip.set_display_progress(True)

        self.menu = menu.ProviderMenu('tray-icon-context', self)
        self.update_icon()
        self.connect_events()
        event.log_event('tray_icon_toggled', self, True)

    def destroy(self):
        """
            Unhides the window and removes the tray icon
        """
        # FIXME: Allow other windows too
        if not self.main.window.get_property('visible'):
            self.main.window.deiconify()
            self.main.window.present()

        self.disconnect_events()
        self.set_visible(False)
        self.tooltip.destroy()
        event.log_event('tray_icon_toggled', self, False)

    def connect_events(self):
        """
            Connects various callbacks with events
        """
        self.connect('button-press-event', self.on_button_press_event)
        self.connect('scroll-event', self.on_scroll_event)

        event.add_callback(self.on_playback_change_state, 'playback_player_end', player.PLAYER)
        event.add_callback(self.on_playback_change_state, 'playback_track_start', player.PLAYER)
        event.add_callback(self.on_playback_change_state, 'playback_toggle_pause', player.PLAYER)
        event.add_callback(self.on_playback_change_state, 'playback_error', player.PLAYER)

    def disconnect_events(self):
        """
            Disconnects various callbacks from events
        """
        event.remove_callback(self.on_playback_change_state, 'playback_player_end', player.PLAYER)
        event.remove_callback(self.on_playback_change_state, 'playback_track_start', player.PLAYER)
        event.remove_callback(self.on_playback_change_state, 'playback_toggle_pause', player.PLAYER)
        event.remove_callback(self.on_playback_change_state, 'playback_error', player.PLAYER)

    def update_icon(self):
        """
            Updates icon appearance based
            on current playback state
        """
        if player.PLAYER.current is None:
            self.set_from_icon_name('exaile')
            self.set_tooltip(_('Exaile Music Player'))
        elif player.PLAYER.is_paused():
            self.set_from_icon_name('exaile-pause')
        else:
            self.set_from_icon_name('exaile-play')

    def set_from_icon_name(self, icon_name):
        """
            Updates the tray icon
        """
        pass

    def set_tooltip(self, tooltip_text):
        """
            Updates the tray icon tooltip
        """
        pass

    def set_visible(self, visible):
        """
            Shows or hides the tray icon
        """
        pass

    def get_menu_position(self, menu, icon):
        """
            Returns coordinates for
            the best menu position
        """
        return (0, 0, False)

    def on_button_press_event(self, widget, event):
        """
            Toggles main window visibility and
            pause as well as opens the context menu
        """
        if event.button == 1:
            self.main.toggle_visible(bringtofront=True)
        if event.button == 2:
            playback.playpause( player.PLAYER )
        if event.button == 3:
            self.menu.popup(None, None, self.get_menu_position,
                event.button, event.time, self)

    def on_scroll_event(self, widget, event):
        """
            Changes volume and skips tracks on scroll
        """
        if event.state & gtk.gdk.SHIFT_MASK:
            if event.direction == gtk.gdk.SCROLL_UP:
                player.QUEUE.prev()
            elif event.direction == gtk.gdk.SCROLL_DOWN:
                player.QUEUE.next()
        else:
            if event.direction == gtk.gdk.SCROLL_UP:
                volume = settings.get_option('player/volume', 1)
                settings.set_option('player/volume', min(volume + self.VOLUME_STEP, 1))
                return True
            elif event.direction == gtk.gdk.SCROLL_DOWN:
                volume = settings.get_option('player/volume', 1)
                settings.set_option('player/volume', max(0, volume - self.VOLUME_STEP))
                return True
            elif event.direction == gtk.gdk.SCROLL_LEFT:
                player.QUEUE.prev()
            elif event.direction == gtk.gdk.SCROLL_RIGHT:
                player.QUEUE.next()

    def on_playback_change_state(self, event, player, current):
        """
            Updates tray icon appearance
            on playback state change
        """
        glib.idle_add(self.update_icon)

class TrayIcon(gtk.StatusIcon, BaseTrayIcon):
    """
        Wrapper around GtkStatusIcon
    """
    def __init__(self, main):
        gtk.StatusIcon.__init__(self)
        BaseTrayIcon.__init__(self, main)

    def get_menu_position(self, menu, icon):
        """
            Returns coordinates for
            the best menu position
        """
        return gtk.status_icon_position_menu(menu, icon)