~ubuntu-branches/ubuntu/warty/kdebase/warty

« back to all changes in this revision

Viewing changes to kpager/main.cpp

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-09-16 04:51:45 UTC
  • Revision ID: james.westby@ubuntu.com-20040916045145-9vr63kith3k1cpza
Tags: upstream-3.2.2
ImportĀ upstreamĀ versionĀ 3.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**************************************************************************
 
2
 
 
3
    main.cpp  - The main function for KPager
 
4
    Copyright (C) 1998-2000  Antonio Larrosa Jimenez
 
5
 
 
6
    This program is free software; you can redistribute it and/or modify
 
7
    it under the terms of the GNU General Public License as published by
 
8
    the Free Software Foundation; either version 2 of the License, or
 
9
    (at your option) any later version.
 
10
 
 
11
    This program is distributed in the hope that it will be useful,
 
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
    GNU General Public License for more details.
 
15
 
 
16
    You should have received a copy of the GNU General Public License
 
17
    along with this program; if not, write to the Free Software
 
18
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
19
 
 
20
    Send comments and bug fixes to larrosa@kde.org
 
21
 
 
22
***************************************************************************/
 
23
 
 
24
#include <kuniqueapplication.h>
 
25
#include <klocale.h>
 
26
#include <kcmdlineargs.h>
 
27
#include <kaboutdata.h>
 
28
#include <qcolor.h>
 
29
#include <kdebug.h>
 
30
#include <stdlib.h>
 
31
#include <qsessionmanager.h>
 
32
 
 
33
#include "kpager.h"
 
34
 
 
35
static KCmdLineOptions pagerOpts[] =
 
36
{
 
37
    { "hidden", I18N_NOOP("Create pager but keep the window hidden"), 0 },
 
38
    KCmdLineLastOption
 
39
};
 
40
 
 
41
bool closed_by_sm = false;
 
42
 
 
43
class KPagerApplication : public KUniqueApplication
 
44
{
 
45
public:
 
46
  KPagerApplication() : KUniqueApplication() {}
 
47
 
 
48
  void commitData(QSessionManager& sm) {
 
49
    if (mainWidget()->isHidden()) {
 
50
      sm.setRestartHint( QSessionManager::RestartNever );
 
51
      return;
 
52
    }
 
53
    closed_by_sm = true;
 
54
    KUniqueApplication::commitData( sm );
 
55
    closed_by_sm = false;
 
56
  }
 
57
 
 
58
  int newInstance() {
 
59
    mainWidget()->show();
 
60
    return 0;
 
61
  }
 
62
 
 
63
};
 
64
 
 
65
int main(int argc, char **argv)
 
66
{
 
67
    KAboutData *aboutdata = new KAboutData("kpager", "KPager", "1.5",
 
68
                                           I18N_NOOP("Desktop Overview"), KAboutData::License_GPL,
 
69
                                           "(C) 1998-2002, Antonio Larrosa Jimenez","",
 
70
                                           "http://devel-home.kde.org/~larrosa/kpager.html");
 
71
 
 
72
    aboutdata->addAuthor("Antonio Larrosa Jimenez",
 
73
                         I18N_NOOP("Original Developer/Maintainer"),"larrosa@kde.org",
 
74
                         "http://devel-home.kde.org/~larrosa/index.html");
 
75
    aboutdata->addAuthor("Matthias Elter",
 
76
                         I18N_NOOP("Developer"),"elter@kde.org", "");
 
77
    aboutdata->addAuthor("Matthias Ettrich",
 
78
                         I18N_NOOP("Developer"),"ettrich@kde.org", "");
 
79
 
 
80
    KCmdLineArgs::init(argc, argv, aboutdata);
 
81
    KCmdLineArgs::addCmdLineOptions(pagerOpts);
 
82
    KUniqueApplication::addCmdLineOptions();
 
83
 
 
84
    if (!KUniqueApplication::start())
 
85
    {
 
86
      kdError() << "kpager is already running!" << endl;
 
87
      return 0;
 
88
    }
 
89
 
 
90
 
 
91
    KApplication * app = new KPagerApplication;
 
92
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
 
93
 
 
94
    KPagerMainWindow *kpager = new KPagerMainWindow(0,"KPager");
 
95
    kpager->setPlainCaption( i18n("Desktop Pager") );
 
96
 
 
97
 
 
98
    app->setMainWidget(kpager);
 
99
    if (!args->isSet("hidden")) kpager->show();
 
100
    else kpager->hide();
 
101
 
 
102
    int ret = app->exec();
 
103
 
 
104
    delete app;
 
105
    return ret;
 
106
}
 
107