This file is indexed.

/usr/share/pymt-examples/desktop/desktop-multi.py is in python-pymt 0.5.1-0ubuntu3.

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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
from __future__ import with_statement
import os
import math
from pymt import *
from OpenGL.GL import GL_LINE_STRIP, glColor4f, glVertex2f, GL_LINE_BIT, glLineWidth
from OpenGL.GL import glTranslatef

plugins = MTPlugins(plugin_paths=[
    os.path.join(os.path.dirname(__file__), '..', 'apps'),
    os.path.join(os.path.dirname(__file__), '..', 'games')
])
plugins.search_plugins()

def gesture_add_default(gdb):
    # Circle
    g = gdb.str_to_gesture('eNqdWk2PHDcOvfcf8VwyEL8k8h5ksb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KG6yhC0NdxDNJwnQQhh+4eIYc0FnHqEoqoDCsEYp35AweCxeCwbDAFiD/gIEKo6+GDESKG06FeE+i64PSZC5HDwRs+uaH7ebPp8x+6nzedPkWiu/veGfzpE93PexCG1Baajg2Lz/28yQEk9jN/Zkb3873zDZ+10f38ChlRc2ix/jIA3c/b/B0Uup+3+csMpDgDJhANs8Nfk6C7+z5l7kH38zp/HYTu7lUOIHEaTiAUZuoC2W+7QXw24gFEwvCeQHxupg7xc+9mv5R91B0F76NuIvYM7umzM9DgHt3TZzmAuPOiAwgFoziB8O5F4BAif4F8r5Q7/PvLwiGk7N4WDiH+QjEfQGz3vnAEcfcvdADxd4p4AMHda8chpKsrB+r6UwPrAcTfOe7LyR8U/hqtGvY34u+v3z7/558/Lv/xpT4NfPzw++u32wu3H+3Sfv/by9unr59fllDpf59J+w8sOH9l/+/r2+sv3z6/NzTU2fjMUBuIScLlr+hL7Pbz8/8A9Aw2sQ==')
    g.label = 'Circle'
    g.id = 'circle'
    gdb.add_gesture(g)

    #X up_letf, bottom_right, top_right, bottom_left
    g = gdb.str_to_gesture('eNq1VttqHFcQfJ8fkV4s+n75Afk1oA8Iji2EiWMt2jXEf+86x6udSXAySoTFgmB3Tk2fqq7qvv54+PrH6ebh/nj68nS/vD3/P9By/eHAy93V8fT0+Pv98Wo5yHL96aDL9Q9P3M3HloONc45zh8ePn0/jWIxj+Q/HfhlPLYcapxqnvuIA03JLN0rRaZqhWekmthzvrv4cP/Ny+4ZuwiLYQtLFODt9Of727l9fwjLvpMvD9zeIFCBYVCOSvHM5PpzB3UzIuqqjO6RtH3xenP0ZnCusxQyvyGZqXcEts7VbKqW6m19QeUzwfAanCGJyofakSK1N6Sqpms5NTYb3v6D0yT73z0GX2UnCF3TyjHZPJg7z0uYVXkyJ8D1ol3JT2YefospZVECwUOpojm5L7ZQVnQrNBLHxQUuV0D7zMmUV/1nwU1jJFb4S93dJUZCvaWf4wZt2ZZYwwxXmQbEPP5WVvsADldukS4XImGSFTxKXMjzhqqW+T71OZZUv6MrtClEzGbZlXdG5DHqjl6IotGOfGZ266qorqE0rZwdFzlQrM+IQA1cipWQQU/vgU1VdVTXqaoVLnQilV6zgMGiUE37wthdIqlNSXSWVZBBaicZQJAnpK7CnnrrRE2dhUAaniDES+//YNtW0VU3EAJrFuxGwhUToV5BiU01b1YTLxc1RdilC1hAmr4GfetoavlQYCSg+3CtktNszdCUcrCyiaKawfQ/Z1NNyL9iH0BAD9mxDDiSPebKHPfW0S/JKob7sptJw5F9vepww4pC9LRyktp+7PvX0S+4qIBBbYERdi3LDCQliBWOuNMHVuNEe9pTT10lqsLYaI0EUTW65Gn/YPTFMkYnerPuc+PcNYtXScV2sAKRu4bmdFkRIkxFj4RjgmKgvyBWfcvo6SjtYGd1YiKhEM24GNWH/QJcmVScumLyfLD4V9XWWGjcbo3a2wj7hm1nK/3mDialpbDzKSPJA1xhsIgKCN7OUqzFBysAgyM/eh5+yxsalTcHesCL4xbKCfl3hG50+8ixHr3Ptz4uYysZmliKriwkxQGh6uQy7kfYBf2IDSeQl9sDa92lMYWOTu6gQVSO4YJcxOjcb2OAbPoA6ngYR9tGnrrFJ3sZ64hLCWE6hYW+Wx7+15b6fcuqam0lqCjsSvAT2kZXb1dRDMGURcHiDIW/20aesqZtphwmH1TMZmwbyZLPD/HCrHp+7q9Pjp/und5/f32MHh1TT3H/947Gin2v49fD0+OHL+9N42JdbHz4eaT5gDWoD9+YbKhZUkQ==')
    g.label = 'X'
    g.id = 'close'
    gdb.add_gesture(g)







