Mod+Wheel Window Resize
[wmaker-crm.git] / WPrefs.app / WindowHandling.c
Commit [+]AuthorDateLineData
9d2e6ef9 scottc1998-09-29 22:36:29 +00001/* WindowHandling.c- options for handling windows
6830b057 dan2004-10-12 21:28:27 +00002 *
9af1c6c4 dan1998-10-21 14:43:47 +00003 * WPrefs - Window Maker Preferences Program
6830b057 dan2004-10-12 21:28:27 +00004 *
4153e2fd dan2003-01-16 23:30:45 +00005 * Copyright (c) 1998-2003 Alfredo K. Kojima
6830b057 dan2004-10-12 21:28:27 +00006 *
9d2e6ef9 scottc1998-09-29 22:36:29 +00007 * 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.
11 *
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.
16 *
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
6830b057 dan2004-10-12 21:28:27 +000019 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
9d2e6ef9 scottc1998-09-29 22:36:29 +000020 * USA.
21 */
22
9d2e6ef9 scottc1998-09-29 22:36:29 +000023#include "WPrefs.h"
24
25typedef struct _Panel {
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020026 WMBox *box;
9d2e6ef9 scottc1998-09-29 22:36:29 +000027
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020028 char *sectionName;
d3f29988 kojima1999-04-25 01:49:46 +000029
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020030 char *description;
d3f29988 kojima1999-04-25 01:49:46 +000031
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020032 CallbackRec callbacks;
6830b057 dan2004-10-12 21:28:27 +000033
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020034 WMWidget *parent;
6830b057 dan2004-10-12 21:28:27 +000035
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020036 WMFrame *placF;
37 WMPopUpButton *placP;
38 WMLabel *porigL;
39 WMLabel *porigvL;
40 WMFrame *porigF;
41 WMLabel *porigW;
6830b057 dan2004-10-12 21:28:27 +000042
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020043 WMSlider *vsli;
44 WMSlider *hsli;
e7495baf dan1999-02-17 11:06:40 +000045
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020046 WMFrame *resF;
47 WMSlider *resS;
48 WMLabel *resL;
49 WMButton *resaB;
50 WMButton *resrB;
e7495baf dan1999-02-17 11:06:40 +000051
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020052 WMFrame *maxiF;
53 WMButton *miconB;
54 WMButton *mdockB;
6830b057 dan2004-10-12 21:28:27 +000055
a0633381
JH
Johann Haarhoff2009-10-11 21:36:46 +020056 WMLabel *resizeL;
57 WMLabel *resizeTextL;
58 WMSlider *resizeS;
59
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020060 WMFrame *opaqF;
61 WMButton *opaqB;
9d2e6ef9 scottc1998-09-29 22:36:29 +000062
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020063 WMFrame *tranF;
64 WMButton *tranB;
9d2e6ef9 scottc1998-09-29 22:36:29 +000065} _Panel;
66
9d2e6ef9 scottc1998-09-29 22:36:29 +000067#define ICON_FILE "whandling"
68
69#define OPAQUE_MOVE_PIXMAP "opaque"
70
71#define NON_OPAQUE_MOVE_PIXMAP "nonopaque"
72
9d2e6ef9 scottc1998-09-29 22:36:29 +000073#define THUMB_SIZE 16
74
9d2e6ef9 scottc1998-09-29 22:36:29 +000075static char *placements[] = {
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020076 "auto",
77 "random",
78 "manual",
79 "cascade",
80 "smart"
9d2e6ef9 scottc1998-09-29 22:36:29 +000081};
82
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020083static void sliderCallback(WMWidget * w, void *data)
9d2e6ef9 scottc1998-09-29 22:36:29 +000084{
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020085 _Panel *panel = (_Panel *) data;
86 int x, y, rx, ry;
87 char buffer[64];
88 int swidth = WMGetSliderMaxValue(panel->hsli);
89 int sheight = WMGetSliderMaxValue(panel->vsli);
9d2e6ef9 scottc1998-09-29 22:36:29 +000090
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020091 x = WMGetSliderValue(panel->hsli);
92 y = WMGetSliderValue(panel->vsli);
6830b057 dan2004-10-12 21:28:27 +000093
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020094 rx = x * (WMWidgetWidth(panel->porigF) - 3) / swidth + 2;
95 ry = y * (WMWidgetHeight(panel->porigF) - 3) / sheight + 2;
96 WMMoveWidget(panel->porigW, rx, ry);
6830b057 dan2004-10-12 21:28:27 +000097
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020098 sprintf(buffer, "(%i,%i)", x, y);
99 WMSetLabelText(panel->porigvL, buffer);
9d2e6ef9 scottc1998-09-29 22:36:29 +0000100}
101
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200102static void resistanceCallback(WMWidget * w, void *data)
e7495baf dan1999-02-17 11:06:40 +0000103{
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200104 _Panel *panel = (_Panel *) data;
105 char buffer[64];
106 int i;
107
108 i = WMGetSliderValue(panel->resS);
109
110 if (i == 0)
111 WMSetLabelText(panel->resL, "OFF");
112 else {
113 sprintf(buffer, "%i", i);
114 WMSetLabelText(panel->resL, buffer);
115 }
e7495baf dan1999-02-17 11:06:40 +0000116}
117
a0633381
JH
Johann Haarhoff2009-10-11 21:36:46 +0200118static void resizeCallback(WMWidget * w, void *data)
119{
120 _Panel *panel = (_Panel *) data;
121 char buffer[64];
122 int i;
123
124 i = WMGetSliderValue(panel->resizeS);
125
126 if (i == 0)
127 WMSetLabelText(panel->resizeL, "OFF");
128 else {
129 sprintf(buffer, "%i", i);
130 WMSetLabelText(panel->resizeL, buffer);
131 }
132}
133
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200134static int getPlacement(char *str)
9d2e6ef9 scottc1998-09-29 22:36:29 +0000135{
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200136 if (!str)
137 return 0;
138
139 if (strcasecmp(str, "auto") == 0)
140 return 0;
141 else if (strcasecmp(str, "random") == 0)
142 return 1;
143 else if (strcasecmp(str, "manual") == 0)
144 return 2;
145 else if (strcasecmp(str, "cascade") == 0)
146 return 3;
147 else if (strcasecmp(str, "smart") == 0)
148 return 4;
149 else
150 wwarning(_("bad option value %s in WindowPlacement. Using default value"), str);
151 return 0;
9d2e6ef9 scottc1998-09-29 22:36:29 +0000152}
153
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200154static void showData(_Panel * panel)
9d2e6ef9 scottc1998-09-29 22:36:29 +0000155{
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200156 char *str;
157 WMPropList *arr;
158 int x, y;
9d2e6ef9 scottc1998-09-29 22:36:29 +0000159
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200160 str = GetStringForKey("WindowPlacement");
9d2e6ef9 scottc1998-09-29 22:36:29 +0000161
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200162 WMSetPopUpButtonSelectedItem(panel->placP, getPlacement(str));
9d2e6ef9 scottc1998-09-29 22:36:29 +0000163
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200164 arr = GetObjectForKey("WindowPlaceOrigin");
9d2e6ef9 scottc1998-09-29 22:36:29 +0000165
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200166 x = 0;
167 y = 0;
168 if (arr && (!WMIsPLArray(arr) || WMGetPropListItemCount(arr) != 2)) {
169 wwarning(_("invalid data in option WindowPlaceOrigin. Using default (0,0)"));
170 } else {
171 if (arr) {
172 x = atoi(WMGetFromPLString(WMGetFromPLArray(arr, 0)));
173 y = atoi(WMGetFromPLString(WMGetFromPLArray(arr, 1)));
174 }
175 }
9d2e6ef9 scottc1998-09-29 22:36:29 +0000176
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200177 WMSetSliderValue(panel->hsli, x);
178 WMSetSliderValue(panel->vsli, y);
9d2e6ef9 scottc1998-09-29 22:36:29 +0000179
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200180 sliderCallback(NULL, panel);
e7495baf dan1999-02-17 11:06:40 +0000181
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200182 x = GetIntegerForKey("EdgeResistance");
183 WMSetSliderValue(panel->resS, x);
184 resistanceCallback(NULL, panel);
e7495baf dan1999-02-17 11:06:40 +0000185
a0633381
JH
Johann Haarhoff2009-10-11 21:36:46 +0200186 x = GetIntegerForKey("ResizeIncrement");
187 WMSetSliderValue(panel->resizeS, x);
188 resizeCallback(NULL, panel);
189
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200190 WMSetButtonSelected(panel->tranB, GetBoolForKey("OpenTransientOnOwnerWorkspace"));
6830b057 dan2004-10-12 21:28:27 +0000191
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200192 WMSetButtonSelected(panel->opaqB, GetBoolForKey("OpaqueMove"));
6830b057 dan2004-10-12 21:28:27 +0000193
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200194 WMSetButtonSelected(panel->miconB, GetBoolForKey("NoWindowOverIcons"));
9007a657 dan1998-11-23 11:32:19 +0000195
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200196 WMSetButtonSelected(panel->mdockB, GetBoolForKey("NoWindowOverDock"));
824edac3 id1999-07-14 14:42:29 +0000197
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200198 if (GetBoolForKey("Attraction"))
199 WMPerformButtonClick(panel->resrB);
200 else
201 WMPerformButtonClick(panel->resaB);
9d2e6ef9 scottc1998-09-29 22:36:29 +0000202}
203
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200204static void storeData(_Panel * panel)
9d2e6ef9 scottc1998-09-29 22:36:29 +0000205{
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200206 WMPropList *arr;
207 char x[16], y[16];
208
209 SetBoolForKey(WMGetButtonSelected(panel->miconB), "NoWindowOverIcons");
210 SetBoolForKey(WMGetButtonSelected(panel->mdockB), "NoWindowOverDock");
211 SetBoolForKey(WMGetButtonSelected(panel->opaqB), "OpaqueMove");
212 SetBoolForKey(WMGetButtonSelected(panel->tranB), "OpenTransientOnOwnerWorkspace");
213 SetStringForKey(placements[WMGetPopUpButtonSelectedItem(panel->placP)], "WindowPlacement");
214 sprintf(x, "%i", WMGetSliderValue(panel->hsli));
215 sprintf(y, "%i", WMGetSliderValue(panel->vsli));
216 arr = WMCreatePLArray(WMCreatePLString(x), WMCreatePLString(y), NULL);
217 SetObjectForKey(arr, "WindowPlaceOrigin");
218 SetIntegerForKey(WMGetSliderValue(panel->resS), "EdgeResistance");
a0633381 Johann Haarhoff2009-10-11 21:36:46 +0200219 SetIntegerForKey(WMGetSliderValue(panel->resizeS), "ResizeIncrement");
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200220 SetBoolForKey(WMGetButtonSelected(panel->resrB), "Attraction");
221 WMReleasePropList(arr);
9d2e6ef9 scottc1998-09-29 22:36:29 +0000222}
223
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200224static void createPanel(Panel * p)
9d2e6ef9 scottc1998-09-29 22:36:29 +0000225{
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200226 _Panel *panel = (Panel *) p;
227 WMScreen *scr = WMWidgetScreen(panel->parent);
228 WMColor *color;
229 WMPixmap *pixmap;
230 int width, height;
231 int swidth, sheight;
232 char *path;
233 WMBox *hbox;
234
235 panel->box = WMCreateBox(panel->parent);
236 WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);
237 WMSetBoxHorizontal(panel->box, False);
238 WMSetBoxBorderWidth(panel->box, 8);
239
240 hbox = WMCreateBox(panel->box);
241 WMSetBoxHorizontal(hbox, True);
242 WMAddBoxSubview(panel->box, WMWidgetView(hbox), False, True, 110, 0, 10);
6830b057 dan2004-10-12 21:28:27 +0000243
9d2e6ef9 scottc1998-09-29 22:36:29 +0000244 /************** Window Placement ***************/
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200245 panel->placF = WMCreateFrame(hbox);
246 WMMapWidget(panel->placF);
247 WMAddBoxSubview(hbox, WMWidgetView(panel->placF), True, True, 100, 0, 10);
248
249 WMSetFrameTitle(panel->placF, _("Window Placement"));
250 WMSetBalloonTextForView(_("How to place windows when they are first put\n"
251 "on screen."), WMWidgetView(panel->placF));
252
253 panel->placP = WMCreatePopUpButton(panel->placF);
254 WMResizeWidget(panel->placP, 105, 20);
255 WMMoveWidget(panel->placP, 15, 20);
256 WMAddPopUpButtonItem(panel->placP, _("Automatic"));
257 WMAddPopUpButtonItem(panel->placP, _("Random"));
258 WMAddPopUpButtonItem(panel->placP, _("Manual"));
259 WMAddPopUpButtonItem(panel->placP, _("Cascade"));
260 WMAddPopUpButtonItem(panel->placP, _("Smart"));
261
262 panel->porigL = WMCreateLabel(panel->placF);
263 WMResizeWidget(panel->porigL, 120, 32);
264 WMMoveWidget(panel->porigL, 5, 45);
265 WMSetLabelTextAlignment(panel->porigL, WACenter);
266 WMSetLabelText(panel->porigL, _("Placement Origin"));
267
268 panel->porigvL = WMCreateLabel(panel->placF);
269 WMResizeWidget(panel->porigvL, 80, 20);
270 WMMoveWidget(panel->porigvL, 30, 75);
271 WMSetLabelTextAlignment(panel->porigvL, WACenter);
272
273 color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True);
274 panel->porigF = WMCreateFrame(panel->placF);
275 WMSetWidgetBackgroundColor(panel->porigF, color);
276 WMReleaseColor(color);
277 WMSetFrameRelief(panel->porigF, WRSunken);
278
279 swidth = WidthOfScreen(DefaultScreenOfDisplay(WMScreenDisplay(scr)));
280 sheight = HeightOfScreen(DefaultScreenOfDisplay(WMScreenDisplay(scr)));
281
282 if (sheight > swidth) {
283 height = 70;
284 width = 70 * swidth / sheight;
285 if (width > 240)
286 width = 240;
287 height = 240 * sheight / swidth;
288 } else {
289 width = 240;
290 height = 240 * sheight / swidth;
291 if (height > 70)
292 height = 70;
293 width = 70 * swidth / sheight;
294 }
295 WMResizeWidget(panel->porigF, width, height);
296 WMMoveWidget(panel->porigF, 130 + (240 - width) / 2, 20 + (70 - height) / 2);
297
298 panel->porigW = WMCreateLabel(panel->porigF);
299 WMResizeWidget(panel->porigW, THUMB_SIZE, THUMB_SIZE);
300 WMMoveWidget(panel->porigW, 2, 2);
301 WMSetLabelRelief(panel->porigW, WRRaised);
302
303 panel->hsli = WMCreateSlider(panel->placF);
304 WMResizeWidget(panel->hsli, width, 12);
305 WMMoveWidget(panel->hsli, 130 + (240 - width) / 2, 20 + (70 - height) / 2 + height + 2);
306 WMSetSliderAction(panel->hsli, sliderCallback, panel);
307 WMSetSliderMinValue(panel->hsli, 0);
308 WMSetSliderMaxValue(panel->hsli, swidth);
309
310 panel->vsli = WMCreateSlider(panel->placF);
311 WMResizeWidget(panel->vsli, 12, height);
312 WMMoveWidget(panel->vsli, 130 + (240 - width) / 2 + width + 2, 20 + (70 - height) / 2);
313 WMSetSliderAction(panel->vsli, sliderCallback, panel);
314 WMSetSliderMinValue(panel->vsli, 0);
315 WMSetSliderMaxValue(panel->vsli, sheight);
316
317 WMMapSubwidgets(panel->porigF);
318
319 WMMapSubwidgets(panel->placF);
9d2e6ef9 scottc1998-09-29 22:36:29 +0000320
321 /************** Opaque Move ***************/
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200322 panel->opaqF = WMCreateFrame(hbox);
323 WMMapWidget(panel->opaqF);
324 WMAddBoxSubview(hbox, WMWidgetView(panel->opaqF), False, True, 110, 0, 0);
325
326 WMSetFrameTitle(panel->opaqF, _("Opaque Move"));
327 WMSetBalloonTextForView(_("Whether the window contents should be moved\n"
328 "when dragging windows aroung or if only a\n"
329 "frame should be displayed.\n"), WMWidgetView(panel->opaqF));
330
331 panel->opaqB = WMCreateButton(panel->opaqF, WBTToggle);
332 WMResizeWidget(panel->opaqB, 64, 64);
333 WMMoveWidget(panel->opaqB, 24, 25);
334 WMSetButtonImagePosition(panel->opaqB, WIPImageOnly);
335
336 path = LocateImage(NON_OPAQUE_MOVE_PIXMAP);
337 if (path) {
338 pixmap = WMCreatePixmapFromFile(scr, path);
339 if (pixmap) {
340 WMSetButtonImage(panel->opaqB, pixmap);
341 WMReleasePixmap(pixmap);
342 } else {
343 wwarning(_("could not load icon %s"), path);
344 }
345 wfree(path);
346 }
347
348 path = LocateImage(OPAQUE_MOVE_PIXMAP);
349 if (path) {
350 pixmap = WMCreatePixmapFromFile(scr, path);
351 if (pixmap) {
352 WMSetButtonAltImage(panel->opaqB, pixmap);
353 WMReleasePixmap(pixmap);
354 } else {
355 wwarning(_("could not load icon %s"), path);
356 }
357 wfree(path);
358 }
359 WMMapSubwidgets(panel->opaqF);
6830b057 dan2004-10-12 21:28:27 +0000360
9d2e6ef9 scottc1998-09-29 22:36:29 +0000361 /**************** Account for Icon/Dock ***************/
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200362 panel->maxiF = WMCreateFrame(panel->box);
363 WMResizeWidget(panel->maxiF, 205, 95);
364 WMMoveWidget(panel->maxiF, 305, 125);
365 WMSetFrameTitle(panel->maxiF, _("When maximizing..."));
6830b057 dan2004-10-12 21:28:27 +0000366
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200367 panel->miconB = WMCreateSwitchButton(panel->maxiF);
368 WMResizeWidget(panel->miconB, 190, 30);
a0633381 Johann Haarhoff2009-10-11 21:36:46 +0200369 WMMoveWidget(panel->miconB, 10, 12);
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200370 WMSetButtonText(panel->miconB, _("...do not cover icons"));
9af1c6c4 dan1998-10-21 14:43:47 +0000371
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200372 panel->mdockB = WMCreateSwitchButton(panel->maxiF);
373 WMResizeWidget(panel->mdockB, 190, 30);
a0633381 Johann Haarhoff2009-10-11 21:36:46 +0200374 WMMoveWidget(panel->mdockB, 10, 35);
9007a657 dan1998-11-23 11:32:19 +0000375
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200376 WMSetButtonText(panel->mdockB, _("...do not cover dock"));
9007a657 dan1998-11-23 11:32:19 +0000377
a0633381
JH
Johann Haarhoff2009-10-11 21:36:46 +0200378 panel->resizeS = WMCreateSlider(panel->maxiF);
379 WMResizeWidget(panel->resizeS, 50, 15);
380 WMMoveWidget(panel->resizeS, 10, 70);
381 WMSetSliderMinValue(panel->resizeS, 0);
382 WMSetSliderMaxValue(panel->resizeS, 100);
383 WMSetSliderAction(panel->resizeS, resizeCallback, panel);
384
385 panel->resizeL = WMCreateLabel(panel->maxiF);
386 WMResizeWidget(panel->resizeL, 30, 15);
387 WMMoveWidget(panel->resizeL, 60, 70);
388
389 panel->resizeTextL = WMCreateLabel(panel->maxiF);
390 WMSetLabelText(panel->resizeTextL, "Mod+Wheel\nresize increment");
391 WMResizeWidget(panel->resizeTextL, 110, 30);
392 WMMoveWidget(panel->resizeTextL, 90, 62);
393
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200394 WMMapSubwidgets(panel->maxiF);
e7495baf dan1999-02-17 11:06:40 +0000395
396 /**************** Edge Resistance ****************/
397
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200398 panel->resF = WMCreateFrame(panel->box);
399 WMResizeWidget(panel->resF, 285, 45);
400 WMMoveWidget(panel->resF, 8, 125);
401 WMSetFrameTitle(panel->resF, _("Edge Resistance"));
e7495baf dan1999-02-17 11:06:40 +0000402
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200403 WMSetBalloonTextForView(_("Edge resistance will make windows `resist'\n"
404 "being moved further for the defined threshold\n"
405 "when moved against other windows or the edges\n"
406 "of the screen."), WMWidgetView(panel->resF));
d3f29988 kojima1999-04-25 01:49:46 +0000407
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200408 panel->resS = WMCreateSlider(panel->resF);
409 WMResizeWidget(panel->resS, 80, 15);
410 WMMoveWidget(panel->resS, 10, 20);
411 WMSetSliderMinValue(panel->resS, 0);
412 WMSetSliderMaxValue(panel->resS, 80);
413 WMSetSliderAction(panel->resS, resistanceCallback, panel);
e7495baf dan1999-02-17 11:06:40 +0000414
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200415 panel->resL = WMCreateLabel(panel->resF);
416 WMResizeWidget(panel->resL, 30, 15);
417 WMMoveWidget(panel->resL, 95, 20);
824edac3 id1999-07-14 14:42:29 +0000418
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200419 panel->resaB = WMCreateRadioButton(panel->resF);
420 WMMoveWidget(panel->resaB, 130, 15);
421 WMResizeWidget(panel->resaB, 70, 25);
422 WMSetButtonText(panel->resaB, _("Resist"));
824edac3 id1999-07-14 14:42:29 +0000423
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200424 panel->resrB = WMCreateRadioButton(panel->resF);
425 WMMoveWidget(panel->resrB, 200, 15);
426 WMResizeWidget(panel->resrB, 70, 25);
427 WMSetButtonText(panel->resrB, _("Attract"));
428 WMGroupButtons(panel->resrB, panel->resaB);
824edac3 id1999-07-14 14:42:29 +0000429
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200430 WMMapSubwidgets(panel->resF);
e7495baf dan1999-02-17 11:06:40 +0000431
432 /**************** Transients on Parent Workspace ****************/
6830b057 dan2004-10-12 21:28:27 +0000433
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200434 panel->tranF = WMCreateFrame(panel->box);
435 WMResizeWidget(panel->tranF, 285, 40);
436 WMMoveWidget(panel->tranF, 8, 180);
6830b057 dan2004-10-12 21:28:27 +0000437
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200438 panel->tranB = WMCreateSwitchButton(panel->tranF);
439 WMMoveWidget(panel->tranB, 10, 5);
440 WMResizeWidget(panel->tranB, 250, 30);
441 WMSetButtonText(panel->tranB, _("Open dialogs in the same workspace\nas their owners"));
6830b057 dan2004-10-12 21:28:27 +0000442
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200443 WMMapSubwidgets(panel->tranF);
6830b057 dan2004-10-12 21:28:27 +0000444
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200445 WMRealizeWidget(panel->box);
446 WMMapSubwidgets(panel->box);
6830b057 dan2004-10-12 21:28:27 +0000447
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200448 /* show the config data */
449 showData(panel);
9d2e6ef9 scottc1998-09-29 22:36:29 +0000450}
451
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200452static void undo(_Panel * panel)
9d2e6ef9 scottc1998-09-29 22:36:29 +0000453{
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200454 showData(panel);
9d2e6ef9 scottc1998-09-29 22:36:29 +0000455}
456
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200457Panel *InitWindowHandling(WMScreen * scr, WMWidget * parent)
9d2e6ef9 scottc1998-09-29 22:36:29 +0000458{
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200459 _Panel *panel;
9d2e6ef9 scottc1998-09-29 22:36:29 +0000460
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200461 panel = wmalloc(sizeof(_Panel));
462 memset(panel, 0, sizeof(_Panel));
9d2e6ef9 scottc1998-09-29 22:36:29 +0000463
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200464 panel->sectionName = _("Window Handling Preferences");
9d2e6ef9 scottc1998-09-29 22:36:29 +0000465
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200466 panel->description = _("Window handling options. Initial placement style\n"
467 "edge resistance, opaque move etc.");
d3f29988 kojima1999-04-25 01:49:46 +0000468
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200469 panel->parent = parent;
6830b057 dan2004-10-12 21:28:27 +0000470
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200471 panel->callbacks.createWidgets = createPanel;
472 panel->callbacks.updateDomain = storeData;
473 panel->callbacks.undoChanges = undo;
6830b057 dan2004-10-12 21:28:27 +0000474
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200475 AddSection(panel, ICON_FILE);
6830b057 dan2004-10-12 21:28:27 +0000476
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200477 return panel;
9d2e6ef9 scottc1998-09-29 22:36:29 +0000478}