1 /* Configurations.c- misc. configurations
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
{
31 CallbackRec callbacks
;
64 #define ICON_FILE "configs"
65 #define OLDS_IMAGE "oldstyle"
66 #define NEWS_IMAGE "newstyle"
67 #define ANIM_IMAGE "animations"
68 #define SUPERF_IMAGE "moreanim"
69 #define SOUND_IMAGE "sound"
70 #define SMOOTH_IMAGE "smooth"
71 #define SPEED_IMAGE "speed%i"
72 #define SPEED_IMAGE_S "speed%is"
73 #define ARQUIVO_XIS "xis"
75 static void updateLabel(WMWidget
*self
, void *data
);
77 static void showData(_Panel
*panel
)
79 WMPerformButtonClick(panel
->icoB
[GetSpeedForKey("IconSlideSpeed")]);
80 WMPerformButtonClick(panel
->shaB
[GetSpeedForKey("ShadeSpeed")]);
82 if (GetBoolForKey("NewStyle"))
83 WMPerformButtonClick(panel
->newsB
);
85 WMPerformButtonClick(panel
->oldsB
);
87 WMSetButtonSelected(panel
->animB
, !GetBoolForKey("DisableAnimations"));
88 WMSetButtonSelected(panel
->supB
, GetBoolForKey("Superfluous"));
89 WMSetButtonSelected(panel
->sfxB
, !GetBoolForKey("DisableSound"));
90 WMSetButtonSelected(panel
->smoB
, GetBoolForKey("SmoothWorkspaceBack"));
91 WMSetButtonSelected(panel
->dithB
, GetBoolForKey("DisableDithering"));
92 WMSetSliderValue(panel
->dithS
, GetIntegerForKey("ColormapSize"));
93 updateLabel(panel
->dithS
, panel
);
96 static void updateLabel(WMWidget
*self
, void *data
)
98 WMSlider
*sPtr
= (WMSlider
*) self
;
99 _Panel
*panel
= (_Panel
*) data
;
103 fl
= WMGetSliderValue(sPtr
);
104 panel
->cmapSize
= (int)fl
;
106 sprintf(buffer
, "%i", panel
->cmapSize
* panel
->cmapSize
* panel
->cmapSize
);
107 WMSetLabelText(panel
->dithL
, buffer
);
111 createImages(WMScreen
*scr
, RContext
*rc
, RImage
*xis
, char *file
,
112 WMPixmap
**icon1
, WMPixmap
**icon2
)
116 RColor gray
= { 0xae, 0xaa, 0xae };
121 path
= LocateImage(file
);
125 *icon1
= WMCreatePixmapFromFile(scr
, path
);
127 wwarning(_("could not load icon %s"), path
);
131 icon
= RLoadImage(rc
, path
, 0);
133 wwarning(_("could not load icon %s"), path
);
137 RCombineImageWithColor(icon
, &gray
);
139 RCombineImagesWithOpaqueness(icon
, xis
, 180);
140 if (!(*icon2
= WMCreatePixmapFromRImage(scr
, icon
, 127)))
141 wwarning(_("could not process icon %s:"), file
, RMessageForError(RErrorCode
));
147 static void createPanel(Panel
*p
)
149 _Panel
*panel
= (_Panel
*) p
;
150 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
152 WMPixmap
*icon
, *altIcon
;
155 RContext
*rc
= WMScreenRContext(scr
);
156 WMFont
*font
= WMSystemFontOfSize(scr
, 10);
159 path
= LocateImage(ARQUIVO_XIS
);
161 xis
= RLoadImage(rc
, path
, 0);
163 wwarning(_("could not load image file %s"), path
);
167 panel
->box
= WMCreateBox(panel
->parent
);
168 WMSetViewExpandsToParent(WMWidgetView(panel
->box
), 2, 2, 2, 2);
170 /*********** Icon Slide Speed **********/
171 panel
->icoF
= WMCreateFrame(panel
->box
);
172 WMResizeWidget(panel
->icoF
, 230, 45);
173 WMMoveWidget(panel
->icoF
, 15, 10);
174 WMSetFrameTitle(panel
->icoF
, _("Icon Slide Speed"));
176 /*********** Shade Animation Speed **********/
177 panel
->shaF
= WMCreateFrame(panel
->box
);
178 WMResizeWidget(panel
->shaF
, 230, 45);
179 WMMoveWidget(panel
->shaF
, 15, 60);
180 WMSetFrameTitle(panel
->shaF
, _("Shade Animation Speed"));
182 buf1
= wmalloc(strlen(SPEED_IMAGE
) + 1);
183 buf2
= wmalloc(strlen(SPEED_IMAGE_S
) + 1);
185 for (i
= 0; i
< 5; i
++) {
186 panel
->icoB
[i
] = WMCreateCustomButton(panel
->icoF
, WBBStateChangeMask
);
187 panel
->shaB
[i
] = WMCreateCustomButton(panel
->shaF
, WBBStateChangeMask
);
188 WMResizeWidget(panel
->icoB
[i
], 40, 24);
189 WMMoveWidget(panel
->icoB
[i
], 10 + (40 * i
), 15);
190 WMResizeWidget(panel
->shaB
[i
], 40, 24);
191 WMMoveWidget(panel
->shaB
[i
], 10 + (40 * i
), 15);
192 WMSetButtonBordered(panel
->icoB
[i
], False
);
193 WMSetButtonImagePosition(panel
->icoB
[i
], WIPImageOnly
);
195 WMGroupButtons(panel
->icoB
[0], panel
->icoB
[i
]);
197 WMSetButtonBordered(panel
->shaB
[i
], False
);
198 WMSetButtonImagePosition(panel
->shaB
[i
], WIPImageOnly
);
200 WMGroupButtons(panel
->shaB
[0], panel
->shaB
[i
]);
202 sprintf(buf1
, SPEED_IMAGE
, i
);
203 sprintf(buf2
, SPEED_IMAGE_S
, i
);
204 path
= LocateImage(buf1
);
206 icon
= WMCreatePixmapFromFile(scr
, path
);
208 WMSetButtonImage(panel
->icoB
[i
], icon
);
209 WMSetButtonImage(panel
->shaB
[i
], icon
);
210 WMReleasePixmap(icon
);
212 wwarning(_("could not load icon file %s"), path
);
216 path
= LocateImage(buf2
);
218 icon
= WMCreatePixmapFromFile(scr
, path
);
220 WMSetButtonAltImage(panel
->icoB
[i
], icon
);
221 WMSetButtonAltImage(panel
->shaB
[i
], icon
);
222 WMReleasePixmap(icon
);
224 wwarning(_("could not load icon file %s"), path
);
232 WMMapSubwidgets(panel
->icoF
);
233 WMMapSubwidgets(panel
->shaF
);
235 /***************** Smoothed Scaling *****************/
236 panel
->smoF
= WMCreateFrame(panel
->box
);
237 WMResizeWidget(panel
->smoF
, 115, 110);
238 WMMoveWidget(panel
->smoF
, 18, 115);
239 WMSetFrameTitle(panel
->smoF
, _("Smooth Scaling"));
240 WMSetBalloonTextForView(_("Smooth scaled background images, neutralizing\n"
241 "the `pixelization' effect. This will slow\n"
242 "down loading of background images considerably."), WMWidgetView(panel
->smoF
));
244 panel
->smoB
= WMCreateButton(panel
->smoF
, WBTToggle
);
245 WMResizeWidget(panel
->smoB
, 64, 64);
246 WMMoveWidget(panel
->smoB
, 25, 25);
247 WMSetButtonImagePosition(panel
->smoB
, WIPImageOnly
);
248 path
= LocateImage(SMOOTH_IMAGE
);
250 RImage
*image
, *scaled
;
252 image
= RLoadImage(WMScreenRContext(scr
), path
, 0);
255 scaled
= RScaleImage(image
, 61, 61);
256 icon
= WMCreatePixmapFromRImage(scr
, scaled
, 128);
257 RReleaseImage(scaled
);
259 WMSetButtonImage(panel
->smoB
, icon
);
260 WMReleasePixmap(icon
);
263 scaled
= RSmoothScaleImage(image
, 61, 61);
264 icon
= WMCreatePixmapFromRImage(scr
, scaled
, 128);
265 RReleaseImage(scaled
);
267 WMSetButtonAltImage(panel
->smoB
, icon
);
268 WMReleasePixmap(icon
);
271 RReleaseImage(image
);
274 WMMapSubwidgets(panel
->smoF
);
276 /***************** Titlebar Style Size ****************/
277 panel
->titlF
= WMCreateFrame(panel
->box
);
278 WMResizeWidget(panel
->titlF
, 105, 110);
279 WMMoveWidget(panel
->titlF
, 140, 115);
280 WMSetFrameTitle(panel
->titlF
, _("Titlebar Style"));
282 panel
->newsB
= WMCreateButton(panel
->titlF
, WBTOnOff
);
283 WMResizeWidget(panel
->newsB
, 74, 40);
284 WMMoveWidget(panel
->newsB
, 15, 20);
285 WMSetButtonImagePosition(panel
->newsB
, WIPImageOnly
);
286 path
= LocateImage(NEWS_IMAGE
);
288 icon
= WMCreatePixmapFromFile(scr
, path
);
290 WMSetButtonImage(panel
->newsB
, icon
);
291 WMReleasePixmap(icon
);
295 panel
->oldsB
= WMCreateButton(panel
->titlF
, WBTOnOff
);
296 WMResizeWidget(panel
->oldsB
, 74, 40);
297 WMMoveWidget(panel
->oldsB
, 15, 60);
298 WMSetButtonImagePosition(panel
->oldsB
, WIPImageOnly
);
299 path
= LocateImage(OLDS_IMAGE
);
301 icon
= WMCreatePixmapFromFile(scr
, path
);
303 WMSetButtonImage(panel
->oldsB
, icon
);
304 WMReleasePixmap(icon
);
309 WMGroupButtons(panel
->newsB
, panel
->oldsB
);
311 WMMapSubwidgets(panel
->titlF
);
313 /**************** Features ******************/
314 panel
->animF
= WMCreateFrame(panel
->box
);
315 WMResizeWidget(panel
->animF
, 255, 115);
316 WMMoveWidget(panel
->animF
, 255, 10);
317 WMSetFrameTitle(panel
->animF
, _("Animations and Sound"));
319 panel
->animB
= WMCreateButton(panel
->animF
, WBTToggle
);
320 WMResizeWidget(panel
->animB
, 64, 64);
321 WMMoveWidget(panel
->animB
, 15, 20);
322 WMSetButtonFont(panel
->animB
, font
);
323 WMSetButtonText(panel
->animB
, _("Animations"));
324 WMSetButtonImagePosition(panel
->animB
, WIPAbove
);
325 createImages(scr
, rc
, xis
, ANIM_IMAGE
, &altIcon
, &icon
);
327 WMSetButtonImage(panel
->animB
, icon
);
328 WMReleasePixmap(icon
);
331 WMSetButtonAltImage(panel
->animB
, altIcon
);
332 WMReleasePixmap(altIcon
);
334 WMSetBalloonTextForView(_("Disable/enable animations such as those shown\n"
335 "for window miniaturization, shading etc."), WMWidgetView(panel
->animB
));
337 panel
->supB
= WMCreateButton(panel
->animF
, WBTToggle
);
338 WMResizeWidget(panel
->supB
, 64, 64);
339 WMMoveWidget(panel
->supB
, 95, 20);
340 WMSetButtonFont(panel
->supB
, font
);
341 WMSetButtonText(panel
->supB
, _("Superfluous"));
342 WMSetButtonImagePosition(panel
->supB
, WIPAbove
);
343 createImages(scr
, rc
, xis
, SUPERF_IMAGE
, &altIcon
, &icon
);
345 WMSetButtonImage(panel
->supB
, icon
);
346 WMReleasePixmap(icon
);
349 WMSetButtonAltImage(panel
->supB
, altIcon
);
350 WMReleasePixmap(altIcon
);
352 WMSetBalloonTextForView(_("Disable/enable `superfluous' features and\n"
353 "animations. These include the `ghosting' of the\n"
354 "dock when it's being moved to another side and\n"
355 "the explosion animation when undocking icons."), WMWidgetView(panel
->supB
));
357 panel
->sfxB
= WMCreateButton(panel
->animF
, WBTToggle
);
358 WMResizeWidget(panel
->sfxB
, 64, 64);
359 WMMoveWidget(panel
->sfxB
, 175, 20);
360 WMSetButtonFont(panel
->sfxB
, font
);
361 WMSetButtonText(panel
->sfxB
, _("Sounds"));
362 WMSetButtonImagePosition(panel
->sfxB
, WIPAbove
);
363 createImages(scr
, rc
, xis
, SOUND_IMAGE
, &altIcon
, &icon
);
365 WMSetButtonImage(panel
->sfxB
, icon
);
366 WMReleasePixmap(icon
);
369 WMSetButtonAltImage(panel
->sfxB
, altIcon
);
370 WMReleasePixmap(altIcon
);
372 WMSetBalloonTextForView(_("Disable/enable support for sound effects played\n"
373 "for actions like shading and closing a window.\n"
374 "You will need a module distributed separately\n"
375 "for this. You can get it at:\n"
376 "http://largo.windowmaker.info/files.php#WSoundServer"),
377 WMWidgetView(panel
->sfxB
));
379 panel
->noteL
= WMCreateLabel(panel
->animF
);
380 WMResizeWidget(panel
->noteL
, 235, 28);
381 WMMoveWidget(panel
->noteL
, 10, 85);
382 WMSetLabelFont(panel
->noteL
, font
);
383 WMSetLabelText(panel
->noteL
, _("Note: sound requires a module distributed\nseparately"));
385 WMMapSubwidgets(panel
->animF
);
387 /*********** Dithering **********/
390 panel
->dithF
= WMCreateFrame(panel
->box
);
391 WMResizeWidget(panel
->dithF
, 255, 95);
392 WMMoveWidget(panel
->dithF
, 255, 130);
393 WMSetFrameTitle(panel
->dithF
, _("Dithering colormap for 8bpp"));
395 WMSetBalloonTextForView(_("Number of colors to reserve for Window Maker\n"
396 "on displays that support only 8bpp (PseudoColor)."),
397 WMWidgetView(panel
->dithF
));
399 panel
->dithB
= WMCreateSwitchButton(panel
->dithF
);
400 WMResizeWidget(panel
->dithB
, 235, 32);
401 WMMoveWidget(panel
->dithB
, 15, 15);
402 WMSetButtonText(panel
->dithB
, _("Disable dithering in any visual/depth"));
404 panel
->dithL
= WMCreateLabel(panel
->dithF
);
405 WMResizeWidget(panel
->dithL
, 75, 16);
406 WMMoveWidget(panel
->dithL
, 90, 50);
407 WMSetLabelTextAlignment(panel
->dithL
, WACenter
);
408 WMSetLabelText(panel
->dithL
, "64");
410 panel
->dithS
= WMCreateSlider(panel
->dithF
);
411 WMResizeWidget(panel
->dithS
, 95, 16);
412 WMMoveWidget(panel
->dithS
, 80, 65);
413 WMSetSliderMinValue(panel
->dithS
, 2);
414 WMSetSliderMaxValue(panel
->dithS
, 6);
415 WMSetSliderContinuous(panel
->dithS
, True
);
416 WMSetSliderAction(panel
->dithS
, updateLabel
, panel
);
418 panel
->dith1L
= WMCreateLabel(panel
->dithF
);
419 WMResizeWidget(panel
->dith1L
, 70, 35);
420 WMMoveWidget(panel
->dith1L
, 5, 50);
421 WMSetLabelTextAlignment(panel
->dith1L
, WACenter
);
422 WMSetLabelFont(panel
->dith1L
, font
);
423 WMSetLabelText(panel
->dith1L
, _("More colors for\napplications"));
425 panel
->dith2L
= WMCreateLabel(panel
->dithF
);
426 WMResizeWidget(panel
->dith2L
, 70, 35);
427 WMMoveWidget(panel
->dith2L
, 180, 50);
428 WMSetLabelTextAlignment(panel
->dith2L
, WACenter
);
429 WMSetLabelFont(panel
->dith2L
, font
);
430 WMSetLabelText(panel
->dith2L
, _("More colors for\nWindow Maker"));
432 WMMapSubwidgets(panel
->dithF
);
434 WMRealizeWidget(panel
->box
);
435 WMMapSubwidgets(panel
->box
);
443 static void storeData(_Panel
*panel
)
447 for (i
= 0; i
< 5; i
++) {
448 if (WMGetButtonSelected(panel
->icoB
[i
]))
451 SetSpeedForKey(i
, "IconSlideSpeed");
453 for (i
= 0; i
< 5; i
++) {
454 if (WMGetButtonSelected(panel
->shaB
[i
]))
457 SetSpeedForKey(i
, "ShadeSpeed");
459 SetBoolForKey(WMGetButtonSelected(panel
->newsB
), "NewStyle");
460 SetBoolForKey(!WMGetButtonSelected(panel
->animB
), "DisableAnimations");
461 SetBoolForKey(WMGetButtonSelected(panel
->supB
), "Superfluous");
462 SetBoolForKey(!WMGetButtonSelected(panel
->sfxB
), "DisableSound");
463 SetBoolForKey(WMGetButtonSelected(panel
->smoB
), "SmoothWorkspaceBack");
464 SetBoolForKey(WMGetButtonSelected(panel
->dithB
), "DisableDithering");
465 SetIntegerForKey(WMGetSliderValue(panel
->dithS
), "ColormapSize");
468 Panel
*InitConfigurations(WMScreen
*scr
, WMWidget
*parent
)
472 panel
= wmalloc(sizeof(_Panel
));
473 memset(panel
, 0, sizeof(_Panel
));
475 panel
->sectionName
= _("Other Configurations");
476 panel
->description
= _("Animation speeds, titlebar styles, various option\n"
477 "toggling and number of colors to reserve for\n" "Window Maker on 8bit displays.");
479 panel
->parent
= parent
;
480 panel
->callbacks
.createWidgets
= createPanel
;
481 panel
->callbacks
.updateDomain
= storeData
;
483 AddSection(panel
, ICON_FILE
);