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);
95 extern char *strdup(const char *);
99 /* This stuff is currently broken */
101 tempbr_sundex_ttedit_cb(
105 unsigned char *contents,
110 char *user_str = "user:";
113 Tempbr *tb = (Tempbr *)c_data;
115 cmfns_name_to_namepanel(contents, tb->np);
117 /* XXX Yech, but hell it is just a demo */
118 if (strncmp(user_str, (char *)contents, strlen(user_str)) == 0) {
119 p = strchr((char *)contents, ':');
122 p = (char *)contents;
125 XmTextFieldSetString(tb->name_text, p);
130 tempbr_sundex_cb(Widget w, XtPointer data, XtPointer cbs)
132 Tempbr *tb = (Tempbr *)data;
133 Tt_message msg = NULL;
136 msg = ttmedia_load(0, (Ttmedia_load_msg_cb)tempbr_sundex_ttedit_cb,
137 tb, TTME_EDIT, "Sun_Info", data, strlen(data) + 1,
138 NULL, "calendar-address", 0);
140 status = tt_ptr_error(msg);
141 if (tt_is_err(status)) {
142 fprintf(stderr, "dtcm: ttmedia_load: %s\n",
143 tt_status_message(status));
147 status = tt_message_send(msg);
148 if (tt_is_err(status)) {
149 fprintf(stderr, "dtcm: tt_message_send: %s\n",
150 tt_status_message(status));
155 #endif /* FNS_DEMO */
158 tempbr_show_cb(Widget w, XtPointer data, XtPointer cbs)
160 Calendar *c = calendar;
162 Tempbr *tb = (Tempbr *)data;
166 if ((name = XmTextGetString(tb->name_text)) == NULL) {
170 _DtTurnOnHourGlass(tb->frame);
173 if (cmfns_use_fns((Props *)c->properties)) {
174 sprintf(msg_buf, catgets(c->DT_catd, 1, 647,
175 "Looking up %s..."), name);
176 set_message(tb->show_message, msg_buf);
177 XmUpdateDisplay(tb->show_message);
178 XFlush(XtDisplay(w));
179 /* Translate name to a calendar address */
180 cmfns_lookup_calendar(name, buf, sizeof(buf));
185 sprintf(msg_buf, catgets(c->DT_catd, 1, 559, "Browsing %s..."),
187 set_message(tb->show_message, msg_buf);
188 XFlush(XtDisplay(w));
189 switch_it(tb->cal, name, tempbrowser);
190 _DtTurnOffHourGlass(tb->frame);
195 make_std_tempbr(Calendar *c)
199 Widget separator, button_form;
202 if (c->tempbr == NULL) {
203 c->tempbr = (caddr_t)ckalloc(sizeof(Tempbr));
204 tb = (Tempbr*)c->tempbr;
207 tb = (Tempbr*)c->tempbr;
209 title = XtNewString(catgets(c->DT_catd, 1, 560, "Calendar : Show Other Calendar"));
210 tb->frame = XtVaCreatePopupShell("frame",
211 xmDialogShellWidgetClass, c->frame,
213 XmNallowShellResize, True,
214 XmNmappedWhenManaged, False,
218 tb->form = XtVaCreateWidget("form",
221 XmNautoUnmanage, False,
223 XmNhorizontalSpacing, 4,
224 XmNverticalSpacing, 4,
229 label_str = XmStringCreateLocalized(
230 catgets(c->DT_catd, 1, 410, "User Name:"));
231 tb->name_label = XtVaCreateWidget("name_label",
234 XmNlabelString, label_str,
235 XmNleftAttachment, XmATTACH_FORM,
237 XmNtopAttachment, XmATTACH_FORM,
240 XmStringFree(label_str);
242 tb->name_text = XtVaCreateWidget("show_text",
245 XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
246 XmNbottomWidget, tb->name_label,
248 XmNleftAttachment, XmATTACH_WIDGET,
249 XmNleftWidget, tb->name_label,
250 XmNrightAttachment, XmATTACH_POSITION,
256 separator = XtVaCreateWidget("separator",
257 xmSeparatorGadgetClass,
259 XmNleftAttachment, XmATTACH_FORM,
260 XmNrightAttachment, XmATTACH_FORM,
261 XmNtopAttachment, XmATTACH_WIDGET,
262 XmNtopWidget, tb->name_text,
266 button_form = XtVaCreateWidget("form",
269 XmNautoUnmanage, False,
270 XmNleftAttachment, XmATTACH_FORM,
272 XmNrightAttachment, XmATTACH_FORM,
274 XmNtopAttachment, XmATTACH_WIDGET,
275 XmNtopWidget, separator,
276 XmNhorizontalSpacing, 4,
280 label_str = XmStringCreateLocalized(
281 catgets(c->DT_catd, 1, 562, "Show"));
282 tb->show_button = XtVaCreateWidget("show_button",
283 xmPushButtonWidgetClass,
285 XmNlabelString, label_str,
286 XmNtopAttachment, XmATTACH_WIDGET,
287 XmNtopWidget, separator,
288 XmNleftAttachment, XmATTACH_POSITION,
290 XmNrightAttachment, XmATTACH_POSITION,
292 XmNnavigationType, XmTAB_GROUP,
294 XmStringFree(label_str);
296 label_str = XmStringCreateLocalized(
297 catgets(c->DT_catd, 1, 680, "Close"));
298 tb->cancel_button = XtVaCreateWidget("cancelButton",
299 xmPushButtonWidgetClass,
301 XmNlabelString, label_str,
302 XmNtopAttachment, XmATTACH_WIDGET,
303 XmNtopWidget, separator,
304 XmNleftAttachment, XmATTACH_POSITION,
306 XmNrightAttachment, XmATTACH_POSITION,
310 XmStringFree(label_str);
311 XtAddCallback(tb->cancel_button,
312 XmNactivateCallback, tb_cancel_cb, NULL);
314 label_str = XmStringCreateLocalized(catgets(c->DT_catd, 1, 77, "Help"));
315 tb->help_button = XtVaCreateWidget("helpButton",
316 xmPushButtonWidgetClass, button_form,
317 XmNlabelString, label_str,
318 XmNtopAttachment, XmATTACH_WIDGET,
319 XmNtopWidget, separator,
320 XmNleftAttachment, XmATTACH_POSITION,
322 XmNrightAttachment, XmATTACH_POSITION,
325 XmStringFree(label_str);
326 XtAddCallback(tb->help_button, XmNactivateCallback,
327 (XtCallbackProc)help_cb, SHOW_OTHER_CAL_HELP_BUTTON);
328 XtAddCallback(tb->form, XmNhelpCallback,
329 (XtCallbackProc)help_cb, (XtPointer) SHOW_OTHER_CAL_HELP_BUTTON);
331 #ifdef FNS_SUNDEX_DEMO
332 label_str = XmStringCreateLocalized(catgets(c->DT_catd, 1, 648,
334 tb->show_button = XtVaCreateWidget("sundex_button",
335 xmPushButtonWidgetClass, tb->form,
336 XmNlabelString, label_str,
337 XmNtopAttachment, XmATTACH_FORM,
339 XmNleftAttachment, XmATTACH_WIDGET,
340 XmNleftWidget, tb->name_text,
343 XmStringFree(label_str);
344 XtAddCallback(tb->show_button, XmNactivateCallback,
345 tempbr_sundex_cb, tb);
348 tb->show_message = XtVaCreateWidget("show_message",
349 xmLabelGadgetClass, tb->form,
350 XmNalignment, XmALIGNMENT_BEGINNING,
351 XmNtopAttachment, XmATTACH_WIDGET,
352 XmNtopWidget, tb->cancel_button,
353 XmNleftAttachment, XmATTACH_FORM,
354 XmNrightAttachment, XmATTACH_FORM,
355 XmNbottomAttachment, XmATTACH_FORM,
358 set_message(tb->show_message, "");
360 XtAddCallback(tb->show_button, XmNactivateCallback,
362 ds_position_popup(c->frame, tb->frame, DS_POPUP_LOR);
364 /* set default button */
365 XtVaSetValues(button_form,
366 XmNdefaultButton, tb->show_button,
367 XmNcancelButton, tb->show_button,
369 XtVaSetValues(tb->form,
370 XmNdefaultButton, tb->show_button,
371 XmNcancelButton, tb->show_button,
374 XmProcessTraversal(tb->name_text, XmTRAVERSE_CURRENT);
375 XtVaSetValues(tb->form, XmNinitialFocus, tb->name_text, NULL);
377 ManageChildren(button_form);
378 ManageChildren(tb->form);
379 XtManageChild(tb->form);
380 XtVaSetValues(tb->frame, XmNmappedWhenManaged, True, NULL);
381 XtRealizeWidget(tb->frame);
383 XtPopup(tb->frame, XtGrabNone);
389 make_tempbr(Calendar *c)
393 tb = make_std_tempbr(c);
394 ((Tempbr *)tb)->cal = c;
402 XtPointer client_data,
403 XmPushButtonCallbackStruct *cbs)
408 XtVaGetValues(widget, XmNuserData, &c, NULL);
409 tb = (Tempbr *)c->tempbr;
411 XmTextSetString(tb->name_text, "");
412 XtPopdown(tb->frame);
418 tb_close_cb(Widget w, XtPointer data, XtPointer cbs)
420 Tempbr *tb = (Tempbr *)data;
422 XtPopdown(tb->frame);