mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-23 14:42:29 +01:00
New helper function get_default_image
The new function get_default_image creates a RImage with the default icon. Now the function get_pixmap_icon_from_user_icon() is more clear and show that, first try to get the user selected image, if not set, then it gets the default icon.
This commit is contained in:
committed by
Carlos R. Mafra
parent
399d476126
commit
4f4b7655de
39
src/icon.c
39
src/icon.c
@@ -68,6 +68,8 @@ static Pixmap makeIcon(WScreen *scr, RImage *image,
|
||||
int titled, int shadowed,
|
||||
int tileType, int highlighted);
|
||||
static void icon_update_pixmap(WIcon *icon, RImage *image);
|
||||
|
||||
static RImage *get_default_image(WScreen *scr);
|
||||
/****** Notification Observers ******/
|
||||
|
||||
static void appearanceObserver(void *self, WMNotification * notif)
|
||||
@@ -627,7 +629,6 @@ void wIconUpdate(WIcon *icon)
|
||||
static void get_pixmap_icon_from_user_icon(WIcon *icon)
|
||||
{
|
||||
RImage *image = NULL;
|
||||
char *path, *file;
|
||||
WScreen *scr = icon->core->screen_ptr;
|
||||
|
||||
if (icon->file_image) {
|
||||
@@ -635,6 +636,28 @@ static void get_pixmap_icon_from_user_icon(WIcon *icon)
|
||||
} else {
|
||||
/* make default icons */
|
||||
if (!scr->def_icon_pixmap) {
|
||||
image = get_default_image(scr);
|
||||
scr->def_icon_pixmap = makeIcon(scr, image, False, False, icon->tile_type, icon->highlighted);
|
||||
scr->def_ticon_pixmap = makeIcon(scr, image, True, False, icon->tile_type, icon->highlighted);
|
||||
if (image)
|
||||
RReleaseImage(image);
|
||||
}
|
||||
|
||||
if (icon->show_title)
|
||||
XSetWindowBackgroundPixmap(dpy, icon->core->window, scr->def_ticon_pixmap);
|
||||
else
|
||||
XSetWindowBackgroundPixmap(dpy, icon->core->window, scr->def_icon_pixmap);
|
||||
|
||||
icon->pixmap = None;
|
||||
}
|
||||
}
|
||||
|
||||
/* This function creates the RImage using the default icon */
|
||||
static RImage *get_default_image(WScreen *scr)
|
||||
{
|
||||
RImage *image = NULL;
|
||||
char *path, *file;
|
||||
|
||||
/* Get the default icon */
|
||||
file = wDefaultGetIconFile(NULL, NULL, True);
|
||||
if (file) {
|
||||
@@ -650,20 +673,10 @@ static void get_pixmap_icon_from_user_icon(WIcon *icon)
|
||||
}
|
||||
}
|
||||
|
||||
/* Validate the icon size */
|
||||
image = wIconValidateIconSize(image, wPreferences.icon_size);
|
||||
scr->def_icon_pixmap = makeIcon(scr, image, False, False, icon->tile_type, icon->highlighted);
|
||||
scr->def_ticon_pixmap = makeIcon(scr, image, True, False, icon->tile_type, icon->highlighted);
|
||||
if (image)
|
||||
RReleaseImage(image);
|
||||
}
|
||||
|
||||
if (icon->show_title)
|
||||
XSetWindowBackgroundPixmap(dpy, icon->core->window, scr->def_ticon_pixmap);
|
||||
else
|
||||
XSetWindowBackgroundPixmap(dpy, icon->core->window, scr->def_icon_pixmap);
|
||||
|
||||
icon->pixmap = None;
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
/* Get the Pixmap from the WIcon of the WWindow */
|
||||
|
||||
Reference in New Issue
Block a user