~ubuntu-branches/ubuntu/saucy/radiotray/saucy

« back to all changes in this revision

Viewing changes to src/Plugin.py

  • Committer: Package Import Robot
  • Author(s): Elías Alejandro Año Mendoza
  • Date: 2011-12-28 17:06:38 UTC
  • mfrom: (6.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20111228170638-cym2rxl7boqq8dxr
Tags: 0.7.1-1
* New upstream release
* debian/copyright
  + Added new copyright owners

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
##########################################################################
 
2
# Copyright 2009 Carlos Ribeiro
 
3
#
 
4
# This file is part of Radio Tray
 
5
#
 
6
# Radio Tray is free software: you can redistribute it and/or modify
 
7
# it under the terms of the GNU General Public License as published by
 
8
# the Free Software Foundation, either version 1 of the License, or
 
9
# (at your option) any later version.
 
10
#
 
11
# Radio Tray is distributed in the hope that it will be useful,
 
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
# GNU General Public License for more details.
 
15
#
 
16
# You should have received a copy of the GNU General Public License
 
17
# along with Radio Tray.  If not, see <http://www.gnu.org/licenses/>.
 
18
#
 
19
##########################################################################
 
20
 
 
21
import threading
 
22
import gtk
 
23
import logging
 
24
 
 
25
# This class should be extended by plugins implementations
 
26
class Plugin(threading.Thread):
 
27
 
 
28
    def __init__(self):
 
29
        threading.Thread.__init__(self)
 
30
        self.log = logging.getLogger('radiotray')
 
31
 
 
32
    def initialize(self, name, eventManagerWrapper, eventSubscriber, provider, cfgProvider, mediator, tooltip):
 
33
    
 
34
        self.name = name
 
35
        self.eventManagerWrapper = eventManagerWrapper
 
36
        self.eventSubscriber = eventSubscriber
 
37
        self.provider = provider
 
38
        self.cfgProvider = cfgProvider
 
39
        self.mediator = mediator
 
40
        self.tooltip = tooltip
 
41
        self.menuItem = gtk.MenuItem(self.getName(), False)
 
42
        self.menuItem.connect('activate', self.on_menu)
 
43
        self.menuItem.show()
 
44
 
 
45
 
 
46
    def getName(self):
 
47
        return self.name
 
48
 
 
49
 
 
50
    def activate(self):
 
51
        raise NotImplementedError( "Subclasses should override this" )
 
52
 
 
53
    def finalize(self):
 
54
        print "Finalizing " + self.name
 
55
        self.join()
 
56
 
 
57
    def setMenuItem(self, item):
 
58
        self.menuItem = item
 
59
 
 
60
    def getMenuItem(self):
 
61
        return self.menuItem
 
62
 
 
63
    def hasMenuItem(self):
 
64
        return False
 
65
 
 
66
    def run(self):
 
67
        self.activate()