File: Look.c

package info (click to toggle)
afterstep 2.2.12-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 33,168 kB
  • sloc: ansic: 201,695; sh: 5,894; xml: 3,721; makefile: 2,095; perl: 1,558; cpp: 811
file content (1204 lines) | stat: -rw-r--r-- 38,692 bytes parent folder | download | duplicates (6)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
/*
 * Copyright (c) 2000 Andrew Ferguson <andrew@owsla.cjb.net>
 * Copyright (c) 1998 Sasha Vasko <sasha at aftercode.net>
 *
 * 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.
 *
 */

#define LOCAL_DEBUG

#include "../configure.h"
#include "../libAfterStep/asapp.h"
#include "../libAfterStep/afterstep.h"
#include "../libAfterStep/parser.h"
#include "../libAfterStep/hints.h"
#include "../libAfterStep/mystyle.h"
#include "../libAfterStep/screen.h"
#include "../libAfterStep/mylook.h"

#include "afterconf.h"


flag_options_xref LookFlagsXref[] = {
	{MenuMiniPixmaps, LOOK_MenuMiniPixmaps_ID, 0}
	,
	{SeparateButtonTitle, LOOK_SeparateButtonTitle_ID, 0}
	,
	{0, 0, 0}

};

/**********************************************************************/
/* The following code has been backported from as-devel and remains
 * undebugged for future use. Feel free to debug it :
 *                                                      Sasha Vasko.
 **********************************************************************/


/*****************  Create/Destroy DeskBackConfig     *****************/
DesktopConfig *GetDesktopConfig (DesktopConfig ** plist, int desk)
{

	register DesktopConfig *curr = *plist;

	while (curr)
		if (curr->desk == desk)
			return curr;
		else
			curr = curr->next;

	curr = (DesktopConfig *) safecalloc (1, sizeof (DesktopConfig));

	curr->desk = desk;
	curr->next = *plist;
	*plist = curr;

	return curr;
}

void PrintDesktopConfig (DesktopConfig * head)
{
	DesktopConfig *cur;

	for (cur = head; cur; cur = cur->next)
		fprintf (stderr, "Desk: %d, back[%s], layout[%s]\n", cur->desk,
						 cur->back_name, cur->layout_name);
}

void DestroyDesktopConfig (DesktopConfig ** head)
{
	if (head) {
		DesktopConfig *cur = *head, *next;

		while (cur) {
			if (cur->back_name)
				free (cur->back_name);
			if (cur->layout_name)
				free (cur->layout_name);

			next = cur->next;
			free (cur);
			cur = next;
		}
		*head = NULL;
	}
}

DesktopConfig *ParseDesktopOptions (DesktopConfig ** plist,
																		ConfigItem * item, int id)
{
	DesktopConfig *config = GetDesktopConfig (plist, item->index);

	item->ok_to_free = 0;
	switch (id) {
	case DESK_CONFIG_BACK:
		set_string (&(config->back_name), item->data.string);
		break;
	case DESK_CONFIG_LAYOUT:
		set_string (&(config->layout_name), item->data.string);
		break;
	default:
		item->ok_to_free = 1;
	}
	return config;
}


/********************************************************************/
/* Supported Hints processing code                                  */
/********************************************************************/
ASSupportedHints *ProcessSupportedHints (FreeStorageElem * options)
{
	ASSupportedHints *list = NULL;

	if (options) {
		list = create_hints_list ();
		while (options) {
			enable_hints_support (list, options->term->id - HINTS_ID_START);
			options = options->next;
		}
	}
	return list;
}

static FreeStorageElem **SupportedHints2FreeStorage (SyntaxDef * syntax,
																										 FreeStorageElem **
																										 tail,
																										 ASSupportedHints *
																										 list)
{
	register int i;
	FreeStorageElem **new_tail;
	HintsTypes *hints;
	int hints_num;

	if (list == NULL)
		return tail;

	new_tail = Flag2FreeStorage (syntax, tail, LOOK_SupportedHints_ID);
	if (new_tail == tail)
		return tail;

	/* we must not free hints after the following !!!!!!!!!! */
	if ((hints = supported_hints_types (list, &hints_num)) != NULL) {
		tail = &((*tail)->sub);
		for (i = 0; i < hints_num; i++)
			tail =
					Flag2FreeStorage (&SupportedHintsSyntax, tail,
														HINTS_ID_START + hints[i]);
	}
	return new_tail;
}

/********************************************************************/
/* Now look processing code 					    */
/********************************************************************/

LookConfig *CreateLookConfig ()
{
	LookConfig *config = (LookConfig *) safecalloc (1, sizeof (LookConfig));

	return config;
}

void DestroyLookConfig (LookConfig * config)
{
	register int i;

	if (config->menu_arrow != NULL)
		free (config->menu_arrow);	/* menu arrow */
	if (config->menu_pin_on != NULL)
		free (config->menu_pin_on);	/* menu pin */
	if (config->menu_pin_off != NULL)
		free (config->menu_pin_off);

	for (i = 0; i < 2; i++)
		if (config->text_gradient[i] != NULL)
			free (config->text_gradient[i]);	/* title text */
	for (i = 0; i < MAX_BUTTONS; i++) {
		if (config->normal_buttons[i] != NULL) {
			destroy_asbutton (config->normal_buttons[i], False);
			config->normal_buttons[i] = NULL;
		}
		if (config->icon_buttons[i] != NULL) {
			destroy_asbutton (config->icon_buttons[i], False);
			config->icon_buttons[i] = NULL;
		}
	}
	for (i = 0; i < BACK_STYLES; i++)
		if (config->window_styles[i] != NULL)
			free (config->window_styles[i]);

	for (i = 0; i < MENU_BACK_STYLES; i++)
		if (config->menu_styles[i] != NULL)
			free (config->menu_styles[i]);

	Destroy_balloonConfig (config->title_balloon_conf);
	Destroy_balloonConfig (config->menu_balloon_conf);
	DestroyMyStyleDefinitions (&(config->style_defs));
	DestroyMyFrameDefinitions (&(config->frame_defs));
	DestroyFreeStorage (&(config->more_stuff));
	DestroyMyBackgroundConfig (&(config->back_defs));
	DestroyDesktopConfig (&(config->desk_configs));


	if (config->menu_frame)
		free (config->menu_frame);

	if (config->supported_hints)
		destroy_hints_list (&(config->supported_hints));

	free (config);
}


