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 along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 typedef struct _Panel
{
31 CallbackRec callbacks
;
53 #define ICON_FILE "workspace"
55 #define ARQUIVO_XIS "xis"
56 #define DONT_LINK_FILE "dontlinkworkspaces"
57 #define CYCLE_FILE "cycleworkspaces"
58 #define ADVANCE_FILE "advancetonewworkspace"
59 #define WSNAME_FILE "workspacename"
60 #define DOCK_FILE "dock"
61 #define CLIP_FILE "clip"
63 static char *WSNamePositions
[] = {
75 createImages(WMScreen
* scr
, RContext
* rc
, RImage
* xis
, char *file
, WMPixmap
** icon1
, WMPixmap
** icon2
)
78 RColor gray
= { 0xae, 0xaa, 0xae, 0 };
80 *icon1
= WMCreatePixmapFromFile(scr
, file
);
82 wwarning(_("could not load icon %s"), file
);
91 icon
= RLoadImage(rc
, file
, 0);
93 wwarning(_("could not load icon %s"), file
);
97 RCombineImageWithColor(icon
, &gray
);
99 RCombineImagesWithOpaqueness(icon
, xis
, 180);
100 if (!(*icon2
= WMCreatePixmapFromRImage(scr
, icon
, 127))) {
101 wwarning(_("could not process icon %s: %s"), file
, RMessageForError(RErrorCode
));
108 static void showData(_Panel
* panel
)
113 WMSetButtonSelected(panel
->linkB
, !GetBoolForKey("DontLinkWorkspaces"));
115 WMSetButtonSelected(panel
->cyclB
, GetBoolForKey("CycleWorkspaces"));
117 WMSetButtonSelected(panel
->newB
, GetBoolForKey("AdvanceToNewWorkspace"));
119 WMSetButtonSelected(panel
->dockB
, !GetBoolForKey("DisableDock"));
121 WMSetButtonSelected(panel
->clipB
, !GetBoolForKey("DisableClip"));
123 str
= GetStringForKey("WorkspaceNameDisplayPosition");
127 idx
= 1; /* center */
128 for (i
= 0; i
< sizeof(WSNamePositions
) / sizeof(char *); i
++) {
129 if (strcasecmp(WSNamePositions
[i
], str
) == 0) {
134 WMSetPopUpButtonSelectedItem(panel
->posP
, idx
);
137 static void createPanel(Panel
* p
)
139 _Panel
*panel
= (_Panel
*) p
;
140 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
141 WMPixmap
*icon1
, *icon2
;
143 RContext
*rc
= WMScreenRContext(scr
);
146 path
= LocateImage(ARQUIVO_XIS
);
148 xis
= RLoadImage(rc
, path
, 0);
150 wwarning(_("could not load image file %s"), path
);
155 panel
->box
= WMCreateBox(panel
->parent
);
156 WMSetViewExpandsToParent(WMWidgetView(panel
->box
), 2, 2, 2, 2);
158 /***************** Workspace Navigation *****************/
159 panel
->navF
= WMCreateFrame(panel
->box
);
160 WMResizeWidget(panel
->navF
, 365, 210);
161 WMMoveWidget(panel
->navF
, 15, 10);
162 WMSetFrameTitle(panel
->navF
, _("Workspace Navigation"));
164 panel
->cyclB
= WMCreateSwitchButton(panel
->navF
);
165 WMResizeWidget(panel
->cyclB
, 280, 34);
166 WMMoveWidget(panel
->cyclB
, 75, 30);
167 WMSetButtonText(panel
->cyclB
, _("Wrap to the first workspace from the last workspace."));
169 panel
->cyclL
= WMCreateLabel(panel
->navF
);
170 WMResizeWidget(panel
->cyclL
, 60, 60);
171 WMMoveWidget(panel
->cyclL
, 10, 15);
172 WMSetLabelImagePosition(panel
->cyclL
, WIPImageOnly
);
173 path
= LocateImage(CYCLE_FILE
);
175 createImages(scr
, rc
, xis
, path
, &icon1
, NULL
);
177 WMSetLabelImage(panel
->cyclL
, icon1
);
178 WMReleasePixmap(icon1
);
183 /**/ panel
->linkB
= WMCreateSwitchButton(panel
->navF
);
184 WMResizeWidget(panel
->linkB
, 280, 34);
185 WMMoveWidget(panel
->linkB
, 75, 75);
186 WMSetButtonText(panel
->linkB
, _("Switch workspaces while dragging windows."));
188 panel
->linkL
= WMCreateLabel(panel
->navF
);
189 WMResizeWidget(panel
->linkL
, 60, 40);
190 WMMoveWidget(panel
->linkL
, 10, 80);
191 WMSetLabelImagePosition(panel
->linkL
, WIPImageOnly
);
192 path
= LocateImage(DONT_LINK_FILE
);
194 createImages(scr
, rc
, xis
, path
, &icon1
, NULL
);
196 WMSetLabelImage(panel
->linkL
, icon1
);
197 WMReleasePixmap(icon1
);
202 /**/ panel
->newB
= WMCreateSwitchButton(panel
->navF
);
203 WMResizeWidget(panel
->newB
, 280, 34);
204 WMMoveWidget(panel
->newB
, 75, 120);
205 WMSetButtonText(panel
->newB
, _("Automatically create new workspaces."));
207 panel
->newL
= WMCreateLabel(panel
->navF
);
208 WMResizeWidget(panel
->newL
, 60, 20);
209 WMMoveWidget(panel
->newL
, 10, 130);
210 WMSetLabelImagePosition(panel
->newL
, WIPImageOnly
);
211 path
= LocateImage(ADVANCE_FILE
);
213 createImages(scr
, rc
, xis
, path
, &icon1
, NULL
);
215 WMSetLabelImage(panel
->newL
, icon1
);
216 WMReleasePixmap(icon1
);
221 /**/ panel
->posL
= WMCreateLabel(panel
->navF
);
222 WMResizeWidget(panel
->posL
, 140, 30);
223 WMMoveWidget(panel
->posL
, 75, 165);
224 WMSetLabelTextAlignment(panel
->posL
, WARight
);
225 WMSetLabelText(panel
->posL
, _("Position of workspace\nname display"));
227 panel
->posiL
= WMCreateLabel(panel
->navF
);
228 WMResizeWidget(panel
->posiL
, 60, 40);
229 WMMoveWidget(panel
->posiL
, 10, 160);
230 WMSetLabelImagePosition(panel
->posiL
, WIPImageOnly
);
231 path
= LocateImage(WSNAME_FILE
);
233 createImages(scr
, rc
, xis
, path
, &icon1
, NULL
);
235 WMSetLabelImage(panel
->posiL
, icon1
);
236 WMReleasePixmap(icon1
);
241 panel
->posP
= WMCreatePopUpButton(panel
->navF
);
242 WMResizeWidget(panel
->posP
, 125, 20);
243 WMMoveWidget(panel
->posP
, 225, 175);
244 WMAddPopUpButtonItem(panel
->posP
, _("Disable"));
245 WMAddPopUpButtonItem(panel
->posP
, _("Center"));
246 WMAddPopUpButtonItem(panel
->posP
, _("Top"));
247 WMAddPopUpButtonItem(panel
->posP
, _("Bottom"));
248 WMAddPopUpButtonItem(panel
->posP
, _("Top/Left"));
249 WMAddPopUpButtonItem(panel
->posP
, _("Top/Right"));
250 WMAddPopUpButtonItem(panel
->posP
, _("Bottom/Left"));
251 WMAddPopUpButtonItem(panel
->posP
, _("Bottom/Right"));
253 WMMapSubwidgets(panel
->navF
);
255 /***************** Dock/Clip *****************/
256 panel
->dockF
= WMCreateFrame(panel
->box
);
257 WMResizeWidget(panel
->dockF
, 115, 210);
258 WMMoveWidget(panel
->dockF
, 390, 10);
259 WMSetFrameTitle(panel
->dockF
, _("Dock/Clip"));
261 panel
->dockB
= WMCreateButton(panel
->dockF
, WBTToggle
);
262 WMResizeWidget(panel
->dockB
, 64, 64);
263 WMMoveWidget(panel
->dockB
, 25, 35);
264 WMSetButtonImagePosition(panel
->dockB
, WIPImageOnly
);
265 path
= LocateImage(DOCK_FILE
);
267 createImages(scr
, rc
, xis
, path
, &icon1
, &icon2
);
269 WMSetButtonImage(panel
->dockB
, icon2
);
270 WMReleasePixmap(icon2
);
273 WMSetButtonAltImage(panel
->dockB
, icon1
);
274 WMReleasePixmap(icon1
);
278 WMSetBalloonTextForView(_("Disable/enable the application Dock (the\n"
279 "vertical icon bar in the side of the screen)."), WMWidgetView(panel
->dockB
));
281 panel
->clipB
= WMCreateButton(panel
->dockF
, WBTToggle
);
282 WMResizeWidget(panel
->clipB
, 64, 64);
283 WMMoveWidget(panel
->clipB
, 25, 120);
284 WMSetButtonImagePosition(panel
->clipB
, WIPImageOnly
);
285 path
= LocateImage(CLIP_FILE
);
287 createImages(scr
, rc
, xis
, path
, &icon1
, &icon2
);
289 WMSetButtonImage(panel
->clipB
, icon2
);
290 WMReleasePixmap(icon2
);
293 WMSetButtonAltImage(panel
->clipB
, icon1
);
294 WMReleasePixmap(icon1
);
298 WMSetBalloonTextForView(_("Disable/enable the Clip (that thing with\n"
299 "a paper clip icon)."), WMWidgetView(panel
->clipB
));
301 WMMapSubwidgets(panel
->dockF
);
306 WMRealizeWidget(panel
->box
);
307 WMMapSubwidgets(panel
->box
);
312 static void storeData(_Panel
* panel
)
314 SetBoolForKey(!WMGetButtonSelected(panel
->linkB
), "DontLinkWorkspaces");
315 SetBoolForKey(WMGetButtonSelected(panel
->cyclB
), "CycleWorkspaces");
316 SetBoolForKey(WMGetButtonSelected(panel
->newB
), "AdvanceToNewWorkspace");
318 SetBoolForKey(!WMGetButtonSelected(panel
->dockB
), "DisableDock");
319 SetBoolForKey(!WMGetButtonSelected(panel
->clipB
), "DisableClip");
321 SetStringForKey(WSNamePositions
[WMGetPopUpButtonSelectedItem(panel
->posP
)],
322 "WorkspaceNameDisplayPosition");
325 Panel
*InitWorkspace(WMScreen
* scr
, WMWidget
* parent
)
329 panel
= wmalloc(sizeof(_Panel
));
330 memset(panel
, 0, sizeof(_Panel
));
332 panel
->sectionName
= _("Workspace Preferences");
334 panel
->description
= _("Workspace navigation features.\n"
335 "You can also enable/disable the Dock and Clip here.");
337 panel
->parent
= parent
;
339 panel
->callbacks
.createWidgets
= createPanel
;
340 panel
->callbacks
.updateDomain
= storeData
;
342 AddSection(panel
, ICON_FILE
);