1 /* Preferences.c- misc personal preferences
3 * WPrefs - Window Maker Preferences Program
5 * Copyright (c) 1998-2002 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
{
33 CallbackRec callbacks
;
50 #endif /* XKB_MODELOCK */
62 #define ICON_FILE "ergonomic"
66 borderCallback(WMWidget
*w
, void *data
)
68 _Panel
*panel
= (_Panel
*)data
;
72 i
= WMGetSliderValue(panel
->borderS
);
75 sprintf(buffer
, _("OFF"));
77 sprintf(buffer
, _("1 pixel"));
80 sprintf(buffer
, _("%i pixels"), i
);
83 sprintf(buffer
, _("%i pixels "), i
); /* note space! */
84 WMSetLabelText(panel
->borderL
, buffer
);
89 showData(_Panel
*panel
)
94 str
= GetStringForKey("ResizeDisplay");
97 if (strcasecmp(str
, "corner")==0)
98 WMSetPopUpButtonSelectedItem(panel
->sizeP
, 0);
99 else if (strcasecmp(str
, "center")==0)
100 WMSetPopUpButtonSelectedItem(panel
->sizeP
, 1);
101 else if (strcasecmp(str
, "floating")==0)
102 WMSetPopUpButtonSelectedItem(panel
->sizeP
, 2);
103 else if (strcasecmp(str
, "line")==0)
104 WMSetPopUpButtonSelectedItem(panel
->sizeP
, 3);
105 else if (strcasecmp(str
, "none")==0)
106 WMSetPopUpButtonSelectedItem(panel
->sizeP
, 4);
108 str
= GetStringForKey("MoveDisplay");
111 if (strcasecmp(str
, "corner")==0)
112 WMSetPopUpButtonSelectedItem(panel
->posiP
, 0);
113 else if (strcasecmp(str
, "center")==0)
114 WMSetPopUpButtonSelectedItem(panel
->posiP
, 1);
115 else if (strcasecmp(str
, "floating")==0)
116 WMSetPopUpButtonSelectedItem(panel
->posiP
, 2);
117 else if (strcasecmp(str
, "none")==0)
118 WMSetPopUpButtonSelectedItem(panel
->posiP
, 3);
120 x
= GetIntegerForKey("WorkspaceBorderSize");
123 WMSetSliderValue(panel
->borderS
, x
);
124 borderCallback(NULL
, panel
);
126 str
= GetStringForKey("WorkspaceBorder");
129 if (strcasecmp(str
, "LeftRight")==0) {
130 WMSetButtonSelected(panel
->lrB
, True
);
131 } else if (strcasecmp(str
, "TopBottom")==0) {
132 WMSetButtonSelected(panel
->tbB
, True
);
133 } else if (strcasecmp(str
, "AllDirections")==0) {
134 WMSetButtonSelected(panel
->tbB
, True
);
135 WMSetButtonSelected(panel
->lrB
, True
);
138 WMSetButtonSelected(panel
->raisB
, GetBoolForKey("CirculateRaise"));
140 WMSetButtonSelected(panel
->modeB
, GetBoolForKey("KbdModeLock"));
141 #endif /* XKB_MODELOCK */
143 WMSetButtonSelected(panel
->ballB
[0], GetBoolForKey("WindowTitleBalloons"));
144 WMSetButtonSelected(panel
->ballB
[1], GetBoolForKey("MiniwindowTitleBalloons"));
145 WMSetButtonSelected(panel
->ballB
[2], GetBoolForKey("AppIconBalloons"));
146 WMSetButtonSelected(panel
->ballB
[3], GetBoolForKey("HelpBalloons"));
151 storeData(_Panel
*panel
)
156 switch (WMGetPopUpButtonSelectedItem(panel
->sizeP
)) {
173 SetStringForKey(str
, "ResizeDisplay");
175 switch (WMGetPopUpButtonSelectedItem(panel
->posiP
)) {
189 SetStringForKey(str
, "MoveDisplay");
191 lr
= WMGetButtonSelected(panel
->lrB
);
192 tb
= WMGetButtonSelected(panel
->tbB
);
194 str
= "AllDirections";
201 SetStringForKey(str
, "WorkspaceBorder");
202 SetIntegerForKey(WMGetSliderValue(panel
->borderS
), "WorkspaceBorderSize");
204 SetBoolForKey(WMGetButtonSelected(panel
->raisB
), "CirculateRaise");
206 SetBoolForKey(WMGetButtonSelected(panel
->modeB
), "KbdModeLock");
207 #endif /* XKB_MODELOCK */
208 SetBoolForKey(WMGetButtonSelected(panel
->ballB
[0]), "WindowTitleBalloons");
209 SetBoolForKey(WMGetButtonSelected(panel
->ballB
[1]), "MiniwindowTitleBalloons");
210 SetBoolForKey(WMGetButtonSelected(panel
->ballB
[2]), "AppIconBalloons");
211 SetBoolForKey(WMGetButtonSelected(panel
->ballB
[3]), "HelpBalloons");
216 createPanel(Panel
*p
)
218 _Panel
*panel
= (_Panel
*)p
;
221 panel
->box
= WMCreateBox(panel
->parent
);
222 WMSetViewExpandsToParent(WMWidgetView(panel
->box
), 2, 2, 2, 2);
225 /***************** Size Display ****************/
226 panel
->sizeF
= WMCreateFrame(panel
->box
);
227 WMResizeWidget(panel
->sizeF
, 240, 60);
228 WMMoveWidget(panel
->sizeF
, 20, 10);
229 WMSetFrameTitle(panel
->sizeF
, _("Size Display"));
231 WMSetBalloonTextForView(_("The position or style of the window size\n"
232 "display that's shown when a window is resized."),
233 WMWidgetView(panel
->sizeF
));
235 panel
->sizeP
= WMCreatePopUpButton(panel
->sizeF
);
236 WMResizeWidget(panel
->sizeP
, 200, 20);
237 WMMoveWidget(panel
->sizeP
, 22, 24);
238 WMAddPopUpButtonItem(panel
->sizeP
, _("Corner of screen"));
239 WMAddPopUpButtonItem(panel
->sizeP
, _("Center of screen"));
240 WMAddPopUpButtonItem(panel
->sizeP
, _("Center of resized window"));
241 WMAddPopUpButtonItem(panel
->sizeP
, _("Technical drawing-like"));
242 WMAddPopUpButtonItem(panel
->sizeP
, _("Disabled"));
244 WMMapSubwidgets(panel
->sizeF
);
246 /***************** Position Display ****************/
247 panel
->posiF
= WMCreateFrame(panel
->box
);
248 WMResizeWidget(panel
->posiF
, 240, 60);
249 WMMoveWidget(panel
->posiF
, 20, 75);
250 WMSetFrameTitle(panel
->posiF
, _("Position Display"));
252 WMSetBalloonTextForView(_("The position or style of the window position\n"
253 "display that's shown when a window is moved."),
254 WMWidgetView(panel
->posiF
));
256 panel
->posiP
= WMCreatePopUpButton(panel
->posiF
);
257 WMResizeWidget(panel
->posiP
, 200, 20);
258 WMMoveWidget(panel
->posiP
, 22, 24);
259 WMAddPopUpButtonItem(panel
->posiP
, _("Corner of screen"));
260 WMAddPopUpButtonItem(panel
->posiP
, _("Center of screen"));
261 WMAddPopUpButtonItem(panel
->posiP
, _("Center of resized window"));
262 WMAddPopUpButtonItem(panel
->posiP
, _("Disabled"));
264 WMMapSubwidgets(panel
->posiF
);
266 /***************** Balloon Text ****************/
267 panel
->ballF
= WMCreateFrame(panel
->box
);
268 WMResizeWidget(panel
->ballF
, 235, 125);
269 WMMoveWidget(panel
->ballF
, 270, 10);
270 WMSetFrameTitle(panel
->ballF
, _("Show balloon text for..."));
272 for (i
=0; i
<4; i
++) {
273 panel
->ballB
[i
] = WMCreateSwitchButton(panel
->ballF
);
274 WMResizeWidget(panel
->ballB
[i
], 205, 20);
275 WMMoveWidget(panel
->ballB
[i
], 15, 20+i
*25);
277 WMSetButtonText(panel
->ballB
[0], _("incomplete window titles"));
278 WMSetButtonText(panel
->ballB
[1], _("miniwindow titles"));
279 WMSetButtonText(panel
->ballB
[2], _("application/dock icons"));
280 WMSetButtonText(panel
->ballB
[3], _("internal help"));
282 WMMapSubwidgets(panel
->ballF
);
284 /***************** Options ****************/
285 panel
->optF
= WMCreateFrame(panel
->box
);
286 WMResizeWidget(panel
->optF
, 235, 75);
287 WMMoveWidget(panel
->optF
, 270, 145);
289 panel
->raisB
= WMCreateSwitchButton(panel
->optF
);
290 WMResizeWidget(panel
->raisB
, 210, 30);
291 WMMoveWidget(panel
->raisB
, 15, 7);
292 WMSetButtonText(panel
->raisB
, _("Raise window when switching\nfocus with keyboard."));
295 panel
->modeB
= WMCreateSwitchButton(panel
->optF
);
296 WMResizeWidget(panel
->modeB
, 210, 30);
297 WMMoveWidget(panel
->modeB
, 15, 40);
298 WMSetButtonText(panel
->modeB
, _("Enable keyboard language\nswitch button in window titlebars."));
301 WMMapSubwidgets(panel
->optF
);
303 /***************** Workspace border ****************/
304 panel
->borderF
= WMCreateFrame(panel
->box
);
305 WMResizeWidget(panel
->borderF
, 240, 75);
306 WMMoveWidget(panel
->borderF
, 20, 145);
307 WMSetFrameTitle(panel
->borderF
, _("Workspace border"));
309 panel
->borderS
= WMCreateSlider(panel
->borderF
);
310 WMResizeWidget(panel
->borderS
, 80, 15);
311 WMMoveWidget(panel
->borderS
, 20, 20);
312 WMSetSliderMinValue(panel
->borderS
, 0);
313 WMSetSliderMaxValue(panel
->borderS
, 5);
314 WMSetSliderAction(panel
->borderS
, borderCallback
, panel
);
316 panel
->borderL
= WMCreateLabel(panel
->borderF
);
317 WMResizeWidget(panel
->borderL
, 100, 15);
318 WMMoveWidget(panel
->borderL
, 105, 20);
320 panel
->lrB
= WMCreateSwitchButton(panel
->borderF
);
321 WMMoveWidget(panel
->lrB
, 20, 40);
322 WMResizeWidget(panel
->lrB
, 100, 30);
323 WMSetButtonText(panel
->lrB
, _("Left/Right"));
325 panel
->tbB
= WMCreateSwitchButton(panel
->borderF
);
326 WMMoveWidget(panel
->tbB
, 120, 40);
327 WMResizeWidget(panel
->tbB
, 100, 30);
328 WMSetButtonText(panel
->tbB
, _("Top/Bottom"));
331 WMMapSubwidgets(panel
->borderF
);
333 WMRealizeWidget(panel
->box
);
334 WMMapSubwidgets(panel
->box
);
342 InitPreferences(WMScreen
*scr
, WMWidget
*parent
)
346 panel
= wmalloc(sizeof(_Panel
));
347 memset(panel
, 0, sizeof(_Panel
));
349 panel
->sectionName
= _("Miscellaneous Ergonomic Preferences");
350 panel
->description
= _("Various settings like balloon text, geometry\n"
353 panel
->parent
= parent
;
355 panel
->callbacks
.createWidgets
= createPanel
;
356 panel
->callbacks
.updateDomain
= storeData
;
358 AddSection(panel
, ICON_FILE
);