Change to the linux kernel coding style
[wmaker-crm.git] / WPrefs.app / FontSimple.c
1 /* FontSimple.c- simplified font configuration panel
2 *
3 * WPrefs - Window Maker Preferences Program
4 *
5 * Copyright (c) 1998-2004 Alfredo K. Kojima
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
20 * USA.
21 */
22
23 #include "WPrefs.h"
24 #include <unistd.h>
25 #include <fontconfig/fontconfig.h>
26
27 /* workaround for older fontconfig, that doesn't define these constants */
28 #ifndef FC_WEIGHT_NORMAL
29 /* Weights */
30 # define FC_WEIGHT_THIN 10
31 # define FC_WEIGHT_EXTRALIGHT 40
32 # define FC_WEIGHT_ULTRALIGHT FC_WEIGHT_EXTRALIGHT
33 # define FC_WEIGHT_REGULAR 80
34 # define FC_WEIGHT_NORMAL FC_WEIGHT_REGULAR
35 # define FC_WEIGHT_SEMIBOLD FC_WEIGHT_DEMIBOLD
36 # define FC_WEIGHT_EXTRABOLD 205
37 # define FC_WEIGHT_ULTRABOLD FC_WEIGHT_EXTRABOLD
38 # define FC_WEIGHT_HEAVY FC_WEIGHT_BLACK
39 /* Widths */
40 # define FC_WIDTH "width"
41 # define FC_WIDTH_ULTRACONDENSED 50
42 # define FC_WIDTH_EXTRACONDENSED 63
43 # define FC_WIDTH_CONDENSED 75
44 # define FC_WIDTH_SEMICONDENSED 87
45 # define FC_WIDTH_NORMAL 100
46 # define FC_WIDTH_SEMIEXPANDED 113
47 # define FC_WIDTH_EXPANDED 125
48 # define FC_WIDTH_EXTRAEXPANDED 150
49 # define FC_WIDTH_ULTRAEXPANDED 200
50 #endif
51
52 #define SAMPLE_TEXT "The Lazy Fox Jumped Ipsum Foobar 1234 - 56789"
53
54 typedef struct {
55 int weight;
56 int width;
57 int slant;
58 } FontStyle;
59
60 typedef struct {
61 char *name;
62 int stylen;
63 FontStyle *styles;
64 } FontFamily;
65
66 typedef struct {
67 int familyn;
68 FontFamily *families;
69 } FontList;
70
71 typedef struct _Panel {
72 WMBox *box;
73 char *sectionName;
74
75 char *description;
76
77 CallbackRec callbacks;
78
79 WMWidget *parent;
80
81 WMPopUpButton *optionP;
82
83 WMList *familyL;
84 WMList *styleL;
85
86 WMList *sizeL;
87
88 WMTextField *sampleT;
89
90 FontList *fonts;
91 } _Panel;
92
93 #define ICON_FILE "fonts"
94
95 static struct {
96 char *option;
97 char *label;
98 } fontOptions[] = {
99 {
100 "WindowTitleFont", N_("Window Title")}, {
101 "MenuTitleFont", N_("Menu Title")}, {
102 "MenuTextFont", N_("Menu Text")}, {
103 "IconTitleFont", N_("Icon Title")}, {
104 "ClipTitleFont", N_("Clip Title")}, {
105 "LargeDisplayFont", N_("Desktop Caption")}, {
106 NULL, NULL},};
107
108 static char *standardSizes[] = {
109 "6",
110 "8",
111 "9",
112 "10",
113 "11",
114 "12",
115 "13",
116 "14",
117 "15",
118 "16",
119 "18",
120 "20",
121 "22",
122 "24",
123 "28",
124 "32",
125 "36",
126 "48",
127 "64",
128 "72",
129 NULL
130 };
131
132 static struct {
133 int weight;
134 char *name;
135 } fontWeights[] = {
136 {
137 FC_WEIGHT_THIN, "Thin"}, {
138 FC_WEIGHT_EXTRALIGHT, "ExtraLight"}, {
139 FC_WEIGHT_LIGHT, "Light"}, {
140 FC_WEIGHT_NORMAL, "Normal"}, {
141 FC_WEIGHT_MEDIUM, ""}, /*"medium"}, */
142 {
143 FC_WEIGHT_DEMIBOLD, "DemiBold"}, {
144 FC_WEIGHT_BOLD, "Bold"}, {
145 FC_WEIGHT_EXTRABOLD, "ExtraBold"}, {
146 FC_WEIGHT_BLACK, "Black"}, {
147 0, NULL}
148 };
149
150 static struct {
151 int slant;
152 char *name;
153 } fontSlants[] = {
154 {
155 FC_SLANT_ROMAN, ""}, /*"Roman"}, */
156 {
157 FC_SLANT_ITALIC, "Italic"}, {
158 FC_SLANT_OBLIQUE, "Oblique"}, {
159 0, NULL}
160 };
161
162 static struct {
163 int width;
164 char *name;
165 } fontWidths[] = {
166 {
167 FC_WIDTH_ULTRACONDENSED, "UltraCondensed"}, {
168 FC_WIDTH_EXTRACONDENSED, "ExtraCondensed"}, {
169 FC_WIDTH_CONDENSED, "Condensed"}, {
170 FC_WIDTH_SEMICONDENSED, "SemiCondensed"}, {
171 FC_WIDTH_NORMAL, ""}, /*"normal"}, */
172 {
173 FC_WIDTH_SEMIEXPANDED, "SemiExpanded"}, {
174 FC_WIDTH_EXPANDED, "Expanded"}, {
175 FC_WIDTH_EXTRAEXPANDED, "ExtraExpanded"}, {
176 FC_WIDTH_ULTRAEXPANDED, "UltraExpanded"}, {
177 0, NULL}
178 };
179
180 static int compare_family(const void *a, const void *b)
181 {
182 FontFamily *fa = (FontFamily *) a;
183 FontFamily *fb = (FontFamily *) b;
184 return strcmp(fa->name, fb->name);
185 }
186
187 static int compare_styles(const void *a, const void *b)
188 {
189 FontStyle *sa = (FontStyle *) a;
190 FontStyle *sb = (FontStyle *) b;
191 int compare;
192
193 compare = sa->weight - sb->weight;
194 if (compare != 0)
195 return compare;
196 compare = sa->slant - sb->slant;
197 if (compare != 0)
198 return compare;
199 return (sa->width - sb->width);
200 }
201
202 static void lookup_available_fonts(_Panel * panel)
203 {
204 FcPattern *pat = FcPatternCreate();
205 FcObjectSet *os;
206 FcFontSet *fonts;
207 FontFamily *family;
208
209 os = FcObjectSetBuild(FC_FAMILY, FC_WEIGHT, FC_WIDTH, FC_SLANT, NULL);
210
211 fonts = FcFontList(0, pat, os);
212
213 if (fonts) {
214 int i;
215
216 panel->fonts = wmalloc(sizeof(FontList));
217 panel->fonts->familyn = 0;
218 panel->fonts->families = wmalloc(sizeof(FontFamily) * fonts->nfont);
219
220 for (i = 0; i < fonts->nfont; i++) {
221 char *name;
222 int weight, slant, width;
223 int j, found;
224
225 if (FcPatternGetString(fonts->fonts[i], FC_FAMILY, 0, (FcChar8 **) & name) !=
226 FcResultMatch)
227 continue;
228
229 if (FcPatternGetInteger(fonts->fonts[i], FC_WEIGHT, 0, &weight) != FcResultMatch)
230 weight = FC_WEIGHT_MEDIUM;
231
232 if (FcPatternGetInteger(fonts->fonts[i], FC_WIDTH, 0, &width) != FcResultMatch)
233 width = FC_WIDTH_NORMAL;
234
235 if (FcPatternGetInteger(fonts->fonts[i], FC_SLANT, 0, &slant) != FcResultMatch)
236 slant = FC_SLANT_ROMAN;
237
238 found = -1;
239 for (j = 0; j < panel->fonts->familyn && found < 0; j++)
240 if (strcasecmp(panel->fonts->families[j].name, name) == 0)
241 found = j;
242
243 if (found < 0) {
244 panel->fonts->families[panel->fonts->familyn++].name = wstrdup(name);
245 family = panel->fonts->families + panel->fonts->familyn - 1;
246 family->stylen = 0;
247 family->styles = NULL;
248 } else
249 family = panel->fonts->families + found;
250
251 family->stylen++;
252 family->styles = wrealloc(family->styles, sizeof(FontStyle) * family->stylen);
253 family->styles[family->stylen - 1].weight = weight;
254 family->styles[family->stylen - 1].slant = slant;
255 family->styles[family->stylen - 1].width = width;
256 }
257 qsort(panel->fonts->families, panel->fonts->familyn, sizeof(FontFamily), compare_family);
258
259 for (i = 0; i < panel->fonts->familyn; i++) {
260 qsort(panel->fonts->families[i].styles, panel->fonts->families[i].stylen,
261 sizeof(FontStyle), compare_styles);
262 }
263
264 FcFontSetDestroy(fonts);
265 }
266 if (os)
267 FcObjectSetDestroy(os);
268 if (pat)
269 FcPatternDestroy(pat);
270
271 panel->fonts->families[panel->fonts->familyn++].name = wstrdup("sans serif");
272 family = panel->fonts->families + panel->fonts->familyn - 1;
273 family->styles = wmalloc(sizeof(FontStyle) * 2);
274 family->stylen = 2;
275 family->styles[0].weight = FC_WEIGHT_MEDIUM;
276 family->styles[0].slant = FC_SLANT_ROMAN;
277 family->styles[0].width = FC_WIDTH_NORMAL;
278 family->styles[1].weight = FC_WEIGHT_BOLD;
279 family->styles[1].slant = FC_SLANT_ROMAN;
280 family->styles[1].width = FC_WIDTH_NORMAL;
281
282 panel->fonts->families[panel->fonts->familyn++].name = wstrdup("serif");
283 family = panel->fonts->families + panel->fonts->familyn - 1;
284 family->styles = wmalloc(sizeof(FontStyle) * 2);
285 family->stylen = 2;
286 family->styles[0].weight = FC_WEIGHT_MEDIUM;
287 family->styles[0].slant = FC_SLANT_ROMAN;
288 family->styles[0].width = FC_WIDTH_NORMAL;
289 family->styles[1].weight = FC_WEIGHT_BOLD;
290 family->styles[1].slant = FC_SLANT_ROMAN;
291 family->styles[1].width = FC_WIDTH_NORMAL;
292 }
293
294 static char *getSelectedFont(_Panel * panel, FcChar8 * curfont)
295 {
296 WMListItem *item;
297 FcPattern *pat;
298 char *name;
299
300 if (curfont)
301 pat = FcNameParse(curfont);
302 else
303 pat = FcPatternCreate();
304
305 item = WMGetListSelectedItem(panel->familyL);
306 if (item) {
307 FcPatternDel(pat, FC_FAMILY);
308 FcPatternAddString(pat, FC_FAMILY, (FcChar8 *) item->text);
309 }
310
311 item = WMGetListSelectedItem(panel->styleL);
312 if (item) {
313 FontStyle *style = (FontStyle *) item->clientData;
314
315 FcPatternDel(pat, FC_WEIGHT);
316 FcPatternAddInteger(pat, FC_WEIGHT, style->weight);
317
318 FcPatternDel(pat, FC_WIDTH);
319 FcPatternAddInteger(pat, FC_WIDTH, style->width);
320
321 FcPatternDel(pat, FC_SLANT);
322 FcPatternAddInteger(pat, FC_SLANT, style->slant);
323 }
324
325 item = WMGetListSelectedItem(panel->sizeL);
326 if (item) {
327 FcPatternDel(pat, FC_PIXEL_SIZE);
328 FcPatternAddDouble(pat, FC_PIXEL_SIZE, atoi(item->text));
329 }
330
331 name = (char *)FcNameUnparse(pat);
332 FcPatternDestroy(pat);
333
334 return name;
335 }
336
337 static void updateSampleFont(_Panel * panel)
338 {
339 WMMenuItem *item = WMGetPopUpButtonMenuItem(panel->optionP,
340 WMGetPopUpButtonSelectedItem(panel->optionP));
341 char *fn = WMGetMenuItemRepresentedObject(item);
342
343 if (fn) {
344 WMFont *font = WMCreateFont(WMWidgetScreen(panel->box), fn);
345 if (font) {
346 WMSetTextFieldFont(panel->sampleT, font);
347 WMReleaseFont(font);
348 }
349 }
350 }
351
352 static void selectedFamily(WMWidget * w, void *data)
353 {
354 _Panel *panel = (_Panel *) data;
355 WMListItem *item;
356 FontStyle *oldStyle = NULL;
357 char buffer[1024];
358
359 item = WMGetListSelectedItem(panel->styleL);
360 if (item)
361 oldStyle = (FontStyle *) item->clientData;
362
363 item = WMGetListSelectedItem(panel->familyL);
364
365 if (item) {
366 FontFamily *family = (FontFamily *) item->clientData;
367 int i, oldi = 0, oldscore = 0;
368
369 WMClearList(panel->styleL);
370 for (i = 0; i < family->stylen; i++) {
371 int j;
372 char *weight = "", *slant = "", *width = "";
373 WMListItem *item;
374
375 for (j = 0; fontWeights[j].name; j++)
376 if (fontWeights[j].weight == family->styles[i].weight) {
377 weight = fontWeights[j].name;
378 break;
379 }
380 for (j = 0; fontWidths[j].name; j++)
381 if (fontWidths[j].width == family->styles[i].width) {
382 width = fontWidths[j].name;
383 break;
384 }
385 for (j = 0; fontSlants[j].name; j++)
386 if (fontSlants[j].slant == family->styles[i].slant) {
387 slant = fontSlants[j].name;
388 break;
389 }
390 sprintf(buffer, "%s%s%s%s%s",
391 weight, *weight ? " " : "", slant, (*slant || *weight) ? " " : "", width);
392 if (!buffer[0])
393 strcpy(buffer, "Roman");
394
395 item = WMAddListItem(panel->styleL, buffer);
396 item->clientData = family->styles + i;
397
398 if (oldStyle) {
399 int score = 0;
400
401 if (oldStyle->width == family->styles[i].width)
402 score |= 1;
403 if (oldStyle->weight == family->styles[i].weight)
404 score |= 2;
405 if (oldStyle->slant == family->styles[i].slant)
406 score |= 4;
407
408 if (score > oldscore) {
409 oldi = i;
410 oldscore = score;
411 }
412 }
413 }
414 WMSelectListItem(panel->styleL, oldi);
415
416 {
417 int index = WMGetPopUpButtonSelectedItem(panel->optionP);
418 WMMenuItem *item = WMGetPopUpButtonMenuItem(panel->optionP, index);
419 FcChar8 *ofont;
420 char *nfont;
421
422 ofont = (FcChar8 *) WMGetMenuItemRepresentedObject(item);
423 nfont = getSelectedFont(panel, ofont);
424 if (ofont)
425 wfree(ofont);
426 WMSetMenuItemRepresentedObject(item, nfont);
427 }
428 updateSampleFont(panel);
429 }
430 }
431
432 static void selected(WMWidget * w, void *data)
433 {
434 _Panel *panel = (_Panel *) data;
435 int index = WMGetPopUpButtonSelectedItem(panel->optionP);
436 WMMenuItem *item = WMGetPopUpButtonMenuItem(panel->optionP, index);
437 FcChar8 *ofont;
438 char *nfont;
439
440 ofont = (FcChar8 *) WMGetMenuItemRepresentedObject(item);
441 nfont = getSelectedFont(panel, ofont);
442 if (ofont)
443 wfree(ofont);
444
445 WMSetMenuItemRepresentedObject(item, nfont);
446
447 updateSampleFont(panel);
448 }
449
450 static void selectedOption(WMWidget * w, void *data)
451 {
452 _Panel *panel = (_Panel *) data;
453 int index = WMGetPopUpButtonSelectedItem(panel->optionP);
454 WMMenuItem *item = WMGetPopUpButtonMenuItem(panel->optionP, index);
455 char *font;
456
457 font = (char *)WMGetMenuItemRepresentedObject(item);
458 if (font) {
459 FcPattern *pat;
460
461 pat = FcNameParse((FcChar8 *) font);
462 if (pat) {
463 char *name;
464 int weight, slant, width;
465 double size;
466 int distance, closest, found;
467 int i;
468
469 FcDefaultSubstitute(pat);
470
471 if (FcPatternGetString(pat, FC_FAMILY, 0, (FcChar8 **) & name) != FcResultMatch)
472 name = "sans serif";
473
474 found = 0;
475 /* select family */
476 for (i = 0; i < WMGetListNumberOfRows(panel->familyL); i++) {
477 WMListItem *item = WMGetListItem(panel->familyL, i);
478 FontFamily *family = (FontFamily *) item->clientData;
479
480 if (strcasecmp(family->name, name) == 0) {
481 found = 1;
482 WMSelectListItem(panel->familyL, i);
483 WMSetListPosition(panel->familyL, i);
484 break;
485 }
486 }
487 if (!found)
488 WMSelectListItem(panel->familyL, -1);
489 selectedFamily(panel->familyL, panel);
490
491 /* select style */
492 if (FcPatternGetInteger(pat, FC_WEIGHT, 0, &weight) != FcResultMatch)
493 weight = FC_WEIGHT_NORMAL;
494 if (FcPatternGetInteger(pat, FC_WIDTH, 0, &width) != FcResultMatch)
495 width = FC_WIDTH_NORMAL;
496 if (FcPatternGetInteger(pat, FC_SLANT, 0, &slant) != FcResultMatch)
497 slant = FC_SLANT_ROMAN;
498
499 if (FcPatternGetDouble(pat, FC_PIXEL_SIZE, 0, &size) != FcResultMatch)
500 size = 10.0;
501
502 for (i = 0, found = 0, closest = 0; i < WMGetListNumberOfRows(panel->styleL); i++) {
503 WMListItem *item = WMGetListItem(panel->styleL, i);
504 FontStyle *style = (FontStyle *) item->clientData;
505
506 distance = ((abs(style->weight - weight) << 16) +
507 (abs(style->slant - slant) << 8) + (abs(style->width - width)));
508
509 if (i == 0 || distance < closest) {
510 closest = distance;
511 found = i;
512 if (distance == 0) {
513 break; /* perfect match */
514 }
515 }
516 }
517 WMSelectListItem(panel->styleL, found);
518 WMSetListPosition(panel->styleL, found);
519
520 for (i = 0, found = 0, closest = 0; i < WMGetListNumberOfRows(panel->sizeL); i++) {
521 WMListItem *item = WMGetListItem(panel->sizeL, i);
522 int distance;
523
524 distance = abs(size - atoi(item->text));
525
526 if (i == 0 || distance < closest) {
527 closest = distance;
528 found = i;
529 if (distance == 0) {
530 break; /* perfect match */
531 }
532 }
533 }
534 WMSelectListItem(panel->sizeL, found);
535 WMSetListPosition(panel->sizeL, found);
536
537 selected(NULL, panel);
538 } else
539 wwarning("Can't parse font '%s'", font);
540 }
541
542 updateSampleFont(panel);
543 }
544
545 static WMLabel *createListLabel(WMScreen * scr, WMWidget * parent, char *text)
546 {
547 WMLabel *label;
548 WMColor *color;
549 WMFont *boldFont = WMBoldSystemFontOfSize(scr, 12);
550
551 label = WMCreateLabel(parent);
552 WMSetLabelFont(label, boldFont);
553 WMSetLabelText(label, text);
554 WMSetLabelRelief(label, WRSunken);
555 WMSetLabelTextAlignment(label, WACenter);
556 color = WMDarkGrayColor(scr);
557 WMSetWidgetBackgroundColor(label, color);
558 WMReleaseColor(color);
559 color = WMWhiteColor(scr);
560 WMSetLabelTextColor(label, color);
561 WMReleaseColor(color);
562
563 WMReleaseFont(boldFont);
564
565 return label;
566 }
567
568 static void showData(_Panel * panel)
569 {
570 int i;
571 WMMenuItem *item;
572
573 for (i = 0; i < WMGetPopUpButtonNumberOfItems(panel->optionP); i++) {
574 char *ofont, *font;
575
576 item = WMGetPopUpButtonMenuItem(panel->optionP, i);
577
578 ofont = WMGetMenuItemRepresentedObject(item);
579 if (ofont)
580 wfree(ofont);
581
582 font = GetStringForKey(fontOptions[i].option);
583 if (font)
584 font = wstrdup(font);
585 WMSetMenuItemRepresentedObject(item, font);
586 }
587
588 WMSetPopUpButtonSelectedItem(panel->optionP, 0);
589 selectedOption(panel->optionP, panel);
590 }
591
592 static void storeData(_Panel * panel)
593 {
594 int i;
595 WMMenuItem *item;
596 for (i = 0; i < WMGetPopUpButtonNumberOfItems(panel->optionP); i++) {
597 char *font;
598
599 item = WMGetPopUpButtonMenuItem(panel->optionP, i);
600
601 font = WMGetMenuItemRepresentedObject(item);
602 if (font && *font) {
603 SetStringForKey(font, fontOptions[i].option);
604 }
605 }
606 }
607
608 static void createPanel(Panel * p)
609 {
610 _Panel *panel = (_Panel *) p;
611 WMScreen *scr = WMWidgetScreen(panel->parent);
612 WMLabel *label;
613 WMBox *hbox, *vbox;
614 int i;
615
616 lookup_available_fonts(panel);
617
618 panel->box = WMCreateBox(panel->parent);
619 WMSetViewExpandsToParent(WMWidgetView(panel->box), 5, 2, 5, 5);
620 WMSetBoxHorizontal(panel->box, False);
621 WMSetBoxBorderWidth(panel->box, 8);
622 WMMapWidget(panel->box);
623
624 hbox = WMCreateBox(panel->box);
625 WMSetBoxHorizontal(hbox, True);
626 WMAddBoxSubview(panel->box, WMWidgetView(hbox), False, True, 40, 22, 8);
627
628 vbox = WMCreateBox(hbox);
629 WMAddBoxSubview(hbox, WMWidgetView(vbox), False, True, 130, 0, 10);
630 WMSetBoxHorizontal(vbox, False);
631 panel->optionP = WMCreatePopUpButton(vbox);
632 WMAddBoxSubviewAtEnd(vbox, WMWidgetView(panel->optionP), False, True, 20, 0, 8);
633 for (i = 0; fontOptions[i].option; i++) {
634 WMAddPopUpButtonItem(panel->optionP, _(fontOptions[i].label));
635 }
636 WMSetPopUpButtonAction(panel->optionP, selectedOption, panel);
637
638 label = WMCreateLabel(hbox);
639 WMSetLabelText(label, _("Sample Text"));
640 WMSetLabelTextAlignment(label, WARight);
641 WMAddBoxSubview(hbox, WMWidgetView(label), False, True, 80, 0, 2);
642
643 panel->sampleT = WMCreateTextField(hbox);
644 WMSetViewExpandsToParent(WMWidgetView(panel->sampleT), 10, 18, 10, 10);
645 WMSetTextFieldText(panel->sampleT, SAMPLE_TEXT);
646 WMAddBoxSubview(hbox, WMWidgetView(panel->sampleT), True, True, 60, 0, 0);
647
648 hbox = WMCreateBox(panel->box);
649 WMSetBoxHorizontal(hbox, True);
650 WMAddBoxSubview(panel->box, WMWidgetView(hbox), True, True, 100, 0, 2);
651
652 vbox = WMCreateBox(hbox);
653 WMSetBoxHorizontal(vbox, False);
654 WMAddBoxSubview(hbox, WMWidgetView(vbox), False, True, 240, 20, 4);
655
656 label = createListLabel(scr, vbox, _("Family"));
657 WMAddBoxSubview(vbox, WMWidgetView(label), False, True, 20, 0, 2);
658
659 /* family */
660 panel->familyL = WMCreateList(vbox);
661 WMAddBoxSubview(vbox, WMWidgetView(panel->familyL), True, True, 0, 0, 0);
662 if (panel->fonts) {
663 WMListItem *item;
664 for (i = 0; i < panel->fonts->familyn; i++) {
665 item = WMAddListItem(panel->familyL, panel->fonts->families[i].name);
666 item->clientData = panel->fonts->families + i;
667 }
668 } else
669 WMAddListItem(panel->familyL, "sans serif");
670
671 WMSetListAction(panel->familyL, selectedFamily, panel);
672
673 vbox = WMCreateBox(hbox);
674 WMSetBoxHorizontal(vbox, False);
675 WMAddBoxSubview(hbox, WMWidgetView(vbox), True, True, 10, 0, 0);
676
677 {
678 WMBox *box = WMCreateBox(vbox);
679 WMSetBoxHorizontal(box, True);
680 WMAddBoxSubview(vbox, WMWidgetView(box), False, True, 20, 0, 2);
681
682 label = createListLabel(scr, box, _("Style"));
683 WMAddBoxSubview(box, WMWidgetView(label), True, True, 20, 0, 4);
684
685 label = createListLabel(scr, box, _("Size"));
686 WMAddBoxSubview(box, WMWidgetView(label), False, True, 60, 0, 0);
687
688 box = WMCreateBox(vbox);
689 WMSetBoxHorizontal(box, True);
690 WMAddBoxSubview(vbox, WMWidgetView(box), True, True, 20, 0, 0);
691
692 panel->styleL = WMCreateList(box);
693 WMAddBoxSubview(box, WMWidgetView(panel->styleL), True, True, 0, 0, 4);
694 WMSetListAction(panel->styleL, selected, panel);
695
696 panel->sizeL = WMCreateList(box);
697 WMAddBoxSubview(box, WMWidgetView(panel->sizeL), False, True, 60, 0, 0);
698 for (i = 0; standardSizes[i]; i++) {
699 WMAddListItem(panel->sizeL, standardSizes[i]);
700 }
701 WMSetListAction(panel->sizeL, selected, panel);
702 }
703
704 WMMapSubwidgets(panel->box);
705 WMMapWidget(panel->box);
706 WMRealizeWidget(panel->box);
707
708 showData(panel);
709 }
710
711 Panel *InitFontSimple(WMScreen * scr, WMWidget * parent)
712 {
713 _Panel *panel;
714
715 panel = wmalloc(sizeof(_Panel));
716 memset(panel, 0, sizeof(_Panel));
717
718 panel->sectionName = _("Font Configuration");
719
720 panel->description = _("Configure fonts for Window Maker titlebars, menus etc.");
721
722 panel->parent = parent;
723
724 panel->callbacks.createWidgets = createPanel;
725 panel->callbacks.updateDomain = storeData;
726
727 AddSection(panel, ICON_FILE);
728
729 return panel;
730 }