Skip to content

Commit

Permalink
Tweaks: refactoring (#355)
Browse files Browse the repository at this point in the history
Tweak options: saving/restoring
Tweak states (`enabled`/`disabled`/`global`)

Former-commit-id: 86e59c3
  • Loading branch information
tkashkin committed Aug 10, 2020
1 parent 6db1504 commit 95d104b
Show file tree
Hide file tree
Showing 52 changed files with 1,764 additions and 1,023 deletions.
10 changes: 5 additions & 5 deletions data/com.github.tkashkin.gamehub.gschema.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@

<!-- UI / Appearance -->
<enum id="@SCHEMA_ID@.ui.appearance.icon-styles">
<value nick="Theme-based" value="0" />
<value nick="Automatic" value="0" />
<value nick="Symbolic" value="1" />
<value nick="Colored" value="2" />
</enum>
Expand All @@ -93,7 +93,7 @@
<summary>Dark theme</summary>
</key>
<key name="icon-style" enum="@SCHEMA_ID@.ui.appearance.icon-styles">
<default>"Theme-based"</default>
<default>"Automatic"</default>
<summary>Icon style</summary>
</key>
<key name="list-style" type="as">
Expand Down Expand Up @@ -375,9 +375,9 @@

<!-- Tweaks -->
<schema path="@SCHEMA_PATH@/tweaks/" id="@SCHEMA_ID@.tweaks">
<key name="global" type="as">
<default>[]</default>
<summary>Global tweaks list</summary>
<key name="global" type="s">
<default>''</default>
<summary>Global tweak options</summary>
</key>
</schema>
</schemalist>
47 changes: 30 additions & 17 deletions res/styles/common/dialogs/SettingsDialog.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,51 @@
padding: 4px;
}

.settings-dialog > .dialog-vbox:dir(ltr)
{
margin-left: -2px;
}

.settings-dialog:dir(ltr)
{
background-image: linear-gradient(to right,
shade(@theme_bg_color, 0.95) 202px,
@borders 202px, @borders 203px,
transparent 203px, transparent);
shade(@theme_bg_color, 0.95) 200px,
@borders 200px, @borders 201px,
transparent 201px, transparent);
}

.settings-dialog > headerbar:dir(ltr)
{
background-image: linear-gradient(to right,
alpha(shade(@theme_bg_color, 0.1), 0.05) 202px,
@borders 202px, @borders 203px,
transparent 203px, transparent);
alpha(shade(@theme_bg_color, 0.1), 0.05) 200px,
@borders 200px, @borders 201px,
transparent 201px, transparent);
}
.settings-dialog:dir(rtl)

.settings-dialog > headerbar > .vertical:dir(ltr)
{
background-image: linear-gradient(to left,
shade(@theme_bg_color, 0.95) 202px,
@borders 202px, @borders 203px,
transparent 203px, transparent);
padding-left: 200px;
}
.settings-dialog > headerbar:dir(rtl)

.settings-dialog > .dialog-vbox:dir(rtl)
{
margin-right: -2px;
}

.settings-dialog:dir(rtl)
{
background-image: linear-gradient(to left,
alpha(shade(@theme_bg_color, 0.1), 0.05) 202px,
@borders 202px, @borders 203px,
transparent 203px, transparent);
shade(@theme_bg_color, 0.95) 200px,
@borders 200px, @borders 201px,
transparent 201px, transparent);
}

.settings-dialog > headerbar > .vertical:dir(ltr)
.settings-dialog > headerbar:dir(rtl)
{
padding-left: 200px;
background-image: linear-gradient(to left,
alpha(shade(@theme_bg_color, 0.1), 0.05) 200px,
@borders 200px, @borders 201px,
transparent 201px, transparent);
}

.settings-dialog > headerbar > .vertical:dir(rtl)
Expand Down
8 changes: 4 additions & 4 deletions src/app.vala
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ namespace GameHub
};

info("Restarting with GDB");
Utils.run(exec_cmd).dir(Environment.get_current_dir()).run_sync();
Utils.exec(exec_cmd).dir(Environment.get_current_dir()).sync();
exit_status = 0;
return true;
}
Expand Down Expand Up @@ -440,10 +440,10 @@ namespace GameHub

println(plain, "- Environment");
#if OS_LINUX
println(plain, " Distro: %s", Utils.get_distro());
println(plain, " DE: %s", Utils.get_desktop_environment() ?? "unknown");
println(plain, " Distro: %s", OS.get_distro());
println(plain, " DE: %s", OS.get_desktop_environment() ?? "unknown");
#else
println(plain, " OS: %s", Utils.get_distro());
println(plain, " OS: %s", OS.get_distro());
#endif
println(plain, " GTK: %u.%u.%u", Gtk.get_major_version(), Gtk.get_minor_version(), Gtk.get_micro_version());

