import gtk import hildondesktop import hildon import os class MmmAudioWidgetPlugin(hildondesktop.HomePluginItem): def __init__(self): hildondesktop.HomePluginItem.__init__(self) self.set_size_request(90, 90) button = gtk.Button("Play") button.connect("clicked", self.play_clicked) button.show_all() self.add(button) self.set_settings(True) self.connect("show-settings", self.show_dialog) self.sound_file = "/home/user/MyDocs/sound.wav" def show_dialog(self, plugin): chooser = hildon.FileChooserDialog(plugin, gtk.FILE_CHOOSER_ACTION_OPEN) response = chooser.run() if response == gtk.RESPONSE_OK: self.sound_file = chooser.get_filename() chooser.destroy() def play_clicked(self, button): os.system("echo \"" + self.sound_file + "\"") os.system("play-sound \"" + self.sound_file + "\""); hd_plugin_type = MmmAudioWidgetPlugin # The code below is just for testing purposes. # It allows to run the widget as a standalone process. if __name__ == "__main__": import gobject gobject.type_register(hd_plugin_type) obj = gobject.new(hd_plugin_type, plugin_id="plugin_id") obj.show_all() gtk.main()