mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 20:38:08 +01:00
WPrefs: Use the macro 'wlengthof' to get the number of element in an array
The new macro 'wlengthof' from WUtil makes code easier to read than the previous [sizeof() / sizeof([0]) ] construct. Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
committed by
Carlos R. Mafra
parent
be022d9623
commit
01c7390be1
@@ -1111,7 +1111,7 @@ static void previewClick(XEvent * event, void *clientData)
|
||||
|
||||
switch (panel->oldTabItem) {
|
||||
case 0:
|
||||
for (i = 0; i < sizeof(previewPositions) / sizeof(previewPositions[0]); i++) {
|
||||
for (i = 0; i < wlengthof(previewPositions); i++) {
|
||||
if (event->xbutton.x >= previewPositions[i].pos.x
|
||||
&& event->xbutton.y >= previewPositions[i].pos.y
|
||||
&& event->xbutton.x < previewPositions[i].pos.x
|
||||
|
||||
@@ -115,11 +115,11 @@ static void createPanel(Panel * p)
|
||||
WMSetScrollViewHasHorizontalScroller(sv, False);
|
||||
|
||||
f = WMCreateFrame(panel->box);
|
||||
WMResizeWidget(f, 495, (sizeof(expert_options) / sizeof(expert_options[0])) * 25 + 8);
|
||||
WMResizeWidget(f, 495, wlengthof(expert_options) * 25 + 8);
|
||||
WMSetFrameRelief(f, WRFlat);
|
||||
|
||||
udb = WMGetStandardUserDefaults();
|
||||
for (i = 0; i < sizeof(expert_options) / sizeof(expert_options[0]); i++) {
|
||||
for (i = 0; i < wlengthof(expert_options); i++) {
|
||||
panel->swi[i] = WMCreateSwitchButton(f);
|
||||
WMResizeWidget(panel->swi[i], FRAME_WIDTH - 40, 25);
|
||||
WMMoveWidget(panel->swi[i], 5, 5 + i * 25);
|
||||
@@ -152,7 +152,7 @@ static void storeDefaults(_Panel * panel)
|
||||
WMUserDefaults *udb = WMGetStandardUserDefaults();
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sizeof(expert_options) / sizeof(expert_options[0]); i++) {
|
||||
for (i = 0; i < wlengthof(expert_options); i++) {
|
||||
switch (expert_options[i].class) {
|
||||
case OPTION_WMAKER:
|
||||
SetBoolForKey(WMGetButtonSelected(panel->swi[i]), expert_options[i].op_name);
|
||||
|
||||
@@ -509,7 +509,7 @@ static void createPanel(Panel * p)
|
||||
WMSetListUserDrawProc(panel->actLs, paintItem);
|
||||
WMHangData(panel->actLs, panel);
|
||||
|
||||
for (i = 0; i < sizeof(keyOptions)/sizeof(keyOptions[0]); i++) {
|
||||
for (i = 0; i < wlengthof(keyOptions); i++) {
|
||||
WMAddListItem(panel->actLs, _(keyOptions[i].title));
|
||||
}
|
||||
WMSetListAction(panel->actLs, listClick, panel);
|
||||
|
||||
@@ -613,13 +613,13 @@ static void createPanel(Panel * p)
|
||||
WMResizeWidget(panel->wheelP, 135, 20);
|
||||
WMMoveWidget(panel->wheelP, 95, 129);
|
||||
|
||||
for (i = 0; i < sizeof(buttonActions) / sizeof(buttonActions[0]); i++) {
|
||||
for (i = 0; i < wlengthof(buttonActions); i++) {
|
||||
WMAddPopUpButtonItem(panel->button1P, buttonActions[i]);
|
||||
WMAddPopUpButtonItem(panel->button2P, buttonActions[i]);
|
||||
WMAddPopUpButtonItem(panel->button3P, buttonActions[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof(wheelActions) / sizeof(wheelActions[0]); i++) {
|
||||
for (i = 0; i < wlengthof(wheelActions); i++) {
|
||||
WMAddPopUpButtonItem(panel->wheelP, wheelActions[i]);
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ static void showData(_Panel * panel)
|
||||
str = "center";
|
||||
|
||||
idx = 1; /* center */
|
||||
for (i = 0; i < sizeof(WSNamePositions) / sizeof(WSNamePositions[0]); i++) {
|
||||
for (i = 0; i < wlengthof(WSNamePositions); i++) {
|
||||
if (strcasecmp(WSNamePositions[i], str) == 0) {
|
||||
idx = i;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user