~pyjamateam/pyjama/main

« back to all changes in this revision

Viewing changes to release/src/plugins/listenstats/__init__.py

  • Committer: Sebastian Kalinowski
  • Date: 2009-09-26 13:51:17 UTC
  • Revision ID: beton@demonek.com-20090926135117-v92j32js62lkj8zi
Now some plugins will work with Python 2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
        t.start()
34
34
    return wrapper
35
35
 
36
 
@threaded
 
36
#@threaded
37
37
class main():
38
38
    def __init__(self, pyjama):
39
39
        self.pyjama = pyjama
45
45
 
46
46
        self.pyjama.preferences.register_plugin("Listenstats", self.create_preferences, self.save_preferences)
47
47
 
 
48
    @threaded
48
49
    def ev_playlist_tooltip(self, x, y, tooltip_boxes):
49
50
        vbox1, vbox2 = tooltip_boxes
50
51
        path = self.pyjama.window.tvPlaylist.get_path_at_pos(int(x), int(y))
164
165
    def ev_alldone(self):
165
166
        gobject.timeout_add(1, self.ev_alldone2)
166
167
 
 
168
    @threaded
167
169
    def ev_alldone2(self):
168
170
        # Append menu entry
169
171
        menu = self.pyjama.window.menubar
285
287
        self.populate_trackmenu()
286
288
        self.populate_albummenu()
287
289
 
 
290
    @threaded
288
291
    def cb_enter_notify_event(self, widget, event, source):
289
292
        if source == "track":
290
293
            if self.trackmenu.populated == False:
304
307
        elif source == "lastlistened":
305
308
            self.populate_lastlistened()
306
309
 
 
310
    @threaded
307
311
    def cb_play_track(self, widget, track):
308
312
        cur = len(self.pyjama.player.playlist)
309
313
 
313
317
        self.pyjama.setplaylist(cur)
314
318
        self.pyjama.window.on_bPlay_clicked(None) 
315
319
 
 
320
    @threaded
316
321
    def cb_play_album(self, widget, album):
317
322
        tracks = self.pyjama.db.albumtracks(album)
318
323
        self.pyjama.appendtracks(tracks, play=True)
449
454
        else:
450
455
            print ("No recent tracks found")
451
456
 
 
457
    @threaded
452
458
    def ev_nowplaying(self, track):
453
459
        self.pyjama.settingsdb.set_value("listenstats_lastlistened", track.id, time.time())
454
460
 
479
485
#        print("You have listened to this track %s times before!!" % self.pyjama.settingsdb.get_value("listenstats_tracks", track['id']))
480
486
#        print("You have listened to this album %s times before!!" % self.pyjama.settingsdb.get_value("listenstats_albums", track['album_id']))
481
487
 
 
488
    @threaded
482
489
    def cb_play_most_listened_albums(self, widget):
483
490
        sql = "SELECT option, value FROM settings WHERE section='listenstats_albums' ORDER BY value DESC LIMIT %s" % self.max_albums_to_query
484
491
        result = self.pyjama.settingsdb.query(sql)
496
503
        self.pyjama.setplaylist(cur)
497
504
        self.pyjama.window.on_bPlay_clicked(None) 
498
505
 
 
506
    @threaded
499
507
    def cb_play_most_listened_tracks(self, widget):
500
508
        sql = "SELECT option, value FROM settings WHERE section='listenstats_tracks' and value>=%i ORDER BY value DESC" % self.minimum_listens
501
509
        result = self.pyjama.settingsdb.query(sql)
582
590
        self.populate_albummenu()
583
591
        self.populate_trackmenu()
584
592
 
585
 
 
586
 
        
587
 
 
588
 
 
589