def action_close_menu(menu, w, args, *largs):
    menu.parent.remove_widget(menu)
    del menu

def action_close_all(menu, w, args):
    sys.exit()

def action_launch_plugin(menu, w, plugin, *largs):
    if not menu.parent:
        return
    pos = w.parent.to_parent(*w.pos)
    win = MTInnerWindow(size=(320,280), pos=pos)
    plugins.activate(plugin, win)
    menu.parent.add_widget(win)

    action_close_menu(menu, w, None)

class MTActionButton(MTButton):
    def __init__(self, **kwargs):
        kwargs.setdefault('action', None)
        kwargs.setdefault('args', None)
        super(MTActionButton, self).__init__(**kwargs)
        self.height = self.label_obj.content_height + 10
        self.width = self.label_obj.content_width + 10
        self.action = kwargs.get('action')
        self.args = kwargs.get('args')

    def on_touch_up(self, touch):
        if not self.collide_point(touch.x, touch.y):
            return
        if self.action:
            self.action(self.parent, self, self.args)

class MTMenuItem(MTKineticItem):
    def __init__(self, path, label, icon, **kwargs):
        super(MTMenuItem, self).__init__(**kwargs)
        self._label = MTLabel(label=label, font_size=12, anchor_x='left',
                           anchor_y='center', size=(self.width, self.height),
                             color=self.style.get('color'))
        self._icon = None
        try:
            ficon = None
            for icon_filename in (icon, 'icon.png'):
                ficon = os.path.join(path, icon_filename)
                if os.path.exists(ficon):
                    break
                ficon = None
            if ficon is not None:
                self._icon = Loader.image(ficon)
        except:
            pass

    def on_move(self, x, y):
        # don't invalidate cache when moving position
        # we'll optimize the position by using pop/push matrix
        pass

    def draw(self):
        with gx_matrix:
            glTranslatef(self.x, self.y, 0)
            set_color(.2, .2, .2, .5)
            drawRectangle(size=self.size)
            self._label.x = 32
            self._label.y = (self.height - self._label.height) / 2.
            self._label.draw()
            if self._icon:
                self._icon.x = (32 - self._icon.width) / 2.
                self._icon.y = (self.height - self._icon.height) / 2.
                self._icon.draw()

class MTMenu(MTKineticList):
    def __init__(self, **kwargs):
        kwargs.setdefault('title', None)
        kwargs.setdefault('searchable', False)
        kwargs.setdefault('deletable', False)
        kwargs.setdefault('padding_x', 0)
        kwargs.setdefault('padding_y', 1)
        super(MTMenu, self).__init__(**kwargs)

        self.size = (190, 230)
        self.center = self.pos
        self.fbo = Fbo(size=self.size)

        self.orig_x = self.x
        self.orig_y = self.y
        self.color = kwargs.get('color')
        self.alpha = 0
        self.dragpos = 0, 0
        self.dragid = 0

        w = MTKineticItem(label='Close Menu', size=(190, 32),
                          style={'font-size': 12, 'bg-color': (.2, .2, .2, .9)})
        w.push_handlers(on_press=curry(action_close_menu,
            self, w, []))
        self.add_widget(w)

        pluginlist = plugins.list()
        keylist = sorted(pluginlist, cmp=lambda x,y:
            cmp(plugins.get_infos(pluginlist[x]).get('title').lower(),
                plugins.get_infos(pluginlist[y]).get('title').lower()))
        for key in keylist:
            plugin = pluginlist[key]
            infos = plugins.get_infos(plugin)
            w = MTMenuItem(infos.get('path'), infos.get('title'), infos.get('icon'), size=(190, 32))
            w.push_handlers(on_press=curry(action_launch_plugin,
                self, w, plugin))
            self.add_widget(w)

    def on_draw(self):
        self.alpha += getFrameDt() * 3
        if self.alpha < 1:
            with DO(self.fbo, gx_matrix):
                glTranslatef(-self.x, -self.y, 0)
                super(MTMenu, self).on_draw()
            set_color(1, 1, 1, self.alpha)
            a = (1 - self.alpha) * 100
            pos = Vector(self.pos) + Vector(a, a)
            size = Vector(self.size) - Vector(a, a) * 2
            drawTexturedRectangle(texture=self.fbo.texture, pos=pos, size=size)
        else:
            super(MTMenu, self).on_draw()

    def collide_menu(self, x, y):
        if x > self.x and x < self.x + self.width and \
            y > self.y + self.height and y < self.y + self.height + 40:
            return True

    def on_touch_down(self, touch):
        if self.collide_menu(touch.x, touch.y):
            self.dragpos = touch.x - self.x, touch.y - self.y
            self.dragid = touch.uid
            touch.grab(self)
            return True
        return super(MTMenu, self).on_touch_down(touch)

    def on_touch_move(self, touch):
        if touch.grab_current == self and self.dragid == touch.uid:
            self.pos = Vector(touch.pos) - Vector(self.dragpos)
            return True
        return super(MTMenu, self).on_touch_move(touch)

    def on_touch_up(self, touch):
        if touch.grab_current == self and self.dragid == touch.uid:
            touch.ungrab(self)
            return True
        return super(MTMenu, self).on_touch_up(touch)

    def draw(self):
        set_color(*self.style.get('bg-color'))

        # outter
        pos = self.x - 5, self.y - 5
        size = self.width + 10, self.height + 40
        drawRoundedRectangle(pos=pos, size=size)

        # title
        drawLabel(label='Menu', pos=(self.x + 5, self.y + self.height + 4),
                  font_size=16, center=False)

        super(MTMenu, self).draw()


