示例#1
0
edit_status
execute_edit_action (rp_input_line *line, KeySym ch, unsigned int modifier, char *keysym_buf)
{
  struct edit_binding *binding = NULL;
  int found_binding = 0;
  edit_status status;

  for (binding = edit_bindings; binding->func; binding++)
    {
      if (ch == binding->key.sym && modifier == binding->key.state)
        {
          found_binding = 1;
          break;
        }
    }

  if (found_binding)
    status = binding->func (line);
  else if (modifier)
    status = editor_no_action (line);
  else
    status = editor_insert (line, keysym_buf);

  return status;
}
示例#2
0
/*
 * Insert the appointment into the calendar.
 *
 * Returns:
 *		1	Success
 *		0	User overuled.  Appointment not inserted.
 *		-1	Failure
 */
static int
schedule_appt(Calendar *c, Dtcm_appointment *a) {
	char		date_buf[MAXNAMELEN], buf[BUFSIZ], buf2[BUFSIZ];
	int		answer;
	Editor		*e = (Editor *)c->editor;
	ToDo		*t = (ToDo *)c->todo;
	Props		*p = (Props *)c->properties;
	CSA_entry_handle	entry;
	OrderingType	ot = get_int_prop(p, CP_DATEORDERING);
	SeparatorType	st = get_int_prop(p, CP_DATESEPARATOR);
	Tick		tick;
	int		rc;

	if (strcmp(c->calname, c->view->current_calendar) != 0) {
		/*
		 * Make sure user really meant to insert appointment
		 * into somebody elses calendar.
		 */
		char *ident = XtNewString(catgets(c->DT_catd, 1, 923, "Cancel"));
	  	char *title = XtNewString(catgets(c->DT_catd, 1, 212,
				"Calendar : Schedule Appointment"));
		sprintf(buf, "%s", catgets(c->DT_catd, 1, 210, "The appointment will be scheduled in the calendar\nyou are currently browsing.  Do you still want to schedule it?"));
		sprintf(buf2, "%s %s", catgets(c->DT_catd, 1, 211, "Schedule in"),
			c->view->current_calendar);
		answer = dialog_popup(c->frame,
			DIALOG_TITLE, title,
			DIALOG_TEXT, buf,
			BUTTON_IDENT, 1, ident,
			BUTTON_IDENT, 2, buf2,
			NULL);
		XtFree(title);
		XtFree(ident);
		if (answer == 1)
			return 0;
	}

	if (a->end_time) {
        if (!editor_created(e))
	{
                e_make_editor(c);
		XtUnmanageChild(e->base_form_mgr);
		e->editor_is_up = False;
	}
	if ((rc = editor_insert(a, &entry, c)) == True) {

		_csa_iso8601_to_tick(a->time->value->item.string_value, &tick);
		format_tick(tick, ot, st, date_buf);
		sprintf(buf, catgets(c->DT_catd, 1, 214,
				     "Appointment scheduled: %s"), date_buf);
		set_message(c->message_text, buf);
		return 1;
	} else {
		set_message(c->message_text, "");
		if ( rc == 2)
			return 0;
			return -1;
	}
	} else {
	if (!t->frame)
	{
		t_make_todo(c);
		XtUnmanageChild(t->frame);
		t->todo_is_up = False;
	}
	if (todo_insert(a, &entry, c)) {
		/*
		 * No messages displayed on calendar for todo.
		 */
		return 1;
	} else {
		/*
		 * No messages displayed on calendar for todo.
		 */
		return -1;
	}
	}
}