[gnome-games/wip/theawless/simplify-thumbnail: 3/5] game-thumbnail: Simplify drawing emblem
- From: Abhinav Singh <abhinavsingh src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/theawless/simplify-thumbnail: 3/5] game-thumbnail: Simplify drawing emblem
- Date: Tue, 2 Oct 2018 15:23:12 +0000 (UTC)
commit 7056834e72165007685dedd83033ae623701d757
Author: theawless <theawless gmail com>
Date: Tue Oct 2 17:10:13 2018 +0530
game-thumbnail: Simplify drawing emblem
src/ui/game-thumbnail.vala | 27 +++++++++++----------------
1 file changed, 11 insertions(+), 16 deletions(-)
---
diff --git a/src/ui/game-thumbnail.vala b/src/ui/game-thumbnail.vala
index 3771e1be..e9307425 100644
--- a/src/ui/game-thumbnail.vala
+++ b/src/ui/game-thumbnail.vala
@@ -102,7 +102,7 @@ private class Games.GameThumbnail: Gtk.DrawingArea {
// Draw the default thumbnail if no thumbnail have been drawn
if (!drawn)
- draw_default (context);
+ draw_emblem (context);
return true;
}
@@ -139,13 +139,17 @@ private class Games.GameThumbnail: Gtk.DrawingArea {
return true;
}
- public void draw_default (DrawingContext context) {
+ public void draw_emblem (DrawingContext context) {
+ var pixbuf = get_scaled_emblem (context, "applications-games-symbolic", EMBLEM_SCALE);
+ if (pixbuf == null)
+ return;
+
draw_background (context);
- draw_emblem_icon (context, "applications-games-symbolic", EMBLEM_SCALE);
+ draw_pixbuf (context, pixbuf);
draw_border (context);
}
- private void draw_emblem_icon (DrawingContext context, string icon_name, double scale) {
+ private Gdk.Pixbuf? get_scaled_emblem (DrawingContext context, string icon_name, double scale) {
Gdk.Pixbuf? emblem = null;
var color = context.style.get_color (context.state);
@@ -156,23 +160,14 @@ private class Games.GameThumbnail: Gtk.DrawingArea {
if (icon_info == null) {
warning ("Couldn't find the emblem");
- return;
+ return null;
}
try {
- emblem = icon_info.load_symbolic (color);
+ return icon_info.load_symbolic (color);
} catch (GLib.Error e) {
warning (@"Couldn’t load the emblem: $(e.message)");
- return;
+ return null;
}
-
- if (emblem == null)
- return;
-
- double offset_x = context.width / 2.0 - emblem.width / 2.0;
- double offset_y = context.height / 2.0 - emblem.height / 2.0;
-
- Gdk.cairo_set_source_pixbuf (context.cr, emblem, offset_x, offset_y);
- context.cr.paint ();
}
private Gdk.Pixbuf? get_scaled_icon (DrawingContext context, GLib.Icon? icon, double scale) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]