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
);
114 static void createPanel(Panel
*p
)
116 _Panel
*panel
= (_Panel
*) p
;
117 WMScreen
*scr
= WMWidgetScreen(panel
->parent
);
119 WMPixmap
*icon
, *altIcon
;
122 RContext
*rc
= WMScreenRContext(scr
);
123 WMFont
*font
= WMSystemFontOfSize(scr
, 10);
126 path
= LocateImage(ARQUIVO_XIS
);
128 xis
= RLoadImage(rc
, path
, 0);
130 wwarning(_("could not load image file %s"), path
);
134 panel
->box
= WMCreateBox(panel
->parent
);
135 WMSetViewExpandsToParent(WMWidgetView(panel
->box
), 2, 2, 2, 2);
137 /*********** Icon Slide Speed **********/
138 panel
->icoF
= WMCreateFrame(panel
->box
);
139 WMResizeWidget(panel
->icoF
, 212, 45);
140 WMMoveWidget(panel
->icoF
, 15, 10);
141 WMSetFrameTitle(panel
->icoF
, _("Icon Slide Speed"));
143 /*********** Shade Animation Speed **********/
144 panel
->shaF
= WMCreateFrame(panel
->box
);
145 WMResizeWidget(panel
->shaF
, 212, 45);
146 WMMoveWidget(panel
->shaF
, 15, 65);
147 WMSetFrameTitle(panel
->shaF
, _("Shade Animation Speed"));
149 buf1
= wmalloc(strlen(SPEED_IMAGE
) + 1);
150 buf2
= wmalloc(strlen(SPEED_IMAGE_S
) + 1);
152 for (i
= 0; i
< 5; i
++) {
153 panel
->icoB
[i
] = WMCreateCustomButton(panel
->icoF
, WBBStateChangeMask
);
154 panel
->shaB
[i
] = WMCreateCustomButton(panel
->shaF
, WBBStateChangeMask
);
155 WMResizeWidget(panel
->icoB
[i
], 40, 24);
156 WMMoveWidget(panel
->icoB
[i
], 2 + (40 * i
), 15);
157 WMResizeWidget(panel
->shaB
[i
], 40, 24);
158 WMMoveWidget(panel
->shaB
[i
], 2 + (40 * i
), 15);
159 WMSetButtonBordered(panel
->icoB
[i
], False
);
160 WMSetButtonImagePosition(panel
->icoB
[i
], WIPImageOnly
);
162 WMGroupButtons(panel
->icoB
[0], panel
->icoB
[i
]);
164 WMSetButtonBordered(panel
->shaB
[i
], False
);
165 WMSetButtonImagePosition(panel
->shaB
[i
], WIPImageOnly
);
167 WMGroupButtons(panel
->shaB
[0], panel
->shaB
[i
]);
169 sprintf(buf1
, SPEED_IMAGE
, i
);
170 sprintf(buf2
, SPEED_IMAGE_S
, i
);
171 path
= LocateImage(buf1
);
173 icon
= WMCreatePixmapFromFile(scr
, path
);
175 WMSetButtonImage(panel
->icoB
[i
], icon
);
176 WMSetButtonImage(panel
->shaB
[i
], icon
);
177 WMReleasePixmap(icon
);
179 wwarning(_("could not load icon file %s"), path
);
183 path
= LocateImage(buf2
);
185 icon
= WMCreatePixmapFromFile(scr
, path
);
187 WMSetButtonAltImage(panel
->icoB
[i
], icon
);
188 WMSetButtonAltImage(panel
->shaB
[i
], icon
);
189 WMReleasePixmap(icon
);
191 wwarning(_("could not load icon file %s"), path
);
199 WMMapSubwidgets(panel
->icoF
);
200 WMMapSubwidgets(panel
->shaF
);
202 /***************** Smoothed Scaling *****************/
203 panel
->smoF
= WMCreateFrame(panel
->box
);
204 WMResizeWidget(panel
->smoF
, 94, 100);
205 WMMoveWidget(panel
->smoF
, 420, 10);
206 WMSetFrameTitle(panel
->smoF
, _("Smooth Scaling"));
208 panel
->smoB
= WMCreateButton(panel
->smoF
, WBTToggle
);
209 WMResizeWidget(panel
->smoB
, 64, 64);
210 WMMoveWidget(panel
->smoB
, 15, 23);
211 WMSetButtonImagePosition(panel
->smoB
, WIPImageOnly
);
212 path
= LocateImage(SMOOTH_IMAGE
);
214 RImage
*image
, *scaled
;
216 image
= RLoadImage(WMScreenRContext(scr
), path
, 0);
219 scaled
= RScaleImage(image
, 61, 61);
220 icon
= WMCreatePixmapFromRImage(scr
, scaled
, 128);
221 RReleaseImage(scaled
);
223 WMSetButtonImage(panel
->smoB
, icon
);
224 WMReleasePixmap(icon
);
227 scaled
= RSmoothScaleImage(image
, 61, 61);
228 icon
= WMCreatePixmapFromRImage(scr
, scaled
, 128);
229 RReleaseImage(scaled
);
231 WMSetButtonAltImage(panel
->smoB
, icon
);
232 WMReleasePixmap(icon
);
235 RReleaseImage(image
);
237 WMSetBalloonTextForView(_("Smooth scaled background images, neutralizing\n"
238 "the `pixelization' effect. This will slow\n"
239 "down loading of background images considerably."), WMWidgetView(panel
->smoB
));
241 WMMapSubwidgets(panel
->smoF
);
243 /***************** Titlebar Style Size ****************/
244 panel
->titlF
= WMCreateFrame(panel
->box
);
245 WMResizeWidget(panel
->titlF
, 212, 97);
246 WMMoveWidget(panel
->titlF
, 15, 120);
247 WMSetFrameTitle(panel
->titlF
, _("Titlebar Style"));
249 panel
->oldsB
= WMCreateButton(panel
->titlF
, WBTOnOff
);
250 WMResizeWidget(panel
->oldsB
, 60, 40);
251 WMMoveWidget(panel
->oldsB
, 16, 32);
252 WMSetButtonImagePosition(panel
->oldsB
, WIPImageOnly
);
253 path
= LocateImage(OLDS_IMAGE
);
255 icon
= WMCreatePixmapFromFile(scr
, path
);
257 WMSetButtonImage(panel
->oldsB
, icon
);
258 WMReleasePixmap(icon
);
263 panel
->newsB
= WMCreateButton(panel
->titlF
, WBTOnOff
);
264 WMResizeWidget(panel
->newsB
, 60, 40);
265 WMMoveWidget(panel
->newsB
, 76, 32);
266 WMSetButtonImagePosition(panel
->newsB
, WIPImageOnly
);
267 path
= LocateImage(NEWS_IMAGE
);
269 icon
= WMCreatePixmapFromFile(scr
, path
);
271 WMSetButtonImage(panel
->newsB
, icon
);
272 WMReleasePixmap(icon
);
277 panel
->nextB
= WMCreateButton(panel
->titlF
, WBTOnOff
);
278 WMResizeWidget(panel
->nextB
, 60, 40);
279 WMMoveWidget(panel
->nextB
, 136, 32);
280 WMSetButtonImagePosition(panel
->nextB
, WIPImageOnly
);
281 path
= LocateImage(NEXT_IMAGE
);
283 icon
= WMCreatePixmapFromFile(scr
, path
);
285 WMSetButtonImage(panel
->nextB
, icon
);
286 WMReleasePixmap(icon
);
291 WMGroupButtons(panel
->newsB
, panel
->oldsB
);
292 WMGroupButtons(panel
->newsB
, panel
->nextB
);
294 WMMapSubwidgets(panel
->titlF
);
296 /**************** Features ******************/
297 panel
->animF
= WMCreateFrame(panel
->box
);
298 WMResizeWidget(panel
->animF
, 173, 100);
299 WMMoveWidget(panel
->animF
, 237, 10);
300 WMSetFrameTitle(panel
->animF
, _("Animations"));
302 panel
->animB
= WMCreateButton(panel
->animF
, WBTToggle
);
303 WMResizeWidget(panel
->animB
, 64, 64);
304 WMMoveWidget(panel
->animB
, 15, 23);
305 WMSetButtonFont(panel
->animB
, font
);
306 WMSetButtonText(panel
->animB
, _("Animations"));
307 WMSetButtonImagePosition(panel
->animB
, WIPAbove
);
308 CreateImages(scr
, rc
, xis
, ANIM_IMAGE
, &altIcon
, &icon
);
310 WMSetButtonImage(panel
->animB
, icon
);
311 WMReleasePixmap(icon
);
314 WMSetButtonAltImage(panel
->animB
, altIcon
);
315 WMReleasePixmap(altIcon
);
317 WMSetBalloonTextForView(_("Disable/enable animations such as those shown\n"
318 "for window miniaturization, shading etc."), WMWidgetView(panel
->animB
));
320 panel
->supB
= WMCreateButton(panel
->animF
, WBTToggle
);
321 WMResizeWidget(panel
->supB
, 64, 64);
322 WMMoveWidget(panel
->supB
, 94, 23);
323 WMSetButtonFont(panel
->supB
, font
);
324 WMSetButtonText(panel
->supB
, _("Superfluous"));
325 WMSetButtonImagePosition(panel
->supB
, WIPAbove
);
326 CreateImages(scr
, rc
, xis
, SUPERF_IMAGE
, &altIcon
, &icon
);
328 WMSetButtonImage(panel
->supB
, icon
);
329 WMReleasePixmap(icon
);
332 WMSetButtonAltImage(panel
->supB
, altIcon
);
333 WMReleasePixmap(altIcon
);
335 WMSetBalloonTextForView(_("Disable/enable `superfluous' features and\n"
336 "animations. These include the `ghosting' of the\n"
337 "dock when it's being moved to another side and\n"
338 "the explosion animation when undocking icons."), WMWidgetView(panel
->supB
));
340 WMMapSubwidgets(panel
->animF
);
342 /*********** Dithering **********/
345 panel
->dithF
= WMCreateFrame(panel
->box
);
346 WMResizeWidget(panel
->dithF
, 277, 97);
347 WMMoveWidget(panel
->dithF
, 237, 120);
348 WMSetFrameTitle(panel
->dithF
, _("Dithering colormap for 8bpp"));
350 WMSetBalloonTextForView(_("Number of colors to reserve for Window Maker\n"
351 "on displays that support only 8bpp (PseudoColor)."),
352 WMWidgetView(panel
->dithF
));
354 panel
->dithB
= WMCreateSwitchButton(panel
->dithF
);
355 WMResizeWidget(panel
->dithB
, 235, 32);
356 WMMoveWidget(panel
->dithB
, 15, 15);
357 WMSetButtonText(panel
->dithB
, _("Disable dithering in any visual/depth"));
359 panel
->dithL
= WMCreateLabel(panel
->dithF
);
360 WMResizeWidget(panel
->dithL
, 75, 16);
361 WMMoveWidget(panel
->dithL
, 98, 50);
362 WMSetLabelTextAlignment(panel
->dithL
, WACenter
);
363 WMSetLabelText(panel
->dithL
, "64");
365 panel
->dithS
= WMCreateSlider(panel
->dithF
);
366 WMResizeWidget(panel
->dithS
, 95, 16);
367 WMMoveWidget(panel
->dithS
, 90, 65);
368 WMSetSliderMinValue(panel
->dithS
, 2);
369 WMSetSliderMaxValue(panel
->dithS
, 6);
370 WMSetSliderContinuous(panel
->dithS
, True
);
371 WMSetSliderAction(panel
->dithS
, updateLabel
, panel
);
373 panel
->dith1L
= WMCreateLabel(panel
->dithF
);
374 WMResizeWidget(panel
->dith1L
, 80, 35);
375 WMMoveWidget(panel
->dith1L
, 5, 50);
376 WMSetLabelTextAlignment(panel
->dith1L
, WACenter
);
377 WMSetLabelFont(panel
->dith1L
, font
);
378 WMSetLabelText(panel
->dith1L
, _("More colors for\napplications"));
380 panel
->dith2L
= WMCreateLabel(panel
->dithF
);
381 WMResizeWidget(panel
->dith2L
, 80, 35);
382 WMMoveWidget(panel
->dith2L
, 190, 50);
383 WMSetLabelTextAlignment(panel
->dith2L
, WACenter
);
384 WMSetLabelFont(panel
->dith2L
, font
);
385 WMSetLabelText(panel
->dith2L
, _("More colors for\nWindow Maker"));
387 WMMapSubwidgets(panel
->dithF
);
389 WMRealizeWidget(panel
->box
);
390 WMMapSubwidgets(panel
->box
);
398 static void storeData(_Panel
*panel
)
402 for (i
= 0; i
< 5; i
++) {
403 if (WMGetButtonSelected(panel
->icoB
[i
]))
406 SetSpeedForKey(i
, "IconSlideSpeed");
408 for (i
= 0; i
< 5; i
++) {
409 if (WMGetButtonSelected(panel
->shaB
[i
]))
412 SetSpeedForKey(i
, "ShadeSpeed");
414 if (WMGetButtonSelected(panel
->newsB
)) {
415 SetStringForKey("new", "NewStyle");
416 } else if (WMGetButtonSelected(panel
->oldsB
)) {
417 SetStringForKey("old", "NewStyle");
419 SetStringForKey("next", "NewStyle");
421 SetBoolForKey(!WMGetButtonSelected(panel
->animB
), "DisableAnimations");
422 SetBoolForKey(WMGetButtonSelected(panel
->supB
), "Superfluous");
423 SetBoolForKey(WMGetButtonSelected(panel
->smoB
), "SmoothWorkspaceBack");
424 SetBoolForKey(WMGetButtonSelected(panel
->dithB
), "DisableDithering");
425 SetIntegerForKey(WMGetSliderValue(panel
->dithS
), "ColormapSize");
428 Panel
*InitConfigurations(WMWidget
*parent
)
432 panel
= wmalloc(sizeof(_Panel
));
434 panel
->sectionName
= _("Other Configurations");
435 panel
->description
= _("Animation speeds, titlebar styles, various option\n"
436 "toggling and number of colors to reserve for\n" "Window Maker on 8bit displays.");
438 panel
->parent
= parent
;
439 panel
->callbacks
.createWidgets
= createPanel
;
440 panel
->callbacks
.updateDomain
= storeData
;
442 AddSection(panel
, ICON_FILE
);