@@ -171,9 +171,11 @@ class MyDesklet extends Desklet.Desklet {
171171 }
172172
173173 _createShapedImageActor ( imagePath , size , loadId ) {
174+ const container = new St . Bin ( { width : size , height : size } ) ;
174175 const canvas = new Clutter . Canvas ( ) ;
175176 canvas . set_size ( size , size ) ;
176177 const actor = new Clutter . Actor ( { width : size , height : size , content : canvas } ) ;
178+ container . set_child ( actor ) ;
177179 const file = Gio . file_new_for_path ( imagePath ) ;
178180 let iter = null ;
179181
@@ -237,13 +239,15 @@ class MyDesklet extends Desklet.Desklet {
237239 updateAnimation ( ) ;
238240 } catch ( e ) {
239241 global . logError ( `${ UUID } : Error creating pixbuf animation from stream: ${ e } ` ) ;
242+ container . set_child ( this . _getErrorLayout ( `Error creating pixbuf animation from stream: ${ e } ` ) ) ;
240243 }
241244 } ) ;
242245 } catch ( e ) {
243246 global . logError ( `${ UUID } : Error reading file async: ${ e } ` ) ;
247+ container . set_child ( this . _getErrorLayout ( `Error reading file: ${ e } ` ) ) ;
244248 }
245249 } ) ;
246- return actor ;
250+ return container ;
247251 }
248252
249253 _drawFinalImage ( cr , pixbuf , width , height ) {
@@ -316,9 +320,19 @@ class MyDesklet extends Desklet.Desklet {
316320 return this . _createActorFromPixbuf ( pixBuf ) ;
317321 } catch ( e ) {
318322 global . logError ( `${ UUID } : Error loading image ${ imageFileName } : ${ e } ` ) ;
319- return new St . Label ( { text : " Error" + e . message , style_class : "picture-frame-error-label" } ) ;
323+ return this . _getErrorLayout ( ` Error loading image ${ imageFileName } : ${ e } ` ) ;
320324 }
321325 }
326+
327+ _getErrorLayout ( message ) {
328+ const headline = new St . Label ( { text : _ ( "Picture Frame" ) , style : `font-weight: bold; color: red; font-size: 1.2em;` } ) ;
329+ const label = new St . Label ( { text : "Error: " + message , style : `color: red;` } ) ;
330+ label . clutter_text . set_line_wrap ( true ) ;
331+ const errorLayout = new St . BoxLayout ( { vertical : true , width : this . size , height : this . size , style : `background-color: #d3b0ae; padding: 1em; spacing: 1em;` } ) ;
332+ errorLayout . add_child ( headline ) ;
333+ errorLayout . add_child ( label ) ;
334+ return errorLayout ;
335+ }
322336}
323337
324338function main ( metadata , deskletId ) {
0 commit comments