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 NEXT_IMAGE "nextstyle"
68 #define ANIM_IMAGE "animations"
69 #define SUPERF_IMAGE "moreanim"
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
)
81 WMPerformButtonClick(panel
->icoB
[GetSpeedForKey("IconSlideSpeed")]);
82 WMPerformButtonClick(panel
->shaB
[GetSpeedForKey("ShadeSpeed")]);
84 str
= GetStringForKey("Newstyle");
85 if (str
&& strcasecmp(str
, "next") == 0) {
86 WMPerformButtonClick(panel
->nextB
);
87 } else if (str
&& strcasecmp(str
, "old") == 0) {
88 WMPerformButtonClick(panel
->oldsB
);
90 WMPerformButtonClick(panel
->newsB
);
93 WMSetButtonSelected(panel
->animB
, !GetBoolForKey("DisableAnimations"));
94 WMSetButtonSelected(panel
->supB
, GetBoolForKey("Superfluous"));
95 WMSetButtonSelected(panel
->smoB
, GetBoolForKey("SmoothWorkspaceBack"));
96 WMSetButtonSelected(panel
->dithB
, GetBoolForKey("DisableDithering"));
97 WMSetSliderValue(panel
->dithS
, GetIntegerForKey("ColormapSize"));
98 updateLabel(panel
->dithS
, panel
);
101 static void updateLabel(WMWidget
*self
, void *data
)
103 WMSlider
*sPtr
= (WMSlider
*) self
;
104 _Panel
*panel
= (_Panel
*) data
;
108 fl
= WMGetSliderValue(sPtr
);
109 panel
->cmapSize
= (int)fl
;
111 sprintf(buffer
, "%i", panel
->cmapSize
* panel
->cmapSize
* panel
->cmapSize
);
112 WMSetLabelText(panel
->dithL
, buffer
);
116 createImages(WMScreen
*scr
, RContext
*rc
, RImage
*xis
, char *file
,
117 WMPixmap
**icon1
, WMPixmap
**icon2
)
121 RColor gray
= { 0xae, 0xaa, 0xae, 0 };
126 path
= LocateImage(file
);
130 *icon1
= WMCreatePixmapFromFile(scr
, path
);
132 wwarning(_("could not load icon %s"), path
);
136 icon
= RLoadImage(rc
, path
, 0);
138 wwarning(_("could not load icon %s"), path
);
142 RCombineImageWithColor(icon
, &gray
);
144 RCombineImagesWithOpaqueness(icon
, xis
, 180);
145 if (!(*icon2
= WMCreatePixmapFromRImage(scr
, icon
, 127)))
146 wwarning(_("could not process icon %s: %s"), file
, RMessageForError(RErrorCode
));
152 static void createPanel(Panel
*p
)
154 _Panel
*panel
= (_Panel
*) p
;
155 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
157 WMPixmap
*icon
, *altIcon
;
160 RContext
*rc
= WMScreenRContext(scr
);
161 WMFont
*font
= WMSystemFontOfSize(scr
, 10);
164 path
= LocateImage(ARQUIVO_XIS
);
166 xis
= RLoadImage(rc
, path
, 0);
168 wwarning(_("could not load image file %s"), path
);
172 panel
->box
= WMCreateBox(panel
->parent
);
173 WMSetViewExpandsToParent(WMWidgetView(panel
->box
), 2, 2, 2, 2);
175 /*********** Icon Slide Speed **********/
176 panel
->icoF
= WMCreateFrame(panel
->box
);
177 WMResizeWidget(panel
->icoF
, 230, 45);
178 WMMoveWidget(panel
->icoF
, 15, 10);
179 WMSetFrameTitle(panel
->icoF
, _("Icon Slide Speed"));
181 /*********** Shade Animation Speed **********/
182 panel
->shaF
= WMCreateFrame(panel
->box
);
183 WMResizeWidget(panel
->shaF
, 230, 45);
184 WMMoveWidget(panel
->shaF
, 15, 60);
185 WMSetFrameTitle(panel
->shaF
, _("Shade Animation Speed"));
187 buf1
= wmalloc(strlen(SPEED_IMAGE
) + 1);
188 buf2
= wmalloc(strlen(SPEED_IMAGE_S
) + 1);
190 for (i
= 0; i
< 5; i
++) {
191 panel
->icoB
[i
] = WMCreateCustomButton(panel
->icoF
, WBBStateChangeMask
);
192 panel
->shaB
[i
] = WMCreateCustomButton(panel
->shaF
, WBBStateChangeMask
);
193 WMResizeWidget(panel
->icoB
[i
], 40, 24);
194 WMMoveWidget(panel
->icoB
[i
], 10 + (40 * i
), 15);
195 WMResizeWidget(panel
->shaB
[i
], 40, 24);
196 WMMoveWidget(panel
->shaB
[i
], 10 + (40 * i
), 15);
197 WMSetButtonBordered(panel
->icoB
[i
], False
);
198 WMSetButtonImagePosition(panel
->icoB
[i
], WIPImageOnly
);
200 WMGroupButtons(panel
->icoB
[0], panel
->icoB
[i
]);
202 WMSetButtonBordered(panel
->shaB
[i
], False
);
203 WMSetButtonImagePosition(panel
->shaB
[i
], WIPImageOnly
);
205 WMGroupButtons(panel
->shaB
[0], panel
->shaB
[i
]);
207 sprintf(buf1
, SPEED_IMAGE
, i
);
208 sprintf(buf2
, SPEED_IMAGE_S
, i
);
209 path
= LocateImage(buf1
);
211 icon
= WMCreatePixmapFromFile(scr
, path
);
213 WMSetButtonImage(panel
->icoB
[i
], icon
);
214 WMSetButtonImage(panel
->shaB
[i
], icon
);
215 WMReleasePixmap(icon
);
217 wwarning(_("could not load icon file %s"), path
);
221 path
= LocateImage(buf2
);
223 icon
= WMCreatePixmapFromFile(scr
, path
);
225 WMSetButtonAltImage(panel
->icoB
[i
], icon
);
226 WMSetButtonAltImage(panel
->shaB
[i
], icon
);
227 WMReleasePixmap(icon
);
229 wwarning(_("could not load icon file %s"), path
);
237 WMMapSubwidgets(panel
->icoF
);
238 WMMapSubwidgets(panel
->shaF
);
240 /***************** Smoothed Scaling *****************/
241 panel
->smoF
= WMCreateFrame(panel
->box
);
242 WMResizeWidget(panel
->smoF
, 115, 110);
243 WMMoveWidget(panel
->smoF
, 18, 115);
244 WMSetFrameTitle(panel
->smoF
, _("Smooth Scaling"));
245 WMSetBalloonTextForView(_("Smooth scaled background images, neutralizing\n"
246 "the `pixelization' effect. This will slow\n"
247 "down loading of background images considerably."), WMWidgetView(panel
->smoF
));
249 panel
->smoB
= WMCreateButton(panel
->smoF
, WBTToggle
);
250 WMResizeWidget(panel
->smoB
, 64, 64);
251 WMMoveWidget(panel
->smoB
, 25, 25);
252 WMSetButtonImagePosition(panel
->smoB
, WIPImageOnly
);
253 path
= LocateImage(SMOOTH_IMAGE
);
255 RImage
*image
, *scaled
;
257 image
= RLoadImage(WMScreenRContext(scr
), path
, 0);
260 scaled
= RScaleImage(image
, 61, 61);
261 icon
= WMCreatePixmapFromRImage(scr
, scaled
, 128);
262 RReleaseImage(scaled
);
264 WMSetButtonImage(panel
->smoB
, icon
);
265 WMReleasePixmap(icon
);
268 scaled
= RSmoothScaleImage(image
, 61, 61);
269 icon
= WMCreatePixmapFromRImage(scr
, scaled
, 128);
270 RReleaseImage(scaled
);
272 WMSetButtonAltImage(panel
->smoB
, icon
);
273 WMReleasePixmap(icon
);
276 RReleaseImage(image
);
279 WMMapSubwidgets(panel
->smoF
);
281 /***************** Titlebar Style Size ****************/
282 panel
->titlF
= WMCreateFrame(panel
->box
);
283 WMResizeWidget(panel
->titlF
, 105, 110);
284 WMMoveWidget(panel
->titlF
, 140, 115);
285 WMSetFrameTitle(panel
->titlF
, _("Titlebar Style"));
287 panel
->newsB
= WMCreateButton(panel
->titlF
, WBTOnOff
);
288 WMResizeWidget(panel
->newsB
, 74, 40);
289 WMMoveWidget(panel
->newsB
, 15, 20);
290 WMSetButtonImagePosition(panel
->newsB
, WIPImageOnly
);
291 path
= LocateImage(NEWS_IMAGE
);
293 icon
= WMCreatePixmapFromFile(scr
, path
);
295 WMSetButtonImage(panel
->newsB
, icon
);
296 WMReleasePixmap(icon
);
301 panel
->oldsB
= WMCreateButton(panel
->titlF
, WBTOnOff
);
302 WMResizeWidget(panel
->oldsB
, 37, 40);
303 WMMoveWidget(panel
->oldsB
, 15, 60);
304 WMSetButtonImagePosition(panel
->oldsB
, WIPImageOnly
);
305 path
= LocateImage(OLDS_IMAGE
);
307 icon
= WMCreatePixmapFromFile(scr
, path
);
309 WMSetButtonImage(panel
->oldsB
, icon
);
310 WMReleasePixmap(icon
);
315 panel
->nextB
= WMCreateButton(panel
->titlF
, WBTOnOff
);
316 WMResizeWidget(panel
->nextB
, 37, 40);
317 WMMoveWidget(panel
->nextB
, 52, 60);
318 WMSetButtonImagePosition(panel
->nextB
, WIPImageOnly
);
319 path
= LocateImage(NEXT_IMAGE
);
321 icon
= WMCreatePixmapFromFile(scr
, path
);
323 WMSetButtonImage(panel
->nextB
, icon
);
324 WMReleasePixmap(icon
);
329 WMGroupButtons(panel
->newsB
, panel
->oldsB
);
330 WMGroupButtons(panel
->newsB
, panel
->nextB
);
332 WMMapSubwidgets(panel
->titlF
);
334 /**************** Features ******************/
335 panel
->animF
= WMCreateFrame(panel
->box
);
336 WMResizeWidget(panel
->animF
, 255, 115);
337 WMMoveWidget(panel
->animF
, 255, 10);
338 WMSetFrameTitle(panel
->animF
, _("Animations"));
340 panel
->animB
= WMCreateButton(panel
->animF
, WBTToggle
);
341 WMResizeWidget(panel
->animB
, 64, 64);
342 WMMoveWidget(panel
->animB
, 15, 20);
343 WMSetButtonFont(panel
->animB
, font
);
344 WMSetButtonText(panel
->animB
, _("Animations"));
345 WMSetButtonImagePosition(panel
->animB
, WIPAbove
);
346 createImages(scr
, rc
, xis
, ANIM_IMAGE
, &altIcon
, &icon
);
348 WMSetButtonImage(panel
->animB
, icon
);
349 WMReleasePixmap(icon
);
352 WMSetButtonAltImage(panel
->animB
, altIcon
);
353 WMReleasePixmap(altIcon
);
355 WMSetBalloonTextForView(_("Disable/enable animations such as those shown\n"
356 "for window miniaturization, shading etc."), WMWidgetView(panel
->animB
));
358 panel
->supB
= WMCreateButton(panel
->animF
, WBTToggle
);
359 WMResizeWidget(panel
->supB
, 64, 64);
360 WMMoveWidget(panel
->supB
, 95, 20);
361 WMSetButtonFont(panel
->supB
, font
);
362 WMSetButtonText(panel
->supB
, _("Superfluous"));
363 WMSetButtonImagePosition(panel
->supB
, WIPAbove
);
364 createImages(scr
, rc
, xis
, SUPERF_IMAGE
, &altIcon
, &icon
);
366 WMSetButtonImage(panel
->supB
, icon
);
367 WMReleasePixmap(icon
);
370 WMSetButtonAltImage(panel
->supB
, altIcon
);
371 WMReleasePixmap(altIcon
);
373 WMSetBalloonTextForView(_("Disable/enable `superfluous' features and\n"
374 "animations. These include the `ghosting' of the\n"
375 "dock when it's being moved to another side and\n"
376 "the explosion animation when undocking icons."), WMWidgetView(panel
->supB
));
378 WMMapSubwidgets(panel
->animF
);
380 /*********** Dithering **********/
383 panel
->dithF
= WMCreateFrame(panel
->box
);
384 WMResizeWidget(panel
->dithF
, 255, 95);
385 WMMoveWidget(panel
->dithF
, 255, 130);
386 WMSetFrameTitle(panel
->dithF
, _("Dithering colormap for 8bpp"));
388 WMSetBalloonTextForView(_("Number of colors to reserve for Window Maker\n"
389 "on displays that support only 8bpp (PseudoColor)."),
390 WMWidgetView(panel
->dithF
));
392 panel
->dithB
= WMCreateSwitchButton(panel
->dithF
);
393 WMResizeWidget(panel
->dithB
, 235, 32);
394 WMMoveWidget(panel
->dithB
, 15, 15);
395 WMSetButtonText(panel
->dithB
, _("Disable dithering in any visual/depth"));
397 panel
->dithL
= WMCreateLabel(panel
->dithF
);
398 WMResizeWidget(panel
->dithL
, 75, 16);
399 WMMoveWidget(panel
->dithL
, 90, 50);
400 WMSetLabelTextAlignment(panel
->dithL
, WACenter
);
401 WMSetLabelText(panel
->dithL
, "64");
403 panel
->dithS
= WMCreateSlider(panel
->dithF
);
404 WMResizeWidget(panel
->dithS
, 95, 16);
405 WMMoveWidget(panel
->dithS
, 80, 65);
406 WMSetSliderMinValue(panel
->dithS
, 2);
407 WMSetSliderMaxValue(panel
->dithS
, 6);
408 WMSetSliderContinuous(panel
->dithS
, True
);
409 WMSetSliderAction(panel
->dithS
, updateLabel
, panel
);
411 panel
->dith1L
= WMCreateLabel(panel
->dithF
);
412 WMResizeWidget(panel
->dith1L
, 70, 35);
413 WMMoveWidget(panel
->dith1L
, 5, 50);
414 WMSetLabelTextAlignment(panel
->dith1L
, WACenter
);
415 WMSetLabelFont(panel
->dith1L
, font
);
416 WMSetLabelText(panel
->dith1L
, _("More colors for\napplications"));
418 panel
->dith2L
= WMCreateLabel(panel
->dithF
);
419 WMResizeWidget(panel
->dith2L
, 70, 35);
420 WMMoveWidget(panel
->dith2L
, 180, 50);
421 WMSetLabelTextAlignment(panel
->dith2L
, WACenter
);
422 WMSetLabelFont(panel
->dith2L
, font
);
423 WMSetLabelText(panel
->dith2L
, _("More colors for\nWindow Maker"));
425 WMMapSubwidgets(panel
->dithF
);
427 WMRealizeWidget(panel
->box
);
428 WMMapSubwidgets(panel
->box
);
436 static void storeData(_Panel
*panel
)
440 for (i
= 0; i
< 5; i
++) {
441 if (WMGetButtonSelected(panel
->icoB
[i
]))
444 SetSpeedForKey(i
, "IconSlideSpeed");
446 for (i
= 0; i
< 5; i
++) {
447 if (WMGetButtonSelected(panel
->shaB
[i
]))
450 SetSpeedForKey(i
, "ShadeSpeed");
452 if (WMGetButtonSelected(panel
->newsB
)) {
453 SetStringForKey("new", "NewStyle");
454 } else if (WMGetButtonSelected(panel
->oldsB
)) {
455 SetStringForKey("old", "NewStyle");
457 SetStringForKey("next", "NewStyle");
459 SetBoolForKey(!WMGetButtonSelected(panel
->animB
), "DisableAnimations");
460 SetBoolForKey(WMGetButtonSelected(panel
->supB
), "Superfluous");
461 SetBoolForKey(WMGetButtonSelected(panel
->smoB
), "SmoothWorkspaceBack");
462 SetBoolForKey(WMGetButtonSelected(panel
->dithB
), "DisableDithering");
463 SetIntegerForKey(WMGetSliderValue(panel
->dithS
), "ColormapSize");
466 Panel
*InitConfigurations(WMScreen
*scr
, WMWidget
*parent
)
470 panel
= wmalloc(sizeof(_Panel
));
471 memset(panel
, 0, sizeof(_Panel
));
473 panel
->sectionName
= _("Other Configurations");
474 panel
->description
= _("Animation speeds, titlebar styles, various option\n"
475 "toggling and number of colors to reserve for\n" "Window Maker on 8bit displays.");
477 panel
->parent
= parent
;
478 panel
->callbacks
.createWidgets
= createPanel
;
479 panel
->callbacks
.updateDomain
= storeData
;
481 AddSection(panel
, ICON_FILE
);