1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-18 20:10:29 +01:00

WPrefs: replaced a few constants by the macro 'wlengthof'

This reduce the risk to miss something in case the array they refer to gets
updated, because with the macro the proper number of element will be
evaluated by the compiler automatically.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS
2014-10-26 19:58:42 +01:00
committed by Carlos R. Mafra
parent 6ac27ba842
commit 4bb93d3dab
4 changed files with 16 additions and 16 deletions

View File

@@ -78,9 +78,9 @@ static void pushAutoDelayButton(WMWidget *w, void *data)
{
_Panel *panel = (_Panel *) data;
int i, j;
for (i = 0; i < 4; i++)
for (i = 0; i < wlengthof(auto_delay); i++)
{
for (j = 0; j < 5; j++)
for (j = 0; j < wlengthof(autoDelayPresetValues); j++)
{
if (w == panel->autoDelayB[i][j])
{
@@ -98,7 +98,7 @@ static void adjustButtonSelectionBasedOnValue(_Panel *panel, int row, const char
if (!value)
return;
for (j = 0; j < 5; j++)
for (j = 0; j < wlengthof(autoDelayPresetValues); j++)
{
int isThatOne = !strcmp(autoDelayPresetValues[j], value);
WMSetButtonSelected(panel->autoDelayB[row][j], isThatOne);
@@ -112,7 +112,7 @@ static void autoDelayChanged(void *observerData, WMNotification *notification)
_Panel *panel = (_Panel *) observerData;
int row;
WMTextField *anAutoDelayT = (WMTextField *) WMGetNotificationObject(notification);
for (row = 0; row < 4; row++)
for (row = 0; row < wlengthof(panel->autoDelayT); row++)
{
if (anAutoDelayT != panel->autoDelayT[row])
{
@@ -188,7 +188,7 @@ static void createPanel(Panel *p)
WMSetLabelText(panel->autoDelayL[i + k * 2], _(auto_delay[i + k * 2].string));
/* WMSetLabelTextAlignment(panel->autoDelayL[i + k * 2], WARight); */
for (j = 0; j < 5; j++)
for (j = 0; j < wlengthof(autoDelayPresetValues); j++)
{
panel->autoDelayB[i + k * 2][j] = WMCreateCustomButton(panel->autoDelayF[k], WBBStateChangeMask);
WMResizeWidget(panel->autoDelayB[i + k * 2][j], 25, 25);
@@ -244,7 +244,7 @@ static void createPanel(Panel *p)
WMMoveWidget(panel->dockF, 390, 10);
WMSetFrameTitle(panel->dockF, _("Dock/Clip/Drawer"));
for (i = 0; i < 3; i++)
for (i = 0; i < wlengthof(dock_config); i++)
{
panel->docksB[i] = WMCreateButton(panel->dockF, WBTToggle);
WMResizeWidget(panel->docksB[i], 56, 56);
@@ -291,7 +291,7 @@ static void createPanel(Panel *p)
static void storeData(_Panel *panel)
{
int i;
for (i = 0; i < 4; i++)
for (i = 0; i < wlengthof(auto_delay); i++)
{
char *str;
@@ -299,7 +299,7 @@ static void storeData(_Panel *panel)
SetStringForKey(str, auto_delay[i].key);
wfree(str);
}
for (i = 0; i < 3; i++)
for (i = 0; i < wlengthof(dock_config); i++)
{
SetBoolForKey(!WMGetButtonSelected(panel->docksB[i]), dock_config[i].disable_key);
}
@@ -309,13 +309,13 @@ static void showData(_Panel *panel)
{
char *value;
int i;
for (i = 0; i < 4; i++)
for (i = 0; i < wlengthof(auto_delay); i++)
{
value = GetStringForKey(auto_delay[i].key);
WMSetTextFieldText(panel->autoDelayT[i], value);
adjustButtonSelectionBasedOnValue(panel, i, value);
}
for (i = 0; i < 3; i++)
for (i = 0; i < wlengthof(dock_config); i++)
{
WMSetButtonSelected(panel->docksB[i], !GetBoolForKey(dock_config[i].disable_key));
}

View File

@@ -804,7 +804,7 @@ static void createPanel(_Panel * p)
{
int i;
for (i = 0; i < 3; i++)
for (i = 0; i < wlengthof(panel->itemPad); i++)
WMUnmapWidget(panel->itemPad[i]);
}
changedItemPad(panel->typeP, panel);

View File

@@ -73,7 +73,7 @@ static void storeData(_Panel * panel)
{
int i;
for (i = 0; i < 5; i++) {
for (i = 0; i < wlengthof(panel->scrB); i++) {
if (WMGetButtonSelected(panel->scrB[i]))
break;
}
@@ -106,7 +106,7 @@ static void createPanel(Panel * p)
buf1 = wmalloc(strlen(SPEED_IMAGE) + 1);
buf2 = wmalloc(strlen(SPEED_IMAGE_S) + 1);
for (i = 0; i < 5; i++) {
for (i = 0; i < wlengthof(panel->scrB); i++) {
panel->scrB[i] = WMCreateCustomButton(panel->scrF, WBBStateChangeMask);
WMResizeWidget(panel->scrB[i], 40, 40);
WMMoveWidget(panel->scrB[i], 15 + (40 * i), 30);

View File

@@ -169,7 +169,7 @@ static void doubleClick(WMWidget * w, void *data)
int i;
char buffer[32];
for (i = 0; i < 5; i++) {
for (i = 0; i < wlengthof(panel->ddelaB); i++) {
if (panel->ddelaB[i] == w)
break;
}
@@ -342,7 +342,7 @@ static void showData(_Panel * panel)
/**/ b = GetIntegerForKey("DoubleClickTime");
/* find best match */
a = -1;
for (i = 0; i < 5; i++) {
for (i = 0; i < wlengthof(panel->ddelaB); i++) {
if (DELAY(i) == b)
a = i;
}
@@ -567,7 +567,7 @@ static void createPanel(Panel * p)
buf1 = wmalloc(strlen(DELAY_ICON) + 2);
buf2 = wmalloc(strlen(DELAY_ICON_S) + 2);
for (i = 0; i < 5; i++) {
for (i = 0; i < wlengthof(panel->ddelaB); i++) {
panel->ddelaB[i] = WMCreateCustomButton(panel->ddelaF, WBBStateChangeMask);
WMResizeWidget(panel->ddelaB[i], 25, 25);
WMMoveWidget(panel->ddelaB[i], 20 + (40 * i), 20);