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 /* $TOG: cmncbs.c /main/8 1999/09/17 15:44:29 mgreess $ */
24 /*****************************************************************************/
28 /* Common callbacks */
30 /*****************************************************************************/
32 #include <sys/types.h>
33 #include <sys/signal.h>
34 #include <X11/cursorfont.h>
38 #include <Dt/HelpDialog.h>
44 #include "CreateActionAppShell.h"
47 #include "icon_selection_dialog.h"
50 extern void UxDoEditPixmap(Widget wid, char *fname);
52 /******************************************************************************/
53 /* Initialize global values. */
54 /******************************************************************************/
55 Boolean bRegisteredSignal = FALSE;
56 int (*sigchildRoutine)();
58 /******************************************************************************/
59 /* activateCB_open_FindSet - Callback for the "Find Set" button on */
60 /* CreateActionAppShell and AddFiletype windows. */
61 /* This callback will pop up the Icon Selection */
64 /* INPUT: Widget filesel - file selection box widget id */
65 /* XtPointer cdata - client data */
66 /* XmFileSelectionBoxCallbackStruct *cbstruct - callback data */
70 /******************************************************************************/
71 void activateCB_open_FindSet (Widget find_set_button, XtPointer cdata,
72 XmFileSelectionBoxCallbackStruct *cbstruct)
75 XtArgVal /* Boolean */ use_bm = False;
76 static char *use_bm_filter = "*.m.bm";
77 static char *use_pm_filter = "*.m.pm";
79 char *filter_field_title = NULL;
80 int use_filter_field = False;
83 char **directories_list = GetIconSearchPathList();
84 int numberOfTopButtons = 0;
85 void *top_button_one_cb = NULL;
86 void *top_button_two_cb = NULL;
87 void *top_button_three_cb = NULL;
88 char *top_button_one_label = NULL;
89 char *top_button_two_label = NULL;
90 char *top_button_three_label = NULL;
91 int use_icon_name_field = True;
92 int numberOfBottomButtons = 3;
93 void *bottom_button_one_cb = (void *)load_icons;
94 void *bottom_button_two_cb = NULL;
95 void *bottom_button_three_cb = NULL;
96 void *bottom_button_four_cb = NULL;
97 char *bottom_button_one_label = NULL; /* use default */
98 char *bottom_button_two_label = NULL; /* use default */
99 char *bottom_button_three_label = NULL; /* use default */
100 char *bottom_button_four_label = NULL; /* use default */
102 char *name_field_title;
103 char *container_title;
104 char *directory_title;
105 char *dialog_title, *pre, *suf;
107 name_field_title = XtNewString(GETMESSAGE(11, 12, "Enter Icon Filename"));
108 container_title = XtNewString(GETMESSAGE(11, 11, "Icon Files"));
109 directory_title = XtNewString(GETMESSAGE(11, 30, "Icon Folders"));
111 pre = GETMESSAGE(3, 10, "Create Action");
112 suf = GETMESSAGE(6, 18, "Find Set");
113 dialog_title = XtMalloc(strlen(pre) + strlen(suf) + 4);
114 sprintf(dialog_title, "%s - %s", pre, suf);
117 printf("activate Find Set button; client_data = %p\n", cdata); /* debug */
120 XtVaGetValues (COLOR_MONO_OPTION, XmNset, &use_bm, NULL);
122 if (use_bm) file_filter = use_bm_filter;
123 else file_filter = use_pm_filter;
125 #ifndef _ICONSELECTOR_DESTROY_ENABLED
127 #endif /* _ICONSELECTOR_DESTROY_ENABLED */
128 IconSelector = create_icon_selection_dialog ((swidget) CreateActionAppShell,
129 (unsigned char *)dialog_title,
130 (unsigned char *)filter_field_title,
132 (unsigned char *)file_filter,
133 (unsigned char *)directory_title,
134 (unsigned char **)directories_list,
135 (unsigned char *)container_title,
137 (unsigned char *)top_button_one_label,
138 (void (*)())top_button_one_cb,
139 (unsigned char *)top_button_two_label,
140 (void (*)())top_button_two_cb,
141 (unsigned char *)top_button_three_label,
142 (void (*)())top_button_three_cb,
144 (unsigned char *)name_field_title,
145 numberOfBottomButtons,
146 (unsigned char *)bottom_button_one_label,
147 (void (*)())bottom_button_one_cb,
148 (unsigned char *)bottom_button_two_label,
149 (void (*)())bottom_button_two_cb,
150 (unsigned char *)bottom_button_three_label,
151 (void (*)())bottom_button_three_cb,
152 (unsigned char *)bottom_button_four_label,
153 (void (*)())bottom_button_four_cb);
154 #ifndef _ICONSELECTOR_DESTROY_ENABLED
156 #endif /* _ICONSELECTOR_DESTROY_ENABLED */
157 XtFree(name_field_title);
158 XtFree(container_title);
159 XtFree(directory_title);
160 XtFree(dialog_title);
161 FreeIconSearchPathList(directories_list);
162 XtVaSetValues (IconSelector, XmNuserData, cdata, NULL);
163 UxPopupInterface (IconSelector, no_grab);
164 XmProcessTraversal(ISD_SelectedIconTextField, XmTRAVERSE_CURRENT);
168 /******************************************************************************/
170 /* createCB_IconGadget */
172 /* INPUT: Widget wid - icon gadget windet id */
173 /* Boolean bActionIcons - is this an action widget */
174 /* enum icon_size_range - size of icon this widget represents */
178 /******************************************************************************/
179 void createCB_IconGadget(Widget wid,
180 Boolean bActionIcons,
181 enum icon_size_range IconSize)
185 (char *)((bActionIcons) ?
186 ca_full_icon_default : af_full_icon_default),
191 /******************************************************************************/
192 /* activateCB_edit_icon - brings up icon editor with selected icon */
194 /* INPUT: Widget wid - widget id */
195 /* XtPointer cd - client data */
196 /* XmPushButtonCallbackStruct *cbs - callback data */
199 /******************************************************************************/
200 void activateCB_edit_icon (Widget wid, XtPointer client_data,
201 XmPushButtonCallbackStruct *cbs)
204 Boolean IsActionIcons;
206 if (bIconEditorDisplayed) return;
208 if ((int)(XtArgVal)client_data == CA_ACTION_ICONS) {
209 IsActionIcons = True;
210 widSelectedIcon = get_selected_action_icon();
211 widEditSource = CreateActionAppShell;
213 IsActionIcons = False;
214 widSelectedIcon = (Widget)get_selected_filetype_icon();
215 widEditSource = AddFiletype;
217 XtVaGetValues (widSelectedIcon, XmNimageName, &pszIconToEdit, NULL);
219 /***************************************************************/
220 /* Call routine to send tooltalk message to start icon editor. */
221 /***************************************************************/
222 UxDoEditPixmap(widSelectedIcon, pszIconToEdit);
227 /* We use this so we can reuse an open help dialog window. */
228 static Widget mainHelpDialog = NULL;
230 /******************************************************************************/
232 /* closeCB_mainHelpDialog */
234 /* INPUT: Widget wid - widget id */
235 /* XtPointer cd - client data */
236 /* XtPointer cbs - callback data */
239 /******************************************************************************/
240 void closeCB_mainHelpDialog(Widget wid, XtPointer client_data,
243 XtDestroyWidget(wid);
244 mainHelpDialog = NULL;
247 /******************************************************************************/
249 /* DisplayHelpDialog */
251 /* INPUT: Widget wid - widget id */
252 /* XtPointer cd - client data */
253 /* XtPointer cbs - callback data */
256 /******************************************************************************/
257 void DisplayHelpDialog(Widget wid, XtPointer client_data, XtPointer cbs)
262 char pszTitle[MAXBUFSIZE];
263 char pszTopic[MAXBUFSIZE];
267 /***********************************************************************/
268 /* Get help dialog window title. */
269 /***********************************************************************/
271 sprintf(pszTitle, "%s - %s", GETMESSAGE(3, 10, "Create Action"),
272 GETMESSAGE(2, 53, "Help"));
274 snprintf(pszTitle, sizeof(pszTitle), "%s - %s", GETMESSAGE(3, 10, "Create Action"), GETMESSAGE(2, 53, "Help"));
275 XtSetArg(args[i], XmNtitle, pszTitle); i++;
277 /***********************************************************************/
278 /* Now set the particular helpvolume and topic to view */
279 /***********************************************************************/
280 XtSetArg(args[i], DtNhelpType, DtHELP_TYPE_TOPIC); i++;
281 XtSetArg(args[i], DtNhelpVolume, "CreatAct"); i++;
282 XtSetArg(args[i], DtNlocationId, pszTopic); i++;
284 switch ((XtArgVal)client_data) {
286 strcpy(pszTopic, "_hometopic");
289 strcpy(pszTopic, "Tasks");
292 strcpy(pszTopic, "Reference");
295 strcpy(pszTopic, "_HOMETOPIC");
296 XtSetArg(args[i], DtNhelpVolume, "Help4Help"); i++;
299 strcpy(pszTopic, "_copyright");
302 strcpy(pszTopic, "CreateActionMainWindow");
304 case HELP_ADDFILETYPE:
305 strcpy(pszTopic, "AddDatatypeWindow");
308 strcpy(pszTopic, "DatatypeCriteriaWindow");
310 case HELP_ICONSELECTOR:
311 strcpy(pszTopic, "FindIconSetDialog");
314 strcpy(pszTopic, "openDialog");
318 /***********************************************************************/
319 /* Create the Help dialog. */
320 /***********************************************************************/
321 /* **** old method of getting parent ****
322 XtVaGetValues(wid, XmNuserData, &parent, NULL);
327 parent = GetTrueToplevel(wid);
328 TurnOnHourGlassAllWindows();
329 if ( mainHelpDialog == NULL ) {
330 mainHelpDialog = DtCreateHelpDialog(parent, "mainHelpDialog", args, i);
331 XtAddCallback(mainHelpDialog, DtNcloseCallback,
332 (void (*)())closeCB_mainHelpDialog,
334 XtManageChild(mainHelpDialog);
336 XtSetValues( mainHelpDialog, args, i );
338 TurnOffHourGlassAllWindows();
340 /******************************************************************************/
344 /* INPUT: Widget wid - widget id */
345 /* XtPointer cd - client data */
346 /* XtPointer cbs - callback data */
349 /******************************************************************************/
350 void helpCB_general(Widget UxWidget,
351 XtPointer UxClientData,
352 XtPointer UxCallbackArg)
355 DisplayHelpDialog(UxWidget, UxClientData, UxCallbackArg);