예제 #1
0
int x_show_alert(int is_fatal, const char *str)     {
  DialogRef alert;
  DialogItemIndex out_item_hit;
  CFStringRef cfstrref;
  CFStringRef okstrref;
  AlertStdCFStringAlertParamRec alert_param;
  OSStatus osstat;

  if (!str || !*str) return 0;

  /* The dialog eats all events--including key-up events */
  /* Call adb_all_keys_up() to prevent annoying key-repeat problems */
  /*  for instance, a key-down causes a dialog to appear--and the */
  /*  eats the key-up event...then as soon as the dialog goes, adb.c */
  /*  auto-repeat will repeat the key, and the dialog re-appears...*/
  adb_all_keys_up();


  cfstrref = CFStringCreateWithCString(NULL, str,
                                       kCFStringEncodingMacRoman);


  osstat = GetStandardAlertDefaultParams(&alert_param,
                                         kStdCFStringAlertVersionOne);

  okstrref = CFSTR("Click OK to continue");
  if(is_fatal) {
    okstrref = CFSTR("Click OK to exit GSplus");
  }
  CreateStandardAlert(kAlertStopAlert, cfstrref, okstrref,
                      &alert_param, &alert);
  out_item_hit = -1;
  RunStandardAlert(alert, NULL, &out_item_hit);

  CFRelease(cfstrref);
  return (out_item_hit >= 3);
}
예제 #2
0
int
x_show_alert(int is_fatal, const char *str)
{
	DialogRef	alert;
	DialogItemIndex	out_item_hit;
	CFStringRef	cfstrref, cfstrref2;
	CFStringRef	okstrref;
	AlertStdCFStringAlertParamRec alert_param;
	OSStatus osstat;
	char	*bufptr, *buf2ptr;
	int	sum, len;
	int	i;
	
	/* The dialog eats all events--including key-up events */
	/* Call adb_all_keys_up() to prevent annoying key-repeat problems */
	/*  for instance, a key-down causes a dialog to appear--and the */
	/*  eats the key-up event...then as soon as the dialog goes, adb.c */
	/*  auto-repeat will repeat the key, and the dialog re-appears...*/
	adb_all_keys_up();
	
	sum = 20;
	for(i = 0; i < g_fatal_log; i++) {
		sum += strlen(g_fatal_log_strs[i]);
	}
	bufptr = (char*)malloc(sum);
	buf2ptr = bufptr;
	for(i = 0; i < g_fatal_log; i++) {
		len = strlen(g_fatal_log_strs[i]);
		len = MIN(len, sum);
		len = MAX(len, 0);
		memcpy(bufptr, g_fatal_log_strs[i], MIN(len, sum));
		bufptr += len;
		bufptr[0] = 0;
		sum = sum - len;
	}
	
	cfstrref = CFStringCreateWithCString(NULL, buf2ptr,
										 kCFStringEncodingMacRoman);
	
	printf("buf2ptr: :%s:\n", buf2ptr);
	
	osstat = GetStandardAlertDefaultParams(&alert_param,
										   kStdCFStringAlertVersionOne);
	
	if(str) {
		// Provide an extra option--create a file
		cfstrref2 = CFStringCreateWithFormat(kCFAllocatorDefault, NULL,
											 CFSTR("Create ~/Library/KEGS/%s"), str);
		alert_param.otherText = cfstrref2;
	}
	okstrref = CFSTR("Click OK to continue");
	if(is_fatal) {
		okstrref = CFSTR("Clock OK to exit KEGS");
	}
	CreateStandardAlert(kAlertStopAlert, cfstrref, okstrref,
						&alert_param, &alert);
	out_item_hit = -1;
	RunStandardAlert(alert, NULL, &out_item_hit);
	printf("out_item_hit: %d\n", out_item_hit);
	free(buf2ptr);
	
	clear_fatal_logs();		/* free the fatal_log string memory */
	return (out_item_hit >= 3);
	
}