static WMPropList* getDefaultMenu(_Panel *panel) { WMPropList *menu; char *menuPath, *gspath; gspath = wusergnusteppath(); menuPath = wmalloc(strlen(gspath)+128); sprintf(menuPath, "%s/Library/WindowMaker/plmenu", gspath); menu = WMReadPropListFromFile(menuPath); if (!menu) { char *buffer, *msg; msg = _("Could not open default menu from '%s'"); buffer = wmalloc(strlen(msg) + strlen(menuPath) + 10); sprintf(buffer, msg, menuPath); WMRunAlertPanel(WMWidgetScreen(panel->parent), panel->parent, _("Error"), buffer, _("OK"), NULL, NULL); wfree(buffer); } wfree(menuPath); return menu; }
static void downloadCallback(WMWidget * w, void *data) { _Panel *panel = (_Panel *) data; pid_t newPid; WMButton *button = (WMButton *) w; pid_t *pid; if (button == panel->totB) { pid = &panel->tilePID; } else { pid = &panel->barPID; } if (*pid == 0) { newPid = downloadFile(WMWidgetScreen(w), panel, NULL); if (newPid < 0) { return; } WMSetButtonText(button, _("Stop")); if (button == panel->totB) { AddDeadChildHandler(newPid, finishedTileDownload, data); } else { AddDeadChildHandler(newPid, finishedBarDownload, data); } *pid = newPid; } else { *pid = 0; WMSetButtonText(button, _("Download")); } }
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 Bool shouldRemoveItem(struct WEditMenuDelegate *delegate, WEditMenu * menu, WEditMenuItem * item) { _Panel *panel = (_Panel *) delegate->data; if (panel->dontAsk) return True; if (WGetEditMenuSubmenu(item)) { int res; res = WMRunAlertPanel(WMWidgetScreen(menu), NULL, _("Remove Submenu"), _("Removing this item will destroy all items inside\n" "the submenu. Do you really want to do that?"), _("Yes"), _("No"), _("Yes, don't ask again")); switch (res) { case WAPRDefault: return True; case WAPRAlternate: return False; case WAPROther: panel->dontAsk = True; return True; } } return True; }
static void browseForFile(WMWidget * self, void *clientData) { _Panel *panel = (_Panel *) clientData; WMFilePanel *filePanel; char *text, *oldprog, *newprog; filePanel = WMGetOpenPanel(WMWidgetScreen(self)); text = WMGetTextFieldText(panel->commandT); oldprog = wtrimspace(text); wfree(text); if (oldprog[0] == 0 || oldprog[0] != '/') { wfree(oldprog); oldprog = wstrdup("/"); } else { char *ptr = oldprog; while (*ptr && !isspace(*ptr)) ptr++; *ptr = 0; } WMSetFilePanelCanChooseDirectories(filePanel, False); if (WMRunModalFilePanelForDirectory(filePanel, panel->parent, oldprog, _("Select Program"), NULL) == True) { newprog = WMGetFilePanelFileName(filePanel); WMSetTextFieldText(panel->commandT, newprog); updateMenuItem(panel, panel->currentItem, panel->commandT); wfree(newprog); } wfree(oldprog); }
static void sgrabClicked(WMWidget * w, void *data) { _Panel *panel = (_Panel *) data; Display *dpy = WMScreenDisplay(WMWidgetScreen(panel->parent)); char *shortcut; if (w == panel->sclearB) { WMSetTextFieldText(panel->shortT, ""); updateMenuItem(panel, panel->currentItem, panel->shortT); return; } if (!panel->capturing) { panel->capturing = 1; WMSetButtonText(w, _("Cancel")); XGrabKeyboard(dpy, WMWidgetXID(panel->parent), True, GrabModeAsync, GrabModeAsync, CurrentTime); shortcut = capture_shortcut(dpy, &panel->capturing, 0); if (shortcut) { WMSetTextFieldText(panel->shortT, shortcut); updateMenuItem(panel, panel->currentItem, panel->shortT); wfree(shortcut); } } panel->capturing = 0; WMSetButtonText(w, _("Capture")); XUngrabKeyboard(dpy, CurrentTime); }
WMTabView *WMCreateTabView(WMWidget * parent) { TabView *tPtr; WMScreen *scr = WMWidgetScreen(parent); tPtr = wmalloc(sizeof(TabView)); tPtr->widgetClass = WC_TabView; tPtr->view = W_CreateView(W_VIEW(parent)); if (!tPtr->view) { wfree(tPtr); return NULL; } tPtr->view->self = tPtr; tPtr->view->delegate = &delegate; tPtr->lightGray = WMCreateRGBColor(scr, 0xd9d9, 0xd9d9, 0xd9d9, False); tPtr->tabColor = WMCreateRGBColor(scr, 0x8420, 0x8420, 0x8420, False); tPtr->font = WMRetainFont(scr->normalFont); tPtr->flags.type = WTTopTabsBevelBorder; tPtr->flags.bordered = 1; tPtr->flags.uniformTabs = 0; tPtr->flags.enabled = 1; WMCreateEventHandler(tPtr->view, ExposureMask | StructureNotifyMask | ButtonPressMask, handleEvents, tPtr); WMResizeWidget(tPtr, DEFAULT_WIDTH, DEFAULT_HEIGHT); tPtr->tabHeight = WMFontHeight(tPtr->font) + 3; return tPtr; }
void ResetGame(void) { int i, x, y, ox, oy; MoveCount = 0; for (i = 0; i < Size*Size-1; i++) { Map[i] = i; } Map[i] = -1; ox = x = Size-1; oy = y = Size-1; for (i = 0; i < 5; i++) { int ok; ok = 1; switch (rand()%4) { case 0: if (x > 0) x--; else ok = 0; break; case 2: if (x < Size-1) x++; else ok = 0; break; case 1: if (y > 0) y--; else ok = 0; break; case 3: if (y < Size-1) y++; else ok = 0; break; } if (ok) { MoveButton(MAP(x,y), ox, oy); SWAP(MAP(ox, oy), MAP(x, y)); while (XPending(WMScreenDisplay(WMWidgetScreen(win)))) { XEvent ev; WMNextEvent(WMScreenDisplay(WMWidgetScreen(win)), &ev); WMHandleEvent(&ev); } ox = x; oy = y; } } }
static void textEditedObserver(void *observerData, WMNotification *notification) { InspectorPanel *panel = (InspectorPanel *) observerData; if ((long)WMGetNotificationClientData(notification) != WMReturnTextMovement) return; showIconFor(WMWidgetScreen(panel->win), panel, NULL, NULL, USE_TEXT_FIELD); }
static void speedChange(WMWidget * w, void *data) { _Panel *panel = (_Panel *) data; int i; char buffer[64]; int threshold; char *tmp; if (w == NULL) { float accel; tmp = WMGetTextFieldText(panel->acceT); if (sscanf(tmp, "%f", &accel) != 1 || accel < 0) { WMRunAlertPanel(WMWidgetScreen(panel->acceT), GetWindow(), _("Error"), _("Invalid mouse acceleration value. Must be a positive real value."), _("OK"), NULL, NULL); wfree(tmp); return; } panel->acceleration = accel; wfree(tmp); } else { i = (int)WMGetSliderValue(panel->speedS); panel->acceleration = 0.25 + (i * 0.25); sprintf(buffer, "%.2f", 0.25 + (i * 0.25)); WMSetTextFieldText(panel->acceT, buffer); } tmp = WMGetTextFieldText(panel->threT); if (sscanf(tmp, "%i", &threshold) != 1 || threshold < 0 || threshold > panel->maxThreshold) { WMRunAlertPanel(WMWidgetScreen(panel->parent), GetWindow(), _("Error"), _ ("Invalid mouse acceleration threshold value. Must be the number of pixels to travel before accelerating."), _("OK"), NULL, NULL); } else { setMouseAccel(WMWidgetScreen(panel->parent), panel->acceleration, threshold); } wfree(tmp); }
static WEditMenu* buildSubmenu(_Panel *panel, WMPropList *pl) { WMScreen *scr = WMWidgetScreen(panel->parent); WEditMenu *menu; WEditMenuItem *item; char *title; WMPropList *tp, *bp; int i; tp = WMGetFromPLArray(pl, 0); title = WMGetFromPLString(tp); menu = WCreateEditMenu(scr, title); for (i = 1; i < WMGetPropListItemCount(pl); i++) { WMPropList *pi; pi = WMGetFromPLArray(pl, i); tp = WMGetFromPLArray(pi, 0); bp = WMGetFromPLArray(pi, 1); title = WMGetFromPLString(tp); if (!bp || WMIsPLArray(bp)) { /* it's a submenu */ WEditMenu *submenu; submenu = buildSubmenu(panel, pi); item = WAddMenuItemWithTitle(menu, title); WSetEditMenuSubmenu(menu, item, submenu); } else { ItemData *data; item = WAddMenuItemWithTitle(menu, title); data = parseCommand(pi); if (panel->markerPix[data->type]) WSetEditMenuItemImage(item, panel->markerPix[data->type]); WSetEditMenuItemData(item, data, (WMCallback*)freeItemData); } } WSetEditMenuAcceptsDrop(menu, True); WSetEditMenuDelegate(menu, &menuDelegate); WMRealizeWidget(menu); return menu; }
static WEditMenu *putNewSubmenu(WEditMenu * menu, const char *title) { WEditMenu *tmp; WEditMenuItem *item; item = WAddMenuItemWithTitle(menu, title); tmp = WCreateEditMenu(WMWidgetScreen(menu), title); WSetEditMenuAcceptsDrop(tmp, True); WSetEditMenuDelegate(tmp, &menuDelegate); WSetEditMenuSubmenu(menu, item, tmp); return tmp; }
static void showData(_Panel *panel) { char *gspath; char *menuPath; WMPropList *pmenu; gspath = wusergnusteppath(); menuPath = wmalloc(strlen(gspath)+32); strcpy(menuPath, gspath); strcat(menuPath, "/Defaults/WMRootMenu"); pmenu = WMReadPropListFromFile(menuPath); if (!pmenu || !WMIsPLArray(pmenu)) { int res; res = WMRunAlertPanel(WMWidgetScreen(panel->parent), panel->parent, _("Warning"), _("The menu file format currently in use is not supported\n" "by this tool. Do you want to discard the current menu\n" "to use this tool?"), _("Yes, Discard and Update"), _("No, Keep Current Menu"), NULL); if (res == WAPRDefault) { pmenu = getDefaultMenu(panel); if (!pmenu) { pmenu = WMCreatePLArray(WMCreatePLString("Applications"), NULL); } } else { panel->dontSave = True; return; } } panel->menuPath = menuPath; buildMenuFromPL(panel, pmenu); WMReleasePropList(pmenu); }
static WMPropList *getDefaultMenu(_Panel * panel) { WMPropList *menu; static const char menuPath[] = WMAKER_RESOURCE_PATH "/plmenu"; menu = WMReadPropListFromFile(menuPath); if (!menu) { char *buffer, *msg; msg = _("Could not open default menu from '%s'"); buffer = wmalloc(strlen(msg) + strlen(menuPath) + 10); sprintf(buffer, msg, menuPath); WMRunAlertPanel(WMWidgetScreen(panel->parent), panel->parent, _("Error"), buffer, _("OK"), NULL, NULL); wfree(buffer); } return menu; }
void buttonClick(WMWidget *w, void *ptr) { char buffer[300]; if (SlideButton((int)ptr)) { MoveCount++; if (CheckWin()) { sprintf(buffer, "You finished the game in %i moves.", MoveCount); if (WMRunAlertPanel(WMWidgetScreen(w), win, "You Won!", buffer, "Wee!", "Gah! Lemme retry!", NULL) == WAPRDefault) { exit(0); } ResetGame(); } } }
static void browseForFile(WMWidget *w, void *data) { _Panel *panel = (_Panel*)data; WMFilePanel *filePanel; filePanel = WMGetOpenPanel(WMWidgetScreen(w)); WMSetFilePanelCanChooseFiles(filePanel, False); if (WMRunModalFilePanelForDirectory(filePanel, panel->parent, "/", _("Select directory"), NULL) == True) { char *str = WMGetFilePanelFileName(filePanel); if (str) { int len = strlen(str); /* Remove the trailing '/' except if the path is exactly / */ if (len > 1 && str[len-1] == '/') { str[len-1] = '\0'; len--; } if (len > 0) { WMList *lPtr; int i; if (w == panel->icoaB) lPtr = panel->icoL; else if (w == panel->pixaB) lPtr = panel->pixL; i = WMGetListSelectedItemRow(lPtr); if (i >= 0) i++; addPathToList(lPtr, i, str); WMSetListBottomPosition(lPtr, WMGetListNumberOfRows(lPtr)); wfree(str); } } } }
static void paintItem(WMList *lPtr, int index, Drawable d, char *text, int state, WMRect *rect) { int width, height, x, y; _Panel *panel = (_Panel*)WMGetHangedData(lPtr); WMScreen *scr = WMWidgetScreen(lPtr); Display *dpy = WMScreenDisplay(scr); WMColor *backColor = (state & WLDSSelected) ? panel->white : panel->gray; width = rect->size.width; height = rect->size.height; x = rect->pos.x; y = rect->pos.y; XFillRectangle(dpy, d, WMColorGC(backColor), x, y, width, height); if (state & 1) { WMDrawString(scr, d, panel->red, panel->font, x+4, y, text, strlen(text)); } else { WMDrawString(scr, d, panel->black, panel->font, x+4, y, text, strlen(text)); } }
static void updateSettingsPanelIcon(AppSettingsPanel * panel) { char *file; file = WMGetTextFieldText(panel->iconField); if (!file) WMSetLabelImage(panel->iconLabel, NULL); else { char *path; path = FindImage(wPreferences.icon_path, file); if (!path) { wwarning(_("could not find icon %s, used in a docked application"), file); wfree(file); WMSetLabelImage(panel->iconLabel, NULL); return; } else { WMPixmap *pixmap; RColor color; color.red = 0xae; color.green = 0xaa; color.blue = 0xae; color.alpha = 0; pixmap = WMCreateBlendedPixmapFromFile(WMWidgetScreen(panel->win), path, &color); if (!pixmap) { WMSetLabelImage(panel->iconLabel, NULL); } else { WMSetLabelImage(panel->iconLabel, pixmap); WMReleasePixmap(pixmap); } } wfree(file); wfree(path); } }
static void createPanel(_Panel * p) { _Panel *panel = (_Panel *) p; WMScreen *scr = WMWidgetScreen(panel->parent); WMColor *black = WMBlackColor(scr); WMColor *white = WMWhiteColor(scr); WMColor *gray = WMGrayColor(scr); WMFont *bold = WMBoldSystemFontOfSize(scr, 12); WMFont *font = WMSystemFontOfSize(scr, 12); WMLabel *label; int width; menuDelegate.data = panel; panel->boldFont = bold; panel->normalFont = font; panel->black = black; panel->white = white; panel->gray = gray; { Pixmap pix; Display *dpy = WMScreenDisplay(scr); GC gc; WMPixmap *pixm; pixm = WMCreatePixmap(scr, 7, 7, WMScreenDepth(scr), True); pix = WMGetPixmapXID(pixm); XDrawLine(dpy, pix, WMColorGC(black), 0, 3, 6, 3); XDrawLine(dpy, pix, WMColorGC(black), 3, 0, 3, 6); /* XDrawLine(dpy, pix, WMColorGC(black), 1, 0, 3, 3); XDrawLine(dpy, pix, WMColorGC(black), 1, 6, 3, 3); XDrawLine(dpy, pix, WMColorGC(black), 0, 0, 0, 6); */ pix = WMGetPixmapMaskXID(pixm); gc = XCreateGC(dpy, pix, 0, NULL); XSetForeground(dpy, gc, 0); XFillRectangle(dpy, pix, gc, 0, 0, 7, 7); XSetForeground(dpy, gc, 1); XDrawLine(dpy, pix, gc, 0, 3, 6, 3); XDrawLine(dpy, pix, gc, 3, 0, 3, 6); panel->markerPix[ExternalInfo] = pixm; panel->markerPix[PipeInfo] = pixm; panel->markerPix[PLPipeInfo] = pixm; panel->markerPix[DirectoryInfo] = pixm; panel->markerPix[WSMenuInfo] = pixm; panel->markerPix[WWindowListInfo] = pixm; XFreeGC(dpy, gc); } panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); panel->typeP = WMCreatePopUpButton(panel->box); WMResizeWidget(panel->typeP, 150, 20); WMMoveWidget(panel->typeP, 10, 10); WMAddPopUpButtonItem(panel->typeP, _("New Items")); WMAddPopUpButtonItem(panel->typeP, _("Sample Commands")); WMAddPopUpButtonItem(panel->typeP, _("Sample Submenus")); WMSetPopUpButtonAction(panel->typeP, changedItemPad, panel); WMSetPopUpButtonSelectedItem(panel->typeP, 0); { WEditMenu *pad; pad = makeFactoryMenu(panel->box, 150); WMMoveWidget(pad, 10, 40); putNewItem(panel, pad, ExecInfo, _("Run Program")); putNewItem(panel, pad, CommandInfo, _("Internal Command")); putNewSubmenu(pad, _("Submenu")); putNewItem(panel, pad, ExternalInfo, _("External Submenu")); putNewItem(panel, pad, PipeInfo, _("Generated Submenu")); putNewItem(panel, pad, PLPipeInfo, _("Generated PL Menu")); putNewItem(panel, pad, DirectoryInfo, _("Directory Contents")); putNewItem(panel, pad, WSMenuInfo, _("Workspace Menu")); putNewItem(panel, pad, WWindowListInfo, _("Window List Menu")); panel->itemPad[0] = pad; } { WEditMenu *pad; ItemData *data; WMScrollView *sview; sview = WMCreateScrollView(panel->box); WMResizeWidget(sview, 150, 180); WMMoveWidget(sview, 10, 40); WMSetScrollViewHasVerticalScroller(sview, True); pad = makeFactoryMenu(panel->box, 130); WMSetScrollViewContentView(sview, WMWidgetView(pad)); data = putNewItem(panel, pad, ExecInfo, _("XTerm")); data->param.exec.command = "xterm -sb -sl 2000 -bg black -fg white"; data = putNewItem(panel, pad, ExecInfo, _("rxvt")); data->param.exec.command = "rxvt"; data = putNewItem(panel, pad, ExecInfo, _("ETerm")); data->param.exec.command = "eterm"; data = putNewItem(panel, pad, ExecInfo, _("Run...")); data->param.exec.command = _("%A(Run,Type command to run)"); data = putNewItem(panel, pad, ExecInfo, _("Firefox")); data->param.exec.command = "firefox"; data = putNewItem(panel, pad, ExecInfo, _("gimp")); data->param.exec.command = "gimp"; data = putNewItem(panel, pad, ExecInfo, _("epic")); data->param.exec.command = "xterm -e epic"; data = putNewItem(panel, pad, ExecInfo, _("ee")); data->param.exec.command = "ee"; data = putNewItem(panel, pad, ExecInfo, _("xv")); data->param.exec.command = "xv"; data = putNewItem(panel, pad, ExecInfo, _("Evince")); data->param.exec.command = "evince"; data = putNewItem(panel, pad, ExecInfo, _("ghostview")); data->param.exec.command = "gv"; data = putNewItem(panel, pad, CommandInfo, _("Exit Window Maker")); data->param.command.command = 3; WMMapWidget(pad); panel->itemPad[1] = sview; } { WEditMenu *pad, *smenu; ItemData *data; WMScrollView *sview; sview = WMCreateScrollView(panel->box); WMResizeWidget(sview, 150, 180); WMMoveWidget(sview, 10, 40); WMSetScrollViewHasVerticalScroller(sview, True); pad = makeFactoryMenu(panel->box, 130); WMSetScrollViewContentView(sview, WMWidgetView(pad)); data = putNewItem(panel, pad, ExternalInfo, _("Debian Menu")); data->param.pipe.command = "/etc/GNUstep/Defaults/menu.hook"; data = putNewItem(panel, pad, PipeInfo, _("RedHat Menu")); data->param.pipe.command = "wmconfig --output wmaker"; data = putNewItem(panel, pad, PipeInfo, _("Menu Conectiva")); data->param.pipe.command = "wmconfig --output wmaker"; data = putNewItem(panel, pad, DirectoryInfo, _("Themes")); data->param.directory.command = "setstyle"; data->param.directory.directory = "/usr/share/WindowMaker/Themes /usr/local/share/WindowMaker/Themes $HOME/GNUstep/Library/WindowMaker/Themes"; data->param.directory.stripExt = 1; data = putNewItem(panel, pad, DirectoryInfo, _("Bg Images (scale)")); data->param.directory.command = "wmsetbg -u -s"; data->param.directory.directory = "/opt/kde2/share/wallpapers /usr/share/WindowMaker/Backgrounds $HOME/GNUstep/Library/WindowMaker/Backgrounds"; data->param.directory.stripExt = 1; data = putNewItem(panel, pad, DirectoryInfo, _("Bg Images (tile)")); data->param.directory.command = "wmsetbg -u -t"; data->param.directory.directory = "/opt/kde2/share/wallpapers /usr/share/WindowMaker/Backgrounds $HOME/GNUstep/Library/WindowMaker/Backgrounds"; data->param.directory.stripExt = 1; smenu = putNewSubmenu(pad, _("Assorted XTerms")); data = putNewItem(panel, smenu, ExecInfo, _("XTerm Yellow on Blue")); data->param.exec.command = "xterm -sb -sl 2000 -bg midnightblue -fg yellow"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm White on Black")); data->param.exec.command = "xterm -sb -sl 2000 -bg black -fg white"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm Black on White")); data->param.exec.command = "xterm -sb -sl 2000 -bg white -fg black"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm Black on Beige")); data->param.exec.command = "xterm -sb -sl 2000 -bg '#bbbb99' -fg black"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm White on Green")); data->param.exec.command = "xterm -sb -sl 2000 -bg '#228822' -fg white"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm White on Olive")); data->param.exec.command = "xterm -sb -sl 2000 -bg '#335533' -fg white"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm Blue on Blue")); data->param.exec.command = "xterm -sb -sl 2000 -bg '#112244' -fg '#88aabb'"; data = putNewItem(panel, smenu, ExecInfo, _("XTerm BIG FONTS")); data->param.exec.command = "xterm -sb -sl 2000 -bg black -fg white -fn 10x20"; WMMapWidget(pad); panel->itemPad[2] = sview; } width = FRAME_WIDTH - 20 - 150 - 10 - 2; panel->optionsF = WMCreateFrame(panel->box); WMResizeWidget(panel->optionsF, width, FRAME_HEIGHT - 15); WMMoveWidget(panel->optionsF, 10 + 150 + 10, 5); width -= 20; /* command */ panel->commandF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->commandF, width, 50); WMMoveWidget(panel->commandF, 10, 20); WMSetFrameTitle(panel->commandF, _("Program to Run")); WMSetFrameTitlePosition(panel->commandF, WTPAtTop); panel->commandT = WMCreateTextField(panel->commandF); WMResizeWidget(panel->commandT, width - 95, 20); WMMoveWidget(panel->commandT, 10, 20); panel->browseB = WMCreateCommandButton(panel->commandF); WMResizeWidget(panel->browseB, 70, 24); WMMoveWidget(panel->browseB, width - 80, 18); WMSetButtonText(panel->browseB, _("Browse")); WMSetButtonAction(panel->browseB, browseForFile, panel); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->commandT); #if 0 panel->xtermC = WMCreateSwitchButton(panel->commandF); WMResizeWidget(panel->xtermC, width - 20, 20); WMMoveWidget(panel->xtermC, 10, 50); WMSetButtonText(panel->xtermC, _("Run the program inside a Xterm")); #endif WMMapSubwidgets(panel->commandF); /* path */ panel->pathF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->pathF, width, 150); WMMoveWidget(panel->pathF, 10, 40); WMSetFrameTitle(panel->pathF, _("Path for Menu")); panel->pathT = WMCreateTextField(panel->pathF); WMResizeWidget(panel->pathT, width - 20, 20); WMMoveWidget(panel->pathT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->pathT); label = WMCreateLabel(panel->pathF); WMResizeWidget(label, width - 20, 80); WMMoveWidget(label, 10, 50); WMSetLabelText(label, _("Enter the path for a file containing a menu\n" "or a list of directories with the programs you\n" "want to have listed in the menu. Ex:\n" "~/GNUstep/Library/WindowMaker/menu\n" "or\n" "/usr/bin ~/xbin")); WMMapSubwidgets(panel->pathF); /* pipe */ panel->pipeF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->pipeF, width, 155); WMMoveWidget(panel->pipeF, 10, 30); WMSetFrameTitle(panel->pipeF, _("Command")); panel->pipeT = WMCreateTextField(panel->pipeF); WMResizeWidget(panel->pipeT, width - 20, 20); WMMoveWidget(panel->pipeT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->pipeT); label = WMCreateLabel(panel->pipeF); WMResizeWidget(label, width - 20, 40); WMMoveWidget(label, 10, 50); WMSetLabelText(label, _("Enter a command that outputs a menu\n" "definition to stdout when invoked.")); panel->pipeCacheB = WMCreateSwitchButton(panel->pipeF); WMResizeWidget(panel->pipeCacheB, width - 20, 40); WMMoveWidget(panel->pipeCacheB, 10, 110); WMSetButtonText(panel->pipeCacheB, _("Cache menu contents after opening for\n" "the first time")); WMMapSubwidgets(panel->pipeF); /* proplist pipe */ panel->plpipeF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->plpipeF, width, 155); WMMoveWidget(panel->plpipeF, 10, 30); WMSetFrameTitle(panel->plpipeF, _("Command")); panel->plpipeT = WMCreateTextField(panel->plpipeF); WMResizeWidget(panel->plpipeT, width - 20, 20); WMMoveWidget(panel->plpipeT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->plpipeT); label = WMCreateLabel(panel->plpipeF); WMResizeWidget(label, width - 20, 40); WMMoveWidget(label, 10, 50); WMSetLabelText(label, _("Enter a command that outputs a proplist menu\n" "definition to stdout when invoked.")); panel->plpipeCacheB = WMCreateSwitchButton(panel->plpipeF); WMResizeWidget(panel->plpipeCacheB, width - 20, 40); WMMoveWidget(panel->plpipeCacheB, 10, 110); WMSetButtonText(panel->plpipeCacheB, _("Cache menu contents after opening for\n" "the first time")); WMMapSubwidgets(panel->plpipeF); /* directory menu */ panel->dcommandF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->dcommandF, width, 90); WMMoveWidget(panel->dcommandF, 10, 25); WMSetFrameTitle(panel->dcommandF, _("Command to Open Files")); panel->dcommandT = WMCreateTextField(panel->dcommandF); WMResizeWidget(panel->dcommandT, width - 20, 20); WMMoveWidget(panel->dcommandT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->dcommandT); label = WMCreateLabel(panel->dcommandF); WMResizeWidget(label, width - 20, 45); WMMoveWidget(label, 10, 40); WMSetLabelText(label, _("Enter the command you want to use to open the\n" "files in the directories listed below.")); WMMapSubwidgets(panel->dcommandF); panel->dpathF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->dpathF, width, 80); WMMoveWidget(panel->dpathF, 10, 125); WMSetFrameTitle(panel->dpathF, _("Directories with Files")); panel->dpathT = WMCreateTextField(panel->dpathF); WMResizeWidget(panel->dpathT, width - 20, 20); WMMoveWidget(panel->dpathT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->dpathT); panel->dstripB = WMCreateSwitchButton(panel->dpathF); WMResizeWidget(panel->dstripB, width - 20, 20); WMMoveWidget(panel->dstripB, 10, 50); WMSetButtonText(panel->dstripB, _("Strip extensions from file names")); WMSetButtonAction(panel->dstripB, buttonClicked, panel); WMMapSubwidgets(panel->dpathF); /* shortcut */ panel->shortF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->shortF, width, 50); WMMoveWidget(panel->shortF, 10, 160); WMSetFrameTitle(panel->shortF, _("Keyboard Shortcut")); panel->shortT = WMCreateTextField(panel->shortF); WMResizeWidget(panel->shortT, width - 20 - 150, 20); WMMoveWidget(panel->shortT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->shortT); panel->sgrabB = WMCreateCommandButton(panel->shortF); WMResizeWidget(panel->sgrabB, 70, 24); WMMoveWidget(panel->sgrabB, width - 80, 18); WMSetButtonText(panel->sgrabB, _("Capture")); WMSetButtonAction(panel->sgrabB, sgrabClicked, panel); panel->sclearB = WMCreateCommandButton(panel->shortF); WMResizeWidget(panel->sclearB, 70, 24); WMMoveWidget(panel->sclearB, width - 155, 18); WMSetButtonText(panel->sclearB, _("Clear")); WMSetButtonAction(panel->sclearB, sgrabClicked, panel); WMMapSubwidgets(panel->shortF); /* internal command */ panel->icommandL = WMCreateList(panel->optionsF); WMResizeWidget(panel->icommandL, width, 80); WMMoveWidget(panel->icommandL, 10, 20); WMSetListAction(panel->icommandL, icommandLClicked, panel); WMAddNotificationObserver(dataChanged, panel, WMListSelectionDidChangeNotification, panel->icommandL); WMInsertListItem(panel->icommandL, 0, _("Arrange Icons")); WMInsertListItem(panel->icommandL, 1, _("Hide All Windows Except For The Focused One")); WMInsertListItem(panel->icommandL, 2, _("Show All Windows")); WMInsertListItem(panel->icommandL, 3, _("Exit Window Maker")); WMInsertListItem(panel->icommandL, 4, _("Exit X Session")); WMInsertListItem(panel->icommandL, 5, _("Restart Window Maker")); WMInsertListItem(panel->icommandL, 6, _("Start Another Window Manager : (")); WMInsertListItem(panel->icommandL, 7, _("Save Current Session")); WMInsertListItem(panel->icommandL, 8, _("Clear Saved Session")); WMInsertListItem(panel->icommandL, 9, _("Refresh Screen")); WMInsertListItem(panel->icommandL, 10, _("Open Info Panel")); WMInsertListItem(panel->icommandL, 11, _("Open Copyright Panel")); panel->paramF = WMCreateFrame(panel->optionsF); WMResizeWidget(panel->paramF, width, 50); WMMoveWidget(panel->paramF, 10, 105); WMSetFrameTitle(panel->paramF, _("Window Manager to Start")); panel->paramT = WMCreateTextField(panel->paramF); WMResizeWidget(panel->paramT, width - 20, 20); WMMoveWidget(panel->paramT, 10, 20); WMAddNotificationObserver(dataChanged, panel, WMTextDidChangeNotification, panel->paramT); WMMapSubwidgets(panel->paramF); panel->quickB = WMCreateSwitchButton(panel->optionsF); WMResizeWidget(panel->quickB, width, 20); WMMoveWidget(panel->quickB, 10, 120); WMSetButtonText(panel->quickB, _("Do not confirm action.")); WMSetButtonAction(panel->quickB, buttonClicked, panel); label = WMCreateLabel(panel->optionsF); WMResizeWidget(label, width + 5, FRAME_HEIGHT - 50); WMMoveWidget(label, 7, 20); WMSetLabelText(label, _("Instructions:\n\n" " - drag items from the left to the menu to add new items\n" " - drag items out of the menu to remove items\n" " - drag items in menu to change their position\n" " - drag items with Control pressed to copy them\n" " - double click in a menu item to change the label\n" " - click on a menu item to change related information")); WMMapWidget(label); WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); WMMapWidget(panel->box); { int i; for (i = 0; i < wlengthof(panel->itemPad); i++) WMUnmapWidget(panel->itemPad[i]); } changedItemPad(panel->typeP, panel); panel->sections[NoInfo][0] = label; panel->sections[ExecInfo][0] = panel->commandF; panel->sections[ExecInfo][1] = panel->shortF; panel->sections[CommandInfo][0] = panel->icommandL; panel->sections[CommandInfo][1] = panel->shortF; panel->sections[ExternalInfo][0] = panel->pathF; panel->sections[PipeInfo][0] = panel->pipeF; panel->sections[PLPipeInfo][0] = panel->plpipeF; panel->sections[DirectoryInfo][0] = panel->dpathF; panel->sections[DirectoryInfo][1] = panel->dcommandF; panel->currentType = NoInfo; showData(panel); { WMPoint pos; pos = WMGetViewScreenPosition(WMWidgetView(panel->box)); if (pos.x < 200) { pos.x += FRAME_WIDTH + 20; } else { pos.x = 10; } pos.y = WMAX(pos.y - 100, 0); if (panel->menu) WEditMenuShowAt(panel->menu, pos.x, pos.y); } }
static void createPanel(Panel *p) { _Panel *panel = (_Panel*)p; WMScreen *scr = WMWidgetScreen(panel->parent); WMPixmap *icon; int i; char *buf1, *buf2; char *path; panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); /***************** Menu Scroll Speed ****************/ panel->scrF = WMCreateFrame(panel->box); WMResizeWidget(panel->scrF, 235, 90); WMMoveWidget(panel->scrF, 25, 20); WMSetFrameTitle(panel->scrF, _("Menu Scrolling Speed")); buf1 = wmalloc(strlen(SPEED_IMAGE)+1); buf2 = wmalloc(strlen(SPEED_IMAGE_S)+1); for (i = 0; i < 5; i++) { panel->scrB[i] = WMCreateCustomButton(panel->scrF, WBBStateChangeMask); WMResizeWidget(panel->scrB[i], 40, 40); WMMoveWidget(panel->scrB[i], 15+(40*i), 30); WMSetButtonBordered(panel->scrB[i], False); WMSetButtonImagePosition(panel->scrB[i], WIPImageOnly); if (i > 0) { WMGroupButtons(panel->scrB[0], panel->scrB[i]); } sprintf(buf1, SPEED_IMAGE, i); sprintf(buf2, SPEED_IMAGE_S, i); path = LocateImage(buf1); if (path) { icon = WMCreatePixmapFromFile(scr, path); if (icon) { WMSetButtonImage(panel->scrB[i], icon); WMReleasePixmap(icon); } else { wwarning(_("could not load icon file %s"), path); } wfree(path); } path = LocateImage(buf2); if (path) { icon = WMCreatePixmapFromFile(scr, path); if (icon) { WMSetButtonAltImage(panel->scrB[i], icon); WMReleasePixmap(icon); } else { wwarning(_("could not load icon file %s"), path); } wfree(path); } } wfree(buf1); wfree(buf2); WMMapSubwidgets(panel->scrF); /***************** Submenu Alignment ****************/ panel->aliF = WMCreateFrame(panel->box); WMResizeWidget(panel->aliF, 220, 90); WMMoveWidget(panel->aliF, 280, 20); WMSetFrameTitle(panel->aliF, _("Submenu Alignment")); panel->alinB = WMCreateButton(panel->aliF, WBTOnOff); WMResizeWidget(panel->alinB, 48, 48); WMMoveWidget(panel->alinB, 56, 25); WMSetButtonImagePosition(panel->alinB, WIPImageOnly); path = LocateImage(MENU_ALIGN1); if (path) { icon = WMCreatePixmapFromFile(scr, path); if (icon) { WMSetButtonImage(panel->alinB, icon); WMReleasePixmap(icon); } else { wwarning(_("could not load icon file %s"), path); } wfree(path); } panel->aliyB = WMCreateButton(panel->aliF, WBTOnOff); WMResizeWidget(panel->aliyB, 48, 48); WMMoveWidget(panel->aliyB, 120, 25); WMSetButtonImagePosition(panel->aliyB, WIPImageOnly); path = LocateImage(MENU_ALIGN2); if (path) { icon = WMCreatePixmapFromFile(scr, path); if (icon) { WMSetButtonImage(panel->aliyB, icon); WMReleasePixmap(icon); } else { wwarning(_("could not load icon file %s"), path); } wfree(path); } WMGroupButtons(panel->alinB, panel->aliyB); WMMapSubwidgets(panel->aliF); /***************** Options ****************/ panel->optF = WMCreateFrame(panel->box); WMResizeWidget(panel->optF, 475, 80); WMMoveWidget(panel->optF, 25, 130); panel->wrapB = WMCreateSwitchButton(panel->optF); WMResizeWidget(panel->wrapB, 440, 32); WMMoveWidget(panel->wrapB, 25, 8); WMSetButtonText(panel->wrapB, _("Always open submenus inside the screen, instead of scrolling.\nNote: this is annoying.")); panel->autoB = WMCreateSwitchButton(panel->optF); WMResizeWidget(panel->autoB, 440, 32); WMMoveWidget(panel->autoB, 25, 45); WMSetButtonText(panel->autoB, _("Scroll off-screen menus when pointer is moved over them.")); WMMapSubwidgets(panel->optF); WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); showData(panel); }
static void createPanel(Panel *p) { _Panel *panel = (_Panel *) p; WMScreen *scr = WMWidgetScreen(panel->parent); char *buf1, *buf2; WMPixmap *icon, *altIcon; RImage *xis = NULL; int i; RContext *rc = WMScreenRContext(scr); WMFont *font = WMSystemFontOfSize(scr, 10); char *path; path = LocateImage(ARQUIVO_XIS); if (path) { xis = RLoadImage(rc, path, 0); if (!xis) wwarning(_("could not load image file %s"), path); wfree(path); } panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); /*********** Icon Slide Speed **********/ panel->icoF = WMCreateFrame(panel->box); WMResizeWidget(panel->icoF, 212, 45); WMMoveWidget(panel->icoF, 15, 10); WMSetFrameTitle(panel->icoF, _("Icon Slide Speed")); /*********** Shade Animation Speed **********/ panel->shaF = WMCreateFrame(panel->box); WMResizeWidget(panel->shaF, 212, 45); WMMoveWidget(panel->shaF, 15, 65); WMSetFrameTitle(panel->shaF, _("Shade Animation Speed")); buf1 = wmalloc(strlen(SPEED_IMAGE) + 1); buf2 = wmalloc(strlen(SPEED_IMAGE_S) + 1); for (i = 0; i < 5; i++) { panel->icoB[i] = WMCreateCustomButton(panel->icoF, WBBStateChangeMask); panel->shaB[i] = WMCreateCustomButton(panel->shaF, WBBStateChangeMask); WMResizeWidget(panel->icoB[i], 40, 24); WMMoveWidget(panel->icoB[i], 2 + (40 * i), 15); WMResizeWidget(panel->shaB[i], 40, 24); WMMoveWidget(panel->shaB[i], 2 + (40 * i), 15); WMSetButtonBordered(panel->icoB[i], False); WMSetButtonImagePosition(panel->icoB[i], WIPImageOnly); if (i > 0) { WMGroupButtons(panel->icoB[0], panel->icoB[i]); } WMSetButtonBordered(panel->shaB[i], False); WMSetButtonImagePosition(panel->shaB[i], WIPImageOnly); if (i > 0) { WMGroupButtons(panel->shaB[0], panel->shaB[i]); } sprintf(buf1, SPEED_IMAGE, i); sprintf(buf2, SPEED_IMAGE_S, i); path = LocateImage(buf1); if (path) { icon = WMCreatePixmapFromFile(scr, path); if (icon) { WMSetButtonImage(panel->icoB[i], icon); WMSetButtonImage(panel->shaB[i], icon); WMReleasePixmap(icon); } else { wwarning(_("could not load icon file %s"), path); } wfree(path); } path = LocateImage(buf2); if (path) { icon = WMCreatePixmapFromFile(scr, path); if (icon) { WMSetButtonAltImage(panel->icoB[i], icon); WMSetButtonAltImage(panel->shaB[i], icon); WMReleasePixmap(icon); } else { wwarning(_("could not load icon file %s"), path); } wfree(path); } } wfree(buf1); wfree(buf2); WMMapSubwidgets(panel->icoF); WMMapSubwidgets(panel->shaF); /***************** Smoothed Scaling *****************/ panel->smoF = WMCreateFrame(panel->box); WMResizeWidget(panel->smoF, 94, 100); WMMoveWidget(panel->smoF, 420, 10); WMSetFrameTitle(panel->smoF, _("Smooth Scaling")); panel->smoB = WMCreateButton(panel->smoF, WBTToggle); WMResizeWidget(panel->smoB, 64, 64); WMMoveWidget(panel->smoB, 15, 23); WMSetButtonImagePosition(panel->smoB, WIPImageOnly); path = LocateImage(SMOOTH_IMAGE); if (path) { RImage *image, *scaled; image = RLoadImage(WMScreenRContext(scr), path, 0); wfree(path); scaled = RScaleImage(image, 61, 61); icon = WMCreatePixmapFromRImage(scr, scaled, 128); RReleaseImage(scaled); if (icon) { WMSetButtonImage(panel->smoB, icon); WMReleasePixmap(icon); } scaled = RSmoothScaleImage(image, 61, 61); icon = WMCreatePixmapFromRImage(scr, scaled, 128); RReleaseImage(scaled); if (icon) { WMSetButtonAltImage(panel->smoB, icon); WMReleasePixmap(icon); } RReleaseImage(image); } WMSetBalloonTextForView(_("Smooth scaled background images, neutralizing\n" "the `pixelization' effect. This will slow\n" "down loading of background images considerably."), WMWidgetView(panel->smoB)); WMMapSubwidgets(panel->smoF); /***************** Titlebar Style Size ****************/ panel->titlF = WMCreateFrame(panel->box); WMResizeWidget(panel->titlF, 212, 97); WMMoveWidget(panel->titlF, 15, 120); WMSetFrameTitle(panel->titlF, _("Titlebar Style")); panel->oldsB = WMCreateButton(panel->titlF, WBTOnOff); WMResizeWidget(panel->oldsB, 60, 40); WMMoveWidget(panel->oldsB, 16, 32); WMSetButtonImagePosition(panel->oldsB, WIPImageOnly); path = LocateImage(OLDS_IMAGE); if (path) { icon = WMCreatePixmapFromFile(scr, path); if (icon) { WMSetButtonImage(panel->oldsB, icon); WMReleasePixmap(icon); } wfree(path); } panel->newsB = WMCreateButton(panel->titlF, WBTOnOff); WMResizeWidget(panel->newsB, 60, 40); WMMoveWidget(panel->newsB, 76, 32); WMSetButtonImagePosition(panel->newsB, WIPImageOnly); path = LocateImage(NEWS_IMAGE); if (path) { icon = WMCreatePixmapFromFile(scr, path); if (icon) { WMSetButtonImage(panel->newsB, icon); WMReleasePixmap(icon); } wfree(path); } panel->nextB = WMCreateButton(panel->titlF, WBTOnOff); WMResizeWidget(panel->nextB, 60, 40); WMMoveWidget(panel->nextB, 136, 32); WMSetButtonImagePosition(panel->nextB, WIPImageOnly); path = LocateImage(NEXT_IMAGE); if (path) { icon = WMCreatePixmapFromFile(scr, path); if (icon) { WMSetButtonImage(panel->nextB, icon); WMReleasePixmap(icon); } wfree(path); } WMGroupButtons(panel->newsB, panel->oldsB); WMGroupButtons(panel->newsB, panel->nextB); WMMapSubwidgets(panel->titlF); /**************** Features ******************/ panel->animF = WMCreateFrame(panel->box); WMResizeWidget(panel->animF, 173, 100); WMMoveWidget(panel->animF, 237, 10); WMSetFrameTitle(panel->animF, _("Animations")); panel->animB = WMCreateButton(panel->animF, WBTToggle); WMResizeWidget(panel->animB, 64, 64); WMMoveWidget(panel->animB, 15, 23); WMSetButtonFont(panel->animB, font); WMSetButtonText(panel->animB, _("Animations")); WMSetButtonImagePosition(panel->animB, WIPAbove); CreateImages(scr, rc, xis, ANIM_IMAGE, &altIcon, &icon); if (icon) { WMSetButtonImage(panel->animB, icon); WMReleasePixmap(icon); } if (altIcon) { WMSetButtonAltImage(panel->animB, altIcon); WMReleasePixmap(altIcon); } WMSetBalloonTextForView(_("Disable/enable animations such as those shown\n" "for window miniaturization, shading etc."), WMWidgetView(panel->animB)); panel->supB = WMCreateButton(panel->animF, WBTToggle); WMResizeWidget(panel->supB, 64, 64); WMMoveWidget(panel->supB, 94, 23); WMSetButtonFont(panel->supB, font); WMSetButtonText(panel->supB, _("Superfluous")); WMSetButtonImagePosition(panel->supB, WIPAbove); CreateImages(scr, rc, xis, SUPERF_IMAGE, &altIcon, &icon); if (icon) { WMSetButtonImage(panel->supB, icon); WMReleasePixmap(icon); } if (altIcon) { WMSetButtonAltImage(panel->supB, altIcon); WMReleasePixmap(altIcon); } WMSetBalloonTextForView(_("Disable/enable `superfluous' features and\n" "animations. These include the `ghosting' of the\n" "dock when it's being moved to another side and\n" "the explosion animation when undocking icons."), WMWidgetView(panel->supB)); WMMapSubwidgets(panel->animF); /*********** Dithering **********/ panel->cmapSize = 4; panel->dithF = WMCreateFrame(panel->box); WMResizeWidget(panel->dithF, 277, 97); WMMoveWidget(panel->dithF, 237, 120); WMSetFrameTitle(panel->dithF, _("Dithering colormap for 8bpp")); WMSetBalloonTextForView(_("Number of colors to reserve for Window Maker\n" "on displays that support only 8bpp (PseudoColor)."), WMWidgetView(panel->dithF)); panel->dithB = WMCreateSwitchButton(panel->dithF); WMResizeWidget(panel->dithB, 235, 32); WMMoveWidget(panel->dithB, 15, 15); WMSetButtonText(panel->dithB, _("Disable dithering in any visual/depth")); panel->dithL = WMCreateLabel(panel->dithF); WMResizeWidget(panel->dithL, 75, 16); WMMoveWidget(panel->dithL, 98, 50); WMSetLabelTextAlignment(panel->dithL, WACenter); WMSetLabelText(panel->dithL, "64"); panel->dithS = WMCreateSlider(panel->dithF); WMResizeWidget(panel->dithS, 95, 16); WMMoveWidget(panel->dithS, 90, 65); WMSetSliderMinValue(panel->dithS, 2); WMSetSliderMaxValue(panel->dithS, 6); WMSetSliderContinuous(panel->dithS, True); WMSetSliderAction(panel->dithS, updateLabel, panel); panel->dith1L = WMCreateLabel(panel->dithF); WMResizeWidget(panel->dith1L, 80, 35); WMMoveWidget(panel->dith1L, 5, 50); WMSetLabelTextAlignment(panel->dith1L, WACenter); WMSetLabelFont(panel->dith1L, font); WMSetLabelText(panel->dith1L, _("More colors for\napplications")); panel->dith2L = WMCreateLabel(panel->dithF); WMResizeWidget(panel->dith2L, 80, 35); WMMoveWidget(panel->dith2L, 190, 50); WMSetLabelTextAlignment(panel->dith2L, WACenter); WMSetLabelFont(panel->dith2L, font); WMSetLabelText(panel->dith2L, _("More colors for\nWindow Maker")); WMMapSubwidgets(panel->dithF); WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); if (xis) RReleaseImage(xis); WMReleaseFont(font); showData(panel); }
static void showData(_Panel * panel) { const char *gspath; char *menuPath, *labelText; char buf[1024]; WMPropList *pmenu; gspath = wusergnusteppath(); menuPath = wmalloc(strlen(gspath) + 32); strcpy(menuPath, gspath); strcat(menuPath, "/Defaults/WMRootMenu"); pmenu = WMReadPropListFromFile(menuPath); /* check if WMRootMenu references another file, and if so, if that file is in proplist format */ while (WMIsPLString(pmenu)) { char *path = NULL; path = wexpandpath(WMGetFromPLString(pmenu)); if (access(path, F_OK) < 0) path = wfindfile(DEF_CONFIG_PATHS, path); /* TODO: if needed, concatenate locale suffix to path. See getLocalizedMenuFile() in src/rootmenu.c. */ if (!path) break; if (access(path, W_OK) < 0) { snprintf(buf, 1024, _("The menu file \"%s\" referenced by " "WMRootMenu is read-only.\n" "You cannot use WPrefs to modify it."), path); WMRunAlertPanel(WMWidgetScreen(panel->parent), panel->parent, _("Warning"), buf, _("OK"), NULL, NULL); panel->dontSave = True; wfree(path); return; } pmenu = WMReadPropListFromFile(path); menuPath = path; } if (!pmenu || !WMIsPLArray(pmenu)) { int res; res = WMRunAlertPanel(WMWidgetScreen(panel->parent), panel->parent, _("Warning"), _("The menu file format currently in use is not supported\n" "by this tool. Do you want to discard the current menu\n" "to use this tool?"), _("Yes, Discard and Update"), _("No, Keep Current Menu"), NULL); if (res == WAPRDefault) { pmenu = getDefaultMenu(panel); if (!pmenu) { pmenu = WMCreatePLArray(WMCreatePLString("Applications"), NULL); } } else { panel->dontSave = True; return; } } panel->menuPath = menuPath; snprintf(buf, 1024, _("\n\nWhen saved, the menu will be written to the file\n\"%s\"."), menuPath); labelText = WMGetLabelText(panel->sections[NoInfo][0]); labelText = wstrconcat(labelText, buf); WMSetLabelText(panel->sections[NoInfo][0], labelText); wfree(labelText); buildMenuFromPL(panel, pmenu); WMReleasePropList(pmenu); }
static void createPanel(Panel *p) { _Panel *panel = (_Panel*)p; WMScreen *scr = WMWidgetScreen(panel->parent); WMTabViewItem *tab; panel->white = WMWhiteColor(scr); panel->black = WMBlackColor(scr); panel->gray = WMGrayColor(scr); panel->red = WMCreateRGBColor(scr, 0xffff, 0, 0, True); panel->font = WMSystemFontOfSize(scr, 12); panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); panel->tabv = WMCreateTabView(panel->box); WMMoveWidget(panel->tabv, 12, 10); WMResizeWidget(panel->tabv, 500, 215); /* icon path */ panel->icoF = WMCreateFrame(panel->box); WMSetFrameRelief(panel->icoF, WRFlat); WMResizeWidget(panel->icoF, 230, 210); tab = WMCreateTabViewItemWithIdentifier(0); WMSetTabViewItemView(tab, WMWidgetView(panel->icoF)); WMAddItemInTabView(panel->tabv, tab); WMSetTabViewItemLabel(tab, _("Icon Search Paths")); panel->icoL = WMCreateList(panel->icoF); WMResizeWidget(panel->icoL, 480, 147); WMMoveWidget(panel->icoL, 10, 10); WMSetListUserDrawProc(panel->icoL, paintItem); WMHangData(panel->icoL, panel); panel->icoaB = WMCreateCommandButton(panel->icoF); WMResizeWidget(panel->icoaB, 95, 24); WMMoveWidget(panel->icoaB, 293, 165); WMSetButtonText(panel->icoaB, _("Add")); WMSetButtonAction(panel->icoaB, browseForFile, panel); WMSetButtonImagePosition(panel->icoaB, WIPRight); panel->icorB = WMCreateCommandButton(panel->icoF); WMResizeWidget(panel->icorB, 95, 24); WMMoveWidget(panel->icorB, 395, 165); WMSetButtonText(panel->icorB, _("Remove")); WMSetButtonAction(panel->icorB, pushButton, panel); WMMapSubwidgets(panel->icoF); /* pixmap path */ panel->pixF = WMCreateFrame(panel->box); WMSetFrameRelief(panel->pixF, WRFlat); WMResizeWidget(panel->pixF, 230, 210); tab = WMCreateTabViewItemWithIdentifier(0); WMSetTabViewItemView(tab, WMWidgetView(panel->pixF)); WMAddItemInTabView(panel->tabv, tab); WMSetTabViewItemLabel(tab, _("Pixmap Search Paths")); panel->pixL = WMCreateList(panel->pixF); WMResizeWidget(panel->pixL, 480, 147); WMMoveWidget(panel->pixL, 10, 10); WMSetListUserDrawProc(panel->pixL, paintItem); WMHangData(panel->pixL, panel); panel->pixaB = WMCreateCommandButton(panel->pixF); WMResizeWidget(panel->pixaB, 95, 24); WMMoveWidget(panel->pixaB, 293, 165); WMSetButtonText(panel->pixaB, _("Add")); WMSetButtonAction(panel->pixaB, browseForFile, panel); WMSetButtonImagePosition(panel->pixaB, WIPRight); panel->pixrB = WMCreateCommandButton(panel->pixF); WMResizeWidget(panel->pixrB, 95, 24); WMMoveWidget(panel->pixrB, 395, 165); WMSetButtonText(panel->pixrB, _("Remove")); WMSetButtonAction(panel->pixrB, pushButton, panel); WMMapSubwidgets(panel->pixF); WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); showData(panel); }
static WEditMenu *buildSubmenu(_Panel * panel, WMPropList * pl) { WMScreen *scr = WMWidgetScreen(panel->parent); WEditMenu *menu; WEditMenuItem *item; char *title; WMPropList *tp, *bp; int i; tp = WMGetFromPLArray(pl, 0); title = WMGetFromPLString(tp); menu = WCreateEditMenu(scr, title); for (i = 1; i < WMGetPropListItemCount(pl); i++) { WMPropList *pi; pi = WMGetFromPLArray(pl, i); tp = WMGetFromPLArray(pi, 0); bp = WMGetFromPLArray(pi, 1); title = WMGetFromPLString(tp); if (!bp || WMIsPLArray(bp)) { /* it's a submenu */ WEditMenu *submenu; submenu = buildSubmenu(panel, pi); item = WAddMenuItemWithTitle(menu, title); WSetEditMenuSubmenu(menu, item, submenu); } else { ItemData *data; data = parseCommand(pi); if (data != NULL) { item = WAddMenuItemWithTitle(menu, title); if (panel->markerPix[data->type]) WSetEditMenuItemImage(item, panel->markerPix[data->type]); WSetEditMenuItemData(item, data, (WMCallback *) freeItemData); } else { char *buf = wmalloc(1024); snprintf(buf, 1024, _("Invalid menu command \"%s\" with label \"%s\" cleared"), WMGetFromPLString(WMGetFromPLArray(pi, 1)), WMGetFromPLString(WMGetFromPLArray(pi, 0))); WMRunAlertPanel(scr, panel->parent, _("Warning"), buf, _("OK"), NULL, NULL); wfree(buf); } } } WSetEditMenuAcceptsDrop(menu, True); WSetEditMenuDelegate(menu, &menuDelegate); WMRealizeWidget(menu); return menu; }
static void revertSettings(WMWidget *button, void *client_data) { InspectorPanel *panel = (InspectorPanel *) client_data; WWindow *wwin = panel->inspected; WApplication *wapp = wApplicationOf(wwin->main_window); int i, n, workspace, level; char *wm_instance = NULL, *wm_class = NULL; /* Parameter not used, but tell the compiler that it is ok */ (void) button; if (panel->instRb && WMGetButtonSelected(panel->instRb) != 0) wm_instance = wwin->wm_instance; else if (panel->clsRb && WMGetButtonSelected(panel->clsRb) != 0) wm_class = wwin->wm_class; else if (panel->bothRb && WMGetButtonSelected(panel->bothRb) != 0) { wm_instance = wwin->wm_instance; wm_class = wwin->wm_class; } memset(&wwin->defined_user_flags, 0, sizeof(WWindowAttributes)); memset(&wwin->user_flags, 0, sizeof(WWindowAttributes)); memset(&wwin->client_flags, 0, sizeof(WWindowAttributes)); wWindowSetupInitialAttributes(wwin, &level, &workspace); for (i = 0; i < wlengthof(panel->attrChk); i++) { int flag = 0; switch (i) { case 0: flag = WFLAGP(wwin, no_titlebar); break; case 1: flag = WFLAGP(wwin, no_resizebar); break; case 2: flag = WFLAGP(wwin, no_close_button); break; case 3: flag = WFLAGP(wwin, no_miniaturize_button); break; case 4: flag = WFLAGP(wwin, no_border); break; case 5: flag = WFLAGP(wwin, floating); break; case 6: flag = WFLAGP(wwin, sunken); break; case 7: flag = WFLAGP(wwin, omnipresent); break; case 8: flag = WFLAGP(wwin, start_miniaturized); break; case 9: flag = WFLAGP(wwin, start_maximized != 0); break; case 10: flag = WFLAGP(wwin, full_maximize); break; } WMSetButtonSelected(panel->attrChk[i], flag); } for (i = 0; i < wlengthof(panel->moreChk); i++) { int flag = 0; switch (i) { case 0: flag = WFLAGP(wwin, no_bind_keys); break; case 1: flag = WFLAGP(wwin, no_bind_mouse); break; case 2: flag = WFLAGP(wwin, skip_window_list); break; case 3: flag = WFLAGP(wwin, skip_switchpanel); break; case 4: flag = WFLAGP(wwin, no_focusable); break; case 5: flag = WFLAGP(wwin, dont_move_off); break; case 6: flag = WFLAGP(wwin, no_hide_others); break; case 7: flag = WFLAGP(wwin, dont_save_session); break; case 8: flag = WFLAGP(wwin, emulate_appicon); break; case 9: flag = WFLAGP(wwin, focus_across_wksp); break; case 10: flag = WFLAGP(wwin, no_miniaturizable); break; #ifdef XKB_BUTTON_HINT case 11: flag = WFLAGP(wwin, no_language_button); break; #endif } WMSetButtonSelected(panel->moreChk[i], flag); } if (panel->appFrm && wapp) { for (i = 0; i < wlengthof(panel->appChk); i++) { int flag = 0; switch (i) { case 0: flag = WFLAGP(wapp->main_window_desc, start_hidden); break; case 1: flag = WFLAGP(wapp->main_window_desc, no_appicon); break; case 2: flag = WFLAGP(wapp->main_window_desc, shared_appicon); break; } WMSetButtonSelected(panel->appChk[i], flag); } } WMSetButtonSelected(panel->alwChk, WFLAGP(wwin, always_user_icon)); showIconFor(WMWidgetScreen(panel->alwChk), panel, wm_instance, wm_class, REVERT_TO_DEFAULT); n = wDefaultGetStartWorkspace(wm_instance, wm_class); if (n >= 0 && n < w_global.workspace.count) WMSetPopUpButtonSelectedItem(panel->wsP, n + 1); else WMSetPopUpButtonSelectedItem(panel->wsP, 0); /* must auto apply, so that there wno't be internal * inconsistencies between the state in the flags and * the actual state of the window */ applySettings(panel->applyBtn, panel); }
static void createPanel(Panel *p) { _Panel *panel = (_Panel *) p; WMScreen *scr = WMWidgetScreen(panel->parent); WMPixmap *icon1, *icon2; RImage *xis = NULL; RContext *rc = WMScreenRContext(scr); char *path; int i, j, k; char *buf1, *buf2; path = LocateImage(ARQUIVO_XIS); if (path) { xis = RLoadImage(rc, path, 0); if (!xis) { wwarning(_("could not load image file %s"), path); } wfree(path); } panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); /***************** Auto-delays *****************/ buf1 = wmalloc(strlen(DELAY_ICON) + 1); buf2 = wmalloc(strlen(DELAY_ICON_S) + 1); for (k = 0; k < 2; k++) { panel->autoDelayF[k] = WMCreateFrame(panel->box); WMResizeWidget(panel->autoDelayF[k], 365, 100); WMMoveWidget(panel->autoDelayF[k], 15, 10 + k * 110); if (k == 0) WMSetFrameTitle(panel->autoDelayF[k], _("Delays in milliseconds for autocollapsing clips")); else WMSetFrameTitle(panel->autoDelayF[k], _("Delays in milliseconds for autoraising clips")); for (i = 0; i < 2; i++) { panel->autoDelayL[i + k * 2] = WMCreateLabel(panel->autoDelayF[k]); WMResizeWidget(panel->autoDelayL[i + k * 2], 165, 20); WMMoveWidget(panel->autoDelayL[i + k * 2], 10, 27 + 40 * i); WMSetLabelText(panel->autoDelayL[i + k * 2], _(auto_delay[i + k * 2].string)); WMSetLabelTextAlignment(panel->autoDelayL[i + k * 2], WARight); for (j = 0; j < 5; j++) { panel->autoDelayB[i + k * 2][j] = WMCreateCustomButton(panel->autoDelayF[k], WBBStateChangeMask); WMResizeWidget(panel->autoDelayB[i + k * 2][j], 25, 25); WMMoveWidget(panel->autoDelayB[i + k * 2][j], 175 + (25 * j), 25 + 40 * i); WMSetButtonBordered(panel->autoDelayB[i + k * 2][j], False); WMSetButtonImagePosition(panel->autoDelayB[i + k * 2][j], WIPImageOnly); WMSetButtonAction(panel->autoDelayB[i + k * 2][j], pushAutoDelayButton, panel); if (j > 0) WMGroupButtons(panel->autoDelayB[i + k * 2][0], panel->autoDelayB[i + k * 2][j]); sprintf(buf1, DELAY_ICON, j); CreateImages(scr, rc, NULL, buf1, &icon1, NULL); if (icon1) { WMSetButtonImage(panel->autoDelayB[i + k * 2][j], icon1); WMReleasePixmap(icon1); } else { wwarning(_("could not load icon file %s"), buf1); } sprintf(buf2, DELAY_ICON_S, j); CreateImages(scr, rc, NULL, buf2, &icon2, NULL); if (icon2) { WMSetButtonAltImage(panel->autoDelayB[i + k * 2][j], icon2); WMReleasePixmap(icon2); } else { wwarning(_("could not load icon file %s"), buf2); } } panel->autoDelayT[i + k * 2] = WMCreateTextField(panel->autoDelayF[k]); WMResizeWidget(panel->autoDelayT[i + k * 2], 36, 20); WMMoveWidget(panel->autoDelayT[i + k * 2], 310, 27 + 40 * i); WMAddNotificationObserver(autoDelayChanged, panel, WMTextDidChangeNotification, panel->autoDelayT[i + k * 2]); } WMMapSubwidgets(panel->autoDelayF[k]); } wfree(buf1); wfree(buf2); /***************** Enable/disable clip/dock/drawers *****************/ panel->dockF = WMCreateFrame(panel->box); WMResizeWidget(panel->dockF, 115, 210); WMMoveWidget(panel->dockF, 390, 10); WMSetFrameTitle(panel->dockF, _("Dock/Clip/Drawer")); for (i = 0; i < 3; i++) { panel->docksB[i] = WMCreateButton(panel->dockF, WBTToggle); WMResizeWidget(panel->docksB[i], 56, 56); WMMoveWidget(panel->docksB[i], 30, 20 + 62 * i); WMSetButtonImagePosition(panel->docksB[i], WIPImageOnly); CreateImages(scr, rc, xis, dock_config[i].icon_file, &icon1, &icon2); if (icon2) { WMSetButtonImage(panel->docksB[i], icon2); WMReleasePixmap(icon2); } if (icon1) { WMSetButtonAltImage(panel->docksB[i], icon1); WMReleasePixmap(icon1); } switch(i) { case 0: WMSetBalloonTextForView(_("Disable/enable the application Dock (the\n" "vertical icon bar in the side of the screen)."), WMWidgetView(panel->docksB[i])); break; case 1: WMSetBalloonTextForView(_("Disable/enable the Clip (that thing with\n" "a paper clip icon)."), WMWidgetView(panel->docksB[i])); break; case 2: WMSetBalloonTextForView(_("Disable/enable Drawers (a dock that stores\n" "application icons horizontally). The dock is required."), WMWidgetView(panel->docksB[i])); break; } WMSetButtonAction(panel->docksB[i], pushDockButton, panel); } WMMapSubwidgets(panel->dockF); if (xis) RReleaseImage(xis); WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); showData(panel); }
static void createPanel(Panel * p) { _Panel *panel = (_Panel *) p; WMScreen *scr = WMWidgetScreen(panel->parent); int i; WMColor *color; WMFont *font; color = WMDarkGrayColor(scr); font = WMSystemFontOfSize(scr, 10); panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); /**************** Initial Key Repeat ***************/ panel->delaF = WMCreateFrame(panel->box); WMResizeWidget(panel->delaF, 495, 60); WMMoveWidget(panel->delaF, 15, 10); WMSetFrameTitle(panel->delaF, _("Initial Key Repeat")); for (i = 0; i < 4; i++) { panel->delaB[i] = WMCreateButton(panel->delaF, WBTOnOff); WMResizeWidget(panel->delaB[i], 60, 20); WMMoveWidget(panel->delaB[i], 70 + i * 60, 25); if (i > 0) WMGroupButtons(panel->delaB[0], panel->delaB[i]); switch (i) { case 0: WMSetButtonText(panel->delaB[i], "....a"); break; case 1: WMSetButtonText(panel->delaB[i], "...a"); break; case 2: WMSetButtonText(panel->delaB[i], "..a"); break; case 3: WMSetButtonText(panel->delaB[i], ".a"); break; } } panel->dmsT = WMCreateTextField(panel->delaF); WMResizeWidget(panel->dmsT, 50, 20); WMMoveWidget(panel->dmsT, 345, 25); /* WMSetTextFieldAlignment(panel->dmsT, WARight); */ panel->dmsL = WMCreateLabel(panel->delaF); WMResizeWidget(panel->dmsL, 30, 16); WMMoveWidget(panel->dmsL, 400, 30); WMSetLabelTextColor(panel->dmsL, color); WMSetLabelFont(panel->dmsL, font); WMSetLabelText(panel->dmsL, "msec"); WMMapSubwidgets(panel->delaF); /**************** Key Repeat Rate ***************/ panel->rateF = WMCreateFrame(panel->box); WMResizeWidget(panel->rateF, 495, 60); WMMoveWidget(panel->rateF, 15, 95); WMSetFrameTitle(panel->rateF, _("Key Repeat Rate")); for (i = 0; i < 4; i++) { panel->rateB[i] = WMCreateButton(panel->rateF, WBTOnOff); WMResizeWidget(panel->rateB[i], 60, 20); WMMoveWidget(panel->rateB[i], 70 + i * 60, 25); if (i > 0) WMGroupButtons(panel->rateB[0], panel->rateB[i]); switch (i) { case 0: WMSetButtonText(panel->rateB[i], "a....a"); break; case 1: WMSetButtonText(panel->rateB[i], "a...a"); break; case 2: WMSetButtonText(panel->rateB[i], "a..a"); break; case 3: WMSetButtonText(panel->rateB[i], "a.a"); break; } } panel->rmsT = WMCreateTextField(panel->rateF); WMResizeWidget(panel->rmsT, 50, 20); WMMoveWidget(panel->rmsT, 345, 25); /* WMSetTextFieldAlignment(panel->rmsT, WARight); */ panel->rmsL = WMCreateLabel(panel->rateF); WMResizeWidget(panel->rmsL, 30, 16); WMMoveWidget(panel->rmsL, 400, 30); WMSetLabelTextColor(panel->rmsL, color); WMSetLabelFont(panel->rmsL, font); WMSetLabelText(panel->rmsL, "msec"); WMMapSubwidgets(panel->rateF); panel->testT = WMCreateTextField(panel->box); WMResizeWidget(panel->testT, 480, 20); WMMoveWidget(panel->testT, 20, 180); WMSetTextFieldText(panel->testT, _("Type here to test")); WMReleaseColor(color); WMReleaseFont(font); WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); }
static void createPanel(Panel * p) { _Panel *panel = (_Panel *) p; WMScreen *scr = WMWidgetScreen(panel->parent); WMPixmap *icon; char *buf1, *buf2; int i; RColor color; char *path; color.red = 0xae; color.green = 0xaa; color.blue = 0xae; panel->box = WMCreateBox(panel->parent); WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2); /**************** Mouse Speed ****************/ panel->speedF = WMCreateFrame(panel->box); WMResizeWidget(panel->speedF, 219, 85); WMMoveWidget(panel->speedF, 9, 54); WMSetFrameTitle(panel->speedF, _("Mouse Speed")); panel->speedL = WMCreateLabel(panel->speedF); WMResizeWidget(panel->speedL, 40, 46); WMMoveWidget(panel->speedL, 8, 10); WMSetLabelImagePosition(panel->speedL, WIPImageOnly); path = LocateImage(SPEED_ICON_FILE); if (path) { icon = WMCreateBlendedPixmapFromFile(scr, path, &color); if (icon) { WMSetLabelImage(panel->speedL, icon); WMReleasePixmap(icon); } else { wwarning(_("could not load icon %s"), path); } wfree(path); } panel->speedS = WMCreateSlider(panel->speedF); WMResizeWidget(panel->speedS, 150, 15); WMMoveWidget(panel->speedS, 58, 30); WMSetSliderMinValue(panel->speedS, 0); WMSetSliderMaxValue(panel->speedS, 40); WMSetSliderContinuous(panel->speedS, False); WMSetSliderAction(panel->speedS, speedChange, panel); panel->acceL = WMCreateLabel(panel->speedF); WMResizeWidget(panel->acceL, 50, 16); WMMoveWidget(panel->acceL, 8, 58); WMSetLabelTextAlignment(panel->acceL, WARight); WMSetLabelText(panel->acceL, _("Accel.:")); panel->acceT = WMCreateTextField(panel->speedF); WMResizeWidget(panel->acceT, 40, 20); WMMoveWidget(panel->acceT, 58, 56); WMAddNotificationObserver(returnPressed, panel, WMTextDidEndEditingNotification, panel->acceT); panel->threL = WMCreateLabel(panel->speedF); WMResizeWidget(panel->threL, 80, 16); WMMoveWidget(panel->threL, 98, 58); WMSetLabelTextAlignment(panel->threL, WARight); WMSetLabelText(panel->threL, _("Threshold:")); panel->threT = WMCreateTextField(panel->speedF); WMResizeWidget(panel->threT, 30, 20); WMMoveWidget(panel->threT, 178, 56); WMAddNotificationObserver(returnPressed, panel, WMTextDidEndEditingNotification, panel->threT); WMMapSubwidgets(panel->speedF); /* ************** Grab Modifier **************** */ panel->grabF = WMCreateFrame(panel->box); WMResizeWidget(panel->grabF, 219, 46); WMMoveWidget(panel->grabF, 9, 5); WMSetFrameTitle(panel->grabF, _("Mouse Grab Modifier")); WMSetBalloonTextForView(_("Keyboard modifier to use for actions that\n" "involve dragging windows with the mouse,\n" "clicking inside the window."), WMWidgetView(panel->grabF)); panel->grabP = WMCreatePopUpButton(panel->grabF); WMResizeWidget(panel->grabP, 178, 20); WMMoveWidget(panel->grabP, 20, 17); fillModifierPopUp(panel->grabP); WMMapSubwidgets(panel->grabF); /***************** Doubleclick Delay ****************/ panel->ddelaF = WMCreateFrame(panel->box); WMResizeWidget(panel->ddelaF, 219, 80); WMMoveWidget(panel->ddelaF, 9, 142); WMSetFrameTitle(panel->ddelaF, _("Double-Click Delay")); buf1 = wmalloc(strlen(DELAY_ICON) + 2); buf2 = wmalloc(strlen(DELAY_ICON_S) + 2); for (i = 0; i < wlengthof(panel->ddelaB); i++) { panel->ddelaB[i] = WMCreateCustomButton(panel->ddelaF, WBBStateChangeMask); WMResizeWidget(panel->ddelaB[i], 25, 25); WMMoveWidget(panel->ddelaB[i], 18 + (40 * i), 18); WMSetButtonBordered(panel->ddelaB[i], False); WMSetButtonImagePosition(panel->ddelaB[i], WIPImageOnly); WMSetButtonAction(panel->ddelaB[i], doubleClick, panel); if (i > 0) { WMGroupButtons(panel->ddelaB[0], panel->ddelaB[i]); } sprintf(buf1, DELAY_ICON, i + 1); sprintf(buf2, DELAY_ICON_S, i + 1); path = LocateImage(buf1); if (path) { icon = WMCreatePixmapFromFile(scr, path); if (icon) { WMSetButtonImage(panel->ddelaB[i], icon); WMReleasePixmap(icon); } else { wwarning(_("could not load icon file %s"), path); } wfree(path); } path = LocateImage(buf2); if (path) { icon = WMCreatePixmapFromFile(scr, path); if (icon) { WMSetButtonAltImage(panel->ddelaB[i], icon); WMReleasePixmap(icon); } else { wwarning(_("could not load icon file %s"), path); } wfree(path); } } wfree(buf1); wfree(buf2); panel->tester = CreateDoubleTest(panel->ddelaF, _("Test")); WMResizeWidget(panel->tester, 84, 24); WMMoveWidget(panel->tester, 20, 48); panel->ddelaT = WMCreateTextField(panel->ddelaF); WMResizeWidget(panel->ddelaT, 40, 20); WMMoveWidget(panel->ddelaT, 130, 50); panel->ddelaL = WMCreateLabel(panel->ddelaF); WMResizeWidget(panel->ddelaL, 40, 16); WMMoveWidget(panel->ddelaL, 173, 54); { WMFont *font; WMColor *color; font = WMSystemFontOfSize(scr, 10); color = WMDarkGrayColor(scr); WMSetLabelTextColor(panel->ddelaL, color); WMSetLabelFont(panel->ddelaL, font); WMReleaseFont(font); WMReleaseColor(color); } WMSetLabelText(panel->ddelaL, _("ms")); WMMapSubwidgets(panel->ddelaF); /* ************** Workspace Action Buttons **************** */ panel->menuF = WMCreateFrame(panel->box); WMResizeWidget(panel->menuF, 276, 217); WMMoveWidget(panel->menuF, 236, 5); WMSetFrameTitle(panel->menuF, _("Workspace Mouse Actions")); panel->disaB = WMCreateSwitchButton(panel->menuF); WMResizeWidget(panel->disaB, 254, 18); WMMoveWidget(panel->disaB, 10, 15); WMSetButtonText(panel->disaB, _("Disable mouse actions")); WMSetButtonAction(panel->disaB, toggle_disabling_of_mouse_actions, panel); for (i = 0; i < wlengthof(button_list); i++) { int j; panel->mouse_action[i].label = WMCreateLabel(panel->menuF); WMResizeWidget(panel->mouse_action[i].label, 115, 20); WMMoveWidget(panel->mouse_action[i].label, 4, 37 + 25 * i); WMSetLabelTextAlignment(panel->mouse_action[i].label, WARight); WMSetLabelText(panel->mouse_action[i].label, _(button_list[i].display_label)); panel->mouse_action[i].popup = WMCreatePopUpButton(panel->menuF); WMResizeWidget(panel->mouse_action[i].popup, 145, 20); WMMoveWidget(panel->mouse_action[i].popup, 121, 37 + 25 * i); if (button_list[i].type == T_BUTTON) { for (j = 0; j < wlengthof(button_actions); j++) WMAddPopUpButtonItem(panel->mouse_action[i].popup, _(button_actions[j].label)); } else { for (j = 0; j < wlengthof(wheel_actions); j++) WMAddPopUpButtonItem(panel->mouse_action[i].popup, _(wheel_actions[j].label)); } } WMMapSubwidgets(panel->menuF); WMRealizeWidget(panel->box); WMMapSubwidgets(panel->box); showData(panel); }
static void fillModifierPopUp(WMPopUpButton * pop) { XModifierKeymap *mapping; Display *dpy = WMScreenDisplay(WMWidgetScreen(pop)); int i, j; char *str; char buffer[64]; mapping = XGetModifierMapping(dpy); if (!mapping || mapping->max_keypermod == 0) { WMAddPopUpButtonItem(pop, "Mod1"); WMAddPopUpButtonItem(pop, "Mod2"); WMAddPopUpButtonItem(pop, "Mod3"); WMAddPopUpButtonItem(pop, "Mod4"); WMAddPopUpButtonItem(pop, "Mod5"); wwarning(_("could not retrieve keyboard modifier mapping")); return; } for (j = 0; j < 8; j++) { int idx; char *array[8]; int a; KeySym ksym; int k; char *ptr; char *tmp; a = 0; memset(array, 0, sizeof(char *) * 8); for (i = 0; i < mapping->max_keypermod; i++) { idx = i + j * mapping->max_keypermod; if (mapping->modifiermap[idx] != 0) { int l; for (l = 0; l < 4; l++) { if (xext_xkb_supported) ksym = XkbKeycodeToKeysym(dpy, mapping->modifiermap[idx], 0, l); else ksym = XKeycodeToKeysym(dpy, mapping->modifiermap[idx], 0); if (ksym != NoSymbol) break; } if (ksym != NoSymbol) str = XKeysymToString(ksym); else str = NULL; if (str && !strstr(str, "_Lock") && !strstr(str, "Shift") && !strstr(str, "Control")) { array[a++] = wstrdup(str); } } } for (k = 0; k < a; k++) { if (array[k] == NULL) continue; tmp = wstrdup(array[k]); ptr = strstr(tmp, "_L"); if (ptr) *ptr = 0; ptr = strstr(tmp, "_R"); if (ptr) *ptr = 0; sprintf(buffer, "%s (%s)", modifierNames[j], tmp); /*sprintf(buffer, "%s", tmp); */ WMAddPopUpButtonItem(pop, buffer); for (i = k + 1; i < a; i++) { if (array[i] == NULL) continue; if (strstr(array[i], tmp)) { wfree(array[i]); array[i] = NULL; break; } } wfree(tmp); } while (--a > 0) { if (array[a]) wfree(array[a]); } } if (mapping) XFreeModifiermap(mapping); }
static void showData(_Panel * panel) { char *str; int i; int a = -1, b = -1; float accel; char buffer[32]; Display *dpy = WMScreenDisplay(WMWidgetScreen(panel->parent)); for (i = 0; i < wlengthof(button_list); i++) { int action; str = GetStringForKey(button_list[i].db_key); if (button_list[i].type == T_BUTTON) action = getButtonAction(str); else action = getWheelAction(str); if (action < 0) { if (action == -1) wwarning(_("bad value %s for option %s"), str, button_list[i].db_key); action = button_list[i].default_action; } WMSetPopUpButtonSelectedItem(panel->mouse_action[i].popup, action); } WMSetButtonSelected(panel->disaB, GetBoolForKey("DisableWSMouseActions")); toggle_disabling_of_mouse_actions(panel->disaB, panel); /**/ getMouseParameters(dpy, &accel, &a); panel->maxThreshold = WidthOfScreen(DefaultScreenOfDisplay(dpy)); if (a > panel->maxThreshold) { panel->maxThreshold = a; } sprintf(buffer, "%i", a); WMSetTextFieldText(panel->threT, buffer); WMSetSliderValue(panel->speedS, (accel - 0.25F) / 0.25F); panel->acceleration = accel; sprintf(buffer, "%.2f", (double)accel); WMSetTextFieldText(panel->acceT, buffer); /**/ b = GetIntegerForKey("DoubleClickTime"); /* find best match */ a = -1; for (i = 0; i < wlengthof(panel->ddelaB); i++) { if (DELAY(i) == b) a = i; } if (a >= 0) WMPerformButtonClick(panel->ddelaB[a]); sprintf(buffer, "%i", b); WMSetTextFieldText(panel->ddelaT, buffer); /**/ str = GetStringForKey("ModifierKey"); if (!str) str = "mod1"; a = ModifierFromKey(dpy, str); if (a != -1) { str = modifierNames[a]; a = 0; for (i = 0; i < WMGetPopUpButtonNumberOfItems(panel->grabP); i++) { if (strstr(WMGetPopUpButtonItem(panel->grabP, i), str)) { WMSetPopUpButtonSelectedItem(panel->grabP, i); a = 1; break; } } } if (a < 1) { char *previous; previous = WMGetPopUpButtonItem(panel->grabP, 0); if (previous != NULL) WMSetPopUpButtonSelectedItem(panel->grabP, 0); wwarning(_("modifier key %s for option ModifierKey was not recognized. Using %s as default"), str, previous?previous:"(empty)"); } }