# Path: gpyconf/mvc.py
# class MVCComponent(events.GSignals):
#     """
#     Base class for all MVC components (frontend, backend, controller).
#     Implements the :class:`gpyconf.events.GSignals` class, so signal emitting
#     and connecting can be used for inheriting classes.
#     """
#     def __init__(self):
#         events.GSignals.__init__(self)
#         self.add_event('log')
# 
#     def log(self, message, level='debug'):
#         self.emit('log', message, level=level)
# 
#     def warn(self, message):
#         self.log(message, 'warning')
# 
#     @classmethod
#     def with_arguments(cls, *args, **kwargs):
#         """
#         Returns a :class:`ComponentFactory` instance. That factory is a wrapper
#         to this class that returns an instance of this class when calling it
#         passing ``args`` and ``kwargs`` as additional arguments. For example, ::
# 
#             wrapper = MyMVCComponentSubclass.with_arguments(42, foo='bar')
#             wrapper(a, b)
# 
#         is equal to ::
# 
#             MyMVCComponentSubclass(a, b, 42, foo='bar')
#         """
#         return ComponentFactory(cls, *args, **kwargs)
# 
#     @property
#     def _class_name(self):
#         """ Wrapper to :attr:`self.__class__.__name__` """
#         return self.__class__.__name__


from gi.repository import Gtk as gtk
from gpyconf.mvc import MVCComponent
from .utils import *
        from urlparse import urlunparse
# %FILEHEADER%


def get_widget_for_field(field, mapping=None):
    """
    Looks up for a corresponding :class:`Widget` in ``mapping``
    (Uses the module-default :attr:`WIDGET_MAP` if ``mapping`` is :const:`None`).
    Raises :exc:`KeyError` if no such widget is defined.
    """
    if mapping is None:
        mapping = WIDGET_MAP
    if field._class_name in mapping:
        return mapping[field._class_name](field)
    else:
        raise NotImplementedError("No widget defined for '%s' field. "
            "You could extend the `gpyconf.frontends._gtk.WIDGET_MAP` dict "
            "with your own implementation of a widget for this field "
            "(inherit from `gpyconf.frontends._gtk.Widget`)." % field)


class Widget(MVCComponent):
    """
    Abstract base class for all widgets.

    A widget is used to "display" a field within the window.
    """
    __events__ = ('value-changed',)
    _changed_signal = 'changed'

    def __init__(self, field):

# Path: gpyconf/mvc.py
# class MVCComponent(events.GSignals):
#     """
#     Base class for all MVC components (frontend, backend, controller).
#     Implements the :class:`gpyconf.events.GSignals` class, so signal emitting
#     and connecting can be used for inheriting classes.
#     """
#     def __init__(self):
#         events.GSignals.__init__(self)
#         self.add_event('log')
# 
#     def log(self, message, level='debug'):
#         self.emit('log', message, level=level)
# 
#     def warn(self, message):
#         self.log(message, 'warning')
# 
#     @classmethod
#     def with_arguments(cls, *args, **kwargs):
#         """
#         Returns a :class:`ComponentFactory` instance. That factory is a wrapper
#         to this class that returns an instance of this class when calling it
#         passing ``args`` and ``kwargs`` as additional arguments. For example, ::
# 
#             wrapper = MyMVCComponentSubclass.with_arguments(42, foo='bar')
#             wrapper(a, b)
# 
#         is equal to ::
# 
#             MyMVCComponentSubclass(a, b, 42, foo='bar')
#         """
#         return ComponentFactory(cls, *args, **kwargs)
# 
#     @property
#     def _class_name(self):
#         """ Wrapper to :attr:`self.__class__.__name__` """
#         return self.__class__.__name__


# Path: gpyconf/frontends/gtk/widgets.py
from gi.repository import Gtk as gtk
from gpyconf.mvc import MVCComponent
from .utils import *
        from urlparse import urlunparse

# %FILEHEADER%


def get_widget_for_field(field, mapping=None):
    """
    Looks up for a corresponding :class:`Widget` in ``mapping``
    (Uses the module-default :attr:`WIDGET_MAP` if ``mapping`` is :const:`None`).
    Raises :exc:`KeyError` if no such widget is defined.
    """
    if mapping is None:
        mapping = WIDGET_MAP
    if field._class_name in mapping:
        return mapping[field._class_name](field)
    else:
        raise NotImplementedError("No widget defined for '%s' field. "
            "You could extend the `gpyconf.frontends._gtk.WIDGET_MAP` dict "
            "with your own implementation of a widget for this field "
            "(inherit from `gpyconf.frontends._gtk.Widget`)." % field)


class Widget(MVCComponent):
    """
    Abstract base class for all widgets.

    A widget is used to "display" a field within the window.
    """
    __events__ = ('value-changed',)
    _changed_signal = 'changed'

    def __init__(self, field):

        MVCComponent.__init__(self)