• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • libtdescreensaver
 

libtdescreensaver

main.cpp

00001 /* This file is part of the KDE libraries
00002 
00003     Copyright (c) 2001  Martin R. Jones <mjones@kde.org>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018     Boston, MA 02110-1301, USA.
00019 */
00020 #include <config.h>
00021 
00022 #include <stdlib.h>
00023 #include <stdio.h>
00024 #include <signal.h>
00025 
00026 #include <tqdialog.h>
00027 #include <tdelocale.h>
00028 #include <tdeglobal.h>
00029 #include <kdebug.h>
00030 #include <tdecmdlineargs.h>
00031 #include <tdeapplication.h>
00032 #include <kcrash.h>
00033 
00034 #include "tdescreensaver.h"
00035 #include "tdescreensaver_vroot.h"
00036 
00037 bool argb_visual = FALSE;
00038 
00039 extern "C"
00040 {
00041     extern const char *kss_applicationName;
00042     extern const char *kss_description;
00043     extern const char *kss_version;
00044     KScreenSaver *kss_create( WId d );
00045     TQDialog *kss_setup();
00046 }
00047 
00048 static const TDECmdLineOptions options[] =
00049 {
00050   { "setup", I18N_NOOP("Setup screen saver"), 0 },
00051   { "window-id wid", I18N_NOOP("Run in the specified XWindow"), 0 },
00052   { "root", I18N_NOOP("Run in the root XWindow"), 0 },
00053   { "demo", I18N_NOOP("Start screen saver in demo mode"), "default"},
00054   TDECmdLineLastOption
00055 };
00056 
00057 static void crashHandler( int  )
00058 {
00059 #ifdef SIGABRT
00060     signal (SIGABRT, SIG_DFL);
00061 #endif
00062     abort();
00063 }
00064 
00065 //----------------------------------------------------------------------------
00066 
00067 class DemoWindow : public TQWidget
00068 {
00069 public:
00070     DemoWindow() : TQWidget()
00071     {
00072     setFixedSize(600, 420);
00073     }
00074 
00075 protected:
00076     virtual void keyPressEvent(TQKeyEvent *e)
00077     {
00078         if (e->ascii() == 'q')
00079         {
00080             kapp->quit();
00081         }
00082     }
00083 
00084     virtual void closeEvent( TQCloseEvent * )
00085     {
00086         kapp->quit();
00087     }
00088 };
00089 
00090 
00091 //----------------------------------------------------------------------------
00092 #if defined(Q_WS_QWS) || defined(Q_WS_MACX)
00093 typedef WId Window;
00094 #endif
00095 
00096 KDE_EXPORT int main(int argc, char *argv[])
00097 {
00098     TDELocale::setMainCatalogue("libtdescreensaver");
00099     TDECmdLineArgs::init(argc, argv, kss_applicationName, kss_description, kss_version);
00100 
00101     TDECmdLineArgs::addCmdLineOptions(options);
00102 
00103 #ifdef HAVE_XCOMPOSITE
00104     TDEApplication app(TDEApplication::openX11RGBADisplay());
00105     argb_visual = app.isX11CompositionAvailable();
00106 #else
00107     TDEApplication app;
00108 #endif
00109 
00110     TDECrash::setCrashHandler( crashHandler );
00111     TDEGlobal::locale()->insertCatalogue("klock");
00112     TDEGlobal::locale()->insertCatalogue("tdescreensaver");
00113 
00114     DemoWindow *demoWidget = 0;
00115     Window saveWin = 0;
00116     KScreenSaver *target;
00117 
00118     TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
00119 
00120     if (args->isSet("setup"))
00121     {
00122        TQDialog *dlg = kss_setup();
00123        args->clear();
00124        dlg->exec();
00125        delete dlg;
00126        exit(0);
00127     }
00128 
00129     if (args->isSet("window-id"))
00130     {
00131         saveWin = atol(args->getOption("window-id"));
00132     }
00133 
00134 #ifdef Q_WS_X11 //FIXME
00135     if (args->isSet("root"))
00136     {
00137         saveWin = RootWindow(tqt_xdisplay(), tqt_xscreen());
00138     }
00139 #endif
00140 
00141     if (args->isSet("demo"))
00142     {
00143         saveWin = 0;
00144     }
00145 
00146     if (saveWin == 0)
00147     {
00148         demoWidget = new DemoWindow();
00149         demoWidget->setBackgroundMode(TQWidget::NoBackground);
00150         saveWin = demoWidget->winId();
00151         app.setMainWidget(demoWidget);
00152         app.processEvents();
00153     }
00154 
00155     target = kss_create( saveWin );
00156 
00157     if ( demoWidget )
00158     {
00159         demoWidget->setFixedSize( 600, 420 );
00160         demoWidget->show();
00161     }
00162     args->clear();
00163     app.exec();
00164 
00165     delete target;
00166     delete demoWidget;
00167 
00168     return 0;
00169 }
00170 

libtdescreensaver

Skip menu "libtdescreensaver"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

libtdescreensaver

Skip menu "libtdescreensaver"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for libtdescreensaver by doxygen 1.7.1
This website is maintained by Timothy Pearson.