예제 #1
0
 def on_dialog_response(self, dialog: Gtk.Dialog,
                        response: Gtk.ResponseType,
                        _dialog: Gtk.Dialog) -> None:
     dialog.destroy()
     if response == Gtk.ResponseType.ACCEPT:
         keyfile = dialog.get_file()
         self.set_keyfile(keyfile)
    def _on_filechooser_response(self, save_dialog: Gtk.Dialog,
                                 response: Gtk.ResponseType,
                                 _dialog: Gtk.Dialog) -> None:
        save_dialog.destroy()
        if response == Gtk.ResponseType.ACCEPT:
            spinner = Gtk.Spinner()
            spinner.start()
            self.generate_keyfile_button.set_child(spinner)

            keyfile = save_dialog.get_file()

            def callback(gfile, result):
                try:
                    _res, keyfile_hash = generate_keyfile_finish(result)
                except GLib.Error as err:
                    self.generate_keyfile_button.set_icon_name(
                        "security-high-symbolic")
                    logging.debug("Could not create keyfile: %s", err.message)
                    self.keyfile_error_revealer.reveal(True)
                else:
                    self.generate_keyfile_button.set_icon_name(
                        "object-select-symbolic")
                    self.new_keyfile_hash = keyfile_hash
                    self.new_keyfile_path = gfile.get_path()

            generate_keyfile_async(keyfile, callback)
예제 #3
0
    def _on_filechooser_response(self, dialog: Gtk.Dialog,
                                 response: Gtk.ResponseType,
                                 _dialog: Gtk.Dialog) -> None:
        dialog.destroy()
        if response == Gtk.ResponseType.ACCEPT:
            self.generate_keyfile_button.set_sensitive(False)
            self.generate_keyfile_button.set_label(_("Generating…"))
            keyfile = dialog.get_file()
            keyfile_path = keyfile.get_path()
            logging.debug("New keyfile location: %s", keyfile_path)

            def callback(gfile, result):
                password = self.new_password
                keyfile_path = gfile.get_path()
                try:
                    _res, keyfile_hash = generate_keyfile_finish(result)
                except GLib.Error as err:
                    logging.debug("Could not create keyfile: %s", err.message)
                    self.window.send_notification(
                        _("Could not create keyfile"))
                    self.generate_keyfile_button.set_sensitive(True)
                    self.generate_keyfile_button.set_label(_("Generate"))
                else:
                    if not self.composite:
                        password = ""

                    self.database_manager.set_credentials_async(
                        password,
                        keyfile_path,
                        keyfile_hash,
                        self._on_set_credentials,
                    )

            generate_keyfile_async(keyfile, callback)
 def _on_select_filechooser_response(
     self,
     select_dialog: Gtk.Dialog,
     response: Gtk.ResponseType,
     _dialog: Gtk.Dialog,
 ) -> None:
     select_dialog.destroy()
     if response == Gtk.ResponseType.ACCEPT:
         keyfile = select_dialog.get_file()
         keyfile.load_bytes_async(None, self.load_bytes_callback)
    def _on_save_filechooser_response(
        self,
        dialog: Gtk.Dialog,
        response: Gtk.ResponseType,
        _dialog: Gtk.Dialog,
    ) -> None:
        dialog.destroy()
        if response == Gtk.ResponseType.ACCEPT:
            gfile = dialog.get_file()
            bytes_buffer = self.entry.get_attachment_content(self.attachment)
            gbytes = GLib.Bytes.new(bytes_buffer)

            gfile.replace_contents_bytes_async(
                gbytes,
                None,
                False,
                Gio.FileCreateFlags.PRIVATE
                | Gio.FileCreateFlags.REPLACE_DESTINATION,
                None,
                self._replace_contents_callback,
            )