@@ -48,6 +48,7 @@ typedef struct {
48
48
UINT filtersSize ;
49
49
filterRecord filters [CONFIG_MAX_RECORDS ] = {0 };
50
50
char configBuf [CONFIG_BUF_SIZE + 2 ]; // add some padding to write \n
51
+ BOOL parameterized = 0 ; // parameterized flag, means reading args from command line
51
52
52
53
// loading up filters and fill in
53
54
void loadConfig () {
@@ -147,6 +148,18 @@ void init(int argc, char* argv[]) {
147
148
)
148
149
);
149
150
151
+ // parse arguments and set globals *before* setting up UI.
152
+ // arguments can be read and set after callbacks are setup
153
+ // FIXME as Release is built as WindowedApp, stdout/stderr won't show
154
+ LOG ("argc: %d" , argc );
155
+ if (argc > 1 ) {
156
+ if (!parseArgs (argc , argv )) {
157
+ fprintf (stderr , "invalid argument count. ensure you're using options as \"--drop on\"" );
158
+ exit (-1 ); // fail fast.
159
+ }
160
+ parameterized = 1 ;
161
+ }
162
+
150
163
IupSetAttribute (topFrame , "TITLE" , "Filtering" );
151
164
IupSetAttribute (topFrame , "EXPAND" , "HORIZONTAL" );
152
165
IupSetAttribute (filterText , "EXPAND" , "HORIZONTAL" );
@@ -228,6 +241,7 @@ void init(int argc, char* argv[]) {
228
241
timer = IupTimer ();
229
242
IupSetAttribute (timer , "TIME" , STR (ICON_UPDATE_MS ));
230
243
IupSetCallback (timer , "ACTION_CB" , uiTimerCb );
244
+
231
245
}
232
246
233
247
void startup () {
@@ -267,7 +281,13 @@ static int uiOnDialogShow(Ihandle *ih, int state) {
267
281
SendMessage (hWnd , WM_SETICON , ICON_SMALL , (LPARAM )icon );
268
282
269
283
// try elevate and decides whether to exit
270
- exit = tryElevate (hWnd );
284
+ exit = tryElevate (hWnd , parameterized );
285
+ if (!exit && parameterized ) {
286
+ setFromParameter (filterText , "VALUE" , "filter" );
287
+ LOG ("is parameterized, start filtering upon execution." );
288
+ uiStartCb (filterButton );
289
+ }
290
+
271
291
return exit ? IUP_CLOSE : IUP_DEFAULT ;
272
292
}
273
293
@@ -322,10 +342,10 @@ static int uiToggleControls(Ihandle *ih, int state) {
322
342
int controlsActive = IupGetInt (controls , "ACTIVE" );
323
343
if (controlsActive && !state ) {
324
344
IupSetAttribute (controls , "ACTIVE" , "NO" );
325
- InterlockedExchange16 (target , ( short ) state );
345
+ InterlockedExchange16 (target , I2S ( state ) );
326
346
} else if (!controlsActive && state ) {
327
347
IupSetAttribute (controls , "ACTIVE" , "YES" );
328
- InterlockedExchange16 (target , ( short ) state );
348
+ InterlockedExchange16 (target , I2S ( state ) );
329
349
}
330
350
331
351
return IUP_DEFAULT ;
@@ -382,7 +402,7 @@ static void uiSetupModule(Module *module, Ihandle *parent) {
382
402
Ihandle * groupBox , * toggle , * controls , * icon ;
383
403
groupBox = IupHbox (
384
404
icon = IupLabel (NULL ),
385
- toggle = IupToggle (module -> name , NULL ),
405
+ toggle = IupToggle (module -> displayName , NULL ),
386
406
IupFill (),
387
407
controls = module -> setupUIFunc (),
388
408
NULL
@@ -403,6 +423,11 @@ static void uiSetupModule(Module *module, Ihandle *parent) {
403
423
IupSetAttribute (icon , "IMAGE" , "none_icon" );
404
424
IupSetAttribute (icon , "PADDING" , "4x" );
405
425
module -> iconHandle = icon ;
426
+
427
+ // parameterize toggle
428
+ if (parameterized ) {
429
+ setFromParameter (toggle , "VALUE" , module -> shortName );
430
+ }
406
431
}
407
432
408
433
int main (int argc , char * argv []) {
0 commit comments