WINGs: allow keypad enter key to validate button
[wmaker-crm.git] / WPrefs.app / FontSimple.c
blob2147b9856dcdf08e9977e53d5c9ee3b360809c2a
1 /* FontSimple.c- simplified font configuration panel
3 * WPrefs - Window Maker Preferences Program
5 * Copyright (c) 1998-2004 Alfredo K. Kojima
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>
25 #include <math.h>
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
52 #define SAMPLE_TEXT "The Lazy Fox Jumped Ipsum Foobar 1234 - 56789"
54 typedef struct {
55 int weight;
56 int width;
57 int slant;
58 } FontStyle;
60 typedef struct {
61 char *name;
62 int stylen;
63 FontStyle *styles;
64 } FontFamily;
66 typedef struct {
67 int familyn;
68 FontFamily *families;
69 } FontList;
71 typedef struct _Panel {
72 WMBox *box;
73 char *sectionName;
75 char *description;
77 CallbackRec callbacks;
79 WMWidget *parent;
81 WMPopUpButton *optionP;
83 WMList *familyL;
84 WMList *styleL;
86 WMList *sizeL;
88 WMTextField *sampleT;
90 FontList *fonts;
91 } _Panel;
93 #define ICON_FILE "fonts"
95 static const struct {
96 const char *option;
97 const char *label;
98 } 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")}
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[] = {
137 { FC_WEIGHT_THIN, "Thin" },
138 { FC_WEIGHT_EXTRALIGHT, "ExtraLight" },
139 { FC_WEIGHT_LIGHT, "Light" },
140 { FC_WEIGHT_NORMAL, "Normal" },
141 { FC_WEIGHT_MEDIUM, "" },
142 { FC_WEIGHT_DEMIBOLD, "DemiBold" },
143 { FC_WEIGHT_BOLD, "Bold" },
144 { FC_WEIGHT_EXTRABOLD, "ExtraBold" },
145 { FC_WEIGHT_BLACK, "Black" }
148 static const struct {
149 int slant;
150 const char *name;
151 } fontSlants[] = {
152 { FC_SLANT_ROMAN, "" },
153 { FC_SLANT_ITALIC, "Italic" },
154 { FC_SLANT_OBLIQUE, "Oblique" }
157 static const struct {
158 int width;
159 const char *name;
160 } fontWidths[] = {
161 { FC_WIDTH_ULTRACONDENSED, "UltraCondensed" },
162 { FC_WIDTH_EXTRACONDENSED, "ExtraCondensed" },
163 { FC_WIDTH_CONDENSED, "Condensed" },
164 { FC_WIDTH_SEMICONDENSED, "SemiCondensed" },
165 { FC_WIDTH_NORMAL, "" },
166 { FC_WIDTH_SEMIEXPANDED, "SemiExpanded" },
167 { FC_WIDTH_EXPANDED, "Expanded" },
168 { FC_WIDTH_EXTRAEXPANDED, "ExtraExpanded" },
169 { FC_WIDTH_ULTRAEXPANDED, "UltraExpanded" },
172 static int compare_family(const void *a, const void *b)
174 FontFamily *fa = (FontFamily *) a;
175 FontFamily *fb = (FontFamily *) b;
176 return strcmp(fa->name, fb->name);
179 static int compare_styles(const void *a, const void *b)
181 FontStyle *sa = (FontStyle *) a;
182 FontStyle *sb = (FontStyle *) b;
183 int compare;
185 compare = sa->weight - sb->weight;
186 if (compare != 0)
187 return compare;
188 compare = sa->slant - sb->slant;
189 if (compare != 0)
190 return compare;
191 return (sa->width - sb->width);
194 static void lookup_available_fonts(_Panel * panel)
196 FcPattern *pat = FcPatternCreate();
197 FcObjectSet *os;
198 FcFontSet *fonts;
199 FontFamily *family;
201 os = FcObjectSetBuild(FC_FAMILY, FC_WEIGHT, FC_WIDTH, FC_SLANT, NULL);
203 fonts = FcFontList(0, pat, os);
205 if (fonts) {
206 int i;
208 panel->fonts = wmalloc(sizeof(FontList));
209 panel->fonts->familyn = 0;
210 panel->fonts->families = wmalloc(sizeof(FontFamily) * fonts->nfont);
212 for (i = 0; i < fonts->nfont; i++) {
213 char *name;
214 int weight, slant, width;
215 int j, found;
217 if (FcPatternGetString(fonts->fonts[i], FC_FAMILY, 0, (FcChar8 **) & name) !=
218 FcResultMatch)
219 continue;
221 if (FcPatternGetInteger(fonts->fonts[i], FC_WEIGHT, 0, &weight) != FcResultMatch)
222 weight = FC_WEIGHT_MEDIUM;
224 if (FcPatternGetInteger(fonts->fonts[i], FC_WIDTH, 0, &width) != FcResultMatch)
225 width = FC_WIDTH_NORMAL;
227 if (FcPatternGetInteger(fonts->fonts[i], FC_SLANT, 0, &slant) != FcResultMatch)
228 slant = FC_SLANT_ROMAN;
230 found = -1;
231 for (j = 0; j < panel->fonts->familyn && found < 0; j++)
232 if (strcasecmp(panel->fonts->families[j].name, name) == 0)
233 found = j;
235 if (found < 0) {
236 panel->fonts->families[panel->fonts->familyn++].name = wstrdup(name);
237 family = panel->fonts->families + panel->fonts->familyn - 1;
238 family->stylen = 0;
239 family->styles = NULL;
240 } else
241 family = panel->fonts->families + found;
243 family->stylen++;
244 family->styles = wrealloc(family->styles, sizeof(FontStyle) * family->stylen);
245 family->styles[family->stylen - 1].weight = weight;
246 family->styles[family->stylen - 1].slant = slant;
247 family->styles[family->stylen - 1].width = width;
249 qsort(panel->fonts->families, panel->fonts->familyn, sizeof(FontFamily), compare_family);
251 for (i = 0; i < panel->fonts->familyn; i++) {
252 qsort(panel->fonts->families[i].styles, panel->fonts->families[i].stylen,
253 sizeof(FontStyle), compare_styles);
256 FcFontSetDestroy(fonts);
258 if (os)
259 FcObjectSetDestroy(os);
260 if (pat)
261 FcPatternDestroy(pat);
263 panel->fonts->families[panel->fonts->familyn++].name = wstrdup("sans serif");
264 family = panel->fonts->families + panel->fonts->familyn - 1;
265 family->styles = wmalloc(sizeof(FontStyle) * 2);
266 family->stylen = 2;
267 family->styles[0].weight = FC_WEIGHT_MEDIUM;
268 family->styles[0].slant = FC_SLANT_ROMAN;
269 family->styles[0].width = FC_WIDTH_NORMAL;
270 family->styles[1].weight = FC_WEIGHT_BOLD;
271 family->styles[1].slant = FC_SLANT_ROMAN;
272 family->styles[1].width = FC_WIDTH_NORMAL;
274 panel->fonts->families[panel->fonts->familyn++].name = wstrdup("serif");
275 family = panel->fonts->families + panel->fonts->familyn - 1;
276 family->styles = wmalloc(sizeof(FontStyle) * 2);
277 family->stylen = 2;
278 family->styles[0].weight = FC_WEIGHT_MEDIUM;
279 family->styles[0].slant = FC_SLANT_ROMAN;
280 family->styles[0].width = FC_WIDTH_NORMAL;
281 family->styles[1].weight = FC_WEIGHT_BOLD;
282 family->styles[1].slant = FC_SLANT_ROMAN;
283 family->styles[1].width = FC_WIDTH_NORMAL;
286 static char *getSelectedFont(_Panel * panel, FcChar8 * curfont)
288 WMListItem *item;
289 FcPattern *pat;
290 char *name;
292 if (curfont)
293 pat = FcNameParse(curfont);
294 else
295 pat = FcPatternCreate();
297 item = WMGetListSelectedItem(panel->familyL);
298 if (item) {
299 FcPatternDel(pat, FC_FAMILY);
300 FcPatternAddString(pat, FC_FAMILY, (FcChar8 *) item->text);
303 item = WMGetListSelectedItem(panel->styleL);
304 if (item) {
305 FontStyle *style = (FontStyle *) item->clientData;
307 FcPatternDel(pat, FC_WEIGHT);
308 FcPatternAddInteger(pat, FC_WEIGHT, style->weight);
310 FcPatternDel(pat, FC_WIDTH);
311 FcPatternAddInteger(pat, FC_WIDTH, style->width);
313 FcPatternDel(pat, FC_SLANT);
314 FcPatternAddInteger(pat, FC_SLANT, style->slant);
317 item = WMGetListSelectedItem(panel->sizeL);
318 if (item) {
319 FcPatternDel(pat, FC_PIXEL_SIZE);
320 FcPatternAddDouble(pat, FC_PIXEL_SIZE, atoi(item->text));
323 name = (char *)FcNameUnparse(pat);
324 FcPatternDestroy(pat);
326 return name;
329 static void updateSampleFont(_Panel * panel)
331 WMMenuItem *item = WMGetPopUpButtonMenuItem(panel->optionP,
332 WMGetPopUpButtonSelectedItem(panel->optionP));
333 char *fn = WMGetMenuItemRepresentedObject(item);
335 if (fn) {
336 WMFont *font = WMCreateFont(WMWidgetScreen(panel->box), fn);
337 if (font) {
338 WMSetTextFieldFont(panel->sampleT, font);
339 WMReleaseFont(font);
344 static void selectedFamily(WMWidget * w, void *data)
346 _Panel *panel = (_Panel *) data;
347 WMListItem *item;
348 FontStyle *oldStyle = NULL;
349 char buffer[1024];
351 /* Parameter not used, but tell the compiler that it is ok */
352 (void) w;
354 item = WMGetListSelectedItem(panel->styleL);
355 if (item)
356 oldStyle = (FontStyle *) item->clientData;
358 item = WMGetListSelectedItem(panel->familyL);
360 if (item) {
361 FontFamily *family = (FontFamily *) item->clientData;
362 int i, oldi = 0, oldscore = 0;
364 WMClearList(panel->styleL);
365 for (i = 0; i < family->stylen; i++) {
366 int j;
367 const char *weight = "", *slant = "", *width = "";
368 WMListItem *item;
370 for (j = 0; j < wlengthof(fontWeights); j++)
371 if (fontWeights[j].weight == family->styles[i].weight) {
372 weight = fontWeights[j].name;
373 break;
375 for (j = 0; j < wlengthof(fontWidths); j++)
376 if (fontWidths[j].width == family->styles[i].width) {
377 width = fontWidths[j].name;
378 break;
380 for (j = 0; j < wlengthof(fontSlants); j++)
381 if (fontSlants[j].slant == family->styles[i].slant) {
382 slant = fontSlants[j].name;
383 break;
385 sprintf(buffer, "%s%s%s%s%s",
386 weight, *weight ? " " : "", slant, (*slant || *weight) ? " " : "", width);
387 if (!buffer[0])
388 strcpy(buffer, "Roman");
390 item = WMAddListItem(panel->styleL, buffer);
391 item->clientData = family->styles + i;
393 if (oldStyle) {
394 int score = 0;
396 if (oldStyle->width == family->styles[i].width)
397 score |= 1;
398 if (oldStyle->weight == family->styles[i].weight)
399 score |= 2;
400 if (oldStyle->slant == family->styles[i].slant)
401 score |= 4;
403 if (score > oldscore) {
404 oldi = i;
405 oldscore = score;
409 WMSelectListItem(panel->styleL, oldi);
412 int index = WMGetPopUpButtonSelectedItem(panel->optionP);
413 WMMenuItem *item = WMGetPopUpButtonMenuItem(panel->optionP, index);
414 FcChar8 *ofont;
415 char *nfont;
417 ofont = (FcChar8 *) WMGetMenuItemRepresentedObject(item);
418 nfont = getSelectedFont(panel, ofont);
419 if (ofont)
420 wfree(ofont);
421 WMSetMenuItemRepresentedObject(item, nfont);
423 updateSampleFont(panel);
427 static void selected(WMWidget * w, void *data)
429 _Panel *panel = (_Panel *) data;
430 int index = WMGetPopUpButtonSelectedItem(panel->optionP);
431 WMMenuItem *item = WMGetPopUpButtonMenuItem(panel->optionP, index);
432 FcChar8 *ofont;
433 char *nfont;
435 /* Parameter not used, but tell the compiler that it is ok */
436 (void) w;
438 ofont = (FcChar8 *) WMGetMenuItemRepresentedObject(item);
439 nfont = getSelectedFont(panel, ofont);
440 if (ofont)
441 wfree(ofont);
443 WMSetMenuItemRepresentedObject(item, nfont);
445 updateSampleFont(panel);
448 static void selectedOption(WMWidget * w, void *data)
450 _Panel *panel = (_Panel *) data;
451 int index = WMGetPopUpButtonSelectedItem(panel->optionP);
452 WMMenuItem *item = WMGetPopUpButtonMenuItem(panel->optionP, index);
453 char *font;
455 /* Parameter not used, but tell the compiler that it is ok */
456 (void) w;
458 font = (char *)WMGetMenuItemRepresentedObject(item);
459 if (font) {
460 FcPattern *pat;
462 pat = FcNameParse((FcChar8 *) font);
463 if (pat) {
464 char *name;
465 int weight, slant, width;
466 double size;
467 int distance, closest, found;
468 int i;
470 FcDefaultSubstitute(pat);
472 if (FcPatternGetString(pat, FC_FAMILY, 0, (FcChar8 **) & name) != FcResultMatch)
473 name = "sans serif";
475 found = 0;
476 /* select family */
477 for (i = 0; i < WMGetListNumberOfRows(panel->familyL); i++) {
478 WMListItem *item = WMGetListItem(panel->familyL, i);
479 FontFamily *family = (FontFamily *) item->clientData;
481 if (strcasecmp(family->name, name) == 0) {
482 found = 1;
483 WMSelectListItem(panel->familyL, i);
484 WMSetListPosition(panel->familyL, i);
485 break;
488 if (!found)
489 WMSelectListItem(panel->familyL, -1);
490 selectedFamily(panel->familyL, panel);
492 /* select style */
493 if (FcPatternGetInteger(pat, FC_WEIGHT, 0, &weight) != FcResultMatch)
494 weight = FC_WEIGHT_NORMAL;
495 if (FcPatternGetInteger(pat, FC_WIDTH, 0, &width) != FcResultMatch)
496 width = FC_WIDTH_NORMAL;
497 if (FcPatternGetInteger(pat, FC_SLANT, 0, &slant) != FcResultMatch)
498 slant = FC_SLANT_ROMAN;
500 if (FcPatternGetDouble(pat, FC_PIXEL_SIZE, 0, &size) != FcResultMatch)
501 size = 10.0;
503 for (i = 0, found = 0, closest = 0; i < WMGetListNumberOfRows(panel->styleL); i++) {
504 WMListItem *item = WMGetListItem(panel->styleL, i);
505 FontStyle *style = (FontStyle *) item->clientData;
507 distance = ((abs(style->weight - weight) << 16) +
508 (abs(style->slant - slant) << 8) + (abs(style->width - width)));
510 if (i == 0 || distance < closest) {
511 closest = distance;
512 found = i;
513 if (distance == 0) {
514 break; /* perfect match */
518 WMSelectListItem(panel->styleL, found);
519 WMSetListPosition(panel->styleL, found);
521 for (i = 0, found = 0, closest = 0; i < WMGetListNumberOfRows(panel->sizeL); i++) {
522 WMListItem *item = WMGetListItem(panel->sizeL, i);
523 int distance;
525 distance = fabs(size - atoi(item->text));
527 if (i == 0 || distance < closest) {
528 closest = distance;
529 found = i;
530 if (distance == 0) {
531 break; /* perfect match */
535 WMSelectListItem(panel->sizeL, found);
536 WMSetListPosition(panel->sizeL, found);
538 selected(NULL, panel);
539 } else
540 wwarning("Can't parse font '%s'", font);
543 updateSampleFont(panel);
546 static WMLabel *createListLabel(WMScreen * scr, WMWidget * parent, const char *text)
548 WMLabel *label;
549 WMColor *color;
550 WMFont *boldFont = WMBoldSystemFontOfSize(scr, 12);
552 label = WMCreateLabel(parent);
553 WMSetLabelFont(label, boldFont);
554 WMSetLabelText(label, text);
555 WMSetLabelRelief(label, WRSunken);
556 WMSetLabelTextAlignment(label, WACenter);
557 color = WMDarkGrayColor(scr);
558 WMSetWidgetBackgroundColor(label, color);
559 WMReleaseColor(color);
560 color = WMWhiteColor(scr);
561 WMSetLabelTextColor(label, color);
562 WMReleaseColor(color);
564 WMReleaseFont(boldFont);
566 return label;
569 static void showData(_Panel * panel)
571 int i;
572 WMMenuItem *item;
573 WMScreen *scr;
575 scr = WMWidgetScreen(panel->parent);
577 for (i = 0; i < WMGetPopUpButtonNumberOfItems(panel->optionP); i++) {
578 char *ofont, *font;
580 item = WMGetPopUpButtonMenuItem(panel->optionP, i);
582 ofont = WMGetMenuItemRepresentedObject(item);
583 if (ofont)
584 wfree(ofont);
586 if (strcmp(fontOptions[i].option, "SystemFont") == 0)
587 font = WMGetFontName(WMDefaultSystemFont(scr));
588 else if (strcmp(fontOptions[i].option, "BoldSystemFont") == 0)
589 font = WMGetFontName(WMDefaultBoldSystemFont(scr));
590 else
591 font = GetStringForKey(fontOptions[i].option);
592 if (font)
593 font = wstrdup(font);
594 WMSetMenuItemRepresentedObject(item, font);
597 WMSetPopUpButtonSelectedItem(panel->optionP, 0);
598 selectedOption(panel->optionP, panel);
601 static void storeData(_Panel * panel)
603 int i;
604 WMMenuItem *item;
605 for (i = 0; i < WMGetPopUpButtonNumberOfItems(panel->optionP); i++) {
606 char *font;
608 item = WMGetPopUpButtonMenuItem(panel->optionP, i);
610 font = WMGetMenuItemRepresentedObject(item);
611 if (font && *font) {
612 if (strcmp(fontOptions[i].option, "SystemFont") == 0 ||
613 strcmp(fontOptions[i].option, "BoldSystemFont") == 0) {
614 char *path;
615 WMUserDefaults *defaults;
617 path = wdefaultspathfordomain("WMGLOBAL");
618 defaults = WMGetDefaultsFromPath(path);
619 wfree(path);
620 WMSetUDStringForKey(defaults,
621 font,
622 fontOptions[i].option);
623 WMSaveUserDefaults(defaults);
624 } else {
625 SetStringForKey(font, fontOptions[i].option);
631 static void createPanel(Panel * p)
633 _Panel *panel = (_Panel *) p;
634 WMScreen *scr = WMWidgetScreen(panel->parent);
635 WMLabel *label;
636 WMBox *hbox, *vbox;
637 int i;
639 lookup_available_fonts(panel);
641 panel->box = WMCreateBox(panel->parent);
642 WMSetViewExpandsToParent(WMWidgetView(panel->box), 5, 2, 5, 5);
643 WMSetBoxHorizontal(panel->box, False);
644 WMSetBoxBorderWidth(panel->box, 8);
645 WMMapWidget(panel->box);
647 hbox = WMCreateBox(panel->box);
648 WMSetBoxHorizontal(hbox, True);
649 WMAddBoxSubview(panel->box, WMWidgetView(hbox), False, True, 40, 22, 8);
651 vbox = WMCreateBox(hbox);
652 WMAddBoxSubview(hbox, WMWidgetView(vbox), False, True, 130, 0, 10);
653 WMSetBoxHorizontal(vbox, False);
654 panel->optionP = WMCreatePopUpButton(vbox);
655 WMAddBoxSubviewAtEnd(vbox, WMWidgetView(panel->optionP), False, True, 20, 0, 8);
656 for (i = 0; i < wlengthof(fontOptions); i++)
657 WMAddPopUpButtonItem(panel->optionP, _(fontOptions[i].label));
658 WMSetPopUpButtonAction(panel->optionP, selectedOption, panel);
660 label = WMCreateLabel(hbox);
661 WMSetLabelText(label, _("Sample Text"));
662 WMSetLabelTextAlignment(label, WARight);
663 WMAddBoxSubview(hbox, WMWidgetView(label), False, True, 80, 0, 2);
665 panel->sampleT = WMCreateTextField(hbox);
666 WMSetViewExpandsToParent(WMWidgetView(panel->sampleT), 10, 18, 10, 10);
667 WMSetTextFieldText(panel->sampleT, SAMPLE_TEXT);
668 WMAddBoxSubview(hbox, WMWidgetView(panel->sampleT), True, True, 60, 0, 0);
670 hbox = WMCreateBox(panel->box);
671 WMSetBoxHorizontal(hbox, True);
672 WMAddBoxSubview(panel->box, WMWidgetView(hbox), True, True, 100, 0, 2);
674 vbox = WMCreateBox(hbox);
675 WMSetBoxHorizontal(vbox, False);
676 WMAddBoxSubview(hbox, WMWidgetView(vbox), False, True, 240, 20, 4);
678 label = createListLabel(scr, vbox, _("Family"));
679 WMAddBoxSubview(vbox, WMWidgetView(label), False, True, 20, 0, 2);
681 /* family */
682 panel->familyL = WMCreateList(vbox);
683 WMAddBoxSubview(vbox, WMWidgetView(panel->familyL), True, True, 0, 0, 0);
684 if (panel->fonts) {
685 WMListItem *item;
686 for (i = 0; i < panel->fonts->familyn; i++) {
687 item = WMAddListItem(panel->familyL, panel->fonts->families[i].name);
688 item->clientData = panel->fonts->families + i;
690 } else
691 WMAddListItem(panel->familyL, "sans serif");
693 WMSetListAction(panel->familyL, selectedFamily, panel);
695 vbox = WMCreateBox(hbox);
696 WMSetBoxHorizontal(vbox, False);
697 WMAddBoxSubview(hbox, WMWidgetView(vbox), True, True, 10, 0, 0);
700 WMBox *box = WMCreateBox(vbox);
701 WMSetBoxHorizontal(box, True);
702 WMAddBoxSubview(vbox, WMWidgetView(box), False, True, 20, 0, 2);
704 label = createListLabel(scr, box, _("Style"));
705 WMAddBoxSubview(box, WMWidgetView(label), True, True, 20, 0, 4);
707 label = createListLabel(scr, box, _("Size"));
708 WMAddBoxSubview(box, WMWidgetView(label), False, True, 60, 0, 0);
710 box = WMCreateBox(vbox);
711 WMSetBoxHorizontal(box, True);
712 WMAddBoxSubview(vbox, WMWidgetView(box), True, True, 20, 0, 0);
714 panel->styleL = WMCreateList(box);
715 WMAddBoxSubview(box, WMWidgetView(panel->styleL), True, True, 0, 0, 4);
716 WMSetListAction(panel->styleL, selected, panel);
718 panel->sizeL = WMCreateList(box);
719 WMAddBoxSubview(box, WMWidgetView(panel->sizeL), False, True, 60, 0, 0);
720 for (i = 0; standardSizes[i]; i++) {
721 WMAddListItem(panel->sizeL, standardSizes[i]);
723 WMSetListAction(panel->sizeL, selected, panel);
726 WMMapSubwidgets(panel->box);
727 WMMapWidget(panel->box);
728 WMRealizeWidget(panel->box);
730 showData(panel);
733 Panel *InitFontSimple(WMWidget *parent)
735 _Panel *panel;
737 panel = wmalloc(sizeof(_Panel));
739 panel->sectionName = _("Font Configuration");
741 panel->description = _("Configure fonts for Window Maker titlebars, menus etc.");
743 panel->parent = parent;
745 panel->callbacks.createWidgets = createPanel;
746 panel->callbacks.updateDomain = storeData;
748 AddSection(panel, ICON_FILE);
750 return panel;