Пример #1
0
/*
 * Read the user preferences from xdvirc_filename and merge them into the
 * current resource database *and* into m_user_db so that all of them are
 * saved again when xdvi exits.
 */
void
read_user_preferences(Widget toplevel, const char *filename)
{
    char *fullpath;
    XrmDatabase db;
#if XtSpecificationRelease == 4
    XrmDatabase file_db;
#endif

    fullpath = get_xdvirc_path(filename);
    TRACE_GUI((stderr, "Reading resources from `%s'", fullpath));
    db = XtDatabase(XtDisplay(toplevel));
    
#if XtSpecificationRelease == 4
    file_db  = XrmGetFileDatabase(fullpath);
    XrmMergeDatabases(file_db, &db);
    XrmMergeDatabases(file_db, &m_user_db);
#else /* Xt >= X11R5 */
    XrmCombineFileDatabase(fullpath, &db, True);
    XrmCombineFileDatabase(fullpath, &m_user_db, True);
#endif
    free(fullpath);
}
Пример #2
0
static void CombineUserDefaults(
    Display *dpy,
    XrmDatabase *pdb)
{
    char *slashDotXdefaults = "/.Xdefaults";
    char *dpy_defaults = XResourceManagerString(dpy);

    if (dpy_defaults) {
	XrmCombineDatabase(XrmGetStringDatabase(dpy_defaults), pdb, False);
    } else {
	char filename[PATH_MAX];
	(void) GetRootDirName(filename,
			PATH_MAX - strlen (slashDotXdefaults) - 1);
	(void) strcat(filename, slashDotXdefaults);
	(void)XrmCombineFileDatabase(filename, pdb, False);
    }
}
Пример #3
0
static XrmDatabase
get_database( void)
{
	XrmDatabase db = XrmGetStringDatabase( "");
	char filename[PATH_MAX];
	char *c;
	char *resource_data = XResourceManagerString( DISP);
	if ( resource_data) {
		XrmCombineDatabase( XrmGetStringDatabase( resource_data), &db, false);
	} else {
		c = getenv( "HOME");
		if (!c) c = "";
		snprintf( filename, PATH_MAX, "%s/.Xdefaults", c);
		XrmCombineFileDatabase( filename, &db, false);
	}
	return db;
}
Пример #4
0
static void CombineAppUserDefaults(
    Display *dpy,
    XrmDatabase *pdb)
{
    char* filename;
    char* path;
    Boolean deallocate = False;

    if (!(path = getenv("XUSERFILESEARCHPATH"))) {
	char *old_path;
	char homedir[PATH_MAX];
	GetRootDirName(homedir, PATH_MAX);
	if (!(old_path = getenv("XAPPLRESDIR"))) {
	    char *path_default = "%s/%%L/%%N%%C:%s/%%l/%%N%%C:%s/%%N%%C:%s/%%L/%%N:%s/%%l/%%N:%s/%%N";
	    if (!(path =
		  ALLOCATE_LOCAL(6*strlen(homedir) + strlen(path_default))))
		_XtAllocError(NULL);
	    sprintf( path, path_default,
		    homedir, homedir, homedir, homedir, homedir, homedir );
	} else {
	    char *path_default = "%s/%%L/%%N%%C:%s/%%l/%%N%%C:%s/%%N%%C:%s/%%N%%C:%s/%%L/%%N:%s/%%l/%%N:%s/%%N:%s/%%N";
	    if (!(path =
		  ALLOCATE_LOCAL( 6*strlen(old_path) + 2*strlen(homedir)
				 + strlen(path_default))))
		_XtAllocError(NULL);
	    sprintf(path, path_default, old_path, old_path, old_path, homedir,
		    old_path, old_path, old_path, homedir );
	}
	deallocate = True;
    }

    filename = XtResolvePathname(dpy, NULL, NULL, NULL, path, NULL, 0, NULL);
    if (filename) {
	(void)XrmCombineFileDatabase(filename, pdb, False);
	XtFree(filename);
    }

    if (deallocate) DEALLOCATE_LOCAL(path);
}
Пример #5
0
static void restore_state(
Widget		w,
XtPointer	client_data,
XtPointer	call_data)
{
    Widget		topl = (Widget) client_data;
    XmFileSelectionBoxCallbackStruct
	*cbs = (XmFileSelectionBoxCallbackStruct *) call_data;
    FILE		*fp;
    String		filestr;
    XrmDatabase 	database;
    SaveRestoreList	*svl=save_list;

    /* get the resource file name */
    if( (fp = HGU_XmGetFilePointer( w, cbs->value, cbs->dir, "r" )) == NULL )
	return;

    /* merge the file database with the application database */
    if( (filestr = HGU_XmGetFileStr( w, cbs->value, cbs->dir )) ){
	database = XtDatabase(XtDisplay(topl));
	XrmCombineFileDatabase(filestr, &database, True);
	XtFree( filestr );
    }

    /* read and set resources */
    restore_state_from_file( topl, fp );

    /* call registered restore_state procedures */
    while( svl != NULL ){

	if( svl->restore_func != NULL )
	    (*svl->restore_func)( svl->widget, svl->restore_data, fp );

	svl = svl->next_data;
    }
	    
    fclose( fp );
    return;
}
Пример #6
0
static void CombineAppUserDefaults(
    Display *dpy,
    XrmDatabase *pdb)
{
    char* filename;
    char* path = NULL;
    Boolean deallocate = False;

    if (!(path = getenv("XUSERFILESEARCHPATH"))) {
#if !defined(WIN32) || !defined(__MINGW32__)
	char *old_path;
	char homedir[PATH_MAX];
	GetRootDirName(homedir, PATH_MAX);
	if (!(old_path = getenv("XAPPLRESDIR"))) {
	    XtAsprintf(&path,
		       "%s/%%L/%%N%%C:%s/%%l/%%N%%C:%s/%%N%%C:%s/%%L/%%N:%s/%%l/%%N:%s/%%N",
		       homedir, homedir, homedir, homedir, homedir, homedir);
	} else {
	    XtAsprintf(&path,
		       "%s/%%L/%%N%%C:%s/%%l/%%N%%C:%s/%%N%%C:%s/%%N%%C:%s/%%L/%%N:%s/%%l/%%N:%s/%%N:%s/%%N",
		       old_path, old_path, old_path, homedir,
		       old_path, old_path, old_path, homedir);
	}
	deallocate = True;
#endif
    }

    filename = XtResolvePathname(dpy, NULL, NULL, NULL, path, NULL, 0, NULL);
    if (filename) {
	(void)XrmCombineFileDatabase(filename, pdb, False);
	XtFree(filename);
    }

    if (deallocate)
	XtFree(path);
}
Пример #7
0
Memimage*
_xattach(char *label, char *winsize)
{
	char *argv[2], *disp;
	int i, havemin, height, mask, n, width, x, xrootid, y;
	Rectangle r;
	XClassHint classhint;
	XDrawable pmid;
	XPixmapFormatValues *pfmt;
	XScreen *xscreen;
	XSetWindowAttributes attr;
	XSizeHints normalhint;
	XTextProperty name;
	XVisualInfo xvi;
	XWindow xrootwin;
	XWindowAttributes wattr;
	XWMHints hint;
	Atom atoms[2];

	/*
	if(XInitThreads() == 0){
		fprint(2, "XInitThreads failed\n");
		abort();
	}
	*/

	/*
	 * Connect to X server.
	 */
	_x.display = XOpenDisplay(NULL);
	if(_x.display == nil){
		disp = getenv("DISPLAY");
		werrstr("XOpenDisplay %s: %r", disp ? disp : ":0");
		free(disp);
		return nil;
	}
	_x.fd = ConnectionNumber(_x.display);
	XSetErrorHandler(xerror);
	XSetIOErrorHandler(xioerror);
	xrootid = DefaultScreen(_x.display);
	xrootwin = DefaultRootWindow(_x.display);

	/* 
	 * Figure out underlying screen format.
	 */
	if(XMatchVisualInfo(_x.display, xrootid, 24, TrueColor, &xvi)
	|| XMatchVisualInfo(_x.display, xrootid, 24, DirectColor, &xvi)){
		_x.vis = xvi.visual;
		_x.depth = 24;
	}
	else
	if(XMatchVisualInfo(_x.display, xrootid, 16, TrueColor, &xvi)
	|| XMatchVisualInfo(_x.display, xrootid, 16, DirectColor, &xvi)){
		_x.vis = xvi.visual;
		_x.depth = 16;
	}
	else
	if(XMatchVisualInfo(_x.display, xrootid, 15, TrueColor, &xvi)
	|| XMatchVisualInfo(_x.display, xrootid, 15, DirectColor, &xvi)){
		_x.vis = xvi.visual;
		_x.depth = 15;
	}
	else
	if(XMatchVisualInfo(_x.display, xrootid, 8, PseudoColor, &xvi)
	|| XMatchVisualInfo(_x.display, xrootid, 8, StaticColor, &xvi)){
		if(_x.depth > 8){
			werrstr("can't deal with colormapped depth %d screens",
				_x.depth);
			goto err0;
		}
		_x.vis = xvi.visual;
		_x.depth = 8;
	}
	else{
		_x.depth = DefaultDepth(_x.display, xrootid);
		if(_x.depth != 8){
			werrstr("can't understand depth %d screen", _x.depth);
			goto err0;
		}
		_x.vis = DefaultVisual(_x.display, xrootid);
	}

	if(DefaultDepth(_x.display, xrootid) == _x.depth)
		_x.usetable = 1;

	/*
	 * _x.depth is only the number of significant pixel bits,
	 * not the total number of pixel bits.  We need to walk the
	 * display list to find how many actual bits are used
	 * per pixel.
	 */
	_x.chan = 0;
	pfmt = XListPixmapFormats(_x.display, &n);
	for(i=0; i<n; i++){
		if(pfmt[i].depth == _x.depth){
			switch(pfmt[i].bits_per_pixel){
			case 1:	/* untested */
				_x.chan = GREY1;
				break;
			case 2:	/* untested */
				_x.chan = GREY2;
				break;
			case 4:	/* untested */
				_x.chan = GREY4;
				break;
			case 8:
				_x.chan = CMAP8;
				break;
			case 15:
				_x.chan = RGB15;
				break;
			case 16: /* how to tell RGB15? */
				_x.chan = RGB16;
				break;
			case 24: /* untested (impossible?) */
				_x.chan = RGB24;
				break;
			case 32:
				_x.chan = XRGB32;
				break;
			}
		}
	}
	if(_x.chan == 0){
		werrstr("could not determine screen pixel format");
		goto err0;
	}

	/*
	 * Set up color map if necessary.
	 */
	xscreen = DefaultScreenOfDisplay(_x.display);
	_x.cmap = DefaultColormapOfScreen(xscreen);
	if(_x.vis->class != StaticColor){
		plan9cmap();
		setupcmap(xrootwin);
	}

	/*
	 * We get to choose the initial rectangle size.
	 * This is arbitrary.  In theory we should read the
	 * command line and allow the traditional X options.
	 */
	mask = 0;
	x = 0;
	y = 0;
	if(winsize && winsize[0]){
		if(parsewinsize(winsize, &r, &havemin) < 0)
			sysfatal("%r");
	}else{
		/*
		 * Parse the various X resources.  Thanks to Peter Canning.
		 */
		char *screen_resources, *display_resources, *geom, 
			*geomrestype, *home, *file;
		XrmDatabase database;
		XrmValue geomres;

		database = XrmGetDatabase(_x.display);
		screen_resources = XScreenResourceString(xscreen);
		if(screen_resources != nil){
			XrmCombineDatabase(XrmGetStringDatabase(screen_resources), &database, False);
			XFree(screen_resources);
		}

		display_resources = XResourceManagerString(_x.display);
		if(display_resources == nil){
			home = getenv("HOME");
			if(home!=nil && (file=smprint("%s/.Xdefaults", home)) != nil){
				XrmCombineFileDatabase(file, &database, False);
				free(file);
			}
			free(home);
		}else
			XrmCombineDatabase(XrmGetStringDatabase(display_resources), &database, False);

		geom = smprint("%s.geometry", label);
		if(geom && XrmGetResource(database, geom, nil, &geomrestype, &geomres))
			mask = XParseGeometry(geomres.addr, &x, &y, (uint*)&width, (uint*)&height);
		free(geom);

		if((mask & WidthValue) && (mask & HeightValue)){
			r = Rect(0, 0, width, height);
		}else{
			r = Rect(0, 0, WidthOfScreen(xscreen)*3/4,
					HeightOfScreen(xscreen)*3/4);
			if(Dx(r) > Dy(r)*3/2)
				r.max.x = r.min.x + Dy(r)*3/2;
			if(Dy(r) > Dx(r)*3/2)
				r.max.y = r.min.y + Dx(r)*3/2;
		}
		if(mask & XNegative){
			x += WidthOfScreen(xscreen);
		}
		if(mask & YNegative){
			y += HeightOfScreen(xscreen);
		}
		havemin = 0;
	}
	screenrect = Rect(0, 0, WidthOfScreen(xscreen), HeightOfScreen(xscreen));
	windowrect = r;

	memset(&attr, 0, sizeof attr);
	attr.colormap = _x.cmap;
	attr.background_pixel = ~0;
	attr.border_pixel = 0;
	_x.drawable = XCreateWindow(
		_x.display,	/* display */
		xrootwin,	/* parent */
		x,		/* x */
		y,		/* y */
		Dx(r),		/* width */
	 	Dy(r),		/* height */
		0,		/* border width */
		_x.depth,	/* depth */
		InputOutput,	/* class */
		_x.vis,		/* visual */
				/* valuemask */
		CWBackPixel|CWBorderPixel|CWColormap,
		&attr		/* attributes (the above aren't?!) */
	);

	/*
	 * Label and other properties required by ICCCCM.
	 */
	memset(&name, 0, sizeof name);
	if(label == nil)
		label = "pjw-face-here";
	name.value = (uchar*)label;
	name.encoding = XA_STRING;
	name.format = 8;
	name.nitems = strlen((char*)name.value);

	memset(&normalhint, 0, sizeof normalhint);
	normalhint.flags = PSize|PMaxSize;
	if(winsize && winsize[0]){
		normalhint.flags &= ~PSize;
		normalhint.flags |= USSize;
		normalhint.width = Dx(r);
		normalhint.height = Dy(r);
	}else{
		if((mask & WidthValue) && (mask & HeightValue)){
			normalhint.flags &= ~PSize;
			normalhint.flags |= USSize;
			normalhint.width = width;
			normalhint.height = height;
		}
		if((mask & WidthValue) && (mask & HeightValue)){
			normalhint.flags |= USPosition;
			normalhint.x = x;
			normalhint.y = y;
		}
	}

	normalhint.max_width = WidthOfScreen(xscreen);
	normalhint.max_height = HeightOfScreen(xscreen);

	memset(&hint, 0, sizeof hint);
	hint.flags = InputHint|StateHint;
	hint.input = 1;
	hint.initial_state = NormalState;

	memset(&classhint, 0, sizeof classhint);
	classhint.res_name = label;
	classhint.res_class = label;

	argv[0] = label;
	argv[1] = nil;

	XSetWMProperties(
		_x.display,	/* display */
		_x.drawable,	/* window */
		&name,		/* XA_WM_NAME property */
		&name,		/* XA_WM_ICON_NAME property */
		argv,		/* XA_WM_COMMAND */
		1,		/* argc */
		&normalhint,	/* XA_WM_NORMAL_HINTS */
		&hint,		/* XA_WM_HINTS */
		&classhint	/* XA_WM_CLASSHINTS */
	);
	XFlush(_x.display);

	if(havemin){
		XWindowChanges ch;

		memset(&ch, 0, sizeof ch);
		ch.x = r.min.x;
		ch.y = r.min.y;
		XConfigureWindow(_x.display, _x.drawable, CWX|CWY, &ch);
		/*
		 * Must pretend origin is 0,0 for X.
		 */
		r = Rect(0,0,Dx(r),Dy(r));
	}
	/*
	 * Look up clipboard atom.
	 */
	_x.clipboard = XInternAtom(_x.display, "CLIPBOARD", False);
	_x.utf8string = XInternAtom(_x.display, "UTF8_STRING", False);
	_x.targets = XInternAtom(_x.display, "TARGETS", False);
	_x.text = XInternAtom(_x.display, "TEXT", False);
	_x.compoundtext = XInternAtom(_x.display, "COMPOUND_TEXT", False);
	_x.takefocus = XInternAtom(_x.display, "WM_TAKE_FOCUS", False);
	_x.losefocus = XInternAtom(_x.display, "_9WM_LOSE_FOCUS", False);
	_x.wmprotos = XInternAtom(_x.display, "WM_PROTOCOLS", False);

	atoms[0] = _x.takefocus;
	atoms[1] = _x.losefocus;
	XChangeProperty(_x.display, _x.drawable, _x.wmprotos, XA_ATOM, 32,
		PropModeReplace, (uchar*)atoms, 2);

	/*
	 * Put the window on the screen, check to see what size we actually got.
	 */
	XMapWindow(_x.display, _x.drawable);
	XSync(_x.display, False);

	if(!XGetWindowAttributes(_x.display, _x.drawable, &wattr))
		fprint(2, "XGetWindowAttributes failed\n");
	else if(wattr.width && wattr.height){
		if(wattr.width != Dx(r) || wattr.height != Dy(r)){
			r.max.x = wattr.width;
			r.max.y = wattr.height;
		}
	}else
		fprint(2, "XGetWindowAttributes: bad attrs\n");

	/*
	 * Allocate our local backing store.
	 */
	_x.screenr = r;
	_x.screenpm = XCreatePixmap(_x.display, _x.drawable, Dx(r), Dy(r), _x.depth);
	_x.nextscreenpm = _x.screenpm;
	_x.screenimage = _xallocmemimage(r, _x.chan, _x.screenpm);

	/*
	 * Allocate some useful graphics contexts for the future.
	 */
	_x.gcfill	= xgc(_x.screenpm, FillSolid, -1);
	_x.gccopy	= xgc(_x.screenpm, -1, -1);
	_x.gcsimplesrc 	= xgc(_x.screenpm, FillStippled, -1);
	_x.gczero	= xgc(_x.screenpm, -1, -1);
	_x.gcreplsrc	= xgc(_x.screenpm, FillTiled, -1);

	pmid = XCreatePixmap(_x.display, _x.drawable, 1, 1, 1);
	_x.gcfill0	= xgc(pmid, FillSolid, 0);
	_x.gccopy0	= xgc(pmid, -1, -1);
	_x.gcsimplesrc0	= xgc(pmid, FillStippled, -1);
	_x.gczero0	= xgc(pmid, -1, -1);
	_x.gcreplsrc0	= xgc(pmid, FillTiled, -1);
	XFreePixmap(_x.display, pmid);

	return _x.screenimage;

err0:
	/*
	 * Should do a better job of cleaning up here.
	 */
	XCloseDisplay(_x.display);
	return nil;
}
Пример #8
0
XrmDatabase XtScreenDatabase(
    Screen *screen)
{
    int scrno;
    Bool doing_def;
    XrmDatabase db, olddb;
    XtPerDisplay pd;
    Status do_fallback;
    char *scr_resources;
    Display *dpy = DisplayOfScreen(screen);
    DPY_TO_APPCON(dpy);

    LOCK_APP(app);
    LOCK_PROCESS;
    if (screen == DefaultScreenOfDisplay(dpy)) {
	scrno = DefaultScreen(dpy);
	doing_def = True;
    } else {
	scrno = XScreenNumberOfScreen(screen);
	doing_def = False;
    }
    pd = _XtGetPerDisplay(dpy);
    if ((db = pd->per_screen_db[scrno])) {
	UNLOCK_PROCESS;
	UNLOCK_APP(app);
	return (doing_def ? XrmGetDatabase(dpy) : db);
    }
    scr_resources = XScreenResourceString(screen);

    if (ScreenCount(dpy) == 1) {
	db = pd->cmd_db;
	pd->cmd_db = NULL;
    } else {
	db = CopyDB(pd->cmd_db);
    }
    {   /* Environment defaults */
	char	filenamebuf[PATH_MAX];
	char	*filename;

	if (!(filename = getenv("XENVIRONMENT"))) {
	    int len;
#ifdef __MINGW32__
	    const char *slashDotXdefaultsDash = "/Xdefaults-";
#else
	    const char *slashDotXdefaultsDash = "/.Xdefaults-";
#endif

	    (void) GetRootDirName(filename = filenamebuf,
			PATH_MAX - strlen (slashDotXdefaultsDash) - 1);
	    (void) strcat(filename, slashDotXdefaultsDash);
	    len = strlen(filename);
	    GetHostname (filename+len, PATH_MAX-len);
	}
	(void)XrmCombineFileDatabase(filename, &db, False);
    }
    if (scr_resources)
    {   /* Screen defaults */
	XrmCombineDatabase(XrmGetStringDatabase(scr_resources), &db, False);
	XFree(scr_resources);
    }
    /* Server or host defaults */
    if (!pd->server_db)
	CombineUserDefaults(dpy, &db);
    else {
	(void) XrmCombineDatabase(pd->server_db, &db, False);
	pd->server_db = NULL;
    }

    if (!db)
	db = XrmGetStringDatabase("");
    pd->per_screen_db[scrno] = db;
    olddb = XrmGetDatabase(dpy);
    /* set database now, for XtResolvePathname to use */
    XrmSetDatabase(dpy, db);
    CombineAppUserDefaults(dpy, &db);
    do_fallback = 1;
    {   /* System app-defaults */
	char	*filename;

	if ((filename = XtResolvePathname(dpy, "app-defaults",
					 NULL, NULL, NULL, NULL, 0, NULL))) {
	    do_fallback = !XrmCombineFileDatabase(filename, &db, False);
	    XtFree(filename);
	}
    }
    /* now restore old database, if need be */
    if (!doing_def)
	XrmSetDatabase(dpy, olddb);
    if (do_fallback && pd->appContext->fallback_resources)
    {   /* Fallback defaults */
        XrmDatabase fdb = NULL;
	String *res;

	for (res = pd->appContext->fallback_resources; *res; res++)
	    XrmPutLineResource(&fdb, *res);
	(void)XrmCombineDatabase(fdb, &db, False);
    }
    UNLOCK_PROCESS;
    UNLOCK_APP(app);
    return db;
}
Пример #9
0
/* save-restore initialisation procedure */
void HGU_XmSaveRestoreInit(
Widget	topl,
int	*argc,
char	**argv)
{
    XmString		xmstr;
    Visual		*visual;
    Arg			arg[1];
    static int		initialised=0;

    /* check initialisation */
    if( initialised )
	return;
    initialised = 1;

    /* check command line for -state option */
    if( *argc > 2 && argv != NULL ){
	int 	i;
	FILE	*fp;
	for(i=0; i < *argc; i++){
	    if( strcmp(argv[i], "-state") == 0 && i < (*argc-1) ){
		int	j;

		XrmDatabase database = XtDatabase(XtDisplay(topl));

		/* merge the file database with the application database */
		XrmCombineFileDatabase(argv[i+1], &database, True);

		/* set any topl widget resources */
		if( (fp = fopen(argv[i+1], "r")) != NULL ){
		    restore_state_from_file( topl, fp );
		    fclose( fp );
		} else {
		    fprintf(stderr,
			    "HGU_XmSaveRestoreInit: can't open file %s\n",
			    argv[i+1]);
		}

		/* remove the -state option from the list */
		for(j=i+2; j < *argc; j++)
		    argv[j-2] = argv[j];
		*argc -= 2;
		i--;
	    }
	}
    }


    /* default save procedure */
    default_save_func = default_save;
    default_save_data = XtName( topl );

    /* create save_state and restore_state file selection dialogs */
    /* get the visual explicitly */
    visual = HGU_XmWidgetToVisual( topl );
    XtSetArg(arg[0], XmNvisual, visual);
    if( argv == NULL )
	XtVaGetValues(topl, XtNargv, &argv, NULL);
    save_state_dialog =
	XmCreateFileSelectionDialog( topl, "save_state_dialog", arg, 1);
    sprintf(argv_0, "%s - save state", argv[0]);
    xmstr = XmStringCreateSimple( argv_0 );
    XtVaSetValues( save_state_dialog, XmNdialogTitle, xmstr, NULL );
    XmStringFree( xmstr );

    XtAddCallback(save_state_dialog, XmNcancelCallback, 
                  (void (*)()) XtUnmanageChild, NULL);
    XtAddCallback(save_state_dialog, XmNokCallback, 
                  (void (*)()) XtUnmanageChild, NULL);
    XtAddCallback(save_state_dialog, XmNokCallback, 
                  save_state, (XtPointer) topl);

    restore_state_dialog =
	XmCreateFileSelectionDialog( topl, "restore_state_dialog", arg, 1);
    sprintf(argv_0, "%s - restore state", argv[0]);
    xmstr = XmStringCreateSimple( argv_0 );
    XtVaSetValues( restore_state_dialog, XmNdialogTitle, xmstr, NULL );
    XmStringFree( xmstr );

    XtAddCallback(restore_state_dialog, XmNcancelCallback, 
                  (void (*)()) XtUnmanageChild, NULL);
    XtAddCallback(restore_state_dialog, XmNokCallback, 
                  (void (*)()) XtUnmanageChild, NULL);
    XtAddCallback(restore_state_dialog, XmNokCallback, 
                  restore_state, (XtPointer) topl);

    sprintf( argv_0, "%s", argv[0] );
    return;
}