diff --git a/Icon.png b/Icon.png deleted file mode 100644 index 3f22023..0000000 Binary files a/Icon.png and /dev/null differ diff --git a/com.vysp3r.ProtonPlus.json b/com.vysp3r.ProtonPlus.json index 1c8d950..67e99eb 100644 --- a/com.vysp3r.ProtonPlus.json +++ b/com.vysp3r.ProtonPlus.json @@ -10,7 +10,15 @@ "--socket=fallback-x11", "--device=dri", "--socket=wayland", - "--filesystem=home", + "--filesystem=~/.var/app/com.valvesoftware.Steam/data/Steam/compatibilitytools.d", + "--filesystem=~/.steam/root/compatibilitytools.d", + "--filesystem=~/.local/share/Steam/compatibilitytools.d", + "--filesystem=~/.var/app/net.lutris.Lutris/data/lutris/", + "--filesystem=~/.local/share/lutris/", + "--filesystem=~/.var/app/com.heroicgameslauncher.hgl/config/heroic/tools/", + "--filesystem=~/.config/heroic/tools", + "--filesystem=~/.var/app/com.usebottles.bottles/data/bottles/runners", + "--filesystem=~/.local/share/bottles/runners", "--talk-name=org.gtk.vfs.*", "--filesystem=xdg-run/gvfsd" ], @@ -18,7 +26,6 @@ { "name" : "ProtonPlus", "builddir" : true, - "only-arches": ["x86_64"], "buildsystem" : "meson" } ] diff --git a/data/com.vysp3r.ProtonPlus.appdata.xml.in b/data/com.vysp3r.ProtonPlus.appdata.xml.in index 075246d..ca0124d 100644 --- a/data/com.vysp3r.ProtonPlus.appdata.xml.in +++ b/data/com.vysp3r.ProtonPlus.appdata.xml.in @@ -12,6 +12,11 @@

ProtonPlus a simple Wine and Proton-based compatiblity tools manager for GNOME. It works with Steam, Lutris, Heroic Games Launcher and Bottles. It was made in Vala with GTK4 and Libadwaita using GNOME Builder.

+ https://github.com/Vysp3r/ProtonPlus + https://github.com/Vysp3r/ProtonPlus/issues + + com.vysp3r.ProtonPlus.desktop + https://raw.githubusercontent.com/Vysp3r/ProtonPlus/main/Preview-1.png @@ -21,15 +26,106 @@ - https://github.com/Vysp3r/ProtonPlus - https://github.com/Vysp3r/ProtonPlus/issues - - com.vysp3r.ProtonPlus.desktop - - - - - + + +

For stability reasons, I've decided to disable Bottles and Heroic Games Launcher support for now. I also disabled Proton Tkg for the same reasons.

+

What's Changed:

+
    +
  • ✨ Add NorthstarProton compatibility tool
  • +
  • 🐛 Fix NorthstarProton not showing up
  • +
  • 🔨 Update flatpak config
  • +
  • 💬 Renamed tools in a uniform way
  • +
  • 🧑‍💻 Project refactor
  • +
  • 🚸 Add error message to selector
  • +
  • 🔨 Update appdata
  • +
  • 💬 Update the release notes
  • +
+
+
+ + +

We are now officialy on Flathub!

+

What's Changed:

+
    +
  • 🔨 Update appdata
  • +
  • 🔨 Update flatpak config
  • +
  • 🍱 Update symbolic icon
  • +
  • 🍱 Add icon
  • +
  • 🔨 Update .desktop
  • +
  • 🍱 Update the preview image
  • +
  • 🍱 Add a preview image
  • +
  • 🐛 Fix install button always being clickable
  • +
  • 💬 Update the release notes
  • +
+
+
+ + +

The new naming convention for extracted directories is basically making sure each installed tools is easily recognizable to make it easier to manage them.

+

Naming convention: Tool name + Tool version

+

Example: GE-Proton | GE-Proton7-41

+

What's Changed:

+
    +
  • ✏️ Fix typo in the release notes
  • +
  • 🍱 Update the preview image
  • +
  • ⚰️ Remove unused custom widget
  • +
  • 🚧 Add notifications tab
  • +
  • 💄 Update selector window components to Libadwaita
  • +
  • 🧱 Separate Release from CompatibilityTool
  • +
  • 🧱 Rename CompatibilityTool to Tool
  • +
  • ⚰️ Remove unused file
  • +
  • 💄 Update home message dialog to libadwaita
  • +
  • ⚰️ Remove unused custom widget
  • +
  • ✨ Added a naming convention extracted directories
  • +
  • 🚚 Rename compatibilitytool to tool
  • +
  • 💬 Update the release notes
  • +
