~ubuntu-branches/ubuntu/karmic/kdepim/karmic

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*******************************************************************
 KNotes -- Notes for the KDE project

 Copyright (c) 1997-2007, The KNotes Developers

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*******************************************************************/

#include "version.h"
#include "application.h"

#include <kcmdlineargs.h>
#include <kaboutdata.h>
#include <klocale.h>
#include <kxerrorhandler.h>

#ifdef Q_WS_X11
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <QX11Info>
#endif

void remove_sm_from_client_leader();
KCmdLineOptions knotesOptions();
void knotesAuthors(  KAboutData &aboutData );

int main( int argc, char *argv[] )
{
  QString version = QString::number( KNOTES_VERSION );

  KAboutData aboutData( "knotes",
                         0,
                         ki18n( "KNotes" ),
                         version.toLatin1(),
                         ki18n( "KDE Notes" ),
                         KAboutData::License_GPL,
                         ki18n( "(c) 1997-2009, The KNotes Developers" ) );

  knotesAuthors( aboutData );

  KCmdLineArgs::init( argc, argv, &aboutData );

  // Command line options

  KCmdLineArgs::addCmdLineOptions( knotesOptions() );

  KUniqueApplication::addCmdLineOptions();


  // Create Application

  Application app;


  remove_sm_from_client_leader();

  return app.exec();
}

void remove_sm_from_client_leader()
{
#ifdef Q_WS_X11
  Atom type;
  int format, status;
  unsigned long nitems = 0;
  unsigned long extra = 0;
  unsigned char *data = 0;

  Atom atoms[ 2 ];
  char *atom_names[ 2 ] = { ( char * ) "WM_CLIENT_LEADER",
                            ( char * ) "SM_CLIENT_ID" };

  XInternAtoms( QX11Info::display(), atom_names, 2, False, atoms );

  QWidget w;
  KXErrorHandler handler; // ignore X errors
  status = XGetWindowProperty( QX11Info::display(), w.winId(), atoms[ 0 ], 0,
                               10000, false, XA_WINDOW, &type, &format, &nitems,
                               &extra, &data );

  if ( ( status == Success ) && !handler.error( false ) ) {
      if ( data && ( nitems > 0 ) ) {
          Window leader = * ( ( Window * ) data );
          XDeleteProperty( QX11Info::display(), leader, atoms[ 1 ] );
      }
      XFree( data );
  }
#endif
}

KCmdLineOptions knotesOptions()
{
  KCmdLineOptions options;

  options.add( "skip-note",
               ki18n( "Suppress creation of a new note "
                      "on a non-unique instance." ) );

  return options;
}

void knotesAuthors(  KAboutData &aboutData )
{
  aboutData.addAuthor( ki18n( "Guillermo Antonio Amaral Bastidas" ),
                       ki18n( "Maintainer" ),
                       "me@guillermoamaral.com" );
  aboutData.addAuthor( ki18n( "Michael Brade" ),
                       ki18n( "Previous Maintainer" ),
                       "brade@kde.org" );
  aboutData.addAuthor( ki18n( "Bernd Johannes Wuebben" ),
                       ki18n( "Original KNotes Author" ),
                       "wuebben@kde.org" );
  aboutData.addAuthor( ki18n( "Wynn Wilkes" ),
                       ki18n( "Ported KNotes to KDE 2" ),
                       "wynnw@calderasystems.com" );
  aboutData.addAuthor( ki18n( "Daniel Martin" ),
                       ki18n( "Network Interface" ),
                       "daniel.martin@pirack.com" );
  aboutData.addAuthor( ki18n( "Bo Thorsen" ),
                       ki18n( "Started KDE Resource Framework Integration" ),
                       "bo@sonofthor.dk" );

  aboutData.addCredit( ki18n( "Bera Debajyoti" ),
                       ki18n( "Idea and initial code for the new look & feel" ),
                       "debajyotibera@gmail.com" );
  aboutData.addCredit( ki18n( "Matthias Ettrich" ),
                       KLocalizedString(),
                       "ettrich@kde.org" );
  aboutData.addCredit( ki18n( "David Faure" ),
                       KLocalizedString(),
                       "faure@kde.org" );
  aboutData.addCredit( ki18n( "Matthias Kiefer" ),
                       KLocalizedString(),
                       "kiefer@kde.org" );
  aboutData.addCredit( ki18n( "Luboš Luňák" ),
                       KLocalizedString(),
                       "l.lunak@kde.org" );
  aboutData.addCredit( ki18n( "Laurent Montel" ),
                       KLocalizedString(),
                       "montel@kde.org" );
  aboutData.addCredit( ki18n( "Dirk A. Mueller" ),
                       KLocalizedString(),
                       "dmuell@gmx.net" );
  aboutData.addCredit( ki18n( "Carsten Pfeiffer" ),
                       KLocalizedString(),
                       "pfeiffer@kde.org" );
  aboutData.addCredit( ki18n( "Harri Porten" ),
                       KLocalizedString(),
                       "porten@kde.org" );
  aboutData.addCredit( ki18n( "Espen Sand" ),
                       KLocalizedString(),
                       "espen@kde.org" );
}