forked from zapek/Ambient
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathappclass.c
More file actions
8489 lines (7286 loc) · 211 KB
/
Copy pathappclass.c
File metadata and controls
8489 lines (7286 loc) · 211 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Ambient - the ultimate desktop
* ------------------------------
* Copyright 2001-2005 by David Gerber
* Copyright 2005-2018 Ambient Open Source Team
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
* $Id: appclass.c,v 1.139 2026/04/25 23:05:00 jacadcaps Exp $
*/
#include "ambient.h"
/* public */
#include <exec/execbase.h>
#include <exec/rawfmt.h> // bitRocky: used in RXCMD_Settings
#include <graphics/rpattr.h>
#include <workbench/workbench.h>
#include <intuition/extensions.h>
#include <intuition/monitorclass.h>
#include <intuition/intuitionbase.h>
#include <dos/dostags.h>
#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/wb.h>
#include <proto/graphics.h>
#include <proto/layers.h>
#include <proto/dos.h>
#include <proto/btree.h>
#include <libraries/btree.h>
#if !USE_LEGACY
#include <proto/log.h>
#endif
/* private */
#include "ambient_cat.h"
#include "copyright.h"
#include "mui_func.h"
#include "prefs_desktop.h"
#include "prefs_startup.h"
#include "threads.h"
#include "prefswin.h"
#include "fonts.h"
#include "prefs.h"
#include "screen.h"
#include "methodstack.h"
#include "rexx.h"
#include "smartreq.h"
#include "name.h"
#include "wbstart.h"
#include "iconview.h"
#include "memtrack.h"
#include "cx.h"
#include "common_picture.h"
#include "datatypes_picture.h"
#include "reggae_picture.h"
#include "panelprefs.h"
#include "sizes.h"
#include "random.h"
#include "mimeuri.h"
#include "background.h"
#include "vars.h"
#include "dosreq.h"
#include "file_func.h"
#include "playsound.h"
#include "gfx_bitmap.h"
#include "gfx_blit.h"
#include "datatypes.h"
#include "multimedia.h"
#include "command.h"
#include "mimetype.h"
#include "appclass.h"
#include "clipboard.h"
#include "dragdrop.h"
#include "viewapi.h"
#include "appicon.h"
#include "wbarg.h"
#include "ipc.h"
#include "storage.h"
#include "deficon_getpath.h"
#include "deficon.h"
#include "deficonpool.h"
#include "time_func.h"
#include "eject.h"
#include "device_func.h"
#include "prefs_advanced.h"
#include "legacy.h"
#include "cache.h"
#include "keyshortcuts.h"
#include "clipboarddevice.h"
#include "doslistcache.h"
#include "bookmarks.h"
#include "panelitem.h"
#include "deficonpool.h"
#include "soundwin.h"
#include "contextmenu.h"
#include "menus.h"
#include "paneltags.h"
#include "preferences_update.h"
#include "trashcan.h"
#include "networksfs.h"
void dprintf(char *, ...) __attribute__ ((format (printf, 1, 2)));
#if USE_OS4
struct Library *OS4LoaderBase;
#endif
STRPTR screentitle;
#define SCREENTITLESIZE 2048
extern CONST_STRPTR __screentitle_additional; /* created on-the-fly for each build (revstring.o) */
struct dialog_delay
{
struct MinNode node;
APTR win;
ULONG launchtime;
};
struct Data {
ULONG id;
APTR idTree;
/* backgrounds
*/
APTR dtp_root_old[AMBIENT_MAX_EXTRA_SCREENS + 1];
APTR dtp_root_new[AMBIENT_MAX_EXTRA_SCREENS + 1];
APTR dtp_root[AMBIENT_MAX_EXTRA_SCREENS + 1];
APTR dtp_window;
APTR rootwin; /* root window object (mostly for speed reasons but also to check if rootwin is around) */
STRPTR screentitle_backup;
/* intuition sucks so much that we need 2 buffers to swap
*/
STRPTR scrbuf[2];
ULONG scrtick;
ULONG pushid;
ULONG wasiconified;
/* images cache
*/
APTR image_cache;
#if USE_INTERNAL_PANELS
APTR panelclasslist;
#endif
/* views counter
*/
/* */
ULONG cleanup_pending;
/* background randomizer input handler
*/
ULONG bgrandom_timer_count;
ULONG bgrandom_timer_wait;
ULONG bgrandom_inputhandler_added;
struct MUI_InputHandlerNode bgrandom_ihnode;
/* cache cleanup counter
*/
ULONG cachecleanup_timer_count;
ULONG cachecleanup_timer_wait;
ULONG cachecleanup_inputhandler_added;
struct MUI_InputHandlerNode cachecleanup_ihnode;
/* Delayed dialogs */
struct MinList delaylist;
struct MUI_InputHandlerNode delay_ihnode;
struct MUI_InputHandlerNode transtimer;
UBYTE bg_transition_active;
UBYTE mixlevel;
};
ULONG xget(Object *object, ULONG attr)
{
ULONG val = 0;
if (get(object, attr, &val))
return val;
return 0;
}
/*
* Used MUI classes (well, we don't use any yet.. maybe Textinput makes sense).
*/
static const CONST_STRPTR classlist[] = {
#if 0
"Textinput.mcc",
#endif
"Listtree.mcc",
NULL
};
static APTR idTreeAlloc(APTR userdata, ULONG size)
{
(void)userdata;
return AllocTaskPooled(size);
}
static void idTreeFree(APTR userdata, APTR ptr, ULONG size)
{
(void)userdata;
FreeTaskPooled(ptr, size);
}
static LONG idTreeCompare(APTR userdata, const APTR keya, const APTR keyb)
{
(void)userdata;
if ((ULONG) keya > (ULONG) keyb) return 1;
else if ((ULONG) keya < (ULONG) keyb) return -1;
return 0;
}
static void idNothing(APTR _, APTR __)
{
(void)_; (void)__;
}
DEFNEW
{
struct Data *data;
static struct BTArgArray idTreeArray = {
idTreeAlloc, idTreeFree, idTreeCompare, idNothing, idNothing, NULL
};
obj = DoSuperNew(cl, obj,
MUIA_Application_Title, APPNAME,
MUIA_Application_Version, "$VER: "APPNAME" "LVERTAG,
MUIA_Application_Copyright, "? 2001-2005 by David Gerber, ? 2005-" COPYRIGHTYEAR_END " by Ambient Open Source Team, All Rights Reserved.",
MUIA_Application_Author, "David Gerber, Ambient Open Source Team",
MUIA_Application_UsedClasses, classlist,
MUIA_Application_Description, "The MorphOS desktop",
MUIA_Application_Base, "AMBIENT",
MUIA_Application_SingleTask, TRUE,
MUIA_Application_UseRexx, FALSE,
MUIA_Application_NoIconify, TRUE,
TAG_MORE, INITTAGS
);
if (!obj)
{
return (0);
}
data = INST_DATA(cl, obj);
data->id = MV_Window_ID_Base;
data->idTree = CreateTree(BT_AVL_TREE, &idTreeArray);
if (!data->idTree)
{
CoerceMethod(cl, obj, OM_DISPOSE);
return (0);
}
data->cleanup_pending = FALSE;
if (!(data->scrbuf[0] = malloc(SCREENTITLESIZE)) || !(data->scrbuf[1] = malloc(SCREENTITLESIZE))) /* should be enough for everyone (tm) */
{
CoerceMethod(cl, obj, OM_DISPOSE);
return (0);
}
screentitle = data->scrbuf[0];
NewRawDoFmt("Ambient Screen%s", NULL, screentitle, __screentitle_additional);
if (!(data->screentitle_backup = malloc(SCREENTITLESIZE)))
{
CoerceMethod(cl, obj, OM_DISPOSE);
return (0);
}
data->screentitle_backup[0] = '\0';
data->bgrandom_timer_count = 0;
data->bgrandom_timer_wait = 0;
data->bgrandom_inputhandler_added = FALSE;
set(obj, MA_Application_BackgroundRefreshDelay, getprefslong(DSI_BACKGROUND_ROOT_REFRESH_DELAY));
#if MORPHOS_BETABUILD
/* cache cleanup handler (invoke once a minute to trigger any lingering bugs) */
data->cachecleanup_timer_count = 1;
data->cachecleanup_timer_wait = 1;
#else
/* cache cleanup handler (invoke cleanup routine every 30 minutes) */
data->cachecleanup_timer_count = 30;
data->cachecleanup_timer_wait = 30;
#endif
data->cachecleanup_ihnode.ihn_Object = obj;
data->cachecleanup_ihnode.ihn_Flags = MUIIHNF_TIMER;
data->cachecleanup_ihnode.ihn_Millis = 60 * 1000;
data->cachecleanup_ihnode.ihn_Method = MM_Application_CleanupCache;
DoMethod(obj, MUIM_Application_AddInputHandler, &data->cachecleanup_ihnode);
data->cachecleanup_inputhandler_added = TRUE;
NEWLIST(&data->delaylist);
data->delay_ihnode.ihn_Object = obj;
data->delay_ihnode.ihn_Flags = MUIIHNF_TIMER;
data->delay_ihnode.ihn_Millis = 1000;
data->delay_ihnode.ihn_Method = MM_Application_CheckDelayedDialog;
data->transtimer.ihn_Object = obj;
data->transtimer.ihn_Millis = 50;
data->transtimer.ihn_Flags = MUIIHNF_TIMER;
data->transtimer.ihn_Method = MM_Application_UpdateTransitionEffect;
set(obj, MUIA_Application_Iconified, FALSE);
#if USE_INTERNAL_PANELS
data->panelclasslist = NewObject(getpanelclasslistclass(),NULL,TAG_DONE);
#endif
return ((ULONG)obj);
}
DEFDISP
{
GETDATA;
if (_conf(misc_remember_windows) || _conf(misc_remember_documents))
{
sprefs_save();
}
sprefs_cleanup();
if(data->bgrandom_inputhandler_added)
{
DoMethod(obj, MUIM_Application_RemInputHandler, &data->bgrandom_ihnode);
}
if(data->cachecleanup_inputhandler_added)
{
DoMethod(obj, MUIM_Application_RemInputHandler, &data->cachecleanup_ihnode);
}
/*
* Close all windows to make sure none of them
* uses the things we're going to free now.
*/
FORCHILD(obj, MUIA_Application_WindowList)
{
set(child, MUIA_Window_Open, FALSE);
}
NEXTCHILD
if (_conf(root_font))
{
font_close(_conf(root_font));
_conf(root_font) = NULL;
}
if (_conf(root_font_small))
{
font_close(_conf(root_font_small));
_conf(root_font_small) = NULL;
}
if (_conf(window_font))
{
font_close(_conf(window_font));
_conf(window_font) = NULL;
}
if (_conf(fl_lister_font))
{
font_close(_conf(fl_lister_font));
_conf(fl_lister_font) = NULL;
}
for (int i = 0; i <= AMBIENT_MAX_EXTRA_SCREENS; i++)
{
picture_delete(data->dtp_root[i]);
picture_delete(data->dtp_root_old[i]);
picture_delete(data->dtp_root_new[i]);
}
picture_delete(data->dtp_window);
if (data->scrbuf[0])
{
free(data->scrbuf[0]);
}
if (data->scrbuf[1])
{
free(data->scrbuf[1]);
}
if (data->screentitle_backup)
{
free(data->screentitle_backup);
}
#if USE_INTERNAL_PANELS
if(data->panelclasslist)
{
MUI_DisposeObject(data->panelclasslist);
}
#endif
DeleteTree(data->idTree);
data->idTree = NULL; // important: dosuper will call REMMEMBER
return (DOSUPER);
}
// Those are here so that we can build a lookup tree by MA_Window_ID
DEFADDMEMBER
{
GETDATA;
if (msg->opam_Object)
{
ULONG id = xget(msg->opam_Object, MA_Window_ID);
if (id != MV_Window_ID_Unknown)
InsertTreeNode(data->idTree, id, msg->opam_Object);
}
return DOSUPER;
}
DEFREMMEMBER
{
GETDATA;
if (msg->opam_Object)
{
ULONG id = xget(msg->opam_Object, MA_Window_ID);
if (id != MV_Window_ID_Unknown)
{
APTR node = FindTreeNodeByKey(data->idTree, (void *)id);
if (node)
DeleteTreeNode(data->idTree, node);
}
}
return DOSUPER;
}
/*
* Add a dialog that is opened with delay.
*/
static void AddDelayedDialog(struct IClass *cl, APTR obj, APTR win, ULONG delay)
{
GETDATA;
struct dialog_delay *dd = AllocTaskPooled(sizeof(*dd));
if (dd)
{
LONG was_empty = ISLISTEMPTY(&data->delaylist);
dd->win = win;
dd->launchtime = MAX(delay, 50) + timedm();
ADDTAIL(&data->delaylist, dd);
if (was_empty)
{
DoSuperMethod(cl, obj, MUIM_Application_AddInputHandler, &data->delay_ihnode);
}
}
}
static void RemoveDelayedDialog(struct IClass *cl, APTR obj, APTR win)
{
GETDATA;
struct dialog_delay *dd, *next;
LONG was_empty = ISLISTEMPTY(&data->delaylist);
ITERATELISTSAFE(dd, next, &data->delaylist)
{
if (dd->win == win)
{
REMOVE(dd);
FreeTaskPooled(dd, sizeof(*dd));
break;
}
}
if (!was_empty && ISLISTEMPTY(&data->delaylist))
DoSuperMethod(cl, obj, MUIM_Application_RemInputHandler, &data->delay_ihnode);
}
/*
* Launch dialogs. Use time_now = (ULONG)-1 to fire all pending dialogs immediately.
*/
static void CheckDelayedDialogs(struct IClass *cl, APTR obj, ULONG time_now)
{
GETDATA;
struct dialog_delay *dd, *next;
LONG was_empty = ISLISTEMPTY(&data->delaylist);
ITERATELISTSAFE(dd, next, &data->delaylist)
{
if (dd->launchtime <= time_now)
{
REMOVE(dd);
set(dd->win, MUIA_Window_PublicScreen, active_screen_name());
set(dd->win, MUIA_Window_Open, TRUE);
FreeTaskPooled(dd, sizeof(*dd));
}
}
if (!was_empty && ISLISTEMPTY(&data->delaylist))
DoSuperMethod(cl, obj, MUIM_Application_RemInputHandler, &data->delay_ihnode);
}
DEFTMETHOD(Application_DisplayDelayedDialog)
{
CheckDelayedDialogs(cl, obj, (ULONG)-1);
return 0;
}
DEFTMETHOD(Application_CheckDelayedDialog)
{
CheckDelayedDialogs(cl, obj, timedm());
return 0;
}
DEFGET
{
GETDATA;
switch (msg->opg_AttrID)
{
case MA_Application_NextID:
{
// 32bit overflow fix - skip over reserved values
if (data->id < MV_Window_ID_Base)
data->id = MV_Window_ID_Base;
// 32 bit overflow fix - skip over used values
while (FindTreeNodeByKey(data->idTree, (void *)data->id))
data->id ++;
*msg->opg_Storage = data->id++;
}
return (TRUE);
#if USE_INTERNAL_PANELS
case MA_Application_PanelClassList:
*msg->opg_Storage = (ULONG)data->panelclasslist;
return (TRUE);
#endif
}
return (DOSUPER);
}
DEFSET
{
GETDATA;
FORTAG(INITTAGS)
{
case MUIA_Application_Iconified:
if (tag->ti_Data)
{
/*
* Clear the backgrounds.
*/
DoMethod(app, MM_Application_LoadBackground, MF_Application_LoadBackground_ClearRoot | MF_Application_LoadBackground_ClearWindow);
data->wasiconified = TRUE;
}
else
{
if (data->wasiconified)
{
ULONG rc;
// See if the # of aux screens hasn't changed while we were gone...
for (ULONG id = MV_Window_ID_RootExtra; id <= MV_Window_ID_RootExtra_Max; id++)
{
ULONG screenId = (id - MV_Window_ID_RootExtra) + 1;
struct Screen *woScr = screen_lock_by_id(screenId);
Object *wo = (APTR)DoMethod(obj, MM_Application_FindWindowByID, id);
if (wo && !woScr)
{
// Close if missing
DoMethod(obj, MM_Application_DisposeWindow, wo);
}
screen_unlock(woScr);
}
// Do another pass shortly after to open bg windows for screens that might have appeared
DoMethod(app, MUIM_Application_PushMethod, app, 1 | MUIV_PushMethod_Delay(100) | MUIF_PUSHMETHOD_SINGLE, MM_Application_ReopenExtraRootWindows);
rc = DOSUPER;
/*
* Reload the background
*/
DoMethod(app, MM_Application_LoadBackground, MF_Application_LoadBackground_Root | MF_Application_LoadBackground_Window);
data->wasiconified = FALSE;
return (rc);
}
}
break;
case MA_Application_BackgroundRefreshDelay:
{
if(data->bgrandom_inputhandler_added)
{
DoMethod(obj, MUIM_Application_RemInputHandler, &data->bgrandom_ihnode);
data->bgrandom_inputhandler_added = FALSE;
}
if(tag->ti_Data)
{
data->bgrandom_timer_wait = data->bgrandom_timer_count = (ULONG)tag->ti_Data;
data->bgrandom_ihnode.ihn_Object = obj;
data->bgrandom_ihnode.ihn_Flags = MUIIHNF_TIMER;
data->bgrandom_ihnode.ihn_Millis = 60 * 1000;
data->bgrandom_ihnode.ihn_Method = MM_Application_ReloadBackgrounds;
DoMethod(obj, MUIM_Application_AddInputHandler, &data->bgrandom_ihnode);
data->bgrandom_inputhandler_added = TRUE;
}
}
}
NEXTTAG
return (DOSUPER);
}
DEFSMETHOD(Application_ReopenExtraRootWindows)
{
GETDATA;
// Skip if we got iconified again
if (data->wasiconified)
return 0;
Object *rootWindow = (APTR)DoMethod(obj, MM_Application_FindWindowByID, MV_Window_ID_Root);
if (!rootWindow)
return 0;
// See if the # of aux screens hasn't changed while we were gone...
for (ULONG id = MV_Window_ID_RootExtra; id <= MV_Window_ID_RootExtra_Max; id++)
{
ULONG screenId = (id - MV_Window_ID_RootExtra) + 1;
struct Screen *woScr = screen_lock_by_id(screenId);
Object *wo = (APTR)DoMethod(obj, MM_Application_FindWindowByID, id);
if (!wo && woScr)
{
// Open if a new screen popped up
char pubscreenName[MAXPUBSCREENNAME];
snprintf(pubscreenName, sizeof(pubscreenName), "Workbench.%ld", screenId);
Object *ewo = (APTR)DoMethod(obj, MM_Application_CreateWindow, MV_Application_CreateWindow_Rootview_Extra, mimeuri_duplicate(xget(rootWindow, MA_Window_MIMEctx)), NULL, (IPTR)pubscreenName);
set(ewo, MUIA_Window_Open, TRUE);
}
screen_unlock(woScr);
}
return 0;
}
//#define CHECKID(x) (msg->id == MV_Application_LoadPrefs_All || msg->id == (x))
/* ok it sucks, but actually, all _conf() members need to be updated IMO, as there can be
* some reallocations in prefs for some id, not appearing in update list, which means old _conf()
* values point to an invalid address if they aren't updated. At least, that's what i think... (fab)
*/
#define CHECKID_OLD(x) ( msg->id == MV_Application_LoadPrefs_All || msg->id == (x) )
#define CHECKID(x) (1)
static ULONG get_icon_size(ULONG size)
{
switch (size)
{
case ICON_SIZE_MICRO:
return (SIZE_MICRO);
case ICON_SIZE_SMALL:
return (SIZE_SMALL);
case ICON_SIZE_MEDIUM:
return (SIZE_MEDIUM);
case ICON_SIZE_LARGE:
return (SIZE_LARGE);
case ICON_SIZE_HUGE:
return (SIZE_HUGE);
#ifdef DEBUG
default:
PDB(("eek, out of bound: %ld\n", size));
break;
#endif
}
return (0); /* shut up gcc */
}
DEFSMETHOD(Application_LoadPrefs)
{
ASSERT(msg->id);
if (!msg->quiet && CHECKID_OLD(DSI_FONT_ROOT))
{
do_action(obj, TA_Font_Load,
TT_Font_Load_Path, getprefsstr(DSI_FONT_ROOT),
TT_Font_Load_Type, TV_Font_Load_Type_Root,
TAG_DONE);
}
if (!msg->quiet && CHECKID_OLD(DSI_FONT_ROOT_SMALL))
{
do_action(obj, TA_Font_Load,
TT_Font_Load_Path, getprefsstr(DSI_FONT_ROOT_SMALL),
TT_Font_Load_Type, TV_Font_Load_Type_Root_Small,
TAG_DONE);
}
if (!msg->quiet && CHECKID_OLD(DSI_FONT_WINDOW))
{
do_action(obj, TA_Font_Load,
TT_Font_Load_Path, getprefsstr(DSI_FONT_WINDOW),
TT_Font_Load_Type, TV_Font_Load_Type_Window,
TAG_DONE);
}
if (!msg->quiet && CHECKID_OLD(DSI_FASTLIST_FONT))
{
do_action(obj, TA_Font_Load,
TT_Font_Load_Path, getprefsstr(DSI_FASTLIST_FONT),
TT_Font_Load_Type, TV_Font_Load_Type_Lister,
TAG_DONE);
}
if (CHECKID(DSI_FONT_ROOT_EFFECT))
{
_conf(root_font_effect) = getprefslong(DSI_FONT_ROOT_EFFECT);
}
if (CHECKID(DSI_FONT_WINDOW_EFFECT))
{
_conf(window_font_effect) = getprefslong(DSI_FONT_WINDOW_EFFECT);
}
if (CHECKID(DSI_BACKGROUND_WINDOW_BGRENDER))
{
_conf(window_bgrender) = getprefslong(DSI_BACKGROUND_WINDOW_BGRENDER);
}
if (CHECKID(DSI_BACKGROUND_WINDOW_BGCOLOR))
{
memcpy(&_conf(window_bgcolor), getprefs(DSI_BACKGROUND_WINDOW_BGCOLOR), sizeof(_conf(window_bgcolor)));
}
if (CHECKID(DSI_COLOR_ROOT))
{
memcpy(&_conf(root_pen1), getprefs(DSI_COLOR_ROOT), sizeof(_conf(root_pen1)));
}
if (CHECKID(DSI_COLOR_WINDOW))
{
memcpy(&_conf(window_pen1), getprefs(DSI_COLOR_WINDOW), sizeof(_conf(window_pen1)));
}
if (CHECKID(DSI_FONT_ROOTSPACE))
{
_conf(root_spaceline) = getprefslong(DSI_FONT_ROOTSPACE);
}
if (CHECKID(DSI_FONT_WINDOWSPACE))
{
_conf(window_spaceline) = getprefslong(DSI_FONT_WINDOWSPACE);
}
if (CHECKID(DSI_COLOR_ROOT2))
{
memcpy(&_conf(root_pen2), getprefs(DSI_COLOR_ROOT2), sizeof(_conf(root_pen2)));
}
if (CHECKID(DSI_COLOR_WINDOW2))
{
memcpy(&_conf(window_pen2), getprefs(DSI_COLOR_WINDOW2), sizeof(_conf(window_pen2)));
}
if (CHECKID(DSI_COLOR_LASSO))
{
memcpy(&_conf(lasso_pen), getprefs(DSI_COLOR_LASSO), sizeof(_conf(lasso_pen)));
}
if (CHECKID(DSI_ICON_MINSIZE))
{
if ( getprefslong(DSI_ICON_MINSIZE) > ICON_SIZE_HUGE )
setprefslong(DSI_ICON_MINSIZE, ICON_SIZE_HUGE );
_conf(icon_minsize) = get_icon_size(getprefslong(DSI_ICON_MINSIZE));
}
if (CHECKID(DSI_ICON_MAXSIZE))
{
if ( getprefslong(DSI_ICON_MAXSIZE) > ICON_SIZE_HUGE )
setprefslong(DSI_ICON_MAXSIZE, ICON_SIZE_HUGE );
_conf(icon_maxsize) = get_icon_size(getprefslong(DSI_ICON_MAXSIZE));
}
/*
Hovering enable/disable config item.
*/
if (CHECKID(DSI_ICON_HOVER))
{
_conf(icon_hover) = getprefslong(DSI_ICON_HOVER);
}
if (CHECKID(DSI_ICON_SEPARATEFILES))
{
_conf(icon_separatefiles) = getprefslong(DSI_ICON_SEPARATEFILES);
}
if (CHECKID(DSI_ICON_DEFGHOSTED))
{
_conf(icon_defghosted) = getprefslong(DSI_ICON_DEFGHOSTED);
}
if (CHECKID(DSI_ICON_FADE))
{
_conf(icon_fade) = getprefslong(DSI_ICON_FADE);
}
if (CHECKID(DSI_ICON_SHORTCUTSIDENTIFIER))
{
_conf(icon_shortcutsidentifier) = getprefslong(DSI_ICON_SHORTCUTSIDENTIFIER);
}
if (CHECKID(DSI_ICON_APPICONSIDENTIFIER))
{
_conf(icon_appiconsidentifier) = getprefslong(DSI_ICON_APPICONSIDENTIFIER);
}
if (CHECKID(DSI_ICON_AUTOSNAPSHOT))
{
_conf(icon_autosnapshot) = getprefslong(DSI_ICON_AUTOSNAPSHOT);
}
if (CHECKID(DSI_ICON_DUALPNG))
{
_conf(icon_dualpng) = getprefslong(DSI_ICON_DUALPNG);
}
/*
* Miscellaneous.
*/
if (CHECKID(DSI_MISC_REMEMBER_WINDOWS))
{
_conf(misc_remember_windows) = getprefslong(DSI_MISC_REMEMBER_WINDOWS);
}
if (CHECKID(DSI_MISC_REMEMBER_DOCUMENTS))
{
_conf(misc_remember_documents) = getprefslong(DSI_MISC_REMEMBER_DOCUMENTS);
}
if (CHECKID(DSI_MISC_MYMORPHOSICON))
{
_conf(misc_mymorphosicon) = getprefslong(DSI_MISC_MYMORPHOSICON);
}
if (CHECKID(DSI_MISC_TRAPMORE))
{
_conf(misc_trapmore) = getprefslong(DSI_MISC_TRAPMORE);
}
if (CHECKID(DSI_MISC_TRAPMULTIVIEW))
{
_conf(misc_trapmultiview) = getprefslong(DSI_MISC_TRAPMULTIVIEW);
}
if (CHECKID(DSI_MISC_CONTEXTMENUIMAGES))
{
_conf(misc_contextmenuimages) = getprefslong(DSI_MISC_CONTEXTMENUIMAGES);
contextmenu_setuplabels();
}
if (CHECKID(DSI_MISC_CREATEICONFORNEWDRAWER))
{
_conf(misc_createiconfornewdrawer) = getprefslong(DSI_MISC_CREATEICONFORNEWDRAWER);
}
if (CHECKID(DSI_MISC_DESKTOPDOUBLECLICK))
{
_conf(misc_desktopdoubleclick) = getprefslong(DSI_MISC_DESKTOPDOUBLECLICK);
}
if (CHECKID(DSI_MISC_DRIVE_INFO))
{
_conf(misc_driveinfo) = getprefslong(DSI_MISC_DRIVE_INFO);
}
if (CHECKID(DSI_MISC_SMARTFILEOPERATIONS))
{
_conf(misc_smartfileoperations) = getprefslong(DSI_MISC_SMARTFILEOPERATIONS);
}
/*
* CLI
*/
if (CHECKID(DSI_CLI_DEVICE))
{
_conf(cli_device) = getprefsstr(DSI_CLI_DEVICE);
}
if (CHECKID(DSI_CLI_STACK))
{
_conf(cli_stack) = getprefslong(DSI_CLI_STACK);
}
#if USE_DROP_EFFECT_PREFS
if (CHECKID(DSI_DRAGDROP_DROPEFFECT))
{
_conf(dragdrop_dropeffect) = getprefslong(DSI_DRAGDROP_DROPEFFECT);
}
#endif
if (CHECKID(DSI_DRAGDROP_TINTVAL))
{
memcpy(&_conf(dragdrop_tintval), getprefs(DSI_DRAGDROP_TINTVAL), sizeof(_conf(dragdrop_tintval)));
}
#if USE_DROP_EFFECT_PREFS
if (CHECKID(DSI_DRAGDROP_TINTFADEVAL))
{
memcpy(&_conf(dragdrop_tintfadeval), getprefs(DSI_DRAGDROP_TINTFADEVAL), sizeof(_conf(dragdrop_tintfadeval)));
}
if (CHECKID(DSI_DRAGDROP_BRIGHTENVAL))
{
_conf(dragdrop_brightenval) = getprefslong(DSI_DRAGDROP_BRIGHTENVAL);
}
if (CHECKID(DSI_DRAGDROP_DARKENVAL))
{
_conf(dragdrop_darkenval) = getprefslong(DSI_DRAGDROP_DARKENVAL);
}
#endif
/* Icon options */
#if USE_DROP_EFFECT_PREFS
if (CHECKID(DSI_ICON_SELECTEFFECT))
{
_conf(icon_selecteffect) = getprefslong(DSI_ICON_SELECTEFFECT);
}
#endif
if (CHECKID(DSI_ICON_TINTVAL))
{
memcpy(&_conf(icon_tintval), getprefs(DSI_ICON_TINTVAL), sizeof(_conf(icon_tintval)));
}
#if USE_DROP_EFFECT_PREFS
if (CHECKID(DSI_ICON_TINTFADEVAL))
{
memcpy(&_conf(icon_tintfadeval), getprefs(DSI_ICON_TINTFADEVAL), sizeof(_conf(icon_tintfadeval)));
}
if (CHECKID(DSI_ICON_BRIGHTENVAL))
{
_conf(icon_brightenval) = getprefslong(DSI_ICON_BRIGHTENVAL);
}
if (CHECKID(DSI_ICON_DARKENVAL))
{