#!/usr/bin/env python # Copyright (C) 2006 Michael Urman # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # import gtk import epiphany def _changed(entry, zws=u'\u200b'.encode('utf-8')): text = entry.get_text() if zws in text: stripped = text.replace(zws, '') entry.set_text(stripped) def find(container, typename): try: children = container.get_children() except: return None for obj in children: objname = type(obj).__name__ if objname == typename or objname.endswith('.' + typename): return obj else: obj = find(obj, typename) if obj is not None: return obj def attach_window(window): loc_entry = find(find(window, 'EphyIconEntry'), 'Entry') if loc_entry is not None: loc_entry._strip_zero_width_sig = loc_entry.connect("changed", _changed) def detach_window(window): loc_entry = find(find(window, 'EphyIconEntry'), 'Entry') if loc_entry is not None: try: sig = loc_entry._strip_zero_width_sig except AttributeError: pass else: loc_entry.disconnect(sig) del loc_entry._strip_zero_width_sig