/*ARGSUSED*/ void GotoPage(Widget w, XEvent * event, String * params, Cardinal * num_params) { ManpageGlobals * man_globals; char error_buf[BUFSIZ]; Arg arglist[1]; Boolean sensitive; if (*num_params != 1) { XtAppWarning(XtWidgetToApplicationContext(w), "Xman - GotoPage: This action routine requires one argument."); return; } man_globals = GetGlobals(w); if (man_globals->both_shown) { ChangeLabel(man_globals->label, man_globals->section_name[man_globals->current_directory]); return; } switch (params[0][0]) { case 'M': case 'm': XtSetArg(arglist[0], XtNsensitive, &sensitive); XtGetValues(man_globals->manpage_entry, arglist, ONE); if (sensitive) { ChangeLabel(man_globals->label,man_globals->manpage_title); XtUnmanageChild(man_globals->manpagewidgets.directory); XtManageChild(man_globals->manpagewidgets.manpage); man_globals->dir_shown = FALSE; } break; case 'D': case 'd': ChangeLabel(man_globals->label, man_globals->section_name[man_globals->current_directory]); XtUnmanageChild(man_globals->manpagewidgets.manpage); XtManageChild(man_globals->manpagewidgets.directory); man_globals->dir_shown = TRUE; break; default: sprintf(error_buf,"%s %s", "Xman - GotoPage: Unknown argument must be", "either Manpage or Directory."); XtAppWarning(XtWidgetToApplicationContext(w), error_buf); return; } }
static void warning( Widget w, char * string) { char buf[100]; sprintf(buf, "SoXtGLArea: %s\n", string); XtAppWarning(XtWidgetToApplicationContext(w), buf); } // warning()
static void warning(Widget w,char* string) { char buf[100]; #ifdef __GLX_MOTIF sprintf (buf, "GLwMDraw: %s\n", string); #else sprintf (buf, "GLwDraw: %s\n", string); #endif XtAppWarning(XtWidgetToApplicationContext(w), buf); }
static void StartFormatPosition(void) { char *fmt = app_resources.position_format; if (fmt) while (*fmt) if (*fmt++ == '%') { int len = 0; if (*fmt == '-') { ++fmt; ++len; } while (*fmt >= '0' && *fmt <= '9') { ++fmt; if (++len >= MAX_FMT_LEN) { XtAppWarning(XtWidgetToApplicationContext(topwindow), "Format too large to formatPosition"); position_format_mask = 0; return; } } switch (*fmt++) { case 'l': position_format_mask |= l_BIT; break; case 'c': position_format_mask |= c_BIT; break; case 'p': position_format_mask |= p_BIT; break; case 's': position_format_mask |= s_BIT; break; case '%': break; default: { char msg[256]; XmuSnprintf(msg, sizeof(msg), "Unknown format \"%%%c\" in positionFormat", fmt[-1]); XtAppWarning(XtWidgetToApplicationContext(topwindow), msg); position_format_mask = 0; return; } } } }
/* * Function: * XawAsciiSrcSetValues * * Parameters: * current - current state of the widget * request - what was requested * cnew - what the widget will become * args - representation of changed resources * num_args - number of resources that have changed * * Description: * Sets the values for the AsciiSource. * * Returns: * True if redisplay is needed */ static Boolean XawAsciiSrcSetValues(Widget current, Widget request, Widget cnew, ArgList args, Cardinal *num_args) { AsciiSrcObject src = (AsciiSrcObject)cnew; AsciiSrcObject old_src = (AsciiSrcObject)current; Bool total_reset = False, string_set = False; FILE *file; unsigned int i; if (old_src->ascii_src.use_string_in_place != src->ascii_src.use_string_in_place) { XtAppWarning(XtWidgetToApplicationContext(cnew), "AsciiSrc: The XtNuseStringInPlace resource may " "not be changed."); src->ascii_src.use_string_in_place = old_src->ascii_src.use_string_in_place; } for (i = 0; i < *num_args ; i++) if (streq(args[i].name, XtNstring)) { string_set = True; break; } if (string_set || (old_src->ascii_src.type != src->ascii_src.type)) { RemoveOldStringOrFile(old_src, string_set); /* remove old info */ file = InitStringOrFile(src, string_set); /* Init new info */ LoadPieces(src, file, NULL); /* load new info into internal buffers */ if (file != NULL) fclose(file); #ifndef OLDXAW for (i = 0; i < src->text_src.num_text; i++) /* Tell text widget what happened */ XawTextSetSource(src->text_src.text[i], cnew, 0); #else XawTextSetSource(XtParent(cnew), cnew, 0); #endif total_reset = True; } if (old_src->ascii_src.ascii_length != src->ascii_src.ascii_length) src->ascii_src.piece_size = src->ascii_src.ascii_length + 1; if (!total_reset && old_src->ascii_src.piece_size != src->ascii_src.piece_size) { String string = StorePiecesInString(old_src); FreeAllPieces(old_src); LoadPieces(src, NULL, string); XtFree(string); } return (False); }
static void XawListResize(Widget w) { Dimension width, height; width = XtWidth(w); height = XtHeight(w); if (Layout(w, False, False, &width, &height)) XtAppWarning(XtWidgetToApplicationContext(w), "List Widget: Size changed when it shouldn't " "have when resising."); }
/*ARGSUSED*/ Boolean XmuCvtShapeStyleToString(Display *dpy, XrmValue *args, Cardinal *num_args, XrmValue *fromVal, XrmValue *toVal, XtPointer *data) { static char *buffer; Cardinal size; switch (*(int *)fromVal->addr) { case XmuShapeRectangle: buffer = XtERectangle; break; case XmuShapeOval: buffer = XtEOval; break; case XmuShapeEllipse: buffer = XtEEllipse; break; case XmuShapeRoundedRectangle: buffer = XtERoundedRectangle; break; default: XtAppWarning(XtDisplayToApplicationContext(dpy), "Cannot convert ShapeStyle to String"); toVal->addr = NULL; toVal->size = 0; return (False); } size = strlen(buffer) + 1; if (toVal->addr != NULL) { if (toVal->size <= size) { toVal->size = size; return (False); } strcpy((char *)toVal->addr, buffer); } else toVal->addr = (XPointer)buffer; toVal->size = size; return (True); }
/*ARGSUSED*/ Boolean XmuCvtGravityToString(Display *dpy, XrmValue *args, Cardinal *num_args, XrmValue *fromVal, XrmValue *toVal, XtPointer *data) { static const char *buffer; Cardinal size; struct _namepair *np; XtGravity gravity; gravity = *(XtGravity *)fromVal->addr; buffer = NULL; for (np = names; np->name; np++) if (np->gravity == gravity) { buffer = np->name; break; } if (!buffer) { XtAppWarning(XtDisplayToApplicationContext(dpy), "Cannot convert Gravity to String"); toVal->addr = NULL; toVal->size = 0; return (False); } size = strlen(buffer) + 1; if (toVal->addr != NULL) { if (toVal->size <= size) { toVal->size = size; return (False); } strcpy((char *)toVal->addr, buffer); } else toVal->addr = (XPointer)buffer; toVal->size = size; return (True); }
void XmLWarning(Widget w, char *msg) { XtAppContext app; char s[512], *cname, *name; WidgetClass c; app = XtWidgetToApplicationContext(w); name = XtName(w); if (!name) name = "[No Name]"; c = XtClass(w); cname = c->core_class.class_name; if (!cname) cname = "[No Class]"; sprintf(s, "%s: %s: %s\n", cname, name, msg); XtAppWarning(app, s); }
static void OpenIM(XawVendorShellExtPart *ve) { int i; char *p, *s, *ns, *end, *pbuf, buf[32]; XIM xim = NULL; XIMStyles *xim_styles; XIMStyle input_style = 0; Boolean found; if (ve->im.open_im == False) return; ve->im.xim = NULL; if (ve->im.input_method == NULL) { if ((p = XSetLocaleModifiers("@im=none")) != NULL && *p) xim = XOpenIM(XtDisplay(ve->parent), NULL, NULL, NULL); } else { /* no fragment can be longer than the whole string */ Cardinal len = strlen (ve->im.input_method) + 5; if (len < sizeof buf) pbuf = buf; else pbuf = XtMalloc (len); if (pbuf == NULL) return; for(ns=s=ve->im.input_method; ns && *s;) { /* skip any leading blanks */ while (*s && isspace(*s)) s++; if (!*s) break; if ((ns = end = strchr(s, ',')) == NULL) end = s + strlen(s); /* If there is a spurious comma end can be the same as s */ if (end > s) { /* strip any trailing blanks */ while (isspace(*(end - 1))) end--; strcpy (pbuf, "@im="); strncat (pbuf, s, end - s); pbuf[end - s + 4] = '\0'; } if ((p = XSetLocaleModifiers(pbuf)) != NULL && *p && (xim = XOpenIM(XtDisplay(ve->parent), NULL, NULL, NULL)) != NULL) break; s = ns + 1; } if (pbuf != buf) XtFree (pbuf); } if (xim == NULL) { if ((p = XSetLocaleModifiers("")) != NULL) { xim = XOpenIM(XtDisplay(ve->parent), NULL, NULL, NULL); } } if (xim == NULL) { XtAppWarning(XtWidgetToApplicationContext(ve->parent), "Input Method Open Failed"); return; } if (XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL) || !xim_styles) { XtAppWarning(XtWidgetToApplicationContext(ve->parent), "input method doesn't support any style"); XCloseIM(xim); return; } found = False; for(ns = s = ve->im.preedit_type; s && !found;) { while (*s && isspace(*s)) s++; if (!*s) break; if ((ns = end = strchr(s, ',')) == NULL) end = s + strlen(s); else ns++; if (end > s) while (isspace(*(end - 1))) end--; if (!strncmp(s, "OverTheSpot", end - s)) { input_style = (XIMPreeditPosition | XIMStatusArea); } else if (!strncmp(s, "OffTheSpot", end - s)) { input_style = (XIMPreeditArea | XIMStatusArea); } else if (!strncmp(s, "Root", end - s)) { input_style = (XIMPreeditNothing | XIMStatusNothing); } for (i = 0; (unsigned short)i < xim_styles->count_styles; i++) if (input_style == xim_styles->supported_styles[i]) { ve->ic.input_style = input_style; SetErrCnxt(ve->parent, xim); ve->im.xim = xim; found = True; break; } s = ns; } XFree(xim_styles); if (!found) { XCloseIM(xim); XtAppWarning(XtWidgetToApplicationContext(ve->parent), "input method doesn't support my input style"); } }
/*ARGSUSED*/ void Search(Widget w, XEvent * event, String * params, Cardinal * num_params) { ManpageGlobals * man_globals = GetGlobals(w); FILE * file = NULL; XtPopdown( XtParent(XtParent(w)) ); /* popdown the search widget */ if ( (*num_params < 1) || (*num_params > 2) ) { XtAppWarning(XtWidgetToApplicationContext(w), "Xman - Search: This action routine requires one or two arguments."); return; } switch(params[0][0]) { case 'a': case 'A': file = DoSearch(man_globals,APROPOS); break; case 'm': case 'M': file = DoSearch(man_globals,MANUAL); break; case 'c': case 'C': file = NULL; break; default: XtAppWarning(XtWidgetToApplicationContext(w), "Xman - Search: First parameter unknown."); file = NULL; break; } if ( *num_params == 2 ) switch (params[1][0]) { case 'O': case 'o': if (file != NULL) { Widget w; char * label; w = CreateManpage(file); man_pages_shown++; /* Put title into new manual page. */ label = man_globals->manpage_title; man_globals = GetGlobals(w); strcpy(man_globals->manpage_title, label); ChangeLabel(man_globals->label, label); } break; default: XtAppWarning(XtWidgetToApplicationContext(w), "Xman - Search: Second parameter unknown."); break; } else { PutUpManpage(man_globals, file); } if (file != NULL) fclose(file); }
/*ARGSUSED*/ void SaveFormattedPage(Widget w, XEvent * event, String * params, Cardinal * num_params) { ManpageGlobals * man_globals; char cmdbuf[BUFSIZ], error_buf[BUFSIZ]; if (*num_params != 1) { XtAppWarning(XtWidgetToApplicationContext(w), "Xman - SaveFormattedPage: This action routine requires one argument."); return; } man_globals = GetGlobals(w); /* * If we are not active then take no action. */ if (man_globals->tempfile == '\0') return; switch (params[0][0]) { case 'S': case 's': #ifndef NO_COMPRESS if (!man_globals->compress) #endif sprintf(cmdbuf, "%s %s %s", COPY, man_globals->tempfile, man_globals->save_file); #ifndef NO_COMPRESS else if (man_globals->gzip) sprintf(cmdbuf, "%s < %s > %s", GZIP_COMPRESS, man_globals->tempfile, man_globals->save_file); else sprintf(cmdbuf, "%s < %s > %s", COMPRESS, man_globals->tempfile, man_globals->save_file); #endif if(! system(cmdbuf)) { /* make sure the formatted man page is fully accessible by the world */ if (chmod(man_globals->save_file, CHMOD_MODE) != 0) { sprintf(error_buf, "Couldn't set permissions on formatted man page '%s'.\n", man_globals->save_file); PopupWarning( man_globals, error_buf); } } else { sprintf(error_buf, "Error while executing the command '%s'.\n", cmdbuf); PopupWarning( man_globals, error_buf); } break; case 'C': case 'c': break; default: sprintf(error_buf,"%s %s", "Xman - SaveFormattedPagee:", "Unknown argument must be either 'Save' or 'Cancel'."); PopupWarning(man_globals, error_buf); return; } /* * We do not need the filename anymore, and have the fd open. * We will unlink it. */ unlink(man_globals->tempfile); XtPopdown( XtParent(XtParent(w)) ); }