From 24600df25440ef2f06e386a0a8091efb0a256ead Mon Sep 17 00:00:00 2001 From: tkashkin Date: Sun, 23 Sep 2018 08:56:16 +0300 Subject: [PATCH] Fixes for CompatTools --- appimage/build.sh | 2 +- appveyor.yml | 2 +- data/GameHub.css | 13 ++++++ ...com.github.tkashkin.gamehub.appdata.xml.in | 5 +++ debian/changelog | 6 +++ meson.build | 2 +- po/ru.po | 40 +++++++++++++++++++ src/data/Game.vala | 4 +- src/data/compat/DOSBox.vala | 21 ++++------ src/data/compat/Innoextract.vala | 16 ++------ src/data/compat/Proton.vala | 2 +- src/data/compat/Wine.vala | 19 ++------- src/data/db/tables/Tags.vala | 33 ++++++++++----- src/data/sources/gog/GOGGame.vala | 2 + src/data/sources/humble/HumbleGame.vala | 2 + src/data/sources/steam/SteamGame.vala | 2 + src/ui/dialogs/GamePropertiesDialog.vala | 9 ++--- .../SettingsDialog/SettingsDialog.vala | 1 + .../GameDetailsView/GameDetailsPage.vala | 12 ++++++ src/ui/views/GamesView/GamesView.vala | 2 +- src/ui/widgets/ActionButton.vala | 19 +++++++-- src/ui/widgets/CompatToolPicker.vala | 1 + src/utils/Utils.vala | 20 +++++++++- 23 files changed, 166 insertions(+), 69 deletions(-) diff --git a/appimage/build.sh b/appimage/build.sh index a459f409..35d53fdd 100755 --- a/appimage/build.sh +++ b/appimage/build.sh @@ -71,7 +71,7 @@ build_deb() set -e echo "[appimage/build.sh] Building deb package" cd "$_ROOT" - export DEB_BUILD_OPTIONS="nostrip,nocheck" + export DEB_BUILD_OPTIONS="nostrip nocheck" dpkg-buildpackage -b -us -uc mkdir -p "build/$_BUILD_IMAGE" mv ../*.deb "build/$_BUILD_IMAGE/GameHub-$_VERSION-amd64.deb" diff --git a/appveyor.yml b/appveyor.yml index dabc4463..b84ccea5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 0.11.1-{build}-{branch} +version: 0.11.2-{build}-{branch} pull_requests: do_not_increment_build_number: true diff --git a/data/GameHub.css b/data/GameHub.css index a6722a6e..54e3996f 100755 --- a/data/GameHub.css +++ b/data/GameHub.css @@ -156,6 +156,13 @@ list.installers-list background: transparent; } + +GtkListBox.installers-list .list-row, +list.installers-list row +{ + border-radius: 2px; +} + GtkListBox.downloads-list .list-row, list.downloads-list row { @@ -302,6 +309,7 @@ list.tags-list row outline: none; padding: 0; margin: 0; + border-radius: 2px; } GtkListBox.tags-list .list-row:last-child, list.tags-list row:last-child @@ -333,3 +341,8 @@ list.tags-list row:hover { padding: 2px 0; } + +.link, .link label +{ + padding: 0; +} diff --git a/data/com.github.tkashkin.gamehub.appdata.xml.in b/data/com.github.tkashkin.gamehub.appdata.xml.in index 11882b6d..0aff8f5f 100644 --- a/data/com.github.tkashkin.gamehub.appdata.xml.in +++ b/data/com.github.tkashkin.gamehub.appdata.xml.in @@ -41,6 +41,11 @@ + + +

Fixes for CompatTools

+
+

Updated pt_BR localization

diff --git a/debian/changelog b/debian/changelog index 879f2270..13b9b169 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +com.github.tkashkin.gamehub (0.11.2) xenial; urgency=low + + * Fixes for CompatTools + + -- tkashkin Sun, 23 Sep 2018 08:55:24 +0300 + com.github.tkashkin.gamehub (0.11.1) xenial; urgency=low * Updated pt_BR localization diff --git a/meson.build b/meson.build index 014a76cc..228a68c8 100644 --- a/meson.build +++ b/meson.build @@ -1,4 +1,4 @@ -project('com.github.tkashkin.gamehub', 'vala', 'c', version: '0.11.1') +project('com.github.tkashkin.gamehub', 'vala', 'c', version: '0.11.2') i18n = import('i18n') gnome = import('gnome') diff --git a/po/ru.po b/po/ru.po index b4967638..05226a88 100644 --- a/po/ru.po +++ b/po/ru.po @@ -658,6 +658,10 @@ msgctxt "tag" msgid "Installed" msgstr "Установленные" +msgctxt "tag" +msgid "Not installed" +msgstr "Не установленные" + #: src/data/db/tables/Tags.vala:150 msgctxt "tag" msgid "Hidden" @@ -719,3 +723,39 @@ msgstr "Избранные" #: src/ui/widgets/CompatToolPicker.vala:32 msgid "Compatibility layer:" msgstr "Слой совместимости:" + +msgctxt "status_header" +msgid "Installing" +msgstr "Установка" + +msgctxt "status_header" +msgid "Not installed" +msgstr "Не установленные" + +msgctxt "status_header" +msgid "Installed" +msgstr "Установленные" + +msgctxt "status_header" +msgid "Downloading" +msgstr "Загрузка" + +msgctxt "status" +msgid "Installing" +msgstr "Установка" + +msgctxt "status" +msgid "Not installed" +msgstr "Не установлена" + +msgctxt "status" +msgid "Installed" +msgstr "Установлена" + +msgctxt "status" +msgid "Downloading" +msgstr "Загрузка" + +msgctxt "status" +msgid "Download started" +msgstr "Загрузка начата" diff --git a/src/data/Game.vala b/src/data/Game.vala index b395558b..c5929273 100644 --- a/src/data/Game.vala +++ b/src/data/Game.vala @@ -57,7 +57,7 @@ namespace GameHub.Data { tags.add(tag); } - if(tag != Tables.Tags.BUILTIN_INSTALLED) + if(!(tag in Tables.Tags.DYNAMIC_TAGS)) { Tables.Games.add(this); status_change(_status); @@ -70,7 +70,7 @@ namespace GameHub.Data { tags.remove(tag); } - if(tag != Tables.Tags.BUILTIN_INSTALLED) + if(!(tag in Tables.Tags.DYNAMIC_TAGS)) { Tables.Games.add(this); status_change(_status); diff --git a/src/data/compat/DOSBox.vala b/src/data/compat/DOSBox.vala index 03b6b7f1..1cfc4ede 100644 --- a/src/data/compat/DOSBox.vala +++ b/src/data/compat/DOSBox.vala @@ -21,19 +21,9 @@ namespace GameHub.Data.Compat id = @"dosbox"; name = @"DOSBox"; icon = "tool-dosbox-symbolic"; - installed = false; - var which = Utils.run({"which", binary}).strip(); - - if("not found" in which) - { - installed = false; - } - else - { - executable = FSUtils.file(which); - installed = executable.query_exists(); - } + executable = Utils.find_executable(binary); + installed = executable != null && executable.query_exists(); conf_windowed = FSUtils.file(ProjectConfig.DATADIR + "/" + ProjectConfig.PROJECT_NAME, "compat/dosbox/windowed.conf"); if(conf_windowed.query_exists()) @@ -43,10 +33,15 @@ namespace GameHub.Data.Compat } } - private static ArrayList find_configs(File dir) + private static ArrayList find_configs(File? dir) { var configs = new ArrayList(); + if(dir == null || !dir.query_exists()) + { + return configs; + } + try { FileInfo? finfo = null; diff --git a/src/data/compat/Innoextract.vala b/src/data/compat/Innoextract.vala index 0c9016ff..de2a0d74 100644 --- a/src/data/compat/Innoextract.vala +++ b/src/data/compat/Innoextract.vala @@ -18,19 +18,9 @@ namespace GameHub.Data.Compat id = @"innoextract"; name = @"Innoextract"; icon = "package-x-generic-symbolic"; - installed = false; - - var which = Utils.run({"which", binary}).strip(); - - if("not found" in which) - { - installed = false; - } - else - { - executable = FSUtils.file(which); - installed = executable.query_exists(); - } + + executable = Utils.find_executable(binary); + installed = executable != null && executable.query_exists(); } public override bool can_install(Game game) diff --git a/src/data/compat/Proton.vala b/src/data/compat/Proton.vala index c2b9538e..9dafde46 100644 --- a/src/data/compat/Proton.vala +++ b/src/data/compat/Proton.vala @@ -12,7 +12,7 @@ namespace GameHub.Data.Compat public Proton(string appid) { - Object(appid: appid, binary: "proton"); + Object(appid: appid, binary: ""); } construct diff --git a/src/data/compat/Wine.vala b/src/data/compat/Wine.vala index 5fc6d4af..3db3536f 100644 --- a/src/data/compat/Wine.vala +++ b/src/data/compat/Wine.vala @@ -6,8 +6,8 @@ namespace GameHub.Data.Compat { public class Wine: CompatTool { - public string binary { get; construct; default = "wine"; } - public File wine_binary { get; protected set; } + public string? binary { get; construct; default = "wine"; } + public File? wine_binary { get; protected set; } public Wine(string binary="wine") { @@ -19,20 +19,9 @@ namespace GameHub.Data.Compat id = @"wine_$(binary)"; name = @"Wine ($(binary))"; icon = "tool-wine-symbolic"; - installed = false; - var which = Utils.run({"which", binary}).strip(); - - if("not found" in which) - { - installed = false; - } - else - { - executable = FSUtils.file(which); - installed = executable.query_exists(); - wine_binary = executable; - } + executable = wine_binary = Utils.find_executable(binary); + installed = executable != null && executable.query_exists(); install_options = { new CompatTool.Option("/SILENT", _("Silent installation"), false), diff --git a/src/data/db/tables/Tags.vala b/src/data/db/tables/Tags.vala index 6f22fff1..c608c2de 100644 --- a/src/data/db/tables/Tags.vala +++ b/src/data/db/tables/Tags.vala @@ -19,8 +19,10 @@ namespace GameHub.Data.DB.Tables public static Table.Field SELECTED; public static ArrayList TAGS; + public static ArrayList DYNAMIC_TAGS; public static Tag BUILTIN_FAVORITES; + public static Tag BUILTIN_UNINSTALLED; public static Tag BUILTIN_INSTALLED; public static Tag BUILTIN_HIDDEN; @@ -36,6 +38,7 @@ namespace GameHub.Data.DB.Tables SELECTED = f(3); TAGS = new ArrayList(Tag.is_equal); + DYNAMIC_TAGS = new ArrayList(Tag.is_equal); } public override void migrate(Sqlite.Database db, int version) @@ -66,11 +69,12 @@ namespace GameHub.Data.DB.Tables if(!TAGS.contains(tag)) TAGS.add(tag); if(BUILTIN_FAVORITES == null && tag.id == Tag.BUILTIN_PREFIX + Tag.Builtin.FAVORITES.id()) BUILTIN_FAVORITES = tag; + if(BUILTIN_UNINSTALLED == null && tag.id == Tag.BUILTIN_PREFIX + Tag.Builtin.UNINSTALLED.id()) BUILTIN_UNINSTALLED = tag; if(BUILTIN_INSTALLED == null && tag.id == Tag.BUILTIN_PREFIX + Tag.Builtin.INSTALLED.id()) BUILTIN_INSTALLED = tag; if(BUILTIN_HIDDEN == null && tag.id == Tag.BUILTIN_PREFIX + Tag.Builtin.HIDDEN.id()) BUILTIN_HIDDEN = tag; } - Tag.Builtin[] builtin = { Tag.Builtin.FAVORITES, Tag.Builtin.INSTALLED, Tag.Builtin.HIDDEN }; + Tag.Builtin[] builtin = { Tag.Builtin.FAVORITES, Tag.Builtin.UNINSTALLED, Tag.Builtin.INSTALLED, Tag.Builtin.HIDDEN }; foreach(var bt in builtin) { @@ -78,10 +82,14 @@ namespace GameHub.Data.DB.Tables Tags.add(tag); if(BUILTIN_FAVORITES == null && tag.id == Tag.BUILTIN_PREFIX + Tag.Builtin.FAVORITES.id()) BUILTIN_FAVORITES = tag; + if(BUILTIN_UNINSTALLED == null && tag.id == Tag.BUILTIN_PREFIX + Tag.Builtin.UNINSTALLED.id()) BUILTIN_UNINSTALLED = tag; if(BUILTIN_INSTALLED == null && tag.id == Tag.BUILTIN_PREFIX + Tag.Builtin.INSTALLED.id()) BUILTIN_INSTALLED = tag; if(BUILTIN_HIDDEN == null && tag.id == Tag.BUILTIN_PREFIX + Tag.Builtin.HIDDEN.id()) BUILTIN_HIDDEN = tag; } + DYNAMIC_TAGS.add(BUILTIN_UNINSTALLED); + DYNAMIC_TAGS.add(BUILTIN_INSTALLED); + tags_updated(); } @@ -128,15 +136,16 @@ namespace GameHub.Data.DB.Tables public enum Builtin { - FAVORITES, INSTALLED, HIDDEN; + FAVORITES, UNINSTALLED, INSTALLED, HIDDEN; public string id() { switch(this) { - case Builtin.FAVORITES: return "favorites"; - case Builtin.INSTALLED: return "installed"; - case Builtin.HIDDEN: return "hidden"; + case Builtin.FAVORITES: return "favorites"; + case Builtin.UNINSTALLED: return "uninstalled"; + case Builtin.INSTALLED: return "installed"; + case Builtin.HIDDEN: return "hidden"; } assert_not_reached(); } @@ -145,9 +154,10 @@ namespace GameHub.Data.DB.Tables { switch(this) { - case Builtin.FAVORITES: return C_("tag", "Favorites"); - case Builtin.INSTALLED: return C_("tag", "Installed"); - case Builtin.HIDDEN: return C_("tag", "Hidden"); + case Builtin.FAVORITES: return C_("tag", "Favorites"); + case Builtin.UNINSTALLED: return C_("tag", "Not installed"); + case Builtin.INSTALLED: return C_("tag", "Installed"); + case Builtin.HIDDEN: return C_("tag", "Hidden"); } assert_not_reached(); } @@ -156,9 +166,10 @@ namespace GameHub.Data.DB.Tables { switch(this) { - case Builtin.FAVORITES: return "gh-tag-favorites-symbolic"; - case Builtin.INSTALLED: return "gh-tag-symbolic"; - case Builtin.HIDDEN: return "gh-tag-hidden-symbolic"; + case Builtin.FAVORITES: return "gh-tag-favorites-symbolic"; + case Builtin.UNINSTALLED: return "gh-tag-symbolic"; + case Builtin.INSTALLED: return "gh-tag-symbolic"; + case Builtin.HIDDEN: return "gh-tag-hidden-symbolic"; } assert_not_reached(); } diff --git a/src/data/sources/gog/GOGGame.vala b/src/data/sources/gog/GOGGame.vala index 25da57f6..32a2eff1 100644 --- a/src/data/sources/gog/GOGGame.vala +++ b/src/data/sources/gog/GOGGame.vala @@ -309,10 +309,12 @@ namespace GameHub.Data.Sources.GOG status = new Game.Status(state); if(state == Game.State.INSTALLED) { + remove_tag(Tables.Tags.BUILTIN_UNINSTALLED); add_tag(Tables.Tags.BUILTIN_INSTALLED); } else { + add_tag(Tables.Tags.BUILTIN_UNINSTALLED); remove_tag(Tables.Tags.BUILTIN_INSTALLED); } } diff --git a/src/data/sources/humble/HumbleGame.vala b/src/data/sources/humble/HumbleGame.vala index 96fff1e0..b5a8494e 100644 --- a/src/data/sources/humble/HumbleGame.vala +++ b/src/data/sources/humble/HumbleGame.vala @@ -103,10 +103,12 @@ namespace GameHub.Data.Sources.Humble status = new Game.Status(executable.query_exists() ? Game.State.INSTALLED : Game.State.UNINSTALLED); if(status.state == Game.State.INSTALLED) { + remove_tag(Tables.Tags.BUILTIN_UNINSTALLED); add_tag(Tables.Tags.BUILTIN_INSTALLED); } else { + add_tag(Tables.Tags.BUILTIN_UNINSTALLED); remove_tag(Tables.Tags.BUILTIN_INSTALLED); } } diff --git a/src/data/sources/steam/SteamGame.vala b/src/data/sources/steam/SteamGame.vala index 11dec400..b2cff5fc 100644 --- a/src/data/sources/steam/SteamGame.vala +++ b/src/data/sources/steam/SteamGame.vala @@ -160,10 +160,12 @@ namespace GameHub.Data.Sources.Steam status = new Game.Status(Steam.is_app_installed(id) ? Game.State.INSTALLED : Game.State.UNINSTALLED); if(status.state == Game.State.INSTALLED) { + remove_tag(Tables.Tags.BUILTIN_UNINSTALLED); add_tag(Tables.Tags.BUILTIN_INSTALLED); } else { + add_tag(Tables.Tags.BUILTIN_UNINSTALLED); remove_tag(Tables.Tags.BUILTIN_INSTALLED); } } diff --git a/src/ui/dialogs/GamePropertiesDialog.vala b/src/ui/dialogs/GamePropertiesDialog.vala index 7b9eebf6..052da85e 100644 --- a/src/ui/dialogs/GamePropertiesDialog.vala +++ b/src/ui/dialogs/GamePropertiesDialog.vala @@ -37,7 +37,7 @@ namespace GameHub.UI.Dialogs get_style_context().add_class("rounded"); get_style_context().add_class(Gtk.STYLE_CLASS_FLAT); - gravity = Gdk.Gravity.CENTER; + gravity = Gdk.Gravity.NORTH; content = new Box(Orientation.HORIZONTAL, 8); content.margin_start = content.margin_end = 6; @@ -79,11 +79,10 @@ namespace GameHub.UI.Dialogs tags_scrolled = new ScrolledWindow(null, null); tags_scrolled.vexpand = true; - tags_scrolled.margin_bottom = 8; #if GTK_3_22 tags_scrolled.propagate_natural_width = true; tags_scrolled.propagate_natural_height = true; - tags_scrolled.max_content_height = 380; + tags_scrolled.max_content_height = 320; #endif tags_scrolled.add(tags_list); @@ -189,7 +188,7 @@ namespace GameHub.UI.Dialogs properties_box.add(icon_entry); - image_search_links = new Box(Orientation.HORIZONTAL, 0); + image_search_links = new Box(Orientation.HORIZONTAL, 8); image_search_links.margin = 8; var image_search_links_label = new Label(_("Search images:")); @@ -277,7 +276,7 @@ namespace GameHub.UI.Dialogs foreach(var tag in Tables.Tags.TAGS) { - if(tag == Tables.Tags.BUILTIN_INSTALLED) continue; + if(tag in Tables.Tags.DYNAMIC_TAGS) continue; var row = new TagRow(game, tag); tags_list.add(row); } diff --git a/src/ui/dialogs/SettingsDialog/SettingsDialog.vala b/src/ui/dialogs/SettingsDialog/SettingsDialog.vala index 4d3b42eb..67410627 100644 --- a/src/ui/dialogs/SettingsDialog/SettingsDialog.vala +++ b/src/ui/dialogs/SettingsDialog/SettingsDialog.vala @@ -90,6 +90,7 @@ namespace GameHub.UI.Dialogs.SettingsDialog restart_msg.revealed = restart_msg_shown; #else restart_msg.visible = restart_msg_shown; + restart_msg.no_show_all = !restart_msg_shown; #endif } } diff --git a/src/ui/views/GameDetailsView/GameDetailsPage.vala b/src/ui/views/GameDetailsView/GameDetailsPage.vala index 1a495c0b..9268e3f0 100644 --- a/src/ui/views/GameDetailsView/GameDetailsPage.vala +++ b/src/ui/views/GameDetailsView/GameDetailsPage.vala @@ -262,6 +262,18 @@ namespace GameHub.UI.Views.GameDetailsView action_open_directory.visible = s.state == Game.State.INSTALLED; action_open_store_page.visible = game.store_page != null; action_uninstall.visible = s.state == Game.State.INSTALLED; + + if(action_run_with_compat.visible && game.compat_tool != null) + { + foreach(var tool in CompatTools) + { + if(tool.id == game.compat_tool) + { + action_run_with_compat.icon_overlay = tool.icon; + break; + } + } + } }); game.status_change(game.status); diff --git a/src/ui/views/GamesView/GamesView.vala b/src/ui/views/GamesView/GamesView.vala index 2b3f85b5..63bce342 100644 --- a/src/ui/views/GamesView/GamesView.vala +++ b/src/ui/views/GamesView/GamesView.vala @@ -558,7 +558,7 @@ namespace GameHub.UI.Views.GamesView { foreach(var tag in tags) { - tags_match = g.has_tag(tag); + tags_match_merged = g.has_tag(tag); if(tags_match_merged) break; } } diff --git a/src/ui/widgets/ActionButton.vala b/src/ui/widgets/ActionButton.vala index 3d90c042..5c7c9d3b 100644 --- a/src/ui/widgets/ActionButton.vala +++ b/src/ui/widgets/ActionButton.vala @@ -4,9 +4,9 @@ namespace GameHub.UI.Widgets { class ActionButton: Gtk.Button { - public string icon { get; construct; } - public string? icon_overlay { get; construct; } - public string text { get; construct; } + public string icon { get; construct set; } + public string? icon_overlay { get; construct set; } + public string text { get; construct set; } public bool show_text { get; construct; default = true; } public ActionButton(string icon, string? icon_overlay, string text, bool show_text=true) @@ -27,6 +27,10 @@ namespace GameHub.UI.Widgets var image = new Image.from_icon_name(icon, IconSize.DIALOG); image.set_size_request(48, 48); overlay.add(image); + + notify["icon"].connect(() => { + image.icon_name = icon; + }); if(icon_overlay != null) { @@ -36,6 +40,9 @@ namespace GameHub.UI.Widgets overlay_image.valign = Align.END; overlay.add_overlay(overlay_image); overlay.set_overlay_pass_through(overlay_image, true); + notify["icon-overlay"].connect(() => { + overlay_image.icon_name = icon_overlay; + }); } box.add(overlay); @@ -47,10 +54,16 @@ namespace GameHub.UI.Widgets label.halign = Align.START; label.valign = Align.CENTER; box.add(label); + notify["text"].connect(() => { + label.label = text; + }); } else { tooltip_text = text; + notify["text"].connect(() => { + tooltip_text = text; + }); } child = box; diff --git a/src/ui/widgets/CompatToolPicker.vala b/src/ui/widgets/CompatToolPicker.vala index af6c8e21..41e677ba 100644 --- a/src/ui/widgets/CompatToolPicker.vala +++ b/src/ui/widgets/CompatToolPicker.vala @@ -82,6 +82,7 @@ namespace GameHub.UI.Widgets { game.compat_tool = selected.id; Tables.Games.add(game); + game.update_status(); } actions.foreach(w => w.destroy()); diff --git a/src/utils/Utils.vala b/src/utils/Utils.vala index a3472ec8..8e79ec78 100644 --- a/src/utils/Utils.vala +++ b/src/utils/Utils.vala @@ -58,7 +58,8 @@ namespace GameHub.Utils { debug("[Utils.run] {'%s'}; dir: '%s'", string.joinv("' '", cmd), cdir); Process.spawn_sync(cdir, cmd, cenv, SpawnFlags.SEARCH_PATH, null, out stdout); - print(stdout.strip() + "\n"); + stdout = stdout.strip(); + if(stdout.length > 0) print(stdout + "\n"); } catch (Error e) { @@ -112,6 +113,17 @@ namespace GameHub.Utils return stdout; } + public static File? find_executable(string? name) + { + if(name == null || name.length == 0) return null; + var which = run({"which", name}); + if(which.length == 0 || !which.has_prefix("/")) + { + return null; + } + return File.new_for_path(which); + } + public static void thread(string name, owned Future worker) { try @@ -137,7 +149,9 @@ namespace GameHub.Utils #elif SNAP return "snap"; #else - return Utils.run({"bash", "-c", "lsb_release -ds 2>/dev/null || cat /etc/*release 2>/dev/null | head -n1 || uname -om"}); + if(distro != null) return distro; + distro = Utils.run({"bash", "-c", "lsb_release -ds 2>/dev/null || cat /etc/*release 2>/dev/null | head -n1 || uname -om"}); + return distro; #endif } @@ -235,4 +249,6 @@ namespace GameHub.Utils catch(Error e){} return n.strip(); } + + private static string? distro; }