void main( int argc, char **argv ) { Display *display; int result; #ifdef USERHELP malloc_check(1); malloc_trace(0); #endif XtAppContext app; /* Initialize the toolkit and open the display */ XtToolkitInitialize(); app = XtCreateApplicationContext(); display = XtOpenDisplay(app, NULL, argv[0], "Customize", NULL, 0, &argc, argv); /* Go register the DT error handler */ XeProgName = argv[0]; result = InitializeDtcolor(display, DEFAULT_SESSION); if(result != 0) exit(0); XtAppMainLoop(app); }
void Application::initialize(std::string name, int argc, char* argv[]) { String fallbacks[fallbackResources.size() + 1]; XtToolkitInitialize(); context = XtCreateApplicationContext(); for(unsigned int resourceIndex = 0; resourceIndex < fallbackResources.size(); resourceIndex++) { fallbacks[resourceIndex] = (char*)fallbackResources.at(resourceIndex).c_str(); } fallbacks[fallbackResources.size()] = NULL; XtAppSetFallbackResources(context, fallbacks); Application::name = name; display = XtOpenDisplay(context, NULL, name.c_str(), name.c_str(), NULL, 0, &argc, argv); if(display == NULL) { throw MotifException("Failed to open display"); } initialized = true; widget = XtAppCreateShell(Application::getName().c_str(), Application::getName().c_str(), applicationShellWidgetClass, Application::getDisplay(), NULL, 0); }
void main (int argc, char **argv) { XtAppContext context; Display *display; /* ** Initialize toolkit and open display. */ XtToolkitInitialize (); context = XtCreateApplicationContext(); /* ** Keep the same application name, so I don't have to muck around the ** Xdefaults file */ display = XtOpenDisplay (context, NULL, "phase", "Space", NULL, 0, &argc, argv); if (!display) { XtWarning("Space: Can't open display"); exit(0); } /* ** Create an event display panel */ DisplayEventFileSp(display, exit); /* ** Process events. */ XtAppMainLoop (context); }
int main (int argc, char *argv[]) { XtSetLanguageProc ( (XtAppContext) NULL, (XtLanguageProc) NULL, (XtPointer) NULL ); XtToolkitInitialize (); app_context = XtCreateApplicationContext (); display = XtOpenDisplay (app_context, NULL, argv[0], "XApplication", NULL, 0, &argc, argv); if (!display) { printf("%s: can't open display, exiting...\n", argv[0]); exit (-1); } create_shell ( display, argv[0], argc, argv ); XtRealizeWidget (shell); /* Note: the following values are the result of * querying the current geometry. */ { static XtWidgetGeometry Expected[] = { CWWidth | CWHeight , 361, 266, 74, 400, 0,0,0, /* form */ CWWidth | CWHeight | CWX | CWY, 0, 0, 74, 260, 0,0,0, /* list1SW */ CWWidth | CWHeight | CWX | CWY, 0, 0, 74, 260, 0,0,0, /* list1 */ CWWidth | CWHeight | CWX | CWY, 0, 260, 74, 140, 0,0,0, /* da */ }; /* toplevel should be replaced with to correct applicationShell */ PrintDetails(shell, Expected); } LessTifTestMainLoop(shell); exit (0); }
bool wxSetDisplay(const wxString& display_name) { gs_displayName = display_name; if ( display_name.empty() ) { gs_currentDisplay = NULL; return true; } else { Cardinal argc = 0; Display *display = XtOpenDisplay((XtAppContext) wxTheApp->GetAppContext(), display_name.c_str(), wxTheApp->GetAppName().c_str(), wxTheApp->GetClassName().c_str(), NULL, #if XtSpecificationRelease < 5 0, &argc, #else 0, (int *)&argc, #endif NULL); if (display) { gs_currentDisplay = (WXDisplay*) display; return true; } else return false; } }
void motif_init(QSP_ARG_DECL const char *progname) { const char *argv[1]; int argc=1; argv[0]=progname; the_dname = check_display(SINGLE_QSP_ARG); /* * initialize the Xt toolkit and create an application context * and shell */ XtSetLanguageProc ( (XtAppContext) NULL, (XtLanguageProc) NULL, (XtPointer) NULL ); XtToolkitInitialize (); globalAppContext = XtCreateApplicationContext (); display = XtOpenDisplay (globalAppContext, the_dname, argv[0],"guimenu", NULL, 0, &argc, (char **)argv); if (!display) { fprintf(stderr, "can't open display\n"); return; } add_event_func(QSP_ARG motif_dispatch); // This is not really a motif-specific thing, // but we do this here because nav_panel_itp is // static to this file... if( nav_panel_itp == NO_ITEM_TYPE ){ init_nav_panels(SINGLE_QSP_ARG); add_genwin(QSP_ARG nav_panel_itp, &navp_genwin_funcs, NULL); } }
static void ChildPrintToFile(String display_name, XPContext pcontext, FILE *file, char *file_name, int pipe, String application_name, String application_class) { FileDescRec *file_desc; XtAppContext app_context; int argc = 0; String argv[] = { NULL }; Display *display; file_desc = (FileDescRec *) XtMalloc(sizeof(FileDescRec)); file_desc->file_name = XtNewString(file_name); file_desc->file = file; file_desc->pipe = pipe; app_context = XtCreateApplicationContext(); if ((display = XtOpenDisplay(app_context, display_name, application_name, application_class, NULL, 0, &argc, argv)) == NULL) { _exit(1); } XpGetDocumentData(display, pcontext, PrintToFileProc, FinishProc, (XPointer) file_desc); XtAppMainLoop(app_context); _exit(0); }
/************************************************************** * main: **************************************************************/ int main(int argc, char **argv) { XtAppContext app_context; Display * display; Widget top_level; char * aclass = "XmdDaInput"; char name[132]; char ** temp_argv = argv; (void) strncpy(name, base(argv[0]), 132); /* handle the '-name' option */ while (*temp_argv) { if (strcmp(*temp_argv, "-name") == 0) { (void) strncpy(name, *++temp_argv, 132); break; } temp_argv++; } /* Initialize the X Intrinsics */ XtToolkitInitialize(); /* Set up language environment */ XtSetLanguageProc(NULL, (XtLanguageProc)NULL, NULL); /* create application context */ app_context = XtCreateApplicationContext(); /* open up one display */ display = XtOpenDisplay(app_context, NULL, name, aclass, (XrmOptionDescRec *)NULL, 0, &argc, argv); if (!display) { (void) fprintf(stderr, "Unable to open display\n"); exit(0); } /* Create the user interface */ top_level = DaCreateGui(name, aclass, argc, argv, display); if (top_level == NULL) { (void) fprintf(stderr, "Unable to create user interface\n"); exit(1); } /* Realize and start event dispatching */ XtRealizeWidget(top_level); XtAppMainLoop(app_context); return 0; /* make compiler happy */ }
static void XInit(int *argc, char ***argv) { XtToolkitInitialize(); xi.context = XtCreateApplicationContext(); XtAppSetFallbackResources(xi.context, fallback_resources); xi.disp = XtOpenDisplay(xi.context, NULL, "NMovie", "NMovie", NULL, 0, argc, *argv); if (!xi.disp) ErrorExit(ERROR_BAD_PARM,"Unable to open display"); shmext = XShmQueryExtension(xi.disp); xi.screenno = DefaultScreen(xi.disp); }
int main(int argc, char *argv[]) { XtAppContext appc; Widget top, arrow, print, fsb; XPPrinterList plist; int nlist, i; Screen *pscreen; Window win; Arg al[10]; int ac; Display *pdpy; XPContext pctxt; top = XtVaAppInitialize(&appc, "drawingArea", NULL, 0, &argc, argv, fallback, NULL); arrow = XtVaCreateManagedWidget("Button1", xmArrowButtonWidgetClass, top, XmNarrowDirection, XmARROW_UP, NULL); XtRealizeWidget(top); pdpy = XtOpenDisplay(appc, /* Display String */ ":1", "print", "Print", NULL, 0, &argc, argv); if (!pdpy) { fprintf(stderr, "Cannot connect to :1\n"); exit(1); } plist = XpGetPrinterList(pdpy, "", &nlist); if (nlist == 0) { fprintf(stderr, "XpGetPrinterList() : No printers\n"); exit(1); } pctxt = XpCreateContext(pdpy, plist[0].name); XpFreePrinterList(plist); XpSetContext(pdpy, pctxt); pscreen = XpGetScreenOfContext(pdpy, pctxt); CreateWindow(top, pdpy, pctxt, pscreen); LessTifTestMainLoop(top); exit(0); }
void imagesc(void *data, int x, int y, const char* type, double (*transf)(double), const char **colormap, char *title) { static XtAppContext context; Widget drawing_area; Widget toplevel; Atom wm_delete; XEvent event; XpmImage *xpmImage; Boolean exitFlag = False; static Display *display = NULL; Arg al[10]; int ac; int argc = 0; xpmImage = CreateXpmImage(data, x, y, type, transf, colormap); /* create the toplevel shell */ XtToolkitInitialize(); if (display == NULL) { context = XtCreateApplicationContext(); display = XtOpenDisplay(context, NULL, NULL, "", NULL, 0, &argc, NULL); } toplevel =XtAppCreateShell(title, "", applicationShellWidgetClass, display, NULL, 0); /* set window size. */ ac=0; XtSetArg(al[ac],XmNmaxWidth, x); ac++; XtSetArg(al[ac],XmNmaxHeight, y); ac++; XtSetArg(al[ac],XmNminWidth, x); ac++; XtSetArg(al[ac],XmNminHeight, y); ac++; XtSetArg(al[ac],XmNdeleteResponse, XmDO_NOTHING); ac++; XtSetValues(toplevel,al,ac); ac=0; drawing_area=XmCreateDrawingArea(toplevel,"drawing_area",al,ac); XtManageChild(drawing_area); XtAddCallback(drawing_area,XmNexposeCallback,draw_pixmap,(XtPointer) xpmImage); XtAddEventHandler(drawing_area, KeyReleaseMask, false, KeyAction, (XtPointer) &exitFlag); XtRealizeWidget(toplevel); wm_delete = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW", False); XmAddWMProtocolCallback(toplevel, wm_delete, quitCB, (XtPointer) &exitFlag); XmActivateWMProtocol(toplevel, wm_delete); while (!exitFlag) { XtAppNextEvent(context, &event); XtDispatchEvent(&event); } XtDestroyWidget(drawing_area); XtDestroyWidget(toplevel); free(xpmImage); }
int main (int argc, char **argv) { Widget app_shell; /* Add Xt support for i18n: locale */ XtSetLanguageProc(NULL, NULL, NULL); XtToolkitInitialize (); app_context = XtCreateApplicationContext (); display = XtOpenDisplay (app_context, NULL, argv[0], "ArborSplash", NULL, 0, &argc, argv); if (!display) { printf("%s: can't open display, exiting...\n", argv[0]); exit (-1); } /* * Create a dummy application shell, and then hide it again so that the * splash screen can be a top-level screen for all applications. */ app_shell = XtAppCreateShell(".splash", "ArborSplash", applicationShellWidgetClass, display, NULL, 0); create_splash_shell(app_shell); XtUnmanageChild(splash_form); /* * Unmanage the OK button -- the window will pop itself down after * 5 seconds. */ XtUnmanageChild(splash_ok_btn); show_window(splash_shell, splash_form); XtAddEventHandler(splash_shell, VisibilityChangeMask, False, popup_splash, NULL); XtAppAddTimeOut(app_context, 5000, exit_splash, NULL); XtAppMainLoop(app_context); return(0); }
void greet_client(int socket) { short byte; int result; char *dpy_name,*app_class,*app_name; message_t first; /* Read byte-swap thing */ result = read(socket,&byte,2); if( !result ) fatal_error("greet_client: Unable to read initial data."); else if( result == 1 ) { result = read(socket, ((char *) &byte)+1,1); fatal_error("greet_client: Unable to read initial data."); } swap_bytes = (byte!=1); if( global_will_trace ) { printf("swap_bytes is: %d (from %d)\n",swap_bytes,byte); fflush(stdout); } /* Read initial packet */ first = message_read(socket); if( !first ) fatal_error("greet_client: No greeting packet sent."); toolkit_read_value(first,&dpy_name,XtRString); toolkit_read_value(first,&app_name,XtRString); toolkit_read_value(first,&app_class,XtRString); global_app_class = XtNewString(app_class); global_app_name = XtNewString(app_name); if( global_will_trace ) { printf("Opening display on '%s' for app '%s' class '%s'\n",dpy_name, app_name,app_class); fflush(stdout); }; display = XtOpenDisplay(app_context, dpy_name, app_name, app_class, NULL, 0, &global_argc, global_argv); if( !display ) fatal_error("greet_client: Unable to open display."); message_free(first); }
void help_win(Widget widget, XtPointer client_data, XtPointer call_data) { Widget tL1, vpane, buttonbox; Widget close, txt; int one = 1; char *argv[2]; Display * dpy; if (help_context != NULL) return; argv[0] = "xsuprem"; argv[1] = NULL; help_context = XtCreateApplicationContext(); dpy = XtOpenDisplay(help_context, (String) NULL, NULL, "XSuprem", NULL, 0, &one, argv); if (dpy == NULL) XtErrorMsg("invalidDisplay","xtInitialize","XtToolkitError", "Can't Open display", (String *) NULL, (Cardinal *)NULL); tL1 = XtVaAppCreateShell( "XSupHelp", "XSuprem", applicationShellWidgetClass, dpy, XtNscreen, (XtArgVal)DefaultScreenOfDisplay(dpy), NULL ); vpane = XtVaCreateManagedWidget("vpane", panedWidgetClass, tL1, NULL); buttonbox = XtVaCreateManagedWidget("buttonbox", boxWidgetClass, vpane, NULL); /*Make the Help Button*/ close = XtVaCreateManagedWidget("Cancel", commandWidgetClass, buttonbox, NULL); XtAddCallback(close, XtNcallback, destroy_help, NULL); txt = XtVaCreateManagedWidget("help", asciiTextWidgetClass, vpane, XtNscrollVertical, XawtextScrollAlways, XtNtype, XawAsciiFile, /*XtNstring, "/home/helios0/law/src/xgraph/help",*/ NULL); XtRealizeWidget(tL1); }
int main (int argc, char **argv) { XtAppContext app_context; Display *display; /* Display */ XtSetLanguageProc ( (XtAppContext) NULL, (XtLanguageProc) NULL, (XtPointer) NULL ); XtToolkitInitialize (); app_context = XtCreateApplicationContext (); display = XtOpenDisplay (app_context, NULL, argv[0], "XApplication", NULL, 0, &argc, argv); if (!display) { printf("%s: can't open display, exiting...\n", argv[0]); exit (-1); } create_shell ( display, argv[0], argc, argv ); exit (0); }
/* Initial Xt plugin */ static void xt_client_init( XtClient * xtclient, Visual *xtvisual, Colormap xtcolormap, int xtdepth) { XtAppContext app_context; char *mArgv[1]; int mArgc = 0; /* * Initialize Xt stuff */ xtclient->top_widget = NULL; xtclient->child_widget = NULL; xtclient->xtdisplay = NULL; xtclient->xtvisual = NULL; xtclient->xtcolormap = 0; xtclient->xtdepth = 0; if (!xt_is_initialized) { #ifdef DEBUG_XTBIN printf("starting up Xt stuff\n"); #endif XtToolkitInitialize(); app_context = XtCreateApplicationContext(); if (fallback) XtAppSetFallbackResources(app_context, fallback); xtdisplay = XtOpenDisplay(app_context, gdk_get_display(), NULL, "Wrapper", NULL, 0, &mArgc, mArgv); if (xtdisplay) xt_is_initialized = TRUE; } xtclient->xtdisplay = xtdisplay; xtclient->xtvisual = xtvisual; xtclient->xtcolormap = xtcolormap; xtclient->xtdepth = xtdepth; }
/************************************************************** * main: **************************************************************/ int main(int argc, char **argv) { Display * display; char name[132]; (void) strncpy(name, base(argv[0]), 132); /* Initialize the X Intrinsics */ XtToolkitInitialize(); /* Set up language environment for X */ XtSetLanguageProc(NULL, (XtLanguageProc)NULL, NULL); /* Create application context */ app_context = XtCreateApplicationContext(); XtAppSetFallbackResources(app_context, fallback_reslist); /* open up one display */ display = XtOpenDisplay(app_context, NULL, name, "XmdI18nInput", (XrmOptionDescRec *)NULL, 0, &argc, argv); if (!display) { (void) fprintf(stderr, "Unable to open display\n"); exit(0); } /* Call init functions. This creates the user interface (placed in input.c) */ if (dialog_init(&argc, argv, display) != 0) exit(1); XtAppMainLoop(app_context); return 0; /* make compiler happy */ }
/* * Main Program */ int main(int argc, char **argv) { Display *display; Arg args[256]; Cardinal ac; /*SUPPRESS 591*/ Boolean argok; XtAppContext context; Widget w; Widget parent; /* Begin user code block <declarations> */ /* End user code block <declarations> */ /* * Hierarchy variable declarations * Set "*newMrmStyle:False" in ~/.bxrc for bx25 style declarations */ MrmHierarchy HierarchyID; MrmType MrmWClass; static char *UidFile [] = { BX_UID_FILE_NAME }; MRMRegisterArg NamesList[49]; Cardinal Nlac; Nlac = 0; NamesList[Nlac].name = "CloseTree"; NamesList[Nlac++].value = (XtPointer) CloseTree; NamesList[Nlac].name = "CommandEntered"; NamesList[Nlac++].value = (XtPointer) CommandEntered; NamesList[Nlac].name = "CreateTree"; NamesList[Nlac++].value = (XtPointer) CreateTree; NamesList[Nlac].name = "MDisplayData"; NamesList[Nlac++].value = (XtPointer) MDisplayData; NamesList[Nlac].name = "MDoAction"; NamesList[Nlac++].value = (XtPointer) MDoAction; NamesList[Nlac].name = "MessageClear"; NamesList[Nlac++].value = (XtPointer) MessageClear; NamesList[Nlac].name = "MessageDismiss"; NamesList[Nlac++].value = (XtPointer) MessageDismiss; NamesList[Nlac].name = "ModifyData"; NamesList[Nlac++].value = (XtPointer) ModifyData; NamesList[Nlac].name = "MenuUnmap"; NamesList[Nlac++].value = (XtPointer) MenuUnmap; NamesList[Nlac].name = "BxManageCB"; NamesList[Nlac++].value = (XtPointer) BxManageCB; NamesList[Nlac].name = "MSetupDevice"; NamesList[Nlac++].value = (XtPointer) MSetupDevice; NamesList[Nlac].name = "SetDefault"; NamesList[Nlac++].value = (XtPointer) SetDefault; NamesList[Nlac].name = "MModifyData"; NamesList[Nlac++].value = (XtPointer) MModifyData; NamesList[Nlac].name = "DisplayNci"; NamesList[Nlac++].value = (XtPointer) DisplayNci; NamesList[Nlac].name = "BxExitCB"; NamesList[Nlac++].value = (XtPointer) BxExitCB; NamesList[Nlac].name = "MTurnOnOff"; NamesList[Nlac++].value = (XtPointer) MTurnOnOff; NamesList[Nlac].name = "DisplayData"; NamesList[Nlac++].value = (XtPointer) DisplayData; NamesList[Nlac].name = "MSetDefault"; NamesList[Nlac++].value = (XtPointer) MSetDefault; NamesList[Nlac].name = "MDisplayNci"; NamesList[Nlac++].value = (XtPointer) MDisplayNci; NamesList[Nlac].name = "TurnOnOff"; NamesList[Nlac++].value = (XtPointer) TurnOnOff; NamesList[Nlac].name = "DoAction"; NamesList[Nlac++].value = (XtPointer) DoAction; NamesList[Nlac].name = "OpenTree"; NamesList[Nlac++].value = (XtPointer) OpenTree; NamesList[Nlac].name = "AddListTree"; NamesList[Nlac++].value = (XtPointer) AddListTree; NamesList[Nlac].name = "SetupDevice"; NamesList[Nlac++].value = (XtPointer) SetupDevice; NamesList[Nlac].name = "AddNode"; NamesList[Nlac++].value = (XtPointer) AddNode; #ifdef __hpux NamesList[Nlac].name = "AddListTree"; NamesList[Nlac++].value = (XtPointer) AddListTree; #endif NamesList[Nlac].name = "AddNodeApply"; NamesList[Nlac++].value = (XtPointer) AddNodeApply; NamesList[Nlac].name = "AddNodeDismiss"; NamesList[Nlac++].value = (XtPointer) AddNodeDismiss; NamesList[Nlac].name = "SetUsage"; NamesList[Nlac++].value = (XtPointer) SetUsage; NamesList[Nlac].name = "AddDeviceDismiss"; NamesList[Nlac++].value = (XtPointer) AddDeviceDismiss; NamesList[Nlac].name = "CreateAddDevice"; NamesList[Nlac++].value = (XtPointer) CreateAddDevice; NamesList[Nlac].name = "AddDevice"; NamesList[Nlac++].value = (XtPointer) AddDevice; NamesList[Nlac].name = "WriteTree"; NamesList[Nlac++].value = (XtPointer) WriteTree; NamesList[Nlac].name = "ModifyTags"; NamesList[Nlac++].value = (XtPointer) ModifyTags; NamesList[Nlac].name = "tag_button_proc"; NamesList[Nlac++].value = (XtPointer) tag_button_proc; NamesList[Nlac].name = "tag_selection_proc"; NamesList[Nlac++].value = (XtPointer) tag_selection_proc; #ifdef __hpux NamesList[Nlac].name = "WriteTree"; NamesList[Nlac++].value = (XtPointer) WriteTree; #endif NamesList[Nlac].name = "DeleteNode"; NamesList[Nlac++].value = (XtPointer) DeleteNode; NamesList[Nlac].name = "DeleteNodeNow"; NamesList[Nlac++].value = (XtPointer) DeleteNodeNow; NamesList[Nlac].name = "RenameNode"; NamesList[Nlac++].value = (XtPointer) RenameNode; NamesList[Nlac].name = "AddNodeStart"; NamesList[Nlac++].value = (XtPointer) AddNodeStart; NamesList[Nlac].name = NULL; NamesList[Nlac].value = NULL; MrmInitialize(); XtToolkitInitialize(); context = XtCreateApplicationContext(); display = XtOpenDisplay(context, 0, BX_APP_NAME, BX_APP_CLASS, #ifndef XtSpecificationRelease options, XtNumber(options), (Cardinal*)&argc, argv); #else #if XtSpecificationRelease == 4 options, XtNumber(options), (Cardinal*)&argc, argv); #else options, XtNumber(options), &argc, argv); #endif #endif if(display == NULL) { XtWarning("cannot open display"); exit(1); } /* * So converters work. */ XtInitializeWidgetClass(applicationShellWidgetClass); /* * Install the tearOffModel resource converter */ #if (XmVersion >= 1002) XmRepTypeInstallTearOffModelConverter(); #endif /* * Register special BuilderXcessory converters */ RegisterBxConverters(context); /* Begin user code block <create_shells> */ XmdsInitialize(); /* End user code block <create_shells> */ /* * The applicationShell is created as an unrealized * parent for multiple topLevelShells. The topLevelShells * are created as popup children of the applicationShell. * This is a recommendation of Paul Asente & Ralph Swick in * _X_Window_System_Toolkit_ p. 677. */ ac = 0; AppShell = parent = XtAppCreateShell( BX_APP_NAME, BX_APP_CLASS, applicationShellWidgetClass, display, args, ac); MrmRegisterNames(NamesList, Nlac); HierarchyID = 0; MrmOpenHierarchy((MrmCount)(1), UidFile, 0, &HierarchyID); XtInitializeWidgetClass(topLevelShellWidgetClass); ac = 0; XtSetArg(args[ac], XmNtitle, "Traverser"); ac++; XtSetArg(args[ac], XmNiconName, "Traverser"); ac++; XtSetArg(args[ac], XmNx, 947); ac++; XtSetArg(args[ac], XmNy, 349); ac++; XtSetArg(args[ac], XmNwidth, 509); ac++; XtSetArg(args[ac], XmNheight, 672); ac++; TopLevelShell = XtCreatePopupShell( "topLevelShell", topLevelShellWidgetClass, AppShell, args, ac); MainWindow = NULL; MrmFetchWidget(HierarchyID, "mainWindow", TopLevelShell, &MainWindow, &MrmWClass); WriteDialog = NULL; MrmFetchWidget(HierarchyID, "writeDialog", MainWindow, &WriteDialog, &MrmWClass); AddDialog = NULL; MrmFetchWidget(HierarchyID, "addDialog", MainWindow, &AddDialog, &MrmWClass); AddDeviceDialog = NULL; MrmFetchWidget(HierarchyID, "addDeviceDialog", MainWindow, &AddDeviceDialog, &MrmWClass); OpenDialog = NULL; MrmFetchWidget(HierarchyID, "openDialog", MainWindow, &OpenDialog, &MrmWClass); MrmCloseHierarchy(HierarchyID); XtManageChild(MainWindow); XtPopup(XtParent(MainWindow), XtGrabNone); /* Begin user code block <app_procedures> */ /* End user code block <app_procedures> */ /* Begin user code block <main_loop> */ /* End user code block <main_loop> */ XtVaSetValues(TopLevelShell,XmNdeleteResponse, XmDO_NOTHING, NULL); XmAddWMProtocolCallback(TopLevelShell,XmInternAtom(XtDisplay(TopLevelShell),"WM_DELETE_WINDOW",True),(XtCallbackProc)CloseWindow,NULL); XtAppMainLoop(context); /* * A return value even though XtAppMainLoop never ends. */ return(0); }
/* * Two different cases : * 1. Quick print button * Parameter "wid" is a DtPrintSetupBox. * DtPrintFillSetupData fills the print_data structure. The caller must * free allocated memory locations by calling DtPrintFreeSetupData(). * The X printer connection is managed by the DtPrintSetupBox. * If printer_name is NULL then DtNprinterName is used. If DtNprinterName * differs from printer_name, then DtNprinterName is updated. * Destination and dest_info will be updated. * If a connection cannot be established then the DtPrintSetupBox will be * managed, showing an error dialog. The user can then dismiss that * dialog and use the DtPrintSetupBox to select another printer and * restart the printing operation. * 2. GUI-less operation * Parameter "wid" is NULL. * The X printer connection returned, including the print context, is managed * by the caller. * If printer_name is NULL then DtPrintFillSetupData will determine a printer * and set printer_name to this value. * Destination and dest_info will be updated. * The caller can free allocated memory by calling DtPrintFreeSetupData(). */ XtEnum DtPrintFillSetupData(Widget wid, DtPrintSetupData *print_data) { char *name = NULL, *list = NULL, *p, *q, *d, *z, *at; Display *dpy = NULL, *pdpy = NULL; XPPrinterList plist; int count; XtAppContext appc = NULL; String argv[] = { "this" }; int argc = 1; XPContext ctx; list = getenv("XPSERVERLIST"); if (wid == NULL) { /* GUI - less case (or the DtPrintSetupBox widget itself wants this). */ DEBUGOUT(_LtDebug(__FILE__, wid, "DtPrintFillSetupData(NULL)\n")); appc = XtCreateApplicationContext(); /* FIX ME ?? */ /* Get a printer name */ if (print_data && print_data->printer_name) name = print_data->printer_name; else if ((name = getenv("XPRINTER"))) ; else if ((name = getenv("PDPRINTER"))) ; else if ((name = getenv("LPDEST"))) ; else name = getenv("PRINTER"); if (! name) { DEBUGOUT(_LtDebug(__FILE__, wid, "DtPrintFillSetupData: no name\n")); /* * Destroying the application context here seems to kill test2 * XtDestroyApplicationContext(appc); */ return DtPRINT_NO_PRINTER; } DEBUGOUT(_LtDebug(__FILE__, wid, "DtPrintFillSetupData(name %s)\n", name)); /* Create an X printing connection */ if (print_data && print_data->print_display) dpy = print_data->print_display; /* Maybe the printer name is fully qualified */ if ((p = strchr(name, '@'))) { d = XtNewString(p+1); if ((q = strchr(d, ':')) == NULL) { d = XtRealloc(d, strlen(d)+4); strcat(d, ":0"); } /* Now d contains a host:display string, try to use it */ pdpy = XtOpenDisplay(appc, d, "", "", NULL, 0, &argc, argv); DEBUGOUT(_LtDebug(__FILE__, wid, "DtPrintFillSetupData opened display %p\n", pdpy)); } /* Check this display */ if (dpy) { plist = XpGetPrinterList(dpy, name, &count); if (count > 0) { pdpy = dpy; print_data->print_display = pdpy; ctx = XpCreateContext(pdpy, plist[0].name); XpSetContext(pdpy, ctx); print_data->print_context = ctx; if (print_data->printer_name) XtFree(print_data->printer_name); print_data->printer_name = XtNewString(plist[0].name); if (print_data->dest_info) XtFree(print_data->dest_info); print_data->dest_info = XtNewString(plist[0].desc); DEBUGOUT(_LtDebug(__FILE__, wid, "Got %d entries on this display\n", count)); } } /* Check the list of print servers */ if (list && ! pdpy) { DEBUGOUT(_LtDebug(__FILE__, wid, "Try XpServerlist [%s]\n", list)); z = XtMalloc(strlen(list)+5); /* Cut the list into pieces */ for (p=list; *p; p++) { while (*p && isspace(*p)) p++; if (*p == '\0') break; for (q=p, d=z; *q && !isspace(*q); q++) *(d++) = *q; *d = '\0'; /* Now z contains a piece of the list */ if (! strchr(z, ':')) strcat(z, ":0"); DEBUGOUT(_LtDebug(__FILE__, wid, "DtPrintFillSetupData try to open display <%s>\n", z)); pdpy = XtOpenDisplay(appc, z, "", "", NULL, 0, &argc, argv); if (! pdpy) { if (*q) p = q; else break; continue; } DEBUGOUT(_LtDebug(__FILE__, wid, "... dpy %p\n", pdpy)); plist = XpGetPrinterList(pdpy, name, &count); if (count > 0) { print_data->print_display = pdpy; ctx = XpCreateContext(pdpy, plist[0].name); XpSetContext(pdpy, ctx); print_data->print_context = ctx; if (print_data->printer_name) { XtFree(print_data->printer_name); } print_data->printer_name = XtNewString(plist[0].name); if (print_data->dest_info) { XtFree(print_data->dest_info); } print_data->dest_info = XtNewString(plist[0].desc); DEBUGOUT(_LtDebug(__FILE__, wid, "Got %d entries on display %s\n", count, z)); } if (*q) p=q; else break; } XtFree(z); } /* * Destroying the application context here seems to kill test2 * XtDestroyApplicationContext(appc); */ } else { /* wid is the DtPrintSetupBox */ DEBUGOUT(_LtDebug(__FILE__, wid, "DtPrintFillSetupData()\n")); appc = XtWidgetToApplicationContext(wid); if (print_data && print_data->printer_name) name = print_data->printer_name; else if (PSB_PrinterName(wid)) name = PSB_PrinterName(wid); /* This is - mostly - copied from above, there must be a better way */ /* Check the list of print servers */ if (list && ! pdpy) { DEBUGOUT(_LtDebug(__FILE__, wid, "Try XpServerlist [%s]\n", list)); z = XtMalloc(strlen(list)+5); /* Cut the list into pieces */ for (p=list; *p; p++) { while (*p && isspace(*p)) p++; if (*p == '\0') break; for (q=p, d=z; *q && !isspace(*q); q++) *(d++) = *q; *d = '\0'; /* Now z contains a piece of the list */ if (! strchr(z, ':')) strcat(z, ":0"); DEBUGOUT(_LtDebug(__FILE__, wid, "DtPrintFillSetupData try to open display <%s>\n", z)); pdpy = XtOpenDisplay(appc, z, "", "", NULL, 0, &argc, argv); if (! pdpy) { if (*q) p = q; else break; continue; } DEBUGOUT(_LtDebug(__FILE__, wid, "... dpy %p\n", pdpy)); plist = XpGetPrinterList(pdpy, name, &count); if (count > 0) { print_data->print_display = pdpy; if (print_data->print_context == (XPContext)0) { ctx = XpCreateContext(pdpy, plist[0].name); print_data->print_context = ctx; } else { ctx = print_data->print_context; } XpSetContext(pdpy, ctx); if (print_data->printer_name) { XtFree(print_data->printer_name); } print_data->printer_name = XtNewString(plist[0].name); if (print_data->dest_info) { XtFree(print_data->dest_info); } print_data->dest_info = XtNewString(plist[0].desc); DEBUGOUT(_LtDebug(__FILE__, wid, "Got %d entries on display %s\n", count, z)); } if (*q) p=q; else break; } XtFree(z); } } return DtPRINT_SUCCESS; }
Display *mXtOpenDisplay(XtAppContext appContext, String n, String o) { int one = 1; char *arg = "foo"; return XtOpenDisplay(appContext, "", n, o, NULL, 0, &one, &arg); }
bool wxApp::Initialize(int& argc_, wxChar **argv_) { #if wxUSE_INTL wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding()); #endif if ( !wxAppBase::Initialize(argc_, argv_) ) return false; wxWidgetHashTable = new wxHashTable(wxKEY_INTEGER); #ifdef __HPUX__ // under HP-UX creating XmFontSet fails when the system locale is C and // we're using a remote DISPLAY, presumably because HP-UX uses its own // names for C and ISO locales (roman8 and iso8859n respectively) and so // its Motif libraries have troubles with non-HP X server // // whatever the reason, the fact is that without this hack any wxMotif // program crashes on startup because it can't create any font (HP programs // still work but they do spit out messages about failing to create font // sets and failing back on "fixed" font too) // // notice that calling setlocale() here is not enough because X(m) init // functions call setlocale() later so we really have to change environment bool fixAll = false; // tweak LC_ALL (or just LC_CTYPE)? const char *loc = getenv("LC_CTYPE"); if ( !loc ) { loc = getenv("LC_ALL"); if ( loc ) fixAll = true; } if ( !loc || (loc[0] == 'C' && loc[1] == '\0') || strcmp(loc, "POSIX") == 0 ) { // we're using C locale, "fix" it wxLogDebug(wxT("HP-UX fontset hack: forcing locale to en_US.iso88591")); putenv(fixAll ? "LC_ALL=en_US.iso88591" : "LC_CTYPE=en_US.iso88591"); } #endif // __HPUX__ XtSetLanguageProc(NULL, NULL, NULL); XtToolkitInitialize() ; wxTheApp->m_appContext = (WXAppContext) XtCreateApplicationContext(); static char *fallbackResources[] = { // better defaults for CDE under Irix // // TODO: do something similar for the other systems, the hardcoded defaults // below are ugly #ifdef __SGI__ wxMOTIF_STR("*sgiMode: True"), wxMOTIF_STR("*useSchemes: all"), #else // !__SGI__ #if !wxMOTIF_USE_RENDER_TABLE wxMOTIF_STR("*.fontList: -*-helvetica-medium-r-normal-*-*-120-*-*-*-*-*-*"), #else wxMOTIF_STR("*wxDefaultRendition.fontName: -*-helvetica-medium-r-normal-*-*-120-*-*-*-*-*-*"), wxMOTIF_STR("*wxDefaultRendition.fontType: FONT_IS_FONTSET"), wxMOTIF_STR("*.renderTable: wxDefaultRendition"), #endif wxMOTIF_STR("*listBox.background: white"), wxMOTIF_STR("*text.background: white"), wxMOTIF_STR("*comboBox.Text.background: white"), wxMOTIF_STR("*comboBox.List.background: white"), #endif // __SGI__/!__SGI__ NULL }; XtAppSetFallbackResources((XtAppContext) wxTheApp->m_appContext, fallbackResources); // we shouldn't pass empty application/class name as it results in // immediate crash inside XOpenIM() (if XIM is used) under IRIX wxString appname = wxTheApp->GetAppName(); if ( appname.empty() ) appname = wxT("wxapp"); wxString clsname = wxTheApp->GetClassName(); if ( clsname.empty() ) clsname = wxT("wx"); // FIXME-UTF8: This code is taken from wxGTK and duplicated here. This // is just a temporary fix to make wxX11 compile in Unicode // build, the real fix is to change Initialize()'s signature // to use char* on Unix. #if wxUSE_UNICODE // XtOpenDisplay() wants char*, not wchar_t*, so convert int i; char **argvX11 = new char *[argc + 1]; for ( i = 0; i < argc; i++ ) { argvX11[i] = strdup(wxConvLibc.cWX2MB(argv_[i])); } argvX11[argc] = NULL; int argcX11 = argc; Display *dpy = XtOpenDisplay((XtAppContext) wxTheApp->m_appContext, (String)NULL, appname.c_str(), clsname.c_str(), NULL, 0, // no options # if XtSpecificationRelease < 5 (Cardinal*) &argcX11, # else &argcX11, # endif argvX11); if ( argcX11 != argc ) { // we have to drop the parameters which were consumed by X11+ for ( i = 0; i < argcX11; i++ ) { while ( strcmp(wxConvLibc.cWX2MB(argv_[i]), argvX11[i]) != 0 ) { memmove(argv_ + i, argv_ + i + 1, (argc - i)*sizeof(*argv_)); } } argc = argcX11; // update internal arg[cv] as X11 may have removed processed options: argc = argc_; argv = argv_; } //else: XtOpenDisplay() didn't modify our parameters // free our copy for ( i = 0; i < argcX11; i++ ) { free(argvX11[i]); } delete [] argvX11; #else // ANSI Display *dpy = XtOpenDisplay((XtAppContext) wxTheApp->m_appContext, (String)NULL, appname.c_str(), clsname.c_str(), NULL, 0, // no options # if XtSpecificationRelease < 5 (Cardinal*) &argc, # else &argc, # endif argv); #endif // Unicode/ANSI if (!dpy) { // if you don't log to stderr, nothing will be shown... delete wxLog::SetActiveTarget(new wxLogStderr); wxString className(wxTheApp->GetClassName()); wxLogError(_("wxWidgets could not open display for '%s': exiting."), className.c_str()); exit(-1); } m_initialDisplay = (WXDisplay*) dpy; // install the X error handler gs_pfnXErrorHandler = XSetErrorHandler(wxXErrorHandler); // Add general resize proc XtActionsRec rec; rec.string = wxMOTIF_STR("resize"); rec.proc = (XtActionProc)wxWidgetResizeProc; XtAppAddActions((XtAppContext) wxTheApp->m_appContext, &rec, 1); GetMainColormap(dpy); wxAddIdleCallback(); return true; }
int main(int argc, char **argv) { // nspluginviewer is a helper app, it shouldn't do session management at all setenv("SESSION_MANAGER", "", 1); // trap X errors kdDebug(1430) << "1 - XSetErrorHandler" << endl; XSetErrorHandler(x_errhandler); setvbuf(stderr, NULL, _IONBF, 0); kdDebug(1430) << "2 - parseCommandLine" << endl; parseCommandLine(argc, argv); #if QT_VERSION < 0x030100 // Create application kdDebug(1430) << "3 - XtToolkitInitialize" << endl; XtToolkitInitialize(); g_appcon = XtCreateApplicationContext(); Display *dpy = XtOpenDisplay(g_appcon, NULL, "nspluginviewer", "nspluginviewer", 0, 0, &argc, argv); _notifiers[0].setAutoDelete(TRUE); _notifiers[1].setAutoDelete(TRUE); _notifiers[2].setAutoDelete(TRUE); kdDebug(1430) << "4 - KXtApplication app" << endl; KLocale::setMainCatalogue("nsplugin"); KXtApplication app(dpy, argc, argv, "nspluginviewer"); #else kdDebug(1430) << "3 - create QXtEventLoop" << endl; QXtEventLoop integrator("nspluginviewer"); parseCommandLine(argc, argv); KLocale::setMainCatalogue("nsplugin"); kdDebug(1430) << "4 - create KApplication" << endl; KApplication app(argc, argv, "nspluginviewer"); GlibEvents glibevents; #endif { KConfig cfg("kcmnspluginrc", true); cfg.setGroup("Misc"); int v = KCLAMP(cfg.readNumEntry("Nice Level", 0), 0, 19); if(v > 0) { nice(v); } v = cfg.readNumEntry("Max Memory", 0); if(v > 0) { rlimit rl; memset(&rl, 0, sizeof(rl)); if(0 == getrlimit(RLIMIT_AS, &rl)) { rl.rlim_cur = kMin(v, int(rl.rlim_max)); setrlimit(RLIMIT_AS, &rl); } } } // initialize the dcop client kdDebug(1430) << "5 - app.dcopClient" << endl; DCOPClient *dcop = app.dcopClient(); if(!dcop->attach()) { KMessageBox::error(NULL, i18n("There was an error connecting to the Desktop " "communications server. Please make sure that " "the 'dcopserver' process has been started, and " "then try again."), i18n("Error Connecting to DCOP Server")); exit(1); } kdDebug(1430) << "6 - dcop->registerAs" << endl; if(g_dcopId) g_dcopId = dcop->registerAs(g_dcopId, false); else g_dcopId = dcop->registerAs("nspluginviewer"); dcop->setNotifications(true); // create dcop interface kdDebug(1430) << "7 - new NSPluginViewer" << endl; NSPluginViewer *viewer = new NSPluginViewer("viewer", 0); // start main loop #if QT_VERSION < 0x030100 kdDebug(1430) << "8 - XtAppProcessEvent" << endl; while(!g_quit) XtAppProcessEvent(g_appcon, XtIMAll); #else kdDebug(1430) << "8 - app.exec()" << endl; app.exec(); #endif // delete viewer delete viewer; }
/* * ------------------------------------------------------------------------ * Name: PdmShellCreate * * Description: * * This function creates a top level application shell. * * Return value: * * 0 if successful; a PDM_EXIT code if not. * */ static int PdmShellCreate(PdmShell* me, const String* fallback_resources, int* argc_in_out, String* argv_in_out) { String app_class; String app_name; XmPixelSet pixelSets[XmCO_NUM_COLORS]; XrmClass class_list[3]; XrmDatabase db; XrmName name_list[3]; XrmRepresentation rep_type; XrmValue value; int decor; int funcs; short secondary_id; /* * create the application context and open the video display */ XtToolkitInitialize(); XtSetLanguageProc((XtAppContext)NULL, (XtLanguageProc)NULL, (XtPointer)NULL); me->app_context = XtCreateApplicationContext(); XtAppSetFallbackResources(me->app_context, (String*)fallback_resources); me->display = XtOpenDisplay(me->app_context, (String)NULL, (String)NULL, "Dtpdm", PdmOptions, XtNumber(PdmOptions), argc_in_out, argv_in_out); if((Display*)NULL == me->display) return PDM_EXIT_VXAUTH; XtGetApplicationNameAndClass(me->display, &app_name, &app_class); /* * the fallback resources are only intended for the video display, so * remove them from the application context */ XtAppSetFallbackResources(me->app_context, (String*)NULL); /* * get the parent video window id from the display's resource database */ db = XtDatabase(me->display); name_list[0] = XrmStringToQuark(app_name); name_list[1] = XrmStringToQuark("parentWindowStr"); name_list[2] = NULLQUARK; class_list[0] = XrmStringToQuark(app_class); class_list[1] = XrmStringToQuark("ParentWindowStr"); class_list[2] = NULLQUARK; XrmQGetResource(db, name_list, class_list, &rep_type, &value); if(!value.addr) return PDM_EXIT_ERROR; me->parent_window = (Window)strtoul((char*)value.addr, (char**)NULL, 0); /* * obtain the parent video window's attributes */ if(!XGetWindowAttributes(me->display, me->parent_window, &me->parent_attr)) return PDM_EXIT_ERROR; /* * register interest in the DestroyNotify event for the parent window */ XSelectInput(me->display, me->parent_window, StructureNotifyMask); /* * create the application shell */ decor = MWM_DECOR_ALL | MWM_DECOR_RESIZEH | MWM_DECOR_MINIMIZE | MWM_DECOR_MAXIMIZE; funcs = MWM_FUNC_ALL | MWM_FUNC_RESIZE | MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE; me->widget = XtVaAppCreateShell(app_name, app_class, applicationShellWidgetClass, me->display, XmNdeleteResponse, XmDESTROY, XmNmappedWhenManaged, False, XmNmwmDecorations, decor, XmNmwmFunctions, funcs, XmNmwmInputMode,MWM_INPUT_PRIMARY_APPLICATION_MODAL, XmNscreen, me->parent_attr.screen, XmNtransient, True, NULL); /* * pick up the secondary color set, so that the PDM presents the same * colors as a secondary window. (the XmColorObj is created by the * the XmDisplay object, which is created when the app shell is * created) */ if(XmeGetColorObjData(XtScreen(me->widget), (int*)NULL, pixelSets, XmCO_NUM_COLORS, (short*)NULL, (short*)NULL, (short*)NULL, &secondary_id, (short*)NULL)) { /* * In the Xrm database, reassign primary color resource values * with the corresponding secondary color values. This will cause * subsequently created widgets that utilize colors from the * primary set to actually present secondary colors. */ db = XtScreenDatabase(XtScreen(me->widget)); value.size = sizeof(Pixel); value.addr = (char*)&pixelSets[secondary_id].bg; XrmPutResource (&db, "*background", "Pixel", &value); XrmPutResource (&db, "*frameBackground", "Pixel", &value); value.addr = (char*)&pixelSets[secondary_id].fg; XrmPutResource (&db, "*foreground", "Pixel", &value); XrmPutResource (&db, "*backPageForeground", "Pixel", &value); value.addr = (char*)&pixelSets[secondary_id].bs; XrmPutResource (&db, "*bottomShadowColor", "Pixel", &value); value.addr = (char*)&pixelSets[secondary_id].ts; XrmPutResource (&db, "*topShadowColor", "Pixel", &value); } /* * get the application resources */ XtGetApplicationResources(me->widget, me, PdmResources, XtNumber(PdmResources), NULL, 0); /* * return */ return 0; }
int XtTest(int argc, char** argv) { Widget toplevel; Display* display; XtAppContext context; Widget form, label, label1, label2, button; Screen* screen; String swap; if (NULL == (swap = strrchr(argv[0], '/'))) { swap = argv[0]; } else { swap++; } context = XtCreateApplicationContext(); display = XtOpenDisplay( context, NULL, NULL, NULL, NULL, 0, &argc, argv); if (NULL == display) { return 0; } screen = XDefaultScreenOfDisplay(display); toplevel = XtVaAppCreateShell("k", "XtTest", applicationShellWidgetClass, display, XtNtitle, swap, XtNx, (screen->width /3), XtNy, (screen->height /3), NULL ); if (NULL == toplevel) { return -2; } if (3 != argc) { form = XtVaCreateManagedWidget("form", xmFormWidgetClass, toplevel, XmNhorizontalSpacing, 5, XmNmarginHeight, 10, XmNmarginWidth, 10, NULL ); label = XtVaCreateManagedWidget("label", xmLabelGadgetClass, form, XmNlabelString, XmStringCreateLocalized("Usage"), XmNalignment, XmALIGNMENT_BEGINNING, XmNtopAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL ); label1 = XtVaCreateManagedWidget("label1", xmLabelGadgetClass, form, XmNlabelString, XmStringCreateLocalized(swap), XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, label, XmNleftAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, NULL ); label2 = XtVaCreateManagedWidget("label2", xmLabelGadgetClass, form, XmNlabelString, XmStringCreateLocalized(": arg1 arg2"), XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, label, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, label1, XmNbottomAttachment, XmATTACH_FORM, NULL); button = XtVaCreateManagedWidget("button", xmPushButtonWidgetClass, form, XmNlabelString, XmStringCreateLocalized("Close"), XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, label, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, label2, XmNbottomAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); XtAddCallback(button, XmNactivateCallback, XtTestDC, context); XtRealizeWidget(toplevel); XtAppMainLoop(context); } XtDestroyWidget(toplevel); XtDestroyApplicationContext(context); return 0; }
int main( int argc, char **argv ) { Display *display; Arg args[20]; int n=0; char *actionName; int numArgs = 0; DtActionArg *ap = NULL; XtSetLanguageProc(NULL, NULL, NULL); _DtEnvControl(DT_ENV_SET); (void) signal(SIGCHLD, (void (*)())SIG_IGN); /* Initialize the toolkit and open the display */ XtToolkitInitialize() ; appContext = XtCreateApplicationContext() ; if ( !(display = XtOpenDisplay( appContext, NULL, argv[0], "Dtaction", option_list, sizeof(option_list)/sizeof(XrmOptionDescRec), &argc, argv)) ) { setlocale(LC_ALL, ""); fprintf(stderr, "%s", GETMESSAGE(1,11,"Can't open display.\n")); exit(-1); } XtSetArg(args[n], XmNallowShellResize, True); n++; XtSetArg(args[n], XmNmappedWhenManaged, False); n++; XtSetArg(args[n], XmNheight, 1); n++; XtSetArg(args[n], XmNwidth, 1); n++; toplevel = XtAppCreateShell( argv[0], "Dtaction", topLevelShellWidgetClass, display, args, n) ; XtRealizeWidget(toplevel); display = XtDisplay (toplevel); XtGetApplicationResources(toplevel, &appArgs, resources, XtNumber(resources), NULL, 0); password = XtMalloc(1); password[0] = '\0'; stars = XtMalloc(1); stars[0] = '\0'; /* Get Dt initialized */ if (DtInitialize (display, toplevel, argv[0], "Dtaction") == False) { /* Fatal Error: could not connect to the messaging system. */ /* DtInitialize() has already logged an appropriate error msg */ exit(-1); } /* * If the request specified that it wanted to run as a different * user, then take care of prompting for a password, and doing any * necessary verification and logging. */ CheckUserRequest(); /* Load the filetype/action dbs; DtInvokeAction() requires this */ DtDbLoad(); /* * Get the requested action name */ if ( (actionName = argv[1]) == NULL) { fprintf(stderr, "%s", GETMESSAGE(1,10,"No action name specified.\n")); exit(-1); } if ( argc > 2 ) { /* * create an action arg array for the file objects for * this action. This number of objects should be one * less than the argument count. The returned vector will * be terminated by a null pointer. */ numArgs= argc - 2; ap = (DtActionArg *) XtCalloc(numArgs,sizeof(DtActionArg)); } /* * This client is restricted to FILE arguments. * for the time being. */ for ( n = 0; n < numArgs; n++) { ap[n].argClass = DtACTION_FILE; ap[n].u.file.name = argv[n+2]; } actionId = DtActionInvoke(toplevel, actionName, ap, numArgs, appArgs.termOpts, appArgs.execHost, appArgs.contextDir, True, /* use indicator */ (DtActionCallbackProc) actionStatusCallback, NULL); /* * Set up a timer if we didn't get a valid procId -- since there will * be no invocation update in that case. * We must invoke XtMainLoop() at least once, to force any prompt or * error dialogs to get posted. */ if ( !actionId) XtAppAddTimeOut(appContext, 10, (XtTimerCallbackProc)CheckForDone, NULL); XtAppMainLoop(appContext); return EXIT_SUCCESS; }
int main (unsigned int argc, char **argv) { FILE *fp; /* check for existance of ARBOR_GUI_LANGUAGE, exit if absent */ if (getenv("ARBOR_GUI_LANGUAGE") == NULL) { printf("Environment variable ARBOR_GUI_LANGUAGE not set. Exiting...\n"); exit(1) ; } /* Add Xt support for i18n: locale */ XtSetLanguageProc(NULL, NULL, NULL); XtToolkitInitialize (); app_context = XtCreateApplicationContext (); display = XtOpenDisplay (app_context, NULL, argv[0], "SysAdmin", NULL, 0, (int *) &argc, argv); if (!display) { printf("%s: can't open display, exiting...\n", argv[0]); exit (-1); } if ( argc == 2) { fp = fopen(argv[1],"r"); if ( fp == (FILE *) NULL) { printf ("\007Unable to open password file \"%s\".\n", argv[1]); exit(-1); } if (fgets(gsSybase_User,80,fp) != NULL) gsSybase_User[strlen(gsSybase_User)-1] = 0; else { printf("\007\nERROR -- Unable to read password file; exiting.") ; exit(1) ; } if (fgets(gsSybase_Pass,80,fp) != NULL) gsSybase_Pass[strlen(gsSybase_Pass)-1] = 0; else { printf("\007\nERROR -- Unable to read password file; exiting.") ; exit(1) ; } fclose(fp); if ( unlink(argv[1]) ) { printf("\007WARNING -- Unable to remove password file.\n"); } gintAutoLogin = 1; } /* Register converters, just in case you are really unlucky !! */ XmRegisterConverters(); /* String to unit type doesn't get added !! */ XtAddConverter ( XmRString, XmRUnitType, XmCvtStringToUnitType, NULL, 0 ); strcpy(gstrProcessname, "SysAdmin"); gLoginMethod1 = GUI_DSQUERY_ONLY; create_gCIloginwindow ( display, "SysAdmin", argc, argv ); XtRealizeWidget (gCIloginwindow); XmProcessTraversal(gCIpassword,XmTRAVERSE_CURRENT); if ( gintAutoLogin ) { XWithdrawWindow(display, XtWindow(gCIloginwindow), 0); XmTextSetString(gCIusername,gsSybase_User); CI_sybase_login_cb(okloginbtn, NULL, NULL); } XtAppMainLoop (app_context); return(0); }
int main (unsigned int argc, char **argv) { process_arguments(argc, argv); /* g_module, db_name side-effected */ #ifdef _DBG_PRINT dbrecftos("/tmp/msg"); #endif dbproc = mydblogin(); if (dbproc == NULL) { fprintf(stderr, "Unable to log into DB. Exiting.\n"); exit(1); } initialize_message_system("UTL", dbproc); /* a lie, but... */ if(em_initialize_severity_codes(dbproc) == FAILURE) { fprintf(stderr,"Severity codes initialization failed. Exiting.\n"); exit(1); } if((nmodule_names = initialize_module_names(dbproc, &module_names)) < 0) { fprintf(stderr,"Module names initialization failed. Exiting.\n"); exit(1); } if (!g_module[0]) /* No module given. Select "All". */ strcpy(g_module, ALL); else { /* module name not specified */ /* * Check if module name given is legal. * If not, issue a message and exit. */ int i; for (i = 0; i < nmodule_names; i++) if (!strcmp(g_module, module_names[i])) break; if (i == nmodule_names) { /* module not found */ fprintf(stderr, "Unknown module name '%s.' Allowed modules are:\n\t", g_module); for (i = 0; i < nmodule_names; i++) if (strcmp(module_names[i], ALL)) fprintf(stderr, " %s ", module_names[i]); fputc('\n', stderr); exit(1); } } XtToolkitInitialize (); app_context = XtCreateApplicationContext(); display = XtOpenDisplay(app_context, NULL, argv[0], "EditMessage", NULL, 0, &argc, argv); if (!display) { fprintf(stderr, "%s: can't open display, exiting...\n", argv[0]); exit (1); } XmRegisterConverters(); XtAddConverter (XmRString, XmRUnitType, XmCvtStringToUnitType, NULL, 0); create_appShell ( display, argv[0], argc, argv ); /* Cache the chosen module, for callbacks. We could just use the set_module() callback, but that swaps labels etc. and we're cheap. */ initialize_default_module(g_module); XtRealizeWidget(appShell); XtAppMainLoop(app_context); exit(0); /* never get here */ }
/* Parse args and go */ int main(int argc, char *argv[]) { XtAppContext context; #ifndef HAVE_XTVAOPENAPPLICATION Display *display; #endif XTickertapeRec rc; elvin_handle_t handle; elvin_error_t error; const char *user; const char *domain; const char *ticker_dir; const char *config_file; const char *groups_file; const char *usenet_file; const char *keys_file; const char *keys_dir; Widget top; const char *names[AN_MAX + 1]; int i; /* Determine the name of the executable. */ progname = xbasename(argv[0]); #ifdef HAVE_XTVAOPENAPPLICATION /* Create the toplevel widget */ top = XtVaOpenApplication( &context, "XTickertape", NULL, 0, &argc, argv, NULL, applicationShellWidgetClass, XtNborderWidth, 0, NULL); #else /* Initialize the X Toolkit */ XtToolkitInitialize(); /* Create an application context */ context = XtCreateApplicationContext(); /* Open the display */ display = XtOpenDisplay(context, NULL, NULL, "XTickertape", NULL, 0, &argc, argv); if (display == NULL) { fprintf(stderr, "Error: Can't open display\n"); exit(1); } /* Create the toplevel widget */ top = XtAppCreateShell(NULL, "XTickertape", applicationShellWidgetClass, display, NULL, 0); #endif /* Load the application shell resources */ XtGetApplicationResources(top, &rc, resources, XtNumber(resources), NULL, 0); /* Make sure our app-defaults file has a version number */ if (rc.version_tag == NULL) { app_defaults_version_error("app-defaults file not found or " "out of date"); exit(1); } /* Make sure that version number is the one we want */ if (strcmp(rc.version_tag, PACKAGE "-" VERSION) != 0) { app_defaults_version_error("app-defaults file has the wrong " "version number"); exit(1); } /* Add a calback for when it gets destroyed */ XtAppAddActions(context, actions, XtNumber(actions)); #if !defined(ELVIN_VERSION_AT_LEAST) /* Initialize the elvin client library */ error = elvin_xt_init(context); if (error == NULL) { fprintf(stderr, "*** elvin_xt_init(): failed\n"); exit(1); } /* Double-check that the initialization worked */ if (elvin_error_is_error(error)) { eeprintf(error, "elvin_xt_init failed\n"); exit(1); } /* Create a new elvin connection handle */ handle = elvin_handle_alloc(error); if (handle == NULL) { eeprintf(error, "elvin_handle_alloc failed\n"); exit(1); } #elif ELVIN_VERSION_AT_LEAST(4, 1, -1) /* Allocate an error context */ error = elvin_error_alloc(NULL, NULL); if (error == NULL) { fprintf(stderr, "%s: error: elvin_error_alloc failed\n", progname); exit(1); } /* Initialize the elvin client library */ client = elvin_xt_init_default(context, error); if (client == NULL) { eeprintf(error, "elvin_xt_init failed\n"); exit(1); } /* Create a new elvin connection handle */ handle = elvin_handle_alloc(client, error); if (handle == NULL) { eeprintf(error, "elvin_handle_alloc failed\n"); exit(1); } #else /* ELVIN_VERSION_AT_LEAST */ # error "Unsupported Elvin library version" #endif /* ELVIN_VERSION_AT_LEAST */ /* Scan what's left of the arguments */ parse_args(argc, argv, handle, &user, &domain, &ticker_dir, &config_file, &groups_file, &usenet_file, &keys_file, &keys_dir, error); /* Intern a bunch of atoms. We jump through a few hoops in order * in order to do this in a single RPC to the X server. */ #ifdef USE_ASSERT memset(names, 0, sizeof(names)); #endif /* USE_ASSERT */ for (i = 0; i <= AN_MAX; i++) { ASSERT(names[atom_list[i].index] == NULL); names[atom_list[i].index] = atom_list[i].name; } /* Make sure we've specified a name for each atom. */ for (i = 0; i <= AN_MAX; i++) { ASSERT(names[i] != NULL); } /* Intern the atoms. */ if (!XInternAtoms(XtDisplay(top), (char **)names, AN_MAX + 1, False, atoms)) { fprintf(stderr, "%s: error: XInternAtoms failed\n", progname); exit(1); } /* Create an Icon for the root shell */ XtVaSetValues(top, XtNiconWindow, create_icon(top), NULL); /* Create a tickertape */ tickertape = tickertape_alloc( &rc, handle, user, domain, ticker_dir, config_file, groups_file, usenet_file, keys_file, keys_dir, top, error); /* Set up SIGHUP to reload the subscriptions */ signal(SIGHUP, reload_subs); #ifdef USE_VALGRIND /* Set up SIGUSR1 to invoke valgrind. */ signal(SIGUSR1, count_leaks); #endif /* USE_VALGRIND */ #ifdef HAVE_LIBXMU /* Enable editres support */ XtAddEventHandler(top, (EventMask)0, True, _XEditResCheckMessages, NULL); #endif /* HAVE_LIBXMU */ /* Let 'er rip! */ XtAppMainLoop(context); /* Keep the compiler happy */ return 0; }