# Path: debugger/enums.py
# class ProcessState(Enum):
#     """
#     Represents the debugged process' state.
#     """
#     Attaching = 3
#     Connected = 2
#     Crashed = 8
#     Detached = 9
#     Exited = 10
#     Invalid = 0
#     Launching = 4
#     Running = 6
#     Stepping = 7
#     Stopped = 5
#     Suspended = 11
#     Unloaded = 1
# 
# class DebuggerState(Enum):
#     """
#     Represents debugger state.
#     """
#     Started = 1
#     BinaryLoaded = 2
#     Running = 3
# 
# 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)


from debugger.enums import ProcessState, DebuggerState
from debugger.util import EventBroadcaster
from gui_util import require_gui_thread, run_on_gui
    @require_gui_thread
    def _get_items(self):
        return [self.toolbar.get_nth_item(i)
                for i in xrange(0, self.toolbar.get_n_items())]

    def _state_exited(self):
        self._change_grp_state(self.grp_halt_control, False)
        self._change_grp_state(self.grp_step, False)
        self._change_state("run", True)

    def _state_stopped(self):
        self._change_grp_state(self.grp_halt_control, False)
        self._change_grp_state(self.grp_step, True)

        self._change_state("stop", True)

    def _state_running(self):
        self._change_grp_state(self.grp_halt_control, True)
        self._change_grp_state(self.grp_step, False)
        self._change_state("run", False)

    def _handle_process_state_change(self, state, event_data):
        if state == ProcessState.Exited:
            self._state_exited()
        elif state == ProcessState.Stopped:
            self._state_stopped()
        elif state == ProcessState.Running:
            self._state_running()

    def _handle_debugger_state_change(self, state, old_value):

# Path: debugger/enums.py
# class ProcessState(Enum):
#     """
#     Represents the debugged process' state.
#     """
#     Attaching = 3
#     Connected = 2
#     Crashed = 8
#     Detached = 9
#     Exited = 10
#     Invalid = 0
#     Launching = 4
#     Running = 6
#     Stepping = 7
#     Stopped = 5
#     Suspended = 11
#     Unloaded = 1
# 
# class DebuggerState(Enum):
#     """
#     Represents debugger state.
#     """
#     Started = 1
#     BinaryLoaded = 2
#     Running = 3
# 
# 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)


# Path: gui/toolbar_manager.py
from debugger.enums import ProcessState, DebuggerState
from debugger.util import EventBroadcaster
from gui_util import require_gui_thread, run_on_gui

    @require_gui_thread
    def _get_items(self):
        return [self.toolbar.get_nth_item(i)
                for i in xrange(0, self.toolbar.get_n_items())]

    def _state_exited(self):
        self._change_grp_state(self.grp_halt_control, False)
        self._change_grp_state(self.grp_step, False)
        self._change_state("run", True)

    def _state_stopped(self):
        self._change_grp_state(self.grp_halt_control, False)
        self._change_grp_state(self.grp_step, True)

        self._change_state("stop", True)

    def _state_running(self):
        self._change_grp_state(self.grp_halt_control, True)
        self._change_grp_state(self.grp_step, False)
        self._change_state("run", False)

    def _handle_process_state_change(self, state, event_data):
        if state == ProcessState.Exited:
            self._state_exited()
        elif state == ProcessState.Stopped:
            self._state_stopped()
        elif state == ProcessState.Running:
            self._state_running()

    def _handle_debugger_state_change(self, state, old_value):

        if (state.is_set(DebuggerState.BinaryLoaded) and