def METHOD_NAME(session):
    main_window = session.get_service("main_window")
    if main_window.window and main_window.window.get_visible():
        status.complete()
        return GLib.SOURCE_REMOVE
    else:
        return GLib.SOURCE_CONTINUE