2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: errordialog.c /main/6 1996/10/17 09:36:14 mustafa $ */
24 /************************************<+>*************************************
25 ****************************************************************************
30 * DESCRIPTION: Routines to create dialogs for error messages
32 * FUNCTIONS: create_error_dialog
33 * error_cancel_callback
37 * (c) Copyright 1993, 1994, 1995 Hewlett-Packard Company
38 * (c) Copyright 1993, 1994, 1995 International Business Machines Corp.
39 * (c) Copyright 1993, 1994, 1995 Sun Microsystems, Inc.
40 * (c) Copyright 1993, 1994, 1995 Novell, Inc.
42 ****************************************************************************
43 ************************************<+>*************************************/
50 #include <X11/Intrinsic.h>
51 #include <X11/StringDefs.h>
55 #include <Xm/DialogS.h>
58 #include <Xm/BulletinB.h>
62 #include <Xm/ToggleB.h>
63 #include <Xm/Separator.h>
66 #include "sharedFuncs.h"
68 #define VERTICAL_SPACING 5
69 #define HORIZONTAL_SPACING 8
70 #define TOP_SPACING (VERTICAL_SPACING + 3)
71 #define INDENTED_SPACING (HORIZONTAL_SPACING + 5)
73 /*--------------------------------------------------------------------
75 *------------------------------------------------------------------*/
80 XtPointer client_data,
83 XtDestroyWidget(G_error_dialog);
84 G_wait_on_input = FALSE;
86 G_error_dialog = NULL;
93 error_cancel_callback(
95 XtPointer client_data,
98 display_cancel_warning(G_error_dialog);
104 /*-------------------------------------------------
106 * The toggle shows up in more than one dialog
107 * thus the state of the two widgets must be
110 *------------------------------------------------*/
114 XtPointer client_data,
119 G_ignore_errors = !G_ignore_errors;
121 if (w == G_toggle_main)
123 if (G_error_dialog != NULL)
124 XtVaSetValues(G_toggle_error,
125 XmNset, !G_ignore_errors,
130 XtVaSetValues(G_toggle_main,
131 XmNset, !G_ignore_errors,
138 /*--------------------------------------------------------------------
139 * create error dialog
140 *------------------------------------------------------------------*/
144 Widget parent_widget,
155 Widget form, outerFrame;
156 Widget icon, error_header_label, error_text_label;
157 Widget separator, action_area;
158 Pixel background, foreground;
162 static ActionAreaItem copy_action_items[] = {
163 {"Continue", 6, 6, ok_callback, NULL},
164 {"Cancel Copy", 6, 7, error_cancel_callback, NULL},
165 {"Help", 6, 4, help_callback, (XtPointer) HELP_DIR_ERROR},
168 ActionAreaDefn copyActions = {
169 XtNumber(copy_action_items),
170 0, /* Ok is default action */
174 static ActionAreaItem move_action_items[] = {
175 {"Continue", 6, 6, ok_callback, NULL},
176 {"Cancel Move", 6, 8, error_cancel_callback, NULL},
177 {"Help", 6, 4, help_callback, (XtPointer) HELP_DIR_ERROR},
180 ActionAreaDefn moveActions = {
181 XtNumber(move_action_items),
182 0, /* Ok is default action */
187 /* Create the dialog shell for the dialog */
189 XtSetArg (args[n], XmNallowShellResize, True); n++;
190 XtSetArg (args[n], XmNmappedWhenManaged, False); n++;
193 XtSetArg (args[n], XmNtitle, GETMESSAGE(4, 4, "Folder Move - Error")); n++;
197 XtSetArg (args[n], XmNtitle, GETMESSAGE(4, 3, "Folder Copy - Error")); n++;
200 G_error_dialog = XmCreateDialogShell (G_copy_dialog, "dialog_shell", args, n);
202 /* create a frame around the dialog for better separation from window border */
203 outerFrame = XtVaCreateManagedWidget("outerFrame",
204 xmFrameWidgetClass, G_error_dialog,
205 XmNshadowThickness, 3,
206 XmNshadowType, XmSHADOW_ETCHED_IN,
210 /* Create the Manager Widget, form, for the copy error dialog */
211 form = XtVaCreateManagedWidget ("dialog_form",
214 XmNverticalSpacing, VERTICAL_SPACING,
215 XmNhorizontalSpacing, HORIZONTAL_SPACING,
218 /* create the action area of the Error Dialog */
220 action_area = Create_Action_Area(form, moveActions, NULL);
222 action_area = Create_Action_Area(form, copyActions, NULL);
224 /* create the separator widget */
225 separator = XtVaCreateManagedWidget("separator",
226 xmSeparatorWidgetClass,
228 XmNbottomAttachment, XmATTACH_WIDGET,
229 XmNbottomWidget, action_area,
230 XmNleftAttachment, XmATTACH_FORM,
231 XmNrightAttachment, XmATTACH_FORM,
236 /* Create the error dialog icon */
238 XtSetArg (args[n], XmNbackground, &background); n++;
239 XtSetArg (args[n], XmNforeground, &foreground); n++;
240 XtGetValues (form, args, n);
241 px = XmGetPixmapByDepth(XtScreen(form), "xm_error",
242 foreground, background, form->core.depth);
243 if (px == XmUNSPECIFIED_PIXMAP)
244 px = XmGetPixmapByDepth(XtScreen(form), "default_xm_error",
245 foreground, background, form->core.depth);
247 icon = XtVaCreateManagedWidget("error_icon",
250 XmNlabelType, XmPIXMAP,
252 XmNtopAttachment, XmATTACH_FORM,
253 XmNbottomAttachment, XmATTACH_WIDGET,
254 XmNbottomWidget, separator,
255 XmNleftAttachment, XmATTACH_FORM,
258 /* Create the first error message label */
259 sprintf(buf,GETMESSAGE(4, 1, "Error %s\n%s"), op, filename);
260 xm_string = XmStringCreateLocalized(buf);
261 error_header_label = XtVaCreateManagedWidget("msg_header",
264 XmNlabelString, xm_string,
265 XmNtopAttachment, XmATTACH_FORM,
266 XmNleftAttachment, XmATTACH_WIDGET,
268 XmNrightAttachment, XmATTACH_FORM,
269 XmNalignment, XmALIGNMENT_BEGINNING,
271 XmStringFree(xm_string);
273 /* Create the second error message label */
274 msg = strerror(errnum);
275 xm_string = XmStringCreateLocalized(msg);
276 error_text_label = XtVaCreateManagedWidget("msg_text",
279 XmNlabelString, xm_string,
280 XmNtopAttachment, XmATTACH_WIDGET,
281 XmNtopWidget, error_header_label,
282 XmNleftAttachment, XmATTACH_WIDGET,
284 XmNrightAttachment, XmATTACH_FORM,
285 XmNalignment, XmALIGNMENT_BEGINNING,
287 XmStringFree(xm_string);
289 /* create the toggle button */
290 xm_string = XmStringCreateLocalized(GETMESSAGE(4, 2, "Pause for errors"));
291 G_toggle_error = XtVaCreateManagedWidget("toggle",
292 xmToggleButtonWidgetClass,
294 XmNlabelString, xm_string,
295 XmNset, !G_ignore_errors,
296 XmNtopAttachment, XmATTACH_WIDGET,
297 XmNtopWidget, error_text_label,
298 XmNleftAttachment, XmATTACH_WIDGET,
300 XmNbottomAttachment, XmATTACH_WIDGET,
301 XmNbottomWidget, separator,
302 XmNalignment, XmALIGNMENT_BEGINNING,
304 XtAddCallback(G_toggle_error, XmNvalueChangedCallback, toggle_callback, NULL);
305 XmStringFree(xm_string);
306 /* set initial keyborad focus to the action button area */
307 XtSetArg (args[0], XmNinitialFocus, action_area);
308 XtSetValues(form, args, 1);
310 /* Manage the Dialog */
314 /* Choose a window position */
315 _DtChildPosition(G_error_dialog, G_toplevel, &x, &y);
317 XtSetArg (args[n], XmNx, x); n++;
318 XtSetArg (args[n], XmNy, y); n++;
319 XtSetValues(G_error_dialog, args, n);
321 /* Now that we have a window postion, mapp the dialog shell */
322 XtMapWidget(G_error_dialog);