gfxmenu relative path in "file" component of images
PATCH 1/1 gfxmenu relative path in "file" component of images
This makes it possible to use relative paths in the "file" component of gfxmenu images. I've tested that it works, but I'd appreciate if someone more familiar with gfxmenu can review it.
Signature · 3 lines
Robert Millan "Be the change you want to see in the world" -- Gandhi
=== modified file 'gfxmenu/gui_image.c'
gui_image.c +18 -2
@@ -207,9 +207,25 @@ load_image (grub_gui_image_t self, conststatic grub_err_t image_set_property (void *vself,const char *name,const char *value) { +static const char *theme_dir =NULL ;grub_gui_image_t self = vself; -if (grub_strcmp (name,"file" ) ==0 ) -return load_image (self, value); +if (grub_strcmp (name,"theme_dir" ) ==0 ) + { + theme_dir = value; + } +else if (grub_strcmp (name,"file" ) ==0 ) + { +char *absvalue; + +/* Resolve to an absolute path. */ +if (! theme_dir) +return grub_error (GRUB_ERR_BAD_ARGUMENT ,"unspecified theme_dir" ); + absvalue =grub_resolve_relative_path (theme_dir, value); +if (! absvalue) +return grub_errno; + +return load_image (self, absvalue); + }else if (grub_strcmp (name,"id" ) ==0 ) {grub_free (self->id);
Quoted 4 lines · Robert Millan
This makes it possible to use relative paths in the "file" component of gfxmenu images. I've tested that it works, but I'd appreciate if someone more familiar with gfxmenu can review it.
+ static const char *theme_dir = NULL;
Add a member to grub_gui_image_t rather than using a static variable
+ theme_dir = value;
Use appropriate grub_strdup and free in _destroy function.
+ return load_image (self, absvalue);
absvalue isn't freeed
Quoted 7 lines
------------------------------------------------------------------------
_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko