From: "Rodolfo García Peñas (kix)" <[email protected]>
The function wIconChangeImageFile now returns True when finish ok
and the function can change the icon image.
If something fails, then returns False.
---
src/appicon.c | 2 +-
src/dockedapp.c | 2 +-
src/icon.c | 33 +++++++++++++++------------------
3 files changed, 17 insertions(+), 20 deletions(-)
diff --git a/src/appicon.c b/src/appicon.c
index 8e22c36..caa6292 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -536,7 +536,7 @@ static void setIconCallback(WMenu *menu, WMenuEntry *entry)
wfree(file);
file = NULL;
}
- if (!wIconChangeImageFile(icon->icon, file)) {
+ if (wIconChangeImageFile(icon->icon, file) == False) {
wMessageDialog(scr, _("Error"),
_("Could not open specified icon file"),
_("OK"), NULL, NULL);
} else {
diff --git a/src/dockedapp.c b/src/dockedapp.c
index b24f127..d66acd2 100644
--- a/src/dockedapp.c
+++ b/src/dockedapp.c
@@ -159,7 +159,7 @@ static void panelBtnCallback(WMWidget * self, void *data)
text = NULL;
}
- if (!wIconChangeImageFile(panel->editedIcon->icon, text)) {
+ if (wIconChangeImageFile(panel->editedIcon->icon, text) ==
False) {
char *buf;
int len = strlen(text) + 64;
diff --git a/src/icon.c b/src/icon.c
index a8fbc65..fcdf663 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -358,33 +358,30 @@ Bool wIconChangeImageFile(WIcon *icon, const char *file)
WScreen *scr = icon->core->screen_ptr;
char *path;
RImage *image = NULL;
- int error = 0;
/* If no new image, don't do nothing */
if (!file)
- return True;
+ return False;
/* Find the new image */
path = FindImage(wPreferences.icon_path, file);
- if (path)
- image = get_rimage_from_file(scr, path, wPreferences.icon_size);
- else
- error = 1;
-
- /* New image! */
- if (!error && image) {
- /* Set the new image */
- set_icon_image_from_image(icon, image);
- icon->file = wstrdup(path);
- update_icon_pixmap(icon);
- } else {
- error = 1;
+ if (!path)
+ return False;
+
+ image = get_rimage_from_file(scr, path, wPreferences.icon_size);
+ if (!image) {
+ wfree(path);
+ return False;
}
- if (path)
- wfree(path);
+ /* Set the new image */
+ set_icon_image_from_image(icon, image);
+ icon->file = wstrdup(path);
+ update_icon_pixmap(icon);
+
+ wfree(path);
- return !error;
+ return True;
}
static char *get_name_for_wwin(WWindow *wwin)
--
1.7.10.4
--
To unsubscribe, send mail to [email protected].