Don't offer to restart a Running (=busy) agent, it won't work.
[kdepim.git] / knotes / main.cpp
blobf52ddac8555223afe9b33f44bf788db9b81e321a
1 /*******************************************************************
2 KNotes -- Notes for the KDE project
4 Copyright (c) 1997-2010, The KNotes Developers
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 *******************************************************************/
21 #include "kdepim-version.h"
22 #include "application.h"
24 #include <kcmdlineargs.h>
25 #include <kaboutdata.h>
26 #include <klocale.h>
27 #include <kxerrorhandler.h>
29 #ifdef Q_WS_X11
30 #include <X11/Xlib.h>
31 #include <X11/Xatom.h>
32 #include <QX11Info>
33 #endif
35 void remove_sm_from_client_leader();
36 KCmdLineOptions knotesOptions();
37 void knotesAuthors( KAboutData &aboutData );
39 int main( int argc, char *argv[] )
41 KAboutData aboutData( "knotes",
43 ki18n( "KNotes" ),
44 KDEPIM_VERSION,
45 ki18n( "KDE Notes" ),
46 KAboutData::License_GPL,
47 ki18n( "Copyright © 1997–2010 KNotes authors" ) );
49 knotesAuthors( aboutData );
51 KCmdLineArgs::init( argc, argv, &aboutData );
53 // Command line options
55 KCmdLineArgs::addCmdLineOptions( knotesOptions() );
57 KUniqueApplication::addCmdLineOptions();
60 // Create Application
62 Application app;
63 KGlobal::locale()->insertCatalog("libkdepim");
65 remove_sm_from_client_leader();
67 return app.exec();
70 void remove_sm_from_client_leader()
72 #ifdef Q_WS_X11
73 Atom type;
74 int format, status;
75 unsigned long nitems = 0;
76 unsigned long extra = 0;
77 unsigned char *data = 0;
79 Atom atoms[ 2 ];
80 char *atom_names[ 2 ] = { ( char * ) "WM_CLIENT_LEADER",
81 ( char * ) "SM_CLIENT_ID" };
83 XInternAtoms( QX11Info::display(), atom_names, 2, False, atoms );
85 QWidget w;
86 KXErrorHandler handler; // ignore X errors
87 status = XGetWindowProperty( QX11Info::display(), w.winId(), atoms[ 0 ], 0,
88 10000, false, XA_WINDOW, &type, &format, &nitems,
89 &extra, &data );
91 if ( ( status == Success ) && !handler.error( false ) ) {
92 if ( data && ( nitems > 0 ) ) {
93 Window leader = * ( ( Window * ) data );
94 XDeleteProperty( QX11Info::display(), leader, atoms[ 1 ] );
96 XFree( data );
98 #endif
101 KCmdLineOptions knotesOptions()
103 KCmdLineOptions options;
105 options.add( "skip-note",
106 ki18n( "Suppress creation of a new note "
107 "on a non-unique instance." ) );
109 return options;
112 void knotesAuthors( KAboutData &aboutData )
114 aboutData.addAuthor( ki18n( "Guillermo Antonio Amaral Bastidas" ),
115 ki18n( "Maintainer" ),
116 "me@guillermoamaral.com" );
117 aboutData.addAuthor( ki18n( "Michael Brade" ),
118 ki18n( "Previous Maintainer" ),
119 "brade@kde.org" );
120 aboutData.addAuthor( ki18n( "Bernd Johannes Wuebben" ),
121 ki18n( "Original KNotes Author" ),
122 "wuebben@kde.org" );
123 aboutData.addAuthor( ki18n( "Wynn Wilkes" ),
124 ki18n( "Ported KNotes to KDE 2" ),
125 "wynnw@calderasystems.com" );
126 aboutData.addAuthor( ki18n( "Daniel Martin" ),
127 ki18n( "Network Interface" ),
128 "daniel.martin@pirack.com" );
129 aboutData.addAuthor( ki18n( "Bo Thorsen" ),
130 ki18n( "Started KDE Resource Framework Integration" ),
131 "bo@sonofthor.dk" );
133 aboutData.addCredit( ki18n( "Bera Debajyoti" ),
134 ki18n( "Idea and initial code for the new look & feel" ),
135 "debajyotibera@gmail.com" );
136 aboutData.addCredit( ki18n( "Matthias Ettrich" ),
137 KLocalizedString(),
138 "ettrich@kde.org" );
139 aboutData.addCredit( ki18n( "David Faure" ),
140 KLocalizedString(),
141 "faure@kde.org" );
142 aboutData.addCredit( ki18n( "Matthias Kiefer" ),
143 KLocalizedString(),
144 "kiefer@kde.org" );
145 aboutData.addCredit( ki18n( "Luboš Luňák" ),
146 KLocalizedString(),
147 "l.lunak@kde.org" );
148 aboutData.addCredit( ki18n( "Laurent Montel" ),
149 KLocalizedString(),
150 "montel@kde.org" );
151 aboutData.addCredit( ki18n( "Dirk A. Mueller" ),
152 KLocalizedString(),
153 "dmuell@gmx.net" );
154 aboutData.addCredit( ki18n( "Carsten Pfeiffer" ),
155 KLocalizedString(),
156 "pfeiffer@kde.org" );
157 aboutData.addCredit( ki18n( "Harri Porten" ),
158 KLocalizedString(),
159 "porten@kde.org" );
160 aboutData.addCredit( ki18n( "Espen Sand" ),
161 KLocalizedString(),
162 "espen@kde.org" );