Rename to Cartridges
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gresources>
|
||||
<gresource prefix="/hu/kramo/GameShelf">
|
||||
<gresource prefix="/hu/kramo/Cartridges">
|
||||
<file preprocess="xml-stripblanks">window.ui</file>
|
||||
<file preprocess="xml-stripblanks">gtk/help-overlay.ui</file>
|
||||
<file preprocess="xml-stripblanks">gtk/game.ui</file>
|
||||
@@ -1,6 +1,6 @@
|
||||
#!@PYTHON@
|
||||
|
||||
# gameshelf.in
|
||||
# cartridges.in
|
||||
#
|
||||
# Copyright 2022 kramo
|
||||
#
|
||||
@@ -31,16 +31,16 @@ localedir = '@localedir@'
|
||||
|
||||
sys.path.insert(1, pkgdatadir)
|
||||
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||
locale.bindtextdomain('gameshelf', localedir)
|
||||
locale.textdomain('gameshelf')
|
||||
gettext.install('gameshelf', localedir)
|
||||
locale.bindtextdomain('cartridges', localedir)
|
||||
locale.textdomain('cartridges')
|
||||
gettext.install('cartridges', localedir)
|
||||
|
||||
if __name__ == '__main__':
|
||||
import gi
|
||||
|
||||
from gi.repository import Gio
|
||||
resource = Gio.Resource.load(os.path.join(pkgdatadir, 'gameshelf.gresource'))
|
||||
resource = Gio.Resource.load(os.path.join(pkgdatadir, 'cartridges.gresource'))
|
||||
resource._register()
|
||||
|
||||
from gameshelf import main
|
||||
from cartridges import main
|
||||
sys.exit(main.main(VERSION))
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
from gi.repository import Gtk
|
||||
|
||||
@Gtk.Template(resource_path='/hu/kramo/GameShelf/gtk/game.ui')
|
||||
@Gtk.Template(resource_path='/hu/kramo/Cartridges/gtk/game.ui')
|
||||
class game(Gtk.Box):
|
||||
__gtype_name__ = 'game'
|
||||
|
||||
|
||||
16
src/main.py
16
src/main.py
@@ -24,7 +24,7 @@ gi.require_version("Adw", "1")
|
||||
|
||||
from gi.repository import Gtk, Gio, GLib, Adw
|
||||
|
||||
from .window import GameShelfWindow
|
||||
from .window import CartridgesWindow
|
||||
from .preferences import PreferencesWindow
|
||||
from .toggle_hidden import toggle_hidden
|
||||
from .save_games import save_games
|
||||
@@ -33,9 +33,9 @@ from .steam_parser import steam_parser
|
||||
from .heroic_parser import heroic_parser
|
||||
from .create_details_window import create_details_window
|
||||
|
||||
class GameShelfApplication(Adw.Application):
|
||||
class CartridgesApplication(Adw.Application):
|
||||
def __init__(self):
|
||||
super().__init__(application_id="hu.kramo.GameShelf", flags=Gio.ApplicationFlags.FLAGS_NONE)
|
||||
super().__init__(application_id="hu.kramo.Cartridges", flags=Gio.ApplicationFlags.FLAGS_NONE)
|
||||
self.create_action("quit", self.on_quit_action, ["<primary>q"])
|
||||
self.create_action("about", self.on_about_action)
|
||||
self.create_action("preferences", self.on_preferences_action)
|
||||
@@ -52,7 +52,7 @@ class GameShelfApplication(Adw.Application):
|
||||
# Create the main window
|
||||
win = self.props.active_window
|
||||
if not win:
|
||||
win = GameShelfWindow(application=self)
|
||||
win = CartridgesWindow(application=self)
|
||||
|
||||
win.present()
|
||||
|
||||
@@ -70,8 +70,8 @@ class GameShelfApplication(Adw.Application):
|
||||
|
||||
def on_about_action(self, widget, callback=None):
|
||||
about = Adw.AboutWindow(transient_for=self.props.active_window,
|
||||
application_name="Game Shelf",
|
||||
application_icon="hu.kramo.GameShelf",
|
||||
application_name="Cartridges",
|
||||
application_icon="hu.kramo.Cartridges",
|
||||
developer_name="kramo",
|
||||
version="0.1.1",
|
||||
developers=["kramo"],
|
||||
@@ -119,7 +119,7 @@ class GameShelfApplication(Adw.Application):
|
||||
|
||||
# Add "removed=True" to the game properties so it can be deleted on next init
|
||||
game_id = self.props.active_window.active_game_id
|
||||
open_file = open(os.path.join(os.path.join(os.environ.get("XDG_DATA_HOME"), "games", game_id + ".json")), "r")
|
||||
open_file = open(os.path.join(os.path.join(os.environ.get("XDG_DATA_HOME"), "cartridges", "games", game_id + ".json")), "r")
|
||||
data = json.loads(open_file.read())
|
||||
open_file.close()
|
||||
data["removed"] = True
|
||||
@@ -153,6 +153,6 @@ class GameShelfApplication(Adw.Application):
|
||||
self.set_accels_for_action(f"win.{name}", shortcuts)
|
||||
|
||||
def main(version):
|
||||
app = GameShelfApplication()
|
||||
app = CartridgesApplication()
|
||||
return app.run(sys.argv)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name())
|
||||
moduledir = join_paths(pkgdatadir, 'gameshelf')
|
||||
moduledir = join_paths(pkgdatadir, 'cartridges')
|
||||
gnome = import('gnome')
|
||||
|
||||
blueprints = custom_target('blueprints',
|
||||
@@ -13,8 +13,8 @@ blueprints = custom_target('blueprints',
|
||||
command: [find_program('blueprint-compiler'), 'batch-compile', '@OUTPUT@', '@CURRENT_SOURCE_DIR@', '@INPUT@'],
|
||||
)
|
||||
|
||||
gnome.compile_resources('gameshelf',
|
||||
'gameshelf.gresource.xml',
|
||||
gnome.compile_resources('cartridges',
|
||||
'cartridges.gresource.xml',
|
||||
gresource_bundle: true,
|
||||
install: true,
|
||||
install_dir: pkgdatadir,
|
||||
@@ -30,14 +30,14 @@ conf.set('localedir', join_paths(get_option('prefix'), get_option('localedir')))
|
||||
conf.set('pkgdatadir', pkgdatadir)
|
||||
|
||||
configure_file(
|
||||
input: 'gameshelf.in',
|
||||
output: 'gameshelf',
|
||||
input: 'cartridges.in',
|
||||
output: 'cartridges',
|
||||
configuration: conf,
|
||||
install: true,
|
||||
install_dir: get_option('bindir')
|
||||
)
|
||||
|
||||
gameshelf_sources = [
|
||||
cartridges_sources = [
|
||||
'__init__.py',
|
||||
'main.py',
|
||||
'window.py',
|
||||
@@ -55,4 +55,4 @@ gameshelf_sources = [
|
||||
'utils/create_details_window.py'
|
||||
]
|
||||
|
||||
install_data(gameshelf_sources, install_dir: moduledir)
|
||||
install_data(cartridges_sources, install_dir: moduledir)
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
from gi.repository import Adw, Gtk, Gio, GLib
|
||||
|
||||
@Gtk.Template(resource_path='/hu/kramo/GameShelf/gtk/preferences.ui')
|
||||
@Gtk.Template(resource_path='/hu/kramo/Cartridges/gtk/preferences.ui')
|
||||
class PreferencesWindow(Adw.PreferencesWindow):
|
||||
__gtype_name__ = 'PreferencesWindow'
|
||||
|
||||
|
||||
@@ -131,7 +131,6 @@ def create_details_window(parent_widget, game_id = None):
|
||||
|
||||
values = {}
|
||||
|
||||
games_dir = os.path.join(os.environ.get("XDG_DATA_HOME"), "games")
|
||||
final_name = name.get_buffer().get_text()
|
||||
final_executable = executable.get_buffer().get_text()
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ def get_cover(game, parent_widget):
|
||||
from gi.repository import GdkPixbuf
|
||||
import os
|
||||
|
||||
cover_path = os.path.join(os.environ.get("XDG_DATA_HOME"), "covers", game["game_id"] + ".dat")
|
||||
cover_path = os.path.join(os.environ.get("XDG_DATA_HOME"), "cartridges", "covers", game["game_id"] + ".dat")
|
||||
|
||||
if os.path.isfile(cover_path) == False:
|
||||
return parent_widget.placeholder_pixbuf
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
def get_games():
|
||||
import os, json
|
||||
|
||||
games_dir = os.path.join(os.environ.get("XDG_DATA_HOME"), "games")
|
||||
games_dir = os.path.join(os.environ.get("XDG_DATA_HOME"), "cartridges", "games")
|
||||
games = {}
|
||||
|
||||
if os.path.exists(games_dir) == False:
|
||||
|
||||
@@ -24,5 +24,5 @@ def run_command(parent_widget, executable):
|
||||
|
||||
subprocess.Popen(["flatpak-spawn --host " + executable], shell=True, start_new_session=True)
|
||||
|
||||
if Gio.Settings.new("hu.kramo.GameShelf").get_boolean("exit-after-launch") == True:
|
||||
if Gio.Settings.new("hu.kramo.Cartridges").get_boolean("exit-after-launch") == True:
|
||||
sys.exit()
|
||||
|
||||
@@ -21,7 +21,7 @@ def save_cover(game, parent_widget, file_path, pixbuf = None, game_id = None):
|
||||
from gi.repository import GdkPixbuf
|
||||
import os
|
||||
|
||||
covers_dir = os.path.join(os.environ.get("XDG_DATA_HOME"), "covers")
|
||||
covers_dir = os.path.join(os.environ.get("XDG_DATA_HOME"), "cartridges", "covers")
|
||||
if os.path.exists(covers_dir) == False:
|
||||
os.makedirs(covers_dir)
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
def save_games(games):
|
||||
import os, json
|
||||
games_dir = os.path.join(os.environ.get("XDG_DATA_HOME"), "games")
|
||||
games_dir = os.path.join(os.environ.get("XDG_DATA_HOME"), "cartridges", "games")
|
||||
existing = []
|
||||
|
||||
if os.path.exists(games_dir) == False:
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
def toggle_hidden(game):
|
||||
import os, json
|
||||
games_dir = os.path.join(os.environ.get("XDG_DATA_HOME"), "games")
|
||||
games_dir = os.path.join(os.environ.get("XDG_DATA_HOME"), "cartridges", "games")
|
||||
|
||||
if os.path.exists(games_dir) == False:
|
||||
return
|
||||
|
||||
@@ -25,8 +25,8 @@ Adw.StatusPage hidden_notice_empty {
|
||||
valign: center;
|
||||
}
|
||||
|
||||
template GameShelfWindow : Adw.ApplicationWindow {
|
||||
title: _("Game Shelf");
|
||||
template CartridgesWindow : Adw.ApplicationWindow {
|
||||
title: _("Cartridges");
|
||||
default-width: 1110;
|
||||
default-height: 820;
|
||||
|
||||
@@ -348,7 +348,7 @@ menu primary_menu {
|
||||
}
|
||||
|
||||
item {
|
||||
label: _("About Game Shelf");
|
||||
label: _("About Cartridges");
|
||||
action: "app.about";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,9 +26,9 @@ from .get_cover import get_cover
|
||||
from .get_games import get_games
|
||||
from .save_games import save_games
|
||||
|
||||
@Gtk.Template(resource_path="/hu/kramo/GameShelf/window.ui")
|
||||
class GameShelfWindow(Adw.ApplicationWindow):
|
||||
__gtype_name__ = "GameShelfWindow"
|
||||
@Gtk.Template(resource_path="/hu/kramo/Cartridges/window.ui")
|
||||
class CartridgesWindow(Adw.ApplicationWindow):
|
||||
__gtype_name__ = "CartridgesWindow"
|
||||
|
||||
toast_overlay = Gtk.Template.Child()
|
||||
stack = Gtk.Template.Child()
|
||||
@@ -77,14 +77,14 @@ class GameShelfWindow(Adw.ApplicationWindow):
|
||||
self.overview.set_measure_overlay(self.overview_box, True)
|
||||
self.overview.set_clip_overlay(self.overview_box, False)
|
||||
|
||||
self.schema = Gio.Settings.new("hu.kramo.GameShelf")
|
||||
self.placeholder_pixbuf = GdkPixbuf.Pixbuf.new_from_resource_at_scale("/hu/kramo/GameShelf/assets/library_placeholder.svg", 200, 300, False)
|
||||
self.schema = Gio.Settings.new("hu.kramo.Cartridges")
|
||||
self.placeholder_pixbuf = GdkPixbuf.Pixbuf.new_from_resource_at_scale("/hu/kramo/Cartridges/assets/library_placeholder.svg", 200, 300, False)
|
||||
games = get_games()
|
||||
for game in games:
|
||||
if "removed" in games[game].keys():
|
||||
os.remove(os.path.join(os.environ.get("XDG_DATA_HOME"), "games", game + ".json"))
|
||||
os.remove(os.path.join(os.environ.get("XDG_DATA_HOME"), "cartridges", "games", game + ".json"))
|
||||
try:
|
||||
os.remove(os.path.join(os.environ.get("XDG_DATA_HOME"), "covers", game + ".dat"))
|
||||
os.remove(os.path.join(os.environ.get("XDG_DATA_HOME"), "cartridges", "covers", game + ".dat"))
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
@@ -374,7 +374,7 @@ class GameShelfWindow(Adw.ApplicationWindow):
|
||||
game_id = list(self.toasts)[-1]
|
||||
except IndexError:
|
||||
return
|
||||
open_file = open(os.path.join(os.path.join(os.environ.get("XDG_DATA_HOME"), "games", game_id + ".json")), "r")
|
||||
open_file = open(os.path.join(os.path.join(os.environ.get("XDG_DATA_HOME"), "cartridges", "games", game_id + ".json")), "r")
|
||||
data = json.loads(open_file.read())
|
||||
open_file.close()
|
||||
data.pop("removed")
|
||||
|
||||
Reference in New Issue
Block a user