From d5eb20d27a1912de3d54085220266e6286e61050 Mon Sep 17 00:00:00 2001 From: tkashkin Date: Fri, 20 Jul 2018 19:17:50 +0300 Subject: [PATCH] Fix crash for GOG "games" like Hotline Miami 2 Digital Comics Fix building with GTK+3 < 3.22 Former-commit-id: e2674e7854730f13e87dfce81625769e1937968b --- ...com.github.tkashkin.gamehub.appdata.xml.in | 6 +++ debian/changelog | 9 +++- meson.build | 2 +- src/data/sources/gog/GOG.vala | 11 +++-- src/data/sources/gog/GOGGame.vala | 45 ++++++++++++++----- src/data/sources/humble/HumbleGame.vala | 32 +++++++------ src/meson.build | 9 +++- src/ui/dialogs/GameInstallDialog.vala | 2 - .../GameDetailsView/GameDetailsView.vala | 4 ++ src/ui/views/GamesView/GamesView.vala | 2 + 10 files changed, 89 insertions(+), 33 deletions(-) diff --git a/data/com.github.tkashkin.gamehub.appdata.xml.in b/data/com.github.tkashkin.gamehub.appdata.xml.in index a85c9c1e..3a810f91 100644 --- a/data/com.github.tkashkin.gamehub.appdata.xml.in +++ b/data/com.github.tkashkin.gamehub.appdata.xml.in @@ -41,6 +41,12 @@ + + +

Fix crash for GOG "games" like Hotline Miami 2: Wrong Number - Digital Comics

+

Fix building with GTK+3 < 3.22

+
+

Bugfixes