class MTGestureDetector(MTGestureWidget):
    def __init__(self, gdb, **kwargs):
        super(MTGestureDetector, self).__init__(**kwargs)
        self.gdb = gdb
        self.dt = 0
        self.inactivity = 0
        self.inactivity_timeout = 5

    def on_touch_down(self, touch):
        touch.userdata['desktop.gesture'] = list(touch.pos)
        return super(MTGestureDetector, self).on_touch_down(touch)

    def on_touch_move(self, touch):
        if 'desktop.gesture' in touch.userdata:
            touch.userdata['desktop.gesture'] += list(touch.pos)
        return super(MTGestureDetector, self).on_touch_move(touch)

    def draw(self):
        # draw gestures
        set_color(1, 1, 1, .6)
        for touch in getCurrentTouches():
            if not 'desktop.gesture' in touch.userdata:
                continue
            drawLine(touch.userdata['desktop.gesture'], width=5.)

        if len(getCurrentTouches()):
            self.inactivity = 0
            return
        self.inactivity += getFrameDt()
        if self.inactivity < self.inactivity_timeout:
            return
        alpha = (self.inactivity - self.inactivity_timeout) / 3.
        alpha = boundary(alpha, 0, 1.)

        w = self.get_parent_window()
        s2 = Vector(w.size) / 2.
        self.dt += getFrameDt() * 2

        step = math.pi / 20.
        radius = 50
        i = 0
        with DO(gx_attrib(GL_LINE_BIT), gx_blending):
            glLineWidth(3)
            with gx_begin(GL_LINE_STRIP):
                while i < math.pi * 2:
                    x, y = math.cos(self.dt - i) * radius, math.sin(self.dt - i) * radius
                    glColor4f(1, 1, 1, min(alpha, i / math.pi))
                    glVertex2f(x + s2.x, y + s2.y - 70)
                    i += step

            set_color(1, 1, 1, alpha)
            drawCircle(pos=(x + s2.x, y + s2.y - 70), radius=4)
            drawCircle(pos=(x + s2.x, y + s2.y - 70), radius=20, linewidth=2)

        label='Draw a circle to make the menu appear'
        k = {'font_size': 24, 'bold': True}
        pos = Vector(w.size) / 2. + Vector(0, 10)
        drawLabel(label=label, pos=pos, color=(.5, .5, .5, min(alpha, .5)), **k)
        pos += Vector(1, -1)
        drawLabel(label=label, pos=pos, color=(1, 1, 2, alpha), **k)

    def on_gesture(self, gesture, touch):
        #print self.gdb.gesture_to_str(gesture)
        # Check whether gesture is to small
        #if ((gesture.width < self.parent.width / 10) or ((gesture.height < self.parent.height / 10)):
        if (gesture.width < self.parent.width / 10) or (gesture.height < self.parent.height / 10):
            return

        try:
            score, best = self.gdb.find(gesture, minscore=.5)
        except Exception, e:
            return

        if best.id == 'circle':
            angle = gesture.get_rigid_rotation(best)
            menu = MTMenu(pos=(touch.x, touch.y), color=(.2, .2, .2, .5), rotation=angle)
            self.parent.add_widget(menu)

        if best.id == 'close':
            menu = MTMenu(pos=(touch.x, touch.y), color=(.2, .2, .2, .5))
            self.parent.add_widget(menu)


if __name__ == '__main__':
    import os

    # Create and fill gesture database
    gdb = GestureDatabase()
    gesture_add_default(gdb)

    # Create background window
    w = getWindow()
    w.wallpaper = os.path.join(os.path.dirname(__file__), 'data', 'wallpaper.jpg')
    w.wallpaper_position = 'strech'

    g = MTGestureDetector(gdb)
    w.add_widget(g)

    runTouchApp()