+
+
+ + +

ProtonPlus now requires Libadwaita version 1.2 or higher.

+

What's Changed:

+
    +
  • 📝 Update README.md
  • +
  • 🐛 Fix Preferences window default siz
  • +
  • 💄 Move main window to Libadwaita
  • +
  • 💄 Move about window to Libadwaita
  • +
  • ⚰️ Remove dead code
  • +
  • 💄 Update main window components to Libadwaita
  • +
  • ⚰️ Remove dead code
  • +
  • 💄 Add an effect when extracting a tool
  • +
  • 🐛 Fix label not showing up
  • +
  • 🐛 Fix wrong label showing up
  • +
  • 💄 Update preferences window to Libadwaita
  • +
  • ⬆️ Update the runtime version
  • +
  • 💬 Update the release notes
  • +
+
+
+ + +

What's Changed:

+
    +
  • 🐛 Fix Steam not showing up on fresh install
  • +
  • 🐛 Fix Kron4ek Wine-Builds Vanilla not showing properly
  • +
  • 🐛 Fix installed tools showing files
  • +
  • 🐛 Fix selector closing after an installation
  • +
  • 🐛 Fix extraction not always working
  • +
  • 📝 Update README.md
  • +
  • 🐛 Fix Lutris DXVK not showing up
  • +
+
+
+ + +

What's Changed:

+
    +
  • 🎉 Initial release
  • +
  • 📝 Create pull request template
  • +
