Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix file chooser dialog on recipe export #347

Merged
merged 4 commits into from
Jun 24, 2021
Merged

Conversation

cydanil
Copy link
Collaborator

@cydanil cydanil commented Jun 24, 2021

Description

This fixes #346 where it's described how recipes cannot be exported.
This was due to a bug in the interface between the file selector window, which returned only a list of filename(s), and the logic later that was expecting an extension to look up the correct plugin.

Now, the extension is directly provided, looked-up from the filetype combobox in the file chooser dialog.

How Has This Been Tested?

This was tested by:

  1. Choosing a filename and a type in the combo box;
  2. Setting a custom extension, but verifying that the type is correctly inferred from the combobox;
    The combo box gets updated when typing another valid extension. That is, if recipe.invalid is provided,
    then the file type is inferred from the combo box.
    If the filename is set to recipe.txt, then the combo box gets updated automatically, and its value is used, as above.
  3. Not setting a filename greys out the Ok button, which simplifies the input validation.
  4. Cancelling an export is correctly handled by returning None, None to the export manager.
  5. The same base class is used to import images. Images can correctly be added to a recipe.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@cydanil
Copy link
Collaborator Author

cydanil commented Jun 24, 2021

The CI generated wheel is available here: gourmet.zip

export_type = sfd.ext_to_filter[extension].get_name()
return filename, export_type
try:
filename, export_type = sfd.run()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The list here is explicitly unpacked to catch empty lists (if the export was cancelled) to correctly return Nones to the export manager, cleanly cancelling the action.

@cydanil cydanil merged commit 7fc6e59 into kirienko:master Jun 24, 2021
@cydanil cydanil deleted the fix/346 branch June 24, 2021 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gourmet crashes when exporting recipes
1 participant