This patch removes the function get_rimage_from_file. The code of this function is moved to the functions where is called.
I removed the function because the code inside make things dup, like if variables are NULL, warning messages,... Function get_default_image call twice wIconValidateIconSize(), now only one. Signed-off-by: Rodolfo García Peñas (kix) <[email protected]> --- src/defaults.h | 1 - src/icon.c | 15 +++++++++++++-- src/wdefaults.c | 40 ++++++++++++++-------------------------- 3 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/defaults.h b/src/defaults.h index 3712038..f59afa7 100644 --- a/src/defaults.h +++ b/src/defaults.h @@ -53,7 +53,6 @@ char *get_icon_filename(const char *winstance, const char *wclass, const char *c int wDefaultGetStartWorkspace(const char *instance, const char *class); void wDefaultChangeIcon(const char *instance, const char* class, const char *file); -RImage *get_rimage_from_file(WScreen *scr, const char *file_name, int max_size); void wDefaultPurgeInfo(const char *instance, const char *class); diff --git a/src/icon.c b/src/icon.c index 90f9607..eff9431 100644 --- a/src/icon.c +++ b/src/icon.c @@ -367,8 +367,12 @@ int wIconChangeImageFile(WIcon *icon, const char *file) if (!path) return 0; - image = get_rimage_from_file(scr, path, wPreferences.icon_size); + image = RLoadImage(scr->rcontext, path, 0); + image = wIconValidateIconSize(image, wPreferences.icon_size); if (!image) { + wwarning(_("error loading image file \"%s\": %s"), path, + RMessageForError(RErrorCode)); + wfree(path); return 0; } @@ -903,11 +907,18 @@ static void miniwindowMouseDown(WObjDescriptor * desc, XEvent * event) void set_icon_image_from_database(WIcon *icon, const char *wm_instance, const char *wm_class, const char *command) { char *file = NULL; + RImage *image = NULL; file = get_icon_filename(wm_instance, wm_class, command, False); if (file) { icon->file = wstrdup(file); - icon->file_image = get_rimage_from_file(icon->core->screen_ptr, icon->file, wPreferences.icon_size); + image = RLoadImage(icon->core->screen_ptr->rcontext, icon->file, 0); + image = wIconValidateIconSize(image, wPreferences.icon_size); + icon->file_image = image; + if (!image) + wwarning(_("error loading image file \"%s\": %s"), icon->file, + RMessageForError(RErrorCode)); + wfree(file); } } diff --git a/src/wdefaults.c b/src/wdefaults.c index 24d2598..ef9c66a 100644 --- a/src/wdefaults.c +++ b/src/wdefaults.c @@ -414,24 +414,6 @@ char *get_icon_filename(const char *winstance, const char *wclass, const char *c return file_path; } -/* This function returns the image picture for the file_name file */ -RImage *get_rimage_from_file(WScreen *scr, const char *file_name, int max_size) -{ - RImage *image = NULL; - - if (!file_name) - return NULL; - - image = RLoadImage(scr->rcontext, file_name, 0); - if (!image) - wwarning(_("error loading image file \"%s\": %s"), file_name, - RMessageForError(RErrorCode)); - - image = wIconValidateIconSize(image, max_size); - - return image; -} - /* This function returns the default icon's full path * If the path for an icon is not found, returns NULL */ char *get_default_image_path(void) @@ -458,25 +440,31 @@ RImage *get_default_image(WScreen *scr) return NULL; /* Get the default icon */ - image = get_rimage_from_file(scr, path, wPreferences.icon_size); + image = RLoadImage(scr->rcontext, path, 0); + image = wIconValidateIconSize(image, wPreferences.icon_size); if (!image) wwarning(_("could not find default icon \"%s\""), path); - /* Resize the icon to the wPreferences.icon_size size - * usually this function will return early, because size is right */ - image = wIconValidateIconSize(image, wPreferences.icon_size); - return image; } RImage *get_icon_image(WScreen *scr, const char *winstance, const char *wclass, int max_size) { - char *file_name = NULL; + RImage *image = NULL; + char *path = NULL; /* Get the file name of the image, using instance and class */ - file_name = get_icon_filename(winstance, wclass, NULL, True); + path = get_icon_filename(winstance, wclass, NULL, True); + if (!path) + return NULL; + + image = RLoadImage(scr->rcontext, path, 0); + image = wIconValidateIconSize(image, max_size); + if (!image) + wwarning(_("error loading image file \"%s\": %s"), path, + RMessageForError(RErrorCode)); - return get_rimage_from_file(scr, file_name, max_size); + return image; } int wDefaultGetStartWorkspace(const char *instance, const char *class) -- 1.8.4.rc3 -- To unsubscribe, send mail to [email protected].
