Add developer property
This commit is contained in:
@@ -31,7 +31,7 @@ from .save_games import save_games
|
||||
|
||||
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=750, transient_for=parent_widget
|
||||
)
|
||||
|
||||
games = parent_widget.games
|
||||
@@ -41,11 +41,15 @@ def create_details_window(parent_widget, game_id=None):
|
||||
window.set_title(_("Add New Game"))
|
||||
cover = Gtk.Picture.new_for_pixbuf(parent_widget.placeholder_pixbuf)
|
||||
name = Gtk.Entry()
|
||||
developer = Gtk.Entry()
|
||||
executable = Gtk.Entry()
|
||||
apply_button = Gtk.Button.new_with_label(_("Confirm"))
|
||||
else:
|
||||
window.set_title(_("Edit Game Details"))
|
||||
cover = Gtk.Picture.new_for_pixbuf(get_cover(game_id, parent_widget))
|
||||
developer = Gtk.Entry.new_with_buffer(
|
||||
Gtk.EntryBuffer.new(games[game_id].developer, -1)
|
||||
)
|
||||
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)
|
||||
@@ -92,6 +96,12 @@ def create_details_window(parent_widget, game_id=None):
|
||||
)
|
||||
title_group.add(name)
|
||||
|
||||
developer_group = Adw.PreferencesGroup(
|
||||
title=_("Developer"),
|
||||
description=_("The developer or publisher (optional)"),
|
||||
)
|
||||
developer_group.add(developer)
|
||||
|
||||
exec_group = Adw.PreferencesGroup(
|
||||
title=_("Executable"),
|
||||
description=_("File to open or command to run when launching the game"),
|
||||
@@ -101,6 +111,7 @@ def create_details_window(parent_widget, game_id=None):
|
||||
general_page = Adw.PreferencesPage()
|
||||
general_page.add(cover_group)
|
||||
general_page.add(title_group)
|
||||
general_page.add(developer_group)
|
||||
general_page.add(exec_group)
|
||||
|
||||
cancel_button = Gtk.Button.new_with_label(_("Cancel"))
|
||||
@@ -142,6 +153,7 @@ def create_details_window(parent_widget, game_id=None):
|
||||
values = {}
|
||||
|
||||
final_name = name.get_buffer().get_text()
|
||||
final_developer = developer.get_buffer().get_text()
|
||||
final_executable = executable.get_buffer().get_text()
|
||||
|
||||
if game_id is None:
|
||||
@@ -195,6 +207,7 @@ def create_details_window(parent_widget, game_id=None):
|
||||
save_cover(None, parent_widget, None, pixbuf, game_id)
|
||||
|
||||
values["name"] = final_name
|
||||
values["developer"] = final_developer if final_developer else None
|
||||
values["executable"] = final_executable
|
||||
|
||||
path = os.path.join(
|
||||
|
||||
@@ -113,6 +113,7 @@ def heroic_parser(parent_widget, action):
|
||||
continue
|
||||
|
||||
values["name"] = game["title"]
|
||||
values["developer"] = game["developer"]
|
||||
values["executable"] = "xdg-open heroic://launch/" + app_name
|
||||
values["hidden"] = False
|
||||
values["source"] = "heroic_epic"
|
||||
@@ -153,7 +154,7 @@ def heroic_parser(parent_widget, action):
|
||||
):
|
||||
continue
|
||||
|
||||
# Get game title from library.json as it's not present in installed.json
|
||||
# Get game title and developer from library.json as they are not present in installed.json
|
||||
with open(
|
||||
os.path.join(heroic_dir, "gog_store", "library.json"), "r"
|
||||
) as open_file:
|
||||
@@ -162,6 +163,7 @@ def heroic_parser(parent_widget, action):
|
||||
library = json.loads(data)
|
||||
for game in library["games"]:
|
||||
if game["app_name"] == app_name:
|
||||
values["developer"] = game["developer"]
|
||||
values["name"] = game["title"]
|
||||
image_path = os.path.join(
|
||||
heroic_dir,
|
||||
|
||||
@@ -22,6 +22,7 @@ import re
|
||||
import time
|
||||
|
||||
from gi.repository import GLib, Gtk
|
||||
from steam.utils.appcache import parse_appinfo
|
||||
|
||||
from .create_dialog import create_dialog
|
||||
from .save_cover import save_cover
|
||||
@@ -92,6 +93,17 @@ def steam_parser(parent_widget, action):
|
||||
if os.path.isfile(path) and "appmanifest" in open_file:
|
||||
appmanifests.append(path)
|
||||
|
||||
with open("/home/kramo/.steam/steam/appcache/appinfo.vdf", "rb") as open_file:
|
||||
_header, apps = parse_appinfo(open_file)
|
||||
|
||||
developers = {
|
||||
app["appid"]: app["data"]["appinfo"]["common"]["associations"]["0"]["name"]
|
||||
for app in apps
|
||||
if "common" in app["data"]["appinfo"]
|
||||
and "associations" in app["data"]["appinfo"]["common"]
|
||||
and "0" in app["data"]["appinfo"]["common"]["associations"]
|
||||
}
|
||||
|
||||
for appmanifest in appmanifests:
|
||||
values = {}
|
||||
with open(appmanifest, "r") as open_file:
|
||||
@@ -114,6 +126,10 @@ def steam_parser(parent_widget, action):
|
||||
values["source"] = "steam"
|
||||
values["added"] = current_time
|
||||
values["last_played"] = 0
|
||||
try:
|
||||
values["developer"] = developers[int(values["appid"])]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
if os.path.isfile(
|
||||
os.path.join(
|
||||
|
||||
Reference in New Issue
Block a user