rem: free(str);
add: free(tmp); free(str);
context: createInspectorForWindow(WWindow *wwin){    WScreen *scr = wwin->screen_ptr;    InspectorPanel *panel;    Window parent;    int i;    int x, y;    int btn_width, frame_width;    WMButton *selectedBtn = NULL;#ifdef wrong_behaviour    WMPixmap *pixmap;#endif    panel = wmalloc(sizeof(InspectorPanel));    memset(panel, 0, sizeof(InspectorPanel));        panel->destroyed = 0;        panel->inspected = wwin;    panel->nextPtr = panelList;    panelList = panel;    panel->win = WMCreateWindow(scr->wmscreen, "windowInspector");    WMResizeWidget(panel->win, PWIDTH, PHEIGHT);        /**** create common stuff ****/    /* command buttons */    /* (PWIDTH - (left and right margin) - (btn interval)) / 3 */    btn_width = (PWIDTH - (2 * 15) - (2 * 10)) / 3;    panel->saveBtn = WMCreateCommandButton(panel->win);    WMSetButtonAction(panel->saveBtn, (WMAction*)saveSettings, panel);    WMMoveWidget(panel->saveBtn, (2 * (btn_width + 10)) + 15, 310);    WMSetButtonText(panel->saveBtn, _("Save"));    WMResizeWidget(panel->saveBtn, btn_width, 28);    if (wPreferences.flags.noupdates || !(wwin->wm_class || wwin->wm_instance))	WMSetButtonEnabled(panel->saveBtn, False);    panel->applyBtn = WMCreateCommandButton(panel->win);    WMSetButtonAction(panel->applyBtn, (WMAction*)applySettings, panel);    WMMoveWidget(panel->applyBtn, btn_width + 10 + 15, 310);    WMSetButtonText(panel->applyBtn, _("Apply"));    WMResizeWidget(panel->applyBtn, btn_width, 28);    panel->revertBtn = WMCreateCommandButton(panel->win);    WMSetButtonAction(panel->revertBtn, (WMAction*)revertSettings, panel);    WMMoveWidget(panel->revertBtn, 15, 310);    WMSetButtonText(panel->revertBtn, _("Reload"));    WMResizeWidget(panel->revertBtn, btn_width, 28);    /* page selection popup button */    panel->pagePopUp = WMCreatePopUpButton(panel->win);    WMSetPopUpButtonAction(panel->pagePopUp, (WMAction*)changePage, panel);    WMMoveWidget(panel->pagePopUp, 25, 15);    WMResizeWidget(panel->pagePopUp, PWIDTH - 50, 20);    WMAddPopUpButtonItem(panel->pagePopUp, _("Window Specification"));    WMAddPopUpButtonItem(panel->pagePopUp, _("Window Attributes"));    WMAddPopUpButtonItem(panel->pagePopUp, _("Advanced Options"));    WMAddPopUpButtonItem(panel->pagePopUp, _("Icon and Initial Workspace"));    WMAddPopUpButtonItem(panel->pagePopUp, _("Application Specific"));    /**** window spec ****/    frame_width = PWIDTH - (2 * 15);    panel->specFrm = WMCreateFrame(panel->win);    WMSetFrameTitle(panel->specFrm, _("Window Specification"));    WMMoveWidget(panel->specFrm, 15, 65);    WMResizeWidget(panel->specFrm, frame_width, 105);    panel->defaultRb = WMCreateRadioButton(panel->specFrm);    WMMoveWidget(panel->defaultRb, 10, 78);    WMResizeWidget(panel->defaultRb, frame_width - (2 * 10), 20);    WMSetButtonText(panel->defaultRb, _("Defaults for all windows"));    WMSetButtonSelected(panel->defaultRb, False);    WMSetButtonAction(panel->defaultRb, selectSpecification, panel);    if (wwin->wm_class && wwin->wm_instance) {	char *str;	str = wstrappend(wwin->wm_instance, wwin->wm_class);	panel->bothRb = WMCreateRadioButton(panel->specFrm);	WMMoveWidget(panel->bothRb, 10, 18);	WMResizeWidget(panel->bothRb, frame_width - (2 * 10), 20);	WMSetButtonText(panel->bothRb, str);	free(str);	WMGroupButtons(panel->defaultRb, panel->bothRb);	if (!selectedBtn)	    selectedBtn = panel->bothRb;	WMSetButtonAction(panel->bothRb, selectSpecification, panel);    }    if (wwin->wm_instance) {	panel->instRb = WMCreateRadioButton(panel->specFrm);	WMMoveWidget(panel->instRb, 10, 38);	WMResizeWidget(panel->instRb, frame_width - (2 * 10), 20);	WMSetButtonText(panel->instRb, wwin->wm_instance);	WMGroupButtons(panel->defaultRb, panel->instRb);	if (!selectedBtn)	    selectedBtn = panel->instRb;	WMSetButtonAction(panel->instRb, selectSpecification, panel);    }    if (wwin->wm_class) {	panel->clsRb = WMCreateRadioButton(panel->specFrm);	WMMoveWidget(panel->clsRb, 10, 58);	WMResizeWidget(panel->clsRb, frame_width - (2 * 10), 20);	WMSetButtonText(panel->clsRb, wwin->wm_class);	WMGroupButtons(panel->defaultRb, panel->clsRb);	if (!selectedBtn)	    selectedBtn = panel->clsRb;	WMSetButtonAction(panel->clsRb, selectSpecification, panel);    }    panel->specLbl = WMCreateLabel(panel->win);    WMMoveWidget(panel->specLbl, 15, 170);    WMResizeWidget(panel->specLbl, frame_width, 100);    WMSetLabelText(panel->specLbl,		   _("The configuration will apply to all\n"		     "windows that have their WM_CLASS property"		     " set to the above selected\nname, when saved."));    WMSetLabelTextAlignment(panel->specLbl, WACenter);        /**** attributes ****/    panel->attrFrm = WMCreateFrame(panel->win);    WMSetFrameTitle(panel->attrFrm, _("Attributes"));    WMMoveWidget(panel->attrFrm, 15, 45);    WMResizeWidget(panel->attrFrm, frame_width, 250);    for (i=0; i < 10; i++) {	char *caption = NULL;	int flag = 0;	char *descr = NULL;	switch (i) {	 case 0:	    caption = _("Disable Titlebar");            flag = WFLAGP(wwin, no_titlebar);	    descr = _("Remove the titlebar of this window.\n"		      "To access the window commands menu of a window\n"		      "without it's titlebar, press Control+Esc (or the\n"		      "equivalent shortcut, if you changed the default\n"		      "settings).");	    break;	 case 1:	    caption = _("Disable Resizebar");	    flag = WFLAGP(wwin, no_resizebar);	    descr = _("Remove the resizebar of this window."); 	    break;	 case 2:	    caption = _("Disable Close Button");	    flag = WFLAGP(wwin, no_close_button);	    descr = _("Remove the `close window' button of this window.");	    break;	 case 3:	    caption = _("Disable Miniaturize Button");	    flag = WFLAGP(wwin, no_miniaturize_button);	    descr = _("Remove the `miniaturize window' button of the window.");	    break;	 case 4:	    caption = _("Keep on Top / Floating");	    flag = WFLAGP(wwin, floating);	    descr = _("Keep the window over other windows, not allowing\n"		      "them to covert it.");	    break;	 case 5:	    caption = _("Keep at Bottom / Sunken");	    flag = WFLAGP(wwin, sunken);	    descr = _("Keep the window under all other windows.");	    break;	 case 6:	    caption = _("Omnipresent");	    flag = WFLAGP(wwin, omnipresent);	    descr = _("Make window occupy all workspaces.");	    break;	 case 7:	    caption = _("Start Miniaturized");	    flag = WFLAGP(wwin, start_miniaturized);	    descr = _("Make the window be automatically miniaturized when it's\n"		    "first shown.");	    break;	 case 8:	    caption = _("Start Maximized");	    flag = WFLAGP(wwin, start_maximized!=0);	    descr = _("Make the window be automatically maximized when it's\n"		    "first shown.");	    break;	 case 9:	    caption = _("Skip Window List");	    flag = WFLAGP(wwin, skip_window_list);	    descr = _("Do not list the window in the window list menu.");	    break;	}	panel->attrChk[i] = WMCreateSwitchButton(panel->attrFrm);	WMMoveWidget(panel->attrChk[i], 10, 20*(i+1));	WMResizeWidget(panel->attrChk[i], frame_width-15, 20);	WMSetButtonSelected(panel->attrChk[i], flag);	WMSetButtonText(panel->attrChk[i], caption);	WMSetBalloonTextForView(descr, WMWidgetView(panel->attrChk[i]));    }    /**** more attributes ****/    panel->moreFrm = WMCreateFrame(panel->win);    WMSetFrameTitle(panel->moreFrm, _("Advanced"));    WMMoveWidget(panel->moreFrm, 15, 45);    WMResizeWidget(panel->moreFrm, frame_width, 250);#ifdef XKB_BUTTON_HINT    for (i=0; i < 9; i++) {#else    for (i=0; i < 8; i++) {#endif	char *caption = NULL;	int flag = 0;	char *descr = NULL;		switch (i) {	 case 0:	    caption = _("Ignore HideOthers");	    flag = WFLAGP(wwin, no_hide_others);	    descr = _("Do not hide the window when issuing the\n"		      "`HideOthers' command.");	    break;	 case 1:	    caption = _("Don't Bind Keyboard Shortcuts");	    flag = WFLAGP(wwin, no_bind_keys);	    descr = _("Do not bind keyboard shortcuts from Window Maker\n"		      "when this window is focused. This will allow the\n"		      "window to receive all key combinations regardless\n"		      "of your shortcut configuration.");	    break;	 case 2:	    caption = _("Don't Bind Mouse Clicks");	    flag = WFLAGP(wwin, no_bind_mouse);	    descr = _("Do not bind mouse actions, such as `Alt'+drag\n"		      "in the window (when alt is the modifier you have"		      "configured).");	    break;	 case 3:	    caption = _("Keep Inside Screen");	    flag = WFLAGP(wwin, dont_move_off);	    descr = _("Do not allow the window to move itself completely\n"		      "outside the screen. For bug compatibility.\n");	    break;	 case 4:	    caption = _("Don't Let It Take Focus");	    flag = WFLAGP(wwin, no_focusable);	    descr = _("Do not let the window take keyboard focus when you\n"		      "click on it.");	    break;	 case 5:	    caption = _("Don't Save Session");	    flag = WFLAGP(wwin, dont_save_session);	    descr = _("Do not save the associated application in the\n"		      "session's state, so that it won't be restarted\n"		      "together with other applications when Window Maker\n"		      "starts.");	    break;	 case 6:	    caption = _("Emulate Application Icon");	    flag = WFLAGP(wwin, emulate_appicon);	    descr = _("Make this window act as an application that provides\n"		      "enough information to Window Maker for a dockable\n"		      "application icon to be created.");	    break;	 case 7:	    caption = _("Full Screen Maximization");	    flag = WFLAGP(wwin, full_maximize);	    descr = _("Make the window use the whole screen space when it's\n"		      "maximized. The titlebar and resizebar will be moved\n"		      "to outside the screen.");	    break;#ifdef XKB_BUTTON_HINT     case 8:        caption = _("Disable Language Button");        flag = WFLAGP(wwin, no_language_button);        descr = _("Remove the `toggle language' button of the window.");        break;#endif	}	panel->moreChk[i] = WMCreateSwitchButton(panel->moreFrm);	WMMoveWidget(panel->moreChk[i], 10, 20*(i+1));	WMResizeWidget(panel->moreChk[i], frame_width-15, 20);	WMSetButtonSelected(panel->moreChk[i], flag);	WMSetButtonText(panel->moreChk[i], caption);	WMSetBalloonTextForView(descr, WMWidgetView(panel->moreChk[i]));    }    /* miniwindow/workspace */    panel->iconFrm = WMCreateFrame(panel->win);    WMMoveWidget(panel->iconFrm, 15, 50);    WMResizeWidget(panel->iconFrm,  PWIDTH - (2 * 15), 170);    WMSetFrameTitle(panel->iconFrm, _("Miniwindow Image"));    panel->iconLbl = WMCreateLabel(panel->iconFrm);    WMMoveWidget(panel->iconLbl, PWIDTH - (2 * 15) - 22 - 64, 30);    WMResizeWidget(panel->iconLbl, 64, 64);    WMSetLabelRelief(panel->iconLbl, WRGroove);    WMSetLabelImagePosition(panel->iconLbl, WIPImageOnly);        panel->browseIconBtn = WMCreateCommandButton(panel->iconFrm);    WMSetButtonAction(panel->browseIconBtn, chooseIconCallback, panel);    WMMoveWidget(panel->browseIconBtn, 22, 30);    WMResizeWidget(panel->browseIconBtn, 100, 26);    WMSetButtonText(panel->browseIconBtn, _("Browse..."));#if 0    panel->updateIconBtn = WMCreateCommandButton(panel->iconFrm);    WMSetButtonAction(panel->updateIconBtn, (WMAction*)updateIcon, panel);    WMMoveWidget(panel->updateIconBtn, 22, 65);    WMResizeWidget(panel->updateIconBtn, 100, 26);    WMSetButtonText(panel->updateIconBtn, _("Update"));#endif#ifdef wrong_behaviour    WMSetButtonImagePosition(panel->updateIconBtn, WIPRight);    pixmap = WMGetSystemPixmap(scr->wmscreen, WSIReturnArrow);    WMSetButtonImage(panel->updateIconBtn, pixmap);    WMReleasePixmap(pixmap);    pixmap = WMGetSystemPixmap(scr->wmscreen, WSIHighlightedReturnArrow);    WMSetButtonAltImage(panel->updateIconBtn, pixmap);    WMReleasePixmap(pixmap);#endif    panel->fileLbl = WMCreateLabel(panel->iconFrm);    WMMoveWidget(panel->fileLbl, 20, 95);    WMResizeWidget(panel->fileLbl, PWIDTH - (2 * 15) - (2 * 20), 14);    WMSetLabelText(panel->fileLbl, _("Icon File Name:"));    panel->fileText = WMCreateTextField(panel->iconFrm);    WMMoveWidget(panel->fileText, 20, 115);    WMResizeWidget(panel->fileText, PWIDTH - (2 * 15) - (2 * 15), 20);    WMSetTextFieldText(panel->fileText, NULL);    WMAddNotificationObserver(textEditedObserver, panel, 			      WMTextDidEndEditingNotification, 			      panel->fileText);    panel->alwChk = WMCreateSwitchButton(panel->iconFrm);    WMMoveWidget(panel->alwChk, 20, 140);    WMResizeWidget(panel->alwChk, PWIDTH - (2 * 15) - (2 * 15), 20);    WMSetButtonText(panel->alwChk, _("Ignore client supplied icon"));    WMSetButtonSelected(panel->alwChk, WFLAGP(wwin, always_user_icon));    panel->wsFrm = WMCreateFrame(panel->win);    WMMoveWidget(panel->wsFrm, 15, 225);    WMResizeWidget(panel->wsFrm, PWIDTH - (2 * 15), 70);    WMSetFrameTitle(panel->wsFrm, _("Initial Workspace"));    WMSetBalloonTextForView(_("The workspace to place the window when it's"			      "first shown."), WMWidgetView(panel->wsFrm));    panel->wsP = WMCreatePopUpButton(panel->wsFrm);    WMMoveWidget(panel->wsP, 20, 30);    WMResizeWidget(panel->wsP, PWIDTH - (2 * 15) - (2 * 20), 20);    WMAddPopUpButtonItem(panel->wsP, _("Nowhere in particular"));    for (i = 0; i < wwin->screen_ptr->workspace_count; i++) {	WMAddPopUpButtonItem(panel->wsP, scr->workspaces[i]->name);    }    i = wDefaultGetStartWorkspace(wwin->screen_ptr, wwin->wm_instance,                                  wwin->wm_class);    if (i >= 0 && i <= wwin->screen_ptr->workspace_count) {	WMSetPopUpButtonSelectedItem(panel->wsP, i + 1);    } else {	WMSetPopUpButtonSelectedItem(panel->wsP, 0);    }    /* application wide attributes */    if (wwin->main_window != None) {	WApplication *wapp = wApplicationOf(wwin->main_window);		panel->appFrm = WMCreateFrame(panel->win);	WMSetFrameTitle(panel->appFrm, _("Application Wide"));	WMMoveWidget(panel->appFrm, 15, 50);	WMResizeWidget(panel->appFrm, frame_width, 240);		for (i=0; i < 2; i++) {	    char *caption = NULL;	    int flag = 0;	    char *descr = NULL;	    	    switch (i) {	     case 0:		caption = _("Start Hidden");		flag = WFLAGP(wapp->main_window_desc, start_hidden);		descr = _("Automatically hide application when it's started.");		break;	     case 1:		caption = _("No Application Icon");		flag = WFLAGP(wapp->main_window_desc, no_appicon);		descr = _("Disable the application icon for the application.\n"			  "Note that you won't be able to dock it anymore,\n"			  "and any icons that are already docked will stop\n"			  "working correctly.");		break;	    }	    panel->appChk[i] = WMCreateSwitchButton(panel->appFrm);	    WMMoveWidget(panel->appChk[i], 10, 20*(i+1));	    WMResizeWidget(panel->appChk[i], 205, 20);	    WMSetButtonSelected(panel->appChk[i], flag);	    WMSetButtonText(panel->appChk[i], caption);	    WMSetBalloonTextForView(descr, WMWidgetView(panel->appChk[i]));	}		if (WFLAGP(wwin, emulate_appicon)) {	    WMSetButtonEnabled(panel->appChk[1], False);	    WMSetButtonEnabled(panel->moreChk[6], True);	} else {	    WMSetButtonEnabled(panel->appChk[1], True);	    WMSetButtonEnabled(panel->moreChk[6], False);	}    } else {	int tmp;		if ((wwin->transient_for!=None && wwin->transient_for!=scr->root_win)	    || !wwin->wm_class || !wwin->wm_instance)	    tmp = False;	else	    tmp = True;	WMSetButtonEnabled(panel->moreChk[6], tmp);	WMSetPopUpButtonItemEnabled(panel->pagePopUp, 4, False);	panel->appFrm = NULL;    }       /* if the window is a transient, don't let it have a miniaturize     * button */    if (wWindowFor(wwin->transient_for)!=NULL)	WMSetButtonEnabled(panel->attrChk[3], False);    else	WMSetButtonEnabled(panel->attrChk[3], True);        if (!wwin->wm_class && !wwin->wm_instance) {	WMSetPopUpButtonItemEnabled(panel->pagePopUp, 0, False);    }        WMRealizeWidget(panel->win);    WMMapSubwidgets(panel->win);    WMMapSubwidgets(panel->specFrm);    WMMapSubwidgets(panel->attrFrm);    WMMapSubwidgets(panel->moreFrm);    WMMapSubwidgets(panel->iconFrm);    WMMapSubwidgets(panel->wsFrm);    if (panel->appFrm)	WMMapSubwidgets(panel->appFrm);    WMSetPopUpButtonSelectedItem(panel->pagePopUp, 1);    changePage(panel->pagePopUp, panel);        parent = XCreateSimpleWindow(dpy, scr->root_win, 0, 0, PWIDTH, PHEIGHT, 				 0, 0, 0);    XSelectInput(dpy, parent, KeyPressMask|KeyReleaseMask);    panel->parent = parent;    XReparentWindow(dpy, WMWidgetXID(panel->win), parent, 0, 0);    WMMapWidget(panel->win);    XSetTransientForHint(dpy, parent, wwin->client_win);    x = wwin->frame_x+wwin->frame->core->width/2;    y = wwin->frame_y+wwin->frame->top_width*2;    if (y + PHEIGHT > scr->scr_height)	y = scr->scr_height - PHEIGHT - 30;    if (x + PWIDTH > scr->scr_width)	x = scr->scr_width - PWIDTH;    panel->frame = wManageInternalWindow(scr, parent, wwin->client_win, 					 "Inspector", x, y, PWIDTH, PHEIGHT);    if (!selectedBtn)	selectedBtn = panel->defaultRb;    selectSpecification(selectedBtn, panel);    /* kluge to know who should get the key events */    panel->frame->client_leader = WMWidgetXID(panel->win);    WSETUFLAG(panel->frame, no_closable, 0);    WSETUFLAG(panel->frame, no_close_button, 0);    wWindowUpdateButtonImages(panel->frame);    wFrameWindowShowButton(panel->frame->frame, WFF_RIGHT_BUTTON);    panel->frame->frame->on_click_right = destroyInspector;    wWindowMap(panel->frame);    showIconFor(WMWidgetScreen(panel->alwChk), panel, wwin->wm_instance, 		wwin->wm_class, UPDATE_TEXT_FIELD);    return panel;}