Bottles import

This commit is contained in:
kramo
2023-02-02 18:52:06 +01:00
parent 24dd082681
commit 8d1e98c277
5 changed files with 30 additions and 3 deletions

View File

@@ -69,5 +69,19 @@ template PreferencesWindow : Adw.PreferencesWindow {
}
}
}
Adw.PreferencesGroup {
title: "Bottles";
Adw.ActionRow {
title: _("Bottles Install Location");
subtitle: _("Directory to use when importing games");
Button bottles_file_chooser_button {
icon-name: "folder-symbolic";
valign: center;
}
}
}
}
}

View File

@@ -30,6 +30,7 @@ class PreferencesWindow(Adw.PreferencesWindow):
steam_file_chooser_button = Gtk.Template.Child()
heroic_file_chooser_button = Gtk.Template.Child()
bottles_file_chooser_button = Gtk.Template.Child()
def __init__(self, parent_widget, **kwargs):
super().__init__(**kwargs)
@@ -55,8 +56,15 @@ class PreferencesWindow(Adw.PreferencesWindow):
except GLib.GError:
pass
def set_bottles_dir(source, result, user_data):
try:
schema.set_string("bottles-location", filechooser.select_folder_finish(result).get_path())
except GLib.GError:
pass
def choose_folder(widget, function):
filechooser.select_folder(parent_widget, None, function, None)
self.steam_file_chooser_button.connect("clicked", choose_folder, set_steam_dir)
self.heroic_file_chooser_button.connect("clicked", choose_folder, set_heroic_dir)
self.bottles_file_chooser_button.connect("clicked", choose_folder, set_bottles_dir)

View File

@@ -69,6 +69,11 @@ def bottles_parser(parent_widget, action):
values = {}
values["game_id"] = "bottles_" + game["id"]
if values["game_id"] in parent_widget.games and "removed" not in parent_widget.games[
values["game_id"]].keys():
continue
values["name"] = game["name"]
values["executable"] = "xdg-open bottles:run/" + game["bottle"]["name"] + "/" + game["name"]
values["hidden"] = False
@@ -77,7 +82,7 @@ def bottles_parser(parent_widget, action):
values["last_played"] = 0
if game["thumbnail"]:
values["pixbuf_options"] = save_cover(values, parent_widget, os.path.join(bottles_dir, "bottles", game["bottle"]["path"], "grids", game["thumbnail"].replace("grid:", "")))
values["pixbuf_options"] = save_cover(values, parent_widget, os.path.join(bottles_dir, "bottles", game["bottle"]["path"], "grids", game["thumbnail"].split(":")[1]))
bottles_games[values["game_id"]] = values