summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergey Udaltsov <svu@gnome.org>2004-10-04 21:51:24 +0000
committerSergey Udaltsov <svu@gnome.org>2004-10-04 21:51:24 +0000
commit2e261677cbf1bff65b334cd12fb2ae4342a6b8da (patch)
tree95ec6521133267d421630a8eca010e988f354204 /tests
parentca30649f27c056494774af384cc37ba76fcf4b27 (diff)
downloadlibxklavier-2e261677cbf1bff65b334cd12fb2ae4342a6b8da.tar.gz
Cleaning up some functions. BREAKING the API/ABI. Hope people will not start chasing me with axes...
Diffstat (limited to 'tests')
-rw-r--r--tests/.cvsignore9
-rw-r--r--tests/test_config.c26
2 files changed, 28 insertions, 7 deletions
diff --git a/tests/.cvsignore b/tests/.cvsignore
index a731fea..702b961 100644
--- a/tests/.cvsignore
+++ b/tests/.cvsignore
@@ -1 +1,8 @@
-Makefile Makefile.in *.o .libs .deps test_config test_monitor
+Makefile
+Makefile.in
+*.o
+.libs
+.deps
+test_config
+test_monitor
+libxklavier.xk?
diff --git a/tests/test_config.c b/tests/test_config.c
index ebe84dd..2121667 100644
--- a/tests/test_config.c
+++ b/tests/test_config.c
@@ -1,17 +1,20 @@
+#include <config.h>
#include <stdio.h>
#include <unistd.h>
#include <X11/Xlib.h>
#include <libxklavier/xklavier.h>
#include <libxklavier/xklavier_config.h>
-enum { ACTION_NONE, ACTION_GET, ACTION_SET };
+enum { ACTION_NONE, ACTION_GET, ACTION_SET, ACTION_WRITE };
static void printUsage()
{
- printf( "Usage: test_config (-g)|(-s -m <model> -l <layouts> -o <options>)|(-h)(-d <debugLevel>)\n" );
+ printf( "Usage: test_config (-g)|(-s -m <model> -l <layouts> -o <options>)|(-h)|(-ws)|(-wb)(-d <debugLevel>)\n" );
printf( "Options:\n" );
printf( " -g - Dump the current config, load original system settings and revert back\n" );
printf( " -s - Set the configuration given my -m -l -o options. Similar to setxkbmap\n" );
+ printf( " -ws - Write the binary XKB config file (" PACKAGE ".xkm)\n" );
+ printf( " -wb - Write the source XKB config file (" PACKAGE ".xkb)\n" );
printf( " -d - Set the debug level (by default, 0)\n" );
printf( " -h - Show this help\n" );
}
@@ -46,10 +49,11 @@ int main( int argc, char * const argv[] )
const char* layouts = NULL;
const char* options = NULL;
int debugLevel = 0;
+ int binary = 0;
while (1)
{
- c = getopt( argc, argv, "hsgm:l:o:d:" );
+ c = getopt( argc, argv, "hsgm:l:o:d:w:" );
if ( c == -1 )
break;
switch (c)
@@ -77,6 +81,9 @@ int main( int argc, char * const argv[] )
case 'd':
debugLevel = atoi( optarg );
break;
+ case 'w':
+ action = ACTION_WRITE;
+ binary = ( 'b' == optarg[0] );
default:
fprintf( stderr, "?? getopt returned character code 0%o ??\n", c );
printUsage();
@@ -124,10 +131,10 @@ int main( int argc, char * const argv[] )
dump( &r2 );
}
- if ( XklConfigActivate( &r2, NULL ) )
+ if ( XklConfigActivate( &r2 ) )
{
XklDebug( 0, "The backup configuration restored\n" );
- if ( XklConfigActivate( &currentConfig, NULL ) )
+ if ( XklConfigActivate( &currentConfig ) )
{
XklDebug( 0, "Reverting the configuration change\n" );
} else
@@ -182,11 +189,18 @@ int main( int argc, char * const argv[] )
XklDebug( 0, "New config:\n" );
dump( &currentConfig );
- if ( XklConfigActivate( &currentConfig, NULL ) )
+ if ( XklConfigActivate( &currentConfig ) )
XklDebug( 0, "Set the config\n" );
else
XklDebug( 0, "Could not set the config: %s\n", XklGetLastError() );
break;
+ case ACTION_WRITE:
+ XklConfigWriteFile( binary ? ( PACKAGE ".xkm" ) : ( PACKAGE ".xkb" ),
+ &currentConfig,
+ binary );
+ XklDebug( 0, "The file " PACKAGE "%s is written\n",
+ binary ? ".xkm" : ".xkb" );
+ break;
}
XklConfigRecDestroy( &currentConfig );