+
+
diff --git a/meson.build b/meson.build index 9aa58a4..7f169e3 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('protonplus', ['c', 'vala'], - version: '0.1.0', + version: '0.2.0', meson_version: '>= 0.59.0', default_options: [ 'warning_level=2', 'werror=false', diff --git a/src/app.css b/src/app.css index 23755f8..23be5bf 100644 --- a/src/app.css +++ b/src/app.css @@ -1,3 +1,3 @@ .bold { font-weight: bold; -} +} \ No newline at end of file diff --git a/src/application.vala b/src/application.vala index 03cd0bd..dd30ff8 100644 --- a/src/application.vala +++ b/src/application.vala @@ -1,5 +1,7 @@ namespace ProtonPlus { public class Application : Adw.Application { + Stores.Preferences preferences; + public Application () { Object (application_id: "com.vysp3r.ProtonPlus", flags : ApplicationFlags.FLAGS_NONE); } @@ -19,13 +21,18 @@ namespace ProtonPlus { public override void activate () { base.activate (); - new Windows.Home (this); + preferences = new Stores.Preferences (); + if (Manager.Preferences.Load (ref preferences)) { + Manager.Preferences.Apply (ref preferences); + Manager.Themes.Load (); - Manager.Preferences.Load (); - Manager.Themes.Load (); + new Windows.Home (this); + } else { + stderr.printf ("There was an error loading the preferences and it will prevent the application from opening.\n"); + } } - private void on_about_action () { + void on_about_action () { string[] devs = { "Charles Malouin (Vysp3r) https://github.com/Vysp3r" }; string[] designers = { "Charles Malouin (Vysp3r) https://github.com/Vysp3r" }; string[] thanks = { @@ -39,10 +46,16 @@ namespace ProtonPlus { aboutDialog.set_application_name ("ProtonPlus"); aboutDialog.set_application_icon ("com.vysp3r.ProtonPlus"); - aboutDialog.set_version ("v0.1.9"); + aboutDialog.set_version ("v0.2.0"); aboutDialog.set_comments ("A simple Wine and Proton-based compatiblity tools manager for GNOME"); aboutDialog.add_link ("Github", "https://github.com/Vysp3r/ProtonPlus"); aboutDialog.set_release_notes (""); @@ -56,8 +69,8 @@ namespace ProtonPlus { aboutDialog.show (); } - private void on_preferences_action () { - new ProtonPlus.Windows.Preferences (); + void on_preferences_action () { + new ProtonPlus.Windows.Preferences (ref preferences); } } } diff --git a/src/main.vala b/src/main.vala index 816823f..7417a08 100644 --- a/src/main.vala +++ b/src/main.vala @@ -6,4 +6,4 @@ int main (string[] args) { var app = new ProtonPlus.Application (); return app.run (args); -} \ No newline at end of file +} diff --git a/src/manager/file.vala b/src/manager/file.vala index cc164c9..dba312e 100644 --- a/src/manager/file.vala +++ b/src/manager/file.vala @@ -1,6 +1,8 @@ namespace ProtonPlus.Manager { public class File { - public static void Extract (string install_location, string launcher_name, string tool_name) { + public static string Extract (string install_location, string tool_name) { // RENAME launcher_name and tool_name correctly see line 117 in selector + const int bufferSize = 192000; + Archive.Read archive = new Archive.Read (); archive.support_format_all (); archive.support_filter_all (); @@ -15,46 +17,44 @@ namespace ProtonPlus.Manager { ext.set_standard_lookup (); ext.set_options (flags); - if (archive.open_filename (install_location + tool_name + ".tar.gz", 1920000) != Archive.Result.OK) return; + if (archive.open_filename (install_location + tool_name + ".tar.gz", bufferSize) != Archive.Result.OK) return ""; ssize_t r; unowned Archive.Entry entry; - int bob = 0; - string test = ""; + string sourcePath = ""; + bool firstRun = true; for ( ;; ) { r = archive.next_header (out entry); if (r == Archive.Result.EOF) break; - if (r < Archive.Result.WARN) break; - entry.set_pathname (install_location + entry.pathname ()); - if(bob++ == 0){ - test = entry.pathname (); + if (r < Archive.Result.OK) stderr.printf (ext.error_string ()); + if (r < Archive.Result.WARN) return ""; + if (firstRun) { + sourcePath = entry.pathname (); + firstRun = false; } + entry.set_pathname (install_location + entry.pathname ()); r = ext.write_header (entry); - if (entry.size () > 0) { + if (r < Archive.Result.OK) stderr.printf (ext.error_string ()); + else if (entry.size () > 0) { r = copy_data (archive, ext); - if (r < Archive.Result.WARN) break; + if (r < Archive.Result.WARN) return ""; } r = ext.finish_entry (); - if (r < Archive.Result.WARN) break; + if (r < Archive.Result.OK) stderr.printf (ext.error_string ()); + if (r < Archive.Result.WARN) return ""; } archive.close (); - GLib.File file = GLib.File.new_for_path (install_location + tool_name + ".tar.gz"); - file.delete (); - - GLib.File fileSource = GLib.File.new_for_path (test); - GLib.File fileDest = GLib.File.new_for_path (install_location + launcher_name + " | " + tool_name); - fileSource.move(fileDest, FileCopyFlags.NONE, null, null); + Delete (install_location + tool_name + ".tar.gz"); - ProtonPlus.Stores.Threads store = ProtonPlus.Stores.Threads.instance (); - store.ProgressBarDone = true; + return install_location + sourcePath; } - private static ssize_t copy_data (Archive.Read ar, Archive.WriteDisk aw) { + static ssize_t copy_data (Archive.Read ar, Archive.WriteDisk aw) { ssize_t r; uint8[] buffer; Archive.int64_t offset; @@ -64,7 +64,39 @@ namespace ProtonPlus.Manager { if (r == Archive.Result.EOF) return (Archive.Result.OK); if (r < Archive.Result.OK) return (r); r = aw.write_data_block (buffer, offset); - if (r < Archive.Result.OK) return (r); + if (r < Archive.Result.OK) { + stderr.printf (aw.error_string ()); + return (r); + } + } + } + + public static void Delete (string sourcePath) { + try { + GLib.File file = GLib.File.new_for_path (sourcePath); + file.delete (); + } catch (GLib.Error e) { + stderr.printf (e.message); + } + } + + public static void Rename (string sourcePath, string destinationPath) { + try { + GLib.File fileSource = GLib.File.new_for_path (sourcePath); + GLib.File fileDest = GLib.File.new_for_path (destinationPath); + fileSource.move (fileDest, FileCopyFlags.NONE, null, null); + } catch (GLib.Error e) { + stderr.printf (e.message); + } + } + + public static void Write (string sourcePath, string content) { + try { + GLib.File file = GLib.File.new_for_path (GLib.Environment.get_user_config_dir () + "/preferences.json"); + FileOutputStream os = file.create (FileCreateFlags.PRIVATE); + os.write (content.data); + } catch (GLib.Error e) { + stderr.printf (e.message); } } } diff --git a/src/manager/http.vala b/src/manager/http.vala index 13ba2b1..3e83ed1 100644 --- a/src/manager/http.vala +++ b/src/manager/http.vala @@ -1,23 +1,29 @@ namespace ProtonPlus.Manager { public class HTTP { public static string GET (string url) { - var session = new Soup.Session (); - var message = new Soup.Message ("GET", url); - session.set_user_agent ("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246"); - Bytes bytes = session.send_and_read (message); - return (string) bytes.get_data (); + try { + var session = new Soup.Session (); + var message = new Soup.Message ("GET", url); + session.set_user_agent ("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246"); + Bytes bytes = session.send_and_read (message); + return (string) bytes.get_data (); + } catch (GLib.Error e) { + stderr.printf (e.message); + return ""; + } } public static int Download (string download_url, string download_path) { try { var file_from_http = GLib.File.new_for_uri (download_url); GLib.File local_file = GLib.File.new_for_path (download_path); - ProtonPlus.Stores.Threads store = ProtonPlus.Stores.Threads.instance (); + Stores.Threads store = Stores.Threads.instance (); file_from_http.copy (local_file, FileCopyFlags.OVERWRITE, null, (current, total) => { store.ProgressBar = (current + 0.0d) / (total + 0.0d); }); return 0; - } catch (Error e) { + } catch (GLib.Error e) { + stderr.printf (e.message); return 1; } } diff --git a/src/manager/preferences.vala b/src/manager/preferences.vala index c3f34a2..0e814cf 100644 --- a/src/manager/preferences.vala +++ b/src/manager/preferences.vala @@ -1,43 +1,41 @@ namespace ProtonPlus.Manager { public class Preferences { - public static void Load() { - ProtonPlus.Stores.Preferences store = ProtonPlus.Stores.Preferences.instance(); + public static bool Load (ref Stores.Preferences preferences) { try { - GLib.File file = GLib.File.new_for_path(GLib.Environment.get_user_config_dir() + "/preferences.json"); + GLib.File file = GLib.File.new_for_path (GLib.Environment.get_user_config_dir () + "/preferences.json"); uint8[] contents; string etag_out; - file.load_contents(null, out contents, out etag_out); + file.load_contents (null, out contents, out etag_out); - Json.Node node = Json.from_string((string) contents); - Json.Object obj = node.get_object(); + Json.Node node = Json.from_string ((string) contents); + Json.Object obj = node.get_object (); - store.CurrentStyle = Models.Preference.FindStyle(obj.get_string_member("style")); + preferences.Style = Models.Preferences.Style.Find (obj.get_string_member ("style")); + + return true; } catch (GLib.IOError.NOT_FOUND e) { - Create(); - Load(); + stderr.printf (e.message); + Create (ref preferences, true); + return Load (ref preferences); + } catch (GLib.Error e) { + stderr.printf (e.message); + return false; } - Apply(); - } - - public static void Apply() { - ProtonPlus.Stores.Preferences store = ProtonPlus.Stores.Preferences.instance(); - Adw.StyleManager.get_default().set_color_scheme(store.CurrentStyle.ColorScheme); } - public static void Update() { - GLib.File file = GLib.File.new_for_path(GLib.Environment.get_user_config_dir() + "/preferences.json"); - file.delete (); - Create(); + public static void Apply (ref Stores.Preferences preferences) { + Adw.StyleManager.get_default ().set_color_scheme (preferences.Style.ColorScheme); } - private static void Create() { - GLib.File file = GLib.File.new_for_path(GLib.Environment.get_user_config_dir() + "/preferences.json"); - FileOutputStream os = file.create(FileCreateFlags.PRIVATE); + public static void Update (ref Stores.Preferences preferences) { + Manager.File.Delete (GLib.Environment.get_user_config_dir () + "/preferences.json"); - ProtonPlus.Stores.Preferences store = ProtonPlus.Stores.Preferences.instance(); + Create (ref preferences, false); + } - os.write(store.GetJson().data); + static void Create (ref Stores.Preferences preferences, bool useDefaultValue) { + Manager.File.Write (GLib.Environment.get_user_config_dir () + "/preferences.json", preferences.GetJson (useDefaultValue)); } } } diff --git a/src/manager/themes.vala b/src/manager/themes.vala index 4dfa358..6e851d1 100644 --- a/src/manager/themes.vala +++ b/src/manager/themes.vala @@ -8,4 +8,4 @@ namespace ProtonPlus.Manager { Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); } } -} \ No newline at end of file +} diff --git a/src/meson.build b/src/meson.build index 5fa2523..5d7567c 100644 --- a/src/meson.build +++ b/src/meson.build @@ -10,9 +10,8 @@ protonplus_sources = [ 'manager/http.vala', 'manager/file.vala', - 'models/preference.vala', + 'models/preferences/style.vala', 'models/tool.vala', - 'models/location.vala', 'models/launcher.vala', 'models/release.vala', diff --git a/src/models/launcher.vala b/src/models/launcher.vala index 427810d..a75880f 100644 --- a/src/models/launcher.vala +++ b/src/models/launcher.vala @@ -1,31 +1,204 @@ namespace ProtonPlus.Models { public class Launcher : Object { - public string Label { public get; private set; } + string homeDirectory; + string directory; - public Launcher (string label) { - this.Label = label; + public string Title; + public string Directory { + public owned get { return homeDirectory + directory; } + private set { directory = value; } } + public List Tools; + public string Scheme; + public bool Installed { + public get { return directory.length > 0; } + } + + public Launcher (string title, string[] directories, string toolDirectory, List tools, string scheme = "") { + homeDirectory = GLib.Environment.get_home_dir (); + + this.Title = title; + this.Directory = verifyDirectories (directories, toolDirectory); + this.Scheme = scheme; - public static Gtk.ListStore GetModel () { - Gtk.ListStore model = new Gtk.ListStore (2, typeof (string), typeof (Launcher)); - Gtk.TreeIter iter; + Tools = new List (); + tools.@foreach ((tool) => { + Tools.append (tool); + }); + } + + private string verifyDirectories (string[] directories, string toolDirectory) { + string dir = ""; - foreach (var item in All ()) { - model.append (out iter); - model.set (iter, 0, item.Label, 1, item, -1); + // Check if any of the given directories exists + foreach (var item in directories) { + if (Posix.opendir (homeDirectory + item) != null) { + dir = item + toolDirectory; + break; + } } - return model; + // If a directory exist, it makes sure that the tool directory is created + if (dir.length > 0) { + if (Posix.opendir (homeDirectory + dir) == null) { + Posix.mkdir (homeDirectory + dir, 0777); + } + } + + return dir; + } + + public static GLib.ListStore GetStore (GLib.List launchers) { + var store = new GLib.ListStore (typeof (Launcher)); + + launchers.@foreach ((launcher) => { + if (launcher.Installed == true) { + store.append (launcher); + } + }); + + return store; } - public static Launcher[] All () { - Launcher[] launchers = new Launcher[5]; + public static GLib.List GetAll () { + var launchers = new GLib.List (); + + // Steam + var steamToolDir = "/compatibilitytools.d"; + var steamTools = Models.Tool.Steam (); + + launchers.append (new Launcher ( + "Steam", + new string[] { + "/.local/share/Steam", + "/.steam/root", + "/.steam/steam", + "/.steam/debian-installation" + }, + steamToolDir, + steamTools + )); + launchers.append (new Launcher ( + "Steam (Flatpak)", + new string[] { + "/.var/app/com.valvesoftware.Steam/data/Steam" + }, + steamToolDir, + steamTools + )); + launchers.append (new Launcher ( + "Steam (Snap)", + new string[] { + "/snap/steam/common/.steam/root" + }, + steamToolDir, + steamTools + )); + + // Lutris + var lutrisToolDir = "/wine"; + var lutrisTools = Models.Tool.Lutris (); + + launchers.append (new Launcher ( + "Lutris", + new string[] { + "/.local/share/lutris/runners" + }, + lutrisToolDir, + lutrisTools + )); + launchers.append (new Launcher ( + "Lutris (Flatpak)", + new string[] { + "/.var/app/net.lutris.Lutris/data/lutris/runners" + }, + lutrisToolDir, + lutrisTools + )); + + // Lutris DXVK + var lutrisDxvkToolDir = "/dxvk"; + var lutrisDxvkTools = Models.Tool.LutrisDXVK (); + + launchers.append (new Launcher ( + "Lutris DXVK", + new string[] { + "/.local/share/lutris/runtime" + }, + lutrisDxvkToolDir, + lutrisDxvkTools + )); + launchers.append (new Launcher ( + "Lutris DXVK (Flatpak)", + new string[] { + "/.var/app/net.lutris.Lutris/data/lutris/runtime" + }, + lutrisDxvkToolDir, + lutrisDxvkTools + )); + + // Heroic Games Launcher (Proton) + // var heroicProtonToolDir = "/proton"; + // var heroicProtonTools = Models.Tool.HeroicProton (); + + // launchers.append(new Launcher ( + // "Heroic Proton", + // new string[] { + // "/.config/heroic/tools" + // }, + // heroicProtonToolDir, + // heroicProtonTools + // )); + // launchers.append(new Launcher ( + // "Heroic Proton (Flatpak)", + // new string[] { + // "/.var/app/com.heroicgameslauncher.hgl/config/heroic/tools" + // }, + // heroicProtonToolDir, + // heroicProtonTools + // )); + + // Heroic Games Launcher (Wine) + // var heroicWineToolDir = "/wine"; + // var heroicWineTools = Models.Tool.HeroicWine (); + + // launchers.append(new Launcher ( + // "Heroic Wine", + // new string[] { + // "/.config/heroic/tools" + // }, + // heroicWineToolDir, + // heroicWineTools + // )); + // launchers.append(new Launcher ( + // "Heroic Wine (Flatpak)", + // new string[] { + // "/.var/app/com.heroicgameslauncher.hgl/config/heroic/tools" + // }, + // heroicWineToolDir, + // heroicWineTools + // )); + + // Bottles + // var bottlesToolDir = "/runners"; + // var bottlesTools = Models.Tool.Bottles (); - launchers[0] = new Launcher ("Steam"); - launchers[1] = new Launcher ("Lutris"); - launchers[2] = new Launcher ("Heroic Wine"); - launchers[3] = new Launcher ("Heroic Proton"); - launchers[4] = new Launcher ("Bottles"); + // launchers.append (new Launcher ( + // "Bottles", + // new string[] { + // "/.local/share/bottles" + // }, + // bottlesToolDir, + // bottlesTools + // )); + // launchers.append (new Launcher ( + // "Bottles (Flatpak)", + // new string[] { + // "/.var/app/com.usebottles.bottles/data/bottles" + // }, + // bottlesToolDir, + // bottlesTools + // )); return launchers; } diff --git a/src/models/location.vala b/src/models/location.vala deleted file mode 100644 index 9773211..0000000 --- a/src/models/location.vala +++ /dev/null @@ -1,64 +0,0 @@ -namespace ProtonPlus.Models { - public class Location : Object { - public string Label { public get; private set; } - public string InstallDirectory { public get; private set; } - public ProtonPlus.Models.Tool[] Tools { public get; private set; } - public ProtonPlus.Models.Launcher Launcher { public get; private set; } - - public Location (string label, string install_directory, ProtonPlus.Models.Tool[] tools, ProtonPlus.Models.Launcher launcher) { - this.Label = label; - this.InstallDirectory = install_directory; - this.Tools = tools; - this.Launcher = launcher; - } - - public static GLib.ListStore GetStore () { - var store = new GLib.ListStore (typeof (ProtonPlus.Models.Location)); - - foreach (var location in GetInstallLocations ()) { - var dir = Posix.opendir (location.InstallDirectory); - - if (dir != null) { - store.append (location); - } - } - - return store; - } - - public static GLib.List GetInstallLocations () { - GLib.List locations = new GLib.List (); - - string home_dir = GLib.Environment.get_home_dir (); - - string[] steam_locations = new string[] { home_dir + "/.local/share/Steam", home_dir + "/.steam/root", home_dir + "/.steam/steam", home_dir + "/.steam/debian-installation" }; - string steam_dir = steam_locations[0]; - foreach (var item in steam_locations) { - if (Posix.opendir (item) != null) { - steam_dir = item + "/compatibilitytools.d"; - break; - } - } - - if (Posix.opendir (steam_dir) == null) { - Posix.mkdir (steam_dir, 0777); - } - - locations.append (new Location ("Steam", steam_dir, ProtonPlus.Models.Tool.Steam (), new ProtonPlus.Models.Launcher ("Steam"))); - locations.append (new Location ("Steam (Flatpak)", home_dir + "/.var/app/com.valvesoftware.Steam/data/Steam/compatibilitytools.d", ProtonPlus.Models.Tool.Steam (), new ProtonPlus.Models.Launcher ("Steam"))); - locations.append (new Location ("Steam (Snap)", home_dir + "/snap/steam/common/.steam/root/compatibilitytools.d", ProtonPlus.Models.Tool.Steam (), new ProtonPlus.Models.Launcher ("Steam"))); - locations.append (new Location ("Lutris", home_dir + "/.local/share/lutris/runners/wine", ProtonPlus.Models.Tool.Lutris (), new ProtonPlus.Models.Launcher ("Lutris"))); - locations.append (new Location ("Lutris (Flatpak)", home_dir + "/.var/app/net.lutris.Lutris/data/lutris/runners/wine", ProtonPlus.Models.Tool.Lutris (), new ProtonPlus.Models.Launcher ("Lutris"))); - locations.append (new Location ("Lutris DXVK", home_dir + "/.local/share/lutris/runtime/dxvk", ProtonPlus.Models.Tool.LutrisDXVK (), new ProtonPlus.Models.Launcher ("Lutris"))); - locations.append (new Location ("Lutris DXVK (Flatpak)", home_dir + "/.var/app/net.lutris.Lutris/data/lutris/runtime/dxvk", ProtonPlus.Models.Tool.LutrisDXVK (), new ProtonPlus.Models.Launcher ("Lutris"))); - locations.append (new Location ("Heroic Wine", home_dir + "/.config/heroic/tools/wine", ProtonPlus.Models.Tool.HeroicWine (), new ProtonPlus.Models.Launcher ("Heroic Wine"))); - locations.append (new Location ("Heroic Proton", home_dir + "/.config/heroic/tools/proton", ProtonPlus.Models.Tool.HeroicProton (), new ProtonPlus.Models.Launcher ("Heroic Proton"))); - locations.append (new Location ("Heroic Wine (Flatpak)", home_dir + "/.var/app/com.heroicgameslauncher.hgl/config/heroic/tools/wine", ProtonPlus.Models.Tool.HeroicWine (), new ProtonPlus.Models.Launcher ("Heroic Wine"))); - locations.append (new Location ("Heroic Proton (Flatpak)", home_dir + "/.var/app/com.heroicgameslauncher.hgl/config/heroic/tools/proton", ProtonPlus.Models.Tool.HeroicProton (), new ProtonPlus.Models.Launcher ("Heroic Proton"))); - locations.append (new Location ("Bottles", home_dir + "/.local/share/bottles/runners", ProtonPlus.Models.Tool.Bottles (), new ProtonPlus.Models.Launcher ("Bottles"))); - locations.append (new Location ("Bottles (Flatpak)", home_dir + "/.var/app/com.usebottles.bottles/data/bottles/runners", ProtonPlus.Models.Tool.Bottles (), new ProtonPlus.Models.Launcher ("Bottles"))); - - return locations; - } - } -} diff --git a/src/models/preference.vala b/src/models/preference.vala deleted file mode 100644 index 4ee50f9..0000000 --- a/src/models/preference.vala +++ /dev/null @@ -1,59 +0,0 @@ -namespace ProtonPlus.Models { - public class Preference: Object { - - public string Title { public get; private set; } - public T[] ObjectList { public get; private set; } - - public Preference (string title, T[] object_list) { - this.Title = title; - this.ObjectList = object_list; - } - - public static Style[] GetStyles () { - Style[] styles = new Style[3]; - styles[0] = new Style ("System", Adw.ColorScheme.DEFAULT, 0); - styles[1] = new Style ("Light", Adw.ColorScheme.FORCE_LIGHT, 1); - styles[2] = new Style ("Dark", Adw.ColorScheme.FORCE_DARK, 2); - return styles; - } - - public static Style FindStyle (string label) { - switch (label) { - case "Light": - return Preference.GetStyles ()[1]; - case "Dark": - return Preference.GetStyles ()[2]; - default: - return Preference.GetStyles ()[0]; - } - } - - public static GLib.ListStore GetStyleStore () { - var model = new GLib.ListStore (typeof (ProtonPlus.Models.Preference.Style)); - - foreach (var style in GetStyles ()) { - model.append (style); - } - - return model; - } - - public class Style : Object { - public string Label { public get; private set; } - public Adw.ColorScheme ColorScheme { public get; private set; } - public int Position { public get; private set; } - - public Style (string label, Adw.ColorScheme color_scheme, int position) { - this.Label = label; - this.ColorScheme = color_scheme; - this.Position = position; - } - } - - public static Preference[] GetPreferences () { - Preference[] preferences = new Preference[1]; - preferences[0] = new Preference