|
1 | | -# $Id: display.py,v 1.20 2005-11-16 15:50:47 petli Exp $ |
| 1 | +# $Id: display.py,v 1.21 2007-03-17 22:14:06 mggrant Exp $ |
2 | 2 | # |
3 | 3 | # Xlib.display -- high level display object |
4 | 4 | # |
@@ -438,10 +438,22 @@ def intern_atom(self, name, only_if_exists = 0): |
438 | 438 | """Intern the string name, returning its atom number. If |
439 | 439 | only_if_exists is true and the atom does not already exist, it |
440 | 440 | will not be created and X.NONE is returned.""" |
441 | | - r = request.InternAtom(display = self.display, |
442 | | - name = name, |
443 | | - only_if_exists = only_if_exists) |
444 | | - return r.atom |
| 441 | + r = request.InternAtom(display = self.display, |
| 442 | + name = name, |
| 443 | + only_if_exists = only_if_exists) |
| 444 | + return r.atom |
| 445 | + |
| 446 | + def get_atom(self, atom, only_if_exists = 0): |
| 447 | + """Alias for intern_atom, using internal cache if safe to do""" |
| 448 | + if only_if_exists == 0: |
| 449 | + # cache lookup will create the atom, as the user wishes |
| 450 | + # safe to use the cache |
| 451 | + return self.display.get_atom(atom) |
| 452 | + else: |
| 453 | + # the user doesn't want the atom created if it doesn't |
| 454 | + # exist, so use intern_atom to avoid the cache creating it |
| 455 | + return self.intern_atom(atom, only_if_exists) |
| 456 | + |
445 | 457 |
|
446 | 458 | def get_atom_name(self, atom): |
447 | 459 | """Look up the name of atom, returning it as a string. Will raise |
|
0 commit comments