# Path: debugger/debugger_api.py
# class StartupInfo(object):
#     def __init__(self, cmd_arguments="", working_directory="", env_vars=None):
#         """
#         @type cmd_arguments: str
#         @type working_directory: str
#         @type env_vars: list of tuple of (str, str)
#         """
#         self.cmd_arguments = cmd_arguments
#         self.working_directory = working_directory
#         self.env_vars = env_vars if env_vars is not None else []
# 
#     def copy(self):
#         return StartupInfo(self.cmd_arguments,
#                            self.working_directory,
#                            list(self.env_vars))
# 
#     def __repr__(self):
#         return "StartupInfo: [{}, {}, {}]".format(
#             self.cmd_arguments, self.working_directory, self.env_vars
#         )
# 
# Path: gui/dialog.py
# class FileOpenDialog(object):
#     @staticmethod
#     @require_gui_thread
#     def select_file(title, parent, initial_path=None):
#         """
#         @type title: str
#         @type parent: Gtk.Widget
#         @type initial_path: str
#         @rtype: str
#         """
#         dialog = FileOpenDialog(title, parent, False, initial_path)
# 
#         file = dialog.open()
#         dialog.destroy()
# 
#         return file
# 
#     @staticmethod
#     @require_gui_thread
#     def select_folder(title, parent, initial_path=None):
#         """
#         @type title: str
#         @type parent: Gtk.Widget
#         @type initial_path: str
#         @rtype: str
#         """
#         dialog = FileOpenDialog(title, parent, True, initial_path)
# 
#         folder = dialog.open()
#         dialog.destroy()
# 
#         return folder
# 
#     def __init__(self, title, parent, directory=False, initial_path=None):
#         """
#         Opens a file or folder chooser dialog.
#         @type title: str
#         @type parent: Gtk.Widget
#         @type directory: bool
#         @type initial_path: str
#         """
#         type = Gtk.FileChooserAction.OPEN
# 
#         if directory:
#             type = Gtk.FileChooserAction.SELECT_FOLDER
# 
#         self.dialog = Gtk.FileChooserDialog(title, parent,
#                                             type,
#                                             (Gtk.STOCK_CANCEL,
#                                              Gtk.ResponseType.CANCEL,
#                                              Gtk.STOCK_OPEN,
#                                              Gtk.ResponseType.OK))
# 
#         if initial_path:
#             self.dialog.set_current_folder(initial_path)
# 
#     @require_gui_thread
#     def open(self):
#         response = self.dialog.run()
#         if response == Gtk.ResponseType.OK:
#             return self.dialog.get_filename()
#         else:
#             return None
# 
#     @require_gui_thread
#     def destroy(self):
#         self.dialog.destroy()
# 
# 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


from gi.repository import Gtk
from debugger.debugger_api import StartupInfo
from gui.dialog import FileOpenDialog
from gui.gui_util import require_gui_thread

        response = self.dialog.run()
        self.dialog.hide()

        if response != Gtk.ResponseType.YES:
            return startup_info
        else:
            return self._construct_startup_info()

    @require_gui_thread
    def _set_startup_info(self, startup_info):
        """
        @type startup_info: debugger.debugger_api.StartupInfo
        """
        for mapping in self.env_line_mapping:
            self.grid.remove_row(1)

        self.env_line_mapping = []

        self.working_dir_entry.set_text(startup_info.working_directory)
        self.cmd_arguments_entry.set_text(startup_info.cmd_arguments)

        for env in startup_info.env_vars:
            self._add_env_var(env[0], env[1])

    @require_gui_thread
    def _construct_startup_info(self):
        """
        @rtype: debugger.debugger_api.StartupInfo
        """

# Path: debugger/debugger_api.py
# class StartupInfo(object):
#     def __init__(self, cmd_arguments="", working_directory="", env_vars=None):
#         """
#         @type cmd_arguments: str
#         @type working_directory: str
#         @type env_vars: list of tuple of (str, str)
#         """
#         self.cmd_arguments = cmd_arguments
#         self.working_directory = working_directory
#         self.env_vars = env_vars if env_vars is not None else []
# 
#     def copy(self):
#         return StartupInfo(self.cmd_arguments,
#                            self.working_directory,
#                            list(self.env_vars))
# 
#     def __repr__(self):
#         return "StartupInfo: [{}, {}, {}]".format(
#             self.cmd_arguments, self.working_directory, self.env_vars
#         )
# 
# Path: gui/dialog.py
# class FileOpenDialog(object):
#     @staticmethod
#     @require_gui_thread
#     def select_file(title, parent, initial_path=None):
#         """
#         @type title: str
#         @type parent: Gtk.Widget
#         @type initial_path: str
#         @rtype: str
#         """
#         dialog = FileOpenDialog(title, parent, False, initial_path)
# 
#         file = dialog.open()
#         dialog.destroy()
# 
#         return file
# 
#     @staticmethod
#     @require_gui_thread
#     def select_folder(title, parent, initial_path=None):
#         """
#         @type title: str
#         @type parent: Gtk.Widget
#         @type initial_path: str
#         @rtype: str
#         """
#         dialog = FileOpenDialog(title, parent, True, initial_path)
# 
#         folder = dialog.open()
#         dialog.destroy()
# 
#         return folder
# 
#     def __init__(self, title, parent, directory=False, initial_path=None):
#         """
#         Opens a file or folder chooser dialog.
#         @type title: str
#         @type parent: Gtk.Widget
#         @type directory: bool
#         @type initial_path: str
#         """
#         type = Gtk.FileChooserAction.OPEN
# 
#         if directory:
#             type = Gtk.FileChooserAction.SELECT_FOLDER
# 
#         self.dialog = Gtk.FileChooserDialog(title, parent,
#                                             type,
#                                             (Gtk.STOCK_CANCEL,
#                                              Gtk.ResponseType.CANCEL,
#                                              Gtk.STOCK_OPEN,
#                                              Gtk.ResponseType.OK))
# 
#         if initial_path:
#             self.dialog.set_current_folder(initial_path)
# 
#     @require_gui_thread
#     def open(self):
#         response = self.dialog.run()
#         if response == Gtk.ResponseType.OK:
#             return self.dialog.get_filename()
#         else:
#             return None
# 
#     @require_gui_thread
#     def destroy(self):
#         self.dialog.destroy()
# 
# 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/startup_dialog.py
from gi.repository import Gtk
from debugger.debugger_api import StartupInfo
from gui.dialog import FileOpenDialog
from gui.gui_util import require_gui_thread


        response = self.dialog.run()
        self.dialog.hide()

        if response != Gtk.ResponseType.YES:
            return startup_info
        else:
            return self._construct_startup_info()

    @require_gui_thread
    def _set_startup_info(self, startup_info):
        """
        @type startup_info: debugger.debugger_api.StartupInfo
        """
        for mapping in self.env_line_mapping:
            self.grid.remove_row(1)

        self.env_line_mapping = []

        self.working_dir_entry.set_text(startup_info.working_directory)
        self.cmd_arguments_entry.set_text(startup_info.cmd_arguments)

        for env in startup_info.env_vars:
            self._add_env_var(env[0], env[1])

    @require_gui_thread
    def _construct_startup_info(self):
        """
        @rtype: debugger.debugger_api.StartupInfo
        """

        startup_info = StartupInfo()