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

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

The parameters for the theme colors 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 the source is clearer on 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:11 +01:00
committed by Carlos R. Mafra
parent db9e002ecf
commit aa24e862c4

View File

@@ -325,19 +325,22 @@ static char *textureOptions[] = {
#define CLIP_COL (1<<10) #define CLIP_COL (1<<10)
#define CCLIP_COL (1<<11) #define CCLIP_COL (1<<11)
static char *colorOptions[] = { static const struct {
"FTitleColor", "white", const char *key;
"UTitleColor", "black", const char *default_value;
"PTitleColor", "white", } colorOptions[] = {
"MenuTitleColor", "white", { "FTitleColor", "white" },
"MenuTextColor", "black", { "UTitleColor", "black" },
"MenuDisabledColor", "#616161", { "PTitleColor", "white" },
"HighlightColor", "white", { "MenuTitleColor", "white" },
"HighlightTextColor", "black", { "MenuTextColor", "black" },
"IconTitleColor", "white", { "MenuDisabledColor", "#616161" },
"IconTitleBack", "black", { "HighlightColor", "white" },
"ClipTitleColor", "black", { "HighlightTextColor", "black" },
"CClipTitleColor", "#454045" { "IconTitleColor", "white" },
{ "IconTitleBack", "black" },
{ "ClipTitleColor", "black" },
{ "CClipTitleColor", "#454045" }
}; };
static WMRect previewPositions[] = { static WMRect previewPositions[] = {
@@ -1922,7 +1925,7 @@ static void setupTextureFor(WMList * list, const char *key, char *defValue, cons
static void showData(_Panel * panel) static void showData(_Panel * panel)
{ {
int i; int i;
char *str; const char *str;
str = GetStringForKey("MenuStyle"); str = GetStringForKey("MenuStyle");
if (str && strcasecmp(str, "flat") == 0) { if (str && strcasecmp(str, "flat") == 0) {
@@ -1942,12 +1945,12 @@ static void showData(_Panel * panel)
panel->titleAlignment = WACenter; panel->titleAlignment = WACenter;
} }
for (i = 0; i < sizeof(colorOptions) / (2 * sizeof(char *)); i++) { for (i = 0; i < wlengthof(colorOptions); i++) {
WMColor *color; WMColor *color;
str = GetStringForKey(colorOptions[i * 2]); str = GetStringForKey(colorOptions[i].key);
if (!str) if (!str)
str = colorOptions[i * 2 + 1]; str = colorOptions[i].default_value;
if (!(color = WMCreateNamedColor(WMWidgetScreen(panel->box), str, False))) { if (!(color = WMCreateNamedColor(WMWidgetScreen(panel->box), str, False))) {
color = WMCreateNamedColor(WMWidgetScreen(panel->box), "#000000", False); color = WMCreateNamedColor(WMWidgetScreen(panel->box), "#000000", False);
@@ -1986,7 +1989,7 @@ static void storeData(_Panel * panel)
str = WMGetColorRGBDescription(panel->colors[i]); str = WMGetColorRGBDescription(panel->colors[i]);
if (str) { if (str) {
SetStringForKey(str, colorOptions[i * 2]); SetStringForKey(str, colorOptions[i].key);
wfree(str); wfree(str);
} }
} }