# Path: mcomix/log.py
# def print_(*args, **options):
#     def print_generic(text):
#     def print_win32(text):
#     def __init__(self):
#     def emit(self, record):
#         INVALID_HANDLE_VALUE, STD_OUTPUT_HANDLE = -1, -11
# class PrintHandler(logging.Handler):


import weakref
import threading
import gobject
from mcomix import log
        # Remove this function from the idle queue
        return 0

    def __run_callbacks(self, *args, **kwargs):
        """ Executes callback functions. """
        for obj_ref, func in self.__callbacks:

            if obj_ref is None:
                # Callback is a normal function
                callback = func
            elif obj_ref() is not None:
                # Callback is a bound method.
                # Recreate it by binding the function to the object.
                callback = func.__get__(obj_ref())
            else:
                # Callback is a bound method, object
                # no longer exists.
                callback = None

            if callback:
                try:
                    callback(*args, **kwargs)
                except Exception, e:
                    log.error(_('! Callback %(function)r failed: %(error)s'),
                              { 'function' : callback, 'error' : e })

    def __callback_deleted(self, obj_ref):
        """ Called whenever one of the callback objects is collected by gc.
        This removes all callback functions registered by the object. """
        self.__callbacks = filter(lambda callback: callback[0] != obj_ref,

# Path: mcomix/log.py
# def print_(*args, **options):
#     def print_generic(text):
#     def print_win32(text):
#     def __init__(self):
#     def emit(self, record):
#         INVALID_HANDLE_VALUE, STD_OUTPUT_HANDLE = -1, -11
# class PrintHandler(logging.Handler):


# Path: mcomix/callback.py
import weakref
import threading
import gobject
from mcomix import log

        # Remove this function from the idle queue
        return 0

    def __run_callbacks(self, *args, **kwargs):
        """ Executes callback functions. """
        for obj_ref, func in self.__callbacks:

            if obj_ref is None:
                # Callback is a normal function
                callback = func
            elif obj_ref() is not None:
                # Callback is a bound method.
                # Recreate it by binding the function to the object.
                callback = func.__get__(obj_ref())
            else:
                # Callback is a bound method, object
                # no longer exists.
                callback = None

            if callback:
                try:
                    callback(*args, **kwargs)
                except Exception, e:
                    log.error(_('! Callback %(function)r failed: %(error)s'),
                              { 'function' : callback, 'error' : e })

    def __callback_deleted(self, obj_ref):
        """ Called whenever one of the callback objects is collected by gc.
        This removes all callback functions registered by the object. """
        self.__callbacks = filter(lambda callback: callback[0] != obj_ref,

            self.__callbacks)