# 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
#




class ToolbarManager(object):
    def __init__(self, toolbar_builder, debugger):
        signals = {
            "toolbar-run": lambda *x: self.run(),
            "toolbar-continue": lambda *x: self.cont(),
            "toolbar-stop": lambda *x: self.stop(),
            "toolbar-pause": lambda *x: self.pause(),
            "toolbar-step-over": lambda *x: self.step_over(),
            "toolbar-step-in": lambda *x: self.step_in(),
            "toolbar-step-out": lambda *x: self.step_out()
        }

        toolbar_builder.connect_signals(signals)

        self.toolbar_builder = toolbar_builder
        self.toolbar = toolbar_builder.get_object("toolbar")
        self.debugger = debugger
        self.debugger.on_process_state_changed.subscribe(
            self._handle_process_state_change)
        self.debugger.on_debugger_state_changed.subscribe(
            self._handle_debugger_state_change)

        self.grp_halt_control = ["stop", "pause"]
        self.grp_step = ["continue", "step_over", "step_in", "step_out"]


# 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

#




class ToolbarManager(object):
    def __init__(self, toolbar_builder, debugger):
        signals = {
            "toolbar-run": lambda *x: self.run(),
            "toolbar-continue": lambda *x: self.cont(),
            "toolbar-stop": lambda *x: self.stop(),
            "toolbar-pause": lambda *x: self.pause(),
            "toolbar-step-over": lambda *x: self.step_over(),
            "toolbar-step-in": lambda *x: self.step_in(),
            "toolbar-step-out": lambda *x: self.step_out()
        }

        toolbar_builder.connect_signals(signals)

        self.toolbar_builder = toolbar_builder
        self.toolbar = toolbar_builder.get_object("toolbar")
        self.debugger = debugger
        self.debugger.on_process_state_changed.subscribe(
            self._handle_process_state_change)
        self.debugger.on_debugger_state_changed.subscribe(
            self._handle_debugger_state_change)

        self.grp_halt_control = ["stop", "pause"]
        self.grp_step = ["continue", "step_over", "step_in", "step_out"]


        self.on_run_process = EventBroadcaster()