# Path: debugger/debugee.py
# class Variable(object):
#     """
#     Represents a variable with type.
#     """
#     @staticmethod
#     def from_lldb(lldb_var):
#         """
#         @type lldb_var: lldb.SBValue
#         @rtype: Variable
#         """
#         address = str(lldb_var.addr)
#         name = lldb_var.name
#         value = lldb_var.value
# 
#         if value is None:
#             value = lldb_var.summary
# 
#         type = Type.from_lldb(lldb_var.type)
#         path = lldb_var.path
# 
#         var = Variable(address, name, value, type, path)
# 
#         if type.is_composite():
#             for i in xrange(lldb_var.num_children):
#                 var.add_child(Variable.from_lldb(lldb_var.GetChildAtIndex(i)))
# 
#         return var
# 
#     def __init__(self, address=None, name=None, value=None, type=None,
#                  path=None):
#         """
#         @type address: str
#         @type name: str
#         @type value: str
#         @type type: Type
#         @type path: str
#         """
#         self.address = address
#         self.name = name
#         self._value = value
#         self.type = type
#         self.path = path
# 
#         self.children = []
# 
#         self.on_value_changed = EventBroadcaster()
# 
#         self.constraint = None
# 
#     def add_child(self, child):
#         """
#         Adds a child variable to this variable.
#         @type child: Variable
#         """
#         self.children.append(child)
#         child.on_value_changed.redirect(self.on_value_changed)
# 
#     def set_constraint(self, constraint):
#         """
#         @type constraint: callable
#         """
#         self.constraint = constraint
# 
#     def get_index_by_address(self, address):
#         """
#         @type address: str
#         @rtype: int
#         """
#         if address == self.address:
#             return 0
#         else:
#             return None
# 
#     @property
#     def value(self):
#         return self._value
# 
#     @value.setter
#     def value(self, value):
#         if self.constraint and not self.constraint(self, value):
#             return
# 
#         self._value = value
#         self.on_value_changed.notify(self)
# 
#     def __repr__(self):
#         return "Variable: {0} ({1}) = {2}".format(self.type,
#                                                   self.path
#                                                   if self.path
#                                                   else self.name,
#                                                   self.value)
# 
# Path: debugger/util.py
# class EventBroadcaster(object):
#     """
#     Object that broadcasts event to it's listeners.
# 
#     Evety broadcaster represents a single event type.
#     """
#     def __init__(self):
#         self.listeners = []
# 
#     def notify(self, *args, **kwargs):
#         """
#         Notifies all listeners that an event has occured.
#         @param args: arbitraty arguments that will be passed to the listeners
#         """
#         map(lambda listener: listener(*args, **kwargs), self.listeners)
# 
#     def subscribe(self, listener):
#         """
#         Subscribes an event listener, who will receive events from the
#         broadcaster.
#         @type listener: function
#         """
#         self.listeners.append(listener)
# 
#     def unsubscribe(self, listener):
#         """
#         Unsubscribes an event listener.
#         It will no longer receive events after he unsubscribes.
#         @param listener: function
#         """
#         self.listeners.remove(listener)
# 
#     def clear(self):
#         """
#         Removes all event listeners.
#         """
#         self.listeners = []
# 
#     def redirect(self, broadcaster):
#         """
#         Redirects this broadcaster to the given broadcaster.
# 
#         All events fired by this broadcaster will be also delivered to the
#         given broadcaster.
#         @type broadcaster: EventBroadcaster
#         """
#         self.subscribe(broadcaster.notify)
# 
#     def __call__(self, *args, **kwargs):
#         self.notify(*args, **kwargs)
# 
# class Logger(object):
#     """
#     Helper class for logging.
#     """
#     logger = None
# 
#     @staticmethod
#     def init_logger(level):
#         logging.basicConfig()
#         Logger.logger = logging.getLogger("debugger")
#         Logger.logger.setLevel(level)
# 
#     @staticmethod
#     def debug(message, *args, **kwargs):
#         Logger.logger.debug(message, *args, **kwargs)
# 
#     @staticmethod
#     def info(message, *args, **kwargs):
#         Logger.logger.info(message, *args, **kwargs)
# 
# Path: gui/gui_util.py
# def require_gui_thread(func):
#     """
#     @type func: callable
#     @rtype: callable
#     """
#     def check(*args, **kwargs):
#         assert_is_gui_thread()
#         return func(*args, **kwargs)
#     return check


import cairo
from enum import Enum
from debugger.debugee import Variable
from geometry import Margin, RectangleBBox, Padding
from mouse import ClickHandler
from size import Size
from vector import Vector
from widgets import ValueEntry
from debugger.util import EventBroadcaster, Logger
from gui.gui_util import require_gui_thread
        return None

    def get_composite_children(self):
        return self.variable.children


class PointerDrawable(VariableDrawable):
    MIN_DISTANCE_CURVE = 50

    def __init__(self, canvas, pointer, **properties):
        """
        @type canvas: canvas.Canvas
        @type pointer: debugee.Variable
        """
        super(PointerDrawable, self).__init__(canvas, pointer, **properties)
        self.variable = pointer

    def handle_mouse_click(self, mouse_data):
        if self.canvas.drag_manager.is_dragging(self):
            self.canvas.drag_manager.cancel_drag()
        else:
            self.canvas.drag_manager.start_drag(self)

    def handle_drag_end(self, target):
        """
        @type target: Drawable
        """
        if isinstance(target, VariableContainer):
            variable = target.variable
            if variable.type.name != self.variable.target_type.name:

