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
47
src/icon.c
47
src/icon.c
@@ -68,6 +68,8 @@ static Pixmap makeIcon(WScreen *scr, RImage *image,
|
|||||||
int titled, int shadowed,
|
int titled, int shadowed,
|
||||||
int tileType, int highlighted);
|
int tileType, int highlighted);
|
||||||
static void icon_update_pixmap(WIcon *icon, RImage *image);
|
static void icon_update_pixmap(WIcon *icon, RImage *image);
|
||||||
|
|
||||||
|
static RImage *get_default_image(WScreen *scr);
|
||||||
/****** Notification Observers ******/
|
/****** Notification Observers ******/
|
||||||
|
|
||||||
static void appearanceObserver(void *self, WMNotification * notif)
|
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)
|
static void get_pixmap_icon_from_user_icon(WIcon *icon)
|
||||||
{
|
{
|
||||||
RImage *image = NULL;
|
RImage *image = NULL;
|
||||||
char *path, *file;
|
|
||||||
WScreen *scr = icon->core->screen_ptr;
|
WScreen *scr = icon->core->screen_ptr;
|
||||||
|
|
||||||
if (icon->file_image) {
|
if (icon->file_image) {
|
||||||
@@ -635,22 +636,7 @@ static void get_pixmap_icon_from_user_icon(WIcon *icon)
|
|||||||
} else {
|
} else {
|
||||||
/* make default icons */
|
/* make default icons */
|
||||||
if (!scr->def_icon_pixmap) {
|
if (!scr->def_icon_pixmap) {
|
||||||
/* Get the default icon */
|
image = get_default_image(scr);
|
||||||
file = wDefaultGetIconFile(NULL, NULL, True);
|
|
||||||
if (file) {
|
|
||||||
path = FindImage(wPreferences.icon_path, file);
|
|
||||||
if (path) {
|
|
||||||
image = RLoadImage(scr->rcontext, path, 0);
|
|
||||||
if (!image)
|
|
||||||
wwarning(_("could not load default icon \"%s\":%s"),
|
|
||||||
file, RMessageForError(RErrorCode));
|
|
||||||
wfree(path);
|
|
||||||
} else {
|
|
||||||
wwarning(_("could not find default icon \"%s\""), file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
image = wIconValidateIconSize(image, wPreferences.icon_size);
|
|
||||||
scr->def_icon_pixmap = makeIcon(scr, image, False, False, icon->tile_type, icon->highlighted);
|
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);
|
scr->def_ticon_pixmap = makeIcon(scr, image, True, False, icon->tile_type, icon->highlighted);
|
||||||
if (image)
|
if (image)
|
||||||
@@ -666,6 +652,33 @@ static void get_pixmap_icon_from_user_icon(WIcon *icon)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 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) {
|
||||||
|
path = FindImage(wPreferences.icon_path, file);
|
||||||
|
if (path) {
|
||||||
|
image = RLoadImage(scr->rcontext, path, 0);
|
||||||
|
if (!image)
|
||||||
|
wwarning(_("could not load default icon \"%s\":%s"),
|
||||||
|
file, RMessageForError(RErrorCode));
|
||||||
|
wfree(path);
|
||||||
|
} else {
|
||||||
|
wwarning(_("could not find default icon \"%s\""), file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Validate the icon size */
|
||||||
|
image = wIconValidateIconSize(image, wPreferences.icon_size);
|
||||||
|
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get the Pixmap from the WIcon of the WWindow */
|
/* Get the Pixmap from the WIcon of the WWindow */
|
||||||
static void get_pixmap_icon_from_icon_win(WIcon * icon)
|
static void get_pixmap_icon_from_icon_win(WIcon * icon)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user