This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project wmaker-crm.git.
The branch, next has been updated
via f8291de919fd3f1ac708680712aba13c7c1737ff (commit)
via 7ef416f8acf7c3952c6c8eb89c06632c619cd93c (commit)
from c61e5bfeb8a036191e1a2517b694d05b7c871900 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/wmaker-crm.git/commit/f8291de919fd3f1ac708680712aba13c7c1737ff
commit f8291de919fd3f1ac708680712aba13c7c1737ff
Author: Rodolfo GarcÃa Peñas (kix) <[email protected]>
Date: Sun Jun 10 00:59:17 2012 +0200
Function get_name_for_icon splitted
The function get_name_for_icon returns now the name of the icon,
without the full icon path and without extension (.xpm). Now is
not static.
The full path, including the folder creation, is done now by
wmkdirhier() (WINGs). This function is much better, because
supports "infinite" folders, not like the old get_name_for_icon
which could only create the specific folder for Cache Icons.
Using this functions, wIconStore() do the same work, but in a better
way, more clear.
diff --git a/src/icon.c b/src/icon.c
index 861e344..27f4eba 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -398,57 +398,28 @@ Bool wIconChangeImageFile(WIcon * icon, char *file)
return !error;
}
-static char *get_name_for_icon(WWindow * wwin)
+char *get_name_for_icon(WWindow *wwin)
{
- char *prefix, *suffix;
- char *path;
+ char *suffix;
int len;
if (wwin->wm_class && wwin->wm_instance) {
- int len = strlen(wwin->wm_class) + strlen(wwin->wm_instance) +
2;
+ len = strlen(wwin->wm_class) + strlen(wwin->wm_instance) + 2;
suffix = wmalloc(len);
snprintf(suffix, len, "%s.%s", wwin->wm_instance,
wwin->wm_class);
} else if (wwin->wm_class) {
- int len = strlen(wwin->wm_class) + 1;
+ len = strlen(wwin->wm_class) + 1;
suffix = wmalloc(len);
snprintf(suffix, len, "%s", wwin->wm_class);
} else if (wwin->wm_instance) {
- int len = strlen(wwin->wm_instance) + 1;
+ len = strlen(wwin->wm_instance) + 1;
suffix = wmalloc(len);
snprintf(suffix, len, "%s", wwin->wm_instance);
} else {
return NULL;
}
- prefix = wusergnusteppath();
- len = strlen(prefix) + 64 + strlen(suffix);
- path = wmalloc(len + 1);
- snprintf(path, len, "%s/Library/WindowMaker", prefix);
-
- if (access(path, F_OK) != 0) {
- if (mkdir(path, S_IRUSR | S_IWUSR | S_IXUSR)) {
- werror(_("could not create directory %s"), path);
- wfree(path);
- wfree(suffix);
- return NULL;
- }
- }
- strcat(path, "/CachedPixmaps");
- if (access(path, F_OK) != 0) {
- if (mkdir(path, S_IRUSR | S_IWUSR | S_IXUSR) != 0) {
- werror(_("could not create directory %s"), path);
- wfree(path);
- wfree(suffix);
- return NULL;
- }
- }
-
- strcat(path, "/");
- strcat(path, suffix);
- strcat(path, ".xpm");
- wfree(suffix);
-
- return path;
+ return suffix;
}
static char *get_icon_cache_path(void)
@@ -502,20 +473,33 @@ static RImage *get_wwindow_image_from_wmhints(WWindow
*wwin, WIcon *icon)
*/
char *wIconStore(WIcon * icon)
{
- char *path;
+ char *path, *dir_path, *file;
+ int len = 0;
RImage *image = NULL;
WWindow *wwin = icon->owner;
if (!wwin)
return NULL;
- path = get_name_for_icon(wwin);
- if (!path)
+ dir_path = get_icon_cache_path();
+ if (!dir_path)
+ return NULL;
+
+ file = get_name_for_icon(wwin);
+ if (!file) {
+ wfree(dir_path);
return NULL;
+ }
+
+ len = strlen(dir_path) + strlen(file) + 5;
+ path = wmalloc(len);
+ snprintf(path, len, "%s%s.xpm", dir_path, file);
+ wfree(dir_path);
+ wfree(file);
/* If icon exists, exit */
if (access(path, F_OK) == 0)
- return path;
+ return path;
if (wwin->net_icon_image)
image = RRetainImage(wwin->net_icon_image);
http://repo.or.cz/w/wmaker-crm.git/commit/7ef416f8acf7c3952c6c8eb89c06632c619cd93c
commit 7ef416f8acf7c3952c6c8eb89c06632c619cd93c
Author: Rodolfo GarcÃa Peñas (kix) <[email protected]>
Date: Wed Jun 6 08:41:01 2012 +0200
New functions in icon.c
This patch creates some functions:
1. Rename getnameforicon() to get_name_for_icon()
2. New function get_icon_cache_path, to get the icon cache folder
($HOME + GNUstep/Library/WindowMaker/CachedPixmaps). This folder
is defined now in the preprocessor. Not used yet, in next commits.
3. New function get_wwindow_image_from_wmhints to read the image from
X11 wmhints. Previous code at wIconStore() now changed.
diff --git a/src/icon.c b/src/icon.c
index 2a6d774..861e344 100644
--- a/src/icon.c
+++ b/src/icon.c
@@ -49,6 +49,7 @@
extern WPreferences wPreferences;
#define MOD_MASK wPreferences.modifier_mask
+#define CACHE_ICON_PATH "/Library/WindowMaker/CachedPixmaps"
extern Cursor wCursor[WCUR_LAST];
@@ -397,7 +398,7 @@ Bool wIconChangeImageFile(WIcon * icon, char *file)
return !error;
}
-static char *getnameforicon(WWindow * wwin)
+static char *get_name_for_icon(WWindow * wwin)
{
char *prefix, *suffix;
char *path;
@@ -450,6 +451,46 @@ static char *getnameforicon(WWindow * wwin)
return path;
}
+static char *get_icon_cache_path(void)
+{
+ char *prefix, *path;
+ int len, ret;
+
+ prefix = wusergnusteppath();
+ len = strlen(prefix) + strlen(CACHE_ICON_PATH) + 2;
+ path = wmalloc(len);
+ snprintf(path, len, "%s%s/", prefix, CACHE_ICON_PATH);
+
+ /* If the folder exists, exit */
+ if (access(path, F_OK) == 0)
+ return path;
+
+ /* Create the folder */
+ ret = wmkdirhier((const char *) path);
+
+ /* Exit 1 on success, 0 on failure */
+ if (ret == 1)
+ return path;
+
+ /* Fail */
+ wfree(path);
+ return NULL;
+}
+
+static RImage *get_wwindow_image_from_wmhints(WWindow *wwin, WIcon *icon)
+{
+ RImage *image = NULL;
+ XWMHints *hints = wwin->wm_hints;
+
+ if (hints && (hints->flags & IconPixmapHint) && hints->icon_pixmap !=
None)
+ image =
RCreateImageFromDrawable(icon->core->screen_ptr->rcontext,
+ hints->icon_pixmap,
+ (hints->flags & IconMaskHint)
+ ? hints->icon_mask : None);
+
+ return image;
+}
+
/*
* wIconStore--
* Stores the client supplied icon at
~/GNUstep/Library/WindowMaker/CachedPixmaps
@@ -468,7 +509,7 @@ char *wIconStore(WIcon * icon)
if (!wwin)
return NULL;
- path = getnameforicon(wwin);
+ path = get_name_for_icon(wwin);
if (!path)
return NULL;
@@ -476,14 +517,10 @@ char *wIconStore(WIcon * icon)
if (access(path, F_OK) == 0)
return path;
- if (wwin->net_icon_image) {
+ if (wwin->net_icon_image)
image = RRetainImage(wwin->net_icon_image);
- } else if (wwin->wm_hints && (wwin->wm_hints->flags & IconPixmapHint)
- && wwin->wm_hints->icon_pixmap != None) {
- image =
RCreateImageFromDrawable(icon->core->screen_ptr->rcontext,
- wwin->wm_hints->icon_pixmap,
(wwin->wm_hints->flags & IconMaskHint)
- ? wwin->wm_hints->icon_mask :
None);
- }
+ else
+ image = get_wwindow_image_from_wmhints(wwin, icon);
if (!image) {
wfree(path);
-----------------------------------------------------------------------
Summary of changes:
src/icon.c | 107 ++++++++++++++++++++++++++++++++++++------------------------
1 files changed, 64 insertions(+), 43 deletions(-)
repo.or.cz automatic notification. Contact project admin [email protected]
if you want to unsubscribe, or site admin [email protected] if you receive
no reply.
--
wmaker-crm.git ("The Window Maker window manager")
--
To unsubscribe, send mail to [email protected].