Cleanups
This commit is contained in:
@@ -17,14 +17,17 @@
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import os
|
||||
import time
|
||||
|
||||
import yaml
|
||||
from gi.repository import GLib, Gtk
|
||||
|
||||
from .create_dialog import create_dialog
|
||||
from .save_cover import save_cover
|
||||
|
||||
|
||||
def bottles_parser(parent_widget, action):
|
||||
import os, yaml, time
|
||||
|
||||
from gi.repository import Gtk, GLib
|
||||
|
||||
from .create_dialog import create_dialog
|
||||
from .save_cover import save_cover
|
||||
|
||||
schema = parent_widget.schema
|
||||
bottles_dir = os.path.expanduser(schema.get_string("bottles-location"))
|
||||
|
||||
@@ -62,7 +65,6 @@ def bottles_parser(parent_widget, action):
|
||||
|
||||
bottles_dir = os.path.expanduser(schema.get_string("bottles-location"))
|
||||
|
||||
datatypes = ["path", "id", "name", "thumbnail"]
|
||||
bottles_games = {}
|
||||
current_time = int(time.time())
|
||||
|
||||
|
||||
@@ -17,14 +17,19 @@
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
def create_details_window(parent_widget, game_id = None):
|
||||
import time, os, json
|
||||
from gi.repository import Adw, Gtk, Gio, GLib, GdkPixbuf
|
||||
from .create_dialog import create_dialog
|
||||
from .save_games import save_games
|
||||
from .save_cover import save_cover
|
||||
from .get_cover import get_cover
|
||||
import json
|
||||
import os
|
||||
import time
|
||||
|
||||
from gi.repository import Adw, GdkPixbuf, Gio, GLib, Gtk
|
||||
|
||||
from .create_dialog import create_dialog
|
||||
from .get_cover import get_cover
|
||||
from .save_cover import save_cover
|
||||
from .save_games import save_games
|
||||
|
||||
|
||||
def create_details_window(parent_widget, game_id = None):
|
||||
window = Adw.Window(
|
||||
modal = True,
|
||||
default_width = 450,
|
||||
@@ -150,6 +155,8 @@ def create_details_window(parent_widget, game_id = None):
|
||||
create_dialog(window, _("Couldn't Add Game"), _("Executable cannot be empty."))
|
||||
return
|
||||
|
||||
# Increment the number after the game id (eg. imported_1, imported_2)
|
||||
|
||||
numbers = [0]
|
||||
|
||||
for game in games:
|
||||
|
||||
@@ -17,9 +17,10 @@
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
def create_dialog(parent_widget, heading, body, extra_option=None, extra_label=None):
|
||||
from gi.repository import Adw, Gtk
|
||||
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"))
|
||||
|
||||
|
||||
@@ -17,15 +17,17 @@
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
def get_cover(game_id, parent_widget):
|
||||
from gi.repository import GdkPixbuf
|
||||
import os
|
||||
import os
|
||||
|
||||
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")
|
||||
|
||||
if os.path.isfile(cover_path) == False:
|
||||
if not os.path.isfile(cover_path):
|
||||
return parent_widget.placeholder_pixbuf
|
||||
|
||||
return GdkPixbuf.Pixbuf.new_from_file(cover_path)
|
||||
|
||||
@@ -17,9 +17,11 @@
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
def get_games(game_ids=None):
|
||||
import os, json
|
||||
import json
|
||||
import os
|
||||
|
||||
|
||||
def get_games(game_ids=None):
|
||||
games_dir = os.path.join(os.environ.get("XDG_DATA_HOME"), "cartridges", "games")
|
||||
games = {}
|
||||
|
||||
|
||||
@@ -17,14 +17,18 @@
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import time
|
||||
|
||||
from gi.repository import GLib, Gtk
|
||||
|
||||
from .create_dialog import create_dialog
|
||||
from .save_cover import save_cover
|
||||
|
||||
|
||||
def heroic_parser(parent_widget, action):
|
||||
import os, json, time, hashlib
|
||||
|
||||
from gi.repository import Gtk, GLib
|
||||
|
||||
from .create_dialog import create_dialog
|
||||
from .save_cover import save_cover
|
||||
|
||||
schema = parent_widget.schema
|
||||
heroic_dir = os.path.expanduser(schema.get_string("heroic-location"))
|
||||
|
||||
|
||||
@@ -17,11 +17,13 @@
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from gi.repository import Gio
|
||||
|
||||
|
||||
def run_command(parent_widget, executable):
|
||||
import subprocess, sys
|
||||
|
||||
from gi.repository import Gio
|
||||
|
||||
subprocess.Popen(["flatpak-spawn --host " + executable], shell=True, start_new_session=True)
|
||||
|
||||
if Gio.Settings.new("hu.kramo.Cartridges").get_boolean("exit-after-launch"):
|
||||
|
||||
@@ -17,10 +17,12 @@
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
def save_cover(game, parent_widget, file_path, pixbuf = None, game_id = None):
|
||||
from gi.repository import Gio, GdkPixbuf
|
||||
import os
|
||||
import os
|
||||
|
||||
from gi.repository import GdkPixbuf, Gio
|
||||
|
||||
|
||||
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)
|
||||
|
||||
@@ -17,11 +17,12 @@
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
def save_games(games):
|
||||
import os, json
|
||||
import json
|
||||
import os
|
||||
|
||||
|
||||
def save_games(games):
|
||||
games_dir = os.path.join(os.environ.get("XDG_DATA_HOME"), "cartridges", "games")
|
||||
existing = []
|
||||
|
||||
if os.path.exists(games_dir) == False:
|
||||
os.makedirs(games_dir)
|
||||
|
||||
@@ -17,14 +17,17 @@
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
|
||||
from gi.repository import GLib, Gtk
|
||||
|
||||
from .create_dialog import create_dialog
|
||||
from .save_cover import save_cover
|
||||
|
||||
|
||||
def steam_parser(parent_widget, action):
|
||||
import os, re, time
|
||||
|
||||
from gi.repository import Gtk, GLib
|
||||
|
||||
from .create_dialog import create_dialog
|
||||
from .save_cover import save_cover
|
||||
|
||||
schema = parent_widget.schema
|
||||
steam_dir = os.path.expanduser(schema.get_string("steam-location"))
|
||||
|
||||
|
||||
@@ -17,8 +17,11 @@
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
|
||||
def toggle_hidden(game):
|
||||
import os, json
|
||||
games_dir = os.path.join(os.environ.get("XDG_DATA_HOME"), "cartridges", "games")
|
||||
|
||||
if not os.path.exists(games_dir):
|
||||
|
||||
Reference in New Issue
Block a user