Code cleanup
This commit is contained in:
parent
00438546ae
commit
cf05ddd189
|
@ -1,5 +1,5 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
/* Copyright (c) 2012 Pierre Pronchery <khorben@defora.org> */
|
/* Copyright (c) 2012-2013 Pierre Pronchery <khorben@defora.org> */
|
||||||
/* This file is part of DeforaOS Desktop Keyboard */
|
/* This file is part of DeforaOS Desktop Keyboard */
|
||||||
/* This program is free software: you can redistribute it and/or modify
|
/* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -26,7 +26,6 @@
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
#define _(string) gettext(string)
|
#define _(string) gettext(string)
|
||||||
|
|
||||||
|
|
||||||
/* constants */
|
/* constants */
|
||||||
#ifndef PREFIX
|
#ifndef PREFIX
|
||||||
# define PREFIX "/usr/local"
|
# define PREFIX "/usr/local"
|
||||||
|
@ -43,6 +42,8 @@
|
||||||
/* private */
|
/* private */
|
||||||
/* prototypes */
|
/* prototypes */
|
||||||
static int _keyboardctl(KeyboardMessage message, unsigned int arg1);
|
static int _keyboardctl(KeyboardMessage message, unsigned int arg1);
|
||||||
|
|
||||||
|
static int _error(char const * message, int ret);
|
||||||
static int _usage(void);
|
static int _usage(void);
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,6 +55,15 @@ static int _keyboardctl(KeyboardMessage message, unsigned int arg1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* error */
|
||||||
|
static int _error(char const * message, int ret)
|
||||||
|
{
|
||||||
|
fputs("keyboardctl: ", stderr);
|
||||||
|
perror(message);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* usage */
|
/* usage */
|
||||||
static int _usage(void)
|
static int _usage(void)
|
||||||
{
|
{
|
||||||
|
@ -73,7 +83,8 @@ int main(int argc, char * argv[])
|
||||||
int message = -1;
|
int message = -1;
|
||||||
int arg1;
|
int arg1;
|
||||||
|
|
||||||
setlocale(LC_ALL, "");
|
if(setlocale(LC_ALL, "") == NULL)
|
||||||
|
_error("setlocale", 1);
|
||||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
textdomain(PACKAGE);
|
textdomain(PACKAGE);
|
||||||
gtk_init(&argc, &argv);
|
gtk_init(&argc, &argv);
|
||||||
|
|
42
src/main.c
42
src/main.c
|
@ -1,5 +1,5 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
/* Copyright (c) 2010-2012 Pierre Pronchery <khorben@defora.org> */
|
/* Copyright (c) 2010-2013 Pierre Pronchery <khorben@defora.org> */
|
||||||
/* This file is part of DeforaOS Desktop Keyboard */
|
/* This file is part of DeforaOS Desktop Keyboard */
|
||||||
/* This program is free software: you can redistribute it and/or modify
|
/* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -26,7 +26,6 @@
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
#define _(string) gettext(string)
|
#define _(string) gettext(string)
|
||||||
|
|
||||||
|
|
||||||
/* constants */
|
/* constants */
|
||||||
#ifndef PREFIX
|
#ifndef PREFIX
|
||||||
# define PREFIX "/usr/local"
|
# define PREFIX "/usr/local"
|
||||||
|
@ -39,8 +38,38 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* keyboard */
|
||||||
/* private */
|
/* private */
|
||||||
|
/* prototypes */
|
||||||
|
static int _keyboard(KeyboardPrefs * prefs);
|
||||||
|
|
||||||
|
static int _error(char const * message, int ret);
|
||||||
|
static int _usage(void);
|
||||||
|
|
||||||
|
|
||||||
/* functions */
|
/* functions */
|
||||||
|
/* keyboard */
|
||||||
|
static int _keyboard(KeyboardPrefs * prefs)
|
||||||
|
{
|
||||||
|
Keyboard * keyboard;
|
||||||
|
|
||||||
|
if((keyboard = keyboard_new(prefs)) == NULL)
|
||||||
|
return -1;
|
||||||
|
gtk_main();
|
||||||
|
keyboard_delete(keyboard);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* error */
|
||||||
|
static int _error(char const * message, int ret)
|
||||||
|
{
|
||||||
|
fputs("keyboard: ", stderr);
|
||||||
|
perror(message);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* usage */
|
/* usage */
|
||||||
static int _usage(void)
|
static int _usage(void)
|
||||||
{
|
{
|
||||||
|
@ -62,11 +91,11 @@ static int _usage(void)
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
int o;
|
int o;
|
||||||
Keyboard * keyboard;
|
|
||||||
KeyboardPrefs prefs;
|
KeyboardPrefs prefs;
|
||||||
char * p;
|
char * p;
|
||||||
|
|
||||||
setlocale(LC_ALL, "");
|
if(setlocale(LC_ALL, "") == NULL)
|
||||||
|
_error("setlocale", 1);
|
||||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
textdomain(PACKAGE);
|
textdomain(PACKAGE);
|
||||||
memset(&prefs, 0, sizeof(prefs));
|
memset(&prefs, 0, sizeof(prefs));
|
||||||
|
@ -102,8 +131,5 @@ int main(int argc, char * argv[])
|
||||||
}
|
}
|
||||||
if(optind != argc)
|
if(optind != argc)
|
||||||
return _usage();
|
return _usage();
|
||||||
keyboard = keyboard_new(&prefs);
|
return (_keyboard(&prefs) == 0) ? 0 : 2;
|
||||||
gtk_main();
|
|
||||||
keyboard_delete(keyboard);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user