    /*

    $Id: main.cpp,v 1.28 2000/05/03 11:54:08 bieker Exp $

    Copyright (C) 1997 Bernd Johannes Wuebben <wuebben@math.cornell.edu>
    Copyright (C) 2000 Hans Petter Bieker <bieker@kde.org>

    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., 675 Mass Ave, Cambridge, MA 02139, USA.

    */

#include <qstrlist.h> 

#include <kglobal.h>
#include <klocale.h>

#include "toplevel.h"
#include "main.h"

#include <X11/X.h>
#include <X11/Xlib.h>

/*  Global Funtion to get all X-Fonts into a QStrList-Object.
    Remeber to delete this object after usage !!

    FIXME: This should be moved somewhere else.
 */
QStrList *KFontList_GetXFonts()
{
  int		numFonts;
  
  QStrList *fontlist = new QStrList(true);

  char **fontNames = XListFonts(qt_xdisplay(), "*", 32767, &numFonts);
  char **fontNames_copy = fontNames;
  
  for (int i = 0 ; i < numFonts - 1; i++) {
    if (**fontNames != '-') {// Font Name doesn't start with a dash -- an alias
      fontNames++;
      continue;
    };
    fontlist->inSort(*fontNames);
    fontNames++;
  }

  XFreeFontNames(fontNames_copy);
  
  return fontlist;
}

extern "C"
{
  KCModule *create_fontmanager(QWidget *parent, const char *name)
  {
    KGlobal::locale()->insertCatalogue("kcmfontmanager");
    return new Toplevel(parent, name);
  };
}
