From 12fb5ed7b307892ac0611401562d5da31c9ba614 Mon Sep 17 00:00:00 2001 From: tkashkin Date: Tue, 3 Jul 2018 05:00:52 +0300 Subject: [PATCH] Unneeded game sources now can be disabled Bug fixes Former-commit-id: 7b8a7357a26200b713e37b4cdc7709d655c99096 --- .gitignore | 2 + ...com.github.tkashkin.gamehub.appdata.xml.in | 6 ++ data/com.github.tkashkin.gamehub.gschema.xml | 9 +++ debian/changelog | 7 ++ debian/control | 4 +- debian/copyright | 8 +- meson.build | 2 +- po/com.github.tkashkin.gamehub.pot | 72 +++++++++--------- po/ru.po | 74 ++++++++++++------- src/data/GameSource.vala | 2 + src/data/sources/gog/GOG.vala | 6 ++ src/data/sources/gog/GOGGame.vala | 2 +- src/data/sources/humble/Humble.vala | 6 ++ src/data/sources/humble/HumbleGame.vala | 2 +- src/data/sources/steam/Steam.vala | 29 +++++++- src/ui/dialogs/SettingsDialog.vala | 22 +++++- src/ui/views/GamesGridView/GamesGridView.vala | 2 +- src/ui/views/WelcomeView.vala | 33 +++++++-- src/utils/Settings.vala | 3 + src/utils/Utils.vala | 4 +- 20 files changed, 211 insertions(+), 84 deletions(-) diff --git a/.gitignore b/.gitignore index 527a0915..c9f56faa 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ debian/* !debian/rules *~ + +.buildconfig \ No newline at end of file diff --git a/data/com.github.tkashkin.gamehub.appdata.xml.in b/data/com.github.tkashkin.gamehub.appdata.xml.in index fae7c108..bf92ad31 100644 --- a/data/com.github.tkashkin.gamehub.appdata.xml.in +++ b/data/com.github.tkashkin.gamehub.appdata.xml.in @@ -40,6 +40,12 @@ + + +

Unneeded game sources now can be disabled

+

Bug fixes

+
+

Humble Bundle authentication fix

diff --git a/data/com.github.tkashkin.gamehub.gschema.xml b/data/com.github.tkashkin.gamehub.gschema.xml index 950d30cb..72f789ba 100644 --- a/data/com.github.tkashkin.gamehub.gschema.xml +++ b/data/com.github.tkashkin.gamehub.gschema.xml @@ -31,6 +31,9 @@ + + true + false @@ -40,6 +43,9 @@ + + true + false @@ -52,6 +58,9 @@ + + true + false diff --git a/debian/changelog b/debian/changelog index 692d4d19..040895ab 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +com.github.tkashkin.gamehub (0.4.0) xenial; urgency=low + + * Unneeded game sources now can be disabled + * Bug fixes + + -- tkashkin Tue, 03 Jul 2018 04:51:10 +0300 + com.github.tkashkin.gamehub (0.3.1) xenial; urgency=low * Humble Bundle authentication fix diff --git a/debian/control b/debian/control index 84a5a0d8..9046cdda 100644 --- a/debian/control +++ b/debian/control @@ -1,6 +1,6 @@ Source: com.github.tkashkin.gamehub Section: x11 -Priority: extra +Priority: optional Maintainer: tkashkin Build-Depends: meson (>= 0.40), valac (>= 0.16), @@ -13,7 +13,7 @@ Build-Depends: meson (>= 0.40), libgee-0.8-dev, libsoup2.4-dev, libsqlite3-dev -Standards-Version: 3.9.3 +Standards-Version: 4.1.4 Package: com.github.tkashkin.gamehub Architecture: any diff --git a/debian/copyright b/debian/copyright index 081c4178..8836ae2e 100644 --- a/debian/copyright +++ b/debian/copyright @@ -9,14 +9,14 @@ License: WTFPL License: WTFPL DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 - + . Copyright (C) 2004 Sam Hocevar - + . Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed. - + . DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - 0. You just DO WHAT THE FUCK YOU WANT TO. + 0. You just DO WHAT THE FUCK YOU WANT TO. \ No newline at end of file diff --git a/meson.build b/meson.build index 1ca9f3e6..fabba792 100644 --- a/meson.build +++ b/meson.build @@ -1,4 +1,4 @@ -project('com.github.tkashkin.gamehub', 'vala', 'c', version: '0.3.1') +project('com.github.tkashkin.gamehub', 'vala', 'c', version: '0.4.0') i18n = import('i18n') gnome = import('gnome') diff --git a/po/com.github.tkashkin.gamehub.pot b/po/com.github.tkashkin.gamehub.pot index 6f3d771c..168a2fc9 100644 --- a/po/com.github.tkashkin.gamehub.pot +++ b/po/com.github.tkashkin.gamehub.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: com.github.tkashkin.gamehub\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-06-17 04:53+0300\n" +"POT-Creation-Date: 2018-07-03 04:35+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -26,7 +26,7 @@ msgstr "" #: data/com.github.tkashkin.gamehub.appdata.xml.in:9 #: data/com.github.tkashkin.gamehub.desktop.in:5 -#: src/ui/views/WelcomeView.vala:32 +#: src/ui/views/WelcomeView.vala:38 msgid "All your games in one place" msgstr "" @@ -34,64 +34,58 @@ msgstr "" msgid "Manage your Steam and GOG games in one place." msgstr "" -#: data/com.github.tkashkin.gamehub.appdata.xml.in:15 -msgid "Anatoliy Kashkin" -msgstr "" - -#: data/com.github.tkashkin.gamehub.desktop.in:7 -msgid "Game;Hub;Steam;GOG;" -msgstr "" - -#: data/com.github.tkashkin.gamehub.desktop.in:10 -msgid "com.github.tkashkin.gamehub" +#: src/data/sources/steam/Steam.vala:17 +msgid "Your SteamID will be read from Steam configuration file" msgstr "" -#: src/data/sources/steam/Steam.vala:13 -msgid "Your SteamID will be read from Steam configuration file" +#: src/data/sources/steam/Steam.vala:20 +msgid "" +"Steam config file not found.\n" +"Login into your account in Steam client and return to GameHub" msgstr "" -#: src/data/sources/humble/HumbleGame.vala:163 +#: src/data/sources/humble/HumbleGame.vala:166 msgid "Select main executable of the game" msgstr "" -#: src/data/sources/humble/HumbleGame.vala:164 +#: src/data/sources/humble/HumbleGame.vala:167 #: src/ui/dialogs/GameInstallDialog.vala:75 msgid "Cancel" msgstr "" -#: src/data/sources/humble/HumbleGame.vala:164 +#: src/data/sources/humble/HumbleGame.vala:167 msgid "Select" msgstr "" -#: src/ui/dialogs/SettingsDialog.vala:27 +#: src/ui/dialogs/SettingsDialog.vala:30 msgid "Use dark theme" msgstr "" -#: src/ui/dialogs/SettingsDialog.vala:31 +#: src/ui/dialogs/SettingsDialog.vala:34 msgid "Steam API keys have limited number of uses per day" msgstr "" -#: src/ui/dialogs/SettingsDialog.vala:31 +#: src/ui/dialogs/SettingsDialog.vala:34 msgid "Generate key" msgstr "" -#: src/ui/dialogs/SettingsDialog.vala:32 +#: src/ui/dialogs/SettingsDialog.vala:35 msgid "Steam API key" msgstr "" -#: src/ui/dialogs/SettingsDialog.vala:33 +#: src/ui/dialogs/SettingsDialog.vala:36 msgid "Steam installation directory" msgstr "" -#: src/ui/dialogs/SettingsDialog.vala:37 +#: src/ui/dialogs/SettingsDialog.vala:40 msgid "GOG games directory" msgstr "" -#: src/ui/dialogs/SettingsDialog.vala:41 +#: src/ui/dialogs/SettingsDialog.vala:44 msgid "Humble Bundle games directory" msgstr "" -#: src/ui/dialogs/SettingsDialog.vala:54 +#: src/ui/dialogs/SettingsDialog.vala:57 msgid "Close" msgstr "" @@ -103,37 +97,45 @@ msgstr "" msgid "Install" msgstr "" -#: src/ui/views/WelcomeView.vala:32 -msgid "Let's get started" +#: src/ui/views/WelcomeView.vala:33 +msgid "No enabled game sources" msgstr "" -#: src/ui/views/WelcomeView.vala:42 -msgid "Skip" +#: src/ui/views/WelcomeView.vala:33 +msgid "Enable some game sources in settings" msgstr "" -#: src/ui/views/WelcomeView.vala:49 +#: src/ui/views/WelcomeView.vala:34 src/ui/views/WelcomeView.vala:59 #: src/ui/views/GamesGridView/GamesGridView.vala:92 msgid "Settings" msgstr "" -#: src/ui/views/WelcomeView.vala:101 +#: src/ui/views/WelcomeView.vala:38 +msgid "Let's get started" +msgstr "" + +#: src/ui/views/WelcomeView.vala:52 +msgid "Skip" +msgstr "" + +#: src/ui/views/WelcomeView.vala:121 msgid "Ready" msgstr "" -#: src/ui/views/WelcomeView.vala:107 +#: src/ui/views/WelcomeView.vala:127 msgid "Authentication required" msgstr "" -#: src/ui/views/WelcomeView.vala:112 +#: src/ui/views/WelcomeView.vala:132 msgid "Authenticating..." msgstr "" -#: src/ui/views/WelcomeView.vala:123 +#: src/ui/views/WelcomeView.vala:143 #, c-format msgid "Install %s" msgstr "" -#: src/ui/views/WelcomeView.vala:124 +#: src/ui/views/WelcomeView.vala:144 msgid "Return to GameHub after installing" msgstr "" diff --git a/po/ru.po b/po/ru.po index 10302637..af9cf749 100644 --- a/po/ru.po +++ b/po/ru.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: com.github.tkashkin.gamehub\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-06-17 04:53+0300\n" +"POT-Creation-Date: 2018-07-03 04:35+0300\n" "PO-Revision-Date: 2018-05-27 03:39+0300\n" "Last-Translator: Automatically generated\n" "Language-Team: none\n" @@ -18,9 +18,15 @@ msgstr "" "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" +#: data/com.github.tkashkin.gamehub.appdata.xml.in:8 +#: data/com.github.tkashkin.gamehub.desktop.in:3 +#: data/com.github.tkashkin.gamehub.desktop.in:4 +msgid "GameHub" +msgstr "" + #: data/com.github.tkashkin.gamehub.appdata.xml.in:9 #: data/com.github.tkashkin.gamehub.desktop.in:5 -#: src/ui/views/WelcomeView.vala:32 +#: src/ui/views/WelcomeView.vala:38 msgid "All your games in one place" msgstr "Все игры в одном месте" @@ -28,52 +34,60 @@ msgstr "Все игры в одном месте" msgid "Manage your Steam and GOG games in one place." msgstr "Управляйте играми из Steam и GOG в одном месте" -#: src/data/sources/steam/Steam.vala:13 +#: src/data/sources/steam/Steam.vala:17 msgid "Your SteamID will be read from Steam configuration file" msgstr "Ваш SteamID будет прочитан из файла конфигурации Steam" -#: src/data/sources/humble/HumbleGame.vala:163 +#: src/data/sources/steam/Steam.vala:20 +msgid "" +"Steam config file not found.\n" +"Login into your account in Steam client and return to GameHub" +msgstr "" +"Файл конфигурации Steam не найден.\n" +"Войдите в ваш аккаунт в клиенте Steam и вернитесь в GameHub" + +#: src/data/sources/humble/HumbleGame.vala:166 msgid "Select main executable of the game" msgstr "Выберите исполняемый файл игры" -#: src/data/sources/humble/HumbleGame.vala:164 +#: src/data/sources/humble/HumbleGame.vala:167 #: src/ui/dialogs/GameInstallDialog.vala:75 msgid "Cancel" msgstr "Отмена" -#: src/data/sources/humble/HumbleGame.vala:164 +#: src/data/sources/humble/HumbleGame.vala:167 msgid "Select" msgstr "Выбрать" -#: src/ui/dialogs/SettingsDialog.vala:27 +#: src/ui/dialogs/SettingsDialog.vala:30 msgid "Use dark theme" msgstr "Использовать тёмную тему" -#: src/ui/dialogs/SettingsDialog.vala:31 +#: src/ui/dialogs/SettingsDialog.vala:34 msgid "Steam API keys have limited number of uses per day" msgstr "API-ключи Steam имеют ограничение на количество использований в день" -#: src/ui/dialogs/SettingsDialog.vala:31 +#: src/ui/dialogs/SettingsDialog.vala:34 msgid "Generate key" msgstr "Сгенерировать ключ" -#: src/ui/dialogs/SettingsDialog.vala:32 +#: src/ui/dialogs/SettingsDialog.vala:35 msgid "Steam API key" msgstr "API-ключ Steam" -#: src/ui/dialogs/SettingsDialog.vala:33 +#: src/ui/dialogs/SettingsDialog.vala:36 msgid "Steam installation directory" msgstr "Папка установки Steam" -#: src/ui/dialogs/SettingsDialog.vala:37 +#: src/ui/dialogs/SettingsDialog.vala:40 msgid "GOG games directory" msgstr "Папка игр GOG" -#: src/ui/dialogs/SettingsDialog.vala:41 +#: src/ui/dialogs/SettingsDialog.vala:44 msgid "Humble Bundle games directory" msgstr "Папка игр Humble Bundle" -#: src/ui/dialogs/SettingsDialog.vala:54 +#: src/ui/dialogs/SettingsDialog.vala:57 msgid "Close" msgstr "Закрыть" @@ -85,37 +99,45 @@ msgstr "Выберите установочный файл игры" msgid "Install" msgstr "Установить" -#: src/ui/views/WelcomeView.vala:32 -msgid "Let's get started" -msgstr "Давайте начнём" +#: src/ui/views/WelcomeView.vala:33 +msgid "No enabled game sources" +msgstr "Нет активных источников игр" -#: src/ui/views/WelcomeView.vala:42 -msgid "Skip" -msgstr "Пропустить" +#: src/ui/views/WelcomeView.vala:33 +msgid "Enable some game sources in settings" +msgstr "Включите источники в настройках" -#: src/ui/views/WelcomeView.vala:49 +#: src/ui/views/WelcomeView.vala:34 src/ui/views/WelcomeView.vala:59 #: src/ui/views/GamesGridView/GamesGridView.vala:92 msgid "Settings" msgstr "Настройки" -#: src/ui/views/WelcomeView.vala:101 +#: src/ui/views/WelcomeView.vala:38 +msgid "Let's get started" +msgstr "Давайте начнём" + +#: src/ui/views/WelcomeView.vala:52 +msgid "Skip" +msgstr "Пропустить" + +#: src/ui/views/WelcomeView.vala:121 msgid "Ready" msgstr "Готово" -#: src/ui/views/WelcomeView.vala:107 +#: src/ui/views/WelcomeView.vala:127 msgid "Authentication required" msgstr "Требуется авторизация" -#: src/ui/views/WelcomeView.vala:112 +#: src/ui/views/WelcomeView.vala:132 msgid "Authenticating..." msgstr "Авторизация..." -#: src/ui/views/WelcomeView.vala:123 +#: src/ui/views/WelcomeView.vala:143 #, c-format msgid "Install %s" msgstr "Установить %s" -#: src/ui/views/WelcomeView.vala:124 +#: src/ui/views/WelcomeView.vala:144 msgid "Return to GameHub after installing" msgstr "Вернитесь в GameHub после установки" diff --git a/src/data/GameSource.vala b/src/data/GameSource.vala index b6cf919d..79a950c7 100644 --- a/src/data/GameSource.vala +++ b/src/data/GameSource.vala @@ -12,6 +12,8 @@ namespace GameHub.Data public virtual string icon { get { return ""; } } public virtual string auth_description { owned get { return ""; } } + public abstract bool enabled { get; set; } + public int games_count { get; protected set; } public abstract bool is_installed(bool refresh=false); diff --git a/src/data/sources/gog/GOG.vala b/src/data/sources/gog/GOG.vala index b8efbb52..37040d28 100644 --- a/src/data/sources/gog/GOG.vala +++ b/src/data/sources/gog/GOG.vala @@ -12,6 +12,12 @@ namespace GameHub.Data.Sources.GOG public override string name { get { return "GOG"; } } public override string icon { get { return "gog"; } } + + public override bool enabled + { + get { return Settings.Auth.GOG.get_instance().enabled; } + set { Settings.Auth.GOG.get_instance().enabled = value; } + } public string? user_id { get; protected set; } public string? user_name { get; protected set; } diff --git a/src/data/sources/gog/GOGGame.vala b/src/data/sources/gog/GOGGame.vala index a524d08b..624bf2f5 100644 --- a/src/data/sources/gog/GOGGame.vala +++ b/src/data/sources/gog/GOGGame.vala @@ -93,7 +93,7 @@ namespace GameHub.Data.Sources.GOG var file = Downloader.get_instance().download.end(res).get_path(); var install_dir = FSUtils.expand(FSUtils.Paths.GOG.Games, installation_dir_name); Utils.run(@"chmod +x \"$(file)\""); - Utils.run_async.begin(@"$(file) -- --i-agree-to-all-licenses --noreadme --nooptions --noprompt --destination $(install_dir)", (obj, res) => { + Utils.run_async.begin(@"$(file) -- --i-agree-to-all-licenses --noreadme --nooptions --noprompt --destination $(install_dir)", true, (obj, res) => { Utils.run_async.end(res); Idle.add(install.callback); }); diff --git a/src/data/sources/humble/Humble.vala b/src/data/sources/humble/Humble.vala index 26b63a65..f3604a0f 100644 --- a/src/data/sources/humble/Humble.vala +++ b/src/data/sources/humble/Humble.vala @@ -10,6 +10,12 @@ namespace GameHub.Data.Sources.Humble public override string name { get { return "Humble Bundle"; } } public override string icon { get { return "humble"; } } + + public override bool enabled + { + get { return Settings.Auth.Humble.get_instance().enabled; } + set { Settings.Auth.Humble.get_instance().enabled = value; } + } public string? user_token = null; diff --git a/src/data/sources/humble/HumbleGame.vala b/src/data/sources/humble/HumbleGame.vala index 7cd065c8..6d324ad9 100644 --- a/src/data/sources/humble/HumbleGame.vala +++ b/src/data/sources/humble/HumbleGame.vala @@ -159,7 +159,7 @@ namespace GameHub.Data.Sources.Humble break; } - Utils.run_async.begin(cmd, (obj, res) => { + Utils.run_async.begin(cmd, true, (obj, res) => { Utils.run_async.end(res); Utils.run(@"chmod -R +x \"$(install_dir)\""); diff --git a/src/data/sources/steam/Steam.vala b/src/data/sources/steam/Steam.vala index bd438eb8..4a530053 100644 --- a/src/data/sources/steam/Steam.vala +++ b/src/data/sources/steam/Steam.vala @@ -10,13 +10,32 @@ namespace GameHub.Data.Sources.Steam public override string name { get { return "Steam"; } } public override string icon { get { return "steam"; } } - public override string auth_description { owned get { return ".\n%s".printf(_("Your SteamID will be read from Steam configuration file")); } } + public override string auth_description + { + owned get + { + var text = _("Your SteamID will be read from Steam configuration file"); + if(!is_authenticated_in_steam_client) + { + text = _("Steam config file not found.\nLogin into your account in Steam client and return to GameHub"); + } + return ".\n%s".printf(text); + } + } + + public override bool enabled + { + get { return Settings.Auth.Steam.get_instance().enabled; } + set { Settings.Auth.Steam.get_instance().enabled = value; } + } public string? user_id { get; protected set; } public string? user_name { get; protected set; } private bool? installed = null; + private bool is_authenticated_in_steam_client { get { return FSUtils.file(FSUtils.Paths.Steam.LoginUsersVDF).query_exists(); } } + public override bool is_installed(bool refresh) { if(installed != null && !refresh) @@ -42,6 +61,12 @@ namespace GameHub.Data.Sources.Steam var result = false; + if(!is_authenticated_in_steam_client) + { + yield Utils.run_async("/usr/bin/env steam", false); + return false; + } + new Thread("steam-loginusers-thread", () => { var config = Parser.parse_vdf_file(FSUtils.Paths.Steam.LoginUsersVDF); var users = Parser.json_object(config, {"users"}); @@ -79,7 +104,7 @@ namespace GameHub.Data.Sources.Steam public override bool can_authenticate_automatically() { - return Settings.Auth.Steam.get_instance().authenticated; + return Settings.Auth.Steam.get_instance().authenticated && is_authenticated_in_steam_client; } private ArrayList games = new ArrayList(Game.is_equal); diff --git a/src/ui/dialogs/SettingsDialog.vala b/src/ui/dialogs/SettingsDialog.vala index 5fc0f9fe..f1a01b9d 100644 --- a/src/ui/dialogs/SettingsDialog.vala +++ b/src/ui/dialogs/SettingsDialog.vala @@ -22,22 +22,25 @@ namespace GameHub.UI.Dialogs var ui = Settings.UI.get_instance(); var paths = FSUtils.Paths.Settings.get_instance(); + var steam_auth = Settings.Auth.Steam.get_instance(); + var gog_auth = Settings.Auth.GOG.get_instance(); + var humble_auth = Settings.Auth.Humble.get_instance(); add_switch(_("Use dark theme"), ui.dark_theme, e => { ui.dark_theme = e; }); add_separator(); - add_header("Steam"); + add_header_with_checkbox("Steam", steam_auth.enabled, v => { steam_auth.enabled = v; }); add_labeled_link(_("Steam API keys have limited number of uses per day"), _("Generate key"), "https://steamcommunity.com/dev/apikey"); add_entry(_("Steam API key"), steam_auth.api_key, v => { steam_auth.api_key = v; }); add_file_chooser(_("Steam installation directory"), FileChooserAction.SELECT_FOLDER, paths.steam_home, v => { paths.steam_home = v; }, false); add_separator(); - add_header("GOG"); + add_header_with_checkbox("GOG", gog_auth.enabled, v => { gog_auth.enabled = v; }); add_file_chooser(_("GOG games directory"), FileChooserAction.SELECT_FOLDER, paths.gog_games, v => { paths.gog_games = v; }); add_separator(); - add_header("Humble Bundle"); + add_header_with_checkbox("Humble Bundle", humble_auth.enabled, v => { humble_auth.enabled = v; }); add_file_chooser(_("Humble Bundle games directory"), FileChooserAction.SELECT_FOLDER, paths.humble_games, v => { paths.humble_games = v; }); content.pack_start(box, false, false, 0); @@ -124,6 +127,19 @@ namespace GameHub.UI.Dialogs add_widget(label); } + private void add_header_with_checkbox(string text, bool enabled, owned SwitchAction action) + { + var cb = new CheckButton.with_label(text); + cb.active = enabled; + cb.halign = Align.START; + cb.hexpand = true; + cb.notify["active"].connect(() => { action(cb.active); }); + + cb.get_style_context().add_class(Granite.STYLE_CLASS_H4_LABEL); + + add_widget(cb); + } + private void add_link(string text, string uri) { var link = new LinkButton.with_label(uri, text); diff --git a/src/ui/views/GamesGridView/GamesGridView.vala b/src/ui/views/GamesGridView/GamesGridView.vala index 5d0e06b7..95edd487 100644 --- a/src/ui/views/GamesGridView/GamesGridView.vala +++ b/src/ui/views/GamesGridView/GamesGridView.vala @@ -35,7 +35,7 @@ namespace GameHub.UI.Views foreach(var src in GameSources) { - if(src.is_authenticated()) sources.add(src); + if(src.enabled && src.is_authenticated()) sources.add(src); } games_list = new GamesGridFlowBox(); diff --git a/src/ui/views/WelcomeView.vala b/src/ui/views/WelcomeView.vala index 95020628..398a1b94 100644 --- a/src/ui/views/WelcomeView.vala +++ b/src/ui/views/WelcomeView.vala @@ -8,6 +8,7 @@ namespace GameHub.UI.Views public class WelcomeView: BaseView { private Stack stack; + private Granite.Widgets.AlertView empty_alert; private Granite.Widgets.Welcome welcome; private Button skip_btn; @@ -29,6 +30,11 @@ namespace GameHub.UI.Views spinner.valign = Align.CENTER; stack.add(spinner); + empty_alert = new Granite.Widgets.AlertView(_("No enabled game sources"), _("Enable some game sources in settings"), "dialog-warning"); + empty_alert.show_action(_("Settings")); + + stack.add(empty_alert); + welcome = new Granite.Widgets.Welcome(_("All your games in one place"), _("Let's get started")); welcome.activated.connect(index => { @@ -41,6 +47,7 @@ namespace GameHub.UI.Views titlebar.get_style_context().add_class(Gtk.STYLE_CLASS_FLAT); welcome.get_style_context().remove_class(Gtk.STYLE_CLASS_VIEW); + empty_alert.get_style_context().remove_class(Gtk.STYLE_CLASS_VIEW); skip_btn = new Button.with_label(_("Skip")); skip_btn.clicked.connect(open_games_grid); @@ -53,6 +60,7 @@ namespace GameHub.UI.Views settings.image = new Image.from_icon_name("open-menu", IconSize.LARGE_TOOLBAR); settings.clicked.connect(() => new Dialogs.SettingsDialog().show_all()); + empty_alert.action_activated.connect(() => settings.clicked()); titlebar.pack_end(settings); titlebar.pack_end(skip_btn); @@ -65,7 +73,7 @@ namespace GameHub.UI.Views var image = FSUtils.get_icon(src.icon + (ui_settings.dark_theme ? "-white" : "")); var i = welcome.append_with_pixbuf(image, src.name, ""); - + ui_settings.notify["dark-theme"].connect(() => { welcome.get_button_from_index(i).icon = new Image.from_pixbuf(FSUtils.get_icon(src.icon + (ui_settings.dark_theme ? "-white" : ""))); }); @@ -91,6 +99,7 @@ namespace GameHub.UI.Views skip_btn.set_sensitive(false); var all_authenticated = true; + int enabled_sources = 0; for(int index = 0; index < GameSources.length; index++) { @@ -98,6 +107,11 @@ namespace GameHub.UI.Views var btn = welcome.get_button_from_index(index); + welcome.set_item_visible(index, src.enabled); + + if(!src.enabled) continue; + enabled_sources++; + if(src.is_installed(true)) { btn.title = src.name; @@ -132,20 +146,27 @@ namespace GameHub.UI.Views } } - if(all_authenticated) + if(enabled_sources > 0 && all_authenticated) { - open_games_grid(); + Idle.add(() => { open_games_grid(); return false; }); return; } + + if(enabled_sources == 0) + { + settings.opacity = 0; + skip_btn.opacity = 0; + stack.set_visible_child(empty_alert); + empty_alert.show_all(); + } else { - stack.set_visible_child(welcome); settings.opacity = 1; skip_btn.opacity = 1; + stack.set_visible_child(welcome); + welcome.show_all(); } - welcome.show_all(); - is_updating = false; } diff --git a/src/utils/Settings.vala b/src/utils/Settings.vala index 025a2dc5..4d390fbe 100644 --- a/src/utils/Settings.vala +++ b/src/utils/Settings.vala @@ -59,6 +59,7 @@ namespace GameHub.Settings { public class Steam: Granite.Services.Settings { + public bool enabled { get; set; } public bool authenticated { get; set; } public string api_key { get; set; } @@ -80,6 +81,7 @@ namespace GameHub.Settings public class GOG: Granite.Services.Settings { + public bool enabled { get; set; } public bool authenticated { get; set; } public string access_token { get; set; } public string refresh_token { get; set; } @@ -102,6 +104,7 @@ namespace GameHub.Settings public class Humble: Granite.Services.Settings { + public bool enabled { get; set; } public bool authenticated { get; set; } public string access_token { get; set; } diff --git a/src/utils/Utils.vala b/src/utils/Utils.vala index e7795cf0..49556689 100644 --- a/src/utils/Utils.vala +++ b/src/utils/Utils.vala @@ -33,7 +33,7 @@ namespace GameHub.Utils return stdout; } - public static async int run_async(string cmd) + public static async int run_async(string cmd, bool wait=true) { int result = -1; var c = new Granite.Services.SimpleCommand(Environment.get_home_dir(), cmd); @@ -42,7 +42,7 @@ namespace GameHub.Utils Idle.add(run_async.callback); }); c.run(); - yield; + if(wait) yield; return result; }