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

Use add_pattern over add_mime_type for FileFilters #3221

Merged
merged 3 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions bottles/frontend/utils/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,24 @@
def add_executable_filters(dialog):
filter = Gtk.FileFilter()
filter.set_name(_("Supported Executables"))
filter.add_mime_type("application/x-ms-dos-executable")
filter.add_mime_type("application/x-msi")
# TODO: Investigate why `filter.add_mime_type(...)` does not show filter in all distributions.
# Intended MIME types are:
# - `application/x-ms-dos-executable`
# - `application/x-msi`
filter.add_pattern("*.exe")
filter.add_pattern("*.msi")

dialog.add_filter(filter)


def add_yaml_filters(dialog):
filter = Gtk.FileFilter()
filter.set_name("YAML")
filter.add_mime_type("application/x-yaml")
# TODO: Investigate why `filter.add_mime_type(...)` does not show filter in all distributions.
# Intended MIME types are:
# - `application/yaml`
filter.add_pattern("*.yml")
filter.add_pattern("*.yaml")

dialog.add_filter(filter)

Expand Down
5 changes: 4 additions & 1 deletion bottles/frontend/views/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ def set_path(_dialog, response):

filter = Gtk.FileFilter()
filter.set_name("GNU Gzip Archive")
filter.add_mime_type("application/gzip")
# TODO: Investigate why `filter.add_mime_type(...)` does not show filter in all distributions.
# Intended MIME types are:
# - `application/gzip`
filter.add_pattern("*.gz")

dialog.add_filter(filter)
add_all_filters(dialog)
Expand Down
Loading