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

WPrefs: Changed array of strings 'textureOptions' into a struct for explicitness

The parameters for the textures were stored all together in an array
which made its usage error prone; now there a struct to clearly identify
which string is what, so it is clear in the source what's being done.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS
2013-11-10 17:41:12 +01:00
committed by Carlos R. Mafra
parent aa24e862c4
commit d2faac6333

View File

@@ -292,14 +292,18 @@ static char *sampleColors[] = {
"black" "black"
}; };
static char *textureOptions[] = { static const struct {
"FTitleBack", "(solid, black)", "[Focused]", const char *key;
"UTitleBack", "(solid, gray)", "[Unfocused]", const char *default_value;
"PTitleBack", "(solid, \"#616161\")", "[Owner of Focused]", const char *label;
"ResizebarBack", "(solid, gray)", "[Resizebar]", } textureOptions[] = {
"MenuTitleBack", "(solid, black)", "[Menu Title]", { "FTitleBack", "(solid, black)", "[Focused]" },
"MenuTextBack", "(solid, gray)", "[Menu Item]", { "UTitleBack", "(solid, gray)", "[Unfocused]" },
"IconBack", "(solid, gray)", "[Icon]" { "PTitleBack", "(solid, \"#616161\")", "[Owner of Focused]" },
{ "ResizebarBack", "(solid, gray)", "[Resizebar]" },
{ "MenuTitleBack", "(solid, black)", "[Menu Title]" },
{ "MenuTextBack", "(solid, gray)", "[Menu Item]" },
{ "IconBack", "(solid, gray)", "[Icon]" }
}; };
#define RESIZEBAR_BEVEL -1 #define RESIZEBAR_BEVEL -1
@@ -1895,7 +1899,7 @@ static void createPanel(Panel * p)
panel->texturePanel = CreateTexturePanel(panel->parent); panel->texturePanel = CreateTexturePanel(panel->parent);
} }
static void setupTextureFor(WMList * list, const char *key, char *defValue, const char *title, int index) static void setupTextureFor(WMList *list, const char *key, const char *defValue, const char *title, int index)
{ {
WMListItem *item; WMListItem *item;
TextureListItem *titem; TextureListItem *titem;
@@ -1960,9 +1964,9 @@ static void showData(_Panel * panel)
} }
changeColorPage(panel->colP, panel); changeColorPage(panel->colP, panel);
for (i = 0; i < sizeof(textureOptions) / (3 * sizeof(char *)); i++) { for (i = 0; i < wlengthof(textureOptions); i++) {
setupTextureFor(panel->texLs, textureOptions[i * 3], setupTextureFor(panel->texLs, textureOptions[i].key,
textureOptions[i * 3 + 1], textureOptions[i * 3 + 2], i); textureOptions[i].default_value, textureOptions[i].label, i);
panel->textureIndex[i] = i; panel->textureIndex[i] = i;
} }
updatePreviewBox(panel, EVERYTHING); updatePreviewBox(panel, EVERYTHING);
@@ -1977,10 +1981,10 @@ static void storeData(_Panel * panel)
WMListItem *item; WMListItem *item;
int i; int i;
for (i = 0; i < sizeof(textureOptions) / (sizeof(char *) * 3); i++) { for (i = 0; i < wlengthof(textureOptions); i++) {
item = WMGetListItem(panel->texLs, panel->textureIndex[i]); item = WMGetListItem(panel->texLs, panel->textureIndex[i]);
titem = (TextureListItem *) item->clientData; titem = (TextureListItem *) item->clientData;
SetObjectForKey(titem->prop, textureOptions[i * 3]); SetObjectForKey(titem->prop, textureOptions[i].key);
} }
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {