>From 5fa3e6fb445c0bc2d1334bfa4e3be7cb8ef4ab31 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Tue, 3 Jul 2012 12:43:02 +0200
Subject: [PATCH 05/13] getWindowMakerIconImage() removed dup code

The code to find the icon in the function getWindowMakerIconImage()
is duplicated, because is the same code that 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 9b5ea95..e96128a 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 f2ec900..3f9e536 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;
-
-       if (!WDWindowAttributes || !WDWindowAttributes->dictionary)
-               return NULL;
-
-       WMPLSetCaseSensitive(True);
-
-       key = WMCreatePLString("Logo.WMPanel");
-       option = WMCreatePLString("Icon");
-
-       dict = WMGetFromPLDictionary(WDWindowAttributes->dictionary, key);
-
-       if (dict) {
-               value = WMGetFromPLDictionary(dict, option);
-       }
-
-       WMReleasePropList(key);
-       WMReleasePropList(option);
-
-       WMPLSetCaseSensitive(False);
+       char *path = NULL;
 
-       if (value && WMIsPLString(value)) {
-               path = FindImage(wPreferences.icon_path, 
WMGetFromPLString(value));
+       path = get_default_icon_filename(NULL, "Logo", "WMPanel", NULL, True);
 
-               if (path) {
-                       RColor gray;
+       if (path) {
+               RColor gray;
 
-                       gray.red = 0xae;
-                       gray.green = 0xaa;
-                       gray.blue = 0xae;
-                       gray.alpha = 0;
+               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;
-- 
1.7.10

-- 
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/
>From 5fa3e6fb445c0bc2d1334bfa4e3be7cb8ef4ab31 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Tue, 3 Jul 2012 12:43:02 +0200
Subject: [PATCH 05/13] getWindowMakerIconImage() removed dup code

The code to find the icon in the function getWindowMakerIconImage()
is duplicated, because is the same code that 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 9b5ea95..e96128a 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 f2ec900..3f9e536 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;
-
-	if (!WDWindowAttributes || !WDWindowAttributes->dictionary)
-		return NULL;
-
-	WMPLSetCaseSensitive(True);
-
-	key = WMCreatePLString("Logo.WMPanel");
-	option = WMCreatePLString("Icon");
-
-	dict = WMGetFromPLDictionary(WDWindowAttributes->dictionary, key);
-
-	if (dict) {
-		value = WMGetFromPLDictionary(dict, option);
-	}
-
-	WMReleasePropList(key);
-	WMReleasePropList(option);
-
-	WMPLSetCaseSensitive(False);
+	char *path = NULL;
 
-	if (value && WMIsPLString(value)) {
-		path = FindImage(wPreferences.icon_path, WMGetFromPLString(value));
+	path = get_default_icon_filename(NULL, "Logo", "WMPanel", NULL, True);
 
-		if (path) {
-			RColor gray;
+	if (path) {
+		RColor gray;
 
-			gray.red = 0xae;
-			gray.green = 0xaa;
-			gray.blue = 0xae;
-			gray.alpha = 0;
+		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;
-- 
1.7.10

Reply via email to