WPrefs: Fixed handling of options which default to true
authorBALATON Zoltan <balaton@eik.bme.hu>
Fri, 16 Nov 2012 21:07:47 +0000 (16 22:07 +0100)
committerCarlos R. Mafra <crmafra@gmail.com>
Sat, 17 Nov 2012 19:32:11 +0000 (17 20:32 +0100)
Two problems caused Boolean options which default to true to be shown
incorrectly when the option was not already present in the defaults database.
First a typo (Enabled instead of Selected) caused the switch button to stay
off then because GetBoolForKey key returns False also when the option
is not set it would have been turned off while it should stay on to
reflect the default value of the option.

WPrefs.app/Expert.c
WPrefs.app/Preferences.c

index 177bbd8..ee8d625 100644 (file)
@@ -53,10 +53,13 @@ static void showData(_Panel * panel)
        WMSetButtonSelected(panel->swi[3], GetBoolForKey("UseSaveUnders"));
        WMSetButtonSelected(panel->swi[4], GetBoolForKey("DontConfirmKill"));
        WMSetButtonSelected(panel->swi[5], GetBoolForKey("DisableBlinking"));
-       WMSetButtonSelected(panel->swi[6], GetBoolForKey("AntialiasedText"));
+       if (GetStringForKey("AntialiasedText"))
+               WMSetButtonSelected(panel->swi[6], GetBoolForKey("AntialiasedText"));
        WMSetButtonSelected(panel->swi[7], GetBoolForKey("CycleActiveHeadOnly"));
-       WMSetButtonSelected(panel->swi[8], GetBoolForKey("ShowClipTitle"));
-       WMSetButtonSelected(panel->swi[9], GetBoolForKey("HighlightActiveApp"));
+       if (GetStringForKey("ShowClipTitle"))
+               WMSetButtonSelected(panel->swi[8], GetBoolForKey("ShowClipTitle"));
+       if (GetStringForKey("HighlightActiveApp"))
+               WMSetButtonSelected(panel->swi[9], GetBoolForKey("HighlightActiveApp"));
 #ifdef XKB_MODELOCK
        WMSetButtonSelected(panel->swi[10], GetBoolForKey("KbdModeLock"));
 #endif /* XKB_MODELOCK */
@@ -104,10 +107,10 @@ static void createPanel(Panel * p)
        WMSetButtonText(panel->swi[10], _("Enable keyboard language switch button in window titlebars."));
 #endif /* XKB_MODELOCK */
 
-       /* If the item is default true, enable the button here */
-       WMSetButtonEnabled(panel->swi[6], True);
-       WMSetButtonEnabled(panel->swi[8], True);
-       WMSetButtonEnabled(panel->swi[9], True);
+       /* If the item is default true, switch it on here */
+       WMSetButtonSelected(panel->swi[6], True);
+       WMSetButtonSelected(panel->swi[8], True);
+       WMSetButtonSelected(panel->swi[9], True);
 
        WMMapSubwidgets(panel->box);
        WMSetScrollViewContentView(sv, WMWidgetView(f));
index 8c0ef2c..9399023 100644 (file)
@@ -127,7 +127,8 @@ static void showData(_Panel * panel)
        }
 
        WMSetButtonSelected(panel->bounceB, GetBoolForKey("DoNotMakeAppIconsBounce"));
-       WMSetButtonSelected(panel->bounceUrgB, GetBoolForKey("BounceAppIconsWhenUrgent"));
+       if (GetStringForKey("BounceAppIconsWhenUrgent"))
+               WMSetButtonSelected(panel->bounceUrgB, GetBoolForKey("BounceAppIconsWhenUrgent"));
        WMSetButtonSelected(panel->bounceRaisB, GetBoolForKey("RaiseAppIconsWhenBouncing"));
 
        WMSetButtonSelected(panel->ballB[0], GetBoolForKey("WindowTitleBalloons"));
@@ -278,7 +279,7 @@ static void createPanel(Panel * p)
        WMResizeWidget(panel->bounceUrgB, 210, 30);
        WMMoveWidget(panel->bounceUrgB, 15, 39);
        WMSetButtonText(panel->bounceUrgB, _("Bounce AppIcon when the application wants attention."));
-       WMSetButtonEnabled(panel->bounceUrgB, True); /* defaults to true */
+       WMSetButtonSelected(panel->bounceUrgB, True); /* defaults to true */
 
        panel->bounceRaisB = WMCreateSwitchButton(panel->optF);
        WMResizeWidget(panel->bounceRaisB, 210, 25);