From 80e1fee8c022c994d5de457a5fe76a0f4b926242 Mon Sep 17 00:00:00 2001 From: Tom Chapple Date: Thu, 28 Dec 2023 13:19:34 +1100 Subject: [PATCH 1/2] Use `add_pattern` over `add_mime_type` Since using `add_mime_type` in 51.0, certain Linux distributions do not show file filters correctly (i.e. the filters for what files can be chosen). In its worst case, no files can be chosen. Using `add_pattern` for the equivalent MIME types works as intended for these distributions. It is unknown why using `add_mime_type` causes this issue to occur as minimal programs using this same protocol work as intended. --- bottles/frontend/utils/filters.py | 14 +++++++++++--- bottles/frontend/views/importer.py | 5 ++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/bottles/frontend/utils/filters.py b/bottles/frontend/utils/filters.py index 7c8b3c973fa..40c6bd68687 100644 --- a/bottles/frontend/utils/filters.py +++ b/bottles/frontend/utils/filters.py @@ -19,15 +19,23 @@ 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-xms-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) diff --git a/bottles/frontend/views/importer.py b/bottles/frontend/views/importer.py index 3ccd04f6fe5..6c0b611c1d4 100644 --- a/bottles/frontend/views/importer.py +++ b/bottles/frontend/views/importer.py @@ -122,7 +122,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) From 0dbb0dd6cafc2eccd31170ce499c479c990f558a Mon Sep 17 00:00:00 2001 From: Tom Chapple Date: Thu, 28 Dec 2023 13:40:18 +1100 Subject: [PATCH 2/2] Fix obviously misspelt media type --- bottles/frontend/utils/filters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bottles/frontend/utils/filters.py b/bottles/frontend/utils/filters.py index 40c6bd68687..a8508022ae3 100644 --- a/bottles/frontend/utils/filters.py +++ b/bottles/frontend/utils/filters.py @@ -21,7 +21,7 @@ def add_executable_filters(dialog): filter.set_name(_("Supported Executables")) # TODO: Investigate why `filter.add_mime_type(...)` does not show filter in all distributions. # Intended MIME types are: - # - `application-xms-dos-executable` + # - `application/x-ms-dos-executable` # - `application/x-msi` filter.add_pattern("*.exe") filter.add_pattern("*.msi")