⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 saveproto.c

📁 This source code has been tested under OpenWindows 2.0, Sun s X11/NeWS server. For Xlib programs th
💻 C
字号:
/*************************************************************************                                                                    ****  saveproto.c                                                       ****                                                                    ****  Text Editor -- DELETE_WINDOW Protocol Interface                   ****                                                                    *************************************************************************/#include <stdio.h>#include <Xm/MessageB.h>#include <X11/Protocols.h>#include "textedit.h"/*************************************************************************                                                                    ****               F O R W A R D   D E F I N I T I O N S                ****                                                                    *************************************************************************/static	void	SaveProtoCB();static	void	InitSaveAlert();static	void	AlertSaveCB();static	Boolean	AlertSaveWP();/*************************************************************************                                                                    ****                    L O C A L   V A R I A B L E S                   ****                                                                    *************************************************************************/static	Widget	save_alert;		/* Warning Dialog	      */static	Atom	a_del_win;		/* Atom for WM_DELETE_WINDOW  *//*************************************************************************                                                                    ****  InitSaveProto()                                                   ****                                                                    ****  This function sets up the callback for the WM_DELETE_WINDOW       ****  protocol. To make this work, it must also modify the shell's      ****  deleteResponse resource -- otherwise the shell kills the job.     ****                                                                    *************************************************************************/void InitSaveProto(){    a_del_win = XInternAtom( XtDisplay(appshell),                             "WM_DELETE_WINDOW", FALSE );    XmAddWMProtocolCallback( appshell, a_del_win, SaveProtoCB, NULL );    XtSetArg( arglist[0], XmNdeleteResponse, XmDO_NOTHING );    XtSetValues( appshell, arglist, 1 );    InitSaveAlert();}/*************************************************************************                                                                    ****  InitSaveAlert()                                                   ****                                                                    ****  Creates the "Quit without Saving?" message box.                   ****                                                                    ****  Note: The "Help" button is changed to "Quit" for this dialog.     ****                                                                    *************************************************************************/static void InitSaveAlert(){    Widget	temp;    save_alert = XmCreateWarningDialog( mainwin, "SaveAlert", NULL, 0 );    temp = XmMessageBoxGetChild( save_alert, XmDIALOG_OK_BUTTON );    XtAddCallback( temp, XmNactivateCallback, AlertSaveCB, "Save" );    temp = XmMessageBoxGetChild( save_alert, XmDIALOG_HELP_BUTTON );    XtAddCallback( temp, XmNactivateCallback, AlertSaveCB, "Quit" );}/*************************************************************************                                                                    ****  SaveProtoCB( w, client_data, call_data )                          ****                                                                    ****  This function handles the callback for the WM_DELETE_WINDOW       ****  protocol. It displays a dialog, which queries whether or not      ****  the workspace should be saved.                                    ****                                                                    *************************************************************************/static void SaveProtoCB( w, client_data, call_data )    Widget		w;    caddr_t		client_data;    XmAnyCallbackStruct	*call_data;{    XtManageChild( save_alert );}/*************************************************************************                                                                    ****  AlertSaveCB( w, client_data, call_data )                          ****                                                                    ****  Callback for the "Quit without Saving?" message box.              ****  This function either quits or saves then quits.                   ****                                                                    *************************************************************************/static void AlertSaveCB( w, client_data, call_data )    Widget      w;    char        *client_data;    caddr_t     call_data;{    if (!strcmp(client_data, "Save"))	{        saved = FALSE;	XtAddWorkProc( AlertSaveWP, NULL );        FileSave();	}    else    	exit( 0 );}/*************************************************************************                                                                    ****  AlertSaveWP( client_data )                                        ****                                                                    ****  Workproc to handle wait while user saves file. This function      ****  simply waits until the global variable "saved" becomes TRUE.      ****                                                                    *************************************************************************/static Boolean AlertSaveWP( client_data )    caddr_t	client_data;{    if (saved)        exit( 0 );    else        return( FALSE );}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -