[PATCH 2/3] WPrefs: fix conversion of old "Apercu" setting to the new keywords

Christophe CURIS <[email protected]>
Newsgroups gmane.compw.window-managers.windowmaker.devel
Message-ID <[email protected]>
As pointed by Josip, the code for loading the legacy setting keywords for
the Minipreview feature did not update correctly the configuration:

 - if the setting used a size as a multiple of icon size, this was
understood as the minimum pixel size, which meant here disabling the
feature. The code is now consistent with what Window Maker does;

 - if the old keyword were found, they were loaded but not removed from the
database after creating the new ones, which is a source of problem as
Window Maker assumes that the presence of the legacy keywords means they
are to be taken in consideration.

Reported-by: Josip Deanovic <[email protected]>
Signed-off-by: Christophe CURIS <[email protected]>
---
 WPrefs.app/Icons.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/WPrefs.app/Icons.c b/WPrefs.app/Icons.c
index 4e7f237..e68da56 100644
--- a/WPrefs.app/Icons.c
+++ b/WPrefs.app/Icons.c
@@ -60,6 +60,8 @@ typedef struct _Panel {
 
 	CallbackRec callbacks;
 
+	Bool have_legacy_apercu;
+
 	WMWidget *parent;
 
 	WMFrame *posF;
@@ -206,6 +208,7 @@ static void showData(_Panel * panel)
 	 * new settings
 	 * This hack should be kept for at least 2 years, that means >= 2017.
 	 */
+	panel->have_legacy_apercu = False;
 	str = GetStringForKey("MiniwindowPreviewBalloons");
 	if (str != NULL) {
 		/* New names found, use them in priority */
@@ -221,9 +224,18 @@ static void showData(_Panel * panel)
 		/* No new names, try the legacy names */
 		b = GetBoolForKey("MiniwindowApercuBalloons");
 		if (b) {
+			panel->have_legacy_apercu = True;
 			i = GetIntegerForKey("ApercuSize");
+
+			/*
+			 * In the beginning, the option was coded as a multiple of the icon
+			 * size; then it was converted to pixel size
+			 */
+			if (i < 24)
+				i *= GetIntegerForKey("IconSize");
+
 			if (i <= minipreview_minimum_size)
-				i = minipreview_minimum_size;
+				i = minipreview_minimum_size + 1;	/* +1 to not display as "off" */
 		} else {
 			i = minipreview_minimum_size;
 		}
@@ -466,6 +478,10 @@ static void storeData(_Panel * panel)
 		}
 		SetIntegerForKey(i, "MiniPreviewSize");
 	}
+	if (panel->have_legacy_apercu) {
+		RemoveObjectForKey("MiniwindowApercuBalloons");
+		RemoveObjectForKey("ApercuSize");
+	}
 
 	for (i = 0; i < wlengthof(icon_animation); i++) {
 		if (WMGetButtonSelected(panel->animB[i])) {
-- 
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.