1 /* Workspace.c- workspace options
3 * WPrefs - Window Maker Preferences Program
5 * Copyright (c) 1998-2003 Alfredo K. Kojima
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
25 typedef struct _Panel {
32 CallbackRec callbacks;
54 #define ICON_FILE "workspace"
56 #define ARQUIVO_XIS "xis"
57 #define DONT_LINK_FILE "dontlinkworkspaces"
58 #define CYCLE_FILE "cycleworkspaces"
59 #define ADVANCE_FILE "advancetonewworkspace"
60 #define WSNAME_FILE "workspacename"
61 #define DOCK_FILE "dock"
62 #define CLIP_FILE "clip"
64 static char *WSNamePositions[] = {
76 createImages(WMScreen * scr, RContext * rc, RImage * xis, char *file, WMPixmap ** icon1, WMPixmap ** icon2)
79 RColor gray = { 0xae, 0xaa, 0xae };
81 *icon1 = WMCreatePixmapFromFile(scr, file);
83 wwarning(_("could not load icon %s"), file);
92 icon = RLoadImage(rc, file, 0);
94 wwarning(_("could not load icon %s"), file);
98 RCombineImageWithColor(icon, &gray);
100 RCombineImagesWithOpaqueness(icon, xis, 180);
101 if (!(*icon2 = WMCreatePixmapFromRImage(scr, icon, 127))) {
102 wwarning(_("could not process icon %s:"), file, RMessageForError(RErrorCode));
109 static void showData(_Panel * panel)
114 WMSetButtonSelected(panel->linkB, !GetBoolForKey("DontLinkWorkspaces"));
116 WMSetButtonSelected(panel->cyclB, GetBoolForKey("CycleWorkspaces"));
118 WMSetButtonSelected(panel->newB, GetBoolForKey("AdvanceToNewWorkspace"));
120 WMSetButtonSelected(panel->dockB, !GetBoolForKey("DisableDock"));
122 WMSetButtonSelected(panel->clipB, !GetBoolForKey("DisableClip"));
124 str = GetStringForKey("WorkspaceNameDisplayPosition");
128 idx = 1; /* center */
129 for (i = 0; i < sizeof(WSNamePositions) / sizeof(char *); i++) {
130 if (strcasecmp(WSNamePositions[i], str) == 0) {
135 WMSetPopUpButtonSelectedItem(panel->posP, idx);
138 static void createPanel(Panel * p)
140 _Panel *panel = (_Panel *) p;
141 WMScreen *scr = WMWidgetScreen(panel->parent);
142 WMPixmap *icon1, *icon2;
144 RContext *rc = WMScreenRContext(scr);
147 path = LocateImage(ARQUIVO_XIS);
149 xis = RLoadImage(rc, path, 0);
151 wwarning(_("could not load image file %s"), path);
156 panel->box = WMCreateBox(panel->parent);
157 WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);
159 /***************** Workspace Navigation *****************/
160 panel->navF = WMCreateFrame(panel->box);
161 WMResizeWidget(panel->navF, 365, 210);
162 WMMoveWidget(panel->navF, 15, 10);
163 WMSetFrameTitle(panel->navF, _("Workspace Navigation"));
165 panel->cyclB = WMCreateSwitchButton(panel->navF);
166 WMResizeWidget(panel->cyclB, 280, 34);
167 WMMoveWidget(panel->cyclB, 75, 30);
168 WMSetButtonText(panel->cyclB, _("Wrap to the first workspace from the last workspace."));
170 panel->cyclL = WMCreateLabel(panel->navF);
171 WMResizeWidget(panel->cyclL, 60, 60);
172 WMMoveWidget(panel->cyclL, 10, 15);
173 WMSetLabelImagePosition(panel->cyclL, WIPImageOnly);
174 path = LocateImage(CYCLE_FILE);
176 createImages(scr, rc, xis, path, &icon1, NULL);
178 WMSetLabelImage(panel->cyclL, icon1);
179 WMReleasePixmap(icon1);
184 /**/ panel->linkB = WMCreateSwitchButton(panel->navF);
185 WMResizeWidget(panel->linkB, 280, 34);
186 WMMoveWidget(panel->linkB, 75, 75);
187 WMSetButtonText(panel->linkB, _("Switch workspaces while dragging windows."));
189 panel->linkL = WMCreateLabel(panel->navF);
190 WMResizeWidget(panel->linkL, 60, 40);
191 WMMoveWidget(panel->linkL, 10, 80);
192 WMSetLabelImagePosition(panel->linkL, WIPImageOnly);
193 path = LocateImage(DONT_LINK_FILE);
195 createImages(scr, rc, xis, path, &icon1, NULL);
197 WMSetLabelImage(panel->linkL, icon1);
198 WMReleasePixmap(icon1);
203 /**/ panel->newB = WMCreateSwitchButton(panel->navF);
204 WMResizeWidget(panel->newB, 280, 34);
205 WMMoveWidget(panel->newB, 75, 120);
206 WMSetButtonText(panel->newB, _("Automatically create new workspaces."));
208 panel->newL = WMCreateLabel(panel->navF);
209 WMResizeWidget(panel->newL, 60, 20);
210 WMMoveWidget(panel->newL, 10, 130);
211 WMSetLabelImagePosition(panel->newL, WIPImageOnly);
212 path = LocateImage(ADVANCE_FILE);
214 createImages(scr, rc, xis, path, &icon1, NULL);
216 WMSetLabelImage(panel->newL, icon1);
217 WMReleasePixmap(icon1);
222 /**/ panel->posL = WMCreateLabel(panel->navF);
223 WMResizeWidget(panel->posL, 140, 30);
224 WMMoveWidget(panel->posL, 75, 165);
225 WMSetLabelTextAlignment(panel->posL, WARight);
226 WMSetLabelText(panel->posL, _("Position of workspace\nname display"));
228 panel->posiL = WMCreateLabel(panel->navF);
229 WMResizeWidget(panel->posiL, 60, 40);
230 WMMoveWidget(panel->posiL, 10, 160);
231 WMSetLabelImagePosition(panel->posiL, WIPImageOnly);
232 path = LocateImage(WSNAME_FILE);
234 createImages(scr, rc, xis, path, &icon1, NULL);
236 WMSetLabelImage(panel->posiL, icon1);
237 WMReleasePixmap(icon1);
242 panel->posP = WMCreatePopUpButton(panel->navF);
243 WMResizeWidget(panel->posP, 125, 20);
244 WMMoveWidget(panel->posP, 225, 175);
245 WMAddPopUpButtonItem(panel->posP, _("Disable"));
246 WMAddPopUpButtonItem(panel->posP, _("Center"));
247 WMAddPopUpButtonItem(panel->posP, _("Top"));
248 WMAddPopUpButtonItem(panel->posP, _("Bottom"));
249 WMAddPopUpButtonItem(panel->posP, _("Top/Left"));
250 WMAddPopUpButtonItem(panel->posP, _("Top/Right"));
251 WMAddPopUpButtonItem(panel->posP, _("Bottom/Left"));
252 WMAddPopUpButtonItem(panel->posP, _("Bottom/Right"));
254 WMMapSubwidgets(panel->navF);
256 /***************** Dock/Clip *****************/
257 panel->dockF = WMCreateFrame(panel->box);
258 WMResizeWidget(panel->dockF, 115, 210);
259 WMMoveWidget(panel->dockF, 390, 10);
260 WMSetFrameTitle(panel->dockF, _("Dock/Clip"));
262 panel->dockB = WMCreateButton(panel->dockF, WBTToggle);
263 WMResizeWidget(panel->dockB, 64, 64);
264 WMMoveWidget(panel->dockB, 25, 35);
265 WMSetButtonImagePosition(panel->dockB, WIPImageOnly);
266 path = LocateImage(DOCK_FILE);
268 createImages(scr, rc, xis, path, &icon1, &icon2);
270 WMSetButtonImage(panel->dockB, icon2);
271 WMReleasePixmap(icon2);
274 WMSetButtonAltImage(panel->dockB, icon1);
275 WMReleasePixmap(icon1);
279 WMSetBalloonTextForView(_("Disable/enable the application Dock (the\n"
280 "vertical icon bar in the side of the screen)."), WMWidgetView(panel->dockB));
282 panel->clipB = WMCreateButton(panel->dockF, WBTToggle);
283 WMResizeWidget(panel->clipB, 64, 64);
284 WMMoveWidget(panel->clipB, 25, 120);
285 WMSetButtonImagePosition(panel->clipB, WIPImageOnly);
286 path = LocateImage(CLIP_FILE);
288 createImages(scr, rc, xis, path, &icon1, &icon2);
290 WMSetButtonImage(panel->clipB, icon2);
291 WMReleasePixmap(icon2);
294 WMSetButtonAltImage(panel->clipB, icon1);
295 WMReleasePixmap(icon1);
299 WMSetBalloonTextForView(_("Disable/enable the Clip (that thing with\n"
300 "a paper clip icon)."), WMWidgetView(panel->clipB));
302 WMMapSubwidgets(panel->dockF);
307 WMRealizeWidget(panel->box);
308 WMMapSubwidgets(panel->box);
313 static void storeData(_Panel * panel)
315 SetBoolForKey(!WMGetButtonSelected(panel->linkB), "DontLinkWorkspaces");
316 SetBoolForKey(WMGetButtonSelected(panel->cyclB), "CycleWorkspaces");
317 SetBoolForKey(WMGetButtonSelected(panel->newB), "AdvanceToNewWorkspace");
319 SetBoolForKey(!WMGetButtonSelected(panel->dockB), "DisableDock");
320 SetBoolForKey(!WMGetButtonSelected(panel->clipB), "DisableClip");
322 SetStringForKey(WSNamePositions[WMGetPopUpButtonSelectedItem(panel->posP)],
323 "WorkspaceNameDisplayPosition");
326 Panel *InitWorkspace(WMScreen * scr, WMWidget * parent)
330 panel = wmalloc(sizeof(_Panel));
331 memset(panel, 0, sizeof(_Panel));
333 panel->sectionName = _("Workspace Preferences");
335 panel->description = _("Workspace navigation features.\n"
336 "You can also enable/disable the Dock and Clip here.");
338 panel->parent = parent;
340 panel->callbacks.createWidgets = createPanel;
341 panel->callbacks.updateDomain = storeData;
343 AddSection(panel, ICON_FILE);