static void chooseIconCallback(WMWidget *self, void *clientData) { char *file; InspectorPanel *panel = (InspectorPanel *) clientData; int result; panel->choosingIcon = 1; WMSetButtonEnabled(panel->browseIconBtn, False); result = wIconChooserDialog(panel->frame->screen_ptr, &file, panel->inspected->wm_instance, panel->inspected->wm_class); panel->choosingIcon = 0; if (!panel->destroyed) { /* kluge */ if (result) { WMSetTextFieldText(panel->fileText, file); showIconFor(WMWidgetScreen(self), panel, NULL, NULL, USE_TEXT_FIELD); } WMSetButtonEnabled(panel->browseIconBtn, True); } else { freeInspector(panel); } if (result) wfree(file); }
static void chooseIconCallback(WMWidget * self, void *clientData) { char *file; AppSettingsPanel *panel = (AppSettingsPanel *) clientData; int result; panel->choosingIcon = 1; WMSetButtonEnabled(panel->browseBtn, False); result = wIconChooserDialog(panel->wwin->screen_ptr, &file, panel->editedIcon->wm_instance, panel->editedIcon->wm_class); panel->choosingIcon = 0; if (!panel->destroyed) { if (result) { WMSetTextFieldText(panel->iconField, file); wfree(file); updateSettingsPanelIcon(panel); } WMSetButtonEnabled(panel->browseBtn, True); } else { /* kluge for the case, the user asked to close the panel before * the icon chooser */ DestroyDockAppSettingsPanel(panel); } }
static void selectSpecification(WMWidget *bPtr, void *data) { InspectorPanel *panel = (InspectorPanel *) data; char str[256]; WWindow *wwin = panel->inspected; if (bPtr == panel->defaultRb && (wwin->wm_instance || wwin->wm_class)) WMSetButtonEnabled(panel->applyBtn, False); else WMSetButtonEnabled(panel->applyBtn, True); snprintf(str, sizeof(str), _("Inspecting %s.%s"), wwin->wm_instance ? wwin->wm_instance : "?", wwin->wm_class ? wwin->wm_class : "?"); wFrameWindowChangeTitle(panel->frame->frame, str); }
static void create_tab_app_specific(WWindow *wwin, InspectorPanel *panel, int frame_width) { WScreen *scr = wwin->screen_ptr; int i = 0, flag = 0, tmp; char *caption = NULL, *descr = NULL; if (wwin->main_window != None) { WApplication *wapp = wApplicationOf(wwin->main_window); panel->appFrm = WMCreateFrame(panel->win); WMSetFrameTitle(panel->appFrm, _("Application Attributes")); WMMoveWidget(panel->appFrm, 15, 50); WMResizeWidget(panel->appFrm, frame_width, 240); for (i = 0; i < wlengthof(panel->appChk); i++) { 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; case 2: caption = _("Shared application icon"); flag = WFLAGP(wapp->main_window_desc, shared_appicon); descr = _("Use a single shared application icon for all of\n" "the instances of this application.\n"); 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[7], True); } else { WMSetButtonEnabled(panel->appChk[1], True); WMSetButtonEnabled(panel->moreChk[7], False); } } else { 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[7], tmp); WMSetPopUpButtonItemEnabled(panel->pagePopUp, 4, False); panel->appFrm = NULL; } }
static InspectorPanel *createInspectorForWindow(WWindow *wwin, int xpos, int ypos, Bool showSelectPanel) { WScreen *scr = wwin->screen_ptr; InspectorPanel *panel; Window parent; char *str = NULL, *tmp = NULL; int x, y, btn_width, frame_width; WMButton *selectedBtn = NULL; spec_text = _("The configuration will apply to all\n" "windows that have their WM_CLASS\n" "property set to the above selected\n" "name, when saved."); 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 */ btn_width = (PWIDTH - (2 * 15) - (2 * 10)) / 3; panel->saveBtn = WMCreateCommandButton(panel->win); WMSetButtonAction(panel->saveBtn, saveSettings, panel); WMMoveWidget(panel->saveBtn, (2 * (btn_width + 10)) + 15, PHEIGHT - 40); 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, applySettings, panel); WMMoveWidget(panel->applyBtn, btn_width + 10 + 15, PHEIGHT - 40); WMSetButtonText(panel->applyBtn, _("Apply")); WMResizeWidget(panel->applyBtn, btn_width, 28); panel->revertBtn = WMCreateCommandButton(panel->win); WMSetButtonAction(panel->revertBtn, revertSettings, panel); WMMoveWidget(panel->revertBtn, 15, PHEIGHT - 40); WMSetButtonText(panel->revertBtn, _("Reload")); WMResizeWidget(panel->revertBtn, btn_width, 28); /* page selection popup button */ panel->pagePopUp = WMCreatePopUpButton(panel->win); WMSetPopUpButtonAction(panel->pagePopUp, 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, 145); 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) { tmp = wstrconcat(wwin->wm_instance, "."); str = wstrconcat(tmp, 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); wfree(tmp); wfree(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->selWinB = WMCreateCommandButton(panel->specFrm); WMMoveWidget(panel->selWinB, 20, 145 - 24 - 10); WMResizeWidget(panel->selWinB, frame_width - 2 * 10 - 20, 24); WMSetButtonText(panel->selWinB, _("Select window")); WMSetButtonAction(panel->selWinB, selectWindow, panel); panel->specLbl = WMCreateLabel(panel->win); WMMoveWidget(panel->specLbl, 15, 210); WMResizeWidget(panel->specLbl, frame_width, 100); WMSetLabelText(panel->specLbl, spec_text); WMSetLabelWraps(panel->specLbl, True); WMSetLabelTextAlignment(panel->specLbl, WALeft); /**** attributes ****/ create_tab_window_attributes(wwin, panel, frame_width); create_tab_window_advanced(wwin, panel, frame_width); create_tab_icon_workspace(wwin, panel); create_tab_app_specific(wwin, panel, frame_width); /* if the window is a transient, don't let it have a miniaturize button */ if (wwin->transient_for != None && wwin->transient_for != scr->root_win) 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); if (showSelectPanel) { WMSetPopUpButtonSelectedItem(panel->pagePopUp, 0); changePage(panel->pagePopUp, panel); } else { 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); if (xpos == UNDEFINED_POS) { 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; } else { x = xpos; y = ypos; } panel->frame = wManageInternalWindow(scr, parent, wwin->client_win, "Inspector", x, y, PWIDTH, PHEIGHT); if (!selectedBtn) selectedBtn = panel->defaultRb; WMSetButtonSelected(selectedBtn, True); 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; }