Add support for multiple Steam library directories
This commit is contained in:
@@ -30,6 +30,30 @@ template PreferencesWindow : Adw.PreferencesWindow {
|
|||||||
valign: center;
|
valign: center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Adw.ActionRow {
|
||||||
|
title: _("Extra Steam Libraries");
|
||||||
|
subtitle: _("Select other directories where you have Steam games installed");
|
||||||
|
|
||||||
|
|
||||||
|
Revealer steam_clear_button_revealer {
|
||||||
|
reveal-child: false;
|
||||||
|
transition-type: slide_left;
|
||||||
|
Button steam_clear_button {
|
||||||
|
label: _("Clear");
|
||||||
|
valign: center;
|
||||||
|
halign: end;
|
||||||
|
|
||||||
|
styles [
|
||||||
|
"destructive-action",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Button steam_extra_file_chooser_button {
|
||||||
|
icon-name: "folder-new-symbolic";
|
||||||
|
valign: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Adw.PreferencesGroup heroic_group {
|
Adw.PreferencesGroup heroic_group {
|
||||||
|
|||||||
@@ -15,6 +15,9 @@
|
|||||||
</key>
|
</key>
|
||||||
<key name="steam-location" type="s">
|
<key name="steam-location" type="s">
|
||||||
<default>"~/.steam/"</default>
|
<default>"~/.steam/"</default>
|
||||||
|
</key>
|
||||||
|
<key name="steam-extra-dirs" type="as">
|
||||||
|
<default>[]</default>
|
||||||
</key>
|
</key>
|
||||||
<key name="heroic-location" type="s">
|
<key name="heroic-location" type="s">
|
||||||
<default>"~/.var/app/com.heroicgameslauncher.hgl/config/heroic/"</default>
|
<default>"~/.var/app/com.heroicgameslauncher.hgl/config/heroic/"</default>
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ class PreferencesWindow(Adw.PreferencesWindow):
|
|||||||
import_sideload_games_switch = Gtk.Template.Child()
|
import_sideload_games_switch = Gtk.Template.Child()
|
||||||
|
|
||||||
steam_file_chooser_button = Gtk.Template.Child()
|
steam_file_chooser_button = Gtk.Template.Child()
|
||||||
|
steam_extra_file_chooser_button = Gtk.Template.Child()
|
||||||
|
steam_clear_button = Gtk.Template.Child()
|
||||||
|
steam_clear_button_revealer = Gtk.Template.Child()
|
||||||
heroic_file_chooser_button = Gtk.Template.Child()
|
heroic_file_chooser_button = Gtk.Template.Child()
|
||||||
bottles_file_chooser_button = Gtk.Template.Child()
|
bottles_file_chooser_button = Gtk.Template.Child()
|
||||||
|
|
||||||
@@ -70,6 +73,12 @@ class PreferencesWindow(Adw.PreferencesWindow):
|
|||||||
|
|
||||||
filechooser = Gtk.FileDialog()
|
filechooser = Gtk.FileDialog()
|
||||||
|
|
||||||
|
def update_revealer():
|
||||||
|
if schema.get_strv("steam-extra-dirs"):
|
||||||
|
self.steam_clear_button_revealer.set_reveal_child(True)
|
||||||
|
else:
|
||||||
|
self.steam_clear_button_revealer.set_reveal_child(False)
|
||||||
|
|
||||||
def set_steam_dir(_source, result, _unused):
|
def set_steam_dir(_source, result, _unused):
|
||||||
try:
|
try:
|
||||||
schema.set_string(
|
schema.set_string(
|
||||||
@@ -79,6 +88,19 @@ class PreferencesWindow(Adw.PreferencesWindow):
|
|||||||
except GLib.GError:
|
except GLib.GError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def add_steam_dir(_source, result, _unused):
|
||||||
|
try:
|
||||||
|
value = schema.get_strv("steam-extra-dirs")
|
||||||
|
value.append(filechooser.select_folder_finish(result).get_path())
|
||||||
|
schema.set_strv("steam-extra-dirs", value)
|
||||||
|
except GLib.GError:
|
||||||
|
pass
|
||||||
|
update_revealer()
|
||||||
|
|
||||||
|
def clear_steam_dirs(*_unused):
|
||||||
|
schema.set_strv("steam-extra-dirs", [])
|
||||||
|
update_revealer()
|
||||||
|
|
||||||
def set_heroic_dir(_source, result, _unused):
|
def set_heroic_dir(_source, result, _unused):
|
||||||
try:
|
try:
|
||||||
schema.set_string(
|
schema.set_string(
|
||||||
@@ -100,7 +122,13 @@ class PreferencesWindow(Adw.PreferencesWindow):
|
|||||||
def choose_folder(_widget, function):
|
def choose_folder(_widget, function):
|
||||||
filechooser.select_folder(parent_widget, None, function, None)
|
filechooser.select_folder(parent_widget, None, function, None)
|
||||||
|
|
||||||
|
update_revealer()
|
||||||
|
|
||||||
self.steam_file_chooser_button.connect("clicked", choose_folder, set_steam_dir)
|
self.steam_file_chooser_button.connect("clicked", choose_folder, set_steam_dir)
|
||||||
|
self.steam_extra_file_chooser_button.connect(
|
||||||
|
"clicked", choose_folder, add_steam_dir
|
||||||
|
)
|
||||||
|
self.steam_clear_button.connect("clicked", clear_steam_dirs)
|
||||||
self.heroic_file_chooser_button.connect(
|
self.heroic_file_chooser_button.connect(
|
||||||
"clicked", choose_folder, set_heroic_dir
|
"clicked", choose_folder, set_heroic_dir
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -267,9 +267,17 @@ def steam_parser(parent_widget, action):
|
|||||||
|
|
||||||
appmanifests = []
|
appmanifests = []
|
||||||
|
|
||||||
for open_file in os.listdir(os.path.join(steam_dir, "steamapps")):
|
steam_dirs = schema.get_strv("steam-extra-dirs")
|
||||||
path = os.path.join(steam_dir, "steamapps", open_file)
|
steam_dirs.append(steam_dir)
|
||||||
if os.path.isfile(path) and "appmanifest" in open_file:
|
|
||||||
appmanifests.append(path)
|
|
||||||
|
|
||||||
get_games_async(parent_widget, appmanifests, steam_dir, import_dialog)
|
for directory in steam_dirs:
|
||||||
|
if not os.path.exists(os.path.join(directory, "steamapps")):
|
||||||
|
steam_dirs.remove(directory)
|
||||||
|
|
||||||
|
for directory in steam_dirs:
|
||||||
|
for open_file in os.listdir(os.path.join(directory, "steamapps")):
|
||||||
|
path = os.path.join(directory, "steamapps", open_file)
|
||||||
|
if os.path.isfile(path) and "appmanifest" in open_file:
|
||||||
|
appmanifests.append(path)
|
||||||
|
|
||||||
|
get_games_async(parent_widget, appmanifests, directory, import_dialog)
|
||||||
|
|||||||
Reference in New Issue
Block a user