From 39181154abedb412a55c13402af11d44f083699e Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sat, 17 May 2014 16:43:22 +0200 Subject: [PATCH] WINGs: changed use of 'if' on panel->rgbState into a switch 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 --- WINGs/wcolorpanel.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/WINGs/wcolorpanel.c b/WINGs/wcolorpanel.c index 63892c46..579fded7 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; } }