1 /* Workspace.c- workspace options
3 * WPrefs - Window Maker Preferences Program
5 * Copyright (c) 1998 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,
27 typedef struct _Panel
{
34 CallbackRec callbacks
;
58 #define ICON_FILE "workspace"
60 #define ARQUIVO_XIS "xis"
61 #define DONT_LINK_FILE "dontlinkworkspaces"
62 #define CYCLE_FILE "cycleworkspaces"
63 #define ADVANCE_FILE "advancetonewworkspace"
64 #define DOCK_FILE "dock"
65 #define CLIP_FILE "clip"
68 static char *WSNamePositions
[] = {
81 createImages(WMScreen
*scr
, RContext
*rc
, RImage
*xis
, char *file
,
82 WMPixmap
**icon1
, WMPixmap
**icon2
)
85 RColor gray
= {0xae,0xaa,0xae};
87 *icon1
= WMCreatePixmapFromFile(scr
, file
);
89 wwarning(_("could not load icon %s"), file
);
98 icon
= RLoadImage(rc
, file
, 0);
100 wwarning(_("could not load icon %s"), file
);
104 RCombineImageWithColor(icon
, &gray
);
106 RCombineImagesWithOpaqueness(icon
, xis
, 180);
107 if (!(*icon2
= WMCreatePixmapFromRImage(scr
, icon
, 127))) {
108 wwarning(_("could not process icon %s:"), file
, RMessageForError(RErrorCode
));
118 showData(_Panel
*panel
)
123 WMSetButtonSelected(panel
->linkB
, !GetBoolForKey("DontLinkWorkspaces"));
125 WMSetButtonSelected(panel
->cyclB
, GetBoolForKey("CycleWorkspaces"));
127 WMSetButtonSelected(panel
->newB
, GetBoolForKey("AdvanceToNewWorkspace"));
129 WMSetButtonSelected(panel
->dockB
, !GetBoolForKey("DisableDock"));
131 WMSetButtonSelected(panel
->clipB
, !GetBoolForKey("DisableClip"));
133 str
= GetStringForKey("WorkspaceNameDisplayPosition");
137 idx
= 1; /* center */
138 for (i
= 0; i
< sizeof(WSNamePositions
); i
++) {
139 if (strcmp(WSNamePositions
[i
], str
) == 0) {
144 WMSetPopUpButtonSelectedItem(panel
->posP
, idx
);
150 createPanel(Panel
*p
)
152 _Panel
*panel
= (_Panel
*)p
;
153 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
154 WMPixmap
*icon1
, *icon2
;
156 RContext
*rc
= WMScreenRContext(scr
);
159 path
= LocateImage(ARQUIVO_XIS
);
161 xis
= RLoadImage(rc
, path
, 0);
163 wwarning(_("could not load image file %s"), path
);
168 panel
->frame
= WMCreateFrame(panel
->win
);
169 WMResizeWidget(panel
->frame
, FRAME_WIDTH
, FRAME_HEIGHT
);
170 WMMoveWidget(panel
->frame
, FRAME_LEFT
, FRAME_TOP
);
172 /***************** Workspace Navigation *****************/
173 panel
->navF
= WMCreateFrame(panel
->frame
);
174 WMResizeWidget(panel
->navF
, 365, 210);
175 WMMoveWidget(panel
->navF
, 15, 10);
176 WMSetFrameTitle(panel
->navF
, _("Workspace Navigation"));
179 panel
->cyclB
= WMCreateSwitchButton(panel
->navF
);
180 WMResizeWidget(panel
->cyclB
, 280, 34);
181 WMMoveWidget(panel
->cyclB
, 75, 30);
182 WMSetButtonText(panel
->cyclB
,
183 _("wrap to the first workspace after the last workspace."));
185 panel
->cyclL
= WMCreateLabel(panel
->navF
);
186 WMResizeWidget(panel
->cyclL
, 60, 60);
187 WMMoveWidget(panel
->cyclL
, 10, 15);
188 WMSetLabelImagePosition(panel
->cyclL
, WIPImageOnly
);
189 path
= LocateImage(CYCLE_FILE
);
191 createImages(scr
, rc
, xis
, path
, &icon1
, NULL
);
193 WMSetLabelImage(panel
->cyclL
, icon1
);
194 WMReleasePixmap(icon1
);
201 panel
->linkB
= WMCreateSwitchButton(panel
->navF
);
202 WMResizeWidget(panel
->linkB
, 280, 34);
203 WMMoveWidget(panel
->linkB
, 75, 75);
204 WMSetButtonText(panel
->linkB
,
205 _("switch workspaces while dragging windows."));
207 panel
->linkL
= WMCreateLabel(panel
->navF
);
208 WMResizeWidget(panel
->linkL
, 60, 40);
209 WMMoveWidget(panel
->linkL
, 10, 80);
210 WMSetLabelImagePosition(panel
->linkL
, WIPImageOnly
);
211 path
= LocateImage(DONT_LINK_FILE
);
213 createImages(scr
, rc
, xis
, path
, &icon1
, NULL
);
215 WMSetLabelImage(panel
->linkL
, icon1
);
216 WMReleasePixmap(icon1
);
223 panel
->newB
= WMCreateSwitchButton(panel
->navF
);
224 WMResizeWidget(panel
->newB
, 280, 34);
225 WMMoveWidget(panel
->newB
, 75, 120);
226 WMSetButtonText(panel
->newB
,
227 _("automatically create new workspaces."));
229 panel
->newL
= WMCreateLabel(panel
->navF
);
230 WMResizeWidget(panel
->newL
, 60, 20);
231 WMMoveWidget(panel
->newL
, 10, 130);
232 WMSetLabelImagePosition(panel
->newL
, WIPImageOnly
);
233 path
= LocateImage(ADVANCE_FILE
);
235 createImages(scr
, rc
, xis
, path
, &icon1
, NULL
);
237 WMSetLabelImage(panel
->newL
, icon1
);
238 WMReleasePixmap(icon1
);
245 panel
->posL
= WMCreateLabel(panel
->navF
);
246 WMResizeWidget(panel
->posL
, 140, 30);
247 WMMoveWidget(panel
->posL
, 75, 165);
248 WMSetLabelTextAlignment(panel
->posL
, WARight
);
249 WMSetLabelText(panel
->posL
,
250 _("Position of workspace name display"));
253 panel
->posiL
= WMCreateLabel(panel
->navF
);
254 WMResizeWidget(panel
->posiL
, 60, 40);
255 WMMoveWidget(panel
->posiL
, 10, 160);
256 WMSetLabelImagePosition(panel
->posiL
, WIPImageOnly
);
257 path
= LocateImage(ADVANCE_FILE
);
259 createImages(scr
, rc
, xis
, path
, &icon1
, NULL
);
261 WMSetLabelImage(panel
->posiL
, icon1
);
262 WMReleasePixmap(icon1
);
268 panel
->posP
= WMCreatePopUpButton(panel
->navF
);
269 WMResizeWidget(panel
->posP
, 125, 20);
270 WMMoveWidget(panel
->posP
, 225, 175);
271 WMAddPopUpButtonItem(panel
->posP
, _("Disable"));
272 WMAddPopUpButtonItem(panel
->posP
, _("Center"));
273 WMAddPopUpButtonItem(panel
->posP
, _("Top"));
274 WMAddPopUpButtonItem(panel
->posP
, _("Bottom"));
275 WMAddPopUpButtonItem(panel
->posP
, _("Top/left"));
276 WMAddPopUpButtonItem(panel
->posP
, _("Top/right"));
277 WMAddPopUpButtonItem(panel
->posP
, _("Bottom/left"));
278 WMAddPopUpButtonItem(panel
->posP
, _("Bottom/right"));
280 WMMapSubwidgets(panel
->navF
);
282 /***************** Dock/Clip *****************/
283 panel
->dockF
= WMCreateFrame(panel
->frame
);
284 WMResizeWidget(panel
->dockF
, 115, 210);
285 WMMoveWidget(panel
->dockF
, 390, 10);
286 WMSetFrameTitle(panel
->dockF
, _("Dock/Clip"));
288 panel
->dockB
= WMCreateButton(panel
->dockF
, WBTToggle
);
289 WMResizeWidget(panel
->dockB
, 64, 64);
290 WMMoveWidget(panel
->dockB
, 25, 35);
291 WMSetButtonImagePosition(panel
->dockB
, WIPImageOnly
);
292 path
= LocateImage(DOCK_FILE
);
294 createImages(scr
, rc
, xis
, path
, &icon1
, &icon2
);
296 WMSetButtonImage(panel
->dockB
, icon2
);
297 WMReleasePixmap(icon2
);
300 WMSetButtonAltImage(panel
->dockB
, icon1
);
301 WMReleasePixmap(icon1
);
305 WMSetBalloonTextForView(_("Disable/enable the application Dock (the\n"
306 "vertical icon bar in the side of the screen)."),
307 WMWidgetView(panel
->dockB
));
309 panel
->clipB
= WMCreateButton(panel
->dockF
, WBTToggle
);
310 WMResizeWidget(panel
->clipB
, 64, 64);
311 WMMoveWidget(panel
->clipB
, 25, 120);
312 WMSetButtonImagePosition(panel
->clipB
, WIPImageOnly
);
313 path
= LocateImage(CLIP_FILE
);
315 createImages(scr
, rc
, xis
, path
, &icon1
, &icon2
);
317 WMSetButtonImage(panel
->clipB
, icon2
);
318 WMReleasePixmap(icon2
);
321 WMSetButtonAltImage(panel
->clipB
, icon1
);
322 WMReleasePixmap(icon1
);
325 WMSetBalloonTextForView(_("Disable/enable the Clip (that thing with\n"
326 "a paper clip icon)."),
327 WMWidgetView(panel
->clipB
));
329 WMMapSubwidgets(panel
->dockF
);
334 WMRealizeWidget(panel
->frame
);
335 WMMapSubwidgets(panel
->frame
);
342 storeData(_Panel
*panel
)
344 SetBoolForKey(!WMGetButtonSelected(panel
->linkB
), "DontLinkWorkspaces");
345 SetBoolForKey(WMGetButtonSelected(panel
->cyclB
), "CycleWorkspaces");
346 SetBoolForKey(WMGetButtonSelected(panel
->newB
), "AdvanceToNewWorkspace");
348 SetBoolForKey(!WMGetButtonSelected(panel
->dockB
), "DisableDock");
349 SetBoolForKey(!WMGetButtonSelected(panel
->clipB
), "DisableClip");
351 SetStringForKey(WSNamePositions
[WMGetPopUpButtonSelectedItem(panel
->posP
)],
352 "WorkspaceNameDisplayPosition");
358 InitWorkspace(WMScreen
*scr
, WMWindow
*win
)
362 panel
= wmalloc(sizeof(_Panel
));
363 memset(panel
, 0, sizeof(_Panel
));
365 panel
->sectionName
= _("Workspace Preferences");
367 panel
->description
= _("Workspace navigation features.\n"
368 "You can also enable/disable the Dock and Clip here.");
372 panel
->callbacks
.createWidgets
= createPanel
;
373 panel
->callbacks
.updateDomain
= storeData
;
375 AddSection(panel
, ICON_FILE
);