1 /* Configurations.c- misc. configurations
3 * WPrefs - WindowMaker 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,
26 typedef struct _Panel
{
30 CallbackRec callbacks
;
62 #define ICON_FILE "configs"
64 #define OLDS_IMAGE "oldstyle"
65 #define NEWS_IMAGE "newstyle"
67 #define ANIM_IMAGE "animations"
68 #define SUPERF_IMAGE "moreanim"
69 #define SOUND_IMAGE "sound"
71 #define SPEED_IMAGE "speed%i"
72 #define SPEED_IMAGE_S "speed%is"
74 #define ARQUIVO_XIS "xis"
77 static void updateLabel(WMWidget
*self
, void *data
);
81 showData(_Panel
*panel
)
83 WMPerformButtonClick(panel
->icoB
[GetSpeedForKey("IconSlideSpeed")]);
85 WMPerformButtonClick(panel
->shaB
[GetSpeedForKey("ShadeSpeed")]);
87 if (GetBoolForKey("NewStyle")) {
88 WMPerformButtonClick(panel
->newsB
);
90 WMPerformButtonClick(panel
->oldsB
);
93 WMSetButtonSelected(panel
->animB
, !GetBoolForKey("DisableAnimations"));
95 WMSetButtonSelected(panel
->supB
, GetBoolForKey("Superfluous"));
97 WMSetButtonSelected(panel
->sfxB
, !GetBoolForKey("DisableSound"));
99 WMSetButtonSelected(panel
->dithB
, GetBoolForKey("DisableDithering"));
101 WMSetSliderValue(panel
->dithS
, GetIntegerForKey("ColormapSize"));
103 updateLabel(panel
->dithS
, panel
);
108 updateLabel(WMWidget
*self
, void *data
)
110 WMSlider
*sPtr
= (WMSlider
*)self
;
111 _Panel
*panel
= (_Panel
*)data
;
115 fl
= WMGetSliderValue(sPtr
);
117 panel
->cmapSize
= (int)fl
;
119 sprintf(buffer
, "%i", panel
->cmapSize
*panel
->cmapSize
*panel
->cmapSize
);
120 WMSetLabelText(panel
->dithL
, buffer
);
125 createImages(WMScreen
*scr
, RContext
*rc
, RImage
*xis
, char *file
,
126 WMPixmap
**icon1
, WMPixmap
**icon2
)
134 path
= LocateImage(file
);
139 *icon1
= WMCreatePixmapFromFile(scr
, path
);
141 wwarning(_("could not load icon %s"), path
);
145 icon
= RLoadImage(rc
, path
, 0);
147 wwarning(_("could not load icon %s"), path
);
152 RCombineImages(icon
, xis
);
153 if (!(*icon2
= WMCreatePixmapFromRImage(scr
, icon
, 127)))
154 wwarning(_("could not process icon %s:"), file
, RErrorString
);
163 createPanel(Panel
*p
)
165 _Panel
*panel
= (_Panel
*)p
;
166 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
168 WMPixmap
*icon
, *altIcon
;
171 RContext
*rc
= WMScreenRContext(scr
);
172 WMFont
*font
= WMSystemFontOfSize(scr
, 10);
175 path
= LocateImage(ARQUIVO_XIS
);
177 xis
= RLoadImage(rc
, path
, 0);
179 wwarning(_("could not load image file %s"), path
);
184 panel
->frame
= WMCreateFrame(panel
->win
);
185 WMResizeWidget(panel
->frame
, FRAME_WIDTH
, FRAME_HEIGHT
);
186 WMMoveWidget(panel
->frame
, FRAME_LEFT
, FRAME_TOP
);
188 /*********** Icon Slide Speed **********/
190 panel
->icoF
= WMCreateFrame(panel
->frame
);
191 WMResizeWidget(panel
->icoF
, 230, 55);
192 WMMoveWidget(panel
->icoF
, 15, 10);
193 WMSetFrameTitle(panel
->icoF
, _("Icon Slide Speed"));
195 /*********** Shade Animation Speed **********/
196 panel
->shaF
= WMCreateFrame(panel
->frame
);
197 WMResizeWidget(panel
->shaF
, 230, 55);
198 WMMoveWidget(panel
->shaF
, 15, 70);
199 WMSetFrameTitle(panel
->shaF
, _("Shade Animation Speed"));
202 buf1
= wmalloc(strlen(SPEED_IMAGE
)+1);
203 buf2
= wmalloc(strlen(SPEED_IMAGE_S
)+1);
205 for (i
= 0; i
< 5; i
++) {
206 panel
->icoB
[i
] = WMCreateCustomButton(panel
->icoF
, WBBStateChangeMask
);
207 panel
->shaB
[i
] = WMCreateCustomButton(panel
->shaF
, WBBStateChangeMask
);
208 WMResizeWidget(panel
->icoB
[i
], 40, 35);
209 WMMoveWidget(panel
->icoB
[i
], 10+(40*i
), 15);
210 WMResizeWidget(panel
->shaB
[i
], 40, 35);
211 WMMoveWidget(panel
->shaB
[i
], 10+(40*i
), 15);
212 WMSetButtonBordered(panel
->icoB
[i
], False
);
213 WMSetButtonImagePosition(panel
->icoB
[i
], WIPImageOnly
);
215 WMGroupButtons(panel
->icoB
[0], panel
->icoB
[i
]);
217 WMSetButtonBordered(panel
->shaB
[i
], False
);
218 WMSetButtonImagePosition(panel
->shaB
[i
], WIPImageOnly
);
220 WMGroupButtons(panel
->shaB
[0], panel
->shaB
[i
]);
222 sprintf(buf1
, SPEED_IMAGE
, i
);
223 sprintf(buf2
, SPEED_IMAGE_S
, i
);
224 path
= LocateImage(buf1
);
226 icon
= WMCreatePixmapFromFile(scr
, path
);
228 WMSetButtonImage(panel
->icoB
[i
], icon
);
229 WMSetButtonImage(panel
->shaB
[i
], icon
);
230 WMReleasePixmap(icon
);
232 wwarning(_("could not load icon file %s"), path
);
236 path
= LocateImage(buf2
);
238 icon
= WMCreatePixmapFromFile(scr
, path
);
240 WMSetButtonAltImage(panel
->icoB
[i
], icon
);
241 WMSetButtonAltImage(panel
->shaB
[i
], icon
);
242 WMReleasePixmap(icon
);
244 wwarning(_("could not load icon file %s"), path
);
253 WMMapSubwidgets(panel
->icoF
);
254 WMMapSubwidgets(panel
->shaF
);
256 /***************** Titlebar Style Size ****************/
257 panel
->titlF
= WMCreateFrame(panel
->frame
);
258 WMResizeWidget(panel
->titlF
, 230, 95);
259 WMMoveWidget(panel
->titlF
, 15, 130);
260 WMSetFrameTitle(panel
->titlF
, _("Titlebar Style"));
262 panel
->newsB
= WMCreateButton(panel
->titlF
, WBTOnOff
);
263 WMResizeWidget(panel
->newsB
, 90, 60);
264 WMMoveWidget(panel
->newsB
, 25, 20);
265 WMSetButtonImagePosition(panel
->newsB
, WIPImageOnly
);
266 path
= LocateImage(NEWS_IMAGE
);
268 icon
= WMCreatePixmapFromFile(scr
, path
);
270 WMSetButtonImage(panel
->newsB
, icon
);
271 WMReleasePixmap(icon
);
275 panel
->oldsB
= WMCreateButton(panel
->titlF
, WBTOnOff
);
276 WMResizeWidget(panel
->oldsB
, 90, 60);
277 WMMoveWidget(panel
->oldsB
, 115, 20);
278 WMSetButtonImagePosition(panel
->oldsB
, WIPImageOnly
);
279 path
= LocateImage(OLDS_IMAGE
);
281 icon
= WMCreatePixmapFromFile(scr
, path
);
283 WMSetButtonImage(panel
->oldsB
, icon
);
284 WMReleasePixmap(icon
);
288 WMGroupButtons(panel
->newsB
, panel
->oldsB
);
290 WMMapSubwidgets(panel
->titlF
);
292 /**************** Features ******************/
294 panel
->animF
= WMCreateFrame(panel
->frame
);
295 WMResizeWidget(panel
->animF
, 255, 115);
296 WMMoveWidget(panel
->animF
, 255, 10);
297 WMSetFrameTitle(panel
->animF
, _("Animations and Sound"));
299 panel
->animB
= WMCreateButton(panel
->animF
, WBTToggle
);
300 WMResizeWidget(panel
->animB
, 64, 64);
301 WMMoveWidget(panel
->animB
, 15, 20);
302 WMSetButtonFont(panel
->animB
, font
);
303 WMSetButtonText(panel
->animB
, _("Animations"));
304 WMSetButtonImagePosition(panel
->animB
, WIPAbove
);
305 createImages(scr
, rc
, xis
, ANIM_IMAGE
, &altIcon
, &icon
);
307 WMSetButtonImage(panel
->animB
, icon
);
308 WMReleasePixmap(icon
);
311 WMSetButtonAltImage(panel
->animB
, altIcon
);
312 WMReleasePixmap(altIcon
);
315 panel
->supB
= WMCreateButton(panel
->animF
, WBTToggle
);
316 WMResizeWidget(panel
->supB
, 64, 64);
317 WMMoveWidget(panel
->supB
, 95, 20);
318 WMSetButtonFont(panel
->supB
, font
);
319 WMSetButtonText(panel
->supB
, _("Superfluous"));
320 WMSetButtonImagePosition(panel
->supB
, WIPAbove
);
321 createImages(scr
, rc
, xis
, SUPERF_IMAGE
, &altIcon
, &icon
);
323 WMSetButtonImage(panel
->supB
, icon
);
324 WMReleasePixmap(icon
);
327 WMSetButtonAltImage(panel
->supB
, altIcon
);
328 WMReleasePixmap(altIcon
);
331 panel
->sfxB
= WMCreateButton(panel
->animF
, WBTToggle
);
332 WMResizeWidget(panel
->sfxB
, 64, 64);
333 WMMoveWidget(panel
->sfxB
, 175, 20);
334 WMSetButtonFont(panel
->sfxB
, font
);
335 WMSetButtonText(panel
->sfxB
, _("Sounds"));
336 WMSetButtonImagePosition(panel
->sfxB
, WIPAbove
);
337 createImages(scr
, rc
, xis
, SOUND_IMAGE
, &altIcon
, &icon
);
339 WMSetButtonImage(panel
->sfxB
, icon
);
340 WMReleasePixmap(icon
);
343 WMSetButtonAltImage(panel
->sfxB
, altIcon
);
344 WMReleasePixmap(altIcon
);
348 panel
->noteL
= WMCreateLabel(panel
->animF
);
349 WMResizeWidget(panel
->noteL
, 235, 28);
350 WMMoveWidget(panel
->noteL
, 10, 85);
351 WMSetLabelFont(panel
->noteL
, font
);
352 WMSetLabelText(panel
->noteL
, _("Note: sound requires a module distributed separately"));
354 WMMapSubwidgets(panel
->animF
);
356 /*********** Dithering **********/
359 panel
->dithF
= WMCreateFrame(panel
->frame
);
360 WMResizeWidget(panel
->dithF
, 255, 95);
361 WMMoveWidget(panel
->dithF
, 255, 130);
362 WMSetFrameTitle(panel
->dithF
, _("Dithering colormap for 8bpp"));
364 panel
->dithB
= WMCreateSwitchButton(panel
->dithF
);
365 WMResizeWidget(panel
->dithB
, 235, 32);
366 WMMoveWidget(panel
->dithB
, 15, 15);
367 WMSetButtonText(panel
->dithB
, _("Disable dithering in any visual/depth"));
369 panel
->dithL
= WMCreateLabel(panel
->dithF
);
370 WMResizeWidget(panel
->dithL
, 75, 16);
371 WMMoveWidget(panel
->dithL
, 90, 50);
372 WMSetLabelTextAlignment(panel
->dithL
, WACenter
);
373 WMSetLabelText(panel
->dithL
, "64");
375 panel
->dithS
= WMCreateSlider(panel
->dithF
);
376 WMResizeWidget(panel
->dithS
, 95, 16);
377 WMMoveWidget(panel
->dithS
, 80, 65);
378 WMSetSliderMinValue(panel
->dithS
, 2);
379 WMSetSliderMaxValue(panel
->dithS
, 6);
380 WMSetSliderContinuous(panel
->dithS
, True
);
381 WMSetSliderAction(panel
->dithS
, updateLabel
, panel
);
383 panel
->dith1L
= WMCreateLabel(panel
->dithF
);
384 WMResizeWidget(panel
->dith1L
, 70, 35);
385 WMMoveWidget(panel
->dith1L
, 5, 50);
386 WMSetLabelTextAlignment(panel
->dith1L
, WACenter
);
387 WMSetLabelFont(panel
->dith1L
, font
);
388 WMSetLabelText(panel
->dith1L
, _("More colors for applications"));
390 panel
->dith2L
= WMCreateLabel(panel
->dithF
);
391 WMResizeWidget(panel
->dith2L
, 70, 35);
392 WMMoveWidget(panel
->dith2L
, 180, 50);
393 WMSetLabelTextAlignment(panel
->dith2L
, WACenter
);
394 WMSetLabelFont(panel
->dith2L
, font
);
395 WMSetLabelText(panel
->dith2L
, _("More colors for WindowMaker"));
397 WMMapSubwidgets(panel
->dithF
);
399 WMRealizeWidget(panel
->frame
);
400 WMMapSubwidgets(panel
->frame
);
411 storeData(_Panel
*panel
)
415 for (i
=0; i
<5; i
++) {
416 if (WMGetButtonSelected(panel
->icoB
[i
]))
419 SetSpeedForKey(i
, "IconSlideSpeed");
422 for (i
=0; i
<5; i
++) {
423 if (WMGetButtonSelected(panel
->shaB
[i
]))
426 SetSpeedForKey(i
, "ShadeSpeed");
428 SetBoolForKey(WMGetButtonSelected(panel
->newsB
), "NewStyle");
430 SetBoolForKey(!WMGetButtonSelected(panel
->animB
), "DisableAnimations");
431 SetBoolForKey(WMGetButtonSelected(panel
->supB
), "Superfluous");
432 SetBoolForKey(!WMGetButtonSelected(panel
->sfxB
), "DisableSound");
434 SetBoolForKey(WMGetButtonSelected(panel
->dithB
), "DisableDithering");
435 SetIntegerForKey(WMGetSliderValue(panel
->dithS
), "ColormapSize");
441 InitConfigurations(WMScreen
*scr
, WMWindow
*win
)
445 panel
= wmalloc(sizeof(_Panel
));
446 memset(panel
, 0, sizeof(_Panel
));
448 panel
->sectionName
= _("Other Configurations");
452 panel
->callbacks
.createWidgets
= createPanel
;
453 panel
->callbacks
.updateDomain
= storeData
;
455 AddSection(panel
, ICON_FILE
);