# Path: debugger/debugee.py
# class Variable(object):
#     """
#     Represents a variable with type.
#     """
#     @staticmethod
#     def from_lldb(lldb_var):
#         """
#         @type lldb_var: lldb.SBValue
#         @rtype: Variable
#         """
#         address = str(lldb_var.addr)
#         name = lldb_var.name
#         value = lldb_var.value
# 
#         if value is None:
#             value = lldb_var.summary
# 
#         type = Type.from_lldb(lldb_var.type)
#         path = lldb_var.path
# 
#         var = Variable(address, name, value, type, path)
# 
#         if type.is_composite():
#             for i in xrange(lldb_var.num_children):
#                 var.add_child(Variable.from_lldb(lldb_var.GetChildAtIndex(i)))
# 
#         return var
# 
#     def __init__(self, address=None, name=None, value=None, type=None,
#                  path=None):
#         """
#         @type address: str
#         @type name: str
#         @type value: str
#         @type type: Type
#         @type path: str
#         """
#         self.address = address
#         self.name = name
#         self._value = value
#         self.type = type
#         self.path = path
# 
#         self.children = []
# 
#         self.on_value_changed = EventBroadcaster()
# 
#         self.constraint = None
# 
#     def add_child(self, child):
#         """
#         Adds a child variable to this variable.
#         @type child: Variable
#         """
#         self.children.append(child)
#         child.on_value_changed.redirect(self.on_value_changed)
# 
#     def set_constraint(self, constraint):
#         """
#         @type constraint: callable
#         """
#         self.constraint = constraint
# 
#     def get_index_by_address(self, address):
#         """
#         @type address: str
#         @rtype: int
#         """
#         if address == self.address:
#             return 0
#         else:
#             return None
# 
#     @property
#     def value(self):
#         return self._value
# 
#     @value.setter
#     def value(self, value):
#         if self.constraint and not self.constraint(self, value):
#             return
# 
#         self._value = value
#         self.on_value_changed.notify(self)
# 
#     def __repr__(self):
#         return "Variable: {0} ({1}) = {2}".format(self.type,
#                                                   self.path
#                                                   if self.path
#                                                   else self.name,
#                                                   self.value)
# 
# Path: debugger/util.py
# class EventBroadcaster(object):
#     """
#     Object that broadcasts event to it's listeners.
# 
#     Evety broadcaster represents a single event type.
#     """
#     def __init__(self):
#         self.listeners = []
# 
#     def notify(self, *args, **kwargs):
#         """
#         Notifies all listeners that an event has occured.
#         @param args: arbitraty arguments that will be passed to the listeners
#         """
#         map(lambda listener: listener(*args, **kwargs), self.listeners)
# 
#     def subscribe(self, listener):
#         """
#         Subscribes an event listener, who will receive events from the
#         broadcaster.
#         @type listener: function
#         """
#         self.listeners.append(listener)
# 
#     def unsubscribe(self, listener):
#         """
#         Unsubscribes an event listener.
#         It will no longer receive events after he unsubscribes.
#         @param listener: function
#         """
#         self.listeners.remove(listener)
# 
#     def clear(self):
#         """
#         Removes all event listeners.
#         """
#         self.listeners = []
# 
#     def redirect(self, broadcaster):
#         """
#         Redirects this broadcaster to the given broadcaster.
# 
#         All events fired by this broadcaster will be also delivered to the
#         given broadcaster.
#         @type broadcaster: EventBroadcaster
#         """
#         self.subscribe(broadcaster.notify)
# 
#     def __call__(self, *args, **kwargs):
#         self.notify(*args, **kwargs)
# 
# class Logger(object):
#     """
#     Helper class for logging.
#     """
#     logger = None
# 
#     @staticmethod
#     def init_logger(level):
#         logging.basicConfig()
#         Logger.logger = logging.getLogger("debugger")
#         Logger.logger.setLevel(level)
# 
#     @staticmethod
#     def debug(message, *args, **kwargs):
#         Logger.logger.debug(message, *args, **kwargs)
# 
#     @staticmethod
#     def info(message, *args, **kwargs):
#         Logger.logger.info(message, *args, **kwargs)
# 
# Path: gui/gui_util.py
# def require_gui_thread(func):
#     """
#     @type func: callable
#     @rtype: callable
#     """
#     def check(*args, **kwargs):
#         assert_is_gui_thread()
#         return func(*args, **kwargs)
#     return check


# Path: gui/drawing/drawable.py
import cairo
from enum import Enum
from debugger.debugee import Variable
from geometry import Margin, RectangleBBox, Padding
from mouse import ClickHandler
from size import Size
from vector import Vector
from widgets import ValueEntry
from debugger.util import EventBroadcaster, Logger
from gui.gui_util import require_gui_thread

        return None

    def get_composite_children(self):
        return self.variable.children


class PointerDrawable(VariableDrawable):
    MIN_DISTANCE_CURVE = 50

    def __init__(self, canvas, pointer, **properties):
        """
        @type canvas: canvas.Canvas
        @type pointer: debugee.Variable
        """
        super(PointerDrawable, self).__init__(canvas, pointer, **properties)
        self.variable = pointer

    def handle_mouse_click(self, mouse_data):
        if self.canvas.drag_manager.is_dragging(self):
            self.canvas.drag_manager.cancel_drag()
        else:
            self.canvas.drag_manager.start_drag(self)

    def handle_drag_end(self, target):
        """
        @type target: Drawable
        """
        if isinstance(target, VariableContainer):
            variable = target.variable
            if variable.type.name != self.variable.target_type.name:

                Logger.debug(