void spread_back_param_array (int *trg, int *src, int count)
{
	register int i = 0, k;

	if (trg == NULL || src == NULL || count == 0)
		return;
	for (k = 0; i < count && i < 3 && k < BACK_STYLES; i++)
		trg[k++] = src[i];
	for (k = BACK_STYLES; i < count && k < BACK_STYLES + MENU_BACK_STYLES;
			 i++)
		trg[k++] = src[i];
}

void
merge_depreciated_options (LookConfig * config, FreeStorageElem * Storage)
{
	FreeStorageElem *pCurr;
	MyStyleDefinition **mystyles_list = &(config->style_defs);
	ConfigItem item;
	register int i;

	char *button_title_styles[BACK_STYLES] = { ICON_STYLE_FOCUS,
		ICON_STYLE_STICKY,
		ICON_STYLE_UNFOCUS,
		NULL
	};
	char *ButtonColors[2] = { NULL, NULL };
	char *ButtonTextureColors[2] = { NULL, NULL };
	char *ButtonPixmap = NULL;
	int ButtonTextureType = -1;


#define SET_WINDOW		0
#define SET_MENU		1
#define SET_ICON		2
#define SET_NUM			3
	char *Fonts[SET_NUM];

	char *MenuColors[MENU_BACK_STYLES][2];
	char *MenuTextureColors[MENU_BACK_STYLES][2];
	char *MenuPixmaps[MENU_BACK_STYLES];

	char *WinColors[BACK_STYLES][2];
	char *WinTextureColors[BACK_STYLES][2];
	char *WinPixmaps[BACK_STYLES];

	int TitleTextStyle = -1;

	int TextureTypes[BACK_STYLES + MENU_BACK_STYLES];
	int *array = NULL;


#define CHANGED_WINDOW		(0x01<<0)
#define CHANGED_MENU		(0x01<<1)
#define CHANGED_ICON		(0x01<<2)
	unsigned long change_flags = 0;

	/* start initialization */
	memset (&(Fonts[0]), 0x00, sizeof (char *) * SET_NUM);

	memset (&(MenuColors[0]), 0x00, sizeof (char *) * MENU_BACK_STYLES * 2);
	memset (&(MenuTextureColors[0]), 0x00,
					sizeof (char *) * MENU_BACK_STYLES * 2);
	memset (&(MenuPixmaps[0]), 0x00, sizeof (char *) * MENU_BACK_STYLES);

	memset (&(WinColors[0]), 0x00, sizeof (char *) * BACK_STYLES * 2);
	memset (&(WinTextureColors[0]), 0x00, sizeof (char *) * BACK_STYLES * 2);
	memset (&(WinPixmaps[0]), 0x00, sizeof (char *) * BACK_STYLES);

	for (i = 0; i < BACK_STYLES + MENU_BACK_STYLES; i++)
		TextureTypes[i] = -1;

	item.memory = NULL;
	/* end initialization */

	for (pCurr = Storage; pCurr; pCurr = pCurr->next) {
		register int id;

		if (pCurr->term == NULL)
			continue;
		id = pCurr->term->id;
		if (id < LOOK_DEPRECIATED_ID_START && id >= LOOK_DEPRECIATED_ID_END)
			continue;
		if (!ReadConfigItem (&item, pCurr))
			continue;

		switch (id) {								/* fonts : */
		case LOOK_Font_ID:
			set_string_value (&Fonts[SET_MENU], item.data.string, &change_flags,
												CHANGED_MENU);
			break;
		case LOOK_WindowFont_ID:
			set_string_value (&Fonts[SET_WINDOW], item.data.string,
												&change_flags, CHANGED_WINDOW);
			break;
		case LOOK_IconFont_ID:
			set_string_value (&Fonts[SET_ICON], item.data.string, &change_flags,
												CHANGED_ICON);
			break;
			/* colors */
		case LOOK_MTitleForeColor_ID:
			set_string_value (&MenuColors[MENU_BACK_TITLE][0], item.data.string,
												&change_flags, CHANGED_MENU);
			break;
		case LOOK_MTitleBackColor_ID:
			set_string_value (&MenuColors[MENU_BACK_TITLE][1], item.data.string,
												&change_flags, CHANGED_MENU);
			break;
		case LOOK_MenuForeColor_ID:
			set_string_value (&MenuColors[MENU_BACK_ITEM][0], item.data.string,
												&change_flags, CHANGED_MENU);
			break;
		case LOOK_MenuBackColor_ID:
			set_string_value (&MenuColors[MENU_BACK_ITEM][1], item.data.string,
												&change_flags, CHANGED_MENU);
			break;
		case LOOK_MenuHiForeColor_ID:
			set_string_value (&MenuColors[MENU_BACK_HILITE][0], item.data.string,
												&change_flags, CHANGED_MENU);
			break;
		case LOOK_MenuHiBackColor_ID:
			set_string_value (&MenuColors[MENU_BACK_HILITE][1], item.data.string,
												&change_flags, CHANGED_MENU);
			break;
		case LOOK_MenuStippleColor_ID:
			set_string_value (&MenuColors[MENU_BACK_STIPPLE][0],
												item.data.string, &change_flags, CHANGED_MENU);
			break;
		case LOOK_StdForeColor_ID:
			set_string_value (&WinColors[BACK_UNFOCUSED][0], item.data.string,
												&change_flags, CHANGED_WINDOW);
			break;
		case LOOK_StdBackColor_ID:
			set_string_value (&WinColors[BACK_UNFOCUSED][1], item.data.string,
												&change_flags, CHANGED_WINDOW);
			break;
		case LOOK_StickyForeColor_ID:
			set_string_value (&WinColors[BACK_STICKY][0], item.data.string,
												&change_flags, CHANGED_WINDOW);
			break;
		case LOOK_StickyBackColor_ID:
			set_string_value (&WinColors[BACK_STICKY][1], item.data.string,
												&change_flags, CHANGED_WINDOW);
			break;
		case LOOK_HiForeColor_ID:
			set_string_value (&WinColors[BACK_FOCUSED][0], item.data.string,
												&change_flags, CHANGED_WINDOW);
			break;
		case LOOK_HiBackColor_ID:
			set_string_value (&WinColors[BACK_FOCUSED][1], item.data.string,
												&change_flags, CHANGED_WINDOW);
			break;
		case LOOK_TitleTextMode_ID:
			TitleTextStyle = item.data.integer;
			set_flags (change_flags, CHANGED_WINDOW);
			break;

		case LOOK_TextureTypes_ID:
			array = &(TextureTypes[0]);	/* will process it down below */
			break;
		case LOOK_TitleTextureColor_ID:	/* title */
			if (pCurr->argc >= 2) {
				set_string_value (&WinTextureColors[BACK_FOCUSED][0],
													item.data.string, &change_flags, CHANGED_WINDOW);
				set_string_value (&WinTextureColors[BACK_FOCUSED][1],
													mystrdup (pCurr->argv[1]), &change_flags,
													CHANGED_WINDOW);
			}
			break;
		case LOOK_UTitleTextureColor_ID:	/* unfoc tit */
			if (pCurr->argc >= 2) {
				set_string_value (&WinTextureColors[BACK_UNFOCUSED][0],
													item.data.string, &change_flags, CHANGED_WINDOW);
				set_string_value (&WinTextureColors[BACK_UNFOCUSED][1],
													mystrdup (pCurr->argv[1]), &change_flags,
													CHANGED_WINDOW);
			}
			break;
		case LOOK_STitleTextureColor_ID:	/* stic tit */
			if (pCurr->argc >= 2) {
				set_string_value (&WinTextureColors[BACK_STICKY][0],
													item.data.string, &change_flags, CHANGED_WINDOW);
				set_string_value (&WinTextureColors[BACK_STICKY][1],
													mystrdup (pCurr->argv[1]), &change_flags,
													CHANGED_WINDOW);
			}
			break;
		case LOOK_MTitleTextureColor_ID:	/* menu title */
			if (pCurr->argc >= 2) {
				set_string_value (&MenuTextureColors[MENU_BACK_TITLE][0],
													item.data.string, &change_flags, CHANGED_MENU);
				set_string_value (&MenuTextureColors[MENU_BACK_TITLE][1],
													mystrdup (pCurr->argv[1]), &change_flags,
													CHANGED_MENU);
			}
			break;
		case LOOK_MenuTextureColor_ID:	/* menu items */
			if (pCurr->argc >= 2) {
				set_string_value (&MenuTextureColors[MENU_BACK_ITEM][0],
													item.data.string, &change_flags, CHANGED_MENU);
				set_string_value (&MenuTextureColors[MENU_BACK_ITEM][1],
													mystrdup (pCurr->argv[1]), &change_flags,
													CHANGED_MENU);
			}
			break;
		case LOOK_MenuHiTextureColor_ID:	/* sel items */
			if (pCurr->argc >= 2) {
				set_string_value (&MenuTextureColors[MENU_BACK_HILITE][0],
													item.data.string, &change_flags, CHANGED_MENU);
				set_string_value (&MenuTextureColors[MENU_BACK_HILITE][1],
													mystrdup (pCurr->argv[1]), &change_flags,
													CHANGED_MENU);
			}
			break;
		case LOOK_MenuPixmap_ID:		/* menu entry */
			set_string_value (&MenuPixmaps[MENU_BACK_ITEM], item.data.string,
												&change_flags, CHANGED_MENU);
			break;
		case LOOK_MenuHiPixmap_ID:	/* hil m entr */
			set_string_value (&MenuPixmaps[MENU_BACK_HILITE], item.data.string,
												&change_flags, CHANGED_MENU);
			break;
		case LOOK_MTitlePixmap_ID:	/* menu title */
			set_string_value (&MenuPixmaps[MENU_BACK_TITLE], item.data.string,
												&change_flags, CHANGED_MENU);
			break;
		case LOOK_TitlePixmap_ID:	/* foc tit */
			set_string_value (&WinPixmaps[BACK_FOCUSED], item.data.string,
												&change_flags, CHANGED_WINDOW);
			break;
		case LOOK_UTitlePixmap_ID:	/* unfoc tit */
			set_string_value (&WinPixmaps[BACK_UNFOCUSED], item.data.string,
												&change_flags, CHANGED_WINDOW);
			break;
		case LOOK_STitlePixmap_ID:	/* stick tit */
			set_string_value (&WinPixmaps[BACK_STICKY], item.data.string,
												&change_flags, CHANGED_WINDOW);
			break;

		case LOOK_ButtonTextureType_ID:
			ButtonTextureType = item.data.integer;
			break;
		case LOOK_ButtonBgColor_ID:
			set_string_value (&ButtonColors[1], item.data.string, &change_flags,
												CHANGED_ICON);
			break;
		case LOOK_ButtonTextureColor_ID:
			if (pCurr->argc >= 2) {
				set_string_value (&ButtonTextureColors[0], item.data.string,
													&change_flags, CHANGED_ICON);
				set_string_value (&ButtonTextureColors[1],
													mystrdup (pCurr->argv[1]), &change_flags,
													CHANGED_ICON);
			}
			break;
		case LOOK_ButtonPixmap_ID:
			set_string_value (&ButtonPixmap, item.data.string, &change_flags,
												CHANGED_ICON);
			break;
		default:
			item.ok_to_free = 1;
		}
		if (array != NULL) {
			if (item.data.int_array.size > BACK_STYLES + MENU_BACK_STYLES)
				item.data.int_array.size = BACK_STYLES + MENU_BACK_STYLES;
			spread_back_param_array (array, item.data.int_array.array,
															 item.data.int_array.size);
			item.ok_to_free = 1;

			if (item.data.int_array.size > 0) {
				set_flags (change_flags, CHANGED_WINDOW);
				if (item.data.int_array.size > 3)
					set_flags (change_flags, CHANGED_MENU);
			}
			array = NULL;
		}
	}

	ReadConfigItem (&item, NULL);

	if (get_flags (change_flags, CHANGED_WINDOW))
		for (i = 0; i < BACK_STYLES; i++) {
			MergeMyStyleText (mystyles_list, config->window_styles[i],
												Fonts[SET_WINDOW], WinColors[i][0],
												WinColors[i][1], TitleTextStyle);
			MergeMyStyleTextureOld (mystyles_list, config->window_styles[i],
															TextureTypes[i], WinTextureColors[i][0],
															WinTextureColors[i][0], WinPixmaps[i]);

			if (WinColors[i][0])
				free (WinColors[i][0]);
			if (WinColors[i][1])
				free (WinColors[i][1]);
			if (WinTextureColors[i][0])
				free (WinTextureColors[i][0]);
			if (WinTextureColors[i][1])
				free (WinTextureColors[i][1]);
			if (WinPixmaps[i])
				free (WinPixmaps[i]);
		}
	if (get_flags (change_flags, CHANGED_MENU))
		for (i = 0; i < MENU_BACK_STYLES; i++) {
			MergeMyStyleText (mystyles_list, config->menu_styles[i],
												Fonts[SET_MENU], MenuColors[i][0],
												MenuColors[i][0], -1);
			MergeMyStyleTextureOld (mystyles_list, config->menu_styles[i],
															TextureTypes[i + BACK_STYLES],
															MenuTextureColors[i][0],
															MenuTextureColors[i][0], MenuPixmaps[i]);
			if (MenuColors[i][0])
				free (MenuColors[i][0]);
			if (MenuColors[i][1])
				free (MenuColors[i][1]);
			if (MenuTextureColors[i][0])
				free (MenuTextureColors[i][0]);
			if (MenuTextureColors[i][1])
				free (MenuTextureColors[i][1]);
			if (MenuPixmaps[i])
				free (MenuPixmaps[i]);
		}
	if (get_flags (change_flags, CHANGED_ICON)) {
		for (i = 0; i < BACK_STYLES; i++) {
			MergeMyStyleText (mystyles_list, button_title_styles[i],
												Fonts[SET_ICON], ButtonColors[0], ButtonColors[1],
												-1);
			MergeMyStyleTextureOld (mystyles_list, button_title_styles[i],
															ButtonTextureType, ButtonTextureColors[0],
															ButtonTextureColors[0], ButtonPixmap);
		}
		if (ButtonColors[0])
			free (ButtonColors[0]);
		if (ButtonColors[1])
			free (ButtonColors[1]);
		if (ButtonTextureColors[0])
			free (ButtonTextureColors[0]);
		if (ButtonTextureColors[1])
			free (ButtonTextureColors[1]);
		if (ButtonPixmap)
			free (ButtonPixmap);
	}

	for (i = 0; i < SET_NUM; i++)
		if (Fonts[i])
			free (Fonts[i]);

}


