>From b60ce770aaf69beebd715737f6107824315d7095 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Wed, 6 Jun 2012 22:44:12 +0200
Subject: [PATCH 09/10] Cache Icon path redefined

The cache icon path (CACHE_ICON_PATH) is now redefined and used in
various files. Now is only in one file, and the same folder. Is using
two different definitions:

define LIB_WMAKER_PATH "Library/WindowMaker"
define CACHE_ICON_PATH "CachedPixmaps"

Then, the full path is:

LIB_WMAKER_PATH + "/" + CACHE_ICON_PATH
---
 src/WindowMaker.h |    3 ++-
 src/appicon.c     |   11 ++++++++---
 src/icon.c        |    5 ++---
 src/main.c        |    6 ++++--
 4 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/WindowMaker.h b/src/WindowMaker.h
index e10b5ab..3169dda 100644
--- a/src/WindowMaker.h
+++ b/src/WindowMaker.h
@@ -26,6 +26,8 @@
 #include <limits.h>
 #include <WINGs/WINGs.h>
 
+#define LIB_WMAKER_PATH "Library/WindowMaker"
+#define CACHE_ICON_PATH "CachedPixmaps"
 
 /* class codes */
 typedef enum {
@@ -476,4 +478,3 @@ extern const char *WMNWorkspaceNameChanged;
 
 extern const char *WMNResetStacking;
 #endif
-
diff --git a/src/appicon.c b/src/appicon.c
index 0083944..28316be 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -846,19 +846,22 @@ void appIconMouseDown(WObjDescriptor * desc, XEvent * 
event)
 
 void save_app_icon(WWindow *wwin, WApplication *wapp)
 {
-       char *tmp, *path;
+       char *tmp, *path, *libpath;
        struct stat dummy;
        WScreen *scr = NULL;
 
        if (!wapp->app_icon)
                return;
 
+       libpath = wmalloc(strlen(LIB_WMAKER_PATH) + strlen(CACHE_ICON_PATH) + 
2);
+       snprintf(libpath, strlen(libpath), "%s/%s", LIB_WMAKER_PATH, 
CACHE_ICON_PATH);
+
        scr = wwin->screen_ptr;
        tmp = wDefaultGetIconFile(scr, wapp->app_icon->wm_instance, 
wapp->app_icon->wm_class, True);
 
        /* If the icon was saved by us from the client supplied icon, but is
         * missing, recreate it. */
-       if (tmp && strstr(tmp, "Library/WindowMaker/CachedPixmaps") != NULL &&
+       if (tmp && strstr(tmp, libpath) != NULL &&
            stat(tmp, &dummy) != 0 && errno == ENOENT) {
                wmessage(_("recreating missing icon '%s'"), tmp);
                path = wIconStore(wapp->app_icon->icon);
@@ -870,6 +873,8 @@ void save_app_icon(WWindow *wwin, WApplication *wapp)
        }
 
        /* if the displayed icon was supplied by the client, save the icon */
-       if (!tmp || strstr(tmp, "Library/WindowMaker/CachedPixmaps") != NULL)
+       if (!tmp || strstr(tmp, libpath) != NULL)
                wAppIconSave(wapp->app_icon);
+
+       wfree(libpath);
 }
diff --git a/src/icon.c b/src/icon.c
index 576e459..8cf8d33 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -50,7 +50,6 @@ extern WPreferences wPreferences;
 
 #define MOD_MASK wPreferences.modifier_mask
 #define ICON_SIZE wPreferences.icon_size
-#define CACHE_ICON_PATH "/Library/WindowMaker/CachedPixmaps"
 
 extern Cursor wCursor[WCUR_LAST];
 
@@ -484,9 +483,9 @@ static char *get_icon_cache_path(void)
        int len, ret;
 
        prefix = wusergnusteppath();
-       len = strlen(prefix) + strlen(CACHE_ICON_PATH) + 1;
+       len = strlen(prefix) + strlen(LIB_WMAKER_PATH) + 
strlen(CACHE_ICON_PATH) + 3;
        path = wmalloc(len);
-       snprintf(path, len, "%s%s", prefix, CACHE_ICON_PATH);
+       snprintf(path, len, "%s/%s/%s", prefix, LIB_WMAKER_PATH, 
CACHE_ICON_PATH);
 
        ret = create_path(path);
 
diff --git a/src/main.c b/src/main.c
index 431d41b..07b01f5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -567,7 +567,8 @@ static void execInitScript()
 {
        char *file, *paths;
 
-       paths = wstrconcat(wusergnusteppath(), "/Library/WindowMaker");
+       paths = wstrconcat(wusergnusteppath(), "/");
+       paths = wstrconcat(wusergnusteppath(), LIB_WMAKER_PATH);
        paths = wstrappend(paths, ":" DEF_CONFIG_PATHS);
 
        file = wfindfile(paths, DEF_INIT_SCRIPT);
@@ -585,7 +586,8 @@ void ExecExitScript()
 {
        char *file, *paths;
 
-       paths = wstrconcat(wusergnusteppath(), "/Library/WindowMaker");
+       paths = wstrconcat(wusergnusteppath(), "/");
+       paths = wstrconcat(wusergnusteppath(), LIB_WMAKER_PATH);
        paths = wstrappend(paths, ":" DEF_CONFIG_PATHS);
 
        file = wfindfile(paths, DEF_EXIT_SCRIPT);
-- 
1.7.10

-- 
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/
>From b60ce770aaf69beebd715737f6107824315d7095 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Wed, 6 Jun 2012 22:44:12 +0200
Subject: [PATCH 09/10] Cache Icon path redefined

The cache icon path (CACHE_ICON_PATH) is now redefined and used in
various files. Now is only in one file, and the same folder. Is using
two different definitions:

define LIB_WMAKER_PATH "Library/WindowMaker"
define CACHE_ICON_PATH "CachedPixmaps"

Then, the full path is:

LIB_WMAKER_PATH + "/" + CACHE_ICON_PATH
---
 src/WindowMaker.h |    3 ++-
 src/appicon.c     |   11 ++++++++---
 src/icon.c        |    5 ++---
 src/main.c        |    6 ++++--
 4 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/WindowMaker.h b/src/WindowMaker.h
index e10b5ab..3169dda 100644
--- a/src/WindowMaker.h
+++ b/src/WindowMaker.h
@@ -26,6 +26,8 @@
 #include <limits.h>
 #include <WINGs/WINGs.h>
 
+#define LIB_WMAKER_PATH "Library/WindowMaker"
+#define CACHE_ICON_PATH "CachedPixmaps"
 
 /* class codes */
 typedef enum {
@@ -476,4 +478,3 @@ extern const char *WMNWorkspaceNameChanged;
 
 extern const char *WMNResetStacking;
 #endif
-
diff --git a/src/appicon.c b/src/appicon.c
index 0083944..28316be 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -846,19 +846,22 @@ void appIconMouseDown(WObjDescriptor * desc, XEvent * event)
 
 void save_app_icon(WWindow *wwin, WApplication *wapp)
 {
-	char *tmp, *path;
+	char *tmp, *path, *libpath;
 	struct stat dummy;
 	WScreen *scr = NULL;
 
 	if (!wapp->app_icon)
 		return;
 
+	libpath = wmalloc(strlen(LIB_WMAKER_PATH) + strlen(CACHE_ICON_PATH) + 2);
+	snprintf(libpath, strlen(libpath), "%s/%s", LIB_WMAKER_PATH, CACHE_ICON_PATH);
+
 	scr = wwin->screen_ptr;
 	tmp = wDefaultGetIconFile(scr, wapp->app_icon->wm_instance, wapp->app_icon->wm_class, True);
 
 	/* If the icon was saved by us from the client supplied icon, but is
 	 * missing, recreate it. */
-	if (tmp && strstr(tmp, "Library/WindowMaker/CachedPixmaps") != NULL &&
+	if (tmp && strstr(tmp, libpath) != NULL &&
 	    stat(tmp, &dummy) != 0 && errno == ENOENT) {
 		wmessage(_("recreating missing icon '%s'"), tmp);
 		path = wIconStore(wapp->app_icon->icon);
@@ -870,6 +873,8 @@ void save_app_icon(WWindow *wwin, WApplication *wapp)
 	}
 
 	/* if the displayed icon was supplied by the client, save the icon */
-	if (!tmp || strstr(tmp, "Library/WindowMaker/CachedPixmaps") != NULL)
+	if (!tmp || strstr(tmp, libpath) != NULL)
 		wAppIconSave(wapp->app_icon);
+
+	wfree(libpath);
 }
diff --git a/src/icon.c b/src/icon.c
index 576e459..8cf8d33 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -50,7 +50,6 @@ extern WPreferences wPreferences;
 
 #define MOD_MASK wPreferences.modifier_mask
 #define ICON_SIZE wPreferences.icon_size
-#define CACHE_ICON_PATH "/Library/WindowMaker/CachedPixmaps"
 
 extern Cursor wCursor[WCUR_LAST];
 
@@ -484,9 +483,9 @@ static char *get_icon_cache_path(void)
 	int len, ret;
 
 	prefix = wusergnusteppath();
-	len = strlen(prefix) + strlen(CACHE_ICON_PATH) + 1;
+	len = strlen(prefix) + strlen(LIB_WMAKER_PATH) + strlen(CACHE_ICON_PATH) + 3;
 	path = wmalloc(len);
-	snprintf(path, len, "%s%s", prefix, CACHE_ICON_PATH);
+	snprintf(path, len, "%s/%s/%s", prefix, LIB_WMAKER_PATH, CACHE_ICON_PATH);
 
 	ret = create_path(path);
 
diff --git a/src/main.c b/src/main.c
index 431d41b..07b01f5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -567,7 +567,8 @@ static void execInitScript()
 {
 	char *file, *paths;
 
-	paths = wstrconcat(wusergnusteppath(), "/Library/WindowMaker");
+	paths = wstrconcat(wusergnusteppath(), "/");
+	paths = wstrconcat(wusergnusteppath(), LIB_WMAKER_PATH);
 	paths = wstrappend(paths, ":" DEF_CONFIG_PATHS);
 
 	file = wfindfile(paths, DEF_INIT_SCRIPT);
@@ -585,7 +586,8 @@ void ExecExitScript()
 {
 	char *file, *paths;
 
-	paths = wstrconcat(wusergnusteppath(), "/Library/WindowMaker");
+	paths = wstrconcat(wusergnusteppath(), "/");
+	paths = wstrconcat(wusergnusteppath(), LIB_WMAKER_PATH);
 	paths = wstrappend(paths, ":" DEF_CONFIG_PATHS);
 
 	file = wfindfile(paths, DEF_EXIT_SCRIPT);
-- 
1.7.10

Reply via email to