>From d476a7da5e1b14674e9b62ed864353444830e93f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Mon, 18 Jun 2012 11:47:44 +0200
Subject: [PATCH 06/12] extractIcon removed.

The function extractIcon is removed, and their behaviour is moved to
save_app_icon, because this function is called always.

To do that, save_app_icon don't need check if the icon is saved (is
done at wIconStore). The icon now is saved always (if not exists!),
like extractIcon() did it.
---
 src/appicon.c     |   26 +++-----------------------
 src/application.c |   15 ---------------
 2 files changed, 3 insertions(+), 38 deletions(-)

diff --git a/src/appicon.c b/src/appicon.c
index ed4403c..01cdd5d 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -929,34 +929,14 @@ void wApplicationSaveIconPathFor(char *iconPath, char 
*wm_instance, char *wm_cla
                UpdateDomainFile(WDWindowAttributes);
 }
 
+/* Save the application icon */
+/* This function is used by normal windows */
 void save_app_icon(WWindow *wwin, WApplication *wapp)
 {
-       char *tmp, *path;
-       struct stat dummy;
-       WScreen *scr = NULL;
-
        if (!wapp->app_icon)
                return;
 
-       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 &&
-           stat(tmp, &dummy) != 0 && errno == ENOENT) {
-               wmessage(_("recreating missing icon '%s'"), tmp);
-               path = wIconStore(wapp->app_icon->icon);
-               if (path)
-                       wfree(path);
-
-               wIconUpdate(wapp->app_icon->icon);
-               wAppIconPaint(wapp->app_icon);
-       }
-
-       /* if the displayed icon was supplied by the client, save the icon */
-       if (!tmp || strstr(tmp, "Library/WindowMaker/CachedPixmaps") != NULL)
-               wAppIconSave(wapp->app_icon);
+       save_app_icon_core(wapp->app_icon);
 }
 
 static WAppIcon *findDockIconFor(WDock * dock, Window main_window)
diff --git a/src/application.c b/src/application.c
index f29e90f..dee6fcc 100644
--- a/src/application.c
+++ b/src/application.c
@@ -77,19 +77,6 @@ WApplication *wApplicationOf(Window window)
        return wapp;
 }
 
-static void extractIcon(WWindow * wwin)
-{
-       char *progname;
-
-       /* Get the application name */
-       progname = GetProgramNameForWindow(wwin->client_win);
-       if (progname) {
-               /* Save the icon path if the application is ".app" */
-               wApplicationExtractDirPackIcon(wwin->screen_ptr, progname, 
wwin->wm_instance, wwin->wm_class);
-               wfree(progname);
-       }
-}
-
 WApplication *wApplicationCreate(WWindow * wwin)
 {
        WScreen *scr = wwin->screen_ptr;
@@ -137,8 +124,6 @@ WApplication *wApplicationCreate(WWindow * wwin)
        wapp->main_window_desc->fake_group = wwin->fake_group;
        wapp->main_window_desc->net_icon_image = 
RRetainImage(wwin->net_icon_image);
 
-       extractIcon(wapp->main_window_desc);
-
        leader = wWindowFor(main_window);
        if (leader)
                leader->main_window = main_window;
-- 
1.7.10

-- 
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/
>From d476a7da5e1b14674e9b62ed864353444830e93f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <[email protected]>
Date: Mon, 18 Jun 2012 11:47:44 +0200
Subject: [PATCH 06/12] extractIcon removed.

The function extractIcon is removed, and their behaviour is moved to
save_app_icon, because this function is called always.

To do that, save_app_icon don't need check if the icon is saved (is
done at wIconStore). The icon now is saved always (if not exists!),
like extractIcon() did it.
---
 src/appicon.c     |   26 +++-----------------------
 src/application.c |   15 ---------------
 2 files changed, 3 insertions(+), 38 deletions(-)

diff --git a/src/appicon.c b/src/appicon.c
index ed4403c..01cdd5d 100644
--- a/src/appicon.c
+++ b/src/appicon.c
@@ -929,34 +929,14 @@ void wApplicationSaveIconPathFor(char *iconPath, char *wm_instance, char *wm_cla
 		UpdateDomainFile(WDWindowAttributes);
 }
 
+/* Save the application icon */
+/* This function is used by normal windows */
 void save_app_icon(WWindow *wwin, WApplication *wapp)
 {
-	char *tmp, *path;
-	struct stat dummy;
-	WScreen *scr = NULL;
-
 	if (!wapp->app_icon)
 		return;
 
-	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 &&
-	    stat(tmp, &dummy) != 0 && errno == ENOENT) {
-		wmessage(_("recreating missing icon '%s'"), tmp);
-		path = wIconStore(wapp->app_icon->icon);
-		if (path)
-			wfree(path);
-
-		wIconUpdate(wapp->app_icon->icon);
-		wAppIconPaint(wapp->app_icon);
-	}
-
-	/* if the displayed icon was supplied by the client, save the icon */
-	if (!tmp || strstr(tmp, "Library/WindowMaker/CachedPixmaps") != NULL)
-		wAppIconSave(wapp->app_icon);
+	save_app_icon_core(wapp->app_icon);
 }
 
 static WAppIcon *findDockIconFor(WDock * dock, Window main_window)
diff --git a/src/application.c b/src/application.c
index f29e90f..dee6fcc 100644
--- a/src/application.c
+++ b/src/application.c
@@ -77,19 +77,6 @@ WApplication *wApplicationOf(Window window)
 	return wapp;
 }
 
-static void extractIcon(WWindow * wwin)
-{
-	char *progname;
-
-	/* Get the application name */
-	progname = GetProgramNameForWindow(wwin->client_win);
-	if (progname) {
-		/* Save the icon path if the application is ".app" */
-		wApplicationExtractDirPackIcon(wwin->screen_ptr, progname, wwin->wm_instance, wwin->wm_class);
-		wfree(progname);
-	}
-}
-
 WApplication *wApplicationCreate(WWindow * wwin)
 {
 	WScreen *scr = wwin->screen_ptr;
@@ -137,8 +124,6 @@ WApplication *wApplicationCreate(WWindow * wwin)
 	wapp->main_window_desc->fake_group = wwin->fake_group;
 	wapp->main_window_desc->net_icon_image = RRetainImage(wwin->net_icon_image);
 
-	extractIcon(wapp->main_window_desc);
-
 	leader = wWindowFor(main_window);
 	if (leader)
 		leader->main_window = main_window;
-- 
1.7.10

Reply via email to