Beispiel #1
0
void
wAppIconDestroy(WAppIcon *aicon)
{
    WScreen *scr = aicon->icon->core->screen_ptr;

    RemoveFromStackList(aicon->icon->core);
    wIconDestroy(aicon->icon);
    if (aicon->command)
        wfree(aicon->command);
#ifdef XDND
    if (aicon->dnd_command)
        wfree(aicon->dnd_command);
#endif
    if (aicon->wm_instance)
        wfree(aicon->wm_instance);
    if (aicon->wm_class)
        wfree(aicon->wm_class);

    if (aicon == scr->app_icon_list) {
        if (aicon->next)
            aicon->next->prev = NULL;
        scr->app_icon_list = aicon->next;
    }
    else {
        if (aicon->next)
            aicon->next->prev = aicon->prev;
        if (aicon->prev)
            aicon->prev->next = aicon->next;
    }

    aicon->destroyed = 1;
    wrelease(aicon);
}
Beispiel #2
0
static void retry_erase(erase_busy_t *busy, u_int cause)
{
    eraseq_entry_t *erase = busy->erase;
    mtd_request_t req;
    client_t *mtd;
    socket_info_t *s;
    int ret;

    DEBUG(2, "cs: trying erase request 0x%p...\n", busy);
    if (busy->next)
	remove_queue(busy);
    req.Function = MTD_REQ_ERASE | cause;
    req.TransferLength = erase->Size;
    req.DestCardOffset = erase->Offset + erase->Handle->info.CardOffset;
    req.MediaID = erase->Handle->MediaID;
    mtd = erase->Handle->mtd;
    s = SOCKET(mtd);
    mtd->event_callback_args.mtdrequest = &req;
    wacquire(&mtd->mtd_req);
    ret = EVENT(mtd, CS_EVENT_MTD_REQUEST, CS_EVENT_PRI_LOW);
    wrelease(&mtd->mtd_req);
    if (ret == CS_BUSY) {
	DEBUG(2, "  Status = %d, requeueing.\n", req.Status);
	switch (req.Status) {
	case MTD_WAITREQ:
	case MTD_WAITPOWER:
	    insert_queue(&mtd->erase_busy, busy);
	    break;
	case MTD_WAITTIMER:
	case MTD_WAITRDY:
	    if (req.Status == MTD_WAITRDY)
		insert_queue(&s->erase_busy, busy);
	    mod_timer(&busy->timeout, jiffies + req.Timeout*HZ/1000);
	    break;
	}
    } else {
	/* update erase queue status */
	DEBUG(2, "  Ret = %d\n", ret);
	switch (ret) {
	case CS_SUCCESS:
	    erase->State = ERASE_PASSED; break;
	case CS_WRITE_PROTECTED:
	    erase->State = ERASE_MEDIA_WRPROT; break;
	case CS_BAD_OFFSET:
	    erase->State = ERASE_BAD_OFFSET; break;
	case CS_BAD_SIZE:
	    erase->State = ERASE_BAD_SIZE; break;
	case CS_NO_CARD:
	    erase->State = ERASE_BAD_SOCKET; break;
	default:
	    erase->State = ERASE_FAILED; break;
	}
	busy->client->event_callback_args.info = erase;
	EVENT(busy->client, CS_EVENT_ERASE_COMPLETE, CS_EVENT_PRI_LOW);
	kfree(busy);
	/* Resubmit anything waiting for a request to finish */
	wakeup(&mtd->mtd_req);
	retry_erase_list(&mtd->erase_busy, 0);
    }
} /* retry_erase */
Beispiel #3
0
static void
killCallback(WMenu *menu, WMenuEntry *entry)
{
    WApplication *wapp = (WApplication*)entry->clientdata;
    WFakeGroupLeader *fPtr;
    char *buffer;

    if (!WCHECK_STATE(WSTATE_NORMAL))
        return;

    WCHANGE_STATE(WSTATE_MODAL);

    assert(entry->clientdata!=NULL);

    buffer = wstrconcat(wapp->app_icon ? wapp->app_icon->wm_class : NULL,
                        _(" will be forcibly closed.\n"
                          "Any unsaved changes will be lost.\n"
                          "Please confirm."));

    fPtr = wapp->main_window_desc->fake_group;

    wretain(wapp->main_window_desc);
    if (wPreferences.dont_confirm_kill
        || wMessageDialog(menu->frame->screen_ptr, _("Kill Application"),
                          buffer, _("Yes"), _("No"), NULL)==WAPRDefault) {
        if (fPtr!=NULL) {
            WWindow *wwin, *twin;

            wwin = wapp->main_window_desc->screen_ptr->focused_window;
            while (wwin) {
                twin = wwin->prev;
                if (wwin->fake_group == fPtr) {
                    wClientKill(wwin);
                }
                wwin = twin;
            }
        } else if (!wapp->main_window_desc->flags.destroyed) {
            wClientKill(wapp->main_window_desc);
        }
    }
    wrelease(wapp->main_window_desc);

    wfree(buffer);

    WCHANGE_STATE(WSTATE_NORMAL);
}
Beispiel #4
0
static int do_mtd_request(memory_handle_t handle, mtd_request_t *req,
			  caddr_t buf)
{
    int ret, tries;
    client_t *mtd;
    socket_info_t *s;
    
    mtd = handle->mtd;
    if (mtd == NULL)
	return CS_GENERAL_FAILURE;
    s = SOCKET(mtd);
    wacquire(&mtd->mtd_req);
    for (ret = tries = 0; tries < 100; tries++) {
	mtd->event_callback_args.mtdrequest = req;
	mtd->event_callback_args.buffer = buf;
	ret = EVENT(mtd, CS_EVENT_MTD_REQUEST, CS_EVENT_PRI_LOW);
	if (ret != CS_BUSY)
	    break;
	switch (req->Status) {
	case MTD_WAITREQ:
	    /* Not that we should ever need this... */
	    wsleeptimeout(&mtd->mtd_req, HZ);
	    break;
	case MTD_WAITTIMER:
	case MTD_WAITRDY:
	    wsleeptimeout(&mtd->mtd_req, req->Timeout*HZ/1000);
	    req->Function |= MTD_REQ_TIMEOUT;
	    break;
	case MTD_WAITPOWER:
	    wsleep(&mtd->mtd_req);
	    break;
	}
#ifndef __MACOSX__
	if (signal_pending(current))
	    printk(KERN_NOTICE "cs: do_mtd_request interrupted!\n");
#endif
    }
    wrelease(&mtd->mtd_req);
    if (tries == 20) {
	printk(KERN_NOTICE "cs: MTD request timed out!\n");
	ret = CS_GENERAL_FAILURE;
    }
    wakeup(&mtd->mtd_req);
    retry_erase_list(&mtd->erase_busy, 0);
    return ret;
} /* do_mtd_request */
Beispiel #5
0
void wAppIconDestroy(WAppIcon *aicon)
{
	RemoveFromStackList(aicon->icon->vscr, aicon->icon->core);
	wIconDestroy(aicon->icon);
	if (aicon->command)
		wfree(aicon->command);
#ifdef USE_DOCK_XDND
	if (aicon->dnd_command)
		wfree(aicon->dnd_command);
#endif
	if (aicon->wm_instance)
		wfree(aicon->wm_instance);

	if (aicon->wm_class)
		wfree(aicon->wm_class);

	remove_from_appicon_list(aicon);

	aicon->destroyed = 1;
	wrelease(aicon);
}
Beispiel #6
0
static void setIconCallback(WMenu *menu, WMenuEntry *entry)
{
	WAppIcon *icon = ((WApplication *) entry->clientdata)->app_icon;
	char *file = NULL;
	virtual_screen *vscr;
	int result;

	/* Parameter not used, but tell the compiler that it is ok */
	(void) menu;

	assert(icon != NULL);

	if (icon->editing)
		return;

	icon->editing = 1;
	vscr = icon->icon->vscr;

	wretain(icon);

	result = wIconChooserDialog(NULL, NULL, icon, &file);
	if (result) {
		if (!icon->destroyed) {
			if (!wIconChangeImageFile(icon->icon, file)) {
				wMessageDialog(vscr, _("Error"),
				               _("Could not open specified icon file"),
				               _("OK"), NULL, NULL);
			} else {
				wDefaultChangeIcon(icon->wm_instance, icon->wm_class, file);
				wAppIconPaint(icon);
			}
		}

		if (file)
			wfree(file);
	}

	icon->editing = 0;
	wrelease(icon);
}
Beispiel #7
0
static void
setIconCallback(WMenu *menu, WMenuEntry *entry)
{
    WAppIcon *icon = ((WApplication*)entry->clientdata)->app_icon;
    char *file=NULL;
    WScreen *scr;
    int result;

    assert(icon!=NULL);

    if (icon->editing)
        return;
    icon->editing = 1;
    scr = icon->icon->core->screen_ptr;

    wretain(icon);

    result = wIconChooserDialog(scr, &file, icon->wm_instance, icon->wm_class);

    if (result && !icon->destroyed) {
        if (file && *file==0) {
            wfree(file);
            file = NULL;
        }
        if (!wIconChangeImageFile(icon->icon, file)) {
            wMessageDialog(scr, _("Error"),
                           _("Could not open specified icon file"),
                           _("OK"), NULL, NULL);
        } else {
            wDefaultChangeIcon(scr, icon->wm_instance, icon->wm_class, file);
            wAppIconPaint(icon);
        }
        if (file)
            wfree(file);
    }
    icon->editing = 0;
    wrelease(icon);
}
Beispiel #8
0
static void execMenuCommand(WMenu * menu, WMenuEntry * entry)
{
	WWindow *wwin = (WWindow *) entry->clientdata;
	WApplication *wapp;

	CloseWindowMenu(menu->frame->screen_ptr);

	switch (entry->order) {
	case MC_CLOSE:
		/* send delete message */
		wClientSendProtocol(wwin, w_global.atom.wm.delete_window,
								  w_global.timestamp.last_event);
		break;

	case MC_KILL:
		wretain(wwin);
		if (wPreferences.dont_confirm_kill
		    || wMessageDialog(menu->frame->screen_ptr, _("Kill Application"),
				      _
				      ("This will kill the application.\nAny unsaved changes will be lost.\nPlease confirm."),
				      _("Yes"), _("No"), NULL) == WAPRDefault) {
			if (!wwin->flags.destroyed)
				wClientKill(wwin);
		}
		wrelease(wwin);
		break;

	case MC_MINIATURIZE:
		if (wwin->flags.miniaturized) {
			wDeiconifyWindow(wwin);
		} else {
			if (wwin->protocols.MINIATURIZE_WINDOW) {
				wClientSendProtocol(wwin, w_global.atom.gnustep.wm_miniaturize_window,
										  w_global.timestamp.last_event);
			} else {
				wIconifyWindow(wwin);
			}
		}
		break;

	case MC_MAXIMIZE:
		if (wwin->flags.maximized)
			wUnmaximizeWindow(wwin);
		else
			wMaximizeWindow(wwin, MAX_VERTICAL | MAX_HORIZONTAL,
					wGetHeadForWindow(wwin));
		break;

	case MC_SHADE:
		if (wwin->flags.shaded)
			wUnshadeWindow(wwin);
		else
			wShadeWindow(wwin);
		break;

	case MC_SELECT:
		if (!wwin->flags.miniaturized)
			wSelectWindow(wwin, !wwin->flags.selected);
		else
			wIconSelect(wwin->icon);
		break;

	case MC_MOVERESIZE:
		wKeyboardMoveResizeWindow(wwin);
		break;

	case MC_PROPERTIES:
		wShowInspectorForWindow(wwin);
		break;

	case MC_RELAUNCH:
		(void) RelaunchWindow(wwin);
		break;

	case MC_HIDE:
		wapp = wApplicationOf(wwin->main_window);
		wHideApplication(wapp);
		break;
	}
}