[comp.windows.x] problem getting XmNdialogTitle

sohara@lamont.ldgo.columbia.edu (suzanne ohara) (12/12/90)

I am trying to get the XmNdialogTitle from a widget when the cancel
button in a dialog box(file selection box in particular) is pressed.
I wrote the routine that follows, but it only fetches the first time
a cancel is pressed and on additional calls it fails. Could anyone
suggest where my problem is, or if I am approaching this wrong.
Thankyou, Suzanne


 .... this is a piece of the total code

cancel_proc(w,tag,reason)
Widget  w;
int     *tag;
caddr_t *reason;
{
        int             widget_num = *tag;
        char            text[120],
                        *ptr_text = NULL;

/*** get name of dialog ***/
        if(get_dialog_title(widget_num,&ptr_text) == TRUE)
        {
                (void)sprintf(text,"%s %s. (%s)",K_CANCEL_CHANGES_TEXT,ptr_text,
                                K_INOPERABLE_TEXT);
        /** write message to log display **/
                add_to_log_list(text);

        /** close displayed dialog **/
                if(XtIsManaged(widget_array[widget_num]))
                        XtUnmanageChild(widget_array[widget_num]);
        }
        if(ptr_text == NULL) XtFree(ptr_text);
}

Boolean
get_dialog_title(widget_id,text)
int     widget_id;
char    **text;
{
        XmString xmstring=NULL;

        get_something(widget_array[widget_id],XmNdialogTitle,&xmstring);
        if(XmStringEmpty(xmstring))
        {
                error_test(K_BAD_GET_DIALOG_TITLE_TEXT,FALSE);
                return(FALSE);
        }
        else
        {
                if(text != NULL)
                {
                        XtFree(*text);
                        *text= NULL;
                }
                if(XmStringGetLtoR(xmstring,XmSTRING_DEFAULT_CHARSET,text) != TR
UE)
                        error_test(K_BAD_CONVERT_DIALOG_TITLE_TEXT,TRUE);
        }
        return(TRUE);
}


void
get_something(w,resource,value)
Widget  w;
char    *resource;
caddr_t *value;
{
        Arg al[1];

        XtSetArg(al[0],resource,value);
        XtGetValues(w,al,1);
}