koshell

koshell_main.cpp
1/* This file is part of the KDE project
2 Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 Copyright (C) 2000, 2001 David Faure <faure@kde.org>
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#include <kofficeversion.h>
22#include <tdeaboutdata.h>
23#include <tdecmdlineargs.h>
24#include <kdebug.h>
25#include <tdelocale.h>
26#include <kuniqueapplication.h>
27#include <twin.h>
28
29#include <KoGlobal.h>
30
31#include "koshell_shell.h"
32
33static const char* description = I18N_NOOP("KOffice Workspace");
34static const char* version = KOFFICE_VERSION_STRING;
35
36class KoShellApp : public KUniqueApplication {
37 public:
38 KoShellApp() : mMainWindow( 0 ) {}
39 ~KoShellApp() {}
40
41 int newInstance();
42
43 private:
44 KoShellWindow *mMainWindow;
45};
46
47
48int KoShellApp::newInstance()
49{
50 if ( isRestored() ) {
51 // There can only be one main window
52 if ( TDEMainWindow::canBeRestored( 1 ) ) {
53 mMainWindow = new KoShellWindow();
54 setMainWidget( mMainWindow );
55 mMainWindow->show();
56 mMainWindow->restore( 1 );
57 }
58 } else {
59 if ( !mMainWindow ) {
60 mMainWindow = new KoShellWindow();
61 mMainWindow->show();
62 setMainWidget( mMainWindow );
63 }
64 }
65 // Handle startup notification and window activation
66 // (The first time it will do nothing except note that it was called)
67 return KUniqueApplication::newInstance();
68}
69
70extern "C" KOSHELL_EXPORT int kdemain( int argc, char **argv )
71{
72 TDEAboutData * aboutData = new TDEAboutData( "koshell", I18N_NOOP("KOffice Workspace"),
73 version, description, TDEAboutData::License_GPL,
74 "(c) 1998-2006, Torben Weis\n(c) 2002-2005, David Faure\n(c) 2005, Sven Lüppken");
75 aboutData->addAuthor("Sven Lüppken", I18N_NOOP("Current Maintainer"), "sven@kde.org");
76 aboutData->addAuthor("Torben Weis", 0, "weis@kde.org");
77 aboutData->addAuthor("David Faure", 0, "faure@kde.org");
78 TDECmdLineArgs::init( argc, argv, aboutData );
79
80 if ( !KoShellApp::start() ) {
81 // Already running, brought to the foreground.
82 return 0;
83 }
84 KoShellApp app;
85 // Initialize stuff (like KoApplication does)
86 KoGlobal::initialize();
87
88 return app.exec();
89}
90