Ejemplo n.º 1
0
static void
dssw_set_non_times(DSSW *dssw, time_t t) {
	Props		*p = (Props *)dssw->cal->properties;
	OrderingType	ot = get_int_prop(p, CP_DATEORDERING);
	SeparatorType	st = get_int_prop(p, CP_DATESEPARATOR);

	set_date_in_widget(t, dssw->date_text, ot, st);
	XmTextSetString(dssw->what_text, dssw->what_val);
}
Ejemplo n.º 2
0
Archivo: alarm.c Proyecto: juddy/edcde
/*
**  Functions to build and popup the postup reminder
*/
extern void
postup_show_proc(Calendar *c, CSA_reminder_reference *r) {
        int			start_hr, stop_hr;
	char			text[BUFSIZ];
	time_t			st, sp = 0;
	Lines			*lines, *l = NULL;
	Props			*p = (Props *)c->properties;
	Widget			pu_frame, pu_base_form, 
				pu_text_form, separator, 
				pu_form, button_form, pu_date,
				pu_range, pu_image, pu_close, line, last_line;
	Boolean			start_am, stop_am;
	XmString		xmstr;
	CSA_return_code		stat;
	DisplayType		dis_t = get_int_prop(p, CP_DEFAULTDISP);
	OrderingType		ord_t = get_int_prop(p, CP_DATEORDERING);
	SeparatorType		sep_t = get_int_prop(p, CP_DATESEPARATOR);
	Dtcm_appointment	*appt;
	char			*title;

	if (!c->postup)
		c->postup = XtAppCreateShell("calendar_postup", "Dtcm",
			xmDialogShellWidgetClass, c->xcontext->display,
			NULL, 0);

	/*
	**  Create the Motif objects
	*/
	title = XtNewString(catgets(c->DT_catd, 1, 839, "Calendar : Reminder"));
	pu_frame = XtVaCreatePopupShell("pu_frame",
		topLevelShellWidgetClass, c->postup,
		XmNtitle, title,
		XmNmwmFunctions, MWM_FUNC_MOVE | MWM_FUNC_CLOSE,
		XmNdeleteResponse,      XmDESTROY,
		NULL);
	XtFree(title);

	pu_base_form = XtVaCreateWidget("pu_base_form",
		xmFormWidgetClass, pu_frame,
		NULL);

	pu_text_form = XtVaCreateWidget("pu_test_form",
		xmFormWidgetClass, pu_base_form,
		XmNtopAttachment, XmATTACH_FORM,
		XmNleftAttachment, XmATTACH_FORM,
		XmNtopAttachment, XmATTACH_FORM,
		XmNleftOffset, 1,
		XmNrightOffset, 1,
		XmNtopOffset, 1,
		NULL);

	pu_image = XtVaCreateWidget("pu_image",
		xmLabelGadgetClass, pu_text_form,
		XmNleftAttachment, XmATTACH_FORM,
		XmNtopAttachment, XmATTACH_FORM,
		XmNtopOffset, 5,
		XmNlabelType, XmPIXMAP,
		XmNlabelPixmap, ((Props_pu *)c->properties_pu)->postup_pixmap,
		NULL);

	button_form = XtVaCreateWidget("pu_form",
		xmFormWidgetClass, pu_base_form,
		XmNbottomAttachment, XmATTACH_FORM,
		XmNbottomOffset, 2,
		XmNleftOffset, 1,
		XmNrightOffset, 1,
		XmNleftAttachment, XmATTACH_FORM,
		XmNrightAttachment, XmATTACH_FORM,
		XmNfractionBase, 3,
		NULL);

	xmstr = XmStringCreateLocalized(catgets(c->DT_catd, 1, 680, "Close"));
	pu_close = XtVaCreateManagedWidget("close", 
		xmPushButtonWidgetClass, button_form, 
                XmNtopAttachment, 	XmATTACH_FORM,
		XmNbottomAttachment, 	XmATTACH_FORM,
		XmNleftAttachment, 	XmATTACH_POSITION,
		XmNrightAttachment, 	XmATTACH_POSITION,
		XmNleftPosition,	1,
		XmNrightPosition,	2,
		XmNbottomOffset, 	1,
                XmNlabelString, 	xmstr,
                NULL);
	XmStringFree(xmstr);

	separator = XtVaCreateWidget("separator",
                xmSeparatorGadgetClass,
                pu_base_form,
                XmNleftAttachment,      XmATTACH_FORM,
                XmNrightAttachment,     XmATTACH_FORM,
                XmNbottomAttachment,   	XmATTACH_WIDGET,
                XmNbottomWidget,        button_form,
		XmNtopAttachment, XmATTACH_WIDGET,
		XmNtopWidget, pu_text_form,
		XmNtopOffset, 1,
                NULL);


	pu_form = XtVaCreateWidget("pu_form",
		xmFormWidgetClass, pu_text_form,
		XmNtopAttachment, XmATTACH_FORM,
		XmNtopOffset, 1,
		XmNleftAttachment, XmATTACH_WIDGET,
		XmNleftWidget, pu_image,
		XmNverticalSpacing, 10,
		NULL);

	pu_date = XtVaCreateWidget("pu_date",
		xmLabelGadgetClass, pu_form,
		XmNleftAttachment, XmATTACH_FORM,
		XmNtopAttachment, XmATTACH_FORM,
		NULL);

	pu_range = XtVaCreateWidget("pu_range",
		xmLabelGadgetClass, pu_form,
		XmNleftAttachment, XmATTACH_FORM,
		XmNtopAttachment, XmATTACH_WIDGET,
		XmNtopWidget, pu_date,
		XmNtopOffset, 8,
		NULL);

	XtAddCallback(pu_close, XmNactivateCallback, close_cb, pu_frame);

	appt = allocate_appt_struct(appt_read,
				    c->general->version,
				    CSA_ENTRY_ATTR_START_DATE_I,
				    CSA_ENTRY_ATTR_END_DATE_I,
				    CSA_ENTRY_ATTR_SUMMARY_I,
				    CSA_X_DT_ENTRY_ATTR_SHOWTIME_I,
				    NULL);
	stat = query_appt_struct(c->cal_handle, r->entry, appt);
	backend_err_msg(c->frame, c->calname, stat,
			((Props_pu *)c->properties_pu)->xm_error_pixmap);
	if (stat != CSA_SUCCESS) {
		free_appt_struct(&appt);
		return;
	}

	_csa_iso8601_to_tick(appt->time->value->item.date_time_value, &st);
	if (appt->end_time)
		_csa_iso8601_to_tick(appt->end_time->value->\
			item.date_time_value, &sp);
	l = lines = text_to_lines(appt->what->value->item.string_value, 5);
	last_line = 0;
	while (l) {
		xmstr = XmStringCreateLocalized(l->s);
		line = XtVaCreateWidget("text_line",
			xmLabelGadgetClass, pu_text_form,
			XmNlabelString, xmstr,
			XmNleftAttachment, XmATTACH_WIDGET,
			XmNleftWidget, pu_form,
			XmNleftOffset, 15,
			NULL);
		XmStringFree(xmstr);

		if (last_line)
			XtVaSetValues(line, 
				XmNtopAttachment, XmATTACH_WIDGET,
				XmNtopWidget, last_line,
				XmNtopOffset, 8,
				NULL);
		else
			XtVaSetValues(line, 
				XmNtopAttachment, XmATTACH_FORM,
				XmNtopOffset, 8,
				NULL);

		last_line = line;
		l = l->next;
	}
	if (lines)
		destroy_lines(lines);

	/*
	**  Now fill in the correct information
	*/
	set_date_in_widget(st, pu_date, ord_t, sep_t);

        if (!showtime_set(appt) || magic_time(st)) 
                text[0] = '\0';
	else {
		start_hr = hour(st);
		if (sp) stop_hr = hour(sp);
		if (dis_t == HOUR12) {
			start_am = adjust_hour(&start_hr);
			if (sp) {
				/* NL_COMMENT

				   Message 1087 : This message is used to form
				   the alarm string that appears in the
				   reminder popup.  In the C locale it would
				   look something like this:

				   ``From 11:00am to 1:00pm''

				   In the printf conversion string the $n are:

					$1 	-> start hour
					$2	-> start minute
					$3	-> am or pm
					$4	-> stop hour
					$5	-> stop minute
					$6	-> am or pm

				*/
			        char *am = XtNewString(catgets(c->DT_catd, 
							       1, 4, "am"));
			        char *pm = XtNewString(catgets(c->DT_catd, 
							       1, 3, "pm"));
				stop_am = adjust_hour(&stop_hr);
				sprintf(text, catgets(c->DT_catd, 1, 1087,
				   "From %1$2d:%2$02d%3$s to %4$2d:%5$02d%6$s"),
					start_hr, minute(st),
					(start_am) ? am : pm,
					stop_hr, minute(sp),
					(stop_am) ? am : pm
					);
				XtFree(am);
				XtFree(pm);
			} else {
				/* NL_COMMENT

				   Message 1088 : This message is used to form
				   the alarm string that appears in the
				   reminder popup.  It is used when an appt
				   does not have and ``end'' time.  In the 
				   C locale it would look something like this:

				   ``11:00am''

				   In the printf conversion string the $n are:

					$1 	-> start hour
					$2	-> start minute
					$3	-> am or pm

				*/
			        char *meridian = 
				  XtNewString ((start_am) ? 
					       catgets(c->DT_catd, 1, 4, "am"):
					       catgets(c->DT_catd, 1, 3, "pm"));
				
				sprintf(text, catgets(c->DT_catd, 1, 1088,
				   			"%1$2d:%2$02d%3$s"), 
					start_hr, minute(st), meridian
					);
				XtFree(meridian);
			}
		} else {
			if (sp) {
				/* NL_COMMENT

				   Message 1089 : This message is used to form
				   the alarm string that appears in the
				   reminder popup.  This string is used when
				   a user has asked that times be displayed
				   in 24 hour format.  In the C locale it 
				   would look something like this:

				   ``From 0100 to 1600''

				   In the printf conversion string the $n are:

					$1 	-> start hour
					$2	-> start minute
					$3	-> stop hour
					$4	-> stop minute

				*/
				sprintf(text, catgets(c->DT_catd, 1, 1089,
				   "From %1$02d%2$02d to %3$02d%4$02d"),
					start_hr, minute(st), stop_hr, 
					minute(sp));
			} else {
				/* NL_COMMENT

				   Message 1090 : This message is used to form
				   the alarm string that appears in the
				   reminder popup.  This string is used when
				   an appt does not have an end time and the
				   user has asked that times be displayed
				   in 24 hour format.  In the C locale it 
				   would look something like this:

				   ``1600''

				   In the printf conversion string the $n are:

					$1 	-> start hour
					$2	-> start minute

				*/
				sprintf(text, catgets(c->DT_catd, 1, 1090,
							"%1$02d%2$02d"), 
					start_hr, minute(st));
			}
		}
	}

	free_appt_struct(&appt);
	xmstr = XmStringCreateLocalized(text);
	XtVaSetValues(pu_range, XmNlabelString, xmstr,
		NULL);
	XmStringFree(xmstr);

	ManageChildren(pu_form);
	ManageChildren(pu_base_form);
	ManageChildren(pu_text_form);
	XtManageChild(pu_base_form);
	XtVaSetValues(button_form, XmNdefaultButton, pu_close, NULL);
        XtVaSetValues(button_form, XmNcancelButton, pu_close, NULL);
	XtPopup(pu_frame, XtGrabNone);
	DtWsmOccupyAllWorkspaces(c->xcontext->display, XtWindow(pu_frame));
}