wrlib: add explicit type definition in API to allow compiler Type Checks (3/3)
[wmaker-crm.git] / WPrefs.app / FontSimple.c
blobb6cdaf40d7d063696356b32fd42d12c9fbcaa97f
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.
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.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "WPrefs.h"
23 #include <unistd.h>
24 #include <fontconfig/fontconfig.h>
26 /* workaround for older fontconfig, that doesn't define these constants */
27 #ifndef FC_WEIGHT_NORMAL
28 /* Weights */
29 # define FC_WEIGHT_THIN 10
30 # define FC_WEIGHT_EXTRALIGHT 40
31 # define FC_WEIGHT_ULTRALIGHT FC_WEIGHT_EXTRALIGHT
32 # define FC_WEIGHT_REGULAR 80
33 # define FC_WEIGHT_NORMAL FC_WEIGHT_REGULAR
34 # define FC_WEIGHT_SEMIBOLD FC_WEIGHT_DEMIBOLD
35 # define FC_WEIGHT_EXTRABOLD 205
36 # define FC_WEIGHT_ULTRABOLD FC_WEIGHT_EXTRABOLD
37 # define FC_WEIGHT_HEAVY FC_WEIGHT_BLACK
38 /* Widths */
39 # define FC_WIDTH "width"
40 # define FC_WIDTH_ULTRACONDENSED 50
41 # define FC_WIDTH_EXTRACONDENSED 63
42 # define FC_WIDTH_CONDENSED 75
43 # define FC_WIDTH_SEMICONDENSED 87
44 # define FC_WIDTH_NORMAL 100
45 # define FC_WIDTH_SEMIEXPANDED 113
46 # define FC_WIDTH_EXPANDED 125
47 # define FC_WIDTH_EXTRAEXPANDED 150
48 # define FC_WIDTH_ULTRAEXPANDED 200
49 #endif
51 #define SAMPLE_TEXT "The Lazy Fox Jumped Ipsum Foobar 1234 - 56789"
53 typedef struct {
54 int weight;
55 int width;
56 int slant;
57 } FontStyle;
59 typedef struct {
60 char *name;
61 int stylen;
62 FontStyle *styles;
63 } FontFamily;
65 typedef struct {
66 int familyn;
67 FontFamily *families;
68 } FontList;
70 typedef struct _Panel {
71 WMBox *box;
72 char *sectionName;
74 char *description;
76 CallbackRec callbacks;
78 WMWidget *parent;
80 WMPopUpButton *optionP;
82 WMList *familyL;
83 WMList *styleL;
85 WMList *sizeL;
87 WMTextField *sampleT;
89 FontList *fonts;
90 } _Panel;
92 #define ICON_FILE "fonts"
94 static const struct {
95 const char *option;
96 const char *label;
97 } fontOptions[] = {
99 "WindowTitleFont", N_("Window Title")}, {
100 "MenuTitleFont", N_("Menu Title")}, {
101 "MenuTextFont", N_("Menu Text")}, {
102 "IconTitleFont", N_("Icon Title")}, {
103 "ClipTitleFont", N_("Clip Title")}, {
104 "LargeDisplayFont", N_("Desktop Caption")}, {
105 "SystemFont", N_("System Font")}, {
106 "BoldSystemFont", N_("Bold System Font")}, {
107 NULL, NULL},};
109 static const char *standardSizes[] = {
110 "6",
111 "8",
112 "9",
113 "10",
114 "11",
115 "12",
116 "13",
117 "14",
118 "15",
119 "16",
120 "18",
121 "20",
122 "22",
123 "24",
124 "28",
125 "32",
126 "36",
127 "48",
128 "64",
129 "72",
130 NULL
133 static const struct {
134 int weight;
135 const char *name;
136 } fontWeights[] = {
138 FC_WEIGHT_THIN, "Thin"}, {
139 FC_WEIGHT_EXTRALIGHT, "ExtraLight"}, {
140 FC_WEIGHT_LIGHT, "Light"}, {
141 FC_WEIGHT_NORMAL, "Normal"}, {
142 FC_WEIGHT_MEDIUM, ""}, /*"medium"}, */
144 FC_WEIGHT_DEMIBOLD, "DemiBold"}, {
145 FC_WEIGHT_BOLD, "Bold"}, {
146 FC_WEIGHT_EXTRABOLD, "ExtraBold"}, {
147 FC_WEIGHT_BLACK, "Black"}, {
148 0, NULL}
151 static const struct {
152 int slant;
153 const char *name;
154 } fontSlants[] = {
156 FC_SLANT_ROMAN, ""}, /*"Roman"}, */
158 FC_SLANT_ITALIC, "Italic"}, {
159 FC_SLANT_OBLIQUE, "Oblique"}, {
160 0, NULL}
163 static const struct {
164 int width;
165 const char *name;
166 } fontWidths[] = {
168 FC_WIDTH_ULTRACONDENSED, "UltraCondensed"}, {
169 FC_WIDTH_EXTRACONDENSED, "ExtraCondensed"}, {
170 FC_WIDTH_CONDENSED, "Condensed"}, {
171 FC_WIDTH_SEMICONDENSED, "SemiCondensed"}, {
172 FC_WIDTH_NORMAL, ""}, /*"normal"}, */
174 FC_WIDTH_SEMIEXPANDED, "SemiExpanded"}, {
175 FC_WIDTH_EXPANDED, "Expanded"}, {
176 FC_WIDTH_EXTRAEXPANDED, "ExtraExpanded"}, {
177 FC_WIDTH_ULTRAEXPANDED, "UltraExpanded"}, {
178 0, NULL}
181 static int compare_family(const void *a, const void *b)
183 FontFamily *fa = (FontFamily *) a;
184 FontFamily *fb = (FontFamily *) b;
185 return strcmp(fa->name, fb->name);
188 static int compare_styles(const void *a, const void *b)
190 FontStyle *sa = (FontStyle *) a;
191 FontStyle *sb = (FontStyle *) b;
192 int compare;
194 compare = sa->weight - sb->weight;
195 if (compare != 0)
196 return compare;
197 compare = sa->slant - sb->slant;
198 if (compare != 0)
199 return compare;
200 return (sa->width - sb->width);
203 static void lookup_available_fonts(_Panel * panel)
205 FcPattern *pat = FcPatternCreate();
206 FcObjectSet *os;
207 FcFontSet *fonts;
208 FontFamily *family;
210 os = FcObjectSetBuild(FC_FAMILY, FC_WEIGHT, FC_WIDTH, FC_SLANT, NULL);
212 fonts = FcFontList(0, pat, os);
214 if (fonts) {
215 int i;
217 panel->fonts = wmalloc(sizeof(FontList));
218 panel->fonts->familyn = 0;
219 panel->fonts->families = wmalloc(sizeof(FontFamily) * fonts->nfont);
221 for (i = 0; i < fonts->nfont; i++) {
222 char *name;
223 int weight, slant, width;
224 int j, found;
226 if (FcPatternGetString(fonts->fonts[i], FC_FAMILY, 0, (FcChar8 **) & name) !=
227 FcResultMatch)
228 continue;
230 if (FcPatternGetInteger(fonts->fonts[i], FC_WEIGHT, 0, &weight) != FcResultMatch)
231 weight = FC_WEIGHT_MEDIUM;
233 if (FcPatternGetInteger(fonts->fonts[i], FC_WIDTH, 0, &width) != FcResultMatch)
234 width = FC_WIDTH_NORMAL;
236 if (FcPatternGetInteger(fonts->fonts[i], FC_SLANT, 0, &slant) != FcResultMatch)
237 slant = FC_SLANT_ROMAN;
239 found = -1;
240 for (j = 0; j < panel->fonts->familyn && found < 0; j++)
241 if (strcasecmp(panel->fonts->families[j].name, name) == 0)
242 found = j;
244 if (found < 0) {
245 panel->fonts->families[panel->fonts->familyn++].name = wstrdup(name);
246 family = panel->fonts->families + panel->fonts->familyn - 1;
247 family->stylen = 0;
248 family->styles = NULL;
249 } else
250 family = panel->fonts->families + found;
252 family->stylen++;
253 family->styles = wrealloc(family->styles, sizeof(FontStyle) * family->stylen);
254 family->styles[family->stylen - 1].weight = weight;
255 family->styles[family->stylen - 1].slant = slant;
256 family->styles[family->stylen - 1].width = width;
258 qsort(panel->fonts->families, panel->fonts->familyn, sizeof(FontFamily), compare_family);
260 for (i = 0; i < panel->fonts->familyn; i++) {
261 qsort(panel->fonts->families[i].styles, panel->fonts->families[i].stylen,
262 sizeof(FontStyle), compare_styles);
265 FcFontSetDestroy(fonts);
267 if (os)
268 FcObjectSetDestroy(os);
269 if (pat)
270 FcPatternDestroy(pat);
272 panel->fonts->families[panel->fonts->familyn++].name = wstrdup("sans serif");
273 family = panel->fonts->families + panel->fonts->familyn - 1;
274 family->styles = wmalloc(sizeof(FontStyle) * 2);
275 family->stylen = 2;
276 family->styles[0].weight = FC_WEIGHT_MEDIUM;
277 family->styles[0].slant = FC_SLANT_ROMAN;
278 family->styles[0].width = FC_WIDTH_NORMAL;
279 family->styles[1].weight = FC_WEIGHT_BOLD;
280 family->styles[1].slant = FC_SLANT_ROMAN;
281 family->styles[1].width = FC_WIDTH_NORMAL;
283 panel->fonts->families[panel->fonts->familyn++].name = wstrdup("serif");
284 family = panel->fonts->families + panel->fonts->familyn - 1;
285 family->styles = wmalloc(sizeof(FontStyle) * 2);
286 family->stylen = 2;
287 family->styles[0].weight = FC_WEIGHT_MEDIUM;
288 family->styles[0].slant = FC_SLANT_ROMAN;
289 family->styles[0].width = FC_WIDTH_NORMAL;
290 family->styles[1].weight = FC_WEIGHT_BOLD;
291 family->styles[1].slant = FC_SLANT_ROMAN;
292 family->styles[1].width = FC_WIDTH_NORMAL;
295 static char *getSelectedFont(_Panel * panel, FcChar8 * curfont)
297 WMListItem *item;
298 FcPattern *pat;
299 char *name;
301 if (curfont)
302 pat = FcNameParse(curfont);
303 else
304 pat = FcPatternCreate();
306 item = WMGetListSelectedItem(panel->familyL);
307 if (item) {
308 FcPatternDel(pat, FC_FAMILY);
309 FcPatternAddString(pat, FC_FAMILY, (FcChar8 *) item->text);
312 item = WMGetListSelectedItem(panel->styleL);
313 if (item) {
314 FontStyle *style = (FontStyle *) item->clientData;
316 FcPatternDel(pat, FC_WEIGHT);
317 FcPatternAddInteger(pat, FC_WEIGHT, style->weight);
319 FcPatternDel(pat, FC_WIDTH);
320 FcPatternAddInteger(pat, FC_WIDTH, style->width);
322 FcPatternDel(pat, FC_SLANT);
323 FcPatternAddInteger(pat, FC_SLANT, style->slant);
326 item = WMGetListSelectedItem(panel->sizeL);
327 if (item) {
328 FcPatternDel(pat, FC_PIXEL_SIZE);
329 FcPatternAddDouble(pat, FC_PIXEL_SIZE, atoi(item->text));
332 name = (char *)FcNameUnparse(pat);
333 FcPatternDestroy(pat);
335 return name;
338 static void updateSampleFont(_Panel * panel)
340 WMMenuItem *item = WMGetPopUpButtonMenuItem(panel->optionP,
341 WMGetPopUpButtonSelectedItem(panel->optionP));
342 char *fn = WMGetMenuItemRepresentedObject(item);
344 if (fn) {
345 WMFont *font = WMCreateFont(WMWidgetScreen(panel->box), fn);
346 if (font) {
347 WMSetTextFieldFont(panel->sampleT, font);
348 WMReleaseFont(font);
353 static void selectedFamily(WMWidget * w, void *data)
355 _Panel *panel = (_Panel *) data;
356 WMListItem *item;
357 FontStyle *oldStyle = NULL;
358 char buffer[1024];
360 /* Parameter not used, but tell the compiler that it is ok */
361 (void) w;
363 item = WMGetListSelectedItem(panel->styleL);
364 if (item)
365 oldStyle = (FontStyle *) item->clientData;
367 item = WMGetListSelectedItem(panel->familyL);
369 if (item) {
370 FontFamily *family = (FontFamily *) item->clientData;
371 int i, oldi = 0, oldscore = 0;
373 WMClearList(panel->styleL);
374 for (i = 0; i < family->stylen; i++) {
375 int j;
376 const char *weight = "", *slant = "", *width = "";
377 WMListItem *item;
379 for (j = 0; fontWeights[j].name; j++)
380 if (fontWeights[j].weight == family->styles[i].weight) {
381 weight = fontWeights[j].name;
382 break;
384 for (j = 0; fontWidths[j].name; j++)
385 if (fontWidths[j].width == family->styles[i].width) {
386 width = fontWidths[j].name;
387 break;
389 for (j = 0; fontSlants[j].name; j++)
390 if (fontSlants[j].slant == family->styles[i].slant) {
391 slant = fontSlants[j].name;
392 break;
394 sprintf(buffer, "%s%s%s%s%s",
395 weight, *weight ? " " : "", slant, (*slant || *weight) ? " " : "", width);
396 if (!buffer[0])
397 strcpy(buffer, "Roman");
399 item = WMAddListItem(panel->styleL, buffer);
400 item->clientData = family->styles + i;
402 if (oldStyle) {
403 int score = 0;
405 if (oldStyle->width == family->styles[i].width)
406 score |= 1;
407 if (oldStyle->weight == family->styles[i].weight)
408 score |= 2;
409 if (oldStyle->slant == family->styles[i].slant)
410 score |= 4;
412 if (score > oldscore) {
413 oldi = i;
414 oldscore = score;
418 WMSelectListItem(panel->styleL, oldi);
421 int index = WMGetPopUpButtonSelectedItem(panel->optionP);
422 WMMenuItem *item = WMGetPopUpButtonMenuItem(panel->optionP, index);
423 FcChar8 *ofont;
424 char *nfont;
426 ofont = (FcChar8 *) WMGetMenuItemRepresentedObject(item);
427 nfont = getSelectedFont(panel, ofont);
428 if (ofont)
429 wfree(ofont);
430 WMSetMenuItemRepresentedObject(item, nfont);
432 updateSampleFont(panel);
436 static void selected(WMWidget * w, void *data)
438 _Panel *panel = (_Panel *) data;
439 int index = WMGetPopUpButtonSelectedItem(panel->optionP);
440 WMMenuItem *item = WMGetPopUpButtonMenuItem(panel->optionP, index);
441 FcChar8 *ofont;
442 char *nfont;
444 /* Parameter not used, but tell the compiler that it is ok */
445 (void) w;
447 ofont = (FcChar8 *) WMGetMenuItemRepresentedObject(item);
448 nfont = getSelectedFont(panel, ofont);
449 if (ofont)
450 wfree(ofont);
452 WMSetMenuItemRepresentedObject(item, nfont);
454 updateSampleFont(panel);
457 static void selectedOption(WMWidget * w, void *data)
459 _Panel *panel = (_Panel *) data;
460 int index = WMGetPopUpButtonSelectedItem(panel->optionP);
461 WMMenuItem *item = WMGetPopUpButtonMenuItem(panel->optionP, index);
462 char *font;
464 /* Parameter not used, but tell the compiler that it is ok */
465 (void) w;
467 font = (char *)WMGetMenuItemRepresentedObject(item);
468 if (font) {
469 FcPattern *pat;
471 pat = FcNameParse((FcChar8 *) font);
472 if (pat) {
473 char *name;
474 int weight, slant, width;
475 double size;
476 int distance, closest, found;
477 int i;
479 FcDefaultSubstitute(pat);
481 if (FcPatternGetString(pat, FC_FAMILY, 0, (FcChar8 **) & name) != FcResultMatch)
482 name = "sans serif";
484 found = 0;
485 /* select family */
486 for (i = 0; i < WMGetListNumberOfRows(panel->familyL); i++) {
487 WMListItem *item = WMGetListItem(panel->familyL, i);
488 FontFamily *family = (FontFamily *) item->clientData;
490 if (strcasecmp(family->name, name) == 0) {
491 found = 1;
492 WMSelectListItem(panel->familyL, i);
493 WMSetListPosition(panel->familyL, i);
494 break;
497 if (!found)
498 WMSelectListItem(panel->familyL, -1);
499 selectedFamily(panel->familyL, panel);
501 /* select style */
502 if (FcPatternGetInteger(pat, FC_WEIGHT, 0, &weight) != FcResultMatch)
503 weight = FC_WEIGHT_NORMAL;
504 if (FcPatternGetInteger(pat, FC_WIDTH, 0, &width) != FcResultMatch)
505 width = FC_WIDTH_NORMAL;
506 if (FcPatternGetInteger(pat, FC_SLANT, 0, &slant) != FcResultMatch)
507 slant = FC_SLANT_ROMAN;
509 if (FcPatternGetDouble(pat, FC_PIXEL_SIZE, 0, &size) != FcResultMatch)
510 size = 10.0;
512 for (i = 0, found = 0, closest = 0; i < WMGetListNumberOfRows(panel->styleL); i++) {
513 WMListItem *item = WMGetListItem(panel->styleL, i);
514 FontStyle *style = (FontStyle *) item->clientData;
516 distance = ((abs(style->weight - weight) << 16) +
517 (abs(style->slant - slant) << 8) + (abs(style->width - width)));
519 if (i == 0 || distance < closest) {
520 closest = distance;
521 found = i;
522 if (distance == 0) {
523 break; /* perfect match */
527 WMSelectListItem(panel->styleL, found);
528 WMSetListPosition(panel->styleL, found);
530 for (i = 0, found = 0, closest = 0; i < WMGetListNumberOfRows(panel->sizeL); i++) {
531 WMListItem *item = WMGetListItem(panel->sizeL, i);
532 int distance;
534 distance = abs(size - atoi(item->text));
536 if (i == 0 || distance < closest) {
537 closest = distance;
538 found = i;
539 if (distance == 0) {
540 break; /* perfect match */
544 WMSelectListItem(panel->sizeL, found);
545 WMSetListPosition(panel->sizeL, found);
547 selected(NULL, panel);
548 } else
549 wwarning("Can't parse font '%s'", font);
552 updateSampleFont(panel);
555 static WMLabel *createListLabel(WMScreen * scr, WMWidget * parent, const char *text)
557 WMLabel *label;
558 WMColor *color;
559 WMFont *boldFont = WMBoldSystemFontOfSize(scr, 12);
561 label = WMCreateLabel(parent);
562 WMSetLabelFont(label, boldFont);
563 WMSetLabelText(label, text);
564 WMSetLabelRelief(label, WRSunken);
565 WMSetLabelTextAlignment(label, WACenter);
566 color = WMDarkGrayColor(scr);
567 WMSetWidgetBackgroundColor(label, color);
568 WMReleaseColor(color);
569 color = WMWhiteColor(scr);
570 WMSetLabelTextColor(label, color);
571 WMReleaseColor(color);
573 WMReleaseFont(boldFont);
575 return label;
578 static void showData(_Panel * panel)
580 int i;
581 WMMenuItem *item;
583 for (i = 0; i < WMGetPopUpButtonNumberOfItems(panel->optionP); i++) {
584 char *ofont, *font;
586 item = WMGetPopUpButtonMenuItem(panel->optionP, i);
588 ofont = WMGetMenuItemRepresentedObject(item);
589 if (ofont)
590 wfree(ofont);
592 if (strcmp(fontOptions[i].option, "SystemFont") == 0 ||
593 strcmp(fontOptions[i].option, "BoldSystemFont") == 0) {
594 char *path;
595 WMUserDefaults *defaults;
597 path = wdefaultspathfordomain("WMGLOBAL");
598 defaults = WMGetDefaultsFromPath(path);
599 wfree(path);
600 font = WMGetUDStringForKey(defaults,
601 fontOptions[i].option);
602 } else {
603 font = GetStringForKey(fontOptions[i].option);
605 if (font)
606 font = wstrdup(font);
607 WMSetMenuItemRepresentedObject(item, font);
610 WMSetPopUpButtonSelectedItem(panel->optionP, 0);
611 selectedOption(panel->optionP, panel);
614 static void storeData(_Panel * panel)
616 int i;
617 WMMenuItem *item;
618 for (i = 0; i < WMGetPopUpButtonNumberOfItems(panel->optionP); i++) {
619 char *font;
621 item = WMGetPopUpButtonMenuItem(panel->optionP, i);
623 font = WMGetMenuItemRepresentedObject(item);
624 if (font && *font) {
625 if (strcmp(fontOptions[i].option, "SystemFont") == 0 ||
626 strcmp(fontOptions[i].option, "BoldSystemFont") == 0) {
627 char *path;
628 WMUserDefaults *defaults;
630 path = wdefaultspathfordomain("WMGLOBAL");
631 defaults = WMGetDefaultsFromPath(path);
632 wfree(path);
633 WMSetUDStringForKey(defaults,
634 font,
635 fontOptions[i].option);
636 WMSaveUserDefaults(defaults);
637 } else {
638 SetStringForKey(font, fontOptions[i].option);
644 static void createPanel(Panel * p)
646 _Panel *panel = (_Panel *) p;
647 WMScreen *scr = WMWidgetScreen(panel->parent);
648 WMLabel *label;
649 WMBox *hbox, *vbox;
650 int i;
652 lookup_available_fonts(panel);
654 panel->box = WMCreateBox(panel->parent);
655 WMSetViewExpandsToParent(WMWidgetView(panel->box), 5, 2, 5, 5);
656 WMSetBoxHorizontal(panel->box, False);
657 WMSetBoxBorderWidth(panel->box, 8);
658 WMMapWidget(panel->box);
660 hbox = WMCreateBox(panel->box);
661 WMSetBoxHorizontal(hbox, True);
662 WMAddBoxSubview(panel->box, WMWidgetView(hbox), False, True, 40, 22, 8);
664 vbox = WMCreateBox(hbox);
665 WMAddBoxSubview(hbox, WMWidgetView(vbox), False, True, 130, 0, 10);
666 WMSetBoxHorizontal(vbox, False);
667 panel->optionP = WMCreatePopUpButton(vbox);
668 WMAddBoxSubviewAtEnd(vbox, WMWidgetView(panel->optionP), False, True, 20, 0, 8);
669 for (i = 0; fontOptions[i].option; i++) {
670 WMAddPopUpButtonItem(panel->optionP, _(fontOptions[i].label));
672 WMSetPopUpButtonAction(panel->optionP, selectedOption, panel);
674 label = WMCreateLabel(hbox);
675 WMSetLabelText(label, _("Sample Text"));
676 WMSetLabelTextAlignment(label, WARight);
677 WMAddBoxSubview(hbox, WMWidgetView(label), False, True, 80, 0, 2);
679 panel->sampleT = WMCreateTextField(hbox);
680 WMSetViewExpandsToParent(WMWidgetView(panel->sampleT), 10, 18, 10, 10);
681 WMSetTextFieldText(panel->sampleT, SAMPLE_TEXT);
682 WMAddBoxSubview(hbox, WMWidgetView(panel->sampleT), True, True, 60, 0, 0);
684 hbox = WMCreateBox(panel->box);
685 WMSetBoxHorizontal(hbox, True);
686 WMAddBoxSubview(panel->box, WMWidgetView(hbox), True, True, 100, 0, 2);
688 vbox = WMCreateBox(hbox);
689 WMSetBoxHorizontal(vbox, False);
690 WMAddBoxSubview(hbox, WMWidgetView(vbox), False, True, 240, 20, 4);
692 label = createListLabel(scr, vbox, _("Family"));
693 WMAddBoxSubview(vbox, WMWidgetView(label), False, True, 20, 0, 2);
695 /* family */
696 panel->familyL = WMCreateList(vbox);
697 WMAddBoxSubview(vbox, WMWidgetView(panel->familyL), True, True, 0, 0, 0);
698 if (panel->fonts) {
699 WMListItem *item;
700 for (i = 0; i < panel->fonts->familyn; i++) {
701 item = WMAddListItem(panel->familyL, panel->fonts->families[i].name);
702 item->clientData = panel->fonts->families + i;
704 } else
705 WMAddListItem(panel->familyL, "sans serif");
707 WMSetListAction(panel->familyL, selectedFamily, panel);
709 vbox = WMCreateBox(hbox);
710 WMSetBoxHorizontal(vbox, False);
711 WMAddBoxSubview(hbox, WMWidgetView(vbox), True, True, 10, 0, 0);
714 WMBox *box = WMCreateBox(vbox);
715 WMSetBoxHorizontal(box, True);
716 WMAddBoxSubview(vbox, WMWidgetView(box), False, True, 20, 0, 2);
718 label = createListLabel(scr, box, _("Style"));
719 WMAddBoxSubview(box, WMWidgetView(label), True, True, 20, 0, 4);
721 label = createListLabel(scr, box, _("Size"));
722 WMAddBoxSubview(box, WMWidgetView(label), False, True, 60, 0, 0);
724 box = WMCreateBox(vbox);
725 WMSetBoxHorizontal(box, True);
726 WMAddBoxSubview(vbox, WMWidgetView(box), True, True, 20, 0, 0);
728 panel->styleL = WMCreateList(box);
729 WMAddBoxSubview(box, WMWidgetView(panel->styleL), True, True, 0, 0, 4);
730 WMSetListAction(panel->styleL, selected, panel);
732 panel->sizeL = WMCreateList(box);
733 WMAddBoxSubview(box, WMWidgetView(panel->sizeL), False, True, 60, 0, 0);
734 for (i = 0; standardSizes[i]; i++) {
735 WMAddListItem(panel->sizeL, standardSizes[i]);
737 WMSetListAction(panel->sizeL, selected, panel);
740 WMMapSubwidgets(panel->box);
741 WMMapWidget(panel->box);
742 WMRealizeWidget(panel->box);
744 showData(panel);
747 Panel *InitFontSimple(WMWidget *parent)
749 _Panel *panel;
751 panel = wmalloc(sizeof(_Panel));
753 panel->sectionName = _("Font Configuration");
755 panel->description = _("Configure fonts for Window Maker titlebars, menus etc.");
757 panel->parent = parent;
759 panel->callbacks.createWidgets = createPanel;
760 panel->callbacks.updateDomain = storeData;
762 AddSection(panel, ICON_FILE);
764 return panel;