From: Christophe CURIS <[email protected]>

This allow compiler to raise a warning in case a new value would be added
to the enum; it also change order in the check so that WMGetButtonSelected
will be called only once, only for the case of interest.

Signed-off-by: Christophe CURIS <[email protected]>
---
 WINGs/wcolorpanel.c | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/WINGs/wcolorpanel.c b/WINGs/wcolorpanel.c
index 63892c4..579fded 100644
--- a/WINGs/wcolorpanel.c
+++ b/WINGs/wcolorpanel.c
@@ -2480,19 +2480,26 @@ static void rgbDecToHex(WMWidget *w, void *data)
 
        (void) w;
 
-       if (WMGetButtonSelected(panel->rgbDecB) && panel->rgbState == RGBhex) {
-               WMSetLabelText(panel->rgbMaxL, "255");
-               WMRedisplayWidget(panel->rgbMaxL);
-               value = rgbCharToInt(panel);
-               panel->rgbState = RGBdec;
-               rgbIntToChar(panel, value);
-       }
-       if (WMGetButtonSelected(panel->rgbHexB) && panel->rgbState == RGBdec) {
-               WMSetLabelText(panel->rgbMaxL, "FF");
-               WMRedisplayWidget(panel->rgbMaxL);
-               value = rgbCharToInt(panel);
-               panel->rgbState = RGBhex;
-               rgbIntToChar(panel, value);
+       switch (panel->rgbState) {
+       case RGBhex:
+               if (WMGetButtonSelected(panel->rgbDecB)) {
+                       WMSetLabelText(panel->rgbMaxL, "255");
+                       WMRedisplayWidget(panel->rgbMaxL);
+                       value = rgbCharToInt(panel);
+                       panel->rgbState = RGBdec;
+                       rgbIntToChar(panel, value);
+               }
+               break;
+
+       case RGBdec:
+               if (WMGetButtonSelected(panel->rgbHexB)) {
+                       WMSetLabelText(panel->rgbMaxL, "FF");
+                       WMRedisplayWidget(panel->rgbMaxL);
+                       value = rgbCharToInt(panel);
+                       panel->rgbState = RGBhex;
+                       rgbIntToChar(panel, value);
+               }
+               break;
        }
 }
 
-- 
1.9.2


-- 
To unsubscribe, send mail to [email protected].

Reply via email to