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"
45 #include "icon_selection_dialog.h"
48 /******************************************************************************/
49 /* Initialize global values. */
50 /******************************************************************************/
51 Boolean bRegisteredSignal = FALSE;
52 int (*sigchildRoutine)();
54 /******************************************************************************/
55 /* activateCB_open_FindSet - Callback for the "Find Set" button on */
56 /* CreateActionAppShell and AddFiletype windows. */
57 /* This callback will pop up the Icon Selection */
60 /* INPUT: Widget filesel - file selection box widget id */
61 /* XtPointer cdata - client data */
62 /* XmFileSelectionBoxCallbackStruct *cbstruct - callback data */
66 /******************************************************************************/
67 void activateCB_open_FindSet (Widget find_set_button, XtPointer cdata,
68 XmFileSelectionBoxCallbackStruct *cbstruct)
71 Boolean use_bm = False;
72 static char *use_bm_filter = "*.m.bm";
73 static char *use_pm_filter = "*.m.pm";
75 char *filter_field_title = NULL;
76 int use_filter_field = False;
79 char **directories_list = GetIconSearchPathList();
80 int numberOfTopButtons = 0;
81 void *top_button_one_cb = NULL;
82 void *top_button_two_cb = NULL;
83 void *top_button_three_cb = NULL;
84 char *top_button_one_label = NULL;
85 char *top_button_two_label = NULL;
86 char *top_button_three_label = NULL;
87 int use_icon_name_field = True;
88 int numberOfBottomButtons = 3;
89 void *bottom_button_one_cb = (void *)load_icons;
90 void *bottom_button_two_cb = NULL;
91 void *bottom_button_three_cb = NULL;
92 void *bottom_button_four_cb = NULL;
93 char *bottom_button_one_label = NULL; /* use default */
94 char *bottom_button_two_label = NULL; /* use default */
95 char *bottom_button_three_label = NULL; /* use default */
96 char *bottom_button_four_label = NULL; /* use default */
98 char *name_field_title;
99 char *container_title;
100 char *directory_title;
101 char *dialog_title, *pre, *suf;
103 name_field_title = XtNewString(GETMESSAGE(11, 12, "Enter Icon Filename"));
104 container_title = XtNewString(GETMESSAGE(11, 11, "Icon Files"));
105 directory_title = XtNewString(GETMESSAGE(11, 30, "Icon Folders"));
107 pre = GETMESSAGE(3, 10, "Create Action");
108 suf = GETMESSAGE(6, 18, "Find Set");
109 dialog_title = XtMalloc(strlen(pre) + strlen(suf) + 2);
110 sprintf(dialog_title, "%s - %s", pre, suf);
113 printf("activate Find Set button; client_data = %p\n", cdata); /* debug */
116 XtVaGetValues (COLOR_MONO_OPTION, XmNset, &use_bm, NULL);
118 if (use_bm) file_filter = use_bm_filter;
119 else file_filter = use_pm_filter;
121 #ifndef _ICONSELECTOR_DESTROY_ENABLED
123 #endif /* _ICONSELECTOR_DESTROY_ENABLED */
124 IconSelector = create_icon_selection_dialog ((swidget) CreateActionAppShell,
125 (unsigned char *)dialog_title,
126 (unsigned char *)filter_field_title,
128 (unsigned char *)file_filter,
129 (unsigned char *)directory_title,
130 (unsigned char **)directories_list,
131 (unsigned char *)container_title,
133 (unsigned char *)top_button_one_label,
134 (void (*)())top_button_one_cb,
135 (unsigned char *)top_button_two_label,
136 (void (*)())top_button_two_cb,
137 (unsigned char *)top_button_three_label,
138 (void (*)())top_button_three_cb,
140 (unsigned char *)name_field_title,
141 numberOfBottomButtons,
142 (unsigned char *)bottom_button_one_label,
143 (void (*)())bottom_button_one_cb,
144 (unsigned char *)bottom_button_two_label,
145 (void (*)())bottom_button_two_cb,
146 (unsigned char *)bottom_button_three_label,
147 (void (*)())bottom_button_three_cb,
148 (unsigned char *)bottom_button_four_label,
149 (void (*)())bottom_button_four_cb);
150 #ifndef _ICONSELECTOR_DESTROY_ENABLED
152 #endif /* _ICONSELECTOR_DESTROY_ENABLED */
153 XtFree(name_field_title);
154 XtFree(container_title);
155 XtFree(directory_title);
156 XtFree(dialog_title);
157 FreeIconSearchPathList(directories_list);
158 XtVaSetValues (IconSelector, XmNuserData, cdata, NULL);
159 UxPopupInterface (IconSelector, no_grab);
160 XmProcessTraversal(ISD_SelectedIconTextField, XmTRAVERSE_CURRENT);
164 /******************************************************************************/
166 /* createCB_IconGadget */
168 /* INPUT: Widget wid - icon gadget windet id */
169 /* Boolean bActionIcons - is this an action widget */
170 /* enum icon_size_range - size of icon this widget represents */
174 /******************************************************************************/
175 void createCB_IconGadget(Widget wid,
176 Boolean bActionIcons,
177 enum icon_size_range IconSize)
181 (char *)((bActionIcons) ?
182 ca_full_icon_default : af_full_icon_default),
187 /******************************************************************************/
188 /* activateCB_edit_icon - brings up icon editor with selected icon */
190 /* INPUT: Widget wid - widget id */
191 /* XtPointer cd - client data */
192 /* XmPushButtonCallbackStruct *cbs - callback data */
195 /******************************************************************************/
196 void activateCB_edit_icon (Widget wid, XtPointer client_data,
197 XmPushButtonCallbackStruct *cbs)
200 Boolean IsActionIcons;
202 if (bIconEditorDisplayed) return;
204 if ((int)client_data == CA_ACTION_ICONS) {
205 IsActionIcons = True;
206 widSelectedIcon = get_selected_action_icon();
207 widEditSource = CreateActionAppShell;
209 IsActionIcons = False;
210 widSelectedIcon = (Widget)get_selected_filetype_icon();
211 widEditSource = AddFiletype;
213 XtVaGetValues (widSelectedIcon, XmNimageName, &pszIconToEdit, NULL);
215 /***************************************************************/
216 /* Call routine to send tooltalk message to start icon editor. */
217 /***************************************************************/
218 UxDoEditPixmap(widSelectedIcon, pszIconToEdit);
223 /******************************************************************************/
225 /* closeCB_mainHelpDialog */
227 /* INPUT: Widget wid - widget id */
228 /* XtPointer cd - client data */
229 /* XtPointer cbs - callback data */
232 /******************************************************************************/
233 void closeCB_mainHelpDialog(Widget wid, XtPointer client_data,
236 XtDestroyWidget(wid);
239 /******************************************************************************/
241 /* DisplayHelpDialog */
243 /* INPUT: Widget wid - widget id */
244 /* XtPointer cd - client data */
245 /* XtPointer cbs - callback data */
248 /******************************************************************************/
249 void DisplayHelpDialog(Widget wid, XtPointer client_data, XtPointer cbs)
251 static Widget mainHelpDialog = NULL;
255 char pszTitle[MAXBUFSIZE];
256 char pszTopic[MAXBUFSIZE];
260 /***********************************************************************/
261 /* Get help dialog window title. */
262 /***********************************************************************/
264 sprintf(pszTitle, "%s - %s", GETMESSAGE(3, 10, "Create Action"),
265 GETMESSAGE(2, 53, "Help"));
267 sprintf(pszTitle, "%s - ", GETMESSAGE(3, 10, "Create Action"));
268 strcat(pszTitle, GETMESSAGE(2, 53, "Help"));
269 XtSetArg(args[i], XmNtitle, pszTitle); i++;
271 /***********************************************************************/
272 /* Now set the particular helpvolume and topic to view */
273 /***********************************************************************/
274 XtSetArg(args[i], DtNhelpType, DtHELP_TYPE_TOPIC); i++;
275 XtSetArg(args[i], DtNhelpVolume, "CreatAct"); i++;
276 XtSetArg(args[i], DtNlocationId, pszTopic); i++;
278 switch ((int)client_data) {
280 strcpy(pszTopic, "_hometopic");
283 strcpy(pszTopic, "Tasks");
286 strcpy(pszTopic, "Reference");
289 strcpy(pszTopic, "_HOMETOPIC");
290 XtSetArg(args[i], DtNhelpVolume, "Help4Help"); i++;
293 strcpy(pszTopic, "_copyright");
296 strcpy(pszTopic, "CreateActionMainWindow");
298 case HELP_ADDFILETYPE:
299 strcpy(pszTopic, "AddDatatypeWindow");
302 strcpy(pszTopic, "DatatypeCriteriaWindow");
304 case HELP_ICONSELECTOR:
305 strcpy(pszTopic, "FindIconSetDialog");
308 strcpy(pszTopic, "openDialog");
312 /***********************************************************************/
313 /* Create the Help dialog. */
314 /***********************************************************************/
315 /* **** old method of getting parent ****
316 XtVaGetValues(wid, XmNuserData, &parent, NULL);
321 parent = GetTrueToplevel(wid);
322 TurnOnHourGlassAllWindows();
323 if ( mainHelpDialog == NULL ) {
324 mainHelpDialog = DtCreateHelpDialog(parent, "mainHelpDialog", args, i);
325 XtAddCallback(mainHelpDialog, DtNcloseCallback,
326 (void (*)())closeCB_mainHelpDialog,
328 XtManageChild(mainHelpDialog);
330 XtSetValues( mainHelpDialog, args, i );
332 TurnOffHourGlassAllWindows();
334 /******************************************************************************/
338 /* INPUT: Widget wid - widget id */
339 /* XtPointer cd - client data */
340 /* XtPointer cbs - callback data */
343 /******************************************************************************/
344 void helpCB_general(Widget UxWidget,
345 XtPointer UxClientData,
346 XtPointer UxCallbackArg)
349 DisplayHelpDialog(UxWidget, UxClientData, UxCallbackArg);