Example #1
0
static PyObject *IBNibRefObj_CreateMenuBarFromNib(IBNibRefObject *_self, PyObject *_args)
{
	PyObject *_res = NULL;
	OSStatus _err;
	CFStringRef inName;
	Handle outMenuBar;
	if (!PyArg_ParseTuple(_args, "O&",
	                      CFStringRefObj_Convert, &inName))
		return NULL;
	_err = CreateMenuBarFromNib(_self->ob_itself,
	                            inName,
	                            &outMenuBar);
	if (_err != noErr) return PyMac_Error(_err);
	_res = Py_BuildValue("O&",
	                     ResObj_New, outMenuBar);
	return _res;
}
static OSStatus SetupUserInterface(void)
	// Create a user interface from our NIB.
{
	OSStatus 	err;
	IBNibRef 	nibRef;
	Handle		menuBar;

	nibRef  = NULL;
	menuBar = NULL;
		
	err = CreateNibReference(CFSTR("LoginItemsAETest"), &nibRef);
	if (err == noErr) {
		err = CreateMenuBarFromNib(nibRef, CFSTR("MenuBar"), &menuBar);
	}
	if (err == noErr) {
		SetMenuBar(menuBar);
	}
	if (err == noErr) {
		err = CreateWindowFromNib(nibRef, CFSTR("MainWindow"), &gMainWindow);
	}
	if (err == noErr) {
		ControlID theID;

		theID.signature = 'HDCB';
		theID.id = 0;	

		err = GetControlByID(gMainWindow, &theID, &gAddHiddenControl);
	}

	// Find and set up the data browser control.
	
	if (err == noErr) {
		ControlID theID;

		theID.signature = 'DATA';
		theID.id = 0;	

		err = GetControlByID(gMainWindow, &theID, &gDataControl);
	}
	if (err == noErr) {
		DataBrowserCallbacks callbacks;
		
		callbacks.version = kDataBrowserLatestCallbacks;
		err = InitDataBrowserCallbacks(&callbacks);

		if (err == noErr) {
			callbacks.u.v1.itemDataCallback = NewDataBrowserItemDataUPP(DataBrowserDataCallback);

			err = SetDataBrowserCallbacks(gDataControl, &callbacks);
		}
	}
	if (err == noErr) {
		DoRefresh();
	}
	
	if (err == noErr) {
		ShowWindow(gMainWindow);
	}
  	
	if (nibRef != NULL) {
		DisposeNibReference(nibRef);
	}
	if (menuBar != NULL) {
		DisposeHandle(menuBar);
	}
	return err;
}