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 librararies 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/signal.h>
33 #include <X11/cursorfont.h>
37 #include <Dt/HelpDialog.h>
43 #include "CreateActionAppShell.h"
46 #include "icon_selection_dialog.h"
49 extern void UxDoEditPixmap(Widget wid, char *fname);
51 /******************************************************************************/
52 /* Initialize global values. */
53 /******************************************************************************/
54 Boolean bRegisteredSignal = FALSE;
55 int (*sigchildRoutine)();
57 /******************************************************************************/
58 /* activateCB_open_FindSet - Callback for the "Find Set" button on */
59 /* CreateActionAppShell and AddFiletype windows. */
60 /* This callback will pop up the Icon Selection */
63 /* INPUT: Widget filesel - file selection box widget id */
64 /* XtPointer cdata - client data */
65 /* XmFileSelectionBoxCallbackStruct *cbstruct - callback data */
69 /******************************************************************************/
70 void activateCB_open_FindSet (Widget find_set_button, XtPointer cdata,
71 XmFileSelectionBoxCallbackStruct *cbstruct)
74 XtArgVal /* Boolean */ use_bm = False;
75 static char *use_bm_filter = "*.m.bm";
76 static char *use_pm_filter = "*.m.pm";
78 char *filter_field_title = NULL;
79 int use_filter_field = False;
82 char **directories_list = GetIconSearchPathList();
83 int numberOfTopButtons = 0;
84 void *top_button_one_cb = NULL;
85 void *top_button_two_cb = NULL;
86 void *top_button_three_cb = NULL;
87 char *top_button_one_label = NULL;
88 char *top_button_two_label = NULL;
89 char *top_button_three_label = NULL;
90 int use_icon_name_field = True;
91 int numberOfBottomButtons = 3;
92 void *bottom_button_one_cb = (void *)load_icons;
93 void *bottom_button_two_cb = NULL;
94 void *bottom_button_three_cb = NULL;
95 void *bottom_button_four_cb = NULL;
96 char *bottom_button_one_label = NULL; /* use default */
97 char *bottom_button_two_label = NULL; /* use default */
98 char *bottom_button_three_label = NULL; /* use default */
99 char *bottom_button_four_label = NULL; /* use default */
101 char *name_field_title;
102 char *container_title;
103 char *directory_title;
104 char *dialog_title, *pre, *suf;
106 name_field_title = XtNewString(GETMESSAGE(11, 12, "Enter Icon Filename"));
107 container_title = XtNewString(GETMESSAGE(11, 11, "Icon Files"));
108 directory_title = XtNewString(GETMESSAGE(11, 30, "Icon Folders"));
110 pre = GETMESSAGE(3, 10, "Create Action");
111 suf = GETMESSAGE(6, 18, "Find Set");
112 dialog_title = XtMalloc(strlen(pre) + strlen(suf) + 4);
113 sprintf(dialog_title, "%s - %s", pre, suf);
116 printf("activate Find Set button; client_data = %p\n", cdata); /* debug */
119 XtVaGetValues (COLOR_MONO_OPTION, XmNset, &use_bm, NULL);
121 if (use_bm) file_filter = use_bm_filter;
122 else file_filter = use_pm_filter;
124 #ifndef _ICONSELECTOR_DESTROY_ENABLED
126 #endif /* _ICONSELECTOR_DESTROY_ENABLED */
127 IconSelector = create_icon_selection_dialog ((swidget) CreateActionAppShell,
128 (unsigned char *)dialog_title,
129 (unsigned char *)filter_field_title,
131 (unsigned char *)file_filter,
132 (unsigned char *)directory_title,
133 (unsigned char **)directories_list,
134 (unsigned char *)container_title,
136 (unsigned char *)top_button_one_label,
137 (void (*)())top_button_one_cb,
138 (unsigned char *)top_button_two_label,
139 (void (*)())top_button_two_cb,
140 (unsigned char *)top_button_three_label,
141 (void (*)())top_button_three_cb,
143 (unsigned char *)name_field_title,
144 numberOfBottomButtons,
145 (unsigned char *)bottom_button_one_label,
146 (void (*)())bottom_button_one_cb,
147 (unsigned char *)bottom_button_two_label,
148 (void (*)())bottom_button_two_cb,
149 (unsigned char *)bottom_button_three_label,
150 (void (*)())bottom_button_three_cb,
151 (unsigned char *)bottom_button_four_label,
152 (void (*)())bottom_button_four_cb);
153 #ifndef _ICONSELECTOR_DESTROY_ENABLED
155 #endif /* _ICONSELECTOR_DESTROY_ENABLED */
156 XtFree(name_field_title);
157 XtFree(container_title);
158 XtFree(directory_title);
159 XtFree(dialog_title);
160 FreeIconSearchPathList(directories_list);
161 XtVaSetValues (IconSelector, XmNuserData, cdata, NULL);
162 UxPopupInterface (IconSelector, no_grab);
163 XmProcessTraversal(ISD_SelectedIconTextField, XmTRAVERSE_CURRENT);
167 /******************************************************************************/
169 /* createCB_IconGadget */
171 /* INPUT: Widget wid - icon gadget windet id */
172 /* Boolean bActionIcons - is this an action widget */
173 /* enum icon_size_range - size of icon this widget represents */
177 /******************************************************************************/
178 void createCB_IconGadget(Widget wid,
179 Boolean bActionIcons,
180 enum icon_size_range IconSize)
184 (char *)((bActionIcons) ?
185 ca_full_icon_default : af_full_icon_default),
190 /******************************************************************************/
191 /* activateCB_edit_icon - brings up icon editor with selected icon */
193 /* INPUT: Widget wid - widget id */
194 /* XtPointer cd - client data */
195 /* XmPushButtonCallbackStruct *cbs - callback data */
198 /******************************************************************************/
199 void activateCB_edit_icon (Widget wid, XtPointer client_data,
200 XmPushButtonCallbackStruct *cbs)
203 Boolean IsActionIcons;
205 if (bIconEditorDisplayed) return;
207 if ((int)(XtArgVal)client_data == CA_ACTION_ICONS) {
208 IsActionIcons = True;
209 widSelectedIcon = get_selected_action_icon();
210 widEditSource = CreateActionAppShell;
212 IsActionIcons = False;
213 widSelectedIcon = (Widget)get_selected_filetype_icon();
214 widEditSource = AddFiletype;
216 XtVaGetValues (widSelectedIcon, XmNimageName, &pszIconToEdit, NULL);
218 /***************************************************************/
219 /* Call routine to send tooltalk message to start icon editor. */
220 /***************************************************************/
221 UxDoEditPixmap(widSelectedIcon, pszIconToEdit);
226 /* We use this so we can reuse an open help dialog window. */
227 static Widget mainHelpDialog = NULL;
229 /******************************************************************************/
231 /* closeCB_mainHelpDialog */
233 /* INPUT: Widget wid - widget id */
234 /* XtPointer cd - client data */
235 /* XtPointer cbs - callback data */
238 /******************************************************************************/
239 void closeCB_mainHelpDialog(Widget wid, XtPointer client_data,
242 XtDestroyWidget(wid);
243 mainHelpDialog = NULL;
246 /******************************************************************************/
248 /* DisplayHelpDialog */
250 /* INPUT: Widget wid - widget id */
251 /* XtPointer cd - client data */
252 /* XtPointer cbs - callback data */
255 /******************************************************************************/
256 void DisplayHelpDialog(Widget wid, XtPointer client_data, XtPointer cbs)
261 char pszTitle[MAXBUFSIZE];
262 char pszTopic[MAXBUFSIZE];
266 /***********************************************************************/
267 /* Get help dialog window title. */
268 /***********************************************************************/
270 sprintf(pszTitle, "%s - %s", GETMESSAGE(3, 10, "Create Action"),
271 GETMESSAGE(2, 53, "Help"));
273 sprintf(pszTitle, "%s - ", GETMESSAGE(3, 10, "Create Action"));
274 strcat(pszTitle, 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);