def display_luggage(self, luggage):
     """Update the Frame to display the given (open) Luggage
     """
     self.luggage = luggage
     self.frame_secrets = SecretsFrame(pyluggage_config=self.pyluggage_config, secrets=luggage.load_secrets())
     self.frame_secrets.secrets_changed.connect(self._update_secrets)
     self.frame_files = FilesFrame(pyluggage_config=self.pyluggage_config, luggage=self.luggage)
     self.frame_config = EditConfigFrame(pyluggage_config=self.pyluggage_config, luggage=self.luggage)
     self.tab_contents.setIconSize(QSize(50,50))
     self.tab_contents.addTab(self.frame_secrets, QIcon(":/pyluggage/img/secret_50.png"), _translate("Secrets"))
     self.tab_contents.addTab(self.frame_files, QIcon(":/pyluggage/img/secret_files_50.png"), _translate("Files"))
     self.tab_contents.addTab(self.frame_config, QIcon(":pyluggage/img/config.png"), _translate("Configuration"))
     self.update_controls()
     self.frame_secrets.lineedit_filter.setFocus()
class LuggageFrame(QFrame, Ui_LuggageFrame):
    # Emitted when the current luggage is closed
    luggage_closed = QtCore.pyqtSignal()

    # Emitted when the user requests help
    help_needed = QtCore.pyqtSignal()

    # Luggage being managed by this frame. Can be None before opening
    luggage = None
    # Tabs managed by this frame
    frame_secrets = None
    frame_files = None

    def __init__(self, pyluggage_config):
        QFrame.__init__(self)
        self.setupUi(self)
        self.update_controls()

        self.luggage = None
        self.pyluggage_config = pyluggage_config

        self.button_close.clicked.connect(self.close_luggage)
        self.button_help.clicked.connect(self.help_needed.emit)

    def display_luggage(self, luggage):
        """Update the Frame to display the given (open) Luggage
        """
        self.luggage = luggage
        self.frame_secrets = SecretsFrame(pyluggage_config=self.pyluggage_config, secrets=luggage.load_secrets())
        self.frame_secrets.secrets_changed.connect(self._update_secrets)
        self.frame_files = FilesFrame(pyluggage_config=self.pyluggage_config, luggage=self.luggage)
        self.frame_config = EditConfigFrame(pyluggage_config=self.pyluggage_config, luggage=self.luggage)
        self.tab_contents.setIconSize(QSize(50,50))
        self.tab_contents.addTab(self.frame_secrets, QIcon(":/pyluggage/img/secret_50.png"), _translate("Secrets"))
        self.tab_contents.addTab(self.frame_files, QIcon(":/pyluggage/img/secret_files_50.png"), _translate("Files"))
        self.tab_contents.addTab(self.frame_config, QIcon(":pyluggage/img/config.png"), _translate("Configuration"))
        self.update_controls()
        self.frame_secrets.lineedit_filter.setFocus()

    def close_luggage(self):
        """Update the frame so that it does not reference the luggage and emit the luggage_closed signal
        """
        if self.luggage is not None:
            if be_verbose:
                print "[LuggageFrame] Closing luggage..."

            # Close the luggage, possibly optimizing its file usage
            if self.luggage.get_db_usage_ratio() < self.pyluggage_config.db_compaction_efficiency_threshold:
                CompactLuggageWorker.run_optimization_with_progress_dialog(parent=self, luggage=self.luggage)
            self.luggage = None

            self.frame_files.hide()
            self.frame_secrets.hide()
            self.frame_config.hide()
            for _ in range(3):
                self.tab_contents.removeTab(0)
            self.frame_secrets = None
            self.frame_files = None
            self.frame_config = None
            self.luggage_closed.emit()


    def update_controls(self):
        if self.luggage is not None:
            self.label_luggage_name.setText(os.path.basename(self.luggage.luggage_path))
        self.tab_contents.setFocus()

    def _update_secrets(self):
        """Called when the list of secrets is modified. Make the luggage store the new list
        """
        self.luggage.save_secrets(self.frame_secrets.secret_list)