|
Line 0
Link Here
|
|
|
1 |
/***************************************************************** |
| 2 |
KWin - the KDE window manager |
| 3 |
This file is part of the KDE project. |
| 4 |
|
| 5 |
Copyright (C) 2005 Lubos Lunak <l.lunak@kde.org> |
| 6 |
|
| 7 |
You can Freely distribute this program under the GNU General Public |
| 8 |
License. See the file "COPYING" for the exact licensing terms. |
| 9 |
******************************************************************/ |
| 10 |
|
| 11 |
// read addtional window rules and add them to kwinrulesrc |
| 12 |
|
| 13 |
#include <dcopclient.h> |
| 14 |
#include <kconfig.h> |
| 15 |
#include <kdebug.h> |
| 16 |
#include <kinstance.h> |
| 17 |
#include <kstandarddirs.h> |
| 18 |
|
| 19 |
int main( int argc, char* argv[] ) |
| 20 |
{ |
| 21 |
if( argc != 2 ) |
| 22 |
return 1; |
| 23 |
KInstance inst( "kwin_update_default_rules" ); |
| 24 |
QString file = locate( "data", QString( "kwin/default_rules/" ) + argv[ 1 ] ); |
| 25 |
if( file.isEmpty()) |
| 26 |
{ |
| 27 |
kdWarning() << "File " << argv[ 1 ] << " not found!" << endl; |
| 28 |
return 1; |
| 29 |
} |
| 30 |
KConfig src_cfg( file ); |
| 31 |
KConfig dest_cfg( "kwinrulesrc" ); |
| 32 |
src_cfg.setGroup( "General" ); |
| 33 |
dest_cfg.setGroup( "General" ); |
| 34 |
int count = src_cfg.readNumEntry( "count", 0 ); |
| 35 |
int pos = dest_cfg.readNumEntry( "count", 0 ); |
| 36 |
for( int group = 1; |
| 37 |
group <= count; |
| 38 |
++group ) |
| 39 |
{ |
| 40 |
QMap< QString, QString > entries = src_cfg.entryMap( QString::number( group )); |
| 41 |
++pos; |
| 42 |
dest_cfg.deleteGroup( QString::number( pos )); |
| 43 |
dest_cfg.setGroup( QString::number( pos )); |
| 44 |
for( QMap< QString, QString >::ConstIterator it = entries.begin(); |
| 45 |
it != entries.end(); |
| 46 |
++it ) |
| 47 |
dest_cfg.writeEntry( it.key(), *it ); |
| 48 |
} |
| 49 |
dest_cfg.setGroup( "General" ); |
| 50 |
dest_cfg.writeEntry( "count", pos ); |
| 51 |
src_cfg.sync(); |
| 52 |
dest_cfg.sync(); |
| 53 |
DCOPClient client; |
| 54 |
client.attach(); |
| 55 |
client.send("kwin*", "", "reconfigure()", ""); |
| 56 |
} |