Пример #1
0
XmFontList CommonGetFontListWithCharset(char *fontstr, char *charset)

{

#ifdef MOTIF1_1
    XFontStruct   *newfont;
#else
    static XmFontListEntry fixed_font = NULL;
    XmFontListEntry fontlistEntry;
#endif
    XmFontList    fontlist;

#ifdef MOTIF1_1

    if (!(newfont = XLoadQueryFont (display, fontstr)))
    	newfont = XLoadQueryFont (display, default_font);
    fontlist = XmFontListCreate (newfont, charset);


#else

    if (!fixed_font) {
        fixed_font = XmFontListEntryLoad(display, "fixed", XmFONT_IS_FONT,
                                         charset);
    }

    if ((fontlistEntry = XmFontListEntryLoad(display, fontstr, XmFONT_IS_FONT,
                                        charset)) == NULL)
      {
	fontlist = XmFontListAppendEntry(NULL, fixed_font);
      }
    else
      {
	fontlist = XmFontListAppendEntry(NULL, fontlistEntry);
	XmFontListEntryFree(&fontlistEntry);
      }

#endif

	return(fontlist);

}
Пример #2
0
/*########################### setup_window() ###########################*/
void
setup_window(char *font_name)
{
   XmFontListEntry entry;

   /* Get width and height of font and fid for the GC. */
   if ((font_struct = XLoadQueryFont(display, font_name)) == NULL)
   {
      (void)fprintf(stderr, "Could not load %s font.\n", font_name);
      if ((font_struct = XLoadQueryFont(display, "fixed")) == NULL)
      {
         (void)fprintf(stderr, "Could not load %s font.\n", "fixed");
         exit(INCORRECT);
      }
   }
   if ((entry = XmFontListEntryLoad(display, font_name, XmFONT_IS_FONT,
                                    "TAG1")) == NULL)
   {
       (void)fprintf(stderr,
                     "Failed to load font with XmFontListEntryLoad() : %s (%s %d)\n",
                     strerror(errno), __FILE__, __LINE__);
       exit(INCORRECT);
   }
   fontlist = XmFontListAppendEntry(NULL, entry);
   XmFontListEntryFree(&entry);

   glyph_height          = font_struct->ascent + font_struct->descent;
   glyph_width           = font_struct->per_char->width;
   y_offset_xaxis        = font_struct->ascent + 4;
   x_offset_left_xaxis   = 9 * glyph_width;
   x_offset_right_xaxis  = 2 * glyph_width;
   y_offset_top_yaxis    = glyph_height;
   y_offset_bottom_yaxis = 5 * glyph_height;

   if (time_type == YEAR_STAT)
   {
      no_of_chars = 4;
   }
   else
   {
      no_of_chars = 3;
   }
   x_data_spacing = no_of_chars * glyph_width;
   y_data_spacing = glyph_height;

   return;
}
Пример #3
0
Файл: mon_info.c Проект: hfs/afd
/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ main() $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/
int
main(int argc, char *argv[])
{
   int             i;
   char            window_title[100],
                   work_dir[MAX_PATH_LENGTH],
                   str_line[MAX_INFO_STRING_LENGTH],
                   tmp_str_line[MAX_INFO_STRING_LENGTH];
   static String   fallback_res[] =
                   {
                      "*mwmDecorations : 42",
                      "*mwmFunctions : 12",
                      ".mon_info.form*background : NavajoWhite2",
                      ".mon_info.form.msa_box.?.?.?.text_wl.background : NavajoWhite1",
                      ".mon_info.form.msa_box.?.?.?.text_wr.background : NavajoWhite1",
                      ".mon_info.form.host_infoSW.host_info.background : NavajoWhite1",
                      ".mon_info.form.buttonbox*background : PaleVioletRed2",
                      ".mon_info.form.buttonbox*foreground : Black",
                      ".mon_info.form.buttonbox*highlightColor : Black",
                      NULL
                   };
   Widget          form_w,
                   msa_box_w,
                   msa_box1_w,
                   msa_box2_w,
                   msa_text_w,
                   button_w,
                   buttonbox_w,
                   rowcol1_w,
                   rowcol2_w,
                   h_separator1_w,
                   h_separator2_w,
                   v_separator_w;
   XmFontListEntry entry;
   XmFontList      fontlist;
   Arg             args[MAXARGS];
   Cardinal        argcount;
   uid_t           euid, /* Effective user ID. */
                   ruid; /* Real user ID. */

   CHECK_FOR_VERSION(argc, argv);

   /* Initialise global values. */
   p_work_dir = work_dir;
   init_mon_info(&argc, argv);

   /*
    * SSH uses wants to look at .Xauthority and with setuid flag
    * set we cannot do that. So when we initialize X lets temporaly
    * disable it. After XtAppInitialize() we set it back.
    */
   euid = geteuid();
   ruid = getuid();
   if (euid != ruid)
   {
      if (seteuid(ruid) == -1)
      {
         (void)fprintf(stderr, "Failed to seteuid() to %d : %s\n",
                       ruid, strerror(errno));
      }
   }

   (void)strcpy(window_title, afd_name);
   (void)strcat(window_title, " Info");
   argcount = 0;
   XtSetArg(args[argcount], XmNtitle, window_title); argcount++;
   appshell = XtAppInitialize(&app, "AFD", NULL, 0,
                              &argc, argv, fallback_res, args, argcount);
   disable_drag_drop(appshell);

   if (euid != ruid)
   {
      if (seteuid(euid) == -1)
      {
         (void)fprintf(stderr, "Failed to seteuid() to %d : %s\n",
                       euid, strerror(errno));
      }
   }

   display = XtDisplay(appshell);

#ifdef HAVE_XPM
   /* Setup AFD logo as icon. */
   setup_icon(display, appshell);
#endif

   /* Create managing widget. */
   form_w = XmCreateForm(appshell, "form", NULL, 0);

   entry = XmFontListEntryLoad(XtDisplay(form_w), font_name,
                               XmFONT_IS_FONT, "TAG1");
   fontlist = XmFontListAppendEntry(NULL, entry);
   XmFontListEntryFree(&entry);

   argcount = 0;
   XtSetArg(args[argcount], XmNtopAttachment,  XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM);
   argcount++;
   msa_box_w = XmCreateForm(form_w, "msa_box", args, argcount);
   XtManageChild(msa_box_w);

   argcount = 0;
   XtSetArg(args[argcount], XmNtopAttachment,  XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_FORM);
   argcount++;
   msa_box1_w = XmCreateForm(msa_box_w, "msa_box1", args, argcount);
   XtManageChild(msa_box1_w);

   rowcol1_w = XtVaCreateWidget("rowcol1", xmRowColumnWidgetClass,
                                 msa_box1_w, NULL);
   for (i = 0; i < NO_OF_MSA_ROWS; i++)
   {
      msa_text_w = XtVaCreateWidget("msa_text", xmFormWidgetClass,
                                     rowcol1_w,
                                     XmNfractionBase, 41,
                                     NULL);
      label_l_widget[i] = XtVaCreateManagedWidget(label_l[i],
                              xmLabelGadgetClass,  msa_text_w,
                              XmNfontList,         fontlist,
                              XmNtopAttachment,    XmATTACH_POSITION,
                              XmNtopPosition,      1,
                              XmNbottomAttachment, XmATTACH_POSITION,
                              XmNbottomPosition,   40,
                              XmNleftAttachment,   XmATTACH_POSITION,
                              XmNleftPosition,     1,
                              XmNalignment,        XmALIGNMENT_END,
                              NULL);
      text_wl[i] = XtVaCreateManagedWidget("text_wl",
                              xmTextWidgetClass,        msa_text_w,
                              XmNfontList,              fontlist,
                              XmNcolumns,               MON_INFO_LENGTH,
                              XmNtraversalOn,           False,
                              XmNeditable,              False,
                              XmNcursorPositionVisible, False,
                              XmNmarginHeight,          1,
                              XmNmarginWidth,           1,
                              XmNshadowThickness,       1,
                              XmNhighlightThickness,    0,
                              XmNrightAttachment,       XmATTACH_FORM,
                              XmNleftAttachment,        XmATTACH_POSITION,
                              XmNleftPosition,          22,
                              NULL);
      XtManageChild(msa_text_w);
   }
   XtManageChild(rowcol1_w);

   /* Fill up the text widget with some values. */
   (void)sprintf(str_line, "%*s", MON_INFO_LENGTH,
                 prev.real_hostname[(int)prev.afd_toggle]);
   XmTextSetString(text_wl[0], str_line);
   (void)sprintf(str_line, "%*d",
                 MON_INFO_LENGTH, prev.port[(int)prev.afd_toggle]);
   XmTextSetString(text_wl[1], str_line);
   (void)strftime(tmp_str_line, MAX_INFO_STRING_LENGTH, "%d.%m.%Y  %H:%M:%S",
                  localtime(&prev.last_data_time));
   (void)sprintf(str_line, "%*s", MON_INFO_LENGTH, tmp_str_line);
   XmTextSetString(text_wl[2], str_line);
   (void)sprintf(str_line, "%*d", MON_INFO_LENGTH, prev.max_connections);
   XmTextSetString(text_wl[3], str_line);
   (void)sprintf(str_line, "%*s", MON_INFO_LENGTH, prev.afd_version);
   XmTextSetString(text_wl[4], str_line);
   if (prev.top_tr > 1048576)
   {
      (void)sprintf(str_line, "%*u MB/s",
                    MON_INFO_LENGTH - 5, prev.top_tr / 1048576);
   }
   else if (prev.top_tr > 1024)               
        {
           (void)sprintf(str_line, "%*u KB/s",
                         MON_INFO_LENGTH - 5, prev.top_tr / 1024);
        }
        else
        {
           (void)sprintf(str_line, "%*u Bytes/s",
                         MON_INFO_LENGTH - 8, prev.top_tr);
        }
   XmTextSetString(text_wl[5], str_line);

   /* Create the first horizontal separator. */
   argcount = 0;
   XtSetArg(args[argcount], XmNorientation,     XmHORIZONTAL);
   argcount++;
   XtSetArg(args[argcount], XmNtopAttachment,   XmATTACH_WIDGET);
   argcount++;
   XtSetArg(args[argcount], XmNtopWidget,       msa_box_w);
   argcount++;
   XtSetArg(args[argcount], XmNleftAttachment,  XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM);
   argcount++;
   h_separator1_w = XmCreateSeparator(form_w, "h_separator1_w", args, argcount);
   XtManageChild(h_separator1_w);

   /* Create the vertical separator. */
   argcount = 0;
   XtSetArg(args[argcount], XmNorientation,      XmVERTICAL);
   argcount++;
   XtSetArg(args[argcount], XmNleftAttachment,   XmATTACH_WIDGET);
   argcount++;
   XtSetArg(args[argcount], XmNleftWidget,       msa_box1_w);
   argcount++;
   XtSetArg(args[argcount], XmNtopAttachment,    XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_FORM);
   argcount++;
   v_separator_w = XmCreateSeparator(msa_box_w, "v_separator", args, argcount);
   XtManageChild(v_separator_w);

   argcount = 0;
   XtSetArg(args[argcount], XmNtopAttachment,   XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNleftAttachment,  XmATTACH_WIDGET);
   argcount++;
   XtSetArg(args[argcount], XmNleftWidget,      v_separator_w);
   argcount++;
   msa_box2_w = XmCreateForm(msa_box_w, "msa_box2", args, argcount);
   XtManageChild(msa_box2_w);

   rowcol2_w = XtVaCreateWidget("rowcol2", xmRowColumnWidgetClass,
                                msa_box2_w, NULL);
   for (i = 0; i < NO_OF_MSA_ROWS; i++)
   {
      msa_text_w = XtVaCreateWidget("msa_text", xmFormWidgetClass,
                                    rowcol2_w,
                                    XmNfractionBase, 41,
                                    NULL);
      label_r_widget[i] = XtVaCreateManagedWidget(label_r[i],
                              xmLabelGadgetClass,  msa_text_w,
                              XmNfontList,         fontlist,
                              XmNtopAttachment,    XmATTACH_POSITION,
                              XmNtopPosition,      1,
                              XmNbottomAttachment, XmATTACH_POSITION,
                              XmNbottomPosition,   40,
                              XmNleftAttachment,   XmATTACH_POSITION,
                              XmNleftPosition,     1,
                              XmNalignment,        XmALIGNMENT_END,
                              NULL);
      text_wr[i] = XtVaCreateManagedWidget("text_wr",
                              xmTextWidgetClass,        msa_text_w,
                              XmNfontList,              fontlist,
                              XmNcolumns,               MON_INFO_LENGTH,
                              XmNtraversalOn,           False,
                              XmNeditable,              False,
                              XmNcursorPositionVisible, False,
                              XmNmarginHeight,          1,
                              XmNmarginWidth,           1,
                              XmNshadowThickness,       1,
                              XmNhighlightThickness,    0,
                              XmNrightAttachment,       XmATTACH_FORM,
                              XmNleftAttachment,        XmATTACH_POSITION,
                              XmNleftPosition,          20,
                              NULL);
      XtManageChild(msa_text_w);
   }
   XtManageChild(rowcol2_w);

   /* Fill up the text widget with some values. */
   get_ip_no(msa[afd_position].hostname[(int)prev.afd_toggle], tmp_str_line);
   (void)sprintf(str_line, "%*s", MON_INFO_LENGTH, tmp_str_line);
   XmTextSetString(text_wr[0], str_line);
   (void)sprintf(str_line, "%*s", MON_INFO_LENGTH, prev.r_work_dir);
   XmTextSetString(text_wr[1], str_line);
   (void)sprintf(str_line, "%*d", MON_INFO_LENGTH, prev.poll_interval);
   XmTextSetString(text_wr[2], str_line);
   (void)sprintf(str_line, "%*d", MON_INFO_LENGTH, prev.top_not);
   XmTextSetString(text_wr[3], str_line);
   (void)sprintf(str_line, "%*d", MON_INFO_LENGTH, prev.no_of_hosts);
   XmTextSetString(text_wr[4], str_line);
   (void)sprintf(str_line, "%*u files/s", MON_INFO_LENGTH - 8, prev.top_fr);
   XmTextSetString(text_wr[5], str_line);

   argcount = 0;
   XtSetArg(args[argcount], XmNleftAttachment,   XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNrightAttachment,  XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNfractionBase,     21);
   argcount++;
   buttonbox_w = XmCreateForm(form_w, "buttonbox", args, argcount);

   /* Create the second horizontal separator. */
   argcount = 0;
   XtSetArg(args[argcount], XmNorientation,           XmHORIZONTAL);
   argcount++;
   XtSetArg(args[argcount], XmNbottomAttachment,      XmATTACH_WIDGET);
   argcount++;
   XtSetArg(args[argcount], XmNbottomWidget,          buttonbox_w);
   argcount++;
   XtSetArg(args[argcount], XmNleftAttachment,        XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNrightAttachment,       XmATTACH_FORM);
   argcount++;
   h_separator2_w = XmCreateSeparator(form_w, "h_separator2", args, argcount);
   XtManageChild(h_separator2_w);

   if (editable == YES)
   {
      button_w = XtVaCreateManagedWidget("Save",
                                         xmPushButtonWidgetClass, buttonbox_w,
                                         XmNfontList,         fontlist,
                                         XmNtopAttachment,    XmATTACH_POSITION,
                                         XmNtopPosition,      2,
                                         XmNbottomAttachment, XmATTACH_POSITION,
                                         XmNbottomPosition,   19,
                                         XmNleftAttachment,   XmATTACH_POSITION,
                                         XmNleftPosition,     1,
                                         XmNrightAttachment,  XmATTACH_POSITION,
                                         XmNrightPosition,    9,
                                         NULL);
      XtAddCallback(button_w, XmNactivateCallback,
                    (XtCallbackProc)save_button, (XtPointer)0);
      button_w = XtVaCreateManagedWidget("Close",
                                         xmPushButtonWidgetClass, buttonbox_w,
                                         XmNfontList,         fontlist,     
                                         XmNtopAttachment,    XmATTACH_POSITION,
                                         XmNtopPosition,      2,                
                                         XmNbottomAttachment, XmATTACH_POSITION,
                                         XmNbottomPosition,   19,
                                         XmNleftAttachment,   XmATTACH_POSITION,
                                         XmNleftPosition,     10,
                                         XmNrightAttachment,  XmATTACH_POSITION,
                                         XmNrightPosition,    20,
                                         NULL);
      XtAddCallback(button_w, XmNactivateCallback,
                    (XtCallbackProc)close_button, (XtPointer)0);
   }
   else
   {
      button_w = XtVaCreateManagedWidget("Close",
                                         xmPushButtonWidgetClass, buttonbox_w,
                                         XmNfontList,         fontlist,
                                         XmNtopAttachment,    XmATTACH_POSITION,
                                         XmNtopPosition,      2,
                                         XmNbottomAttachment, XmATTACH_POSITION,
                                         XmNbottomPosition,   19,
                                         XmNleftAttachment,   XmATTACH_POSITION,
                                         XmNleftPosition,     1,
                                         XmNrightAttachment,  XmATTACH_POSITION,
                                         XmNrightPosition,    20,
                                         NULL);
      XtAddCallback(button_w, XmNactivateCallback,
                    (XtCallbackProc)close_button, (XtPointer)0);
   }
   XtManageChild(buttonbox_w);

   /* Create log_text as a ScrolledText window. */
   argcount = 0;
   XtSetArg(args[argcount], XmNfontList,               fontlist);
   argcount++;
   XtSetArg(args[argcount], XmNrows,                   10);
   argcount++;
   XtSetArg(args[argcount], XmNcolumns,                80);
   argcount++;
   if (editable == YES)
   {
      XtSetArg(args[argcount], XmNeditable,               True);
      argcount++;
      XtSetArg(args[argcount], XmNcursorPositionVisible,  True);
      argcount++;
      XtSetArg(args[argcount], XmNautoShowCursorPosition, True);
   }
   else
   {
      XtSetArg(args[argcount], XmNeditable,               False);
      argcount++;
      XtSetArg(args[argcount], XmNcursorPositionVisible,  False);
      argcount++;
      XtSetArg(args[argcount], XmNautoShowCursorPosition, False);
   }
   argcount++;
   XtSetArg(args[argcount], XmNeditMode,               XmMULTI_LINE_EDIT);
   argcount++;
   XtSetArg(args[argcount], XmNwordWrap,               False);
   argcount++;
   XtSetArg(args[argcount], XmNscrollHorizontal,       False);
   argcount++;
   XtSetArg(args[argcount], XmNcursorPositionVisible,  False);
   argcount++;
   XtSetArg(args[argcount], XmNautoShowCursorPosition, False);
   argcount++;
   XtSetArg(args[argcount], XmNtopAttachment,          XmATTACH_WIDGET);
   argcount++;
   XtSetArg(args[argcount], XmNtopWidget,              h_separator1_w);
   argcount++;
   XtSetArg(args[argcount], XmNtopOffset,              3);
   argcount++;
   XtSetArg(args[argcount], XmNleftAttachment,         XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNleftOffset,             3);
   argcount++;
   XtSetArg(args[argcount], XmNrightAttachment,        XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNrightOffset,            3);
   argcount++;
   XtSetArg(args[argcount], XmNbottomAttachment,       XmATTACH_WIDGET);
   argcount++;
   XtSetArg(args[argcount], XmNbottomWidget,           h_separator2_w);
   argcount++;
   XtSetArg(args[argcount], XmNbottomOffset,           3);
   argcount++;
   info_w = XmCreateScrolledText(form_w, "host_info", args, argcount);
   XtManageChild(info_w);
   XtManageChild(form_w);

   /* Free font list. */
   XmFontListFree(fontlist);

#ifdef WITH_EDITRES
   XtAddEventHandler(appshell, (EventMask)0, True,
                     _XEditResCheckMessages, NULL);
#endif

   /* Realize all widgets. */
   XtRealizeWidget(appshell);
   wait_visible(appshell);

   /* Read and display the information file. */
   (void)check_info_file(afd_name, AFD_INFO_FILE, YES);
   XmTextSetString(info_w, NULL);  /* Clears old entry. */
   XmTextSetString(info_w, info_data);

   /* Call update_info() after UPDATE_INTERVAL ms. */
   interval_id_host = XtAppAddTimeOut(app, UPDATE_INTERVAL,
                                      (XtTimerCallbackProc)update_info,
                                      form_w);

   /* We want the keyboard focus on the Done button. */
   XmProcessTraversal(button_w, XmTRAVERSE_CURRENT);

   /* Write window ID, so mon_ctrl can set focus if it is called again. */
   write_window_id(XtWindow(appshell), getpid(), MON_INFO);

   /* Start the main event-handling loop. */
   XtAppMainLoop(app);

   exit(SUCCESS);
}
Пример #4
0
Файл: afd_load.c Проект: hfs/afd
/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ main() $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/
int
main(int argc, char *argv[])
{
   char            font_name[256],
                   *heading_str[4] =
                   {
                      "FILE LOAD",
                      "KBYTE LOAD",
                      "CONNECTION LOAD",
                      "ACTIVE TRANSFERS",
                   },
                   *unit_str[4] =
                   {
                      "Files/s",
                      "KBytes/s",
                      "Connections/s",
                      " "
                   },
                   window_title[100],
                   work_dir[MAX_PATH_LENGTH];
   XtAppContext    app_context;
   Widget          appshell,
                   bottom_separator_w,
                   buttonbox_w,
                   button_w,
                   chart_w,
                   headingbox_w,
                   label_w,
                   mainform_w,
                   top_separator_w;
   static String   fallback_res[] =
                   {
                      ".afd_load*mwmDecorations : 110",
                      ".afd_load*mwmFunctions : 30",
                      ".afd_load.mainform*background : NavajoWhite2",
                      ".afd_load.mainform.headingbox.current_value*background : NavajoWhite1",
                      ".afd_load.mainform.chart*background : NavajoWhite1",
                      ".afd_load.mainform.buttonbox*background : PaleVioletRed2",
                      ".afd_load.mainform.buttonbox*foreground : Black",
                      ".afd_load.mainform.buttonbox*highlightColor : Black",
                      NULL
                   };
   Arg             args[MAXARGS];
   Cardinal        argcount;
   XmFontList      fontlist;
   XmFontListEntry entry;
   uid_t           euid, /* Effective user ID. */
                   ruid; /* Real user ID. */

   CHECK_FOR_VERSION(argc, argv);

   /* Initialize global variables. */
   p_work_dir = work_dir;
   init_afd_load(&argc, argv, font_name, window_title);

   /*
    * SSH uses wants to look at .Xauthority and with setuid flag
    * set we cannot do that. So when we initialize X lets temporaly
    * disable it. After XtAppInitialize() we set it back.
    */
   euid = geteuid();
   ruid = getuid();
   if (euid != ruid)
   {
      if (seteuid(ruid) == -1)
      {
         (void)fprintf(stderr, "Failed to seteuid() to %d : %s\n",
                       ruid, strerror(errno));
      }
   }

   argcount = 0;
   XtSetArg(args[argcount], XmNtitle, window_title); argcount++;
   appshell = XtAppInitialize(&app_context, "afd_load", NULL, 0,
                              &argc, argv, fallback_res, args, argcount);

   if (euid != ruid)
   {
      if (seteuid(euid) == -1)
      {
         (void)fprintf(stderr, "Failed to seteuid() to %d : %s\n",
                       euid, strerror(errno));
      }
   }

#ifdef HAVE_XPM
   /* Setup AFD logo as icon. */
   setup_icon(XtDisplay(appshell), appshell);
#endif

   /* Create managing widget. */
   mainform_w = XmCreateForm(appshell, "mainform", NULL, 0);

   /* Prepare font. */
   if ((entry = XmFontListEntryLoad(XtDisplay(mainform_w), font_name, XmFONT_IS_FONT, "TAG1")) == NULL)
   {
       if ((entry = XmFontListEntryLoad(XtDisplay(mainform_w), "fixed", XmFONT_IS_FONT, "TAG1")) == NULL)
       {
          (void)fprintf(stderr,
                        "Failed to load font with XmFontListEntryLoad() : %s (%s %d)\n",
                        strerror(errno), __FILE__, __LINE__);
          exit(INCORRECT);
       }
   }
   fontlist = XmFontListAppendEntry(NULL, entry);
   XmFontListEntryFree(&entry);

/*-----------------------------------------------------------------------*/
/*                             Heading Box                               */
/*                             -----------                               */
/*-----------------------------------------------------------------------*/
   XtSetArg(args[argcount], XmNtopAttachment,   XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNleftAttachment,  XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM);
   argcount++;
   headingbox_w = XmCreateForm(mainform_w, "headingbox", args, argcount);

   label_w = XtVaCreateManagedWidget(heading_str[(int)chart_type],
                        xmLabelGadgetClass,  headingbox_w,
                        XmNtopAttachment,    XmATTACH_FORM,
                        XmNtopOffset,        5,
                        XmNbottomAttachment, XmATTACH_FORM,
                        XmNbottomOffset,     5,
                        XmNleftAttachment,   XmATTACH_FORM,
                        XmNleftOffset,       5,
                        XmNfontList,         fontlist,
                        XmNalignment,        XmALIGNMENT_BEGINNING,
                        NULL);
   label_w = XtVaCreateManagedWidget(unit_str[(int)chart_type],
                        xmLabelGadgetClass,  headingbox_w,
                        XmNtopAttachment,    XmATTACH_FORM,
                        XmNtopOffset,        5,
                        XmNbottomAttachment, XmATTACH_FORM,
                        XmNbottomOffset,     5,
                        XmNrightAttachment,  XmATTACH_FORM,
                        XmNrightOffset,      5,
                        XmNfontList,         fontlist,
                        XmNalignment,        XmALIGNMENT_BEGINNING,
                        NULL);
   current_value_w = XtVaCreateWidget("current_value",
                        xmTextWidgetClass,        headingbox_w,
                        XmNtopAttachment,         XmATTACH_FORM,
                        XmNtopOffset,             5,
                        XmNrightAttachment,       XmATTACH_WIDGET,
                        XmNrightWidget,           label_w,
                        XmNrightOffset,           5,
                        XmNbottomAttachment,      XmATTACH_FORM,
                        XmNbottomOffset,          5,
                        XmNfontList,              fontlist,
                        XmNrows,                  1,
                        XmNcolumns,               MAX_CURRENT_VALUE_DIGIT,
                        XmNeditable,              False,
                        XmNcursorPositionVisible, False,
                        XmNmarginHeight,          1,
                        XmNmarginWidth,           1,
                        XmNshadowThickness,       1,
                        XmNhighlightThickness,    0,
                        NULL);
   XtManageChild(current_value_w);
   XtManageChild(headingbox_w);

/*-----------------------------------------------------------------------*/
/*                         Horizontal Separator                          */
/*-----------------------------------------------------------------------*/
   argcount = 0;
   XtSetArg(args[argcount], XmNorientation,     XmHORIZONTAL);
   argcount++;
   XtSetArg(args[argcount], XmNtopAttachment,   XmATTACH_WIDGET);
   argcount++;
   XtSetArg(args[argcount], XmNtopWidget,       headingbox_w);
   argcount++;
   XtSetArg(args[argcount], XmNleftAttachment,  XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM);
   argcount++;
   top_separator_w = XmCreateSeparator(mainform_w, "top separator",
                                       args, argcount);
   XtManageChild(top_separator_w);

/*-----------------------------------------------------------------------*/
/*                             Button Box                                */
/*-----------------------------------------------------------------------*/
   argcount = 0;
   XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_FORM);
   argcount++;
   buttonbox_w = XmCreateForm(mainform_w, "buttonbox", args, argcount);
   button_w = XtVaCreateManagedWidget("Close",
                                     xmPushButtonWidgetClass, buttonbox_w,
                                     XmNfontList,         fontlist,
                                     XmNtopAttachment,    XmATTACH_FORM,
                                     XmNleftAttachment,   XmATTACH_FORM,
                                     XmNrightAttachment,  XmATTACH_FORM,
                                     XmNbottomAttachment, XmATTACH_FORM,
                                     NULL);
   XtAddCallback(button_w, XmNactivateCallback,
                 (XtCallbackProc)close_button, (XtPointer)0);
   XtManageChild(buttonbox_w);

