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 /*******************************************************************************
27 ** $TOG: tempbr.c /main/5 1999/02/23 09:42:53 mgreess $
29 ** RESTRICTED CONFIDENTIAL INFORMATION:
31 ** The information in this document is subject to special
32 ** restrictions in a confidential disclosure agreement between
33 ** HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
34 ** document outside HP, IBM, Sun, USL, SCO, or Univel without
35 ** Sun's specific written approval. This document and all copies
36 ** and derivative works thereof must be returned or destroyed at
39 ** Copyright 1993 Sun Microsystems, Inc. All rights reserved.
41 *******************************************************************************/
44 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
45 * (c) Copyright 1993, 1994 International Business Machines Corp. *
46 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
47 * (c) Copyright 1993, 1994 Novell, Inc. *
51 static char sccsid[] = "@(#)tempbr.c 1.48 95/03/28 Copyr 1991 Sun Microsystems, Inc.";
54 #include <EUSCompat.h>
59 #include <Xm/LabelG.h>
61 #include <Xm/DialogS.h>
63 #include <Xm/PushBG.h>
64 #include <Xm/RowColumn.h>
66 #include <Xm/SeparatoG.h>
69 #include <Xm/ToggleBG.h>
70 #include <Xm/XmStrDefs.h>
71 #include <Xm/MwmUtil.h>
72 #include <Dt/HourGlass.h>
80 #include "datefield.h"
89 static void tb_cancel_cb();
90 static void tb_close_cb();
91 static void tempbr_show_cb(Widget w, XtPointer data, XtPointer cbs);
92 extern char *strdup(const char *);
95 /* This stuff is currently broken */
97 tempbr_sundex_ttedit_cb(
101 unsigned char *contents,
106 char *user_str = "user:";
109 Tempbr *tb = (Tempbr *)c_data;
111 cmfns_name_to_namepanel(contents, tb->np);
113 /* XXX Yech, but hell it is just a demo */
114 if (strncmp(user_str, (char *)contents, strlen(user_str)) == 0) {
115 p = strchr((char *)contents, ':');
118 p = (char *)contents;
121 XmTextFieldSetString(tb->name_text, p);
126 tempbr_sundex_cb(Widget w, XtPointer data, XtPointer cbs)
128 Tempbr *tb = (Tempbr *)data;
129 Tt_message msg = NULL;
132 msg = ttmedia_load(0, (Ttmedia_load_msg_cb)tempbr_sundex_ttedit_cb,
133 tb, TTME_EDIT, "Sun_Info", data, strlen(data) + 1,
134 NULL, "calendar-address", 0);
136 status = tt_ptr_error(msg);
137 if (tt_is_err(status)) {
138 fprintf(stderr, "dtcm: ttmedia_load: %s\n",
139 tt_status_message(status));
143 status = tt_message_send(msg);
144 if (tt_is_err(status)) {
145 fprintf(stderr, "dtcm: tt_message_send: %s\n",
146 tt_status_message(status));
151 #endif /* FNS_DEMO */
154 tempbr_show_cb(Widget w, XtPointer data, XtPointer cbs)
156 Calendar *c = calendar;
158 Tempbr *tb = (Tempbr *)data;
162 if ((name = XmTextGetString(tb->name_text)) == NULL) {
166 _DtTurnOnHourGlass(tb->frame);
169 if (cmfns_use_fns((Props *)c->properties)) {
170 sprintf(msg_buf, catgets(c->DT_catd, 1, 647,
171 "Looking up %s..."), name);
172 set_message(tb->show_message, msg_buf);
173 XmUpdateDisplay(tb->show_message);
174 XFlush(XtDisplay(w));
175 /* Translate name to a calendar address */
176 cmfns_lookup_calendar(name, buf, sizeof(buf));
181 sprintf(msg_buf, catgets(c->DT_catd, 1, 559, "Browsing %s..."),
183 set_message(tb->show_message, msg_buf);
184 XFlush(XtDisplay(w));
185 switch_it(tb->cal, name, tempbrowser);
186 _DtTurnOffHourGlass(tb->frame);
191 make_std_tempbr(Calendar *c)
195 Widget separator, button_form;
198 if (c->tempbr == NULL) {
199 c->tempbr = (caddr_t)ckalloc(sizeof(Tempbr));
200 tb = (Tempbr*)c->tempbr;
203 tb = (Tempbr*)c->tempbr;
205 title = XtNewString(catgets(c->DT_catd, 1, 560, "Calendar : Show Other Calendar"));
206 tb->frame = XtVaCreatePopupShell("frame",
207 xmDialogShellWidgetClass, c->frame,
209 XmNallowShellResize, True,
210 XmNmappedWhenManaged, False,
214 tb->form = XtVaCreateWidget("form",
217 XmNautoUnmanage, False,
219 XmNhorizontalSpacing, 4,
220 XmNverticalSpacing, 4,
225 label_str = XmStringCreateLocalized(
226 catgets(c->DT_catd, 1, 410, "User Name:"));
227 tb->name_label = XtVaCreateWidget("name_label",
230 XmNlabelString, label_str,
231 XmNleftAttachment, XmATTACH_FORM,
233 XmNtopAttachment, XmATTACH_FORM,
236 XmStringFree(label_str);
238 tb->name_text = XtVaCreateWidget("show_text",
241 XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
242 XmNbottomWidget, tb->name_label,
244 XmNleftAttachment, XmATTACH_WIDGET,
245 XmNleftWidget, tb->name_label,
246 XmNrightAttachment, XmATTACH_POSITION,
252 separator = XtVaCreateWidget("separator",
253 xmSeparatorGadgetClass,
255 XmNleftAttachment, XmATTACH_FORM,
256 XmNrightAttachment, XmATTACH_FORM,
257 XmNtopAttachment, XmATTACH_WIDGET,
258 XmNtopWidget, tb->name_text,
262 button_form = XtVaCreateWidget("form",
265 XmNautoUnmanage, False,
266 XmNleftAttachment, XmATTACH_FORM,
268 XmNrightAttachment, XmATTACH_FORM,
270 XmNtopAttachment, XmATTACH_WIDGET,
271 XmNtopWidget, separator,
272 XmNhorizontalSpacing, 4,
276 label_str = XmStringCreateLocalized(
277 catgets(c->DT_catd, 1, 562, "Show"));
278 tb->show_button = XtVaCreateWidget("show_button",
279 xmPushButtonWidgetClass,
281 XmNlabelString, label_str,
282 XmNtopAttachment, XmATTACH_WIDGET,
283 XmNtopWidget, separator,
284 XmNleftAttachment, XmATTACH_POSITION,
286 XmNrightAttachment, XmATTACH_POSITION,
288 XmNnavigationType, XmTAB_GROUP,
290 XmStringFree(label_str);
292 label_str = XmStringCreateLocalized(
293 catgets(c->DT_catd, 1, 680, "Close"));
294 tb->cancel_button = XtVaCreateWidget("cancelButton",
295 xmPushButtonWidgetClass,
297 XmNlabelString, label_str,
298 XmNtopAttachment, XmATTACH_WIDGET,
299 XmNtopWidget, separator,
300 XmNleftAttachment, XmATTACH_POSITION,
302 XmNrightAttachment, XmATTACH_POSITION,
306 XmStringFree(label_str);
307 XtAddCallback(tb->cancel_button,
308 XmNactivateCallback, tb_cancel_cb, NULL);
310 label_str = XmStringCreateLocalized(catgets(c->DT_catd, 1, 77, "Help"));
311 tb->help_button = XtVaCreateWidget("helpButton",
312 xmPushButtonWidgetClass, button_form,
313 XmNlabelString, label_str,
314 XmNtopAttachment, XmATTACH_WIDGET,
315 XmNtopWidget, separator,
316 XmNleftAttachment, XmATTACH_POSITION,
318 XmNrightAttachment, XmATTACH_POSITION,
321 XmStringFree(label_str);
322 XtAddCallback(tb->help_button, XmNactivateCallback,
323 (XtCallbackProc)help_cb, SHOW_OTHER_CAL_HELP_BUTTON);
324 XtAddCallback(tb->form, XmNhelpCallback,
325 (XtCallbackProc)help_cb, (XtPointer) SHOW_OTHER_CAL_HELP_BUTTON);
327 #ifdef FNS_SUNDEX_DEMO
328 label_str = XmStringCreateLocalized(catgets(c->DT_catd, 1, 648,
330 tb->show_button = XtVaCreateWidget("sundex_button",
331 xmPushButtonWidgetClass, tb->form,
332 XmNlabelString, label_str,
333 XmNtopAttachment, XmATTACH_FORM,
335 XmNleftAttachment, XmATTACH_WIDGET,
336 XmNleftWidget, tb->name_text,
339 XmStringFree(label_str);
340 XtAddCallback(tb->show_button, XmNactivateCallback,
341 tempbr_sundex_cb, tb);
344 tb->show_message = XtVaCreateWidget("show_message",
345 xmLabelGadgetClass, tb->form,
346 XmNalignment, XmALIGNMENT_BEGINNING,
347 XmNtopAttachment, XmATTACH_WIDGET,
348 XmNtopWidget, tb->cancel_button,
349 XmNleftAttachment, XmATTACH_FORM,
350 XmNrightAttachment, XmATTACH_FORM,
351 XmNbottomAttachment, XmATTACH_FORM,
354 set_message(tb->show_message, "");
356 XtAddCallback(tb->show_button, XmNactivateCallback,
358 ds_position_popup(c->frame, tb->frame, DS_POPUP_LOR);
360 /* set default button */
361 XtVaSetValues(button_form,
362 XmNdefaultButton, tb->show_button,
363 XmNcancelButton, tb->show_button,
365 XtVaSetValues(tb->form,
366 XmNdefaultButton, tb->show_button,
367 XmNcancelButton, tb->show_button,
370 XmProcessTraversal(tb->name_text, XmTRAVERSE_CURRENT);
371 XtVaSetValues(tb->form, XmNinitialFocus, tb->name_text, NULL);
373 ManageChildren(button_form);
374 ManageChildren(tb->form);
375 XtManageChild(tb->form);
376 XtVaSetValues(tb->frame, XmNmappedWhenManaged, True, NULL);
377 XtRealizeWidget(tb->frame);
379 XtPopup(tb->frame, XtGrabNone);
385 make_tempbr(Calendar *c)
389 tb = make_std_tempbr(c);
390 ((Tempbr *)tb)->cal = c;
398 XtPointer client_data,
399 XmPushButtonCallbackStruct *cbs)
404 XtVaGetValues(widget, XmNuserData, &c, NULL);
405 tb = (Tempbr *)c->tempbr;
407 XmTextSetString(tb->name_text, "");
408 XtPopdown(tb->frame);
414 tb_close_cb(Widget w, XtPointer data, XtPointer cbs)
416 Tempbr *tb = (Tempbr *)data;
418 XtPopdown(tb->frame);