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.
25 /* Possible choices to display window information during a resize */
29 } resize_display
[] = {
30 { "corner", N_("Corner of screen") },
31 { "center", N_("Center of screen") },
32 { "floating", N_("Center of resized window") },
33 { "line", N_("Technical drawing-like") },
34 { "none", N_("Disabled") }
37 /* Possible choices to display window information while a window is being moved */
42 { "corner", N_("Corner of screen") },
43 { "center", N_("Center of screen") },
44 { "floating", N_("Center of resized window") },
45 { "none", N_("Disabled") }
48 /* All the places where a balloon can be used to display more stuff to user */
52 } balloon_choices
[] = {
53 { "WindowTitleBalloons", N_("incomplete window titles"), },
54 { "MiniwindowTitleBalloons", N_("miniwindow titles"), },
55 { "AppIconBalloons", N_("application/dock icons"), },
56 { "HelpBalloons", N_("internal help"), }
63 const char *balloon_msg
;
64 } appicon_bouncing
[] = {
65 { "DoNotMakeAppIconsBounce", False
, N_("Disable AppIcon bounce"),
66 N_("By default, the AppIcon bounces when the application is launched") },
68 { "BounceAppIconsWhenUrgent", True
, N_("Bounce when the application wants attention"),
71 { "RaiseAppIconsWhenBouncing", False
, N_("Raise AppIcon when bouncing"),
72 N_("Otherwise you will not see it bouncing if\nthere is a window in front of the AppIcon") }
75 typedef struct _Panel
{
82 CallbackRec callbacks
;
93 WMButton
*ballB
[wlengthof_nocheck(balloon_choices
)];
96 WMButton
*bounceB
[wlengthof_nocheck(appicon_bouncing
)];
106 #define ICON_FILE "ergonomic"
108 static void borderCallback(WMWidget
* w
, void *data
)
110 _Panel
*panel
= (_Panel
*) data
;
114 /* Parameter not used, but tell the compiler that it is ok */
117 i
= WMGetSliderValue(panel
->borderS
);
120 sprintf(buffer
, _("OFF"));
122 sprintf(buffer
, _("1 pixel"));
125 sprintf(buffer
, _("%i pixels"), i
);
128 sprintf(buffer
, _("%i pixels "), i
); /* note space! */
129 WMSetLabelText(panel
->borderL
, buffer
);
132 static void showData(_Panel
* panel
)
137 str
= GetStringForKey("ResizeDisplay");
139 for (x
= 0; x
< wlengthof(resize_display
); x
++) {
140 if (strcasecmp(str
, resize_display
[x
].db_value
) == 0) {
141 WMSetPopUpButtonSelectedItem(panel
->sizeP
, x
);
142 goto found_valid_resize_display
;
145 wwarning(_("bad value \"%s\" for option %s, using default \"%s\""),
146 str
, "ResizeDisplay", resize_display
[0].db_value
);
148 WMSetPopUpButtonSelectedItem(panel
->sizeP
, 0);
149 found_valid_resize_display
:
151 str
= GetStringForKey("MoveDisplay");
153 for (x
= 0; x
< wlengthof(move_display
); x
++) {
154 if (strcasecmp(str
, move_display
[x
].db_value
) == 0) {
155 WMSetPopUpButtonSelectedItem(panel
->posiP
, x
);
156 goto found_valid_move_display
;
159 wwarning(_("bad value \"%s\" for option %s, using default \"%s\""),
160 str
, "MoveDisplay", move_display
[0].db_value
);
162 WMSetPopUpButtonSelectedItem(panel
->posiP
, 0);
163 found_valid_move_display
:
165 x
= GetIntegerForKey("WorkspaceBorderSize");
168 WMSetSliderValue(panel
->borderS
, x
);
169 borderCallback(NULL
, panel
);
171 str
= GetStringForKey("WorkspaceBorder");
174 if (strcasecmp(str
, "LeftRight") == 0) {
175 WMSetButtonSelected(panel
->lrB
, True
);
176 } else if (strcasecmp(str
, "TopBottom") == 0) {
177 WMSetButtonSelected(panel
->tbB
, True
);
178 } else if (strcasecmp(str
, "AllDirections") == 0) {
179 WMSetButtonSelected(panel
->tbB
, True
);
180 WMSetButtonSelected(panel
->lrB
, True
);
183 for (x
= 0; x
< wlengthof(appicon_bouncing
); x
++) {
184 if (GetStringForKey(appicon_bouncing
[x
].db_key
))
185 WMSetButtonSelected(panel
->bounceB
[x
], GetBoolForKey(appicon_bouncing
[x
].db_key
));
188 for (x
= 0; x
< wlengthof(balloon_choices
); x
++)
189 WMSetButtonSelected(panel
->ballB
[x
], GetBoolForKey(balloon_choices
[x
].db_key
));
192 static void storeData(_Panel
* panel
)
198 i
= WMGetPopUpButtonSelectedItem(panel
->sizeP
);
199 SetStringForKey(resize_display
[i
].db_value
, "ResizeDisplay");
201 i
= WMGetPopUpButtonSelectedItem(panel
->posiP
);
202 SetStringForKey(move_display
[i
].db_value
, "MoveDisplay");
204 lr
= WMGetButtonSelected(panel
->lrB
);
205 tb
= WMGetButtonSelected(panel
->tbB
);
207 str
= "AllDirections";
214 SetStringForKey(str
, "WorkspaceBorder");
215 SetIntegerForKey(WMGetSliderValue(panel
->borderS
), "WorkspaceBorderSize");
217 for (i
= 0; i
< wlengthof(appicon_bouncing
); i
++)
218 SetBoolForKey(WMGetButtonSelected(panel
->bounceB
[i
]), appicon_bouncing
[i
].db_key
);
220 for (i
= 0; i
< wlengthof(balloon_choices
); i
++)
221 SetBoolForKey(WMGetButtonSelected(panel
->ballB
[i
]), balloon_choices
[i
].db_key
);
224 static void createPanel(Panel
* p
)
226 _Panel
*panel
= (_Panel
*) p
;
229 panel
->box
= WMCreateBox(panel
->parent
);
230 WMSetViewExpandsToParent(WMWidgetView(panel
->box
), 2, 2, 2, 2);
232 /***************** Size Display ****************/
233 panel
->sizeF
= WMCreateFrame(panel
->box
);
234 WMResizeWidget(panel
->sizeF
, 255, 52);
235 WMMoveWidget(panel
->sizeF
, 15, 7);
236 WMSetFrameTitle(panel
->sizeF
, _("Size Display"));
238 WMSetBalloonTextForView(_("The position or style of the window size\n"
239 "display that's shown when a window is resized."), WMWidgetView(panel
->sizeF
));
241 panel
->sizeP
= WMCreatePopUpButton(panel
->sizeF
);
242 WMResizeWidget(panel
->sizeP
, 227, 20);
243 WMMoveWidget(panel
->sizeP
, 14, 20);
244 for (i
= 0; i
< wlengthof(resize_display
); i
++)
245 WMAddPopUpButtonItem(panel
->sizeP
, _(resize_display
[i
].label
));
247 WMMapSubwidgets(panel
->sizeF
);
249 /***************** Position Display ****************/
250 panel
->posiF
= WMCreateFrame(panel
->box
);
251 WMResizeWidget(panel
->posiF
, 255, 52);
252 WMMoveWidget(panel
->posiF
, 15, 66);
253 WMSetFrameTitle(panel
->posiF
, _("Position Display"));
255 WMSetBalloonTextForView(_("The position or style of the window position\n"
256 "display that's shown when a window is moved."), WMWidgetView(panel
->posiF
));
258 panel
->posiP
= WMCreatePopUpButton(panel
->posiF
);
259 WMResizeWidget(panel
->posiP
, 227, 20);
260 WMMoveWidget(panel
->posiP
, 14, 20);
261 for (i
= 0; i
< wlengthof(move_display
); i
++)
262 WMAddPopUpButtonItem(panel
->posiP
, _(move_display
[i
].label
));
264 WMMapSubwidgets(panel
->posiF
);
266 /***************** Balloon Text ****************/
267 panel
->ballF
= WMCreateFrame(panel
->box
);
268 WMResizeWidget(panel
->ballF
, 220, 130);
269 WMMoveWidget(panel
->ballF
, 285, 7);
270 WMSetFrameTitle(panel
->ballF
, _("Show balloon for..."));
272 for (i
= 0; i
< wlengthof(balloon_choices
); i
++) {
273 panel
->ballB
[i
] = WMCreateSwitchButton(panel
->ballF
);
274 WMResizeWidget(panel
->ballB
[i
], 198, 20);
275 WMMoveWidget(panel
->ballB
[i
], 11, 20 + i
* 26);
276 WMSetButtonText(panel
->ballB
[i
], _(balloon_choices
[i
].label
));
279 WMMapSubwidgets(panel
->ballF
);
281 /***************** Options ****************/
282 panel
->optF
= WMCreateFrame(panel
->box
);
283 WMResizeWidget(panel
->optF
, 255, 94);
284 WMMoveWidget(panel
->optF
, 15, 125);
285 WMSetFrameTitle(panel
->optF
, _("AppIcon bouncing"));
287 for (i
= 0; i
< wlengthof(appicon_bouncing
); i
++) {
288 panel
->bounceB
[i
] = WMCreateSwitchButton(panel
->optF
);
289 WMResizeWidget(panel
->bounceB
[i
], 237, 26);
290 WMMoveWidget(panel
->bounceB
[i
], 9, 14 + i
* 25);
291 WMSetButtonText(panel
->bounceB
[i
], _(appicon_bouncing
[i
].label
));
293 if (appicon_bouncing
[i
].default_value
)
294 WMSetButtonSelected(panel
->bounceB
[i
], True
);
296 if (appicon_bouncing
[i
].balloon_msg
)
297 WMSetBalloonTextForView(_(appicon_bouncing
[i
].balloon_msg
),
298 WMWidgetView(panel
->bounceB
[i
]));
301 WMMapSubwidgets(panel
->optF
);
303 /***************** Workspace border ****************/
304 panel
->borderF
= WMCreateFrame(panel
->box
);
305 WMResizeWidget(panel
->borderF
, 220, 75);
306 WMMoveWidget(panel
->borderF
, 285, 144);
307 WMSetFrameTitle(panel
->borderF
, _("Workspace border"));
309 panel
->borderS
= WMCreateSlider(panel
->borderF
);
310 WMResizeWidget(panel
->borderS
, 80, 15);
311 WMMoveWidget(panel
->borderS
, 11, 22);
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, 22);
320 panel
->lrB
= WMCreateSwitchButton(panel
->borderF
);
321 WMMoveWidget(panel
->lrB
, 11, 40);
322 WMResizeWidget(panel
->lrB
, 95, 30);
323 WMSetButtonText(panel
->lrB
, _("Left/Right"));
325 panel
->tbB
= WMCreateSwitchButton(panel
->borderF
);
326 WMMoveWidget(panel
->tbB
, 110, 40);
327 WMResizeWidget(panel
->tbB
, 105, 30);
328 WMSetButtonText(panel
->tbB
, _("Top/Bottom"));
330 WMMapSubwidgets(panel
->borderF
);
332 WMRealizeWidget(panel
->box
);
333 WMMapSubwidgets(panel
->box
);
338 Panel
*InitPreferences(WMWidget
*parent
)
342 panel
= wmalloc(sizeof(_Panel
));
344 panel
->sectionName
= _("Miscellaneous Ergonomic Preferences");
345 panel
->description
= _("Various settings like balloon text, geometry\n" "displays etc.");
347 panel
->parent
= parent
;
349 panel
->callbacks
.createWidgets
= createPanel
;
350 panel
->callbacks
.updateDomain
= storeData
;
352 AddSection(panel
, ICON_FILE
);