Skip to content

Commit

Permalink
Fix crash for GOG "games" like Hotline Miami 2 Digital Comics
Browse files Browse the repository at this point in the history
Fix building with GTK+3 < 3.22


Former-commit-id: e2674e7
  • Loading branch information
tkashkin committed Jul 20, 2018
1 parent 5ebe515 commit d5eb20d
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 33 deletions.
6 changes: 6 additions & 0 deletions data/com.github.tkashkin.gamehub.appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
</screenshots>

<releases>
<release type="development" version="0.5.6" date="2018-07-20">
<description>
<p>Fix crash for GOG "games" like Hotline Miami 2: Wrong Number - Digital Comics</p>
<p>Fix building with GTK+3 &lt; 3.22</p>
</description>
</release>
<release type="development" version="0.5.5" date="2018-07-20">
<description>
<p>Bugfixes</p>
Expand Down
9 changes: 8 additions & 1 deletion debian/changelog
Original file line number Diff line number Diff line change
@@ -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 <[email protected]> Fri, 20 Jul 2018 19:01:45 +0300

com.github.tkashkin.gamehub (0.5.5) xenial; urgency=low

* Bugfixes
* Design changes
* Compatibility

-- tkashkin <[email protected]> Mon, 16 Jul 2018 05:52:48 +0300
-- tkashkin <[email protected]> Fri, 20 Jul 2018 17:15:34 +0300

com.github.tkashkin.gamehub (0.5.4) xenial; urgency=low

Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
11 changes: 8 additions & 3 deletions src/data/sources/gog/GOG.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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"; } }

Expand Down Expand Up @@ -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);
}
}
}
}
Expand All @@ -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);
Expand Down
45 changes: 34 additions & 11 deletions src/data/sources/gog/GOGGame.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 += "<ul><li>" + cool.replace("\n", "</li><li>") + "</li></ul>";
}
}

if(links != null)
{
description += "<ul><li>" + cool.replace("\n", "</li><li>") + "</li></ul>";
store_page = links.get_string_member("product_card");
}

GamesDB.get_instance().add_game(this);
Expand All @@ -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<Game.Installer>();

foreach(var installer_json in installers_json.get_elements())
Expand All @@ -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);
Expand Down
32 changes: 18 additions & 14 deletions src/data/sources/humble/HumbleGame.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 8 additions & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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')
Expand Down
2 changes: 0 additions & 2 deletions src/ui/dialogs/GameInstallDialog.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 4 additions & 0 deletions src/ui/views/GameDetailsView/GameDetailsView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions src/ui/views/GamesView/GamesView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit d5eb20d

Please sign in to comment.