>From 244671a650bae1be4d2b12d0ecc308c63b08783d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <k...@kix.es>
Date: Wed, 28 Nov 2012 23:56:19 +0100
Subject: [PATCH 3/4] 3 Save iconpath if icon will be used

This patch avoid to save the icon name in the configuration file
if the flag "Ignore client suplied icon" is not selected.

First, when winspector try to show the icon to the user, mustn't search
the default icon. It should use the specific icon or the icon provided
by the client.

When we click in "save Settings", the function saveSettings reads the icon
specified by the user in the text box. If the checkbox "Ignore client supplied
icon" is not selected, then saves the icon too.

Using this behaviour we never recover the initial position (no icon selected,
no ignore client supplied icon flag set). This patch recovers the initial
state of the icon options.

When the user unset the ignore client the filename provided is not saved in
the configuration file. Now, the configuration is like the initial status.
If the user checks the flag and set the file to use as icon, the file is used.
---
 src/winspector.c |   40 +++++++++++++++++++++++++---------------
 1 file changed, 25 insertions(+), 15 deletions(-)

diff --git a/src/winspector.c b/src/winspector.c
index 543b764..239f7f6 100644
--- a/src/winspector.c
+++ b/src/winspector.c
@@ -314,8 +314,8 @@ static int showIconFor(WMScreen *scrPtr, InspectorPanel 
*panel, char *wm_instanc
                        file = NULL;
                }
        } else {
-               /* Get the application icon, default included */
-               db_icon = wDefaultGetIconFile(wm_instance, wm_class, True);
+               /* Get the application icon, default NOT included */
+               db_icon = wDefaultGetIconFile(wm_instance, wm_class, False);
                if (db_icon != NULL)
                        file = wstrdup(db_icon);
        }
@@ -433,7 +433,7 @@ static void saveSettings(WMButton *button, InspectorPanel 
*panel)
        WWindow *wwin = panel->inspected;
        WDDomain *db = WDWindowAttributes;
        WMPropList *dict = NULL;
-       WMPropList *winDic, *appDic, *value, *key = NULL, *key2;
+       WMPropList *winDic, *appDic, *value, *value1, *key = NULL, *key2;
        char *icon_file, *buf1, *buf2;
        int flags = 0, i = 0, different = 0, different2 = 0;
 
@@ -475,16 +475,29 @@ static void saveSettings(WMButton *button, InspectorPanel 
*panel)
        winDic = WMCreatePLDictionary(NULL, NULL);
        appDic = WMCreatePLDictionary(NULL, NULL);
 
-       /* Update icon for window */
-       icon_file = WMGetTextFieldText(panel->fileText);
-       if (icon_file) {
-               if (icon_file[0] != 0) {
-                       value = WMCreatePLString(icon_file);
-                       different |= insertAttribute(dict, winDic, AIcon, 
value, flags);
-                       different2 |= insertAttribute(dict, appDic, AIcon, 
value, flags);
-                       WMReleasePropList(value);
+       /* If the "Ignore client suplied icon is not selected" flag was not set,
+        * then, don't save the icon filename. If saved, the application will 
use
+        * that icon, even the flag is not set. */
+       if (WMGetButtonSelected(panel->alwChk) != 0) {
+               /* Update icon for window */
+               icon_file = WMGetTextFieldText(panel->fileText);
+               if (icon_file) {
+                       if (icon_file[0] != 0) {
+                               value = WMCreatePLString(icon_file);
+                               different |= insertAttribute(dict, winDic, 
AIcon, value, flags);
+                               different2 |= insertAttribute(dict, appDic, 
AIcon, value, flags);
+                               WMReleasePropList(value);
+
+                               /* Set the ckeck for AAlwaysUserIcon only if 
icon_file exists */
+                               buf1 = wmalloc(4);
+                               snprintf(buf1, 4, "%s", 
(WMGetButtonSelected(panel->alwChk) != 0) ? "Yes" : "No");
+                               value1 = WMCreatePLString(buf1);
+                               different |= insertAttribute(dict, winDic, 
AAlwaysUserIcon, value1, flags);
+                               WMReleasePropList(value1);
+                               wfree(buf1);
+                       }
+                       wfree(icon_file);
                }
-               wfree(icon_file);
        }
 
        i = WMGetPopUpButtonSelectedItem(panel->wsP) - 1;
@@ -496,9 +509,6 @@ static void saveSettings(WMButton *button, InspectorPanel 
*panel)
 
        flags |= IS_BOOLEAN;
 
-       value = (WMGetButtonSelected(panel->alwChk) != 0) ? Yes : No;
-       different |= insertAttribute(dict, winDic, AAlwaysUserIcon, value, 
flags);
-
        value = (WMGetButtonSelected(panel->attrChk[0]) != 0) ? Yes : No;
        different |= insertAttribute(dict, winDic, ANoTitlebar, value, flags);
 
-- 
1.7.10.4

>From 244671a650bae1be4d2b12d0ecc308c63b08783d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)"?= <k...@kix.es>
Date: Wed, 28 Nov 2012 23:56:19 +0100
Subject: [PATCH 3/4] 3 Save iconpath if icon will be used

This patch avoid to save the icon name in the configuration file
if the flag "Ignore client suplied icon" is not selected.

First, when winspector try to show the icon to the user, mustn't search
the default icon. It should use the specific icon or the icon provided
by the client.

When we click in "save Settings", the function saveSettings reads the icon
specified by the user in the text box. If the checkbox "Ignore client supplied
icon" is not selected, then saves the icon too.

Using this behaviour we never recover the initial position (no icon selected,
no ignore client supplied icon flag set). This patch recovers the initial
state of the icon options.

When the user unset the ignore client the filename provided is not saved in
the configuration file. Now, the configuration is like the initial status.
If the user checks the flag and set the file to use as icon, the file is used.
---
 src/winspector.c |   40 +++++++++++++++++++++++++---------------
 1 file changed, 25 insertions(+), 15 deletions(-)

diff --git a/src/winspector.c b/src/winspector.c
index 543b764..239f7f6 100644
--- a/src/winspector.c
+++ b/src/winspector.c
@@ -314,8 +314,8 @@ static int showIconFor(WMScreen *scrPtr, InspectorPanel *panel, char *wm_instanc
 			file = NULL;
 		}
 	} else {
-		/* Get the application icon, default included */
-		db_icon = wDefaultGetIconFile(wm_instance, wm_class, True);
+		/* Get the application icon, default NOT included */
+		db_icon = wDefaultGetIconFile(wm_instance, wm_class, False);
 		if (db_icon != NULL)
 			file = wstrdup(db_icon);
 	}
