1 /* Preferences.c- misc ergonomic preferences
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.
28 } balloon_choices
[] = {
29 { "WindowTitleBalloons", N_("incomplete window titles"), },
30 { "MiniwindowTitleBalloons", N_("miniwindow titles"), },
31 { "MiniwindowApercuBalloons", N_("miniwindow apercus"), },
32 { "AppIconBalloons", N_("application/dock icons"), },
33 { "HelpBalloons", N_("internal help"), }
40 const char *balloon_msg
;
41 } appicon_bouncing
[] = {
42 { "DoNotMakeAppIconsBounce", False
, N_("Disable AppIcon bounce"),
43 N_("By default, the AppIcon bounces when the application is launched") },
45 { "BounceAppIconsWhenUrgent", True
, N_("Bounce when the application wants attention"),
48 { "RaiseAppIconsWhenBouncing", False
, N_("Raise AppIcon when bouncing"),
49 N_("Otherwise you will not see it bouncing if\nthere is a window in front of the AppIcon") }
52 typedef struct _Panel
{
59 CallbackRec callbacks
;
70 WMButton
*ballB
[wlengthof_nocheck(balloon_choices
)];
73 WMButton
*bounceB
[wlengthof_nocheck(appicon_bouncing
)];
83 #define ICON_FILE "ergonomic"
85 static void borderCallback(WMWidget
* w
, void *data
)
87 _Panel
*panel
= (_Panel
*) data
;
91 /* Parameter not used, but tell the compiler that it is ok */
94 i
= WMGetSliderValue(panel
->borderS
);
97 sprintf(buffer
, _("OFF"));
99 sprintf(buffer
, _("1 pixel"));
102 sprintf(buffer
, _("%i pixels"), i
);
105 sprintf(buffer
, _("%i pixels "), i
); /* note space! */
106 WMSetLabelText(panel
->borderL
, buffer
);
109 static void showData(_Panel
* panel
)
114 str
= GetStringForKey("ResizeDisplay");
117 if (strcasecmp(str
, "corner") == 0)
118 WMSetPopUpButtonSelectedItem(panel
->sizeP
, 0);
119 else if (strcasecmp(str
, "center") == 0)
120 WMSetPopUpButtonSelectedItem(panel
->sizeP
, 1);
121 else if (strcasecmp(str
, "floating") == 0)
122 WMSetPopUpButtonSelectedItem(panel
->sizeP
, 2);
123 else if (strcasecmp(str
, "line") == 0)
124 WMSetPopUpButtonSelectedItem(panel
->sizeP
, 3);
125 else if (strcasecmp(str
, "none") == 0)
126 WMSetPopUpButtonSelectedItem(panel
->sizeP
, 4);
128 str
= GetStringForKey("MoveDisplay");
131 if (strcasecmp(str
, "corner") == 0)
132 WMSetPopUpButtonSelectedItem(panel
->posiP
, 0);
133 else if (strcasecmp(str
, "center") == 0)
134 WMSetPopUpButtonSelectedItem(panel
->posiP
, 1);
135 else if (strcasecmp(str
, "floating") == 0)
136 WMSetPopUpButtonSelectedItem(panel
->posiP
, 2);
137 else if (strcasecmp(str
, "none") == 0)
138 WMSetPopUpButtonSelectedItem(panel
->posiP
, 3);
140 x
= GetIntegerForKey("WorkspaceBorderSize");
143 WMSetSliderValue(panel
->borderS
, x
);
144 borderCallback(NULL
, panel
);
146 str
= GetStringForKey("WorkspaceBorder");
149 if (strcasecmp(str
, "LeftRight") == 0) {
150 WMSetButtonSelected(panel
->lrB
, True
);
151 } else if (strcasecmp(str
, "TopBottom") == 0) {
152 WMSetButtonSelected(panel
->tbB
, True
);
153 } else if (strcasecmp(str
, "AllDirections") == 0) {
154 WMSetButtonSelected(panel
->tbB
, True
);
155 WMSetButtonSelected(panel
->lrB
, True
);
158 for (x
= 0; x
< wlengthof(appicon_bouncing
); x
++) {
159 if (GetStringForKey(appicon_bouncing
[x
].db_key
))
160 WMSetButtonSelected(panel
->bounceB
[x
], GetBoolForKey(appicon_bouncing
[x
].db_key
));
163 for (x
= 0; x
< wlengthof(balloon_choices
); x
++)
164 WMSetButtonSelected(panel
->ballB
[x
], GetBoolForKey(balloon_choices
[x
].db_key
));
167 static void storeData(_Panel
* panel
)
173 switch (WMGetPopUpButtonSelectedItem(panel
->sizeP
)) {
190 SetStringForKey(str
, "ResizeDisplay");
192 switch (WMGetPopUpButtonSelectedItem(panel
->posiP
)) {
206 SetStringForKey(str
, "MoveDisplay");
208 lr
= WMGetButtonSelected(panel
->lrB
);
209 tb
= WMGetButtonSelected(panel
->tbB
);
211 str
= "AllDirections";
218 SetStringForKey(str
, "WorkspaceBorder");
219 SetIntegerForKey(WMGetSliderValue(panel
->borderS
), "WorkspaceBorderSize");
221 for (i
= 0; i
< wlengthof(appicon_bouncing
); i
++)
222 SetBoolForKey(WMGetButtonSelected(panel
->bounceB
[i
]), appicon_bouncing
[i
].db_key
);
224 for (i
= 0; i
< wlengthof(balloon_choices
); i
++)
225 SetBoolForKey(WMGetButtonSelected(panel
->ballB
[i
]), balloon_choices
[i
].db_key
);
228 static void createPanel(Panel
* p
)
230 _Panel
*panel
= (_Panel
*) p
;
233 panel
->box
= WMCreateBox(panel
->parent
);
234 WMSetViewExpandsToParent(WMWidgetView(panel
->box
), 2, 2, 2, 2);
236 /***************** Size Display ****************/
237 panel
->sizeF
= WMCreateFrame(panel
->box
);
238 WMResizeWidget(panel
->sizeF
, 255, 52);
239 WMMoveWidget(panel
->sizeF
, 15, 7);
240 WMSetFrameTitle(panel
->sizeF
, _("Size Display"));
242 WMSetBalloonTextForView(_("The position or style of the window size\n"
243 "display that's shown when a window is resized."), WMWidgetView(panel
->sizeF
));
245 panel
->sizeP
= WMCreatePopUpButton(panel
->sizeF
);
246 WMResizeWidget(panel
->sizeP
, 227, 20);
247 WMMoveWidget(panel
->sizeP
, 14, 20);
248 WMAddPopUpButtonItem(panel
->sizeP
, _("Corner of screen"));
249 WMAddPopUpButtonItem(panel
->sizeP
, _("Center of screen"));
250 WMAddPopUpButtonItem(panel
->sizeP
, _("Center of resized window"));
251 WMAddPopUpButtonItem(panel
->sizeP
, _("Technical drawing-like"));
252 WMAddPopUpButtonItem(panel
->sizeP
, _("Disabled"));
254 WMMapSubwidgets(panel
->sizeF
);
256 /***************** Position Display ****************/
257 panel
->posiF
= WMCreateFrame(panel
->box
);
258 WMResizeWidget(panel
->posiF
, 255, 52);
259 WMMoveWidget(panel
->posiF
, 15, 66);
260 WMSetFrameTitle(panel
->posiF
, _("Position Display"));
262 WMSetBalloonTextForView(_("The position or style of the window position\n"
263 "display that's shown when a window is moved."), WMWidgetView(panel
->posiF
));
265 panel
->posiP
= WMCreatePopUpButton(panel
->posiF
);
266 WMResizeWidget(panel
->posiP
, 227, 20);
267 WMMoveWidget(panel
->posiP
, 14, 20);
268 WMAddPopUpButtonItem(panel
->posiP
, _("Corner of screen"));
269 WMAddPopUpButtonItem(panel
->posiP
, _("Center of screen"));
270 WMAddPopUpButtonItem(panel
->posiP
, _("Center of resized window"));
271 WMAddPopUpButtonItem(panel
->posiP
, _("Disabled"));
273 WMMapSubwidgets(panel
->posiF
);
275 /***************** Balloon Text ****************/
276 panel
->ballF
= WMCreateFrame(panel
->box
);
277 WMResizeWidget(panel
->ballF
, 220, 132);
278 WMMoveWidget(panel
->ballF
, 285, 7);
279 WMSetFrameTitle(panel
->ballF
, _("Show balloon for..."));
281 for (i
= 0; i
< wlengthof(balloon_choices
); i
++) {
282 panel
->ballB
[i
] = WMCreateSwitchButton(panel
->ballF
);
283 WMResizeWidget(panel
->ballB
[i
], 198, 20);
284 WMMoveWidget(panel
->ballB
[i
], 11, 16 + i
* 22);
285 WMSetButtonText(panel
->ballB
[i
], _(balloon_choices
[i
].label
));
288 WMMapSubwidgets(panel
->ballF
);
290 /***************** Options ****************/
291 panel
->optF
= WMCreateFrame(panel
->box
);
292 WMResizeWidget(panel
->optF
, 255, 94);
293 WMMoveWidget(panel
->optF
, 15, 125);
294 WMSetFrameTitle(panel
->optF
, _("AppIcon bouncing"));
296 for (i
= 0; i
< wlengthof(appicon_bouncing
); i
++) {
297 panel
->bounceB
[i
] = WMCreateSwitchButton(panel
->optF
);
298 WMResizeWidget(panel
->bounceB
[i
], 237, 26);
299 WMMoveWidget(panel
->bounceB
[i
], 9, 14 + i
* 25);
300 WMSetButtonText(panel
->bounceB
[i
], _(appicon_bouncing
[i
].label
));
302 if (appicon_bouncing
[i
].default_value
)
303 WMSetButtonSelected(panel
->bounceB
[i
], True
);
305 if (appicon_bouncing
[i
].balloon_msg
)
306 WMSetBalloonTextForView(_(appicon_bouncing
[i
].balloon_msg
),
307 WMWidgetView(panel
->bounceB
[i
]));
310 WMMapSubwidgets(panel
->optF
);
312 /***************** Workspace border ****************/
313 panel
->borderF
= WMCreateFrame(panel
->box
);
314 WMResizeWidget(panel
->borderF
, 220, 75);
315 WMMoveWidget(panel
->borderF
, 285, 144);
316 WMSetFrameTitle(panel
->borderF
, _("Workspace border"));
318 panel
->borderS
= WMCreateSlider(panel
->borderF
);
319 WMResizeWidget(panel
->borderS
, 80, 15);
320 WMMoveWidget(panel
->borderS
, 11, 22);
321 WMSetSliderMinValue(panel
->borderS
, 0);
322 WMSetSliderMaxValue(panel
->borderS
, 5);
323 WMSetSliderAction(panel
->borderS
, borderCallback
, panel
);
325 panel
->borderL
= WMCreateLabel(panel
->borderF
);
326 WMResizeWidget(panel
->borderL
, 100, 15);
327 WMMoveWidget(panel
->borderL
, 105, 22);
329 panel
->lrB
= WMCreateSwitchButton(panel
->borderF
);
330 WMMoveWidget(panel
->lrB
, 11, 40);
331 WMResizeWidget(panel
->lrB
, 95, 30);
332 WMSetButtonText(panel
->lrB
, _("Left/Right"));
334 panel
->tbB
= WMCreateSwitchButton(panel
->borderF
);
335 WMMoveWidget(panel
->tbB
, 110, 40);
336 WMResizeWidget(panel
->tbB
, 105, 30);
337 WMSetButtonText(panel
->tbB
, _("Top/Bottom"));
339 WMMapSubwidgets(panel
->borderF
);
341 WMRealizeWidget(panel
->box
);
342 WMMapSubwidgets(panel
->box
);
347 Panel
*InitPreferences(WMWidget
*parent
)
351 panel
= wmalloc(sizeof(_Panel
));
353 panel
->sectionName
= _("Miscellaneous Ergonomic Preferences");
354 panel
->description
= _("Various settings like balloon text, geometry\n" "displays etc.");
356 panel
->parent
= parent
;
358 panel
->callbacks
.createWidgets
= createPanel
;
359 panel
->callbacks
.updateDomain
= storeData
;
361 AddSection(panel
, ICON_FILE
);