diff --git a/sgbackup/game.py b/sgbackup/game.py index 409a806..6173053 100644 --- a/sgbackup/game.py +++ b/sgbackup/game.py @@ -927,7 +927,207 @@ class SteamMacOSGame(SteamGame): file_match, ignore_match) +class SteamPlatformData(GameData): + def __init__(self, + savegame_type:SavegameType, + savegame_root:str, + savegame_dir:str, + variables:dict|None=None, + file_match:str|None=None, + ignore_match:str|None=None, + installdir:str|None=None, + librarydir:str|None=None): + + if savegame_type not in (SavegameType.STEAM_WINDOWS, + SavegameType.STEAM_LINUX, + SavegameType.STEAM_MACOS): + raise TypeError("\"savegame_type\" is not valid!") + + GameData.__init__(self, + savegame_type=savegame_type, + savegame_root=savegame_root, + savegame_dir=savegame_dir, + variables=variables, + file_match=file_match, + ignore_match=ignore_match) + self.installdir = installdir + self.librarydir = librarydir + + @Property(type=str) + def installdir(self)->str: + return self.__installdir if self.__installdir else "" + @installdir.setter + def installdir(self,installdir:str|None): + self.__installdir = installdir + + + @Property(type=str) + def librarydir(self)->str: + return self.__librarydir if self.__librarydir else "" + + @librarydir.setter + def librarydir(self,steam_libdir:str|None): + self.__librarydir = steam_libdir + + def serialize(self)->dict: + data = super().serialize() + if self.__installdir: + data['installdir'] = self.__installdir + if self.__librarydir: + data['librarydir'] = self.__librarydir + + return data + +class SteamWindowsData(SteamPlatformData): + def __init__(self, + savegame_root:str, + savegame_dir:str, + variables:dict|None=None, + file_match:str|None=None, + ignore_match:str|None=None, + installdir:str|None=None, + librarydir:str|None=None): + SteamPlatformData.__init__(self, + savegame_type=SavegameType.STEAM_WINDOWS, + savegame_root=savegame_root, + savegame_dir=savegame_dir, + variables=variables, + file_match=file_match, + ignore_match=ignore_match, + installdir=installdir, + librarydir=librarydir) + +class SteamLinuxData(SteamPlatformData): + def __init__(self, + savegame_root:str, + savegame_dir:str, + variables:dict|None=None, + file_match:str|None=None, + ignore_match:str|None=None, + installdir:str|None=None, + librarydir:str|None=None): + SteamPlatformData.__init__(self, + savegame_type=SavegameType.STEAM_LINUX, + savegame_root=savegame_root, + savegame_dir=savegame_dir, + variables=variables, + file_match=file_match, + ignore_match=ignore_match, + installdir=installdir, + librarydir=librarydir) + +class SteamMacOSData(SteamPlatformData): + def __init__(self, + savegame_root:str, + savegame_dir:str, + variables:dict|None=None, + file_match:str|None=None, + ignore_match:str|None=None, + installdir:str|None=None, + librarydir:str|None=None): + SteamPlatformData.__init__(self, + savegame_type=SavegameType.STEAM_MACOS, + savegame_root=savegame_root, + savegame_dir=savegame_dir, + variables=variables, + file_match=file_match, + ignore_match=ignore_match, + installdir=installdir, + librarydir=librarydir) + +class SteamGameData(GObject): + def __init__(self,appid:int, + windows:SteamWindowsData|None=None, + linux:SteamLinuxData|None=None, + macos:SteamMacOSData|None=None): + GObject.__init__(self) + self.__appid = int(appid) + self.windows = windows + self.linux = linux + self.macos = macos + + @Property(type=int) + def appid(self)->int: + return self.__appid + + @appid.setter + def appid(self,appid:int): + return self.__appid + + @property + def windows(self)->SteamWindowsData|None: + return self.__windows_data + + @windows.setter + def windows(self,data:SteamWindowsData|None): + self.__windows_data = data + + @property + def linux(self)->SteamLinuxData|None: + return self.__linux_data + + @linux.setter + def linux(self,data:SteamLinuxData|None): + self.__linux_data = data + + @property + def macos(self)->SteamMacOSData|None: + return self.__macos_data + + @macos.setter + def macos(self,data:SteamMacOSData|None): + self.__macos_data = data + + @property + def windows_game(self)->SteamWindowsGame|None: + if self.windows: + return SteamWindowsGame(appid=self.appid, + savegame_root=self.windows.savegame_root, + savegame_dir=self.windows.savegame_dir, + variables=self.windows.variables, + installdir=self.windows.installdir, + file_match=self.windows.file_matchers, + ignore_match=self.windows.ignore_matchers) + return None + + @property + def linux_game(self)->SteamLinuxGame|None: + if self.linux: + return SteamLinuxGame(appid=self.appid, + savegame_root=self.windows.savegame_root, + savegame_dir=self.windows.savegame_dir, + variables=self.windows.variables, + installdir=self.windows.installdir, + file_match=self.windows.file_matchers, + ignore_match=self.windows.ignore_matchers) + return None + + @property + def macos_game(self)->SteamLinuxGame|None: + if self.macos: + return SteamMacOSGame(appid=self.appid, + savegame_root=self.windows.savegame_root, + savegame_dir=self.windows.savegame_dir, + variables=self.windows.variables, + installdir=self.windows.installdir, + file_match=self.windows.file_matchers, + ignore_match=self.windows.ignore_matchers) + return None + + def serialize(self)->dict: + data = { + 'appid': self.appid, + } + if self.windows: + data['windows'] = self.windows.serialize() + if self.linux: + data['linux'] = self.linux.serialize() + if self.macos: + data['macos'] = self.macos.serialize() + + return data + class Game(GObject): __gtype_name__ = "Game" @@ -968,18 +1168,50 @@ class Game(GObject): return (file_match,ignore_match) - def new_steam_game(conf,cls:SteamGame): - appid = conf['appid'] if 'appid' in conf else "" - sgroot = conf['savegame_root'] if 'savegame_root' in conf else "" - sgdir = conf['savegame_dir'] if 'savegame_dir' in conf else "" - vars = conf['variables'] if 'variables' in conf else {} - installdir = conf['installdir'] if 'installdir' in conf else "" - file_match,ignore_match = get_file_match(conf) + def new_steamdata(conf)->SteamGameData|None: + def new_steam_platform_data(data:dict,cls:SteamPlatformData)->SteamPlatformData|None: + if not 'savegame_root' in data or not 'savegame_dir' in data: + return None - if appid is not None and sgroot and sgdir: - cls(appid,sgroot,sgdir,vars,installdir,file_match,ignore_match) - return cls(appid,sgroot,sgdir,vars,installdir,file_match,ignore_match) - # new_steam_game() + file_match,ignore_match = get_file_match(data) + return cls( + savegame_root=data['savegame_root'], + savegame_dir=data['savegame_dir'], + variables=dict(((v['name'],v['value']) for v in data['variables'])) if ('variables' in data and config['variables']) else None, + file_match=file_match, + ignore_match=ignore_match, + installdir=data['installdir'] if ('installdir' in data and data['installdir']) else None, + librarydir=data['librarydir'] if ('librarydir' in data and data['librarydir']) else None + ) + + if ('steam' not in conf or not 'appid' in conf['steam']): + return None + + steam=conf['steam'] + + if 'windows' in steam: + windows = new_steam_platform_data(steam['windows'],SteamWindowsData) + else: + windows = None + + if 'linux' in steam: + linux = new_steam_platform_data(steam['linux'],SteamLinuxData) + else: + linux = None + + if 'macos' in steam: + macos = new_steam_platform_data(steam['macos'],SteamMacOSData) + else: + macos = None + + if windows is None and linux is None and macos is None: + return None + + return SteamGameData(steam['appid'], + windows=windows, + linux=linux, + macos=macos) + # new_steamdata() if not 'key' in config or not 'name' in config: return None @@ -1034,12 +1266,7 @@ class Game(GObject): file_match,ignore_match = get_file_match(macconf) game.macos = MacOSGame(sgroot,sgdir,vars,binary,file_match,ignore_match) - if 'steam_windows' in config: - game.steam_windows = new_steam_game(config['steam_windows'],SteamWindowsGame) - if 'steam_linux' in config: - game.steam_linux = new_steam_game(config['steam_linux'],SteamLinuxGame) - if 'steam_macos' in config: - game.steam_macos = new_steam_game(config['steam_macos'],SteamMacOSGame) + game.steam = new_steamdata(config) return game @@ -1070,6 +1297,9 @@ class Game(GObject): self.__windows = None self.__linux = None self.__macos = None + self.__steam = None + self.__epic = None + self.__gog = None self.__steam_windows = None self.__steam_linux = None self.__steam_macos = None @@ -1175,11 +1405,11 @@ class Game(GObject): elif (sgtype == SavegameType.MACOS): return self.macos elif (sgtype == SavegameType.STEAM_WINDOWS): - return self.steam_windows + return self.steam.windows_game elif (sgtype == SavegameType.STEAM_LINUX): - return self.steam_linux + return self.steam.linux_game elif (sgtype == SavegameType.STEAM_MACOS): - return self.steam_macos + return self.steam.macos_game elif (sgtype == SavegameType.GOG_WINDOWS): return self.__gog_windows elif (sgtype == SavegameType.GOG_LINUX): @@ -1226,41 +1456,39 @@ class Game(GObject): raise TypeError("MacOSGame") self.__macos = data + @Property + def steam(self)->SteamGameData|None: + return self.__steam + + @steam.setter + def steam(self,steam_data:SteamGameData|None): + if (not steam_data): + self.__steam = steam_data + return + + if (not isinstance(steam_data,SteamGameData)): + raise TypeError("\"steam\" is not \"None\" or a \"SteamGameData\" instance!") + + self.__steam = steam_data + @Property def steam_windows(self)->SteamWindowsGame|None: - return self.__steam_windows - @steam_windows.setter - def steam_windows(self,data:SteamWindowsGame|None): - if not data: - self.__steam_windows = None - else: - if not isinstance(data,SteamWindowsGame): - raise TypeError("SteamWindowsGame") - self.__steam_windows = data - + if self.steam: + return self.steam.windows_game + return None + @Property def steam_linux(self)->SteamLinuxGame|None: - return self.__steam_linux - @steam_linux.setter - def steam_linux(self,data:SteamLinuxGame|None): - if not data: - self.__steam_linux = None - else: - if not isinstance(data,SteamLinuxGame): - raise TypeError("SteamLinuxGame") - self.__steam_linux = data + if self.steam: + return self.steam.linux_game + return None + @Property def steam_macos(self)->SteamMacOSGame|None: - return self.__steam_macos - @steam_macos.setter - def steam_macos(self,data:SteamMacOSGame|None): - if not data: - self.__steam_macos = None - else: - if not isinstance(data,SteamMacOSGame): - raise TypeError("SteamMacOSGame") - self.__steam_macos = data + if self.steam: + return self.steam.macos_game + return None @Property def savegame_root(self)->str|None: @@ -1315,12 +1543,9 @@ class Game(GObject): ret['linux'] = self.linux.serialize() if (self.macos): ret['macos'] = self.macos.serialize() - if (self.steam_windows): - ret['steam_windows'] = self.steam_windows.serialize() - if (self.steam_linux): - ret['steam_linux'] = self.steam_linux.serialize() - if (self.steam_macos): - ret['steam_macos'] = self.steam_macos.serialize() + if (self.steam): + ret['steam'] = self.steam.serialize() + #if self.gog_windows: # ret['gog_windows'] = self.gog_windows.serialize() #if self.gog_linux: diff --git a/sgbackup/gui/_gamedialog.py b/sgbackup/gui/_gamedialog.py index a84c634..d51dfcc 100644 --- a/sgbackup/gui/_gamedialog.py +++ b/sgbackup/gui/_gamedialog.py @@ -33,6 +33,10 @@ from ..game import ( SteamLinuxGame, SteamWindowsGame, SteamMacOSGame, + SteamGameData, + SteamLinuxData, + SteamMacOSData, + SteamWindowsData, GameManager, ) @@ -355,9 +359,7 @@ class GameDialog(Gtk.Dialog): self.__windows = self.__create_windows_page() self.__linux = self.__create_linux_page() self.__macos = self.__create_macos_page() - self.__steam_windows = self.__create_steam_page('steam-windows','Steam Windows') - self.__steam_linux = self.__create_steam_page('steam-linux','Steam Linux') - self.__steam_macos = self.__create_steam_page('steam-macos','Steam MacOS') + self.__steam = self.__create_steam_page() for stack_page in self.__stack.get_pages(): @@ -615,51 +617,81 @@ class GameDialog(Gtk.Dialog): return page - def __create_steam_page(self,name,title): - page = Gtk.ScrolledWindow() - vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL,2) - self.__set_widget_margin(vbox,5) + def __create_steam_page(self): + def create_notebook_page(title,icon_name): + label_widget = Gtk.Box.new(Gtk.Orientation.HORIZONTAL,2) + label_icon = Gtk.Image.new_from_icon_name(icon_name) + label_icon.set_pixel_size(12) + label=Gtk.Label.new(title) + label_widget.append(label_icon) + label_widget.append(label) + + nbpage = Gtk.ScrolledWindow() + nbvbox = Gtk.Box.new(Gtk.Orientation.VERTICAL,5) + nbgrid = Gtk.Grid() + self.__set_widget_margin(nbgrid,5) + + label = Gtk.Label.new("Root directory:") + nbpage.sgroot_entry = Gtk.Entry() + nbpage.sgroot_entry.set_hexpand(True) + nbpage.sgroot_entry.connect('changed',lambda w: self._on_savegame_type_changed()) + nbgrid.attach(label,0,0,1,1) + nbgrid.attach(nbpage.sgroot_entry,1,0,1,1) + + label = Gtk.Label.new("Backup directory:") + nbpage.sgdir_entry = Gtk.Entry() + nbpage.sgdir_entry.set_hexpand(True) + nbpage.sgdir_entry.connect('changed',lambda w: self._on_savegame_type_changed()) + nbgrid.attach(label,0,1,1,1) + nbgrid.attach(nbpage.sgdir_entry,1,1,1,1) + + label = Gtk.Label.new("Installation directory:") + nbpage.installdir_entry = Gtk.Entry() + nbpage.installdir_entry.set_hexpand(True) + nbgrid.attach(label,0,3,1,1) + nbgrid.attach(nbpage.installdir_entry,1,3,1,1) + + nbvbox.append(nbgrid) + + nbpage.filematch = self.__create_filematch_widget('Match Files') + nbvbox.append(nbpage.filematch) + + nbpage.ignorematch = self.__create_filematch_widget('Ignore Files') + nbvbox.append(nbpage.ignorematch) + + nbpage.variables = self.__create_variables_widget() + nbvbox.append(nbpage.variables) + + nbpage.set_child(nbvbox) + return nbpage,label_widget + # create_notebook_page() + + page = Gtk.Box.new(Gtk.Orientation.VERTICAL,2) grid = Gtk.Grid() + self.__set_widget_margin(grid,5) label = Gtk.Label.new("App ID:") page.appid_entry = Gtk.Entry() page.appid_entry.set_hexpand(True) grid.attach(label,0,0,1,1) grid.attach(page.appid_entry,1,0,1,1) - - label = Gtk.Label.new("Root directory:") - page.sgroot_entry = Gtk.Entry() - page.sgroot_entry.set_hexpand(True) - page.sgroot_entry.connect('changed',lambda w: self._on_savegame_type_changed()) - grid.attach(label,0,1,1,1) - grid.attach(page.sgroot_entry,1,1,1,1) + page.append(grid) + + page.notebook = Gtk.Notebook() + page.notebook.set_hexpand(True) + page.notebook.set_vexpand(True) + page.windows,nb_label = create_notebook_page('Windows','windows-svgrepo-com-symbolic') + page.notebook.append_page(page.windows,nb_label) - label = Gtk.Label.new("Backup directory:") - page.sgdir_entry = Gtk.Entry() - page.sgdir_entry.set_hexpand(True) - page.sgdir_entry.connect('changed',lambda w: self._on_savegame_type_changed()) - grid.attach(label,0,2,1,1) - grid.attach(page.sgdir_entry,1,2,1,1) + page.linux,nb_label = create_notebook_page("Linux",'linux-svgrepo-com-symbolic') + page.notebook.append_page(page.linux,nb_label) - label = Gtk.Label.new("Installation directory:") - page.installdir_entry = Gtk.Entry() - page.installdir_entry.set_hexpand(True) - grid.attach(label,0,3,1,1) - grid.attach(page.installdir_entry,1,3,1,1) - vbox.append(grid) + page.macos,nb_label = create_notebook_page("Mac OS",'apple-svgrepo-com-symbolic') + page.notebook.append_page(page.macos,nb_label) - page.filematch = self.__create_filematch_widget('Match Files') - vbox.append(page.filematch) - - page.ignorematch = self.__create_filematch_widget('Ignore Files') - vbox.append(page.ignorematch) - - page.variables = self.__create_variables_widget() - vbox.append(page.variables) - - page.set_child(vbox) - self.__stack.add_titled(page,name,title) + page.append(page.notebook) + self.__stack.add_titled(page,'steam','Steam') stack_page = self.__stack.get_page(page) stack_page.set_icon_name("steam-svgrepo-com-symbolic") @@ -869,36 +901,31 @@ class GameDialog(Gtk.Dialog): set_game_widget_data(self.__macos,self.__game.macos if self.__game else None) self.__macos.binary_entry.set_text(self.__game.macos.binary if self.has_game and self.__game.macos else "") - #steam windows - set_game_widget_data(self.__steam_windows,self.__game.steam_windows if self.has_game else None) - self.__steam_windows.appid_entry.set_text(str(self.__game.steam_windows.appid) - if self.has_game and self.__game.steam_windows else "") - self.__steam_windows.installdir_entry.set_text(self.__game.steam_windows.installdir + #steam + set_game_widget_data(self.__steam.windows,self.__game.steam.windows if self.has_game and self.__game.steam else None) + set_game_widget_data(self.__steam.linux,self.__game.steam.linux if self.has_game and self.__game.steam else None) + set_game_widget_data(self.__steam.macos,self.__game.steam.macos if self.has_game and self.__game.steam else None) + + self.__steam.appid_entry.set_text(str(self.__game.steam.appid) + if self.has_game and self.__game.steam else "") + self.__steam.windows.installdir_entry.set_text(self.__game.steam.windows.installdir if self.has_game - and self.__game.steam_windows - and self.__game.steam_windows.installdir + and self.__game.steam + and self.__game.steam.windows + and self.__game.steam.windows.installdir else "") - - #steam linux - set_game_widget_data(self.__steam_linux,self.__game.steam_linux if self.has_game else None) - self.__steam_linux.appid_entry.set_text(str(self.__game.steam_linux.appid) - if self.has_game and self.__game.steam_linux else "") - self.__steam_linux.installdir_entry.set_text(self.__game.steam_linux.installdir + self.__steam.linux.installdir_entry.set_text(self.__game.steam.linux.installdir if self.has_game - and self.__game.steam_linux - and self.__game.steam_linux.installdir + and self.__game.steam + and self.__game.steam.linux + and self.__game.steam.linux.installdir else "") - - #steam macos - set_game_widget_data(self.__steam_macos,self.__game.steam_macos if self.has_game else None) - self.__steam_macos.appid_entry.set_text(str(self.__game.steam_macos.appid) - if self.has_game and self.__game.steam_macos else "") - self.__steam_macos.installdir_entry.set_text(self.__game.steam_macos.installdir + self.__steam.macos.installdir_entry.set_text(self.__game.steam.macos.installdir if self.has_game - and self.__game.steam_macos - and self.__game.steam_macos.installdir + and self.__game.steam + and self.__game.steam.macos + and self.__game.steam.macos.installdir else "") - # reset() def save(self): @@ -937,7 +964,6 @@ class GameDialog(Gtk.Dialog): def get_steam_data(widget): conf = get_game_data(widget) conf.update({ - 'appid': int(widget.appid_entry.get_text()), 'installdir': widget.installdir_entry.get_text(), }) return conf @@ -1048,72 +1074,77 @@ class GameDialog(Gtk.Dialog): elif self.__game.macos: self.__game.macos = None - if self.get_is_valid_savegame_type(SavegameType.STEAM_WINDOWS): - data = get_steam_data(self.__steam_windows) - if self.__game.steam_windows: - sg = self.__game.steam_windows - sg.savegame_root = data['sgroot'] - sg.savegame_dir = data['sgdir'] - sg.variables = data['variables'] - sg.file_matchers = data["filematch"] - sg.ignore_matchers = data['ignorematch'] - sg.appid = data['appid'] - sg.installdir = data['installdir'] + if (self.get_is_valid_savegame_type(SavegameType.STEAM_WINDOWS) + or self.get_is_valid_savegame_type(SavegameType.STEAM_LINUX) + or self.get_is_valid_savegame_type(SavegameType.STEAM_MACOS)): + + if self.__game.steam: + self.__game.steam.appid = int(self.__steam.appid_entry.get_text()) else: - self.__game.steam_windows = SteamWindowsGame(data['appid'], - data['sgroot'], - data['sgdir'], - data['variables'], - data['installdir'], - data['filematch'], - data['ignorematch']) - elif self.__steam_windows: - self.__steam_windows = None + self.__game.steam = SteamGameData(int(self.__steam.appid_entry.get_text())) - if self.get_is_valid_savegame_type(SavegameType.STEAM_LINUX): - data = get_steam_data(self.__steam_linux) - if self.__game.steam_linux: - sg = self.__game.steam_linux - sg.savegame_root = data['sgroot'] - sg.savegame_dir = data['sgdir'] - sg.variables = data['variables'] - sg.file_matchers = data["filematch"] - sg.ignore_matchers = data['ignorematch'] - sg.appid = data['appid'] - sg.installdir = data['installdir'] - else: - self.__game.steam_linux = SteamLinuxGame(data['appid'], - data['sgroot'], - data['sgdir'], - data['variables'], - data['installdir'], - data['filematch'], - data['ignorematch']) - elif self.__steam_linux: - self.__steam_linux = None - if self.get_is_valid_savegame_type(SavegameType.STEAM_MACOS): - data = get_steam_data(self.__steam_macos) - if self.__game.steam_macos: - sg = self.__game.steam_macos - sg.savegame_root = data['sgroot'] - sg.savegame_dir = data['sgdir'] - sg.variables = data['variables'] - sg.file_matchers = data["filematch"] - sg.ignore_matchers = data['ignorematch'] - sg.appid = data['appid'] - sg.installdir = data['installdir'] - else: - self.__game.steam_macos = SteamMacOSGame(data['appid'], - data['sgroot'], - data['sgdir'], - data['variables'], - data['installdir'], - data['filematch'], - data['ignorematch']) - elif self.__steam_macos: - self.__steam_macos = None + if self.get_is_valid_savegame_type(SavegameType.STEAM_WINDOWS): + data = get_steam_data(self.__steam.windows) + if self.__game.steam.windows: + g = self.__game.steam.windows + g.savegame_root = data['sgroot'] + g.savegame_dir = data['sgdir'] + g.variables = data['variables'] + g.file_matchers = data["filematch"] + g.ignore_matchers = data['ignorematch'] + g.installdir = data['installdir'] + else: + self.__game.steam.windows = SteamWindowsData(savegame_root=data['sgroot'], + savegame_dir=data['sgdir'], + variables=data['variables'], + installdir=data['installdir'], + file_match=data['filematch'], + ignore_match=data['ignorematch']) + elif self.__game.steam.windows: + self.__game.steam.windows = None + + if self.get_is_valid_savegame_type(SavegameType.STEAM_LINUX): + data = get_steam_data(self.__steam.linux) + if self.__game.steam_linux: + g = self.__game.steam.linux + g.savegame_root = data['sgroot'] + g.savegame_dir = data['sgdir'] + g.variables = data['variables'] + g.file_matchers = data["filematch"] + g.ignore_matchers = data['ignorematch'] + g.installdir = data['installdir'] + else: + self.__game.steam_linux = SteamLinuxData(savegame_root=data['sgroot'], + savegame_dir=data['sgdir'], + variables=data['variables'], + installdir=data['installdir'], + file_match=data['filematch'], + ignore_match=data['ignorematch']) + elif self.__game.steam.linux: + self.__game.steam.linux = None + if self.get_is_valid_savegame_type(SavegameType.STEAM_MACOS): + data = get_steam_data(self.__steam_macos) + if self.__game.steam_macos: + g = self.__game.steam_macos + g.savegame_root = data['sgroot'] + g.savegame_dir = data['sgdir'] + g.variables = data['variables'] + g.file_matchers = data["filematch"] + g.ignore_matchers = data['ignorematch'] + g.installdir = data['installdir'] + else: + self.__game.steam_macos = SteamMacOSData(savegame_root=data['sgroot'], + savegame_dir=data['sgdir'], + variables=data['variables'], + installdir=data['installdir'], + file_match=data['filematch'], + ignore_match=data['ignorematch']) + elif self.__game.steam.macos: + self.__game.steam.macos = None + # bEND: steam + self.__game.save() GameManager.get_global().add_game(self.__game) @@ -1141,7 +1172,8 @@ class GameDialog(Gtk.Dialog): """ def check_is_valid(widget): - return (bool(widget.sgroot_entry.get_text()) and bool(widget.sgdir_entry.get_text())) + return (len(widget.sgroot_entry.get_text().strip()) > 0 + and len(widget.sgdir_entry.get_text().strip()) > 0) if sgtype == SavegameType.WINDOWS: return check_is_valid(self.__windows) @@ -1150,11 +1182,11 @@ class GameDialog(Gtk.Dialog): elif sgtype == SavegameType.MACOS: return check_is_valid(self.__macos) elif sgtype == SavegameType.STEAM_WINDOWS: - return check_is_valid(self.__steam_windows) + return check_is_valid(self.__steam.windows) elif sgtype == SavegameType.STEAM_LINUX: - return check_is_valid(self.__steam_linux) + return check_is_valid(self.__steam.linux) elif sgtype == SavegameType.STEAM_MACOS: - return check_is_valid(self.__steam_macos) + return check_is_valid(self.__steam.macos) #elif sgtype == SavegameType.EPIC_WINDOWS: # return check_is_valid(self.__epic_windows) #elif sgtype == SavegameType.EPIC_LINUX: @@ -1247,8 +1279,6 @@ class GameDialog(Gtk.Dialog): if not label.get_text(): label.grab_focus() label.start_editing() - - def _on_windows_regkey_setup(self,factory,item): label = Gtk.EditableLabel() diff --git a/sgbackup/gui/_steam.py b/sgbackup/gui/_steam.py index 6aad503..dd271d7 100644 --- a/sgbackup/gui/_steam.py +++ b/sgbackup/gui/_steam.py @@ -249,20 +249,6 @@ class NewSteamAppsDialog(Gtk.Dialog): grid.set_hexpand(True) grid.set_column_spacing(5) - vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL,2) - - icon = Gtk.Image.new_from_icon_name('list-add-symbolic') - grid.add_app_button = Gtk.Button() - grid.add_app_button.set_child(icon) - vbox.append(grid.add_app_button) - - icon = Gtk.Image.new_from_icon_name('edit-delete-symbolic') - grid.ignore_app_button = Gtk.Button() - grid.ignore_app_button.set_child(icon) - vbox.append(grid.ignore_app_button) - - grid.attach(vbox,3,0,1,3) - #label = Gtk.Label.new("Name:") #label.set_xalign(0.0) grid.name_label = Gtk.Label() @@ -287,8 +273,43 @@ class NewSteamAppsDialog(Gtk.Dialog): grid.attach(label,0,2,1,1) grid.attach(grid.installdir_label,1,2,1,1) - item.set_child(grid) + # Buttons + button_grid = Gtk.Grid() + button_grid.set_column_spacing(2) + button_grid.set_row_spacing(2) + + icon = Gtk.Image.new_from_icon_name('list-add-symbolic') + icon.set_pixel_size(16) + grid.add_app_button = Gtk.Button() + grid.add_app_button.set_child(icon) + grid.add_app_button.set_tooltip_markup('Add SteamApp as new Game.') + button_grid.attach(grid.add_app_button,0,0,1,1) + + icon = Gtk.Image.new_from_icon_name('edit-delete-symbolic') + icon.set_pixel_size(16) + grid.ignore_app_button = Gtk.Button() + grid.ignore_app_button.set_child(icon) + grid.ignore_app_button.set_tooltip_text('Add SteamApp to ignore list.') + button_grid.attach(grid.ignore_app_button,1,0,1,1) + icon = Gtk.Image.new_from_icon_name('edit-find-symbolic') + icon.set_pixel_size(16) + grid.lookup_button = Gtk.Button() + grid.lookup_button.set_child(icon) + grid.lookup_button.set_tooltip_text("Lookup SteamApp for already registered game.") + button_grid.attach(grid.lookup_button,0,1,1,1) + + icon = Gtk.Image.new_from_icon_name('folder-download-symbolic') + icon.set_pixel_size(16) + grid.search_online_button = Gtk.Button() + grid.search_online_button.set_child(icon) + grid.search_online_button.set_tooltip_text("Lookup SteamApp online.") + button_grid.attach(grid.search_online_button,1,1,1,1) + + grid.attach(button_grid,3,0,1,3) + + item.set_child(grid) + def _on_listitem_bind(self,factory,item): child = item.get_child() data = item.get_item() @@ -310,6 +331,15 @@ class NewSteamAppsDialog(Gtk.Dialog): child.ignore_app_button.disconnect(child.ignore_app_button._signal_clicked_connector) child.ignore_app_button._signal_clicked_connector = child.ignore_app_button.connect('clicked',self._on_ignore_steamapp_button_clicked,data) + if hasattr(child.lookup_button,'_signal_clicked_connector'): + child.lookup_button.disconnect(child.lookup_button._signal_clicked_connector) + #child.lookup_button._signal_clicked_connector = child.lookup_button.connect('clicked',self._on_lookup_steamapp_button_clicked,data) + child.lookup_button.set_sensitive(False) + + if hasattr(child.search_online_button,'_signal_clicked_connector'): + child.search_online_button.disconnect(child.search_online_button._signal_clicked_connector) + #child.search_button._signal_clicked_connector = child.search_online_button.connect('clicked',self._on_lookup_steamapp_button_clicked,data) + child.search_online_button.set_sensitive(False) def _on_add_steamapp_button_clicked(self,button,data:SteamApp,*args): def on_dialog_response(dialog,response): diff --git a/sgbackup/settings.py b/sgbackup/settings.py index 1371830..3987fa5 100644 --- a/sgbackup/settings.py +++ b/sgbackup/settings.py @@ -447,7 +447,7 @@ class Settings(GObject.GObject): self.set_string('cli','pager',value) else: self.remove_key('cli','pager') - + def add_variable(self,name:str,value:str): self.set_string('variables',name,value) @@ -470,6 +470,15 @@ class Settings(GObject.GObject): "CONFIGDIR": GLib.get_user_config_dir(), "CONFIG_DIR": GLib.get_user_config_dir(), "STEAM_INSTALLPATH": self.steam_installpath, + "DESKTOP_DIR": GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DESKTOP), + "XDG_CONFIG_HOME": GLib.get_user_config_dir(), + "XDG_DESKTOP_DIR": GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DESKTOP), + "XDG_DOCUMENTS_DIR": GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DOCUMENTS), + "DOWNLOADS": GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DOWNLOAD), + "XDG_DOWLNLOAD_DIR": GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DOWNLOAD), + "XDG_PICTURES_DIR": GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES), + "XDG_MUSIC_DIR": GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_MUSIC), + "XDG_DATA_DIR": GLib.get_user_data_dir(), }) ret.update(self.variables) return ret