Update code style
This commit is contained in:
@@ -32,18 +32,28 @@ def bottles_parser(parent_widget, action):
|
||||
bottles_dir = os.path.expanduser(schema.get_string("bottles-location"))
|
||||
|
||||
def bottles_not_found():
|
||||
if os.path.exists(os.path.expanduser("~/.var/app/com.usebottles.bottles/data/bottles/")):
|
||||
schema.set_string("bottles-location", "~/.var/app/com.usebottles.bottles/data/bottles/")
|
||||
if os.path.exists(
|
||||
os.path.expanduser("~/.var/app/com.usebottles.bottles/data/bottles/")
|
||||
):
|
||||
schema.set_string(
|
||||
"bottles-location", "~/.var/app/com.usebottles.bottles/data/bottles/"
|
||||
)
|
||||
action(None, None)
|
||||
elif os.path.exists(os.path.join(os.environ.get("XDG_DATA_HOME"), "bottles")):
|
||||
schema.set_string("bottles-location", os.path.join(os.environ.get("XDG_DATA_HOME"), "bottles"))
|
||||
schema.set_string(
|
||||
"bottles-location",
|
||||
os.path.join(os.environ.get("XDG_DATA_HOME"), "bottles"),
|
||||
)
|
||||
action(None, None)
|
||||
else:
|
||||
filechooser = Gtk.FileDialog.new()
|
||||
|
||||
def set_bottles_dir(source, result, _):
|
||||
try:
|
||||
schema.set_string("bottles-location", filechooser.select_folder_finish(result).get_path())
|
||||
schema.set_string(
|
||||
"bottles-location",
|
||||
filechooser.select_folder_finish(result).get_path(),
|
||||
)
|
||||
action(None, None)
|
||||
except GLib.GError:
|
||||
return
|
||||
@@ -55,7 +65,13 @@ def bottles_parser(parent_widget, action):
|
||||
if response == "choose_folder":
|
||||
choose_folder(widget)
|
||||
|
||||
create_dialog(parent_widget, _("Couldn't Import Games"), _("The Bottles directory cannot be found."), "choose_folder", _("Set Bottles Location")).connect("response", response)
|
||||
create_dialog(
|
||||
parent_widget,
|
||||
_("Couldn't Import Games"),
|
||||
_("The Bottles directory cannot be found."),
|
||||
"choose_folder",
|
||||
_("Set Bottles Location"),
|
||||
).connect("response", response)
|
||||
|
||||
if os.path.isfile(os.path.join(bottles_dir, "library.yml")):
|
||||
pass
|
||||
@@ -80,25 +96,56 @@ def bottles_parser(parent_widget, action):
|
||||
|
||||
values["game_id"] = "bottles_" + game["id"]
|
||||
|
||||
if values["game_id"] in parent_widget.games and not parent_widget.games[values["game_id"]].removed:
|
||||
if (
|
||||
values["game_id"] in parent_widget.games
|
||||
and not parent_widget.games[values["game_id"]].removed
|
||||
):
|
||||
continue
|
||||
|
||||
values["name"] = game["name"]
|
||||
values["executable"] = "xdg-open bottles:run/" + game["bottle"]["name"] + "/" + game["name"]
|
||||
values["executable"] = (
|
||||
"xdg-open bottles:run/" + game["bottle"]["name"] + "/" + game["name"]
|
||||
)
|
||||
values["hidden"] = False
|
||||
values["source"] = "bottles"
|
||||
values["added"] = current_time
|
||||
values["last_played"] = 0
|
||||
|
||||
if game["thumbnail"]:
|
||||
save_cover(values, parent_widget, os.path.join(bottles_dir, "bottles", game["bottle"]["path"], "grids", game["thumbnail"].split(":")[1]))
|
||||
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
|
||||
|
||||
if len(bottles_games) == 0:
|
||||
create_dialog(parent_widget, _("No Games Found"), _("No new games were found in the Bottles library."))
|
||||
create_dialog(
|
||||
parent_widget,
|
||||
_("No Games Found"),
|
||||
_("No new games were found in the Bottles library."),
|
||||
)
|
||||
elif len(bottles_games) == 1:
|
||||
create_dialog(parent_widget, _("Bottles Games Imported"), _("Successfully imported 1 game."))
|
||||
create_dialog(
|
||||
parent_widget,
|
||||
_("Bottles Games Imported"),
|
||||
_("Successfully imported 1 game."),
|
||||
)
|
||||
elif len(bottles_games) > 1:
|
||||
create_dialog(parent_widget, _("Bottles Games Imported"), _("Successfully imported") + " " + str(len(bottles_games)) + " " + _("games."))
|
||||
create_dialog(
|
||||
parent_widget,
|
||||
_("Bottles Games Imported"),
|
||||
_("Successfully imported")
|
||||
+ " "
|
||||
+ str(len(bottles_games))
|
||||
+ " "
|
||||
+ _("games."),
|
||||
)
|
||||
return bottles_games
|
||||
|
||||
@@ -29,12 +29,9 @@ from .save_cover import save_cover
|
||||
from .save_games import save_games
|
||||
|
||||
|
||||
def create_details_window(parent_widget, game_id = None):
|
||||
def create_details_window(parent_widget, game_id=None):
|
||||
window = Adw.Window(
|
||||
modal = True,
|
||||
default_width = 450,
|
||||
default_height = 650,
|
||||
transient_for = parent_widget
|
||||
modal=True, default_width=450, default_height=650, transient_for=parent_widget
|
||||
)
|
||||
|
||||
games = parent_widget.games
|
||||
@@ -50,12 +47,12 @@ def create_details_window(parent_widget, game_id = None):
|
||||
window.set_title(_("Edit Game Details"))
|
||||
cover = Gtk.Picture.new_for_pixbuf(get_cover(game_id, parent_widget))
|
||||
name = Gtk.Entry.new_with_buffer(Gtk.EntryBuffer.new(games[game_id].name, -1))
|
||||
executable = Gtk.Entry.new_with_buffer(Gtk.EntryBuffer.new((games[game_id].executable), -1))
|
||||
executable = Gtk.Entry.new_with_buffer(
|
||||
Gtk.EntryBuffer.new((games[game_id].executable), -1)
|
||||
)
|
||||
apply_button = Gtk.Button.new_with_label(_("Apply"))
|
||||
|
||||
image_filter = Gtk.FileFilter(
|
||||
name= _("Images")
|
||||
)
|
||||
image_filter = Gtk.FileFilter(name=_("Images"))
|
||||
image_filter.add_pixbuf_formats()
|
||||
file_filters = Gio.ListStore.new(Gtk.FileFilter)
|
||||
file_filters.append(image_filter)
|
||||
@@ -66,38 +63,38 @@ def create_details_window(parent_widget, game_id = None):
|
||||
cover.set_size_request(200, 300)
|
||||
|
||||
cover_button = Gtk.Button(
|
||||
icon_name = "document-edit-symbolic",
|
||||
halign = Gtk.Align.END,
|
||||
valign = Gtk.Align.END,
|
||||
margin_bottom = 6,
|
||||
margin_end = 6,
|
||||
css_classes = ["circular", "osd"],
|
||||
icon_name="document-edit-symbolic",
|
||||
halign=Gtk.Align.END,
|
||||
valign=Gtk.Align.END,
|
||||
margin_bottom=6,
|
||||
margin_end=6,
|
||||
css_classes=["circular", "osd"],
|
||||
)
|
||||
|
||||
cover_overlay = Gtk.Overlay(
|
||||
child = cover,
|
||||
halign = Gtk.Align.CENTER,
|
||||
valign = Gtk.Align.CENTER,
|
||||
child=cover,
|
||||
halign=Gtk.Align.CENTER,
|
||||
valign=Gtk.Align.CENTER,
|
||||
)
|
||||
cover_overlay.add_overlay(cover_button)
|
||||
|
||||
cover_clamp = Adw.Clamp(
|
||||
maximum_size = 200,
|
||||
child = cover_overlay,
|
||||
maximum_size=200,
|
||||
child=cover_overlay,
|
||||
)
|
||||
|
||||
cover_group = Adw.PreferencesGroup()
|
||||
cover_group.add(cover_clamp)
|
||||
|
||||
title_group = Adw.PreferencesGroup(
|
||||
title = _("Title"),
|
||||
description = _("The title of the game"),
|
||||
title=_("Title"),
|
||||
description=_("The title of the game"),
|
||||
)
|
||||
title_group.add(name)
|
||||
|
||||
exec_group = Adw.PreferencesGroup(
|
||||
title = _("Executable"),
|
||||
description = _("File to open or command to run when launching the game"),
|
||||
title=_("Executable"),
|
||||
description=_("File to open or command to run when launching the game"),
|
||||
)
|
||||
exec_group.add(executable)
|
||||
|
||||
@@ -111,8 +108,8 @@ def create_details_window(parent_widget, game_id = None):
|
||||
apply_button.add_css_class("suggested-action")
|
||||
|
||||
header_bar = Adw.HeaderBar(
|
||||
show_start_title_buttons = False,
|
||||
show_end_title_buttons = False,
|
||||
show_start_title_buttons=False,
|
||||
show_end_title_buttons=False,
|
||||
)
|
||||
header_bar.pack_start(cancel_button)
|
||||
header_bar.pack_end(apply_button)
|
||||
@@ -128,7 +125,9 @@ def create_details_window(parent_widget, game_id = None):
|
||||
def set_cover(source, result, _):
|
||||
nonlocal pixbuf
|
||||
try:
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(filechooser.open_finish(result).get_path(), 200, 300, False)
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
|
||||
filechooser.open_finish(result).get_path(), 200, 300, False
|
||||
)
|
||||
cover.set_pixbuf(pixbuf)
|
||||
except GLib.GError:
|
||||
return
|
||||
@@ -148,11 +147,15 @@ def create_details_window(parent_widget, game_id = None):
|
||||
if game_id == None:
|
||||
|
||||
if final_name == "":
|
||||
create_dialog(window, _("Couldn't Add Game"), _("Game title cannot be empty."))
|
||||
create_dialog(
|
||||
window, _("Couldn't Add Game"), _("Game title cannot be empty.")
|
||||
)
|
||||
return
|
||||
|
||||
if final_executable == "":
|
||||
create_dialog(window, _("Couldn't Add Game"), _("Executable cannot be empty."))
|
||||
create_dialog(
|
||||
window, _("Couldn't Add Game"), _("Executable cannot be empty.")
|
||||
)
|
||||
return
|
||||
|
||||
# Increment the number after the game id (eg. imported_1, imported_2)
|
||||
@@ -163,7 +166,7 @@ def create_details_window(parent_widget, game_id = None):
|
||||
if "imported_" in game:
|
||||
numbers.append(int(game.replace("imported_", "")))
|
||||
|
||||
game_id = "imported_" + str(max(numbers)+1)
|
||||
game_id = "imported_" + str(max(numbers) + 1)
|
||||
|
||||
values["game_id"] = game_id
|
||||
values["hidden"] = False
|
||||
@@ -173,11 +176,19 @@ def create_details_window(parent_widget, game_id = None):
|
||||
|
||||
else:
|
||||
if final_name == "":
|
||||
create_dialog(window, _("Couldn't Apply Preferences"), _("Game title cannot be empty."))
|
||||
create_dialog(
|
||||
window,
|
||||
_("Couldn't Apply Preferences"),
|
||||
_("Game title cannot be empty."),
|
||||
)
|
||||
return
|
||||
|
||||
if final_executable == "":
|
||||
create_dialog(window, _("Couldn't Apply Preferences"), _("Executable cannot be empty."))
|
||||
create_dialog(
|
||||
window,
|
||||
_("Couldn't Apply Preferences"),
|
||||
_("Executable cannot be empty."),
|
||||
)
|
||||
return
|
||||
|
||||
if pixbuf != None:
|
||||
@@ -186,16 +197,23 @@ def create_details_window(parent_widget, game_id = None):
|
||||
values["name"] = final_name
|
||||
values["executable"] = final_executable
|
||||
|
||||
path = os.path.join(os.path.join(os.environ.get("XDG_DATA_HOME"), "cartridges", "games", game_id + ".json"))
|
||||
path = os.path.join(
|
||||
os.path.join(
|
||||
os.environ.get("XDG_DATA_HOME"),
|
||||
"cartridges",
|
||||
"games",
|
||||
game_id + ".json",
|
||||
)
|
||||
)
|
||||
|
||||
if os.path.exists(path):
|
||||
open_file = open(path, "r")
|
||||
data = json.loads(open_file.read())
|
||||
open_file.close()
|
||||
data.update(values)
|
||||
save_games({game_id : data})
|
||||
save_games({game_id: data})
|
||||
else:
|
||||
save_games({game_id : values})
|
||||
save_games({game_id: values})
|
||||
|
||||
parent_widget.update_games([game_id])
|
||||
if parent_widget.stack.get_visible_child() == parent_widget.overview:
|
||||
@@ -213,9 +231,13 @@ def create_details_window(parent_widget, game_id = None):
|
||||
executable.connect("activate", apply_preferences)
|
||||
|
||||
shortcut_controller = Gtk.ShortcutController()
|
||||
shortcut_controller.add_shortcut(Gtk.Shortcut.new(Gtk.ShortcutTrigger.parse_string('Escape'), Gtk.CallbackAction.new(close_window)))
|
||||
shortcut_controller.add_shortcut(
|
||||
Gtk.Shortcut.new(
|
||||
Gtk.ShortcutTrigger.parse_string("Escape"),
|
||||
Gtk.CallbackAction.new(close_window),
|
||||
)
|
||||
)
|
||||
|
||||
window.add_controller(shortcut_controller)
|
||||
window.set_focus(name)
|
||||
window.present()
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ from gi.repository import Adw, Gtk
|
||||
|
||||
def create_dialog(parent_widget, heading, body, extra_option=None, extra_label=None):
|
||||
dialog = Adw.MessageDialog.new(parent_widget, _(heading), body)
|
||||
dialog.add_response("dismiss", _("Dismiss"))
|
||||
dialog.add_response("dismiss", _("Dismiss"))
|
||||
|
||||
if extra_option:
|
||||
dialog.add_response(extra_option, _(extra_label))
|
||||
|
||||
@@ -25,7 +25,9 @@ from gi.repository import GdkPixbuf
|
||||
def get_cover(game_id, parent_widget):
|
||||
if game_id in parent_widget.pixbufs.keys():
|
||||
return parent_widget.pixbufs[game_id]
|
||||
cover_path = os.path.join(os.environ.get("XDG_DATA_HOME"), "cartridges", "covers", game_id + ".png")
|
||||
cover_path = os.path.join(
|
||||
os.environ.get("XDG_DATA_HOME"), "cartridges", "covers", game_id + ".png"
|
||||
)
|
||||
|
||||
if not os.path.isfile(cover_path):
|
||||
return parent_widget.placeholder_pixbuf
|
||||
|
||||
@@ -33,18 +33,29 @@ def heroic_parser(parent_widget, action):
|
||||
heroic_dir = os.path.expanduser(schema.get_string("heroic-location"))
|
||||
|
||||
def heroic_not_found():
|
||||
if os.path.exists(os.path.expanduser("~/.var/app/com.heroicgameslauncher.hgl/config/heroic/")):
|
||||
schema.set_string("heroic-location", "~/.var/app/com.heroicgameslauncher.hgl/config/heroic/")
|
||||
if os.path.exists(
|
||||
os.path.expanduser("~/.var/app/com.heroicgameslauncher.hgl/config/heroic/")
|
||||
):
|
||||
schema.set_string(
|
||||
"heroic-location",
|
||||
"~/.var/app/com.heroicgameslauncher.hgl/config/heroic/",
|
||||
)
|
||||
action(None, None)
|
||||
elif os.path.exists(os.path.join(os.environ.get("XDG_CONFIG_HOME"), "heroic")):
|
||||
schema.set_string("heroic-location", os.path.join(os.environ.get("XDG_CONFIG_HOME"), "heroic"))
|
||||
schema.set_string(
|
||||
"heroic-location",
|
||||
os.path.join(os.environ.get("XDG_CONFIG_HOME"), "heroic"),
|
||||
)
|
||||
action(None, None)
|
||||
else:
|
||||
filechooser = Gtk.FileDialog.new()
|
||||
|
||||
def set_heroic_dir(source, result, _):
|
||||
try:
|
||||
schema.set_string("heroic-location", filechooser.select_folder_finish(result).get_path())
|
||||
schema.set_string(
|
||||
"heroic-location",
|
||||
filechooser.select_folder_finish(result).get_path(),
|
||||
)
|
||||
action(None, None)
|
||||
except GLib.GError:
|
||||
return
|
||||
@@ -56,7 +67,13 @@ def heroic_parser(parent_widget, action):
|
||||
if response == "choose_folder":
|
||||
choose_folder(widget)
|
||||
|
||||
create_dialog(parent_widget, _("Couldn't Import Games"), _("The Heroic directory cannot be found."), "choose_folder", _("Set Heroic Location")).connect("response", response)
|
||||
create_dialog(
|
||||
parent_widget,
|
||||
_("Couldn't Import Games"),
|
||||
_("The Heroic directory cannot be found."),
|
||||
"choose_folder",
|
||||
_("Set Heroic Location"),
|
||||
).connect("response", response)
|
||||
|
||||
if os.path.exists(os.path.join(heroic_dir, "config.json")):
|
||||
pass
|
||||
@@ -87,7 +104,10 @@ def heroic_parser(parent_widget, action):
|
||||
app_name = game["app_name"]
|
||||
values["game_id"] = "heroic_epic_" + app_name
|
||||
|
||||
if values["game_id"] in parent_widget.games and not parent_widget.games[values["game_id"]].removed:
|
||||
if (
|
||||
values["game_id"] in parent_widget.games
|
||||
and not parent_widget.games[values["game_id"]].removed
|
||||
):
|
||||
continue
|
||||
|
||||
values["name"] = game["title"]
|
||||
@@ -97,7 +117,13 @@ def heroic_parser(parent_widget, action):
|
||||
values["added"] = current_time
|
||||
values["last_played"] = 0
|
||||
|
||||
image_path = os.path.join(heroic_dir, "images-cache", hashlib.sha256((game["art_square"] + "?h=400&resize=1&w=300").encode()).hexdigest())
|
||||
image_path = os.path.join(
|
||||
heroic_dir,
|
||||
"images-cache",
|
||||
hashlib.sha256(
|
||||
(game["art_square"] + "?h=400&resize=1&w=300").encode()
|
||||
).hexdigest(),
|
||||
)
|
||||
if os.path.exists(image_path):
|
||||
save_cover(values, parent_widget, image_path)
|
||||
|
||||
@@ -117,7 +143,10 @@ def heroic_parser(parent_widget, action):
|
||||
|
||||
values["game_id"] = "heroic_gog_" + app_name
|
||||
|
||||
if values["game_id"] in parent_widget.games and not parent_widget.games[values["game_id"]].removed:
|
||||
if (
|
||||
values["game_id"] in parent_widget.games
|
||||
and not parent_widget.games[values["game_id"]].removed
|
||||
):
|
||||
continue
|
||||
|
||||
# Get game title from library.json as it's not present in installed.json
|
||||
@@ -128,8 +157,11 @@ def heroic_parser(parent_widget, action):
|
||||
for game in library["games"]:
|
||||
if game["app_name"] == app_name:
|
||||
values["name"] = game["title"]
|
||||
image_path = os.path.join(heroic_dir, "images-cache",
|
||||
hashlib.sha256(game["art_square"].encode()).hexdigest())
|
||||
image_path = os.path.join(
|
||||
heroic_dir,
|
||||
"images-cache",
|
||||
hashlib.sha256(game["art_square"].encode()).hexdigest(),
|
||||
)
|
||||
if os.path.exists(image_path):
|
||||
save_cover(values, parent_widget, image_path)
|
||||
break
|
||||
@@ -156,7 +188,10 @@ def heroic_parser(parent_widget, action):
|
||||
|
||||
values["game_id"] = "heroic_sideload_" + app_name
|
||||
|
||||
if values["game_id"] in parent_widget.games and not parent_widget.games[values["game_id"]].removed:
|
||||
if (
|
||||
values["game_id"] in parent_widget.games
|
||||
and not parent_widget.games[values["game_id"]].removed
|
||||
):
|
||||
continue
|
||||
|
||||
values["name"] = item["title"]
|
||||
@@ -165,18 +200,36 @@ def heroic_parser(parent_widget, action):
|
||||
values["source"] = "heroic_sideload"
|
||||
values["added"] = current_time
|
||||
values["last_played"] = 0
|
||||
image_path = os.path.join(heroic_dir, "images-cache",
|
||||
hashlib.sha256(item["art_square"].encode()).hexdigest())
|
||||
image_path = os.path.join(
|
||||
heroic_dir,
|
||||
"images-cache",
|
||||
hashlib.sha256(item["art_square"].encode()).hexdigest(),
|
||||
)
|
||||
if os.path.exists(image_path):
|
||||
save_cover(values, parent_widget, image_path)
|
||||
|
||||
heroic_games[values["game_id"]] = values
|
||||
|
||||
if len(heroic_games) == 0:
|
||||
create_dialog(parent_widget, _("No Games Found"), _("No new games were found in the Heroic library."))
|
||||
create_dialog(
|
||||
parent_widget,
|
||||
_("No Games Found"),
|
||||
_("No new games were found in the Heroic library."),
|
||||
)
|
||||
elif len(heroic_games) == 1:
|
||||
create_dialog(parent_widget, _("Heroic Games Imported"), _("Successfully imported 1 game."))
|
||||
create_dialog(
|
||||
parent_widget,
|
||||
_("Heroic Games Imported"),
|
||||
_("Successfully imported 1 game."),
|
||||
)
|
||||
elif len(heroic_games) > 1:
|
||||
create_dialog(parent_widget, _("Heroic Games Imported"),
|
||||
_("Successfully imported") + " " + str(len(heroic_games)) + " " + _("games."))
|
||||
create_dialog(
|
||||
parent_widget,
|
||||
_("Heroic Games Imported"),
|
||||
_("Successfully imported")
|
||||
+ " "
|
||||
+ str(len(heroic_games))
|
||||
+ " "
|
||||
+ _("games."),
|
||||
)
|
||||
return heroic_games
|
||||
|
||||
@@ -24,7 +24,9 @@ from gi.repository import Gio
|
||||
|
||||
|
||||
def run_command(parent_widget, executable):
|
||||
subprocess.Popen(["flatpak-spawn --host " + executable], shell=True, start_new_session=True)
|
||||
subprocess.Popen(
|
||||
["flatpak-spawn --host " + executable], shell=True, start_new_session=True
|
||||
)
|
||||
|
||||
if Gio.Settings.new("hu.kramo.Cartridges").get_boolean("exit-after-launch"):
|
||||
sys.exit()
|
||||
|
||||
@@ -22,7 +22,7 @@ import os
|
||||
from gi.repository import GdkPixbuf, Gio
|
||||
|
||||
|
||||
def save_cover(game, parent_widget, file_path, pixbuf = None, game_id = None):
|
||||
def save_cover(game, parent_widget, file_path, pixbuf=None, game_id=None):
|
||||
covers_dir = os.path.join(os.environ.get("XDG_DATA_HOME"), "cartridges", "covers")
|
||||
if os.path.exists(covers_dir) == False:
|
||||
os.makedirs(covers_dir)
|
||||
@@ -40,4 +40,11 @@ def save_cover(game, parent_widget, file_path, pixbuf = None, game_id = None):
|
||||
|
||||
file = Gio.File.new_for_path(os.path.join(covers_dir, game_id + ".png"))
|
||||
parent_widget.pixbufs[game_id] = pixbuf
|
||||
pixbuf.save_to_streamv_async(file.replace(None, False, Gio.FileCreateFlags.NONE), "png", None, None, None, cover_callback)
|
||||
pixbuf.save_to_streamv_async(
|
||||
file.replace(None, False, Gio.FileCreateFlags.NONE),
|
||||
"png",
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
cover_callback,
|
||||
)
|
||||
|
||||
@@ -32,8 +32,12 @@ def steam_parser(parent_widget, action):
|
||||
steam_dir = os.path.expanduser(schema.get_string("steam-location"))
|
||||
|
||||
def steam_not_found():
|
||||
if os.path.exists(os.path.expanduser("~/.var/app/com.valvesoftware.Steam/data/Steam/")):
|
||||
schema.set_string("steam-location", "~/.var/app/com.valvesoftware.Steam/data/Steam/")
|
||||
if os.path.exists(
|
||||
os.path.expanduser("~/.var/app/com.valvesoftware.Steam/data/Steam/")
|
||||
):
|
||||
schema.set_string(
|
||||
"steam-location", "~/.var/app/com.valvesoftware.Steam/data/Steam/"
|
||||
)
|
||||
action(None, None)
|
||||
elif os.path.exists(os.path.expanduser("~/.steam/steam/")):
|
||||
schema.set_string("steam-location", "~/.steam/steam/")
|
||||
@@ -43,7 +47,10 @@ def steam_parser(parent_widget, action):
|
||||
|
||||
def set_steam_dir(source, result, _):
|
||||
try:
|
||||
schema.set_string("steam-location", filechooser.select_folder_finish(result).get_path())
|
||||
schema.set_string(
|
||||
"steam-location",
|
||||
filechooser.select_folder_finish(result).get_path(),
|
||||
)
|
||||
action(None, None)
|
||||
except GLib.GError:
|
||||
return
|
||||
@@ -55,7 +62,13 @@ def steam_parser(parent_widget, action):
|
||||
if response == "choose_folder":
|
||||
choose_folder(widget)
|
||||
|
||||
create_dialog(parent_widget, _("Couldn't Import Games"), _("The Steam directory cannot be found."), "choose_folder", _("Set Steam Location")).connect("response", response)
|
||||
create_dialog(
|
||||
parent_widget,
|
||||
_("Couldn't Import Games"),
|
||||
_("The Steam directory cannot be found."),
|
||||
"choose_folder",
|
||||
_("Set Steam Location"),
|
||||
).connect("response", response)
|
||||
|
||||
if os.path.exists(os.path.join(steam_dir, "steamapps")):
|
||||
pass
|
||||
@@ -85,12 +98,15 @@ def steam_parser(parent_widget, action):
|
||||
data = open_file.read()
|
||||
open_file.close()
|
||||
for datatype in datatypes:
|
||||
value = re.findall("\"" + datatype + "\"\t\t\"(.*)\"\n", data)
|
||||
value = re.findall('"' + datatype + '"\t\t"(.*)"\n', data)
|
||||
values[datatype] = value[0]
|
||||
|
||||
values["game_id"] = "steam_" + values["appid"]
|
||||
|
||||
if values["game_id"] in parent_widget.games and not parent_widget.games[values["game_id"]].removed:
|
||||
if (
|
||||
values["game_id"] in parent_widget.games
|
||||
and not parent_widget.games[values["game_id"]].removed
|
||||
):
|
||||
continue
|
||||
|
||||
values["executable"] = "xdg-open steam://rungameid/" + values["appid"]
|
||||
@@ -99,15 +115,45 @@ def steam_parser(parent_widget, action):
|
||||
values["added"] = current_time
|
||||
values["last_played"] = 0
|
||||
|
||||
if os.path.isfile(os.path.join(steam_dir, "appcache", "librarycache", values["appid"] + "_library_600x900.jpg")):
|
||||
save_cover(values, parent_widget, os.path.join(steam_dir, "appcache", "librarycache", values["appid"] + "_library_600x900.jpg"))
|
||||
if os.path.isfile(
|
||||
os.path.join(
|
||||
steam_dir,
|
||||
"appcache",
|
||||
"librarycache",
|
||||
values["appid"] + "_library_600x900.jpg",
|
||||
)
|
||||
):
|
||||
save_cover(
|
||||
values,
|
||||
parent_widget,
|
||||
os.path.join(
|
||||
steam_dir,
|
||||
"appcache",
|
||||
"librarycache",
|
||||
values["appid"] + "_library_600x900.jpg",
|
||||
),
|
||||
)
|
||||
|
||||
steam_games[values["game_id"]] = values
|
||||
|
||||
if len(steam_games) == 0:
|
||||
create_dialog(parent_widget, _("No Games Found"), _("No new games were found in the Steam library."))
|
||||
create_dialog(
|
||||
parent_widget,
|
||||
_("No Games Found"),
|
||||
_("No new games were found in the Steam library."),
|
||||
)
|
||||
elif len(steam_games) == 1:
|
||||
create_dialog(parent_widget, _("Steam Games Imported"), _("Successfully imported 1 game."))
|
||||
create_dialog(
|
||||
parent_widget, _("Steam Games Imported"), _("Successfully imported 1 game.")
|
||||
)
|
||||
elif len(steam_games) > 1:
|
||||
create_dialog(parent_widget, _("Steam Games Imported"), _("Successfully imported") + " " + str(len(steam_games)) + " " + _("games."))
|
||||
create_dialog(
|
||||
parent_widget,
|
||||
_("Steam Games Imported"),
|
||||
_("Successfully imported")
|
||||
+ " "
|
||||
+ str(len(steam_games))
|
||||
+ " "
|
||||
+ _("games."),
|
||||
)
|
||||
return steam_games
|
||||
|
||||
Reference in New Issue
Block a user