11 # A simple applet to display the utilization of the snapshot device
12 # during a casper session
14 # Matt Zimmerman <mdz@canonical.com>
17 # - tooltip with details
18 # - flash at threshold
21 def __init__(self, applet, iid):
22 self.timeout_interval = 1000
23 self.device = 'casper-snapshot'
25 self.datafile = '/var/lib/casper/snapshot-status'
27 # initializate the gnome internals
28 gnome.init("casper", "0.1")
32 self.tooltips = gtk.Tooltips()
33 self.hbox = gtk.HBox()
36 # add the second button event for the popup menu and the enter mouse event to change the tooltip value
37 self.ev_box = gtk.EventBox()
38 #self.ev_box.connect("button-press-event",self.button_press)
39 self.ev_box.connect("enter-notify-event", self.update_info)
40 self.hbox.add(self.ev_box)
42 self.prog = gtk.ProgressBar()
43 self.ev_box.add(self.prog)
47 gtk.timeout_add(self.timeout_interval,self.update_info, self)
49 applet.connect("destroy",self.cleanup)
52 def update_info(self, event=None):
53 self.capacity = self.read_info()
54 self.prog.set_fraction(float(self.capacity[0]) / self.capacity[1])
58 fields = open(self.datafile).readline().split()
59 if fields[2] != 'snapshot':
62 return map(int,fields[3].split('/', 1))
68 def casper_factory(applet, iid):
69 CasperApplet(applet, iid)
73 gnome.applet.bonobo_factory("OAFIID:GNOME_PythonAppletCasper_Factory",
74 gnome.applet.Applet.__gtype__,
75 "casper", "0", casper_factory)