Beispiel #1
0
void
PackageInstaller::ArgvReceived(int32 argc, char** argv)
{
	for (int i = 1; i < argc; i++) {
		if (strcmp("--verbose", argv[i]) == 0 || strcmp("-v", argv[i]) == 0) {
			gVerbose = true;
			continue;
		}
		
		BPath path;
		if (path.SetTo(argv[i]) != B_OK) {
			fprintf(stderr, B_TRANSLATE("Error! \"%s\" is not a valid path.\n"),
				argv[i]);
			continue;
		}

		entry_ref ref;
		status_t ret = get_ref_for_path(path.Path(), &ref);
		if (ret != B_OK) {
			fprintf(stderr, B_TRANSLATE("Error (%s)! Could not open \"%s\".\n"),
				strerror(ret), argv[i]);
			continue;
		}

		_NewWindow(&ref);
	}
}
Beispiel #2
0
void
PackageInstaller::RefsReceived(BMessage* message)
{
	entry_ref ref;
	for (int32 i = 0; message->FindRef("refs", i, &ref) == B_OK; i++)
		_NewWindow(&ref);
}
Beispiel #3
0
/*
 * windowsInit - windows-specific initialization
*/
static int windowsInit( HANDLE inst, int showcmd )
{
    LOGFONT     logfont;
    WORD        x,y;

    /*** Create a font to use ***/
    #ifdef _MBCS
        if( __IsDBCS ) {
            _FixedFont = GetStockObject( SYSTEM_FONT );
        } else {
            _FixedFont = GetStockObject( SYSTEM_FIXED_FONT );
        }
    #else
        _FixedFont = GetStockObject( SYSTEM_FIXED_FONT );
    #endif
    GetObject( _FixedFont, sizeof(LOGFONT), (LPSTR) &logfont );
    _FixedFont = CreateFontIndirect( &logfont );

    x = GetSystemMetrics( SM_CXSCREEN );
    y = GetSystemMetrics( SM_CYSCREEN );

    _InitMainWindowData( inst );

    _MainWindow = CreateWindow(
        mainClass,                      /* our class                  */
        __WinTitleBar,                  /* Text for window title bar  */
        WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,  /* Window style.      */
        0,                              /* horizontal position.       */
        0,                              /* vertical position.         */
        x,                              /* width.                     */
        y,                              /* height.                    */
        (HWND)NULL,                     /* parent                     */
        _MainMenu,                      /* menu handle                */
        inst,                           /* owner of window            */
        NULL                            /* extra data pointer         */
    );

    if( !_MainWindow ) {
        return( FALSE );
    }

    /*
     * display the window
     */
    ShowWindow( _MainWindow, showcmd );
    UpdateWindow( _MainWindow );

    /*
     * create standard IO window - takes output from stdout, stderr and
     *                             input from stdin
     */
    _NewWindow( "Standard IO", stdin->_handle, stdout->_handle,
                        stderr->_handle, -1 );
    return( TRUE );

} /* windowsInit */
void
TPeopleApp::RefsReceived(BMessage* message)
{
	int32 index = 0;
	while (message->HasRef("refs", index)) {
		entry_ref ref;
		message->FindRef("refs", index++, &ref);
		PersonWindow* window = _FindWindow(ref);
		if (window != NULL) {
			window->Activate(true);
		} else {
			BFile* file = new BFile(&ref, B_READ_WRITE);
			if (file->InitCheck() == B_OK)
				_NewWindow(&ref, file);
		}
	}
}
void
TPeopleApp::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case M_NEW:
		case B_SILENT_RELAUNCH:
			_NewWindow();
			break;

		case M_WINDOW_QUITS:
			_SavePreferences(message);
			fWindowCount--;
			if (fWindowCount < 1)
				PostMessage(B_QUIT_REQUESTED);
			break;

		case M_CONFIGURE_ATTRIBUTES:
		{
			const char* arguments[] = { "-type", B_PERSON_MIMETYPE, 0 };
			status_t ret = be_roster->Launch(
				"application/x-vnd.Haiku-FileTypes",
				sizeof(arguments) / sizeof(const char*) - 1,
				const_cast<char**>(arguments));
			if (ret != B_OK && ret != B_ALREADY_RUNNING) {
				BString errorMsg(B_TRANSLATE("Launching the FileTypes "
					"preflet to configure Person attributes has failed."
					"\n\nError: "));
				errorMsg << strerror(ret);
				BAlert* alert = new BAlert(B_TRANSLATE("Error"),
					errorMsg.String(), B_TRANSLATE("OK"), NULL, NULL,
					B_WIDTH_AS_USUAL, B_STOP_ALERT);
				alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
				alert->Go(NULL);
			}
			break;
		}

		default:
			BApplication::MessageReceived(message);
	}
}
Beispiel #6
0
_WCRTLINK int   __InitDefaultWin() {
//==================================

    ULONG       style;
    RECTL       rcl;
    HWND        menhdl;
    HWND        submenu;
    MENUITEM    *menudesc;
    MENUITEM    menus;
    SWP         swp;

    _ClassName = WatcomClass;

    _AnchorBlock = WinInitialize( 0 );
    if( _AnchorBlock == 0 ) return( 0 );
    hMessageQueue = WinCreateMsgQueue( _AnchorBlock, 0 );
    if( hMessageQueue == 0 ) return( 0 );
    if( !WinRegisterClass( _AnchorBlock, _ClassName, (PFNWP)_MainDriver,
                           CS_SIZEREDRAW, 0 ) ) {
        return( 0 );
    }

    _InitMainWindowData( 0 );

    style = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER | FCF_MINMAX |
            FCF_SHELLPOSITION | FCF_TASKLIST;
    _MainFrameWindow = WinCreateStdWindow( HWND_DESKTOP,
                        WS_VISIBLE | WS_CLIPCHILDREN,
                        &style, _ClassName, "", 0, NULL, 0, &ClientWindow );

    if( _MainFrameWindow == 0 ) return( 0 );
    WinSendMsg( _MainFrameWindow, WM_SETICON,
        MPFROMLONG( WinQuerySysPointer( HWND_DESKTOP, SPTR_APPICON, TRUE ) ), 0 );
    WinQueryWindowRect( _MainWindow, &rcl );
    WinSetWindowPos( _MainFrameWindow, HWND_TOP,
                rcl.xLeft,
                rcl.yBottom,
                rcl.xLeft - rcl.xRight,
                rcl.yTop - rcl.yBottom,
                SWP_SHOW | SWP_SIZE | SWP_MOVE | SWP_MAXIMIZE );

    _InitFunctionPointers();
    _MainWindow = ClientWindow;
    WinUpdateWindow( _MainWindow );

    menudesc = &menus;
    menhdl = WinCreateMenu( _MainFrameWindow, NULL );
    WinSetWindowBits( menhdl, QWL_STYLE, MS_ACTIONBAR, MS_ACTIONBAR );
    submenu = WinCreateMenu( menhdl, NULL );

    menudesc->afStyle = MIS_TEXT;
    menudesc->afAttribute = 0;
    menudesc->hwndSubMenu = NULL;
    menudesc->hItem = 0;

    menudesc->iPosition = 0;
    menudesc->id = DID_FILE_SAVE;
    if ( MIT_ERROR == (BOOL)WinSendMsg( submenu, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "Save As..." ) ) ) abort();
    menudesc->iPosition = 1;
    menudesc->id = DID_FILE_CLEAR;
    if ( MIT_ERROR == (BOOL)WinSendMsg( submenu, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "Set Lines Between Clears..." ) ) ) abort();
    menudesc->afStyle = MIS_SEPARATOR;
    menudesc->iPosition = 2;
    menudesc->id = 0;
    if ( MIT_ERROR == (BOOL)WinSendMsg( submenu, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "Exit" ) ) ) abort();
    menudesc->afStyle = MIS_TEXT;
    menudesc->iPosition = 3;
    menudesc->id = DID_FILE_EXIT;
    if ( MIT_ERROR == (BOOL)WinSendMsg( submenu, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "Exit" ) ) ) abort();
    menudesc->iPosition = 0;
    menudesc->id = DID_MAIN_FILE;
    menudesc->hwndSubMenu = submenu;
    menudesc->afStyle = MIS_TEXT | MIS_SUBMENU;
    if ( MIT_ERROR == (BOOL)WinSendMsg( menhdl, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "~File" ) ) ) abort();

    submenu = WinCreateMenu( menhdl, NULL );
    menudesc->afStyle = MIS_TEXT;
    menudesc->iPosition = 0;
    menudesc->id = DID_EDIT_CLEAR;
    menudesc->hwndSubMenu = NULL;
    if ( MIT_ERROR == (BOOL)WinSendMsg( submenu, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "Clear" ) ) ) abort();
    menudesc->iPosition = 1;
    menudesc->id = DID_EDIT_COPY;
    if ( MIT_ERROR == (BOOL)WinSendMsg( submenu, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "Copy" ) ) ) abort();
    menudesc->iPosition = 1;
    menudesc->id = DID_MAIN_EDIT;
    menudesc->hwndSubMenu = submenu;
    menudesc->afStyle = MIS_SUBMENU;
    if ( MIT_ERROR == (BOOL)WinSendMsg( menhdl, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "~Edit" ) ) ) abort();

    submenu = WinCreateMenu( menhdl, NULL );
    _SetWinMenuHandle( submenu );
    menudesc->iPosition = 2;
    menudesc->afAttribute = 0;
    menudesc->id = DID_MAIN_WIND;
    menudesc->hwndSubMenu = submenu;
    menudesc->afStyle = MIS_SUBMENU;
    if ( MIT_ERROR == (BOOL)WinSendMsg( menhdl, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "~Windows" ) ) ) abort();

    submenu = WinCreateMenu( menhdl, NULL );
    menudesc->afStyle = MIS_TEXT;
    menudesc->iPosition = 0;
    menudesc->id = DID_HELP_ABOUT;
    menudesc->hwndSubMenu = NULL;
    if ( MIT_ERROR == (BOOL)WinSendMsg( submenu, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "About" ) ) ) abort();
    menudesc->iPosition = 3;
    menudesc->id = DID_MAIN_HELP;
    menudesc->hwndSubMenu = submenu;
    menudesc->afStyle = MIS_SUBMENU;
    if ( MIT_ERROR == (BOOL)WinSendMsg( menhdl, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "~Help" ) ) ) abort();

    WinSendMsg( _MainFrameWindow, ( ULONG )WM_UPDATEFRAME, 0, 0 );
    _NewWindow( "Standard IO", 0,1,2,-1 );
    WinUpdateWindow( _MainFrameWindow );
    WinQueryWindowPos( _MainWindow, &swp );
    swp.fl |= SWP_MAXIMIZE;
    WinSetWindowPos( _MainWindow, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy, SWP_MAXIMIZE | SWP_ACTIVATE | SWP_MOVE | SWP_SHOW | SWP_SIZE );

    return( 1 );
}
void
TPeopleApp::ReadyToRun()
{
	if (fWindowCount < 1)
		_NewWindow();
}