LookConfig *ParseLookOptions (const char *filename, char *myname)
{
	ConfigData cd;
	ConfigDef *ConfigReader;
	LookConfig *config = CreateLookConfig ();
	FreeStorageElem *Storage = NULL, *pCurr;
	ConfigItem item;
	MyFrameDefinition **frames_tail = &(config->frame_defs);
	MyBackgroundConfig **backs_tail = &(config->back_defs);

	cd.filename = filename;
	ConfigReader =
			InitConfigReader (myname, &LookSyntax, CDT_Filename, cd, NULL);
	if (!ConfigReader)
		return config;

	item.memory = NULL;
	PrintConfigReader (ConfigReader);
	ParseConfig (ConfigReader, &Storage);

	/* getting rid of all the crap first */
	StorageCleanUp (&Storage, &(config->more_stuff), CF_DISABLED_OPTION);
	config->title_balloon_conf =
			Process_balloonOptions (Storage, NULL, TITLE_BALLOON_ID_START);
	config->menu_balloon_conf =
			Process_balloonOptions (Storage, NULL, MENU_BALLOON_ID_START);

	config->style_defs = free_storage2MyStyleDefinitionsList (Storage);

	for (pCurr = Storage; pCurr; pCurr = pCurr->next) {
		register int id;

		if (pCurr->term == NULL)
			continue;
		id = pCurr->term->id;
		if (id == BGR_MYBACKGROUND) {
			if ((*backs_tail =
					 ParseMyBackgroundOptions (pCurr->sub, myname)) != NULL)
				backs_tail = &((*backs_tail)->next);
			continue;
		}

		if (id < LOOK_SUPPORTED_ID_START && id > LOOK_SUPPORTED_ID_END)
			continue;
		if (ReadFlagItem
				(&(config->set_flags), &(config->flags), pCurr, LookFlagsXref))
			continue;
		if (!ReadConfigItem (&item, pCurr))
			continue;
		if (id >= LOOK_WindowStyle_ID_START && id < LOOK_WindowStyle_ID_END) {
			id -= LOOK_WindowStyle_ID_START;
			set_string (&(config->window_styles[id]), item.data.string);
		} else if (id >= LOOK_MenuStyle_ID_START && id < LOOK_MenuStyle_ID_END) {
			id -= LOOK_MenuStyle_ID_START;
			set_string (&(config->menu_styles[id]), item.data.string);
		} else {
			switch (pCurr->term->id) {
			case LOOK_IconBox_ID:
				{
					register int bnum = config->icon_boxes_num++;

					config->icon_boxes =
							saferealloc (config->icon_boxes,
													 config->icon_boxes_num * sizeof (ASBox));
					config->icon_boxes[bnum] = item.data.box;
				}
				break;
#define SET_ONOFF_FLAG(i,f,sf,v) if(i)set_flags((f),(v));else clear_flags((f),(v)); set_flags((sf),(v))
			case LOOK_MArrowPixmap_ID:	/* menu arrow */
				set_string (&(config->menu_arrow), item.data.string);
				break;
			case LOOK_MenuPinOn_ID:	/* menu pin */
				set_string (&(config->menu_pin_on), item.data.string);
				break;

			case LOOK_TitleTextAlign_ID:
				config->title_text_align = item.data.integer;
				set_flags (config->set_flags, LOOK_TitleTextAlign);
				break;
			case LOOK_TitleButtonSpacing_ID:
				config->title_button_spacing = item.data.integer;
				set_flags (config->set_flags, LOOK_TitleButtonSpacing);
				break;
			case LOOK_TitleButtonStyle_ID:
				config->title_button_style = item.data.integer;
				set_flags (config->set_flags, LOOK_TitleButtonStyle);
				break;
			case LOOK_TitleButtonXOffset_ID:
				config->title_button_x_offset = item.data.integer;
				set_flags (config->set_flags, LOOK_TitleButtonXOffset);
				break;
			case LOOK_TitleButtonYOffset_ID:
				config->title_button_y_offset = item.data.integer;
				set_flags (config->set_flags, LOOK_TitleButtonYOffset);
				break;
			case LOOK_TitleButton_ID:
				if (item.data.button != NULL) {
					if (config->normal_buttons[item.index])
						destroy_asbutton (config->normal_buttons[item.index], False);
					config->normal_buttons[item.index] = item.data.button;
				} else
					item.ok_to_free = 1;
				break;
			case LOOK_ResizeMoveGeometry_ID:
				config->resize_move_geometry = item.data.geometry;
				set_flags (config->set_flags, LOOK_ResizeMoveGeometry);
				break;
			case LOOK_StartMenuSortMode_ID:
				config->start_menu_sort_mode = item.data.integer;
				set_flags (config->set_flags, LOOK_StartMenuSortMode);
				break;
			case LOOK_DrawMenuBorders_ID:
				config->draw_menu_borders = item.data.integer;
				set_flags (config->set_flags, LOOK_DrawMenuBorders);
				break;
			case LOOK_ButtonSize_ID:
				config->button_size = item.data.box;
				set_flags (config->set_flags, LOOK_ButtonSize);
				break;

			case LOOK_RubberBand_ID:
				config->rubber_band = item.data.integer;
				set_flags (config->set_flags, LOOK_RubberBand);
				break;
			case LOOK_ShadeAnimationSteps_ID:
				config->shade_animation_steps = item.data.integer;
				set_flags (config->set_flags, LOOK_ShadeAnimationSteps);
				break;

			case MYFRAME_START_ID:
				frames_tail = ProcessMyFrameOptions (pCurr->sub, frames_tail);
				item.ok_to_free = 1;
				break;

			case LOOK_DeskBack_ID:
				break;

			case LOOK_SupportedHints_ID:
				if (config->supported_hints)
					destroy_hints_list (&(config->supported_hints));
				config->supported_hints = ProcessSupportedHints (pCurr->sub);
				item.ok_to_free = 1;
				break;

			default:
				item.ok_to_free = 1;
			}
		}
	}
	if (config->icon_boxes_num >= MAX_BOXES)
		config->icon_boxes_num = MAX_BOXES;

	ReadConfigItem (&item, NULL);

	merge_depreciated_options (config, Storage);

	DestroyConfig (ConfigReader);
	DestroyFreeStorage (&Storage);
	return config;
}

