Hello,
sorry for hiding the patch. But i wanted to reengineer WPrefs in the whole.
The patch touches main.c, Theme.c.
Theme.c will be commented out, because it is not used.
Greetings,
c64zottel
Do you have a patch for using getopt? Or was this included in the patch you
> posted before which removed files from WINGs?
> Gilbert
>
>
# Will change:
# main.c - changing to getopt arguments treating
# Theme.c - completely commented out. no use for now.
diff -crB ./main.c ../../WPrefs.app/main.c
*** ./main.c 2008-12-13 22:57:40.000000000 +0100
--- ../../WPrefs.app/main.c 2009-11-20 13:37:32.449992817 +0100
***************
*** 20,153 ****
*/
#include "WPrefs.h"
-
-
- #include <assert.h>
-
#include <X11/Xlocale.h>
- #include <sys/wait.h>
- #include <unistd.h>
-
-
- char *NOptionValueChanged = "NOptionValueChanged";
-
- extern void Initialize(WMScreen *scr);
-
- #define MAX_DEATHS 64
-
- struct {
- pid_t pid;
- void *data;
- void (*handler)(void*);
- } DeadHandlers[MAX_DEATHS];
-
-
- static pid_t DeadChildren[MAX_DEATHS];
- static int DeadChildrenCount = 0;
-
- void
- wAbort(Bool foo)
- {
- exit(1);
- }
static void
! print_help(char *progname)
{
! printf(_("usage: %s [options]\n"), progname);
! puts(_("options:"));
! puts(_(" -display <display> display to be used"));
! puts(_(" --version print version number and exit"));
! puts(_(" --help print this message and exit"));
}
- #if 0
- static RETSIGTYPE
- handleDeadChild(int sig)
- {
- pid_t pid;
- int status;
-
- pid = waitpid(-1, &status, WNOHANG);
- if (pid > 0) {
- DeadChildren[DeadChildrenCount++] = pid;
- }
- }
- #endif
! void
! AddDeadChildHandler(pid_t pid, void (*handler)(void*), void *data)
{
! int i;
!
! for (i = 0; i < MAX_DEATHS; i++) {
! if (DeadHandlers[i].pid == 0) {
! DeadHandlers[i].pid = pid;
! DeadHandlers[i].handler = handler;
! DeadHandlers[i].data = data;
break;
}
}
! assert(i!=MAX_DEATHS);
! }
int
main(int argc, char **argv)
{
! Display *dpy;
! WMScreen *scr;
! char *locale, *path;
! int i;
! char *display_name="";
! wsetabort(wAbort);
! memset(DeadHandlers, 0, sizeof(DeadHandlers));
! WMInitializeApplication("WPrefs", &argc, argv);
! WMSetResourcePath(RESOURCE_PATH);
! path = WMPathForResourceOfType("WPrefs.tiff", NULL);
! if (!path) {
/* maybe it is run directly from the source directory */
WMSetResourcePath(".");
! path = WMPathForResourceOfType("WPrefs.tiff", NULL);
! if (!path) {
! WMSetResourcePath("..");
! }
! }
! if (path) {
! wfree(path);
}
! if (argc>1) {
! for (i=1; i<argc; i++) {
! if (strcmp(argv[i], "-version")==0
! || strcmp(argv[i], "--version")==0) {
! printf("WPrefs (Window Maker) %s\n", VERSION);
! exit(0);
! } else if (strcmp(argv[i], "-display")==0) {
! i++;
! if (i>=argc) {
! wwarning(_("too few arguments for %s"), argv[i-1]);
! exit(0);
! }
! display_name = argv[i];
! } else {
! print_help(argv[0]);
! exit(0);
! }
! }
! }
! locale = getenv("LANG");
! setlocale(LC_ALL, "");
#ifdef I18N
if (getenv("NLSPATH"))
bindtextdomain("WPrefs", getenv("NLSPATH"));
else
--- 20,107 ----
*/
#include "WPrefs.h"
#include <X11/Xlocale.h>
+ #include <getopt.h>
+ extern void Initialize( WMScreen * scr );
static void
! print_usage( char * progname )
{
! printf( _( "usage: %s [options]\n"), progname );
! puts( _( "options:") );
! puts( _( "-d --display <display> \t\t display to be used" ) );
! puts( _( "-v --version \t\t\t print version number and exit" ) );
! puts( _( "-h --help \t\t\t print this message and exit" ) );
}
! static void
! handle_user_arguments( int argc, char ** argv, char * display_name )
{
! opterr = 0;
! char * optstring = "vd:h";
! static struct option long_options[] = {
! {"version", 0, 0, 'v'},
! {"display", 1, 0, 'd'},
! {"help", 1, 0, 'h'},
! {0, 0, 0, 0}
! };
!
! while( 1 ) {
! int c = getopt_long( argc, argv, optstring, long_options, 0 );
! if( c == -1 )
! break;
!
! switch( c ) {
! case 'v':
! printf( "WPrefs (Window Maker) %s\n" VERSION );
! exit(0);
! case 'd':
! printf( "display is %s", optarg );
! display_name = optarg;
break;
+ case '?':
+ case 'h':
+ print_usage( argv[0] );
+ exit(1);
}
}
! }
int
main(int argc, char **argv)
{
! char * display_name="";
! handle_user_arguments( argc, argv, display_name );
! WMInitializeApplication("WPrefs", &argc, argv);
! WMSetResourcePath( RESOURCE_PATH );
! char * path = WMPathForResourceOfType( "WPrefs.tiff", NULL );
! if( !path ){
/* maybe it is run directly from the source directory */
WMSetResourcePath(".");
! path = WMPathForResourceOfType( "WPrefs.tiff", NULL );
}
! if( path )
! wfree( path );
! else
! WMSetResourcePath( ".." );
!
! setlocale( LC_ALL, "" );
#ifdef I18N
+
+ char * locale = getenv("LANG");
+
if (getenv("NLSPATH"))
bindtextdomain("WPrefs", getenv("NLSPATH"));
else
***************
*** 163,177 ****
}
#endif
! dpy = XOpenDisplay(display_name);
if (!dpy) {
wfatal(_("could not open display %s"), XDisplayName(display_name));
exit(0);
}
! #if 0
! XSynchronize(dpy, 1);
! #endif
! scr = WMCreateScreen(dpy, DefaultScreen(dpy));
if (!scr) {
wfatal(_("could not initialize application"));
exit(0);
--- 117,131 ----
}
#endif
! Display * dpy = XOpenDisplay( display_name );
!
if (!dpy) {
wfatal(_("could not open display %s"), XDisplayName(display_name));
exit(0);
}
!
! WMScreen * scr = WMCreateScreen(dpy, DefaultScreen(dpy));
!
if (!scr) {
wfatal(_("could not initialize application"));
exit(0);
***************
*** 185,202 ****
XEvent event;
WMNextEvent(dpy, &event);
-
- while (DeadChildrenCount-- > 0) {
- int i;
-
- for (i=0; i<MAX_DEATHS; i++) {
- if (DeadChildren[i] == DeadHandlers[i].pid) {
- (*DeadHandlers[i].handler)(DeadHandlers[i].data);
- DeadHandlers[i].pid = 0;
- }
- }
- }
-
WMHandleEvent(&event);
}
}
--- 139,144 ----
diff -crB ./Themes.c ../../WPrefs.app/Themes.c
*** ./Themes.c 2008-12-13 22:57:40.000000000 +0100
--- ../../WPrefs.app/Themes.c 2009-11-20 19:03:42.570252536 +0100
***************
*** 20,25 ****
--- 20,26 ----
* USA.
*/
+ #if 0
#include "WPrefs.h"
***************
*** 259,261 ****
--- 260,263 ----
return panel;
}
+ #endif