static void FindWindows(AG_Tlist *tl, AG_Window *win, int depth) { char text[AG_TLIST_LABEL_MAX]; AG_Window *wSub; AG_Widget *wChild; AG_TlistItem *it; if (strncmp(OBJECT(win)->name, "_Popup-", sizeof("_Popup-")) == 0) return; Strlcpy(text, win->caption, sizeof(text)); if (strcmp(OBJECT(win)->name, "generic") == 0) { it = AG_TlistAddS(tl, NULL, win->caption[0] != '\0' ? win->caption : _("Untitled")); } else { it = AG_TlistAdd(tl, NULL, "%s (<%s>)", win->caption[0] != '\0' ? win->caption : _("Untitled"), OBJECT(win)->name); } it->p1 = win; it->depth = depth; it->cat = "window"; if (!TAILQ_EMPTY(&OBJECT(win)->children) || !TAILQ_EMPTY(&win->subwins)) { it->flags |= AG_TLIST_HAS_CHILDREN; } if ((it->flags & AG_TLIST_HAS_CHILDREN) && AG_TlistVisibleChildren(tl, it)) { TAILQ_FOREACH(wSub, &win->subwins, swins) FindWindows(tl, wSub, depth+1); OBJECT_FOREACH_CHILD(wChild, win, ag_widget) FindWidgets(wChild, tl, depth+1); } }
void AGOL_Settings::UpdateWadDirList(AG_Event *event) { list<string>::iterator i; // Clear the list and store selection AG_TlistBegin(WadDirList); // Traverse the waddir list and add them to the tlist widget for(i = WadDirs.begin(); i != WadDirs.end(); i++) AG_TlistAddS(WadDirList, agIconDirectory.s, (*i).c_str()); // Restore list selection AG_TlistEnd(WadDirList); }
static void UpdateFaces(AG_Event *event) { AG_Variable *bFont; AG_Font **pFont; AG_FontSelector *fs = AG_SELF(); char fontPath[AG_SEARCHPATH_MAX], *pFontPath = &fontPath[0]; AG_TlistItem *ti; char *s; int i; const int stdSizes[] = { 4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20, 22,24,26,28,32,48,64 }; const int nStdSizes = sizeof(stdSizes) / sizeof(stdSizes[0]); bFont = AG_GetVariable(fs, "font", &pFont); AG_PushTextState(); fs->flags &= ~(AG_FONTSELECTOR_UPDATE); for (i = 0; i < agBuiltinFontCount; i++) { AG_StaticFont *font = agBuiltinFonts[i]; ti = AG_TlistAdd(fs->tlFaces, NULL, "_%s", font->name); ti->p1 = font; if (*pFont != NULL && strcmp(ti->text, OBJECT(*pFont)->name) == 0) ti->selected++; } AG_CopyCfgString("font-path", fontPath, sizeof(fontPath)); while ((s = AG_Strsep(&pFontPath, ":")) != NULL) { AG_Dir *dir; int i; if ((dir = AG_OpenDir(s)) == NULL) { AG_Verbose(_("Ignoring: %s\n"), AG_GetError()); continue; } for (i = 0; i < dir->nents; i++) { char path[AG_FILENAME_MAX]; AG_FileInfo info; char *file = dir->ents[i], *pExt; if (file[0] == '.' || (pExt = strrchr(file, '.')) == NULL) { continue; } if (strcmp(pExt, ".ttf") != 0 && strcmp(pExt, ".TTF") != 0) continue; Strlcpy(path, s, sizeof(path)); Strlcat(path, AG_PATHSEP, sizeof(path)); Strlcat(path, file, sizeof(path)); if (AG_GetFileInfo(path, &info) == -1 || info.type != AG_FILE_REGULAR) { continue; } ti = AG_TlistAddS(fs->tlFaces, NULL, file); if (*pFont != NULL && strcmp(file, OBJECT(*pFont)->name) == 0) ti->selected++; } AG_CloseDir(dir); } /* XXX */ for (i = 0; i < nStdSizes; i++) { ti = AG_TlistAdd(fs->tlSizes, NULL, "%d", stdSizes[i]); if (*pFont != NULL && stdSizes[i] == (*pFont)->size) ti->selected++; } ti = AG_TlistAdd(fs->tlStyles, NULL, _("Regular")); if (*pFont != NULL && (*pFont)->flags == 0) { ti->selected++; } ti = AG_TlistAdd(fs->tlStyles, NULL, _("Italic")); if (*pFont != NULL && (*pFont)->flags == AG_FONT_ITALIC) { ti->selected++; } ti = AG_TlistAdd(fs->tlStyles, NULL, _("Bold")); if (*pFont != NULL && (*pFont)->flags == AG_FONT_BOLD) { ti->selected++; } ti = AG_TlistAdd(fs->tlStyles, NULL, _("Bold Italic")); if (*pFont != NULL && (*pFont)->flags == (AG_FONT_BOLD|AG_FONT_ITALIC)) { ti->selected++; } UpdatePreview(fs); AG_UnlockVariable(bFont); }