/* returns:
 *            0 on success
 *              1 if data is empty
 *              2 if ConfigWriter cannot be initialized
 *
 */
int
WriteLookOptions (const char *filename, char *myname, LookConfig * config,
									unsigned long flags)
{
	ConfigData cd;
	ConfigDef *ConfigWriter = NULL;
	FreeStorageElem *Storage = NULL, **tail = &Storage;
	register int i;

	if (config == NULL)
		return 1;
	cd.filename = filename;
	if ((ConfigWriter =
			 InitConfigWriter (myname, &LookSyntax, CDT_Filename, cd)) == NULL)
		return 2;

	CopyFreeStorage (&Storage, config->more_stuff);

	/* building free storage here */
	/* MyStyles go first */
	if (config->style_defs)
		*tail =
				MyStyleDefinitionsList2free_storage (config->style_defs,
																						 &LookSyntax);

	/* then MyFrames */
	if (config->frame_defs)
		tail = MyFrameDefs2FreeStorage (&LookSyntax, tail, config->frame_defs);

	/* Window Styles */
	for (i = 0; i < BACK_STYLES; i++)
		if (config->window_styles[i])
			tail =
					QuotedString2FreeStorage (&LookSyntax, tail, NULL,
																		config->window_styles[i],
																		LOOK_WindowStyle_ID_START + i);

	/* Menu Styles */
	for (i = 0; i < MENU_BACK_STYLES; i++)
		if (config->menu_styles[i])
			tail =
					QuotedString2FreeStorage (&LookSyntax, tail, NULL,
																		config->menu_styles[i],
																		LOOK_MenuStyle_ID_START + i);

	/* Menu Icons */
	if (config->menu_arrow)
		tail =
				String2FreeStorage (&LookSyntax, tail, config->menu_arrow,
														LOOK_MArrowPixmap_ID);
	if (config->menu_pin_on)
		tail =
				String2FreeStorage (&LookSyntax, tail, config->menu_pin_on,
														LOOK_MenuPinOn_ID);
	/* Other Misc stuff */
	if (get_flags (config->set_flags, LOOK_StartMenuSortMode))
		tail =
				Integer2FreeStorage (&LookSyntax, tail, NULL,
														 config->start_menu_sort_mode,
														 LOOK_StartMenuSortMode_ID);
	if (get_flags (config->set_flags, LOOK_DrawMenuBorders))
		tail =
				Integer2FreeStorage (&LookSyntax, tail, NULL,
														 config->draw_menu_borders,
														 LOOK_DrawMenuBorders_ID);
	if (get_flags (config->set_flags, LOOK_RubberBand))
		tail =
				Integer2FreeStorage (&LookSyntax, tail, NULL, config->rubber_band,
														 LOOK_RubberBand_ID);
	if (get_flags (config->set_flags, LOOK_ShadeAnimationSteps))
		tail =
				Integer2FreeStorage (&LookSyntax, tail, NULL,
														 config->shade_animation_steps,
														 LOOK_ShadeAnimationSteps_ID);
	/* flags : */
	tail =
			Flags2FreeStorage (&LookSyntax, tail, LookFlagsXref,
												 config->set_flags, config->flags);

	/* ResizeMove window geometry */
	if (get_flags (config->set_flags, LOOK_ResizeMoveGeometry))
		tail =
				Geometry2FreeStorage (&LookSyntax, tail,
															&(config->resize_move_geometry),
															LOOK_ResizeMoveGeometry_ID);
	/* Icon boxes and size */
	for (i = 0; i < config->icon_boxes_num; i++)
		tail =
				Box2FreeStorage (&LookSyntax, tail, &(config->icon_boxes[i]),
												 LOOK_IconBox_ID);
	if (get_flags (config->set_flags, LOOK_ButtonSize))
		tail =
				Box2FreeStorage (&LookSyntax, tail, &(config->button_size),
												 LOOK_ButtonSize_ID);
	/* TitleButtons config: */
/*    if (config->balloon_conf)
        tail = balloon2FreeStorage (&LookSyntax, tail, config->balloon_conf); */

	if (get_flags (config->set_flags, LOOK_TitleTextAlign))
		tail =
				Integer2FreeStorage (&LookSyntax, tail, NULL,
														 config->title_text_align,
														 LOOK_TitleTextAlign_ID);
	if (get_flags (config->set_flags, LOOK_TitleButtonStyle))
		tail =
				Integer2FreeStorage (&LookSyntax, tail, NULL,
														 config->title_button_style,
														 LOOK_TitleButtonStyle_ID);
	if (get_flags (config->set_flags, LOOK_TitleButtonXOffset))
		tail =
				Integer2FreeStorage (&LookSyntax, tail, NULL,
														 config->title_button_x_offset,
														 LOOK_TitleButtonXOffset_ID);
	if (get_flags (config->set_flags, LOOK_TitleButtonYOffset))
		tail =
				Integer2FreeStorage (&LookSyntax, tail, NULL,
														 config->title_button_y_offset,
														 LOOK_TitleButtonYOffset_ID);
	if (get_flags (config->set_flags, LOOK_TitleButtonSpacing))
		tail =
				Integer2FreeStorage (&LookSyntax, tail, NULL,
														 config->title_button_spacing,
														 LOOK_TitleButtonSpacing_ID);

	/* then Supported Hints : */
	if (config->supported_hints)
		tail =
				SupportedHints2FreeStorage (&LookSyntax, tail,
																		config->supported_hints);

	/* Normal Title Buttons : */
	for (i = 0; i < MAX_BUTTONS; i++)
		if (config->normal_buttons[i] != NULL)
			tail =
					ASButton2FreeStorage (&LookSyntax, tail, i,
																config->normal_buttons[i],
																LOOK_TitleButton_ID);

	/* writing config into the file */
	cd.filename = filename;
	WriteConfig (ConfigWriter, Storage, CDT_Filename, &cd, flags);
	DestroyFreeStorage (&Storage);
	DestroyConfig (ConfigWriter);

	if (Storage) {
		fprintf (stderr,
						 "\n%s:Config Writing warning: Not all Free Storage discarded! Trying again...",
						 myname);
		DestroyFreeStorage (&Storage);
		fprintf (stderr, (Storage != NULL) ? " failed." : " success.");
	}
	return 0;
}

