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 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
{
30 CallbackRec callbacks
;
63 #define ICON_FILE "configs"
64 #define OLDS_IMAGE "oldstyle"
65 #define NEWS_IMAGE "newstyle"
66 #define NEXT_IMAGE "nextstyle"
67 #define ANIM_IMAGE "animations"
68 #define SUPERF_IMAGE "moreanim"
69 #define SMOOTH_IMAGE "smooth"
70 #define SPEED_IMAGE "speed%i"
71 #define SPEED_IMAGE_S "speed%is"
72 #define ARQUIVO_XIS "xis"
74 static void updateLabel(WMWidget
*self
, void *data
);
76 static void showData(_Panel
*panel
)
80 WMPerformButtonClick(panel
->icoB
[GetSpeedForKey("IconSlideSpeed")]);
81 WMPerformButtonClick(panel
->shaB
[GetSpeedForKey("ShadeSpeed")]);
83 str
= GetStringForKey("NewStyle");
84 if (str
&& strcasecmp(str
, "next") == 0) {
85 WMPerformButtonClick(panel
->nextB
);
86 } else if (str
&& strcasecmp(str
, "old") == 0) {
87 WMPerformButtonClick(panel
->oldsB
);
89 WMPerformButtonClick(panel
->newsB
);
92 WMSetButtonSelected(panel
->animB
, !GetBoolForKey("DisableAnimations"));
93 WMSetButtonSelected(panel
->supB
, GetBoolForKey("Superfluous"));
94 WMSetButtonSelected(panel
->smoB
, GetBoolForKey("SmoothWorkspaceBack"));
95 WMSetButtonSelected(panel
->dithB
, GetBoolForKey("DisableDithering"));
96 WMSetSliderValue(panel
->dithS
, GetIntegerForKey("ColormapSize"));
97 updateLabel(panel
->dithS
, panel
);
100 static void updateLabel(WMWidget
*self
, void *data
)
102 WMSlider
*sPtr
= (WMSlider
*) self
;
103 _Panel
*panel
= (_Panel
*) data
;
107 fl
= WMGetSliderValue(sPtr
);
108 panel
->cmapSize
= (int)fl
;
110 sprintf(buffer
, "%i", panel
->cmapSize
* panel
->cmapSize
* panel
->cmapSize
);
111 WMSetLabelText(panel
->dithL
, buffer
);
115 createImages(WMScreen
*scr
, RContext
*rc
, RImage
*xis
, char *file
,
116 WMPixmap
**icon1
, WMPixmap
**icon2
)
120 RColor gray
= { 0xae, 0xaa, 0xae, 0 };
125 path
= LocateImage(file
);
129 *icon1
= WMCreatePixmapFromFile(scr
, path
);
131 wwarning(_("could not load icon %s"), path
);
135 icon
= RLoadImage(rc
, path
, 0);
137 wwarning(_("could not load icon %s"), path
);
141 RCombineImageWithColor(icon
, &gray
);
143 RCombineImagesWithOpaqueness(icon
, xis
, 180);
144 if (!(*icon2
= WMCreatePixmapFromRImage(scr
, icon
, 127)))
145 wwarning(_("could not process icon %s: %s"), file
, RMessageForError(RErrorCode
));
151 static void createPanel(Panel
*p
)
153 _Panel
*panel
= (_Panel
*) p
;
154 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
156 WMPixmap
*icon
, *altIcon
;
159 RContext
*rc
= WMScreenRContext(scr
);
160 WMFont
*font
= WMSystemFontOfSize(scr
, 10);
163 path
= LocateImage(ARQUIVO_XIS
);
165 xis
= RLoadImage(rc
, path
, 0);
167 wwarning(_("could not load image file %s"), path
);
171 panel
->box
= WMCreateBox(panel
->parent
);
172 WMSetViewExpandsToParent(WMWidgetView(panel
->box
), 2, 2, 2, 2);
174 /*********** Icon Slide Speed **********/
175 panel
->icoF
= WMCreateFrame(panel
->box
);
176 WMResizeWidget(panel
->icoF
, 230, 45);
177 WMMoveWidget(panel
->icoF
, 15, 10);
178 WMSetFrameTitle(panel
->icoF
, _("Icon Slide Speed"));
180 /*********** Shade Animation Speed **********/
181 panel
->shaF
= WMCreateFrame(panel
->box
);
182 WMResizeWidget(panel
->shaF
, 230, 45);
183 WMMoveWidget(panel
->shaF
, 15, 60);
184 WMSetFrameTitle(panel
->shaF
, _("Shade Animation Speed"));
186 buf1
= wmalloc(strlen(SPEED_IMAGE
) + 1);
187 buf2
= wmalloc(strlen(SPEED_IMAGE_S
) + 1);
189 for (i
= 0; i
< 5; i
++) {
190 panel
->icoB
[i
] = WMCreateCustomButton(panel
->icoF
, WBBStateChangeMask
);
191 panel
->shaB
[i
] = WMCreateCustomButton(panel
->shaF
, WBBStateChangeMask
);
192 WMResizeWidget(panel
->icoB
[i
], 40, 24);
193 WMMoveWidget(panel
->icoB
[i
], 10 + (40 * i
), 15);
194 WMResizeWidget(panel
->shaB
[i
], 40, 24);
195 WMMoveWidget(panel
->shaB
[i
], 10 + (40 * i
), 15);
196 WMSetButtonBordered(panel
->icoB
[i
], False
);
197 WMSetButtonImagePosition(panel
->icoB
[i
], WIPImageOnly
);
199 WMGroupButtons(panel
->icoB
[0], panel
->icoB
[i
]);
201 WMSetButtonBordered(panel
->shaB
[i
], False
);
202 WMSetButtonImagePosition(panel
->shaB
[i
], WIPImageOnly
);
204 WMGroupButtons(panel
->shaB
[0], panel
->shaB
[i
]);
206 sprintf(buf1
, SPEED_IMAGE
, i
);
207 sprintf(buf2
, SPEED_IMAGE_S
, i
);
208 path
= LocateImage(buf1
);
210 icon
= WMCreatePixmapFromFile(scr
, path
);
212 WMSetButtonImage(panel
->icoB
[i
], icon
);
213 WMSetButtonImage(panel
->shaB
[i
], icon
);
214 WMReleasePixmap(icon
);
216 wwarning(_("could not load icon file %s"), path
);
220 path
= LocateImage(buf2
);
222 icon
= WMCreatePixmapFromFile(scr
, path
);
224 WMSetButtonAltImage(panel
->icoB
[i
], icon
);
225 WMSetButtonAltImage(panel
->shaB
[i
], icon
);
226 WMReleasePixmap(icon
);
228 wwarning(_("could not load icon file %s"), path
);
236 WMMapSubwidgets(panel
->icoF
);
237 WMMapSubwidgets(panel
->shaF
);
239 /***************** Smoothed Scaling *****************/
240 panel
->smoF
= WMCreateFrame(panel
->box
);
241 WMResizeWidget(panel
->smoF
, 115, 110);
242 WMMoveWidget(panel
->smoF
, 18, 115);
243 WMSetFrameTitle(panel
->smoF
, _("Smooth Scaling"));
244 WMSetBalloonTextForView(_("Smooth scaled background images, neutralizing\n"
245 "the `pixelization' effect. This will slow\n"
246 "down loading of background images considerably."), WMWidgetView(panel
->smoF
));
248 panel
->smoB
= WMCreateButton(panel
->smoF
, WBTToggle
);
249 WMResizeWidget(panel
->smoB
, 64, 64);
250 WMMoveWidget(panel
->smoB
, 25, 25);
251 WMSetButtonImagePosition(panel
->smoB
, WIPImageOnly
);
252 path
= LocateImage(SMOOTH_IMAGE
);
254 RImage
*image
, *scaled
;
256 image
= RLoadImage(WMScreenRContext(scr
), path
, 0);
259 scaled
= RScaleImage(image
, 61, 61);
260 icon
= WMCreatePixmapFromRImage(scr
, scaled
, 128);
261 RReleaseImage(scaled
);
263 WMSetButtonImage(panel
->smoB
, icon
);
264 WMReleasePixmap(icon
);
267 scaled
= RSmoothScaleImage(image
, 61, 61);
268 icon
= WMCreatePixmapFromRImage(scr
, scaled
, 128);
269 RReleaseImage(scaled
);
271 WMSetButtonAltImage(panel
->smoB
, icon
);
272 WMReleasePixmap(icon
);
275 RReleaseImage(image
);
278 WMMapSubwidgets(panel
->smoF
);
280 /***************** Titlebar Style Size ****************/
281 panel
->titlF
= WMCreateFrame(panel
->box
);
282 WMResizeWidget(panel
->titlF
, 105, 110);
283 WMMoveWidget(panel
->titlF
, 140, 115);
284 WMSetFrameTitle(panel
->titlF
, _("Titlebar Style"));
286 panel
->newsB
= WMCreateButton(panel
->titlF
, WBTOnOff
);
287 WMResizeWidget(panel
->newsB
, 74, 40);
288 WMMoveWidget(panel
->newsB
, 15, 20);
289 WMSetButtonImagePosition(panel
->newsB
, WIPImageOnly
);
290 path
= LocateImage(NEWS_IMAGE
);
292 icon
= WMCreatePixmapFromFile(scr
, path
);
294 WMSetButtonImage(panel
->newsB
, icon
);
295 WMReleasePixmap(icon
);
300 panel
->oldsB
= WMCreateButton(panel
->titlF
, WBTOnOff
);
301 WMResizeWidget(panel
->oldsB
, 37, 40);
302 WMMoveWidget(panel
->oldsB
, 15, 60);
303 WMSetButtonImagePosition(panel
->oldsB
, WIPImageOnly
);
304 path
= LocateImage(OLDS_IMAGE
);
306 icon
= WMCreatePixmapFromFile(scr
, path
);
308 WMSetButtonImage(panel
->oldsB
, icon
);
309 WMReleasePixmap(icon
);
314 panel
->nextB
= WMCreateButton(panel
->titlF
, WBTOnOff
);
315 WMResizeWidget(panel
->nextB
, 37, 40);
316 WMMoveWidget(panel
->nextB
, 52, 60);
317 WMSetButtonImagePosition(panel
->nextB
, WIPImageOnly
);
318 path
= LocateImage(NEXT_IMAGE
);
320 icon
= WMCreatePixmapFromFile(scr
, path
);
322 WMSetButtonImage(panel
->nextB
, icon
);
323 WMReleasePixmap(icon
);
328 WMGroupButtons(panel
->newsB
, panel
->oldsB
);
329 WMGroupButtons(panel
->newsB
, panel
->nextB
);
331 WMMapSubwidgets(panel
->titlF
);
333 /**************** Features ******************/
334 panel
->animF
= WMCreateFrame(panel
->box
);
335 WMResizeWidget(panel
->animF
, 255, 115);
336 WMMoveWidget(panel
->animF
, 255, 10);
337 WMSetFrameTitle(panel
->animF
, _("Animations"));
339 panel
->animB
= WMCreateButton(panel
->animF
, WBTToggle
);
340 WMResizeWidget(panel
->animB
, 64, 64);
341 WMMoveWidget(panel
->animB
, 15, 20);
342 WMSetButtonFont(panel
->animB
, font
);
343 WMSetButtonText(panel
->animB
, _("Animations"));
344 WMSetButtonImagePosition(panel
->animB
, WIPAbove
);
345 createImages(scr
, rc
, xis
, ANIM_IMAGE
, &altIcon
, &icon
);
347 WMSetButtonImage(panel
->animB
, icon
);
348 WMReleasePixmap(icon
);
351 WMSetButtonAltImage(panel
->animB
, altIcon
);
352 WMReleasePixmap(altIcon
);
354 WMSetBalloonTextForView(_("Disable/enable animations such as those shown\n"
355 "for window miniaturization, shading etc."), WMWidgetView(panel
->animB
));
357 panel
->supB
= WMCreateButton(panel
->animF
, WBTToggle
);
358 WMResizeWidget(panel
->supB
, 64, 64);
359 WMMoveWidget(panel
->supB
, 95, 20);
360 WMSetButtonFont(panel
->supB
, font
);
361 WMSetButtonText(panel
->supB
, _("Superfluous"));
362 WMSetButtonImagePosition(panel
->supB
, WIPAbove
);
363 createImages(scr
, rc
, xis
, SUPERF_IMAGE
, &altIcon
, &icon
);
365 WMSetButtonImage(panel
->supB
, icon
);
366 WMReleasePixmap(icon
);
369 WMSetButtonAltImage(panel
->supB
, altIcon
);
370 WMReleasePixmap(altIcon
);
372 WMSetBalloonTextForView(_("Disable/enable `superfluous' features and\n"
373 "animations. These include the `ghosting' of the\n"
374 "dock when it's being moved to another side and\n"
375 "the explosion animation when undocking icons."), WMWidgetView(panel
->supB
));
377 WMMapSubwidgets(panel
->animF
);
379 /*********** Dithering **********/
382 panel
->dithF
= WMCreateFrame(panel
->box
);
383 WMResizeWidget(panel
->dithF
, 255, 95);
384 WMMoveWidget(panel
->dithF
, 255, 130);
385 WMSetFrameTitle(panel
->dithF
, _("Dithering colormap for 8bpp"));
387 WMSetBalloonTextForView(_("Number of colors to reserve for Window Maker\n"
388 "on displays that support only 8bpp (PseudoColor)."),
389 WMWidgetView(panel
->dithF
));
391 panel
->dithB
= WMCreateSwitchButton(panel
->dithF
);
392 WMResizeWidget(panel
->dithB
, 235, 32);
393 WMMoveWidget(panel
->dithB
, 15, 15);
394 WMSetButtonText(panel
->dithB
, _("Disable dithering in any visual/depth"));
396 panel
->dithL
= WMCreateLabel(panel
->dithF
);
397 WMResizeWidget(panel
->dithL
, 75, 16);
398 WMMoveWidget(panel
->dithL
, 90, 50);
399 WMSetLabelTextAlignment(panel
->dithL
, WACenter
);
400 WMSetLabelText(panel
->dithL
, "64");
402 panel
->dithS
= WMCreateSlider(panel
->dithF
);
403 WMResizeWidget(panel
->dithS
, 95, 16);
404 WMMoveWidget(panel
->dithS
, 80, 65);
405 WMSetSliderMinValue(panel
->dithS
, 2);
406 WMSetSliderMaxValue(panel
->dithS
, 6);
407 WMSetSliderContinuous(panel
->dithS
, True
);
408 WMSetSliderAction(panel
->dithS
, updateLabel
, panel
);
410 panel
->dith1L
= WMCreateLabel(panel
->dithF
);
411 WMResizeWidget(panel
->dith1L
, 70, 35);
412 WMMoveWidget(panel
->dith1L
, 5, 50);
413 WMSetLabelTextAlignment(panel
->dith1L
, WACenter
);
414 WMSetLabelFont(panel
->dith1L
, font
);
415 WMSetLabelText(panel
->dith1L
, _("More colors for\napplications"));
417 panel
->dith2L
= WMCreateLabel(panel
->dithF
);
418 WMResizeWidget(panel
->dith2L
, 70, 35);
419 WMMoveWidget(panel
->dith2L
, 180, 50);
420 WMSetLabelTextAlignment(panel
->dith2L
, WACenter
);
421 WMSetLabelFont(panel
->dith2L
, font
);
422 WMSetLabelText(panel
->dith2L
, _("More colors for\nWindow Maker"));
424 WMMapSubwidgets(panel
->dithF
);
426 WMRealizeWidget(panel
->box
);
427 WMMapSubwidgets(panel
->box
);
435 static void storeData(_Panel
*panel
)
439 for (i
= 0; i
< 5; i
++) {
440 if (WMGetButtonSelected(panel
->icoB
[i
]))
443 SetSpeedForKey(i
, "IconSlideSpeed");
445 for (i
= 0; i
< 5; i
++) {
446 if (WMGetButtonSelected(panel
->shaB
[i
]))
449 SetSpeedForKey(i
, "ShadeSpeed");
451 if (WMGetButtonSelected(panel
->newsB
)) {
452 SetStringForKey("new", "NewStyle");
453 } else if (WMGetButtonSelected(panel
->oldsB
)) {
454 SetStringForKey("old", "NewStyle");
456 SetStringForKey("next", "NewStyle");
458 SetBoolForKey(!WMGetButtonSelected(panel
->animB
), "DisableAnimations");
459 SetBoolForKey(WMGetButtonSelected(panel
->supB
), "Superfluous");
460 SetBoolForKey(WMGetButtonSelected(panel
->smoB
), "SmoothWorkspaceBack");
461 SetBoolForKey(WMGetButtonSelected(panel
->dithB
), "DisableDithering");
462 SetIntegerForKey(WMGetSliderValue(panel
->dithS
), "ColormapSize");
465 Panel
*InitConfigurations(WMScreen
*scr
, WMWidget
*parent
)
469 panel
= wmalloc(sizeof(_Panel
));
470 memset(panel
, 0, sizeof(_Panel
));
472 panel
->sectionName
= _("Other Configurations");
473 panel
->description
= _("Animation speeds, titlebar styles, various option\n"
474 "toggling and number of colors to reserve for\n" "Window Maker on 8bit displays.");
476 panel
->parent
= parent
;
477 panel
->callbacks
.createWidgets
= createPanel
;
478 panel
->callbacks
.updateDomain
= storeData
;
480 AddSection(panel
, ICON_FILE
);