From 39fa6d9e2cc75861d71fe9d7387c7e26d7d02a99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20=28kix=29?= Date: Tue, 3 Jul 2012 12:43:02 +0200 Subject: [PATCH] Remove dup code from getWindowMakerIconImage() The code to find the icon in the function getWindowMakerIconImage() is duplicated, because it is the same code as in get_default_icon_filename() This patch includes the prototypes of get_default_icon_filename() and get_default_icon_rimage() in defaults.h, so these functions can be used in other files. --- src/defaults.h | 3 +++ src/dialog.c | 44 +++++++++++--------------------------------- 2 files changed, 14 insertions(+), 33 deletions(-) diff --git a/src/defaults.h b/src/defaults.h index 9b5ea957..e96128ab 100644 --- a/src/defaults.h +++ b/src/defaults.h @@ -48,4 +48,7 @@ RImage * wDefaultGetImage(WScreen *scr, char *winstance, char *wclass, int max_s int wDefaultGetStartWorkspace(WScreen *scr, char *instance, char *class); void wDefaultChangeIcon(WScreen *scr, char *instance, char* class, char *file); +char *get_default_icon_filename(WScreen *scr, char *winstance, char *wclass, char *command, + Bool noDefault); +RImage *get_default_icon_rimage(WScreen *scr, char *file_name, int max_size); #endif /* WMDEFAULTS_H_ */ diff --git a/src/dialog.c b/src/dialog.c index f2ec9004..3f9e5368 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -1461,45 +1461,23 @@ static void setCrashAction(void *self, void *clientData) } /* Make this read the logo from a compiled in pixmap -Dan */ -static WMPixmap *getWindowMakerIconImage(WMScreen * scr) +static WMPixmap *getWindowMakerIconImage(WMScreen *scr) { - WMPropList *dict, *key, *option, *value = NULL; WMPixmap *pix = NULL; - char *path; + char *path = NULL; - if (!WDWindowAttributes || !WDWindowAttributes->dictionary) - return NULL; + path = get_default_icon_filename(NULL, "Logo", "WMPanel", NULL, True); - WMPLSetCaseSensitive(True); + if (path) { + RColor gray; - key = WMCreatePLString("Logo.WMPanel"); - option = WMCreatePLString("Icon"); + gray.red = 0xae; + gray.green = 0xaa; + gray.blue = 0xae; + gray.alpha = 0; - dict = WMGetFromPLDictionary(WDWindowAttributes->dictionary, key); - - if (dict) { - value = WMGetFromPLDictionary(dict, option); - } - - WMReleasePropList(key); - WMReleasePropList(option); - - WMPLSetCaseSensitive(False); - - if (value && WMIsPLString(value)) { - path = FindImage(wPreferences.icon_path, WMGetFromPLString(value)); - - if (path) { - RColor gray; - - gray.red = 0xae; - gray.green = 0xaa; - gray.blue = 0xae; - gray.alpha = 0; - - pix = WMCreateBlendedPixmapFromFile(scr, path, &gray); - wfree(path); - } + pix = WMCreateBlendedPixmapFromFile(scr, path, &gray); + wfree(path); } return pix;