[PATCH] Revert "wmaker: fix clearing of window attribute that was not saved properly"

"Carlos R. Mafra" <[email protected]>
Newsgroups gmane.compw.window-managers.windowmaker.devel
Message-ID <[email protected]>
Unfortunately the fix implemented in the patch messes up with the
interface and makes the check buttons behave inconsistently (read-only
in the attribute window and fully functional everywhere else).

From e97fb5cfa5a57d939fa388169120bc6652213979 Mon Sep 17 00:00:00 2001
From: "Carlos R. Mafra" <[email protected]>
Date: Tue, 7 Jul 2015 14:36:13 -0300
Subject: [PATCH] Revert "wmaker: fix clearing of window attribute that was not
 saved properly"

This reverts commit 14d1d3f141bc6740e7c8704f7883ed9c56fc45d5.

Conflicts:
	src/winspector.c

Signed-off-by: Carlos R. Mafra <[email protected]>
---
 src/winspector.c | 61 +++++++++-----------------------------------------------
 1 file changed, 9 insertions(+), 52 deletions(-)

diff --git a/src/winspector.c b/src/winspector.c
index 3d701e5..0d6d57d 100644
--- a/src/winspector.c
+++ b/src/winspector.c
@@ -203,7 +203,6 @@ typedef struct InspectorPanel {
 
 	/* second page. attributes */
 	WMFrame *attrFrm;
-	WMButton *attrClient[sizeof(window_attribute) / sizeof(window_attribute[0])];
 	WMButton *attrChk[sizeof(window_attribute) / sizeof(window_attribute[0])];
 
 	/* 3rd page. more attributes */
@@ -643,27 +642,8 @@ static void saveSettings(WMWidget *button, void *client_data)
 
 	/* Attributes... --> Window Attributes */
 	for (i = 0; i < wlengthof(window_attribute); i++) {
-		WMPropList *old_value;
-		int state;
-
-		old_value = WMGetFromPLDictionary(winDic, pl_attribute[i]);
-		state = WMGetButtonSelected(panel->attrChk[i]);
-		if (state > 0) {
-			if ((old_value == NULL) || !getBool(old_value)) {
-				WMPutInPLDictionary(winDic, pl_attribute[i], Yes);
-				different |= 1;
-			}
-		} else if (state == 0) {
-			if ((old_value == NULL) || getBool(old_value)) {
-				WMPutInPLDictionary(winDic, pl_attribute[i], No);
-				different |= 1;
-			}
-		} else {	/* (state < 0) */
-			if (old_value != NULL) {
-				WMRemoveFromPLDictionary(winDic, pl_attribute[i]);
-				different |= 1;
-			}
-		}
+		value = (WMGetButtonSelected(panel->attrChk[i]) != 0) ? Yes : No;
+		different |= insertAttribute(dict, winDic, pl_attribute[i], value, flags);
 	}
 
 	/* Attributes... --> Advanced Options */
@@ -746,19 +726,12 @@ static void applySettings(WMWidget *button, void *client_data)
 
 	/* Attributes... --> Window Attributes */
 	for (i = 0; i < wlengthof(window_attribute); i++) {
-		int state;
-
-		state = WMGetButtonSelected(panel->attrChk[i]);
-
-		if (state > 0)
+		if (WMGetButtonSelected(panel->attrChk[i]))
 			set_attr_flag(&wwin->user_flags, &window_attribute[i].flag);
 		else
 			clear_attr_flag(&wwin->user_flags, &window_attribute[i].flag);
 
-		if (state < 0)
-			clear_attr_flag(&wwin->defined_user_flags, &window_attribute[i].flag);
-		else
-			set_attr_flag(&wwin->defined_user_flags, &window_attribute[i].flag);
+		set_attr_flag(&wwin->defined_user_flags, &window_attribute[i].flag);
 	}
 
 	/* Attributes... --> Advanced Options */
@@ -931,7 +904,7 @@ static void revertSettings(WMWidget *button, void *client_data)
 		if (is_userdef)
 			flag = get_attr_flag(&wwin->user_flags, &window_attribute[i].flag);
 		else
-			flag = -1;
+			flag = get_attr_flag(&wwin->client_flags, &window_attribute[i].flag);
 
 		WMSetButtonSelected(panel->attrChk[i], flag);
 	}
@@ -1342,31 +1315,15 @@ static void create_tab_window_attributes(WWindow *wwin, InspectorPanel *panel, i
 	for (i = 0; i < wlengthof(window_attribute); i++) {
 		int is_userdef, flag;
 
-		/* Read-only button to display the state requested by the application */
-		flag = get_attr_flag(&wwin->client_flags, &window_attribute[i].flag);
-
-		panel->attrClient[i] = WMCreateSwitchButton(panel->attrFrm);
-		WMMoveWidget(panel->attrClient[i], 10, 20 * (i + 1));
-		WMResizeWidget(panel->attrClient[i], 20, 20);
-		WMSetButtonText(panel->attrClient[i], NULL);
-		WMSetButtonSelected(panel->attrClient[i], flag);
-		WMSetButtonEnabled(panel->attrClient[i], False);
-
-		WMSetBalloonTextForView(_("Shows the state that was asked by the application.\n"
-		                          "You can use the checkbox on the right to change this setting;\n"
-		                          "when it is grayed it means to follow application's choice."),
-		                        WMWidgetView(panel->attrClient[i]));
-
-		/* Button to let user override this choice */
 		is_userdef = get_attr_flag(&wwin->defined_user_flags, &window_attribute[i].flag);
 		if (is_userdef)
 			flag = get_attr_flag(&wwin->user_flags, &window_attribute[i].flag);
 		else
-			flag = -1;
+			flag = get_attr_flag(&wwin->client_flags, &window_attribute[i].flag);
 
-		panel->attrChk[i] = WMCreateButton(panel->attrFrm, WBTTriState);
-		WMMoveWidget(panel->attrChk[i], 30, 20 * (i + 1));
-		WMResizeWidget(panel->attrChk[i], frame_width - 45, 20);
+		panel->attrChk[i] = WMCreateSwitchButton(panel->attrFrm);
+		WMMoveWidget(panel->attrChk[i], 10, 20 * (i + 1));
+		WMResizeWidget(panel->attrChk[i], frame_width - 15, 20);
 		WMSetButtonSelected(panel->attrChk[i], flag);
 		WMSetButtonText(panel->attrChk[i], _(window_attribute[i].caption));
 
-- 
2.1.4


-- 
To unsubscribe, send mail to [email protected].
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.