~ubuntu-branches/ubuntu/gutsy/kdebase-workspace/gutsy-backports

« back to all changes in this revision

Viewing changes to kmenuedit/main.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-09-05 20:45:14 UTC
  • Revision ID: james.westby@ubuntu.com-20070905204514-632hhspl0nvrc84i
Tags: upstream-3.93.0
ImportĀ upstreamĀ versionĀ 3.93.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *   Copyright (C) 2000 Matthias Elter <elter@kde.org>
 
3
 *   Copyright (C) 2001-2002 Raffaele Sandrini <sandrini@kde.org)
 
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 Free Software
 
17
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
18
 *
 
19
 */
 
20
 
 
21
#include <unistd.h>
 
22
 
 
23
#include <kuniqueapplication.h>
 
24
#include <klocale.h>
 
25
#include <kcmdlineargs.h>
 
26
#include <kaboutdata.h>
 
27
 
 
28
#include "kmenuedit.h"
 
29
#include "khotkeys.h"
 
30
 
 
31
static const char description[] = I18N_NOOP("KDE menu editor");
 
32
static const char version[] = "0.7";
 
33
 
 
34
static KMenuEdit *menuEdit = 0;
 
35
 
 
36
class KMenuApplication : public KUniqueApplication
 
37
{
 
38
public:
 
39
   KMenuApplication() { }
 
40
   virtual ~KMenuApplication() { KHotKeys::cleanup(); }
 
41
   
 
42
   virtual int newInstance()
 
43
   {
 
44
      KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
 
45
      if (args->count() > 0)
 
46
      {
 
47
          menuEdit->selectMenu(args->arg(0));
 
48
          if (args->count() > 1)
 
49
          {
 
50
              menuEdit->selectMenuEntry(args->arg(1));
 
51
          }
 
52
      }
 
53
      args->clear();
 
54
      return KUniqueApplication::newInstance();
 
55
   }
 
56
};
 
57
 
 
58
 
 
59
extern "C" int KDE_EXPORT kdemain( int argc, char **argv )
 
60
{
 
61
    KAboutData aboutData("kmenuedit", 0, ki18n("KDE Menu Editor"),
 
62
                         version, ki18n(description), KAboutData::License_GPL,
 
63
                         ki18n("(C) 2000-2003, Waldo Bastian, Raffaele Sandrini, Matthias Elter"));
 
64
    aboutData.addAuthor(ki18n("Waldo Bastian"), ki18n("Maintainer"), "bastian@kde.org");
 
65
    aboutData.addAuthor(ki18n("Raffaele Sandrini"), ki18n("Previous Maintainer"), "sandrini@kde.org");
 
66
    aboutData.addAuthor(ki18n("Matthias Elter"), ki18n("Original Author"), "elter@kde.org");
 
67
 
 
68
    KCmdLineArgs::init( argc, argv, &aboutData );
 
69
    KUniqueApplication::addCmdLineOptions();
 
70
 
 
71
    KCmdLineOptions options;
 
72
    options.add("+[menu]", ki18n("Sub menu to pre-select"));
 
73
    options.add("+[menu-id]", ki18n("Menu entry to pre-select"));
 
74
    KCmdLineArgs::addCmdLineOptions( options );
 
75
 
 
76
    if (!KUniqueApplication::start()) 
 
77
        return 1;
 
78
 
 
79
    KMenuApplication app;
 
80
 
 
81
    menuEdit = new KMenuEdit(false);
 
82
    menuEdit->show();
 
83
 
 
84
    app.setMainWidget(menuEdit);
 
85
    return  app.exec();
 
86
}