#if 0
MyLook *LookConfig2MyLook (struct LookConfig * config, MyLook * look,
													 struct ASImageManager * imman,
													 struct ASFontManager * fontman,
													 Bool free_resources, Bool do_init,
													 unsigned long what_flags)
{
	register int i;

	if (look) {
		if (look->magic != MAGIC_MYLOOK)
			look = mylook_create ();
		else if (do_init)
			mylook_init (look, free_resources, what_flags);
	} else
		look = mylook_create ();

	if (get_flags (what_flags, LL_Flags))
		look->flags = (look->flags & ~config->set_flags) | config->flags;

	if (get_flags (what_flags, LL_MyStyles)) {
		MyStyleDefinition *pCurr;

		look->styles_list = mystyle_list_init ();
		for (pCurr = config->style_defs; pCurr; pCurr = pCurr->next)
			mystyle_list_create_from_definition (look->styles_list, pCurr, imman,
																					 fontman);

/*	DestroyMyStyleDefinitions (list); */
		if (config->style_defs != NULL)
			mystyle_list_fix_styles (look->styles_list, imman, fontman);

		if (get_flags (what_flags, LL_MSMenu)) {	/* menu MyStyles */
			for (i = 0; i < MENU_BACK_STYLES; i++)
				if (config->menu_styles[i] != NULL)
					look->MSMenu[i] =
							mystyle_list_new (look->styles_list, config->menu_styles[i]);
		}

		if (get_flags (what_flags, LL_MSWindow)) {	/* focussed, unfocussed, sticky window styles */
			for (i = 0; i < BACK_STYLES; i++)
				if (config->window_styles[i] != NULL)
					look->MSWindow[i] =
							mystyle_list_new (look->styles_list,
																config->window_styles[i]);
		}
	}

	if (get_flags (what_flags, LL_DeskBacks)) {
		MyBackgroundConfig *pcurr;
		MyBackground *myback;

		init_deskbacks_list (look);
		for (pcurr = config->back_defs; pcurr; pcurr = pcurr->next)
			if ((myback = render_myback (look, pcurr, imman)) != NULL)
				add_myback_to_list (look->backs_list, myback, imman);
	}
	if (get_flags (what_flags, LL_DeskConfigs)) {
		register DesktopConfig *pcurr;

		init_deskconfigs_list (look);

		for (pcurr = config->desk_configs; pcurr; pcurr = pcurr->next) {
			MyDesktopConfig *dc = safecalloc (1, sizeof (MyDesktopConfig));

			dc->desk = pcurr->desk;
			dc->back_name = pcurr->back_name;
			dc->layout_name = pcurr->layout_name;
			pcurr->back_name = pcurr->layout_name = NULL;

			add_deskconfig_to_list (look->desk_configs, dc);
		}
	}

	if (get_flags (what_flags, LL_MenuIcons)) {
		if (config->menu_arrow)
			look->MenuArrow = filename2asicon (config->menu_arrow, imman);
		if (config->menu_pin_on)
			look->MenuPinOn = filename2asicon (config->menu_pin_on, imman);
		if (config->menu_pin_off)
			look->MenuPinOff = filename2asicon (config->menu_pin_off, imman);
	}

	if (get_flags (what_flags, LL_Buttons)) {	/* TODO: Titlebuttons - we 'll move them into  MyStyles */
		check_ascontextbuttons (&(look->normal_buttons), ASC_TitleButton_Start,
														ASC_TitleButton_End);
		check_ascontextbuttons (&(look->icon_buttons), ASC_TitleButton_Start,
														ASC_TitleButton_End);
		/* we will translate button numbers from the user input */
		for (i = 0; i <= ASC_TitleButton_End - ASC_TitleButton_Start; i++) {
			look->normal_buttons.buttons[i] =
					dup_asbutton (config->normal_buttons[i]);
			if (look->normal_buttons.buttons[i]) {
				int s;

				for (s = 0; s < ASB_StateCount; ++s)
					if (look->normal_buttons.buttons[i]->shapes[s])
						load_asicon (look->normal_buttons.buttons[i]->shapes[s], NULL,
												 imman);

				look->buttons[i] =
						look->normal_buttons.buttons[i]->shapes[ASB_State_Up];
				look->dbuttons[i] =
						look->normal_buttons.buttons[i]->shapes[ASB_State_Down];
			} else {
				look->buttons[i] = NULL;
				look->dbuttons[i] = NULL;
			}

			look->icon_buttons.buttons[i] =
					dup_asbutton (config->icon_buttons[i]);
			if (look->icon_buttons.buttons[i]) {
				int s;

				for (s = 0; s < ASB_StateCount; ++s)
					if (look->icon_buttons.buttons[i]->shapes[s])
						load_asicon (look->icon_buttons.buttons[i]->shapes[s], NULL,
												 imman);
			}
		}
	}

	if (get_flags (what_flags, LL_SizeWindow)) {
		MyStyle *focus_style = look->MSWindow[BACK_FOCUSED];
		int width = -1, height = -1;

		if (focus_style) {
			int max_digits = 1;
			char *test_str;
			unsigned long test_val = (Scr.VxMax + Scr.MyDisplayWidth) * 3;

			if (test_val < (Scr.VyMax + Scr.MyDisplayHeight) * 3)
				test_val = (Scr.VyMax + Scr.MyDisplayHeight) * 3;
			while ((test_val / (10 * max_digits)) > 0)
				max_digits++;

			test_str = safemalloc (max_digits * 4 + 11);
			sprintf (test_str, " %lu x %lu %+ld %+ld ", test_val, test_val,
							 test_val, test_val);
/*			mystyle_get_text_geometry(focus_style, test_str, strlen(test_str), &width, &height); */
			free (test_str);
		}

		if (get_flags (config->set_flags, LOOK_ResizeMoveGeometry))
			look->resize_move_geometry = config->resize_move_geometry;
		else
			look->resize_move_geometry.flags = 0;
		if (!get_flags (look->resize_move_geometry.flags, WidthValue)
				&& width > 0) {
			look->resize_move_geometry.width = width;
			set_flags (look->resize_move_geometry.flags, WidthValue);
		}

		if (!get_flags (look->resize_move_geometry.flags, HeightValue)
				&& height > 0) {
			look->resize_move_geometry.height = height;
			set_flags (look->resize_move_geometry.flags, HeightValue);
		}
	}

	if (get_flags (what_flags, LL_Layouts)) {
		MyFrameDefinition *frame_def = config->frame_defs;

		look->TitleTextAlign = get_flags (config->set_flags, LOOK_TitleTextAlign) ? config->title_text_align : 0;	/* alignment of title bar text */
		look->TitleButtonSpacing =
				get_flags (config->set_flags,
									 LOOK_TitleButtonSpacing) ? config->
				title_button_spacing : 3;
		look->TitleButtonStyle = get_flags (config->set_flags, LOOK_TitleButtonStyle) ? config->title_button_style : 0;	/* 0 - afterstep, 1 - WM old, 2 - free hand */
		look->TitleButtonXOffset =
				get_flags (config->set_flags,
									 LOOK_TitleButtonXOffset) ? config->
				title_button_x_offset : 0;
		look->TitleButtonYOffset =
				get_flags (config->set_flags,
									 LOOK_TitleButtonYOffset) ? config->
				title_button_y_offset : 0;
		look->TitleButtonStyle %= 3;
		switch (look->TitleButtonStyle) {
		case 0:										/* traditional AfterStep style */
			look->TitleButtonXOffset[0] = look->TitleButtonXOffset[1] = 3;
			look->TitleButtonYOffset[0] = look->TitleButtonYOffset[1] = 3;
			break;
		case 1:
			look->TitleButtonXOffset[0] = look->TitleButtonXOffset[1] = 1;
			look->TitleButtonYOffset[0] = look->TitleButtonYOffset[1] = 1;
			break;
		case 2:										/* advanced AfterStep style */
			/* nothing to do here - user must supply values for x/y offsets */
			break;
		}
		mylook_init_layouts (look);

		while (frame_def != NULL) {
			add_frame_to_list (look->layouts,
												 filenames2myframe (frame_def->name,
																						frame_def->parts, imman));
			frame_def = frame_def->next;
		}
		if (config->menu_frame) {
			ASHashData hdata = { 0 };
			if (get_hash_item
					(look->layouts, (ASHashableValue) config->menu_frame,
					 &hdata.vptr) != ASH_Success)
				look->menu_frame = NULL;
			else
				look->menu_frame = hdata.vptr;
		}
	}

	if (get_flags (what_flags, LL_Buttons) && look->layouts) {
		update_titlebar_buttons (look->layouts, NULL, False,
														 &(look->normal_buttons));
		update_titlebar_buttons (look->layouts, NULL, True,
														 &(look->icon_buttons));
	}

	if (get_flags (what_flags, LL_Boundary))
		look->BoundaryWidth = BOUNDARY_WIDTH;	/* not a configuration option yet */

	if (get_flags (what_flags, LL_MenuParams)) {
		look->DrawMenuBorders =
				get_flags (config->set_flags,
									 LOOK_DrawMenuBorders) ? config->draw_menu_borders : 1;
		look->StartMenuSortMode =
				get_flags (config->set_flags,
									 LOOK_StartMenuSortMode) ? config->
				start_menu_sort_mode : SORTBYALPHA;
	}

	if (get_flags (what_flags, LL_Icons)) {
		for (i = 0; i < config->icon_boxes_num; i++) {
			look->IconBoxes[i] = config->icon_boxes[i];
			while (look->IconBoxes[i].left < 0)
				look->IconBoxes[i].left += Scr.MyDisplayWidth;
			if (look->IconBoxes[i].left == 0
					&& get_flags (look->IconBoxes[i].flags, LeftNegative))
				look->IconBoxes[i].left = Scr.MyDisplayWidth;

			while (look->IconBoxes[i].top < 0)
				look->IconBoxes[i].top += Scr.MyDisplayHeight;
			if (look->IconBoxes[i].top == 0
					&& get_flags (look->IconBoxes[i].flags, TopNegative))
				look->IconBoxes[i].top = Scr.MyDisplayHeight;

			while (look->IconBoxes[i].right < 0)
				look->IconBoxes[i].right += Scr.MyDisplayWidth;
			if (look->IconBoxes[i].right == 0
					&& get_flags (look->IconBoxes[i].flags, RightNegative))
				look->IconBoxes[i].right = Scr.MyDisplayWidth;

			while (look->IconBoxes[i].bottom < 0)
				look->IconBoxes[i].bottom += Scr.MyDisplayHeight;
			if (look->IconBoxes[i].bottom == 0
					&& get_flags (look->IconBoxes[i].flags, BottomNegative))
				look->IconBoxes[i].bottom = Scr.MyDisplayHeight;
		}
		look->NumBoxes = config->icon_boxes_num;
		if (get_flags (config->set_flags, LOOK_ButtonSize)) {
			look->ButtonWidth = config->button_size.left;
			look->ButtonHeight = config->button_size.top;
		}
	}

	if (get_flags (what_flags, LL_Misc)) {
		look->RubberBand =
				get_flags (config->set_flags,
									 LOOK_RubberBand) ? config->rubber_band : 0;
		look->ShadeAnimationSteps =
				get_flags (config->set_flags,
									 LOOK_ShadeAnimationSteps) ? config->
				shade_animation_steps : 12;
	}

	if (get_flags (what_flags, LL_Balloons)) {
/*	
		look->balloon_look = balloon_look_new ();
		if (config->menu_balloon_conf)
			BalloonConfig2BalloonLook (look->menu_balloon_look, config->balloon_conf);
*/
	}

	if (get_flags (what_flags, LL_SupportedHints)) {
		if (config->supported_hints) {
			look->supported_hints = config->supported_hints;
			config->supported_hints = NULL;
		} else {										/* Otherwise we should enable all the hints possible in standard order : */
			look->supported_hints = create_hints_list ();
			enable_hints_support (look->supported_hints, HINTS_ICCCM);
			enable_hints_support (look->supported_hints, HINTS_Motif);
			enable_hints_support (look->supported_hints, HINTS_Gnome);
			enable_hints_support (look->supported_hints, HINTS_KDE);
			enable_hints_support (look->supported_hints, HINTS_ExtendedWM);
			enable_hints_support (look->supported_hints, HINTS_ASDatabase);
			enable_hints_support (look->supported_hints, HINTS_GroupLead);
			enable_hints_support (look->supported_hints, HINTS_Transient);
		}
	}

	return look;
}

#endif


/******************************************************************************
 * Test cases and utilities
 ******************************************************************************/