@@ -433,7 +433,7 @@ static void saveSettings(WMButton *button, InspectorPanel *panel)
 	WWindow *wwin = panel->inspected;
 	WDDomain *db = WDWindowAttributes;
 	WMPropList *dict = NULL;
-	WMPropList *winDic, *appDic, *value, *key = NULL, *key2;
+	WMPropList *winDic, *appDic, *value, *value1, *key = NULL, *key2;
 	char *icon_file, *buf1, *buf2;
 	int flags = 0, i = 0, different = 0, different2 = 0;
 
@@ -475,16 +475,29 @@ static void saveSettings(WMButton *button, InspectorPanel *panel)
 	winDic = WMCreatePLDictionary(NULL, NULL);
 	appDic = WMCreatePLDictionary(NULL, NULL);
 
-	/* Update icon for window */
-	icon_file = WMGetTextFieldText(panel->fileText);
-	if (icon_file) {
-		if (icon_file[0] != 0) {
-			value = WMCreatePLString(icon_file);
-			different |= insertAttribute(dict, winDic, AIcon, value, flags);
-			different2 |= insertAttribute(dict, appDic, AIcon, value, flags);
-			WMReleasePropList(value);
+	/* If the "Ignore client suplied icon is not selected" flag was not set,
+	 * then, don't save the icon filename. If saved, the application will use
+	 * that icon, even the flag is not set. */
+	if (WMGetButtonSelected(panel->alwChk) != 0) {
+		/* Update icon for window */
+		icon_file = WMGetTextFieldText(panel->fileText);
+		if (icon_file) {
+			if (icon_file[0] != 0) {
+				value = WMCreatePLString(icon_file);
+				different |= insertAttribute(dict, winDic, AIcon, value, flags);
+				different2 |= insertAttribute(dict, appDic, AIcon, value, flags);
+				WMReleasePropList(value);
+
+				/* Set the ckeck for AAlwaysUserIcon only if icon_file exists */
+				buf1 = wmalloc(4);
+				snprintf(buf1, 4, "%s", (WMGetButtonSelected(panel->alwChk) != 0) ? "Yes" : "No");
+				value1 = WMCreatePLString(buf1);
+				different |= insertAttribute(dict, winDic, AAlwaysUserIcon, value1, flags);
+				WMReleasePropList(value1);
+				wfree(buf1);
+			}
+			wfree(icon_file);
 		}
-		wfree(icon_file);
 	}
 
 	i = WMGetPopUpButtonSelectedItem(panel->wsP) - 1;
@@ -496,9 +509,6 @@ static void saveSettings(WMButton *button, InspectorPanel *panel)
 
 	flags |= IS_BOOLEAN;
 
-	value = (WMGetButtonSelected(panel->alwChk) != 0) ? Yes : No;
-	different |= insertAttribute(dict, winDic, AAlwaysUserIcon, value, flags);
-
 	value = (WMGetButtonSelected(panel->attrChk[0]) != 0) ? Yes : No;
 	different |= insertAttribute(dict, winDic, ANoTitlebar, value, flags);
 
-- 
1.7.10.4

Reply via email to