📄 seinit.c
字号:
/* * This file is part of the Seyon, Copyright (c) 1992-1993 by Muhammad M. * Saggaf. All rights reserved. * * See the file COPYING (1-COPYING) or the manual page seyon(1) for a full * statement of rights and permissions for this program. *//* -*- Mode: C -*- * SeInit.c --- Initialization routines * Author : Muhammad M. Saggaf * Created On : sometime in 1992 * Last Modified By: system admin * Last Modified On: Fri Jun 4 16:17:39 1993 * Update Count : 8 * Status : Mostly OK, needs some cleaning up */#include <X11/Intrinsic.h>#include <X11/StringDefs.h>#include <X11/Shell.h>#include <X11/Xaw/Label.h>#include <X11/Xaw/Dialog.h>#include <signal.h>#include <fcntl.h>#include "seyon.h"#include "SeDecl.h"#include "version.h"#ifndef HELPFILE#define HELPFILE "/usr/lib/X11/seyon.help"#endifextern void TopAbout(), TopHelp(), TopSet(), TopTransfer(), TopMisc(), SetNewlineTrMode(), FunMessage();extern void upload_acc_ok(), setVal_action_ok(), manual_dial_action_ok(), divert_action_ok();extern Boolean CvtStringToStringArray();void HangupConfirm(), ExecHangup(), ExitConfirm(), ExitAction(), test();Boolean inhibit_child = False;Widget w_exit, w_kill, statusMessage;Widget dialWidget, genericWidget;pid_t w_child_pid = 0;Pixmap progIcon;#include "progIcon.h"voidInitVariables(topLevel) Widget topLevel;{ char buffer[REG_BUF]; sprintf(captureFile, "%s/%s", expand_fname(qres.defaultDirectory, buffer), qres.captureFile); SetNewlineTrMode(qres.newlineTranslation);}voidSetIcon(topLevelWidget) Widget topLevelWidget;{ progIcon = XCreateBitmapFromData(XtDisplay(topLevelWidget), DefaultRootWindow(XtDisplay(topLevelWidget)), progIcon_bits, progIcon_width, progIcon_height); XtVaSetValues(topLevelWidget, XtNiconPixmap, progIcon, NULL);}voidCreateCommandCenter(){ void GetQuickKeyResources(), GetValueByPopupOKAction(), DispatchActionsCallback(); void TopShell(); void KillChildProc(); Widget mainBox, menuBox, statusBox, messageBox, quickKeyBox; static Widget status[NUM_MDM_STAT]; static Atom wm_delete_window; Dimension menuBoxWidth; struct _quickKeyRes quickKeyRes; Widget quickKeyW; char qKBuf[REG_BUF]; int i, n = 0; static XtActionsRec actionTable[] = { {"UploadOk", upload_acc_ok}, {"SetValOk", setVal_action_ok}, {"ManualDialOk", manual_dial_action_ok}, {"DivertOk", divert_action_ok}, {"Exit", ExitAction}, {"GetValueByPopupOK", GetValueByPopupOKAction}, }; XtAppAddActions(XtWidgetToApplicationContext(topLevel), actionTable, XtNumber(actionTable)); mainBox = SeAddPaned("mainBox", topLevel); statusBox = AddBox("statusBox", mainBox); messageBox = SeAddForm("messageBox", mainBox); quickKeyBox = AddBox("quickKeyBox", mainBox); menuBox = AddBox("menuBox", mainBox); status[0] = SeAddToggle("dcd", statusBox, NULL); status[1] = SeAddToggle("dtr", statusBox, NULL); status[2] = SeAddToggle("dsr", statusBox, NULL); status[3] = SeAddToggle("rts", statusBox, NULL); status[4] = SeAddToggle("cts", statusBox, NULL); status[5] = SeAddToggle("rng", statusBox, NULL); statusMessage = SeAddLabel("message", messageBox); AddButton("about", menuBox, TopAbout, NULL); AddButton("help", menuBox, TopHelp, NULL); AddButton("set", menuBox, TopSet, NULL); genericWidget = dialWidget = AddButton("dial", menuBox, TopDial, NULL); AddButton("transfer", menuBox, TopTransfer, NULL); AddButton("shellCommand", menuBox, TopShell, NULL); AddButton("misc", menuBox, TopMisc, NULL); AddButton("hangup", menuBox, HangupConfirm, NULL); w_exit = AddButton("exit", menuBox, ExitConfirm, NULL); w_kill = AddButton("kill", menuBox, KillChildProc, NULL); for (i = 0; i < MAX_SEQUICKKEYS; i++) { sprintf(qKBuf, "quickKey%d", i+1); GetQuickKeyResources(qKBuf, &quickKeyRes); if (quickKeyRes.visible) { n++; quickKeyW = AddButton(qKBuf, quickKeyBox, DispatchActionsCallback, NULL); } } if (n == 0) XtDestroyWidget(quickKeyBox); XtOverrideTranslations(topLevel, XtParseTranslationTable("<Message>WM_PROTOCOLS: Exit()")); /* Call UpdateStatusBox() before realizing the top-level widget so that the status widget array in that function would be properly initialized before the user is able to call hangup(), since the latter passes NULL to UpdateStatusBox() */ UpdateStatusBox((XtPointer)status); XtSetMappedWhenManaged(topLevel, False); XtRealizeWidget(topLevel); XtVaGetValues(menuBox, XtNwidth, &menuBoxWidth, NULL); XtVaSetValues(statusBox, XtNwidth, menuBoxWidth, NULL); if (n) XtVaSetValues(quickKeyBox, XtNwidth, menuBoxWidth, NULL); /* * (ideally one should not assume any fixed numbers, but this will do * for now). * * width of message box = label width * + 2*border width (2*1) * + defaultDistance (right) (1) * + horizDistance (left) (4) * * desired width of label = width of menu box * - hSpace of menu box (2*4) (to align with buttons) * - border with of label (2*1) * = width of menu box - 10 * * => width of message box = width of menu box - 10 + 7 * => width of message box < width of menu box * => menu box width is the controlling factor in deciding the widnow * width, as desired. */ XtVaSetValues(statusMessage, XtNresizable, True, NULL); XtVaSetValues(statusMessage, XtNwidth, menuBoxWidth - 10, NULL); XtVaSetValues(statusMessage, XtNresizable, False, NULL); wm_delete_window = XInternAtom(XtDisplay(topLevel), "WM_DELETE_WINDOW", False); XSetWMProtocols(XtDisplay(topLevel), XtWindow(topLevel), &wm_delete_window, 1);}voidTopAbout(parent) Widget parent;{ Widget popup, mBox, uBox, lBox, pic, msg, caption; Pixmap pix; Dimension width1, width2; char msgStr[LRG_BUF];#include "authPic.h" popup = SeAddPopup("about", parent); mBox = SeAddPaned("mBox", popup); uBox = SeAddBox("uBox", mBox); lBox = SeAddBox("lBox", mBox); msg = SeAddLabel("msg", uBox); pic = SeAddLabel("pic", uBox); caption = SeAddLabel("caption", uBox); sprintf(msgStr, "%s %s rev. %s\n%s\n%s\n%s", "Seyon version", VERSION, REVISION, "Copyright 1992-1993", "(c) Muhammad M. Saggaf", "All rights reserved"); XtVaSetValues(msg, XtNlabel, msgStr, NULL); pix = XCreateBitmapFromData(XtDisplay(pic), DefaultRootWindow(XtDisplay(pic)), authPic_bits, authPic_width, authPic_height); XtVaSetValues(pic, XtNbitmap, pix, NULL); width1 = SeWidgetWidth(msg); width2 = SeWidgetWidth(pic); width1 = width1 > width2 ? width1 : width2; width2 = SeWidgetWidth(caption); width1 = width1 > width2 ? width1 : width2; XtVaSetValues(msg, XtNwidth, width1, NULL); XtVaSetValues(pic, XtNwidth, width1, NULL); XtVaSetValues(caption, XtNwidth, width1, NULL); SeAddButton("dismiss", lBox, DestroyShell); XtPopupSpringLoaded(popup);}/* * TopHelp: displays the help file. */voidTopHelp(widget) Widget widget;{ Widget DoDisplayFile(); Widget displayPopup; XtVaSetValues(widget, XtNsensitive, False, NULL); displayPopup = DoDisplayFile(widget, qres.helpFile); XtAddCallback(displayPopup, XtNdestroyCallback, SetSensitiveOn, widget); PositionShell(displayPopup, widget, SHELLPOS_HWFH); XtPopup(displayPopup, XtGrabNone);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -