Пример #1
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);
}
Пример #2
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;
	}
}