<commit_before>import gtk
from gobject import timeout_add, source_remove

class EscapeObject(object): pass

class FeedbackPopup(object):
    def __init__(self):

        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_property('allow-shrink', True)
        self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_POPUP_MENU)

        self.window.props.skip_pager_hint = True
        self.window.props.skip_taskbar_hint = True
        self.window.props.accept_focus = False
        self.window.set_decorated(False)

        self.bar = gtk.EventBox()
        self.bar.set_border_width(5)

        box = gtk.EventBox()

        self.label = gtk.Label()
        self.label.set_alignment(0, 0)
        self.label.set_padding(10, 0)
        box.add(self.label)

        self.bar.add(box)
        self.bar.show_all()

        self.window.add(self.bar)

        self.window.realize()
        self.window.window.set_override_redirect(True)

        self.timeout_id = None

        self.escape = None

    def remove_timeout(self):
        if self.timeout_id:
            source_remove(self.timeout_id)

        self.timeout_id = None

    def show(self, editor, text, timeout=1500, markup=False):
        self.remove_timeout()
        if self.escape:
            self.hide()

        if markup:
            self.label.set_markup(text)
        else:
            self.label.set_text(text)

        self.window.resize(*self.window.size_request())

        win = editor.view.get_window(gtk.TEXT_WINDOW_TEXT)
        x, y, w, h, _ = win.get_geometry()
        x, y = win.get_origin()
        mw, mh = self.window.get_size()

        editor.request_transient_for.emit(self.window)
        self.window.move(x + w - mw, y + h - mh)
        self.window.show()

        if not self.escape:
            self.escape = EscapeObject()

        self.timeout_id = timeout_add(timeout, self.hide)

    def hide(self, *args):<commit_msg>handle focus out/in events for feedback window<commit_after>import gtk
from gobject import timeout_add, source_remove

class EscapeObject(object): pass

class FeedbackPopup(object):
    def __init__(self):

        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_property('allow-shrink', True)

        self.window.props.skip_pager_hint = True
        self.window.props.skip_taskbar_hint = True
        self.window.props.accept_focus = False
        self.window.set_decorated(False)

        self.bar = gtk.EventBox()
        self.bar.set_border_width(5)

        box = gtk.EventBox()

        self.label = gtk.Label()
        self.label.set_alignment(0, 0)
        self.label.set_padding(10, 0)
        box.add(self.label)

        self.bar.add(box)
        self.bar.show_all()

        self.window.add(self.bar)

        self.window.realize()
        self.window.window.set_override_redirect(True)

        self.timeout_id = None
        self.escape = None

        self.handlers_connected = False

    def focus_out_event(self, wnd, event):
        self.window.hide()

    def focus_in_event(self, wnd, event):
        if self.timeout_id:
            self.window.show()

    def remove_timeout(self):
        if self.timeout_id:
            source_remove(self.timeout_id)

        self.timeout_id = None

    def show(self, editor, text, timeout=1500, markup=False):
        if not self.handlers_connected:
            self.handlers_connected = True
            toplevel = editor.view.get_toplevel()
            toplevel.connect('focus-out-event', self.focus_out_event)
            toplevel.connect('focus-in-event', self.focus_in_event)

        self.remove_timeout()
        if self.escape:
            self.hide()

        if markup:
            self.label.set_markup(text)
        else:
            self.label.set_text(text)

        self.window.resize(*self.window.size_request())

        win = editor.view.get_window(gtk.TEXT_WINDOW_TEXT)
        x, y, w, h, _ = win.get_geometry()
        x, y = win.get_origin()
        mw, mh = self.window.get_size()

        editor.request_transient_for.emit(self.window)
        self.window.move(x + w - mw, y + h - mh)
        self.window.show()

        if not self.escape:
            self.escape = EscapeObject()

        self.timeout_id = timeout_add(timeout, self.hide)

    def hide(self, *args):
{'fraction_non_alphanumeric': 0.10927691234596605, 'fraction_numerical': 0.0046500813764240876, 'mean_word_length': 2.21044776119403, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '82651', 'n_tokens_mistral': 1442, 'n_tokens_neox': 1370, 'n_words': 233}