diff --git a/debian/changelog b/debian/changelog index 2d420901..47c123b9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,17 @@ +com.github.tkashkin.gamehub (0.5.6) xenial; urgency=low + + * Fix crash for GOG "games" like Hotline Miami 2 Digital Comics + * Fix building with GTK+3 < 3.22 + + -- tkashkin Fri, 20 Jul 2018 19:01:45 +0300 + com.github.tkashkin.gamehub (0.5.5) xenial; urgency=low * Bugfixes * Design changes * Compatibility - -- tkashkin Mon, 16 Jul 2018 05:52:48 +0300 + -- tkashkin Fri, 20 Jul 2018 17:15:34 +0300 com.github.tkashkin.gamehub (0.5.4) xenial; urgency=low diff --git a/meson.build b/meson.build index 64148d50..9ed58925 100644 --- a/meson.build +++ b/meson.build @@ -1,4 +1,4 @@ -project('com.github.tkashkin.gamehub', 'vala', 'c', version: '0.5.4') +project('com.github.tkashkin.gamehub', 'vala', 'c', version: '0.5.6') i18n = import('i18n') gnome = import('gnome') diff --git a/src/data/sources/gog/GOG.vala b/src/data/sources/gog/GOG.vala index 04a7266a..a4859486 100644 --- a/src/data/sources/gog/GOG.vala +++ b/src/data/sources/gog/GOG.vala @@ -10,6 +10,8 @@ namespace GameHub.Data.Sources.GOG private const string CLIENT_SECRET = "9d85c43b1482497dbbce61f6e4aa173a433796eeae2ca8c5f6129f2dc4de46d9"; private const string REDIRECT = "https%3A%2F%2Fembed.gog.com%2Fon_login_success%3Forigin%3Dclient"; + private const string[] GAMES_BLACKLIST = {"1424856371" /* Hotline Miami 2: Wrong Number - Digital Comics */}; + public override string name { get { return "GOG"; } } public override string icon { get { return "gog"; } } @@ -164,12 +166,15 @@ namespace GameHub.Data.Sources.GOG var cached = GamesDB.get_instance().get_games(this); if(cached.size > 0) { - games = cached; if(game_loaded != null) { foreach(var g in cached) { - game_loaded(g); + if(!(g.id in GAMES_BLACKLIST)) + { + games.add(g); + game_loaded(g); + } } } } @@ -193,7 +198,7 @@ namespace GameHub.Data.Sources.GOG foreach(var g in products.get_elements()) { var game = new GOGGame(this, g.get_object()); - if(!games.contains(game) && yield game.is_for_linux()) + if(!(game.id in GAMES_BLACKLIST) && !games.contains(game) && yield game.is_for_linux()) { games.add(game); if(game_loaded != null) game_loaded(game); diff --git a/src/data/sources/gog/GOGGame.vala b/src/data/sources/gog/GOGGame.vala index 9f287bfb..65055c77 100644 --- a/src/data/sources/gog/GOGGame.vala +++ b/src/data/sources/gog/GOGGame.vala @@ -75,15 +75,32 @@ namespace GameHub.Data.Sources.GOG _product_info_updated = true; } - var root = Parser.parse_json(custom_info).get_object(); - icon = "https:" + root.get_object_member("images").get_string_member("icon"); - description = root.get_object_member("description").get_string_member("full"); - store_page = root.get_object_member("links").get_string_member("product_card"); + var root = Parser.parse_json(custom_info); - var cool = root.get_object_member("description").get_string_member("whats_cool_about_it"); - if(cool != null && cool.length > 0) + var images = Parser.json_object(root, {"images"}); + var desc = Parser.json_object(root, {"description"}); + var links = Parser.json_object(root, {"links"}); + + if(images != null) + { + icon = images.get_string_member("icon"); + if(icon != null) icon = "https:" + icon; + else icon = image; + } + + if(desc != null) + { + description = desc.get_string_member("full"); + var cool = desc.get_string_member("whats_cool_about_it"); + if(cool != null && cool.length > 0) + { + description += "
  • " + cool.replace("\n", "
  • ") + "
"; + } + } + + if(links != null) { - description += "
  • " + cool.replace("\n", "
  • ") + "
"; + store_page = links.get_string_member("product_card"); } GamesDB.get_instance().add_game(this); @@ -95,10 +112,16 @@ namespace GameHub.Data.Sources.GOG { yield update_game_info(); - var root = Parser.parse_json(custom_info).get_object(); + var root = Parser.parse_json(custom_info); + + var downloads = Parser.json_object(root, {"downloads"}); + + if(downloads == null) return; - var installers_json = root.get_object_member("downloads").get_array_member("installers"); + var installers_json = downloads.get_array_member("installers"); + if(installers_json == null) return; + var installers = new ArrayList(); foreach(var installer_json in installers_json.get_elements()) @@ -112,8 +135,8 @@ namespace GameHub.Data.Sources.GOG wnd.canceled.connect(() => Idle.add(install.callback)); wnd.install.connect(installer => { - root = Parser.parse_remote_json_file(installer.file, "GET", ((GOG) source).user_token).get_object(); - var link = root.get_string_member("downlink"); + root = Parser.parse_remote_json_file(installer.file, "GET", ((GOG) source).user_token); + var link = root.get_object().get_string_member("downlink"); var local = FSUtils.expand(FSUtils.Paths.GOG.Installers, "gog_" + id + "_" + installer.id + ".sh"); FSUtils.mkdir(FSUtils.Paths.GOG.Games); diff --git a/src/data/sources/humble/HumbleGame.vala b/src/data/sources/humble/HumbleGame.vala index a882438d..348a50c8 100644 --- a/src/data/sources/humble/HumbleGame.vala +++ b/src/data/sources/humble/HumbleGame.vala @@ -179,26 +179,30 @@ namespace GameHub.Data.Sources.Humble Utils.run_async.end(res); Utils.run({"chmod", "-R", "+x", install_dir.get_path()}); - string? dirname = null; - FileInfo? finfo = null; - var enumerator = install_dir.enumerate_children("standard::*", FileQueryInfoFlags.NOFOLLOW_SYMLINKS); - while((finfo = enumerator.next_file()) != null) + try { - if(dirname == null) + string? dirname = null; + FileInfo? finfo = null; + var enumerator = install_dir.enumerate_children("standard::*", FileQueryInfoFlags.NOFOLLOW_SYMLINKS); + while((finfo = enumerator.next_file()) != null) { - dirname = finfo.get_name(); + if(dirname == null) + { + dirname = finfo.get_name(); + } + else + { + dirname = null; + } } - else + + if(dirname != null) { - dirname = null; + Utils.run({"bash", "-c", "mv " + dirname + "/* " + dirname + "/.* ."}, install_dir.get_path()); + FSUtils.rm(install_dir.get_path(), dirname, "-rf"); } } - - if(dirname != null) - { - Utils.run({"bash", "-c", "mv " + dirname + "/* " + dirname + "/.* ."}, install_dir.get_path()); - FSUtils.rm(install_dir.get_path(), dirname, "-rf"); - } + catch(Error e){} choose_executable(); Idle.add(install.callback); diff --git a/src/meson.build b/src/meson.build index 387328b5..dfcf2abe 100644 --- a/src/meson.build +++ b/src/meson.build @@ -13,7 +13,6 @@ project_config = configure_file( deps = [ dependency('granite'), - dependency('gtk+-3.0'), dependency('gdk-3.0'), dependency('webkit2gtk-4.0'), dependency('glib-2.0'), @@ -23,6 +22,14 @@ deps = [ dependency('sqlite3') ] +gtk322 = dependency('gtk+-3.0', version: '>=3.22', required: false) +if gtk322.found() + add_global_arguments('-D', 'GTK_3_22', language: 'vala') + deps += gtk322 +else + deps += dependency('gtk+-3.0') +endif + if get_option('use_ivy') add_global_arguments('-g', '-X', '-rdynamic', '-D', 'USE_IVY', language: 'vala') deps += meson.get_compiler('vala').find_library('posix') diff --git a/src/ui/dialogs/GameInstallDialog.vala b/src/ui/dialogs/GameInstallDialog.vala index a1ffef33..fb3b9752 100644 --- a/src/ui/dialogs/GameInstallDialog.vala +++ b/src/ui/dialogs/GameInstallDialog.vala @@ -19,10 +19,8 @@ namespace GameHub.UI.Dialogs public signal void canceled(); private Box content; - private Box actions; private Label title_label; private Label subtitle_label; - private AutoSizeImage icon; private ListBox installers_list; diff --git a/src/ui/views/GameDetailsView/GameDetailsView.vala b/src/ui/views/GameDetailsView/GameDetailsView.vala index a688b6d4..97c41bc4 100644 --- a/src/ui/views/GameDetailsView/GameDetailsView.vala +++ b/src/ui/views/GameDetailsView/GameDetailsView.vala @@ -75,8 +75,10 @@ namespace GameHub.UI.Views spinner.valign = Align.CENTER; content_scrolled = new ScrolledWindow(null, null); + #if GTK_3_22 content_scrolled.propagate_natural_width = true; content_scrolled.propagate_natural_height = true; + #endif content = new Box(Orientation.VERTICAL, 0); content.margin_start = content.margin_end = 8; @@ -166,7 +168,9 @@ namespace GameHub.UI.Views { is_dialog = !(get_toplevel() is GameHub.UI.Windows.MainWindow); + #if GTK_3_22 content_scrolled.max_content_height = is_dialog ? 640 : -1; + #endif stack.set_visible_child(spinner); diff --git a/src/ui/views/GamesView/GamesView.vala b/src/ui/views/GamesView/GamesView.vala index e17b743f..31919ed1 100644 --- a/src/ui/views/GamesView/GamesView.vala +++ b/src/ui/views/GamesView/GamesView.vala @@ -120,9 +120,11 @@ namespace GameHub.UI.Views downloads_list = new ListBox(); var downloads_scrolled = new ScrolledWindow(null, null); + #if GTK_3_22 downloads_scrolled.propagate_natural_width = true; downloads_scrolled.propagate_natural_height = true; downloads_scrolled.max_content_height = 440; + #endif downloads_scrolled.add(downloads_list); downloads_scrolled.show_all();