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) + 4);
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 /* We use this so we can reuse an open help dialog window. */
224 static Widget mainHelpDialog = NULL;
226 /******************************************************************************/
228 /* closeCB_mainHelpDialog */
230 /* INPUT: Widget wid - widget id */
231 /* XtPointer cd - client data */
232 /* XtPointer cbs - callback data */
235 /******************************************************************************/
236 void closeCB_mainHelpDialog(Widget wid, XtPointer client_data,
239 XtDestroyWidget(wid);
240 mainHelpDialog = NULL;
243 /******************************************************************************/
245 /* DisplayHelpDialog */
247 /* INPUT: Widget wid - widget id */
248 /* XtPointer cd - client data */
249 /* XtPointer cbs - callback data */
252 /******************************************************************************/
253 void DisplayHelpDialog(Widget wid, XtPointer client_data, XtPointer cbs)
258 char pszTitle[MAXBUFSIZE];
259 char pszTopic[MAXBUFSIZE];
263 /***********************************************************************/
264 /* Get help dialog window title. */
265 /***********************************************************************/
267 sprintf(pszTitle, "%s - %s", GETMESSAGE(3, 10, "Create Action"),
268 GETMESSAGE(2, 53, "Help"));
270 sprintf(pszTitle, "%s - ", GETMESSAGE(3, 10, "Create Action"));
271 strcat(pszTitle, GETMESSAGE(2, 53, "Help"));
272 XtSetArg(args[i], XmNtitle, pszTitle); i++;
274 /***********************************************************************/
275 /* Now set the particular helpvolume and topic to view */
276 /***********************************************************************/
277 XtSetArg(args[i], DtNhelpType, DtHELP_TYPE_TOPIC); i++;
278 XtSetArg(args[i], DtNhelpVolume, "CreatAct"); i++;
279 XtSetArg(args[i], DtNlocationId, pszTopic); i++;
281 switch ((int)client_data) {
283 strcpy(pszTopic, "_hometopic");
286 strcpy(pszTopic, "Tasks");
289 strcpy(pszTopic, "Reference");
292 strcpy(pszTopic, "_HOMETOPIC");
293 XtSetArg(args[i], DtNhelpVolume, "Help4Help"); i++;
296 strcpy(pszTopic, "_copyright");
299 strcpy(pszTopic, "CreateActionMainWindow");
301 case HELP_ADDFILETYPE:
302 strcpy(pszTopic, "AddDatatypeWindow");
305 strcpy(pszTopic, "DatatypeCriteriaWindow");
307 case HELP_ICONSELECTOR:
308 strcpy(pszTopic, "FindIconSetDialog");
311 strcpy(pszTopic, "openDialog");
315 /***********************************************************************/
316 /* Create the Help dialog. */
317 /***********************************************************************/
318 /* **** old method of getting parent ****
319 XtVaGetValues(wid, XmNuserData, &parent, NULL);
324 parent = GetTrueToplevel(wid);
325 TurnOnHourGlassAllWindows();
326 if ( mainHelpDialog == NULL ) {
327 mainHelpDialog = DtCreateHelpDialog(parent, "mainHelpDialog", args, i);
328 XtAddCallback(mainHelpDialog, DtNcloseCallback,
329 (void (*)())closeCB_mainHelpDialog,
331 XtManageChild(mainHelpDialog);
333 XtSetValues( mainHelpDialog, args, i );
335 TurnOffHourGlassAllWindows();
337 /******************************************************************************/
341 /* INPUT: Widget wid - widget id */
342 /* XtPointer cd - client data */
343 /* XtPointer cbs - callback data */
346 /******************************************************************************/
347 void helpCB_general(Widget UxWidget,
348 XtPointer UxClientData,
349 XtPointer UxCallbackArg)
352 DisplayHelpDialog(UxWidget, UxClientData, UxCallbackArg);