@@ -25,12 +25,11 @@ public class PantheonShell.WallpaperContainer : Granite.Bin {
2525 protected const int THUMB_HEIGHT = 144 ;
2626 protected Gtk . Picture image;
2727
28- private Gtk . Box card_box;
2928 private Gtk . Revealer check_revealer;
3029
31- public string ? thumb_path { get ; con struct set ; }
32- public bool thumb_valid { get ; construct; }
33- public string uri { get ; construct; }
30+ private string ? thumb_path = null ;
31+
32+ public string ? uri { get ; construct; default = null ; }
3433 public uint64 creation_date = 0 ;
3534
3635 public bool checked {
@@ -49,8 +48,8 @@ public class PantheonShell.WallpaperContainer : Granite.Bin {
4948 }
5049 }
5150
52- public WallpaperContainer (string uri, string ? thumb_path, bool thumb_valid ) {
53- Object (uri: uri, thumb_path : thumb_path, thumb_valid : thumb_valid );
51+ public WallpaperContainer (string uri ) {
52+ Object (uri: uri);
5453 }
5554
5655 construct {
@@ -95,6 +94,15 @@ public class PantheonShell.WallpaperContainer : Granite.Bin {
9594 var file = File . new_for_uri (uri);
9695 try {
9796 var info = file. query_info (" *" , FileQueryInfoFlags . NONE );
97+
98+ thumb_path = info. get_attribute_as_string (FileAttribute . THUMBNAIL_PATH );
99+
100+ if (thumb_path != null && info. get_attribute_boolean (FileAttribute . THUMBNAIL_IS_VALID )) {
101+ update_thumb. begin ();
102+ } else {
103+ generate_and_load_thumb ();
104+ }
105+
98106 creation_date = info. get_attribute_uint64 (GLib . FileAttribute . TIME_CREATED );
99107 remove_wallpaper_action. set_enabled (info. get_attribute_boolean (GLib . FileAttribute . ACCESS_CAN_DELETE ));
100108 } catch (Error e) {
@@ -124,21 +132,6 @@ public class PantheonShell.WallpaperContainer : Granite.Bin {
124132
125133 add_controller (secondary_click_gesture);
126134 }
127-
128- try {
129- if (uri != null ) {
130- if (thumb_path != null && thumb_valid) {
131- update_thumb. begin ();
132- } else {
133- generate_and_load_thumb ();
134- }
135- } else {
136- image. set_filename (thumb_path);
137- }
138- } catch (Error e) {
139- critical (" Failed to load wallpaper thumbnail: %s " , e. message);
140- return ;
141- }
142135 }
143136
144137 private void generate_and_load_thumb () {
0 commit comments