Expand Down
6 changes: 3 additions & 3 deletions src/data/Emulator.vala
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ namespace GameHub.Data
{
Runnable.IsLaunched = is_running = true;

yield Utils.run(get_args(null, executable)).dir(work_dir.get_path()).override_runtime(true).run_sync_thread();
yield Utils.exec(get_args(null, executable)).dir(work_dir.get_path()).override_runtime(true).sync_thread();

Timeout.add_seconds(1, () => {
Runnable.IsLaunched = is_running = false;
Expand Down Expand Up @@ -204,12 +204,12 @@ namespace GameHub.Data

var dir = game != null && launch_in_game_dir ? game.work_dir : work_dir;

var task = Utils.run(get_args(game, executable)).dir(dir.get_path()).override_runtime(true);
var task = Utils.exec(get_args(game, executable)).dir(dir.get_path()).override_runtime(true);
if(game != null && game is TweakableGame)
{
task.tweaks(((TweakableGame) game).get_enabled_tweaks());
}
yield task.run_sync_thread();
yield task.sync_thread();

Timeout.add_seconds(1, () => {
Runnable.IsLaunched = is_running = false;
Expand Down
8 changes: 4 additions & 4 deletions src/data/adapters/GamesAdapter.vala
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ namespace GameHub.Data.Adapters
if(this.grid != null)
{
this.grid.set_filter_func(c => {
return filter((c as GameCard).game);
return filter(((GameCard) c).game);
});
this.grid.set_sort_func((c, c2) => {
return sort((c as GameCard).game, (c2 as GameCard).game);
return sort(((GameCard) c).game, ((GameCard) c2).game);
});
add_cached_views(false);
}
Expand All @@ -106,10 +106,10 @@ namespace GameHub.Data.Adapters
if(this.list != null)
{
this.list.set_filter_func(r => {
return filter((r as GameListRow).game);
return filter(((GameListRow) r).game);
});
this.list.set_sort_func((r, r2) => {
return sort((r as GameListRow).game, (r2 as GameListRow).game);
return sort(((GameListRow) r).game, ((GameListRow) r2).game);
});
this.list.set_header_func(list_header);
add_cached_views(false);
Expand Down
12 changes: 6 additions & 6 deletions src/data/compat/CustomScript.vala
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace GameHub.Data.Compat
var script = gh_dir.get_child(SCRIPT);
if(script.query_exists())
{
var task = Utils.run({ script.get_path() }).dir(runnable.install_dir.get_path());
var task = Utils.exec({ script.get_path() }).dir(runnable.install_dir.get_path());

runnable.cast<Game>(game => {
task.env_var("GH_INSTALL_DIR", game.install_dir.get_path())
Expand All @@ -107,7 +107,7 @@ namespace GameHub.Data.Compat
runnable.cast<Traits.Game.SupportsTweaks>(game => {
task.tweaks(game.get_enabled_tweaks(this));
});
yield task.run_sync_thread();
yield task.sync_thread();
}
else
{
Expand All @@ -122,17 +122,17 @@ namespace GameHub.Data.Compat
var script = gh_dir.get_child(SCRIPT);
if(script.query_exists())
{
Utils.run({"chmod", "+x", script.get_path()}).run_sync();
Utils.exec({"chmod", "+x", script.get_path()}).sync();
var executable_path = emu.executable != null ? emu.executable.get_path() : "null";
var game_executable_path = game != null && game.executable != null ? game.executable.get_path() : "null";
string[] cmd = { script.get_path(), executable_path, emu.id, emu.name, game_executable_path, game.id, game.full_id, game.name, game.escaped_name };
var dir = game != null && launch_in_game_dir ? game.work_dir : emu.work_dir;
var task = Utils.run(cmd).dir(dir.get_path());
var task = Utils.exec(cmd).dir(dir.get_path());
runnable.cast<Traits.Game.SupportsTweaks>(game => {
task.tweaks(game.get_enabled_tweaks(this));
});
yield task.run_sync_thread();
yield task.sync_thread();
}
else
{
Expand All @@ -157,7 +157,7 @@ namespace GameHub.Data.Compat
warning("[CustomScript.edit_script] %s", e.message);
}
}
Utils.run({"chmod", "+x", script.get_path()}).run_sync();
Utils.exec({"chmod", "+x", script.get_path()}).sync();
Utils.open_uri(script.get_uri());
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/data/compat/DOSBox.vala
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ namespace GameHub.Data.Compat
private static bool is_dos_executable(File? file)
{
if(file == null || !file.query_exists()) return false;
var type = Utils.run({"file", "-b", file.get_path()}).log(false).run_sync(true).output;
var type = Utils.exec({"file", "-b", file.get_path()}).log(false).sync(true).output;
if(type != null && type.length > 0)
{
return "DOS" in type;
Expand Down Expand Up @@ -216,11 +216,11 @@ namespace GameHub.Data.Compat
wdir = bundled_win_dosbox.get_parent();
}

var task = Utils.run(combine_cmd_with_args(cmd, runnable)).dir(wdir.get_path());
var task = Utils.exec(combine_cmd_with_args(cmd, runnable)).dir(wdir.get_path());
runnable.cast<Traits.Game.SupportsTweaks>(game => {
task.tweaks(game.get_enabled_tweaks(this));
});
yield task.run_sync_thread();
yield task.sync_thread();
}
}
}
4 changes: 2 additions & 2 deletions src/data/compat/Innoextract.vala
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace GameHub.Data.Compat

if(installed)
{
version = Utils.run({executable.get_path(), "-v", "-q", "-c", "0"}).log(false).run_sync(true).output.replace(id, "").strip();
version = Utils.exec({executable.get_path(), "-v", "-q", "-c", "0"}).log(false).sync(true).output.replace(id, "").strip();
name = name + " (" + version + ")";

if(Utils.compare_versions(Utils.parse_version(version), Innoextract.MIN_SUPPORTED_VERSION) < 0)
Expand All @@ -76,7 +76,7 @@ namespace GameHub.Data.Compat
string[] cmd = { executable.get_path(), "-e", "-m", "-d", runnable.install_dir.get_path() };
if(runnable is Sources.GOG.GOGGame) cmd += "--gog";
cmd += installer.get_path();
yield Utils.run(cmd).dir(installer.get_parent().get_path()).run_sync_thread();
yield Utils.exec(cmd).dir(installer.get_parent().get_path()).sync_thread();
do
{
Expand Down
12 changes: 6 additions & 6 deletions src/data/compat/Proton.vala
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ namespace GameHub.Data.Compat
{
cmd = { executable.get_path(), "run", "msiexec", "/i", file.get_path() };
}
var task = Utils.run(combine_cmd_with_args(cmd, runnable, args)).dir(dir.get_path()).env(prepare_env(runnable, parse_opts));
var task = Utils.exec(combine_cmd_with_args(cmd, runnable, args)).dir(dir.get_path()).env(prepare_env(runnable, parse_opts));
runnable.cast<Traits.Game.SupportsTweaks>(game => {
task.tweaks(game.get_enabled_tweaks(this));
});
yield task.run_sync_thread();
yield task.sync_thread();
}

public override File get_default_wineprefix(Traits.SupportsCompatTools runnable)
Expand All @@ -150,7 +150,7 @@ namespace GameHub.Data.Compat

if(FS.file(install_dir.get_path(), @"$(FS.GAMEHUB_DIR)/$(binary)_$(arch)").query_exists())
{
Utils.run({"bash", "-c", @"mv -f $(FS.GAMEHUB_DIR)/$(binary)_$(arch) $(FS.GAMEHUB_DIR)/$(FS.COMPAT_DATA_DIR)/$(id)"}).dir(install_dir.get_path()).run_sync();
Utils.exec({"bash", "-c", @"mv -f $(FS.GAMEHUB_DIR)/$(binary)_$(arch) $(FS.GAMEHUB_DIR)/$(FS.COMPAT_DATA_DIR)/$(id)"}).dir(install_dir.get_path()).sync();
FS.rm(dosdevices.get_child("d:").get_path());
}

Expand Down Expand Up @@ -184,7 +184,7 @@ namespace GameHub.Data.Compat
{
if(!dosdevices.get_child(@"$(letter):").query_exists() && !dosdevices.get_child(@"$(letter)::").query_exists())
{
Utils.run({"ln", "-nsf", "../../../../../", @"$(letter):"}).dir(dosdevices.get_path()).run_sync();
Utils.exec({"ln", "-nsf", "../../../../../", @"$(letter):"}).dir(dosdevices.get_path()).sync();
break;
}
}
Expand Down Expand Up @@ -269,10 +269,10 @@ namespace GameHub.Data.Compat

if(!cmd.query_exists())
{
yield Utils.run({executable.get_path(), "run", cmd.get_path(), "/c", "exit"})
yield Utils.exec({executable.get_path(), "run", cmd.get_path(), "/c", "exit"})
.dir(runnable.install_dir.get_path())
.env(prepare_env(runnable))
.run_sync_thread(true);
.sync_thread(true);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/data/compat/RetroArch.vala
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ namespace GameHub.Data.Compat

string[] cmd = { executable.get_path(), "-L", core, runnable.executable.get_path() };

yield Utils.run(combine_cmd_with_args(cmd, runnable)).dir(runnable.work_dir.get_path()).run_sync_thread();
yield Utils.exec(combine_cmd_with_args(cmd, runnable)).dir(runnable.work_dir.get_path()).sync_thread();
}
}
}
6 changes: 3 additions & 3 deletions src/data/compat/ScummVM.vala
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace GameHub.Data.Compat
{
if(dir != null && dir.query_exists())
{
var output = Utils.run({executable.get_path(), "--detect"}).dir(dir.get_path()).log(false).run_sync(true).output;
var output = Utils.exec({executable.get_path(), "--detect"}).dir(dir.get_path()).log(false).sync(true).output;
return !(SCUMMVM_NO_GAMES_WARNING in output);
}
return false;
Expand All @@ -74,11 +74,11 @@ namespace GameHub.Data.Compat

string[] cmd = { executable.get_path(), "--auto-detect" };

var task = Utils.run(combine_cmd_with_args(cmd, runnable)).dir(dir.get_path());
var task = Utils.exec(combine_cmd_with_args(cmd, runnable)).dir(dir.get_path());
runnable.cast<Traits.Game.SupportsTweaks>(game => {
task.tweaks(game.get_enabled_tweaks(this));
});
yield task.run_sync_thread();
yield task.sync_thread();
}
}
}
14 changes: 7 additions & 7 deletions src/data/compat/Wine.vala
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ namespace GameHub.Data.Compat
{
cmd = { executable.get_path(), "msiexec", "/i", file.get_path() };
}
var task = Utils.run(combine_cmd_with_args(cmd, runnable, args)).dir(dir.get_path()).env(prepare_env(runnable, parse_opts));
var task = Utils.exec(combine_cmd_with_args(cmd, runnable, args)).dir(dir.get_path()).env(prepare_env(runnable, parse_opts));
runnable.cast<Traits.Game.SupportsTweaks>(game => {
task.tweaks(game.get_enabled_tweaks(this));
});
yield task.run_sync_thread();
yield task.sync_thread();
}

public virtual File get_default_wineprefix(Traits.SupportsCompatTools runnable)
Expand All @@ -187,7 +187,7 @@ namespace GameHub.Data.Compat

if(FS.file(install_dir.get_path(), @"$(FS.GAMEHUB_DIR)/$(binary)_$(arch)").query_exists())
{
Utils.run({"bash", "-c", @"mv -f $(FS.GAMEHUB_DIR)/$(binary)_$(arch) $(FS.GAMEHUB_DIR)/$(FS.COMPAT_DATA_DIR)/$(binary)_$(arch)"}).dir(install_dir.get_path()).run_sync();
Utils.exec({"bash", "-c", @"mv -f $(FS.GAMEHUB_DIR)/$(binary)_$(arch) $(FS.GAMEHUB_DIR)/$(FS.COMPAT_DATA_DIR)/$(binary)_$(arch)"}).dir(install_dir.get_path()).sync();
FS.rm(dosdevices.get_child("d:").get_path());
}

Expand Down Expand Up @@ -221,7 +221,7 @@ namespace GameHub.Data.Compat
{
if(!dosdevices.get_child(@"$(letter):").query_exists() && !dosdevices.get_child(@"$(letter)::").query_exists())
{
Utils.run({"ln", "-nsf", "../../../../", @"$(letter):"}).dir(dosdevices.get_path()).run_sync();
Utils.exec({"ln", "-nsf", "../../../../", @"$(letter):"}).dir(dosdevices.get_path()).sync();
break;
}
}
Expand Down Expand Up @@ -316,17 +316,17 @@ namespace GameHub.Data.Compat
}
}

yield Utils.run(cmd).dir(runnable.install_dir.get_path()).env(prepare_env(runnable)).run_sync_thread();
yield Utils.exec(cmd).dir(runnable.install_dir.get_path()).env(prepare_env(runnable)).sync_thread();
}

protected async void winetricks(Traits.SupportsCompatTools runnable)
{
yield Utils.run({"winetricks"}).dir(runnable.install_dir.get_path()).env(prepare_env(runnable)).run_sync_thread();
yield Utils.exec({"winetricks"}).dir(runnable.install_dir.get_path()).env(prepare_env(runnable)).sync_thread();
}

public async string convert_path(Traits.SupportsCompatTools runnable, File path)
{
var win_path = (yield Utils.run({wine_binary.get_path(), "winepath", "-w", path.get_path()}).env(prepare_env(runnable)).log(false).run_sync_thread(true)).output.strip();
var win_path = (yield Utils.exec({wine_binary.get_path(), "winepath", "-w", path.get_path()}).env(prepare_env(runnable)).log(false).sync_thread(true)).output.strip();
debug("[Wine.convert_path] '%s' -> '%s'", path.get_path(), win_path);
return win_path;
}
Expand Down
Loading

0 comments on commit 95d104b

Please sign in to comment.