Enable using ImageClass as menu icon

Before 00c261652e the menu item icon
was always an ImageClass name.
After changing this to be a file name some themes defining menus
(e.g. Ganymede with button tweaks) did not work as intended wrt. button
menus.
So now we accept both.
This commit is contained in:
Kim Woelders 2018-02-04 08:48:58 +01:00
parent ca5040e643
commit 2f0b4464fc
3 changed files with 27 additions and 0 deletions

View File

@ -640,6 +640,21 @@ ImageclassGetImage(ImageClass * ic, int active, int sticky, int state)
return im;
}
char *
ImageclassGetFile(ImageClass * ic)
{
ImageState *is;
if (!ic)
return NULL;
is = ImageclassGetImageState(ic, STATE_NORMAL, 0, 0);
if (!is || !is->im_file)
return NULL;
return ThemeFileFind(is->im_file, FILE_TYPE_IMAGE);
}
EImage *
ImageclassGetImageBlended(ImageClass * ic, Win win __UNUSED__, int w, int h,
int active, int sticky, int state)

View File

@ -65,6 +65,7 @@ ImageState *ImageclassGetImageState(ImageClass * ic, int state,
int active, int sticky);
ImageClass *ImageclassCreateSimple(const char *name, const char *image);
ImageClass *ImageclassGetBlack(void);
char *ImageclassGetFile(ImageClass * ic);
EImage *ImageclassGetImage(ImageClass * ic, int active, int sticky,
int state);
void ImageclassApplySimple(ImageClass * ic, Win win,

View File

@ -686,6 +686,7 @@ MenuRealize(Menu * m)
{
int i, maxh, maxw, nmaxy;
int maxx1, maxx2, w, h, x, y, r, mmw, mmh;
char *s;
EImage *im;
EImageBorder *pad, *pad_item, *pad_sub;
char has_i, has_s;
@ -741,6 +742,16 @@ MenuRealize(Menu * m)
if (m->items[i]->icon && Conf.menus.show_icons)
{
im = EImageLoad(m->items[i]->icon);
if (!im)
{
s = ImageclassGetFile(ImageclassFind(m->items[i]->icon, 0));
im = EImageLoad(s);
if (im)
{
Efree(m->items[i]->icon);
m->items[i]->icon = s;
}
}
if (im)
{
w = h = 0;