/*-----------------------------------------------------------------------*/
/*                         Horizontal Separator                          */
/*-----------------------------------------------------------------------*/
   argcount = 0;
   XtSetArg(args[argcount], XmNorientation,      XmHORIZONTAL);
   argcount++;
   XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_WIDGET);
   argcount++;
   XtSetArg(args[argcount], XmNbottomWidget,     buttonbox_w);
   argcount++;
   XtSetArg(args[argcount], XmNleftAttachment,   XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNrightAttachment,  XmATTACH_FORM);
   argcount++;
   bottom_separator_w = XmCreateSeparator(mainform_w, "bottom separator",
                                          args, argcount);
   XtManageChild(bottom_separator_w);

/*-----------------------------------------------------------------------*/
/*                             Chart Box                                 */
/*-----------------------------------------------------------------------*/
   chart_w = XtVaCreateManagedWidget("chart",
                                     stripChartWidgetClass, mainform_w,
                                     XmNtopAttachment,      XmATTACH_WIDGET,
                                     XmNtopWidget,          top_separator_w,
                                     XmNleftAttachment,     XmATTACH_FORM,
                                     XmNrightAttachment,    XmATTACH_FORM,
                                     XmNbottomAttachment,   XmATTACH_WIDGET,
                                     XmNbottomWidget,       bottom_separator_w,
                                     XtNupdate,             (int)update_interval,
                                     XtNjumpScroll,         1,
                                     XtNheight,             100,
                                     XtNwidth,              260,
                                     NULL);
   if (chart_type == FILE_CHART)
   {
      XtAddCallback(chart_w, XtNgetValue, get_file_value, (XtPointer)0);
   }
   else if (chart_type == KBYTE_CHART)
        {
           XtAddCallback(chart_w, XtNgetValue, get_kbyte_value, (XtPointer)0);
        }
   else if (chart_type == CONNECTION_CHART)
        {
           XtAddCallback(chart_w, XtNgetValue, get_connection_value,
                         (XtPointer)0);
        }
        else
        {
           XtAddCallback(chart_w, XtNgetValue, get_transfer_value,
                         (XtPointer)0);
        }

   XtManageChild(mainform_w);

   /* Free font list. */
   XmFontListFree(fontlist);

   /* Realize all widgets. */
   XtRealizeWidget(appshell);

   XmTextSetString(current_value_w, "      0.00");

   /* Start the main event-handling loop. */
   XtAppMainLoop(app_context);

   exit(SUCCESS);
}
Пример #5
0
/*######################### setup_mon_window() #########################*/
void
setup_mon_window(char *font_name)
{
   int             i,
                   his_log_length,
                   led_width,
                   new_max_bar_length;
   XmFontListEntry entry;

   /* Get width and height of font and fid for the GC. */
   if (font_struct != NULL)
   {
      XFreeFont(display, font_struct);
      font_struct = NULL;
   }
   if (fontlist != NULL)
   {
      XmFontListFree(fontlist);
      fontlist = NULL;
   }
   if ((font_struct = XLoadQueryFont(display, font_name)) == NULL)
   {
      (void)fprintf(stderr, "Could not load %s font.\n", font_name);
      if ((font_struct = XLoadQueryFont(display, DEFAULT_FONT)) == NULL)
      {
         (void)fprintf(stderr, "Could not load %s font.\n", DEFAULT_FONT);
         exit(INCORRECT);
      }
      else
      {
         (void)strcpy(font_name, DEFAULT_FONT);
      }
   }
   if ((entry = XmFontListEntryLoad(display, font_name, XmFONT_IS_FONT, "TAG1")) == NULL)
   {
       (void)fprintf(stderr,
                     "Failed to load font with XmFontListEntryLoad() : %s (%s %d)\n",
                     strerror(errno), __FILE__, __LINE__);
       exit(INCORRECT);
   }
   fontlist = XmFontListAppendEntry(NULL, entry);
   XmFontListEntryFree(&entry);

   if (line_height != 0)
   {
      /* Set the font for the monitor pulldown. */
      XtVaSetValues(mw[MON_W], XmNfontList, fontlist, NULL);
      if ((mcp.show_ms_log != NO_PERMISSION) ||
          (mcp.show_mon_log != NO_PERMISSION) ||
          (mcp.mon_info != NO_PERMISSION) ||
          (mcp.retry != NO_PERMISSION) ||
          (mcp.switch_afd != NO_PERMISSION) ||
          (mcp.disable != NO_PERMISSION))
      {
         if (mcp.show_ms_log != NO_PERMISSION)
         {
            XtVaSetValues(ow[MON_SYS_LOG_W], XmNfontList, fontlist, NULL);
            XtVaSetValues(pw[0], XmNfontList, fontlist, NULL);
         }
         if (mcp.show_mon_log != NO_PERMISSION)
         {
            XtVaSetValues(ow[MON_LOG_W], XmNfontList, fontlist, NULL);
            XtVaSetValues(pw[1], XmNfontList, fontlist, NULL);
         }
         if (mcp.mon_info != NO_PERMISSION)
         {
            XtVaSetValues(ow[MON_INFO_W], XmNfontList, fontlist, NULL);
            XtVaSetValues(pw[4], XmNfontList, fontlist, NULL);
         }
         if (mcp.retry != NO_PERMISSION)
         {
            XtVaSetValues(ow[MON_RETRY_W], XmNfontList, fontlist, NULL);
            XtVaSetValues(pw[2], XmNfontList, fontlist, NULL);
         }
         if (mcp.switch_afd != NO_PERMISSION)
         {
            XtVaSetValues(ow[MON_SWITCH_W], XmNfontList, fontlist, NULL);
            XtVaSetValues(pw[3], XmNfontList, fontlist, NULL);
         }
         if (mcp.disable != NO_PERMISSION)
         {
            XtVaSetValues(ow[MON_DISABLE_W], XmNfontList, fontlist, NULL);
            XtVaSetValues(pw[5], XmNfontList, fontlist, NULL);
         }
         if ((ping_cmd != NULL) || (traceroute_cmd != NULL))
         {
            XtVaSetValues(ow[MON_TEST_W], XmNfontList, fontlist, NULL);
            if (ping_cmd != NULL)
            {
               XtVaSetValues(tw[PING_W], XmNfontList, fontlist, NULL);
            }
            if (traceroute_cmd != NULL)
            {
               XtVaSetValues(tw[TRACEROUTE_W], XmNfontList, fontlist, NULL);
            }
         }
      }
      XtVaSetValues(ow[MON_SELECT_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(ow[MON_EXIT_W], XmNfontList, fontlist, NULL);

      /* Set the font for the RAFD pulldown. */
      if ((mcp.afd_ctrl != NO_PERMISSION) ||
          (mcp.show_slog != NO_PERMISSION) ||
          (mcp.show_elog != NO_PERMISSION) ||
          (mcp.show_rlog != NO_PERMISSION) ||
          (mcp.show_tlog != NO_PERMISSION) ||
          (mcp.show_ilog != NO_PERMISSION) ||
          (mcp.show_plog != NO_PERMISSION) ||
          (mcp.show_olog != NO_PERMISSION) ||
          (mcp.show_dlog != NO_PERMISSION) ||
          (mcp.show_queue != NO_PERMISSION) ||
          (mcp.afd_load != NO_PERMISSION))
      {
         XtVaSetValues(mw[LOG_W], XmNfontList, fontlist, NULL);
         if (mcp.afd_ctrl != NO_PERMISSION)
         {
            XtVaSetValues(vw[MON_AFD_CTRL_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.show_slog != NO_PERMISSION)
         {
            XtVaSetValues(vw[MON_SYSTEM_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.show_elog != NO_PERMISSION)
         {
            XtVaSetValues(vw[MON_EVENT_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.show_rlog != NO_PERMISSION)
         {
            XtVaSetValues(vw[MON_RECEIVE_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.show_tlog != NO_PERMISSION)
         {
            XtVaSetValues(vw[MON_TRANS_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.show_ilog != NO_PERMISSION)
         {
            XtVaSetValues(vw[MON_INPUT_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.show_plog != NO_PERMISSION)
         {
            XtVaSetValues(vw[MON_PRODUCTION_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.show_olog != NO_PERMISSION)
         {
            XtVaSetValues(vw[MON_OUTPUT_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.show_dlog != NO_PERMISSION)
         {
            XtVaSetValues(vw[MON_DELETE_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.show_queue != NO_PERMISSION)
         {
            XtVaSetValues(vw[MON_SHOW_QUEUE_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.afd_load != NO_PERMISSION)
         {
            XtVaSetValues(vw[MON_VIEW_LOAD_W], XmNfontList, fontlist, NULL);
            XtVaSetValues(lw[FILE_LOAD_W], XmNfontList, fontlist, NULL);
            XtVaSetValues(lw[KBYTE_LOAD_W], XmNfontList, fontlist, NULL);
            XtVaSetValues(lw[CONNECTION_LOAD_W], XmNfontList, fontlist, NULL);
            XtVaSetValues(lw[TRANSFER_LOAD_W], XmNfontList, fontlist, NULL);
         }
      }

      /* Set the font for the Control pulldown. */
      if ((mcp.amg_ctrl != NO_PERMISSION) ||
          (mcp.fd_ctrl != NO_PERMISSION) ||
          (mcp.rr_dc != NO_PERMISSION) ||
          (mcp.rr_hc != NO_PERMISSION) ||
          (mcp.edit_hc != NO_PERMISSION) ||
          (mcp.dir_ctrl != NO_PERMISSION) ||
          (mcp.startup_afd != NO_PERMISSION) ||
          (mcp.shutdown_afd != NO_PERMISSION))
      {
         XtVaSetValues(mw[CONTROL_W], XmNfontList, fontlist, NULL);
         if (mcp.amg_ctrl != NO_PERMISSION)
         {
            XtVaSetValues(cw[AMG_CTRL_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.fd_ctrl != NO_PERMISSION)
         {
            XtVaSetValues(cw[FD_CTRL_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.rr_dc != NO_PERMISSION)
         {
            XtVaSetValues(cw[RR_DC_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.rr_hc != NO_PERMISSION)
         {
            XtVaSetValues(cw[RR_HC_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.edit_hc != NO_PERMISSION)
         {
            XtVaSetValues(cw[EDIT_HC_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.dir_ctrl != NO_PERMISSION)
         {
            XtVaSetValues(cw[DIR_CTRL_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.startup_afd != NO_PERMISSION)
         {
            XtVaSetValues(cw[STARTUP_AFD_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.shutdown_afd != NO_PERMISSION)
         {
            XtVaSetValues(cw[SHUTDOWN_AFD_W], XmNfontList, fontlist, NULL);
         }
      }

      /* Set the font for the Setup pulldown. */
      XtVaSetValues(mw[CONFIG_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(sw[FONT_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(sw[ROWS_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(sw[STYLE_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(sw[HISTORY_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(sw[MON_OTHER_W], XmNfontList, fontlist, NULL);
      if (have_groups == YES)
      {
         XtVaSetValues(sw[MON_OPEN_ALL_GROUPS_W], XmNfontList, fontlist, NULL);
         XtVaSetValues(sw[MON_CLOSE_ALL_GROUPS_W], XmNfontList, fontlist, NULL);
      }
      XtVaSetValues(sw[MON_SAVE_W], XmNfontList, fontlist, NULL);

      /* Set the font for the Help pulldown. */
#ifdef _WITH_HELP_PULLDOWN
      XtVaSetValues(mw[HELP_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(hw[ABOUT_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(hw[HYPER_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(hw[VERSION_W], XmNfontList, fontlist, NULL);
#endif

      /* Set the font for the Row pulldown. */
      XtVaSetValues(rw[ROW_0_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_1_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_2_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_3_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_4_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_5_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_6_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_7_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_8_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_9_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_10_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_11_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_12_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_13_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_14_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_15_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_16_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_17_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_18_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_19_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_20_W], XmNfontList, fontlist, NULL);

      /* Set the font for the Line Style pulldown. */
      XtVaSetValues(lsw[STYLE_0_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(lsw[STYLE_1_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(lsw[STYLE_2_W], XmNfontList, fontlist, NULL);

      /* Set the font for the history pulldown. */
      for (i = 0; i < NO_OF_HISTORY_LOGS; i++)
      {
         XtVaSetValues(hlw[i], XmNfontList, fontlist, NULL);
      }

      /* Set the font for the Other options pulldown. */
      XtVaSetValues(oow[FORCE_SHIFT_SELECT_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(oow[AUTO_SAVE_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(oow[FRAMED_GROUPS_W], XmNfontList, fontlist, NULL);
   }

   glyph_height       = font_struct->ascent + font_struct->descent;
   glyph_width        = font_struct->per_char->width;
   new_max_bar_length = glyph_width * BAR_LENGTH_MODIFIER;

   /* We now have to recalculate the length of all */
   /* bars and the scale, because a font change    */
   /* might have occurred.                         */
   if (new_max_bar_length != max_bar_length)
   {
      unsigned int new_bar_length;

      max_bar_length = new_max_bar_length;
      step_size = MAX_INTENSITY / max_bar_length;

      /* NOTE: We do not care what the line style is because the */
      /*       following could happen: font size = 7x13 style =  */
      /*       chars + bars, the user now wants chars only and   */
      /*       then reduces the font to 5x7. After a while he    */
      /*       wants the bars again. Thus we always need to re-  */
      /*       calculate the bar length and queue scale!         */
      for (i = 0; i < no_of_afds; i++)
      {
         /* Calculate new scale for active transfers bar. */
         if (connect_data[i].max_connections < 1)
         {
            connect_data[i].scale[ACTIVE_TRANSFERS_BAR_NO - 1] = (double)max_bar_length;
         }
         else
         {
            connect_data[i].scale[ACTIVE_TRANSFERS_BAR_NO - 1] = max_bar_length / connect_data[i].max_connections;
         }
         if (connect_data[i].no_of_transfers == 0)
         {
            new_bar_length = 0;
         }
         else if (connect_data[i].no_of_transfers >= connect_data[i].max_connections)
              {
                 new_bar_length = max_bar_length;
              }
              else
              {
                 new_bar_length = connect_data[i].no_of_transfers * connect_data[i].scale[ACTIVE_TRANSFERS_BAR_NO - 1];
              }
         if (new_bar_length >= max_bar_length)
         {
            connect_data[i].bar_length[ACTIVE_TRANSFERS_BAR_NO] = max_bar_length;
            connect_data[i].blue_color_offset = MAX_INTENSITY;
            connect_data[i].green_color_offset = 0;
         }
         else
         {
            connect_data[i].bar_length[ACTIVE_TRANSFERS_BAR_NO] = new_bar_length;
            connect_data[i].blue_color_offset = new_bar_length * step_size;
            connect_data[i].green_color_offset = MAX_INTENSITY - connect_data[i].blue_color_offset;
         }

         /* Calculate new scale for error bar. */
         if (connect_data[i].no_of_hosts < 1)
         {
            connect_data[i].scale[HOST_ERROR_BAR_NO - 1] = (double)max_bar_length;
         }
         else
         {
            connect_data[i].scale[HOST_ERROR_BAR_NO - 1] = max_bar_length / connect_data[i].no_of_hosts;
         }
         if (connect_data[i].host_error_counter == 0)
         {
            connect_data[i].bar_length[HOST_ERROR_BAR_NO] = 0;
         }
         else if (connect_data[i].host_error_counter >= connect_data[i].no_of_hosts)
              {
                 connect_data[i].bar_length[HOST_ERROR_BAR_NO] = max_bar_length;
              }
              else
              {
                 connect_data[i].bar_length[HOST_ERROR_BAR_NO] = connect_data[i].host_error_counter *
                                                                 connect_data[i].scale[HOST_ERROR_BAR_NO - 1];
              }

         /* Calculate new bar length for the transfer rate. */
         if (connect_data[i].average_tr > 1.0)
         {
            /* First ensure we do not divide by zero. */
            if (connect_data[i].max_average_tr < 2.0)
            {
               connect_data[i].bar_length[MON_TR_BAR_NO] =
                 log10(connect_data[i].average_tr) *
                 max_bar_length /
                 log10((double) 2.0);
            }
            else
            {
               connect_data[i].bar_length[MON_TR_BAR_NO] =
                 log10(connect_data[i].average_tr) *
                 max_bar_length /
                 log10(connect_data[i].max_average_tr);
            }
         }
         else
         {
            connect_data[i].bar_length[MON_TR_BAR_NO] = 0;
         }
      } /* for (i = 0; i < no_of_afds; i++) */
   }

   text_offset     = font_struct->ascent;
   line_height     = SPACE_ABOVE_LINE + glyph_height + SPACE_BELOW_LINE;
   bar_thickness_3 = glyph_height / 3;
   y_offset_led    = (glyph_height - glyph_width) / 2;
   led_width       = glyph_height / 3;
   y_center_log    = SPACE_ABOVE_LINE + (glyph_height / 2);
   if (his_log_set > 0)
   {
      his_log_length  = (his_log_set * bar_thickness_3) + DEFAULT_FRAME_SPACE;
   }
   else
   {
      his_log_length  = 0;
   }
   line_length     = DEFAULT_FRAME_SPACE +
                     (MAX_AFDNAME_LENGTH * glyph_width) +
                     DEFAULT_FRAME_SPACE +
                     (3 * (led_width + PROC_LED_SPACING)) +
                     glyph_height + (glyph_height / 2) + DEFAULT_FRAME_SPACE +
                     his_log_length + DEFAULT_FRAME_SPACE;

   if (line_style == BARS_ONLY)
   {
      line_length += (int)max_bar_length + DEFAULT_FRAME_SPACE;
   }
   else  if (line_style == CHARACTERS_ONLY)
         {
            line_length += (32 * glyph_width) + DEFAULT_FRAME_SPACE;
         }
         else
         {
            line_length += (32 * glyph_width) + DEFAULT_FRAME_SPACE +
                           (int)max_bar_length + DEFAULT_FRAME_SPACE;
         }

   x_offset_led = DEFAULT_FRAME_SPACE + (MAX_AFDNAME_LENGTH * glyph_width) +
                  DEFAULT_FRAME_SPACE;
   x_offset_log_status = x_offset_led + (3 * (led_width + PROC_LED_SPACING)) +
                         (glyph_height / 2) + DEFAULT_FRAME_SPACE;
   x_center_log_status = x_offset_log_status + (glyph_height / 2);
   x_offset_log_history = x_offset_log_status + glyph_height +
                          DEFAULT_FRAME_SPACE;
   for (i = 0; i < LOG_FIFO_SIZE; i++)
   {
      coord[i].x = x_center_log_status +
                   (int)((glyph_height / 2) *
                   cos((double)((log_angle * i * PI) / 180)));
      coord[i].y = y_center_log -
                   (int)((glyph_height / 2) *
                   sin((double)((log_angle * i * PI) / 180)));
   }
   if (line_style == BARS_ONLY)
   {
      x_offset_bars = x_offset_log_history + his_log_length;
   }
   else  if (line_style == CHARACTERS_ONLY)
         {
            x_offset_characters = x_offset_log_history + his_log_length;
            x_offset_ec = x_offset_characters + (27 * glyph_width);
            x_offset_eh = x_offset_ec + (3 *glyph_width);
         }
         else
         {
            x_offset_characters = x_offset_log_history + his_log_length;
            x_offset_bars = x_offset_characters + (32 * glyph_width) +
                            DEFAULT_FRAME_SPACE;
            x_offset_ec = x_offset_characters + (27 * glyph_width);
            x_offset_eh = x_offset_ec + (3 *glyph_width);
         }

   return;
}
Пример #6
0
Файл: show_cmd.c Проект: hfs/afd
/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ main() $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/
int
main(int argc, char *argv[])
{
   char            window_title[MAX_TITLE_CMD_LENGTH + 1 + 25 + 1];
   static String   fallback_res[] =
                   {
                      ".show_cmd*mwmDecorations : 110",
                      ".show_cmd*mwmFunctions : 30",
                      ".show_cmd.mainform_w.cmd_outputSW*XmText.fontList : fixed",
                      ".show_cmd*background : NavajoWhite2",
                      ".show_cmd.mainform_w.cmd_outputSW.cmd_output.background : NavajoWhite1",
                      ".show_cmd.mainform_w.buttonbox_w*background : PaleVioletRed2",
                      ".show_cmd.mainform_w.buttonbox_w*foreground : Black",
                      ".show_cmd.mainform_w.buttonbox_w*highlightColor : Black",
                      ".show_cmd.Print Data*background : NavajoWhite2",
                      ".show_cmd.Print Data*XmText.background : NavajoWhite1",
                      ".show_cmd.Print Data.main_form.buttonbox*background : PaleVioletRed2",
                      ".show_cmd.Print Data.main_form.buttonbox*foreground : Black",
                      ".show_cmd.Print Data.main_form.buttonbox*highlightColor : Black",
                      NULL
                   };
   Widget          mainform_w,
                   button,
                   buttonbox_w,
                   separator_w;
   Arg             args[MAXARGS];
   Cardinal        argcount;
   XmFontListEntry entry;
   XmFontList      fontlist;
   uid_t           euid, /* Effective user ID. */
                   ruid; /* Real user ID. */

   CHECK_FOR_VERSION(argc, argv);

   p_work_dir = work_dir;
   init_cmd(&argc, argv, window_title);

   /*
    * SSH wants to look at .Xauthority and with setuid flag
    * set we cannot do that. So when we initialize X lets temporaly
    * disable it. After XtAppInitialize() we set it back.
    */
   euid = geteuid();
   ruid = getuid();
   if (euid != ruid)
   {
      if (seteuid(ruid) == -1)
      {
         (void)fprintf(stderr, "Failed to seteuid() to %d : %s\n",
                       ruid, strerror(errno));
      }
   }

   argcount = 0;
   XtSetArg(args[argcount], XmNtitle, window_title); argcount++;
   appshell = XtAppInitialize(&app, "AFD", NULL, 0,
                              &argc, argv, fallback_res, args, argcount);
   disable_drag_drop(appshell);

   if (euid != ruid)
   {
      if (seteuid(euid) == -1)
      {
         (void)fprintf(stderr, "Failed to seteuid() to %d : %s\n",
                       euid, strerror(errno));
      }
   }

   if ((display = XtDisplay(appshell)) == NULL)
   {
      (void)fprintf(stderr,
                    "ERROR   : Could not open Display : %s (%s %d)\n",
                    strerror(errno), __FILE__, __LINE__);
      exit(INCORRECT);
   }

#ifdef HAVE_XPM
   /* Setup AFD logo as icon. */
   setup_icon(display, appshell);
#endif

   /* Create managing widget. */
   mainform_w = XmCreateForm(appshell, "mainform_w", NULL, 0);

   /* Prepare the font. */
   entry = XmFontListEntryLoad(XtDisplay(appshell), font_name,
                               XmFONT_IS_FONT, "TAG1");
   fontlist = XmFontListAppendEntry(NULL, entry);
   XmFontListEntryFree(&entry);

   argcount = 0;
   XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNfractionBase, 31);
   argcount++;
   buttonbox_w = XmCreateForm(mainform_w, "buttonbox_w", args, argcount);
   button = XtVaCreateManagedWidget("Repeat",
                        xmPushButtonWidgetClass, buttonbox_w,
                        XmNfontList,         fontlist,
                        XmNtopAttachment,    XmATTACH_POSITION,
                        XmNtopPosition,      1,
                        XmNleftAttachment,   XmATTACH_POSITION,
                        XmNleftPosition,     1,
                        XmNrightAttachment,  XmATTACH_POSITION,
                        XmNrightPosition,    10,
                        XmNbottomAttachment, XmATTACH_POSITION,
                        XmNbottomPosition,   30,
                        NULL);
   XtAddCallback(button, XmNactivateCallback,
                 (XtCallbackProc)repeat_button, 0);
   button = XtVaCreateManagedWidget("Print",
                        xmPushButtonWidgetClass, buttonbox_w,
                        XmNfontList,         fontlist,
                        XmNtopAttachment,    XmATTACH_POSITION,
                        XmNtopPosition,      1,
                        XmNleftAttachment,   XmATTACH_POSITION,
                        XmNleftPosition,     11,
                        XmNrightAttachment,  XmATTACH_POSITION,
                        XmNrightPosition,    20,
                        XmNbottomAttachment, XmATTACH_POSITION,
                        XmNbottomPosition,   30,
                        NULL);
   XtAddCallback(button, XmNactivateCallback,
                 (XtCallbackProc)print_button, 0);
   button = XtVaCreateManagedWidget("Close",
                        xmPushButtonWidgetClass, buttonbox_w,
                        XmNfontList,         fontlist,
                        XmNtopAttachment,    XmATTACH_POSITION,
                        XmNtopPosition,      1,
                        XmNleftAttachment,   XmATTACH_POSITION,
                        XmNleftPosition,     21,
                        XmNrightAttachment,  XmATTACH_POSITION,
                        XmNrightPosition,    30,
                        XmNbottomAttachment, XmATTACH_POSITION,
                        XmNbottomPosition,   30,
                        NULL);
   XtAddCallback(button, XmNactivateCallback,
                 (XtCallbackProc)close_button, 0);
   XtManageChild(buttonbox_w);

/*-----------------------------------------------------------------------*/
/*                         Horizontal Separator                          */
/*-----------------------------------------------------------------------*/
   argcount = 0;
   XtSetArg(args[argcount], XmNorientation,      XmHORIZONTAL);
   argcount++;
   XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_WIDGET);
   argcount++;
   XtSetArg(args[argcount], XmNbottomWidget,     buttonbox_w);
   argcount++;
   XtSetArg(args[argcount], XmNleftAttachment,   XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNrightAttachment,  XmATTACH_FORM);
   argcount++;
   separator_w = XmCreateSeparator(mainform_w, "separator", args, argcount);
   XtManageChild(separator_w);                                              

/*-----------------------------------------------------------------------*/
/*                            Status Box                                 */
/*                            ----------                                 */
/* The status of the output log is shown here. If eg. no files are found */
/* it will be shown here.                                                */
/*-----------------------------------------------------------------------*/
   statusbox_w = XtVaCreateManagedWidget(" ",                              
                        xmLabelWidgetClass,  mainform_w,
                        XmNfontList,         fontlist,  
                        XmNleftAttachment,   XmATTACH_FORM,
                        XmNrightAttachment,  XmATTACH_FORM,
                        XmNbottomAttachment, XmATTACH_WIDGET,
                        XmNbottomWidget,     separator_w,
                        NULL);

/*-----------------------------------------------------------------------*/
/*                         Horizontal Separator                          */
/*-----------------------------------------------------------------------*/
   argcount = 0;
   XtSetArg(args[argcount], XmNorientation,      XmHORIZONTAL);
   argcount++;
   XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_WIDGET);
   argcount++;
   XtSetArg(args[argcount], XmNbottomWidget,     statusbox_w);
   argcount++;
   XtSetArg(args[argcount], XmNleftAttachment,   XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNrightAttachment,  XmATTACH_FORM);
   argcount++;
   separator_w = XmCreateSeparator(mainform_w, "separator", args, argcount);
   XtManageChild(separator_w);

   /* Create cmd_output as a ScrolledText window. */
   argcount = 0;
   XtSetArg(args[argcount], XmNrows,                   18);
   argcount++;
   XtSetArg(args[argcount], XmNcolumns,                80);
   argcount++;
   XtSetArg(args[argcount], XmNeditable,               False);
   argcount++;
   XtSetArg(args[argcount], XmNeditMode,               XmMULTI_LINE_EDIT);
   argcount++;
   XtSetArg(args[argcount], XmNwordWrap,               False);
   argcount++;
   XtSetArg(args[argcount], XmNscrollHorizontal,       True);
   argcount++;
   XtSetArg(args[argcount], XmNcursorPositionVisible,  True);
   argcount++;
   XtSetArg(args[argcount], XmNautoShowCursorPosition, False);
   argcount++;
   XtSetArg(args[argcount], XmNfontList,               fontlist);
   argcount++;
   XtSetArg(args[argcount], XmNtopAttachment,          XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNleftAttachment,         XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNrightAttachment,        XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNbottomAttachment,       XmATTACH_WIDGET);
   argcount++;
   XtSetArg(args[argcount], XmNbottomWidget,           separator_w);
   argcount++;
   cmd_output = XmCreateScrolledText(mainform_w, "cmd_output", args, argcount);
   XtManageChild(cmd_output);
   XtManageChild(mainform_w);

#ifdef WITH_EDITRES
   XtAddEventHandler(appshell, (EventMask)0, True,
                      _XEditResCheckMessages, NULL);
#endif

   /* Realize all widgets. */
   XtRealizeWidget(appshell);


   /* Set some signal handlers. */
   if ((signal(SIGBUS, sig_bus) == SIG_ERR) ||
       (signal(SIGSEGV, sig_segv) == SIG_ERR))
   {
      (void)xrec(WARN_DIALOG, "Failed to set signal handler's for %s : %s",
                 SHOW_CMD, strerror(errno));
   }

   xexec_cmd(cmd);

   /* We want the keyboard focus on the cmd output. */
   XmProcessTraversal(cmd_output, XmTRAVERSE_CURRENT);

   /* Start the main event-handling loop. */
   XtAppMainLoop(app);

   exit(SUCCESS);
}
Пример #7
0
Файл: view_dc.c Проект: hfs/afd
/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ main() $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/
int
main(int argc, char *argv[])
{
    int             glyph_height,
                    max_vertical_lines;
    char            window_title[100],
                    work_dir[MAX_PATH_LENGTH];
    static String   fallback_res[] =
    {
        "*mwmDecorations : 42",
        "*mwmFunctions : 12",
        ".view_dc.form*background : NavajoWhite2",
        ".view_dc.form.buttonbox2.searchbox*background : NavajoWhite1",
        ".view_dc.form.dc_textSW.dc_text.background : NavajoWhite1",
        ".view_dc.form.buttonbox*background : PaleVioletRed2",
        ".view_dc.form.buttonbox*foreground : Black",
        ".view_dc.form.buttonbox*highlightColor : Black",
        NULL
    };
    Widget          form_w,
                    button_w,
                    buttonbox_w,
                    h_separator_w;
    XmFontListEntry entry;
    XFontStruct     *font_struct;
    XmFontList      fontlist;
    XmFontType      dummy;
    Arg             args[MAXARGS];
    Cardinal        argcount;
    uid_t           euid, /* Effective user ID. */
                    ruid; /* Real user ID. */

    CHECK_FOR_VERSION(argc, argv);

    /* Initialise global values. */
    p_work_dir = work_dir;
    init_view_dc(&argc, argv);

    /*
     * SSH uses wants to look at .Xauthority and with setuid flag
     * set we cannot do that. So when we initialize X lets temporaly
     * disable it. After XtAppInitialize() we set it back.
     */
    euid = geteuid();
    ruid = getuid();
    if (euid != ruid)
    {
        if (seteuid(ruid) == -1)
        {
            (void)fprintf(stderr, "Failed to seteuid() to %d : %s\n",
                          ruid, strerror(errno));
        }
    }

    (void)strcpy(window_title, "DIR_CONFIG ");
    (void)strcat(window_title, p_title);
    argcount = 0;
    XtSetArg(args[argcount], XmNtitle, window_title);
    argcount++;
    appshell = XtAppInitialize(&app, "AFD", NULL, 0,
                               &argc, argv, fallback_res, args, argcount);
    disable_drag_drop(appshell);

    if (euid != ruid)
    {
        if (seteuid(euid) == -1)
        {
            (void)fprintf(stderr, "Failed to seteuid() to %d : %s\n",
                          euid, strerror(errno));
        }
    }

    /* Get display pointer. */
    if ((display = XtDisplay(appshell)) == NULL)
    {
        (void)fprintf(stderr,
                      "ERROR   : Could not open Display : %s (%s %d)\n",
                      strerror(errno), __FILE__, __LINE__);
        exit(INCORRECT);
    }

#ifdef HAVE_XPM
    /* Setup AFD logo as icon. */
    setup_icon(display, appshell);
#endif

    /* Create managing widget. */
    form_w = XmCreateForm(appshell, "form", NULL, 0);

    if ((entry = XmFontListEntryLoad(XtDisplay(form_w), font_name,
                                     XmFONT_IS_FONT, "TAG1")) == NULL)
    {
        if ((entry = XmFontListEntryLoad(XtDisplay(form_w), "fixed",
                                         XmFONT_IS_FONT, "TAG1")) == NULL)
        {
            (void)fprintf(stderr,
                          "Failed to load font with XmFontListEntryLoad() : %s (%s %d)\n",
                          strerror(errno), __FILE__, __LINE__);
            exit(INCORRECT);
        }
    }
    font_struct = (XFontStruct *)XmFontListEntryGetFont(entry, &dummy);
    glyph_height = font_struct->ascent + font_struct->descent;
    fontlist = XmFontListAppendEntry(NULL, entry);
    XmFontListEntryFree(&entry);

    /* Calculate the maximum lines to show. */
    max_vertical_lines = (8 * (DisplayHeight(display, DefaultScreen(display)) /
                               glyph_height)) / 10;
    if (max_y > max_vertical_lines)
    {
        max_y = max_vertical_lines;
    }

    argcount = 0;
    XtSetArg(args[argcount], XmNleftAttachment,   XmATTACH_FORM);
    argcount++;
    XtSetArg(args[argcount], XmNrightAttachment,  XmATTACH_FORM);
    argcount++;
    XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_FORM);
    argcount++;
    XtSetArg(args[argcount], XmNfractionBase,     21);
    argcount++;
    buttonbox_w = XmCreateForm(form_w, "buttonbox", args, argcount);

    /* Create a horizontal separator. */
    argcount = 0;
    XtSetArg(args[argcount], XmNorientation,           XmHORIZONTAL);
    argcount++;
    XtSetArg(args[argcount], XmNbottomAttachment,      XmATTACH_WIDGET);
    argcount++;
    XtSetArg(args[argcount], XmNbottomWidget,          buttonbox_w);
    argcount++;
    XtSetArg(args[argcount], XmNleftAttachment,        XmATTACH_FORM);
    argcount++;
    XtSetArg(args[argcount], XmNrightAttachment,       XmATTACH_FORM);
    argcount++;
    h_separator_w = XmCreateSeparator(form_w, "h_separator", args, argcount);
    XtManageChild(h_separator_w);

    button_w = XtVaCreateManagedWidget("Close",
                                       xmPushButtonWidgetClass, buttonbox_w,
                                       XmNfontList,         fontlist,
                                       XmNtopAttachment,    XmATTACH_POSITION,
                                       XmNtopPosition,      2,
                                       XmNbottomAttachment, XmATTACH_POSITION,
                                       XmNbottomPosition,   19,
                                       XmNleftAttachment,   XmATTACH_POSITION,
                                       XmNleftPosition,     1,
                                       XmNrightAttachment,  XmATTACH_POSITION,
                                       XmNrightPosition,    20,
                                       NULL);
    XtAddCallback(button_w, XmNactivateCallback,
                  (XtCallbackProc)close_button, (XtPointer)0);
    XtManageChild(buttonbox_w);

    /* Create DIR_CONFIG data as a ScrolledText window. */
    argcount = 0;
    XtSetArg(args[argcount], XmNfontList,               fontlist);
    argcount++;
    XtSetArg(args[argcount], XmNeditable,               False);
    argcount++;
    XtSetArg(args[argcount], XmNeditMode,               XmMULTI_LINE_EDIT);
    argcount++;
    XtSetArg(args[argcount], XmNwordWrap,               False);
    argcount++;
    XtSetArg(args[argcount], XmNscrollHorizontal,       False);
    argcount++;
    XtSetArg(args[argcount], XmNcursorPositionVisible,  False);
    argcount++;
    XtSetArg(args[argcount], XmNautoShowCursorPosition, False);
    argcount++;
    XtSetArg(args[argcount], XmNleftAttachment,         XmATTACH_FORM);
    argcount++;
    XtSetArg(args[argcount], XmNleftOffset,             3);
    argcount++;
    XtSetArg(args[argcount], XmNrightAttachment,        XmATTACH_FORM);
    argcount++;
    XtSetArg(args[argcount], XmNrightOffset,            3);
    argcount++;
    XtSetArg(args[argcount], XmNbottomAttachment,       XmATTACH_WIDGET);
    argcount++;
    XtSetArg(args[argcount], XmNbottomWidget,           h_separator_w);
    argcount++;
    XtSetArg(args[argcount], XmNbottomOffset,           3);
    argcount++;
    XtSetArg(args[argcount], XmNrows,                   max_y);
    argcount++;
    XtSetArg(args[argcount], XmNcolumns,                max_x);
    argcount++;
    XtSetArg(args[argcount], XmNvalue,                  view_buffer);
    argcount++;
    text_w = XmCreateScrolledText(form_w, "dc_text", args, argcount);
    XtManageChild(text_w);

    /* Create a horizontal separator. */
    argcount = 0;
    XtSetArg(args[argcount], XmNorientation,           XmHORIZONTAL);
    argcount++;
    XtSetArg(args[argcount], XmNbottomAttachment,      XmATTACH_WIDGET);
    argcount++;
    XtSetArg(args[argcount], XmNbottomWidget,          text_w);
    argcount++;
    XtSetArg(args[argcount], XmNleftAttachment,        XmATTACH_FORM);
    argcount++;
    XtSetArg(args[argcount], XmNrightAttachment,       XmATTACH_FORM);
    argcount++;
    h_separator_w = XmCreateSeparator(form_w, "h_separator", args, argcount);
    XtManageChild(h_separator_w);

    argcount = 0;
    XtSetArg(args[argcount], XmNtopAttachment,          XmATTACH_FORM);
    argcount++;
    XtSetArg(args[argcount], XmNtopOffset,              1);
    argcount++;
    XtSetArg(args[argcount], XmNleftAttachment,         XmATTACH_FORM);
    argcount++;
    XtSetArg(args[argcount], XmNrightAttachment,        XmATTACH_FORM);
    argcount++;
    XtSetArg(args[argcount], XmNbottomAttachment,       XmATTACH_WIDGET);
    argcount++;
    XtSetArg(args[argcount], XmNbottomWidget,           h_separator_w);
    argcount++;
    XtSetArg(args[argcount], XmNbottomOffset,           1);
    argcount++;
    XtSetArg(args[argcount], XmNfractionBase,           31);
    argcount++;
    buttonbox_w = XmCreateForm(form_w, "buttonbox2", args, argcount);

    searchbox_w = XtVaCreateWidget("searchbox",
                                   xmTextWidgetClass,        buttonbox_w,
                                   XmNtopAttachment,         XmATTACH_POSITION,
                                   XmNtopPosition,           5,
                                   XmNbottomAttachment,      XmATTACH_POSITION,
                                   XmNbottomPosition,        26,
                                   XmNleftAttachment,        XmATTACH_POSITION,
                                   XmNleftPosition,          1,
                                   XmNrightAttachment,       XmATTACH_POSITION,
                                   XmNrightPosition,         20,
                                   XmNfontList,              fontlist,
                                   XmNrows,                  1,
                                   XmNeditable,              True,
                                   XmNcursorPositionVisible, True,
                                   XmNmarginHeight,          1,
                                   XmNmarginWidth,           1,
                                   XmNshadowThickness,       1,
                                   XmNhighlightThickness,    0,
                                   NULL);
    XtManageChild(searchbox_w);
    button_w = XtVaCreateManagedWidget("Search",
                                       xmPushButtonWidgetClass, buttonbox_w,
                                       XmNleftAttachment,       XmATTACH_POSITION,
                                       XmNleftPosition,         22,
                                       XmNrightAttachment,      XmATTACH_POSITION,
                                       XmNrightPosition,        28,
                                       XmNtopAttachment,        XmATTACH_FORM,
                                       XmNfontList,             fontlist,
                                       NULL);
    XtAddCallback(button_w, XmNactivateCallback,
                  (XtCallbackProc)search_button, (XtPointer)0);
    XtManageChild(buttonbox_w);
    XtManageChild(form_w);

    /* Free font list. */
    XmFontListFree(fontlist);

#ifdef WITH_EDITRES
    XtAddEventHandler(appshell, (EventMask)0, True,
                      _XEditResCheckMessages, NULL);
#endif

    /* Realize all widgets. */
    XtRealizeWidget(appshell);

    /* We want the keyboard focus on the Close button. */
    XmProcessTraversal(button_w, XmTRAVERSE_CURRENT);

    /* Write window ID, so afd_ctrl can set focus if it is called again. */
    write_window_id(XtWindow(appshell), getpid(), VIEW_DC);

    /* Start the main event-handling loop. */
    XtAppMainLoop(app);

    exit(SUCCESS);
}