Repository: flxzt/rnote (language: rust)

Issue:
Problem at the moment of Export the archive,
When I save an archive, it exports as a '.archive' file, but it can't be opened with any program, including Rnote. This issue occurs most of the time, although occasionally it works. Additionally, today I encountered problems when saving the PDF archive. I'm working with Rnote Version 0.10.0 on Windows 11.


Discussion / hints:
Can you provide screenshots of the process, I'm not sure I understand what you mean.
This is what I mean: I discovered that the problem arises when I change the name of the file during download. If I don't change the name, the file is saved as '.Rnote', which is what is expected (Documento Nuevo). However, if I change the name to something else, such as "Documento Nuevo 2", then it can't be opened, and it is saved as '.archive'.
![Captura de pantalla 2024-04-10 101516](https://github.com/flxzt/rnote/assets/143981629/659ee918-a707-4e7e-9fc8-014fda014b9b)
![Captura de pantalla 2024-04-10 101929](https://github.com/flxzt/rnote/assets/143981629/b5c7f6c8-6723-46a7-9967-8f762f423101)
The second picture shows the different ways I tried to download the file. However, the same issue occurred in all cases. (I apologize for translating the button names to English in that manner, but I have the program set to Spanish.)
I'm not sure, but I think you have to save it with a `.rnote` file ending. So the new file name should be `Documento nuevo 2.rnote`

Windows hides file extensions by default, which is why the documents seem to have the same name.
Oh right I see what you did. The file is selected, including the `.rnote` file ending
![image](https://github.com/flxzt/rnote/assets/115779707/c36f2049-7273-4972-96ef-1cf27fab0507)

So that changing the name without removing the selection (or only modifying the first part) will end up with a file that has no extension upon saving

![image](https://github.com/flxzt/rnote/assets/115779707/2f6b6df0-192f-4f30-88f3-62b921e64263)


Found the reason, the filter is not working in the file chooser because it seems right now that you cannot set a default filter without giving a list of filters first and choosing from this list 

From the `gtk-rs` documentation :

If it is not (`filters` is none), the dialog may choose to not make it available.  (for the default filter).

Got a minimum example working, will open a PR to text/fix later.

Fix patch:
diff --git a/crates/rnote-ui/src/dialogs/export.rs b/crates/rnote-ui/src/dialogs/export.rs
index 830bcfb0f5..80f4270b9c 100644
--- a/crates/rnote-ui/src/dialogs/export.rs
+++ b/crates/rnote-ui/src/dialogs/export.rs
@@ -26,10 +26,15 @@ pub(crate) async fn dialog_save_doc_as(appwindow: &RnAppWindow, canvas: &RnCanva
     filter.add_suffix("rnote");
     filter.set_name(Some(&gettext(".rnote")));
 
+    // create the list of filters
+    let filter_list = gio::ListStore::new::<FileFilter>();
+    filter_list.append(&filter);
+
     let filedialog = FileDialog::builder()
         .title(gettext("Save Document As"))
         .modal(true)
         .accept_label(gettext("Save"))
+        .filters(&filter_list)
         .default_filter(&filter)
         .build();
 
@@ -295,6 +300,10 @@ fn create_filedialog_export_doc(
         Some(&(String::from(".") + &file_ext)),
     );
 
+    let filter_list = gio::ListStore::new::<FileFilter>();
+    filter_list.append(&filter);
+    filedialog.set_filters(Some(&filter_list));
+
     filedialog.set_default_filter(Some(&filter));
     filedialog.set_initial_name(Some(&file_name));
     filedialog.set_initial_folder(get_initial_folder_for_export(appwindow, canvas).as_ref());
@@ -591,6 +600,10 @@ fn create_filedialog_export_doc_pages(
         }
     }
 
+    let filter_list = gio::ListStore::new::<FileFilter>();
+    filter_list.append(&filter);
+    filedialog.set_filters(Some(&filter_list));
+
     filedialog.set_default_filter(Some(&filter));
 
     filedialog
@@ -884,6 +897,10 @@ fn create_filedialog_export_selection(
         Some(&(String::from(" - Selection") + "." + &file_ext)),
     );
 
+    let filter_list = gio::ListStore::new::<FileFilter>();
+    filter_list.append(&filter);
+    filedialog.set_filters(Some(&filter_list));
+
     filedialog.set_default_filter(Some(&filter));
     filedialog.set_initial_name(Some(&file_name));
 
@@ -895,6 +912,10 @@ pub(crate) async fn filechooser_export_engine_state(appwindow: &RnAppWindow, can
     filter.add_mime_type("application/json");
     filter.add_suffix("json");
     filter.set_name(Some(&gettext("Json")));
+
+    let filter_list = gio::ListStore::new::<FileFilter>();
+    filter_list.append(&filter);
+
     let initial_name = crate::utils::default_file_title_for_export(
         canvas.output_file(),
         Some(&canvas::OUTPUT_FILE_NEW_TITLE),
@@ -905,6 +926,7 @@ pub(crate) async fn filechooser_export_engine_state(appwindow: &RnAppWindow, can
         .title(gettext("Export Engine State"))
         .modal(true)
         .accept_label(gettext("Export"))
+        .filters(&filter_list)
         .default_filter(&filter)
         .initial_name(&initial_name)
         .build();
@@ -943,6 +965,10 @@ pub(crate) async fn filechooser_export_engine_config(appwindow: &RnAppWindow, ca
     filter.add_mime_type("application/json");
     filter.add_suffix("json");
     filter.set_name(Some(&gettext("Json")));
+
+    let filter_list = gio::ListStore::new::<FileFilter>();
+    filter_list.append(&filter);
+
     let initial_name = crate::utils::default_file_title_for_export(
         canvas.output_file(),
         Some(&canvas::OUTPUT_FILE_NEW_TITLE),
@@ -953,6 +979,7 @@ pub(crate) async fn filechooser_export_engine_config(appwindow: &RnAppWindow, ca
         .title(gettext("Export Engine Config"))
         .modal(true)
         .accept_label(gettext("Export"))
+        .filters(&filter_list)
         .default_filter(&filter)
         .initial_name(&initial_name)
         .build();
diff --git a/crates/rnote-ui/src/dialogs/import.rs b/crates/rnote-ui/src/dialogs/import.rs
index 971061cbd6..bd2f5c2e50 100644
--- a/crates/rnote-ui/src/dialogs/import.rs
+++ b/crates/rnote-ui/src/dialogs/import.rs
@@ -20,10 +20,14 @@ pub(crate) async fn filedialog_open_doc(appwindow: &RnAppWindow) {
     filter.add_suffix("rnote");
     filter.set_name(Some(&gettext(".rnote")));
 
+    let filter_list = gio::ListStore::new::<FileFilter>();
+    filter_list.append(&filter);
+
     let filedialog = FileDialog::builder()
         .title(gettext("Open File"))
         .modal(true)
         .accept_label(gettext("Open"))
+        .filters(&filter_list)
         .default_filter(&filter)
         .build();
 
@@ -62,10 +66,14 @@ pub(crate) async fn filedialog_import_file(appwindow: &RnAppWindow) {
     filter.add_suffix("txt");
     filter.set_name(Some(&gettext("Jpg, Pdf, Png, Svg, Xopp, Txt")));
 
+    let filter_list = gio::ListStore::new::<FileFilter>();
+    filter_list.append(&filter);
+
     let dialog = FileDialog::builder()
         .title(gettext("Import File"))
         .modal(true)
         .accept_label(gettext("Import"))
+        .filters(&filter_list)
         .default_filter(&filter)
         .build();
 


Test patch: