~ubuntu-branches/ubuntu/precise/kbibtex/precise

« back to all changes in this revision

Viewing changes to src/main.cpp

  • Committer: Package Import Robot
  • Author(s): Michael Hanke
  • Date: 2011-07-18 09:29:48 UTC
  • mfrom: (1.1.6) (2.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20110718092948-ksxjmg7kdfamolmg
Tags: 0.3-1
* First upstream release for KDE4 (Closes: #634255). A number of search
  engines are still missing, in comparison to the 0.2 series.
* Bumped Standards-Version to 3.9.2, no changes necessary.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
*   Copyright (C) 2004-2009 by Thomas Fischer                             *
3
 
*   fischer@unix-ag.uni-kl.de                                             *
4
 
*                                                                         *
5
 
*   This program is free software; you can redistribute it and/or modify  *
6
 
*   it under the terms of the GNU General Public License as published by  *
7
 
*   the Free Software Foundation; either version 2 of the License, or     *
8
 
*   (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         *
13
 
*   GNU 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; if not, write to the                         *
17
 
*   Free Software Foundation, Inc.,                                       *
18
 
*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19
 
***************************************************************************/
20
 
 
21
 
// #define UNIQUEAPP 1
22
 
 
23
 
#include <qframe.h>
24
 
#include <qpixmap.h>
25
 
#ifdef UNIQUEAPP
26
 
#include <kuniqueapplication.h>
27
 
#else // UNIQUEAPP
28
 
#include <kapplication.h>
29
 
#endif // UNIQUEAPP
30
 
#include <kmessagebox.h>
31
 
#include <kaboutdata.h>
32
 
#include <kcmdlineargs.h>
33
 
#include <klocale.h>
34
 
#include <kglobal.h>
35
 
#include <kstandarddirs.h>
36
 
#include <kdebug.h>
37
 
#include "kbibtexshell.h"
38
 
 
39
 
static const char description[] =
40
 
    I18N_NOOP( "A BibTeX editor for KDE" );
41
 
 
42
 
static const char version[] = "0.2.3.90";
43
 
 
44
 
static KCmdLineOptions options[] =
45
 
{
46
 
    { "+[URL]", I18N_NOOP( "Document to open." ), 0
47
 
    },
48
 
    KCmdLineLastOption
49
 
};
50
 
 
51
 
#ifdef UNIQUEAPP
52
 
class KBibTeXApplication: public KUniqueApplication
53
 
#else // UNIQUEAPP
54
 
class KBibTeXApplication: public KApplication
55
 
#endif // UNIQUEAPP
56
 
{
57
 
public:
58
 
#ifdef UNIQUEAPP
59
 
    KBibTeXApplication() : KUniqueApplication()
60
 
    {
61
 
// nothing
62
 
    }
63
 
 
64
 
    int newInstance()
65
 
    {
66
 
#else // UNIQUEAPP
67
 
    KBibTeXApplication() : KApplication()
68
 
    {
69
 
#endif // UNIQUEAPP
70
 
        // see if we are starting with session management
71
 
        if ( isRestored() )
72
 
        {
73
 
            RESTORE( KBibTeXShell );
74
 
        }
75
 
        else
76
 
        {
77
 
            // no session.. just start up normally
78
 
            KCmdLineArgs * args = KCmdLineArgs::parsedArgs();
79
 
 
80
 
            if ( args->count() == 0 )
81
 
            {
82
 
                KBibTeXShell * shell = new KBibTeXShell();
83
 
                shell->show();
84
 
            }
85
 
            else
86
 
            {
87
 
                for ( int i = 0 ; i < args->count(); i++ )
88
 
                {
89
 
                    KBibTeXShell *shell = new KBibTeXShell();
90
 
                    if ( shell->openURL( args->url( i ) ) )
91
 
                        shell->show();
92
 
                    else
93
 
                    {
94
 
                        kdDebug() << "Couldn't open file " << args->url( i ).path() << endl;
95
 
                        KMessageBox::error( NULL, i18n( "Could not open file '%1'." ).arg( args->url( i ).path() ) );
96
 
                    }
97
 
                }
98
 
            }
99
 
            args->clear();
100
 
        }
101
 
 
102
 
#ifdef UNIQUEAPP
103
 
        return 0;
104
 
#endif // UNIQUEAPP
105
 
 
106
 
    }
107
 
};
108
 
 
109
 
int main( int argc, char **argv )
110
 
{
111
 
    KAboutData about( "kbibtex", I18N_NOOP( "KBibTeX" ), version, description,
112
 
                      KAboutData::License_GPL, "(C) 2004-2009 Thomas Fischer", 0, "http://www.unix-ag.uni-kl.de/~fischer/kbibtex/", "fischer@unix-ag.uni-kl.de" );
113
 
    about.addAuthor( "Thomas Fischer", 0, "fischer@unix-ag.uni-kl.de" );
114
 
    about.setTranslator( I18N_NOOP( "NAME OF TRANSLATORS" ), I18N_NOOP( "EMAIL OF TRANSLATORS" ) );
115
 
    KCmdLineArgs::init( argc, argv, &about );
116
 
    KCmdLineArgs::addCmdLineOptions( options );
117
 
 
118
 
#ifdef UNIQUEAPP
119
 
    if ( !KUniqueApplication::start() )
120
 
    {
121
 
        kdDebug() << "Reusing existing KBibTeX instance" << endl;
122
 
        return 0;
123
 
    }
124
 
#endif // UNIQUEAPP
125
 
 
126
 
    KBibTeXApplication app;
127
 
    return app.exec();
128
 
}