7 class ExampleStatusPlugin(hildondesktop.StatusMenuItem):
9 hildondesktop.StatusMenuItem.__init__(self)
11 self.backend_started = self.status_backend()
13 self.button_title_text = "profile-appointments"
14 self.button = hildon.Button(gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL)
15 self.button.set_style(hildon.BUTTON_STYLE_PICKER)
16 self.button.set_alignment(0.2,0.5,1,1)
17 image = gtk.image_new_from_icon_name("profile-appointments", gtk.ICON_SIZE_BUTTON)
18 self.button.set_image(image)
19 self.button.set_image_position(gtk.POS_LEFT)
20 self.button.connect("clicked", self.button_clicked_event)
22 icon_theme = gtk.icon_theme_get_default()
23 self.pixbuf = icon_theme.load_icon("profile-appointments", 22, gtk.ICON_LOOKUP_NO_SVG)
29 def status_backend(self):
30 """is backend running?"""
31 return commands.getoutput('pgrep switch_backend')
33 def button_clicked_event(self,*args):
34 if self.backend_started:
40 def update_button(self):
41 """Update the start/stop button to reflect current state"""
42 if self.backend_started:
43 self.button.set_text(self.button_title_text,'Stop')
44 self.set_status_area_icon(self.pixbuf)
46 self.button.set_text(self.button_title_text,'Start')
47 self.set_status_area_icon(None)
49 def start_backend(self):
50 """calls backend start"""
51 (exitstatus, outtext) = commands.getstatusoutput("""/etc/init.d/switch_backend start""")
53 print "DEBUG: backend start exit code " + str(status) + ", output: \n"
54 note = hildon.hildon_note_new_information(self.mainwindow, 'profile-appointments failed to start')
55 response = gtk.Dialog.run(note)
58 self.backend_started = True
60 def stop_backend(self):
62 (exitstatus, outtext) = commands.getstatusoutput("""/etc/init.d/switch_backend stop""")
64 print "DEBUG: backend start exit code " + str(status) + ", output: \n"
65 note = hildon.hildon_note_new_information(self.mainwindow, 'profile-appointments failed to start')
66 response = gtk.Dialog.run(note)
69 self.backend_started = False
71 hd_plugin_type = ExampleStatusPlugin