diff --git a/src/Dialogs/Preferences/Pages/Backup.vala b/src/Dialogs/Preferences/Pages/Backup.vala index f8e671a24..680aa6e6a 100644 --- a/src/Dialogs/Preferences/Pages/Backup.vala +++ b/src/Dialogs/Preferences/Pages/Backup.vala @@ -71,7 +71,7 @@ public class Dialogs.Preferences.Pages.Backup : Adw.Bin { backups_group.set_sort_func (set_sort_func); - var import_planner_button = new Gtk.Button.with_label (_("Select Database File")); + var import_planner_button = new Gtk.Button.with_label (_("Migrate")); var migrate_group = new Layouts.HeaderItem (_("Migrate From Planner")); migrate_group.reveal = true; @@ -87,12 +87,6 @@ public class Dialogs.Preferences.Pages.Backup : Adw.Bin { content_box.append (import_button); content_box.append (backups_group); content_box.append (migrate_group); - content_box.append (new Gtk.Label (_("The Planner database should be located in the following path: /home//.var/app/com.github.alainm23.planner/data/com.github.alainm23.planner/database.db")) { - wrap = true, - css_classes = { "dim-label", "small-label" }, - xalign = 0, - margin_start = 9 - }); var content_clamp = new Adw.Clamp () { maximum_size = 400, @@ -139,13 +133,17 @@ public class Dialogs.Preferences.Pages.Backup : Adw.Bin { }); import_planner_button.clicked.connect (() => { - Services.Migrate.get_default ().select_file.begin ((obj, res) => { - GLib.File file = Services.Migrate.get_default ().select_file.end (res); + string path = Environment.get_home_dir () + "/.var/app/com.github.alainm23.planner/data/com.github.alainm23.planner/database.db"; + GLib.File file = GLib.File.new_for_path (path); + + if (file.query_exists ()) { if (Services.Migrate.get_default ().migrate_from_file (file)) { popup_toast (_("Tasks Migrate Successfully")); pop_subpage (); } - }); + } else { + popup_toast (_("The database file does not exist.")); + } }); foreach (Objects.Backup backup in Services.Backups.get_default ().backups) { diff --git a/src/Services/Migrate.vala b/src/Services/Migrate.vala index d407a3841..1f50ff302 100644 --- a/src/Services/Migrate.vala +++ b/src/Services/Migrate.vala @@ -28,20 +28,6 @@ public class Services.Migrate : GLib.Object { }); } - public async GLib.File? select_file () { - var dialog = new Gtk.FileDialog (); - add_filters (dialog); - - try { - var file = yield dialog.open (Planify._instance.main_window, null); - return file; - } catch (Error e) { - debug ("Error during import database: %s".printf (e.message)); - } - - return null; - } - private void add_filters (Gtk.FileDialog file_dialog) { Gtk.FileFilter filter = new Gtk.FileFilter (); filter.add_pattern ("*.db");