wmail: added option index enum and used designated initializers for options.
This commit is contained in:
parent
7e3cb9cbe4
commit
e27a0f4001
|
@ -139,37 +139,144 @@ static XFontStruct *tickerFS;
|
||||||
static name_t *names;
|
static name_t *names;
|
||||||
static name_t *curTickerName;
|
static name_t *curTickerName;
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
OPT_INDEX_DISPLAY,
|
||||||
|
OPT_INDEX_COMMAND,
|
||||||
|
OPT_INDEX_INTERVAL,
|
||||||
|
OPT_INDEX_FAMILY_NAME,
|
||||||
|
OPT_INDEX_FRAMES,
|
||||||
|
OPT_INDEX_SHORT_NAME,
|
||||||
|
OPT_INDEX_SYMBOL_COLOR,
|
||||||
|
OPT_INDEX_FONT_COLOR,
|
||||||
|
OPT_INDEX_BACK_COLOR,
|
||||||
|
OPT_INDEX_OFF_COLOR,
|
||||||
|
OPT_INDEX_BACKGROUND,
|
||||||
|
OPT_INDEX_NO_SHAPE,
|
||||||
|
OPT_INDEX_NEW,
|
||||||
|
OPT_INDEX_MAILBOX,
|
||||||
|
OPT_INDEX_EXECUTE,
|
||||||
|
OPT_INDEX_STATUS_FIELD,
|
||||||
|
OPT_INDEX_READ_STATUS,
|
||||||
|
OPT_INDEX_TICKER_FONT
|
||||||
|
};
|
||||||
|
|
||||||
static DAProgramOption options[] = {
|
static DAProgramOption options[] = {
|
||||||
{"-display", NULL, "display to use", DOString, False, {&config.display}},
|
[OPT_INDEX_DISPLAY] = {
|
||||||
{"-c", "--command", "cmd to run on btn-click (\"xterm -e mail\" is default)",
|
.shortForm = "-display",
|
||||||
DOString, False, {&config.runCmd} },
|
.description = "display to use",
|
||||||
{"-i", "--intervall",
|
.type = DOString,
|
||||||
"number of secs between mail-status updates (1 is default)", DONatural,
|
.value = { .string = &config.display }
|
||||||
False, {&config.checkInterval} },
|
},
|
||||||
{"-f", "--familyname", "tickers the family-name if available", DONone,
|
[OPT_INDEX_COMMAND] = {
|
||||||
False, {NULL} },
|
.shortForm = "-c",
|
||||||
{"-fps", "--frames", "ticker frames per second", DONatural,
|
.longForm = "--command",
|
||||||
False, {&config.fps} },
|
.description = "cmd to run on btn-click (\"xterm -e mail\" is default)",
|
||||||
{"-s", "--shortname", "tickers the nickname (all before the '@')", DONone,
|
.type = DOString,
|
||||||
False, {NULL} },
|
.value = { .string = &config.runCmd }
|
||||||
{"-sc", "--symbolcolor", "symbol color-name",
|
},
|
||||||
DOString, False, {&config.symbolColor} },
|
[OPT_INDEX_INTERVAL] = {
|
||||||
{"-fc", "--fontcolor", "ticker-font color-name",
|
.shortForm = "-i",
|
||||||
DOString, False, {&config.fontColor} },
|
.longForm = "--interval",
|
||||||
{"-bc", "--backcolor", "backlight color-name",
|
.description = "number of secs between mail-status updates (1 is default)",
|
||||||
DOString, False, {&config.backColor} },
|
.type = DONatural,
|
||||||
{"-oc", "--offcolor", "off-light color-name",
|
.value = { .integer = &config.checkInterval }
|
||||||
DOString, False, {&config.offlightColor} },
|
},
|
||||||
{"-bg", "--background", "frame-background for non-shaped window",
|
[OPT_INDEX_FAMILY_NAME] = {
|
||||||
DOString, False, {&config.backgroundColor} },
|
.shortForm = "-f",
|
||||||
{"-ns", "--noshape", "make the dockapp non-shaped (combine with -w)",
|
.longForm = "--familyname",
|
||||||
DONone, False, {NULL} },
|
.description = "tickers the family-name if available",
|
||||||
{"-n", "--new", "forces wmail to show new mail exclusively", DONone, False, {NULL} },
|
},
|
||||||
{"-mb", "--mailbox", "specify another mailbox ($MAIL is default)", DOString, False, {&config.mailBox} },
|
[OPT_INDEX_FRAMES] = {
|
||||||
{"-e", "--execute", "command to execute when receiving a new mail", DOString, False, {&config.cmdOnMail} },
|
.shortForm = "-fps",
|
||||||
{"-sf", "--statusfield", "consider the status-field of the mail header to distinguish unread mails", DONone, False, {NULL} },
|
.longForm = "--frames",
|
||||||
{"-rs", "--readstatus", "status field content that your client uses to mark read mails", DOString, False, {&config.readStatus} },
|
.description = "ticker frames per second",
|
||||||
{"-fn", "--tickerfont", "use specified X11 font to draw the ticker", DOString, False, {&config.useX11Font} }
|
.type = DONatural,
|
||||||
|
.value = { .integer = &config.fps }
|
||||||
|
},
|
||||||
|
[OPT_INDEX_SHORT_NAME] = {
|
||||||
|
.shortForm = "-s",
|
||||||
|
.longForm = "--shortname",
|
||||||
|
.description = "tickers the nickname (all before the '@')",
|
||||||
|
},
|
||||||
|
[OPT_INDEX_SYMBOL_COLOR] = {
|
||||||
|
.shortForm = "-sc",
|
||||||
|
.longForm = "--symbolcolor",
|
||||||
|
.description = "symbol color-name",
|
||||||
|
.type = DOString,
|
||||||
|
.value = { .string = &config.symbolColor }
|
||||||
|
},
|
||||||
|
[OPT_INDEX_FONT_COLOR] = {
|
||||||
|
.shortForm = "-fc",
|
||||||
|
.longForm = "--fontcolor",
|
||||||
|
.description = "ticker-font color-name",
|
||||||
|
.type = DOString,
|
||||||
|
.value = { .string = &config.fontColor }
|
||||||
|
},
|
||||||
|
[OPT_INDEX_BACK_COLOR] = {
|
||||||
|
.shortForm = "-bc",
|
||||||
|
.longForm = "--backcolor",
|
||||||
|
.description = "backlight color-name",
|
||||||
|
.type = DOString,
|
||||||
|
.value = { .string = &config.backColor }
|
||||||
|
},
|
||||||
|
[OPT_INDEX_OFF_COLOR] = {
|
||||||
|
.shortForm = "-oc",
|
||||||
|
.longForm = "--offcolor",
|
||||||
|
.description = "off-light color-name",
|
||||||
|
.type = DOString,
|
||||||
|
.value = { .string = &config.offlightColor }
|
||||||
|
},
|
||||||
|
[OPT_INDEX_BACKGROUND] = {
|
||||||
|
.shortForm = "-bg",
|
||||||
|
.longForm = "--background",
|
||||||
|
.description = "frame-background for non-shaped window",
|
||||||
|
.type = DOString,
|
||||||
|
.value = { .string = &config.backgroundColor }
|
||||||
|
},
|
||||||
|
[OPT_INDEX_NO_SHAPE] = {
|
||||||
|
.shortForm = "-ns",
|
||||||
|
.longForm = "--noshape",
|
||||||
|
.description = "make the dockapp non-shaped (combine with -w)",
|
||||||
|
},
|
||||||
|
[OPT_INDEX_NEW] = {
|
||||||
|
.shortForm = "-n",
|
||||||
|
.longForm = "--new",
|
||||||
|
.description = "forces wmail to show new mail exclusively",
|
||||||
|
},
|
||||||
|
[OPT_INDEX_MAILBOX] = {
|
||||||
|
.shortForm = "-mb",
|
||||||
|
.longForm = "--mailbox",
|
||||||
|
.description = "specify another mailbox ($MAIL is default)",
|
||||||
|
.type = DOString,
|
||||||
|
.value = { .string = &config.mailBox }
|
||||||
|
},
|
||||||
|
[OPT_INDEX_EXECUTE] = {
|
||||||
|
.shortForm = "-e",
|
||||||
|
.longForm = "--execute",
|
||||||
|
.description = "command to execute when receiving a new mail",
|
||||||
|
.type = DOString,
|
||||||
|
.value = { .string = &config.cmdOnMail }
|
||||||
|
},
|
||||||
|
[OPT_INDEX_STATUS_FIELD] = {
|
||||||
|
.shortForm = "-sf",
|
||||||
|
.longForm = "--statusfield",
|
||||||
|
.description = "consider the status-field of the mail header to distinguish unread mails",
|
||||||
|
},
|
||||||
|
[OPT_INDEX_READ_STATUS] = {
|
||||||
|
.shortForm = "-rs",
|
||||||
|
.longForm = "--readstatus",
|
||||||
|
.description = "status field content that your client uses to mark read mails",
|
||||||
|
.type = DOString,
|
||||||
|
.value = { .string = &config.readStatus }
|
||||||
|
},
|
||||||
|
[OPT_INDEX_TICKER_FONT] = {
|
||||||
|
.shortForm = "-fn",
|
||||||
|
.longForm = "--tickerfont",
|
||||||
|
.description = "use specified X11 font to draw the ticker",
|
||||||
|
.type = DOString,
|
||||||
|
.value = { .string = &config.useX11Font }
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -249,51 +356,51 @@ int main( int argc, char **argv )
|
||||||
sizeof(options) / sizeof(DAProgramOption),
|
sizeof(options) / sizeof(DAProgramOption),
|
||||||
PACKAGE_NAME, PACKAGE_STRING );
|
PACKAGE_NAME, PACKAGE_STRING );
|
||||||
|
|
||||||
if( options[0].used )
|
if( options[OPT_INDEX_DISPLAY].used )
|
||||||
config.givenOptions |= CL_DISPLAY;
|
config.givenOptions |= CL_DISPLAY;
|
||||||
if( options[1].used )
|
if( options[OPT_INDEX_COMMAND].used )
|
||||||
config.givenOptions |= CL_RUNCMD;
|
config.givenOptions |= CL_RUNCMD;
|
||||||
if( options[2].used )
|
if( options[OPT_INDEX_INTERVAL].used )
|
||||||
config.givenOptions |= CL_CHECKINTERVAL;
|
config.givenOptions |= CL_CHECKINTERVAL;
|
||||||
if( options[3].used ) {
|
if( options[OPT_INDEX_FAMILY_NAME].used ) {
|
||||||
config.givenOptions |= CL_TICKERMODE;
|
config.givenOptions |= CL_TICKERMODE;
|
||||||
config.tickerMode = TICKER_FAMILYNAME;
|
config.tickerMode = TICKER_FAMILYNAME;
|
||||||
}
|
}
|
||||||
if( options[4].used )
|
if( options[OPT_INDEX_FRAMES].used )
|
||||||
config.givenOptions |= CL_FPS;
|
config.givenOptions |= CL_FPS;
|
||||||
if( options[5].used ) {
|
if( options[OPT_INDEX_SHORT_NAME].used ) {
|
||||||
config.givenOptions |= CL_TICKERMODE;
|
config.givenOptions |= CL_TICKERMODE;
|
||||||
config.tickerMode = TICKER_NICKNAME;
|
config.tickerMode = TICKER_NICKNAME;
|
||||||
}
|
}
|
||||||
if( options[6].used )
|
if( options[OPT_INDEX_SYMBOL_COLOR].used )
|
||||||
config.givenOptions |= CL_SYMBOLCOLOR;
|
config.givenOptions |= CL_SYMBOLCOLOR;
|
||||||
if( options[7].used )
|
if( options[OPT_INDEX_FONT_COLOR].used )
|
||||||
config.givenOptions |= CL_FONTCOLOR;
|
config.givenOptions |= CL_FONTCOLOR;
|
||||||
if( options[8].used )
|
if( options[OPT_INDEX_BACK_COLOR].used )
|
||||||
config.givenOptions |= CL_BACKCOLOR;
|
config.givenOptions |= CL_BACKCOLOR;
|
||||||
if( options[9].used )
|
if( options[OPT_INDEX_OFF_COLOR].used )
|
||||||
config.givenOptions |= CL_OFFLIGHTCOLOR;
|
config.givenOptions |= CL_OFFLIGHTCOLOR;
|
||||||
if( options[10].used )
|
if( options[OPT_INDEX_BACK_COLOR].used )
|
||||||
config.givenOptions |= CL_BACKGROUNDCOLOR;
|
config.givenOptions |= CL_BACKGROUNDCOLOR;
|
||||||
if( options[11].used ) {
|
if( options[OPT_INDEX_NO_SHAPE].used ) {
|
||||||
config.givenOptions |= CL_NOSHAPE;
|
config.givenOptions |= CL_NOSHAPE;
|
||||||
config.noshape = true;
|
config.noshape = true;
|
||||||
}
|
}
|
||||||
if( options[12].used ) {
|
if( options[OPT_INDEX_NEW].used ) {
|
||||||
config.givenOptions |= CL_NEWMAILONLY;
|
config.givenOptions |= CL_NEWMAILONLY;
|
||||||
config.newMailsOnly = true;
|
config.newMailsOnly = true;
|
||||||
}
|
}
|
||||||
if( options[13].used )
|
if( options[OPT_INDEX_MAILBOX].used )
|
||||||
config.givenOptions |= CL_MAILBOX;
|
config.givenOptions |= CL_MAILBOX;
|
||||||
if( options[14].used )
|
if( options[OPT_INDEX_EXECUTE].used )
|
||||||
config.givenOptions |= CL_CMDONMAIL;
|
config.givenOptions |= CL_CMDONMAIL;
|
||||||
if( options[15].used ) {
|
if( options[OPT_INDEX_STATUS_FIELD].used ) {
|
||||||
config.givenOptions |= CL_CONSIDERSTATUSFIELD;
|
config.givenOptions |= CL_CONSIDERSTATUSFIELD;
|
||||||
config.considerStatusField = true;
|
config.considerStatusField = true;
|
||||||
}
|
}
|
||||||
if( options[16].used )
|
if( options[OPT_INDEX_READ_STATUS].used )
|
||||||
config.givenOptions |= CL_READSTATUS;
|
config.givenOptions |= CL_READSTATUS;
|
||||||
if( options[17].used )
|
if( options[OPT_INDEX_TICKER_FONT].used )
|
||||||
config.givenOptions |= CL_USEX11FONT;
|
config.givenOptions |= CL_USEX11FONT;
|
||||||
|
|
||||||
if( config.mailBox == NULL )
|
if( config.mailBox == NULL )
|
||||||
|
|
Loading…
Reference in a new issue