def unlinkCity(caller,row,statef,cityf): global states caller.set_sensitive(False) path = [statef,"info","cities",cityf] if states.get(path[0]) is not None and states[path[0]].get(path[1]) is not None and states[path[0]][path[1]].get(path[2]) is not None and states[path[0]][path[1]][path[2]].get(path[3]) is not None: del states[path[0]][path[1]][path[2]][path[3]] states[path[0]]["changed"] = True # TODO: Also unlink from place record, if it's loaded kill(caller,row)
def unlinkPlace(caller, row, cityf, placef): global cities caller.set_sensitive(False) path = [cityf, "info", "places", placef] if ( cities.get(path[0]) is not None and cities[path[0]].get(path[1]) is not None and cities[path[0]][path[1]].get(path[2]) is not None and cities[path[0]][path[1]][path[2]].get(path[3]) is not None ): del cities[path[0]][path[1]][path[2]][path[3]] cities[path[0]]["changed"] = True # TODO: Also unlink from place record, if it's loaded kill(caller, row)
def stop(conf): if (common.exists(conf['pidfile']) == True): if (common.kill(int(open(conf['pidfile'], "r").read())) == True): common.delete(conf['pidfile']) return True common.delete(conf['pidfile']) return False
def preClose(caller,fileid,target = None): result = -8 if places.get(fileid): if places[fileid].get("changed"): result = 0 caller.set_sensitive(False) asker = gtk.MessageDialog(None,gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,gtk.MESSAGE_INFO,gtk.BUTTONS_YES_NO,None) asker.set_markup("Are you sure you want to close %s?\nYou will lose all unsaved changes." % fileid) asker.connect("destroy",lambda x: caller.set_sensitive(True)) (x,y,w,h) = caller.get_allocation() asker.move(x - 50,y - 50) result = asker.run() asker.destroy() if result == -8: # Yes print "Destroying tab %s" % fileid kill(caller,target) return True else: # No print "Cancel" return False