1 /* Configurations.c- misc. configurations
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,
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
)
130 RColor gray
= {0xae,0xaa,0xae};
135 path
= LocateImage(file
);
140 *icon1
= WMCreatePixmapFromFile(scr
, path
);
142 wwarning(_("could not load icon %s"), path
);
146 icon
= RLoadImage(rc
, path
, 0);
148 wwarning(_("could not load icon %s"), path
);
152 RCombineImageWithColor(icon
, &gray
);
154 RCombineImagesWithOpaqueness(icon
, xis
, 180);
155 if (!(*icon2
= WMCreatePixmapFromRImage(scr
, icon
, 127)))
156 wwarning(_("could not process icon %s:"), file
, RMessageForError(RErrorCode
));
165 createPanel(Panel
*p
)
167 _Panel
*panel
= (_Panel
*)p
;
168 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
170 WMPixmap
*icon
, *altIcon
;
173 RContext
*rc
= WMScreenRContext(scr
);
174 WMFont
*font
= WMSystemFontOfSize(scr
, 10);
177 path
= LocateImage(ARQUIVO_XIS
);
179 xis
= RLoadImage(rc
, path
, 0);
181 wwarning(_("could not load image file %s"), path
);
186 panel
->frame
= WMCreateFrame(panel
->win
);
187 WMResizeWidget(panel
->frame
, FRAME_WIDTH
, FRAME_HEIGHT
);
188 WMMoveWidget(panel
->frame
, FRAME_LEFT
, FRAME_TOP
);
190 /*********** Icon Slide Speed **********/
192 panel
->icoF
= WMCreateFrame(panel
->frame
);
193 WMResizeWidget(panel
->icoF
, 230, 55);
194 WMMoveWidget(panel
->icoF
, 15, 10);
195 WMSetFrameTitle(panel
->icoF
, _("Icon Slide Speed"));
197 /*********** Shade Animation Speed **********/
198 panel
->shaF
= WMCreateFrame(panel
->frame
);
199 WMResizeWidget(panel
->shaF
, 230, 55);
200 WMMoveWidget(panel
->shaF
, 15, 70);
201 WMSetFrameTitle(panel
->shaF
, _("Shade Animation Speed"));
204 buf1
= wmalloc(strlen(SPEED_IMAGE
)+1);
205 buf2
= wmalloc(strlen(SPEED_IMAGE_S
)+1);
207 for (i
= 0; i
< 5; i
++) {
208 panel
->icoB
[i
] = WMCreateCustomButton(panel
->icoF
, WBBStateChangeMask
);
209 panel
->shaB
[i
] = WMCreateCustomButton(panel
->shaF
, WBBStateChangeMask
);
210 WMResizeWidget(panel
->icoB
[i
], 40, 35);
211 WMMoveWidget(panel
->icoB
[i
], 10+(40*i
), 15);
212 WMResizeWidget(panel
->shaB
[i
], 40, 35);
213 WMMoveWidget(panel
->shaB
[i
], 10+(40*i
), 15);
214 WMSetButtonBordered(panel
->icoB
[i
], False
);
215 WMSetButtonImagePosition(panel
->icoB
[i
], WIPImageOnly
);
217 WMGroupButtons(panel
->icoB
[0], panel
->icoB
[i
]);
219 WMSetButtonBordered(panel
->shaB
[i
], False
);
220 WMSetButtonImagePosition(panel
->shaB
[i
], WIPImageOnly
);
222 WMGroupButtons(panel
->shaB
[0], panel
->shaB
[i
]);
224 sprintf(buf1
, SPEED_IMAGE
, i
);
225 sprintf(buf2
, SPEED_IMAGE_S
, i
);
226 path
= LocateImage(buf1
);
228 icon
= WMCreatePixmapFromFile(scr
, path
);
230 WMSetButtonImage(panel
->icoB
[i
], icon
);
231 WMSetButtonImage(panel
->shaB
[i
], icon
);
232 WMReleasePixmap(icon
);
234 wwarning(_("could not load icon file %s"), path
);
238 path
= LocateImage(buf2
);
240 icon
= WMCreatePixmapFromFile(scr
, path
);
242 WMSetButtonAltImage(panel
->icoB
[i
], icon
);
243 WMSetButtonAltImage(panel
->shaB
[i
], icon
);
244 WMReleasePixmap(icon
);
246 wwarning(_("could not load icon file %s"), path
);
255 WMMapSubwidgets(panel
->icoF
);
256 WMMapSubwidgets(panel
->shaF
);
258 /***************** Titlebar Style Size ****************/
259 panel
->titlF
= WMCreateFrame(panel
->frame
);
260 WMResizeWidget(panel
->titlF
, 230, 95);
261 WMMoveWidget(panel
->titlF
, 15, 130);
262 WMSetFrameTitle(panel
->titlF
, _("Titlebar Style"));
264 panel
->newsB
= WMCreateButton(panel
->titlF
, WBTOnOff
);
265 WMResizeWidget(panel
->newsB
, 90, 60);
266 WMMoveWidget(panel
->newsB
, 25, 20);
267 WMSetButtonImagePosition(panel
->newsB
, WIPImageOnly
);
268 path
= LocateImage(NEWS_IMAGE
);
270 icon
= WMCreatePixmapFromFile(scr
, path
);
272 WMSetButtonImage(panel
->newsB
, icon
);
273 WMReleasePixmap(icon
);
277 panel
->oldsB
= WMCreateButton(panel
->titlF
, WBTOnOff
);
278 WMResizeWidget(panel
->oldsB
, 90, 60);
279 WMMoveWidget(panel
->oldsB
, 115, 20);
280 WMSetButtonImagePosition(panel
->oldsB
, WIPImageOnly
);
281 path
= LocateImage(OLDS_IMAGE
);
283 icon
= WMCreatePixmapFromFile(scr
, path
);
285 WMSetButtonImage(panel
->oldsB
, icon
);
286 WMReleasePixmap(icon
);
290 WMGroupButtons(panel
->newsB
, panel
->oldsB
);
292 WMMapSubwidgets(panel
->titlF
);
294 /**************** Features ******************/
296 panel
->animF
= WMCreateFrame(panel
->frame
);
297 WMResizeWidget(panel
->animF
, 255, 115);
298 WMMoveWidget(panel
->animF
, 255, 10);
299 WMSetFrameTitle(panel
->animF
, _("Animations and Sound"));
301 panel
->animB
= WMCreateButton(panel
->animF
, WBTToggle
);
302 WMResizeWidget(panel
->animB
, 64, 64);
303 WMMoveWidget(panel
->animB
, 15, 20);
304 WMSetButtonFont(panel
->animB
, font
);
305 WMSetButtonText(panel
->animB
, _("Animations"));
306 WMSetButtonImagePosition(panel
->animB
, WIPAbove
);
307 createImages(scr
, rc
, xis
, ANIM_IMAGE
, &altIcon
, &icon
);
309 WMSetButtonImage(panel
->animB
, icon
);
310 WMReleasePixmap(icon
);
313 WMSetButtonAltImage(panel
->animB
, altIcon
);
314 WMReleasePixmap(altIcon
);
317 panel
->supB
= WMCreateButton(panel
->animF
, WBTToggle
);
318 WMResizeWidget(panel
->supB
, 64, 64);
319 WMMoveWidget(panel
->supB
, 95, 20);
320 WMSetButtonFont(panel
->supB
, font
);
321 WMSetButtonText(panel
->supB
, _("Superfluous"));
322 WMSetButtonImagePosition(panel
->supB
, WIPAbove
);
323 createImages(scr
, rc
, xis
, SUPERF_IMAGE
, &altIcon
, &icon
);
325 WMSetButtonImage(panel
->supB
, icon
);
326 WMReleasePixmap(icon
);
329 WMSetButtonAltImage(panel
->supB
, altIcon
);
330 WMReleasePixmap(altIcon
);
333 panel
->sfxB
= WMCreateButton(panel
->animF
, WBTToggle
);
334 WMResizeWidget(panel
->sfxB
, 64, 64);
335 WMMoveWidget(panel
->sfxB
, 175, 20);
336 WMSetButtonFont(panel
->sfxB
, font
);
337 WMSetButtonText(panel
->sfxB
, _("Sounds"));
338 WMSetButtonImagePosition(panel
->sfxB
, WIPAbove
);
339 createImages(scr
, rc
, xis
, SOUND_IMAGE
, &altIcon
, &icon
);
341 WMSetButtonImage(panel
->sfxB
, icon
);
342 WMReleasePixmap(icon
);
345 WMSetButtonAltImage(panel
->sfxB
, altIcon
);
346 WMReleasePixmap(altIcon
);
350 panel
->noteL
= WMCreateLabel(panel
->animF
);
351 WMResizeWidget(panel
->noteL
, 235, 28);
352 WMMoveWidget(panel
->noteL
, 10, 85);
353 WMSetLabelFont(panel
->noteL
, font
);
354 WMSetLabelText(panel
->noteL
, _("Note: sound requires a module distributed separately"));
356 WMMapSubwidgets(panel
->animF
);
358 /*********** Dithering **********/
361 panel
->dithF
= WMCreateFrame(panel
->frame
);
362 WMResizeWidget(panel
->dithF
, 255, 95);
363 WMMoveWidget(panel
->dithF
, 255, 130);
364 WMSetFrameTitle(panel
->dithF
, _("Dithering colormap for 8bpp"));
366 panel
->dithB
= WMCreateSwitchButton(panel
->dithF
);
367 WMResizeWidget(panel
->dithB
, 235, 32);
368 WMMoveWidget(panel
->dithB
, 15, 15);
369 WMSetButtonText(panel
->dithB
, _("Disable dithering in any visual/depth"));
371 panel
->dithL
= WMCreateLabel(panel
->dithF
);
372 WMResizeWidget(panel
->dithL
, 75, 16);
373 WMMoveWidget(panel
->dithL
, 90, 50);
374 WMSetLabelTextAlignment(panel
->dithL
, WACenter
);
375 WMSetLabelText(panel
->dithL
, "64");
377 panel
->dithS
= WMCreateSlider(panel
->dithF
);
378 WMResizeWidget(panel
->dithS
, 95, 16);
379 WMMoveWidget(panel
->dithS
, 80, 65);
380 WMSetSliderMinValue(panel
->dithS
, 2);
381 WMSetSliderMaxValue(panel
->dithS
, 6);
382 WMSetSliderContinuous(panel
->dithS
, True
);
383 WMSetSliderAction(panel
->dithS
, updateLabel
, panel
);
385 panel
->dith1L
= WMCreateLabel(panel
->dithF
);
386 WMResizeWidget(panel
->dith1L
, 70, 35);
387 WMMoveWidget(panel
->dith1L
, 5, 50);
388 WMSetLabelTextAlignment(panel
->dith1L
, WACenter
);
389 WMSetLabelFont(panel
->dith1L
, font
);
390 WMSetLabelText(panel
->dith1L
, _("More colors for applications"));
392 panel
->dith2L
= WMCreateLabel(panel
->dithF
);
393 WMResizeWidget(panel
->dith2L
, 70, 35);
394 WMMoveWidget(panel
->dith2L
, 180, 50);
395 WMSetLabelTextAlignment(panel
->dith2L
, WACenter
);
396 WMSetLabelFont(panel
->dith2L
, font
);
397 WMSetLabelText(panel
->dith2L
, _("More colors for WindowMaker"));
399 WMMapSubwidgets(panel
->dithF
);
401 WMRealizeWidget(panel
->frame
);
402 WMMapSubwidgets(panel
->frame
);
413 storeData(_Panel
*panel
)
417 for (i
=0; i
<5; i
++) {
418 if (WMGetButtonSelected(panel
->icoB
[i
]))
421 SetSpeedForKey(i
, "IconSlideSpeed");
424 for (i
=0; i
<5; i
++) {
425 if (WMGetButtonSelected(panel
->shaB
[i
]))
428 SetSpeedForKey(i
, "ShadeSpeed");
430 SetBoolForKey(WMGetButtonSelected(panel
->newsB
), "NewStyle");
432 SetBoolForKey(!WMGetButtonSelected(panel
->animB
), "DisableAnimations");
433 SetBoolForKey(WMGetButtonSelected(panel
->supB
), "Superfluous");
434 SetBoolForKey(!WMGetButtonSelected(panel
->sfxB
), "DisableSound");
436 SetBoolForKey(WMGetButtonSelected(panel
->dithB
), "DisableDithering");
437 SetIntegerForKey(WMGetSliderValue(panel
->dithS
), "ColormapSize");
443 InitConfigurations(WMScreen
*scr
, WMWindow
*win
)
447 panel
= wmalloc(sizeof(_Panel
));
448 memset(panel
, 0, sizeof(_Panel
));
450 panel
->sectionName
= _("Other Configurations");
454 panel
->callbacks
.createWidgets
= createPanel
;
455 panel
->callbacks
.updateDomain
= storeData
;
457 AddSection(panel
, ICON_FILE
);