def check_bluetooth_status(message, exitfunc, *args, **kwargs): try: applet = AppletService() except: print("Blueman applet needs to be running") exitfunc() if "PowerManager" in applet.QueryPlugins(): if not applet.GetBluetoothStatus(): d = Gtk.MessageDialog(None, type=Gtk.MessageType.ERROR) d.props.icon_name = "blueman" d.props.text = _("Bluetooth Turned Off") d.props.secondary_text = message d.add_button("Exit", Gtk.ResponseType.NO) d.add_button(_("Enable Bluetooth"), Gtk.ResponseType.YES) resp = d.run() d.destroy() if resp != Gtk.ResponseType.YES: exitfunc() else: applet.SetBluetoothStatus('(b)', True, **kwargs) if not applet.GetBluetoothStatus(): print('Failed to enable bluetooth') exitfunc()
def check_bluetooth_status(message, exitfunc, *args, **kwargs): try: applet = AppletService() except: print "Blueman applet needs to be running" exitfunc() if "PowerManager" in applet.QueryPlugins(): if not applet.GetBluetoothStatus(): d = gtk.MessageDialog(None, type=gtk.MESSAGE_ERROR) d.props.icon_name = "blueman" d.props.text = _("Bluetooth Turned Off") d.props.secondary_text = message d.add_button(gtk.STOCK_QUIT, gtk.RESPONSE_NO) d.add_button(_("Enable Bluetooth"), gtk.RESPONSE_YES) resp = d.run() d.destroy() if resp != gtk.RESPONSE_YES: exitfunc() else: applet.SetBluetoothStatus(True, *args, **kwargs)