El 10.06.2012 13:38, Carlos R. Mafra escribió:
On Thu,  7 Jun 2012 at 23:48:43 +0200, Rodolfo García Peñas wrote:
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

I think this patch makes things more complicated. Having a

#define CACHE_ICON_PATH "/Library/WindowMaker/CachedPixmaps"

like we have now is completely straightforward.

Perhaps you should simply replace its appearance in src/appicon.c
by CACHE_ICON_PATH, no? See here:

[mafra@Pilar:wmaker.git]$ git grep CachedPixmaps src/*
src/appicon.c:    if (tmp && strstr(tmp,
"Library/WindowMaker/CachedPixmaps") != NULL &&
src/appicon.c:    if (!tmp || strstr(tmp,
"Library/WindowMaker/CachedPixmaps") != NULL)
src/icon.c:#define CACHE_ICON_PATH "/Library/WindowMaker/CachedPixmaps"
src/icon.c: *     Stores the client supplied icon at
~/GNUstep/Library/WindowMaker/CachedPixmaps
[mafra@Pilar:wmaker.git]$


I this in that idea first, but in main.c the CachedPixmap folder is not included, and I needs other define:

kix@kentin:~/src/wmaker-crm/src$ grep Library *  grep -v wconfig
appicon.c: if (tmp && strstr(tmp, "Library/WindowMaker/CachedPixmaps") != NULL && appicon.c: if (!tmp || strstr(tmp, "Library/WindowMaker/CachedPixmaps") != NULL)
icon.c:#define CACHE_ICON_PATH "/Library/WindowMaker/CachedPixmaps"
icon.c: * Stores the client supplied icon at ~/GNUstep/Library/WindowMaker/CachedPixmaps
main.c: paths = wstrconcat(wusergnusteppath(), "/Library/WindowMaker");
main.c: paths = wstrconcat(wusergnusteppath(), "/Library/WindowMaker");

This is the reason to use two different defines. I thought to use two defines and create a patch for main.c in the future.

Thanks for your check.
kix



---
 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);
--

--
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/


--
To unsubscribe, send mail to [email protected].

Reply via email to