koshell

koshell_main.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
00003    Copyright (C) 2000, 2001 David Faure <faure@kde.org>
00004 
00005    This program is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU 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 program 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     General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program; see the file COPYING.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include <kofficeversion.h>
00022 #include <kaboutdata.h>
00023 #include <kcmdlineargs.h>
00024 #include <kdebug.h>
00025 #include <klocale.h>
00026 #include <kuniqueapplication.h>
00027 #include <kwin.h>
00028 
00029 #include <KoGlobal.h>
00030 
00031 #include "koshell_shell.h"
00032 
00033 static const char* description = I18N_NOOP("KOffice Workspace");
00034 static const char* version = KOFFICE_VERSION_STRING;
00035 
00036 class KoShellApp : public KUniqueApplication {
00037   public:
00038     KoShellApp() : mMainWindow( 0 ) {}
00039     ~KoShellApp() {}
00040 
00041     int newInstance();
00042 
00043   private:
00044     KoShellWindow *mMainWindow;
00045 };
00046 
00047 
00048 int KoShellApp::newInstance()
00049 {
00050   if ( isRestored() ) {
00051     // There can only be one main window
00052     if ( KMainWindow::canBeRestored( 1 ) ) {
00053       mMainWindow = new KoShellWindow();
00054       setMainWidget( mMainWindow );
00055       mMainWindow->show();
00056       mMainWindow->restore( 1 );
00057     }
00058   } else {
00059     if ( !mMainWindow ) {
00060       mMainWindow = new KoShellWindow();
00061       mMainWindow->show();
00062       setMainWidget( mMainWindow );
00063     }
00064   }
00065   // Handle startup notification and window activation
00066   // (The first time it will do nothing except note that it was called)
00067   return KUniqueApplication::newInstance();
00068 }
00069 
00070 extern "C" KOSHELL_EXPORT int kdemain( int argc, char **argv )
00071 {
00072   KAboutData * aboutData = new KAboutData( "koshell", I18N_NOOP("KOffice Workspace"),
00073      version, description, KAboutData::License_GPL,
00074        "(c) 1998-2006, Torben Weis\n(c) 2002-2005, David Faure\n(c) 2005, Sven Lüppken");
00075   aboutData->addAuthor("Sven Lüppken", I18N_NOOP("Current Maintainer"), "sven@kde.org");
00076   aboutData->addAuthor("Torben Weis", 0, "weis@kde.org");
00077   aboutData->addAuthor("David Faure", 0, "faure@kde.org");
00078   KCmdLineArgs::init( argc, argv, aboutData );
00079 
00080   if ( !KoShellApp::start() ) {
00081     // Already running, brought to the foreground.
00082     return 0;
00083   }
00084   KoShellApp app;
00085   // Initialize stuff (like KoApplication does)
00086   KoGlobal::initialize();
00087 
00088   return app.exec();
00089 }
00090 
KDE Home | KDE Accessibility Home | Description of Access Keys