1 /* Expert.c- expert user options
3 * WPrefs - Window Maker Preferences Program
5 * Copyright (c) 2014-2023 Window Maker Team
6 * Copyright (c) 1998-2003 Alfredo K. Kojima
7 * Copyright (c) 2009-2023 Window Maker Team
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 /* This structure containts the list of all the check-buttons to display in the
27 * expert tab of the window with the corresponding information for effect
29 static struct expert_option
{
30 const char *label
; /* Text displayed to user */
32 int def_state
; /* True/False: the default value, if not defined in current config */
41 const char *op_name
; /* The identifier for the option in the config file */
43 } expert_options
[] = {
45 { N_("Disable miniwindows (icons for minimized windows). For use with KDE/GNOME."),
46 /* default: */ False
, OPTION_WMAKER
, "DisableMiniwindows" },
48 { N_("Ignore decoration hints for GTK applications."),
49 /* default: */ False
, OPTION_WMAKER
, "IgnoreGtkHints" },
51 { N_("Enable workspace pager."),
52 /* default: */ False
, OPTION_WMAKER
, "EnableWorkspacePager" },
54 { N_("Do not set non-WindowMaker specific parameters (do not use xset)."),
55 /* default: */ False
, OPTION_USERDEF
, "NoXSetStuff" },
57 { N_("Automatically save session when exiting Window Maker."),
58 /* default: */ False
, OPTION_WMAKER
, "SaveSessionOnExit" },
60 { N_("Use SaveUnder in window frames, icons, menus and other objects."),
61 /* default: */ False
, OPTION_WMAKER
, "UseSaveUnders" },
63 { N_("Disable confirmation panel for the Kill command."),
64 /* default: */ False
, OPTION_WMAKER
, "DontConfirmKill" },
66 { N_("Disable selection animation for selected icons."),
67 /* default: */ False
, OPTION_WMAKER
, "DisableBlinking" },
69 { N_("Smooth font edges (needs restart)."),
70 /* default: */ True
, OPTION_WMAKER
, "AntialiasedText" },
72 { N_("Cycle windows only on the active head."),
73 /* default: */ False
, OPTION_WMAKER
, "CycleActiveHeadOnly" },
75 { N_("Ignore minimized windows when cycling."),
76 /* default: */ False
, OPTION_WMAKER
, "CycleIgnoreMinimized" },
78 { N_("Show switch panel when cycling windows."),
79 /* default: */ True
, OPTION_WMAKER_ARRAY
, "SwitchPanelImages" },
81 { N_("Show workspace title on Clip."),
82 /* default: */ True
, OPTION_WMAKER
, "ShowClipTitle" },
84 { N_("Highlight the icon of the application when it has the focus."),
85 /* default: */ True
, OPTION_WMAKER
, "HighlightActiveApp" },
88 { N_("Enable keyboard language switch button in window titlebars."),
89 /* default: */ False
, OPTION_WMAKER
, "KbdModeLock" },
90 #endif /* XKB_MODELOCK */
92 { N_("Snap a window to edge or corner by dragging."),
93 /* default: */ False
, OPTION_WMAKER
, "WindowSnapping" },
95 { N_("Distance from edge to begin window snap."),
96 /* default: */ 1, OPTION_WMAKER_INT
, "SnapEdgeDetect" },
98 { N_("Distance from corner to begin window snap."),
99 /* default: */ 10, OPTION_WMAKER_INT
, "SnapCornerDetect" },
101 { N_("Snap a window to the top to maximize it to the full screen."),
102 /* default: */ False
, OPTION_WMAKER
, "SnapToTopMaximizesFullscreen" },
104 { N_("Allow move half-maximized windows between multiple screens."),
105 /* default: */ False
, OPTION_WMAKER
, "MoveHalfMaximizedWindowsBetweenScreens" },
107 { N_("Alternative transitions between states for half maximized windows."),
108 /* default: */ False
, OPTION_WMAKER
, "AlternativeHalfMaximized" },
110 { N_("Move mouse pointer with half maximized windows."),
111 /* default: */ False
, OPTION_WMAKER
, "PointerWithHalfMaxWindows" },
113 { N_("Open dialogs in the same workspace as their owners."),
114 /* default: */ False
, OPTION_WMAKER
, "OpenTransientOnOwnerWorkspace" },
116 { N_("Wrap dock-attached icons around the screen edges."),
117 /* default: */ True
, OPTION_WMAKER
, "WrapAppiconsInDock" },
119 { N_("Double click on titlebar maximizes/minimizes a window to/from full screen."),
120 /* default: */ False
, OPTION_WMAKER
, "DbClickFullScreen" },
122 { N_("Close rootmenu when mouse (left or right) is clicked outside focus."),
123 /* default: */ False
, OPTION_WMAKER
, "CloseRootMenuByLeftOrRightMouseClick" },
124 { N_("Keep dock on primary head."),
125 /* default: */ False
, OPTION_WMAKER
, "KeepDockOnPrimaryHead"},
131 typedef struct _Panel
{
137 CallbackRec callbacks
;
141 WMButton
*swi
[wlengthof_nocheck(expert_options
)];
143 WMTextField
*textfield
[wlengthof_nocheck(expert_options
)];
147 #define ICON_FILE "expert"
149 static void changeIntTextfield(void *data
, int delta
)
151 WMTextField
*textfield
;
152 char *text
, buffer
[12];
155 textfield
= (WMTextField
*)data
;
156 text
= WMGetTextFieldText(textfield
);
160 sprintf(buffer
, "%d", value
);
161 WMSetTextFieldText(textfield
, buffer
);
164 static void downButtonCallback(WMWidget
*self
, void *data
)
167 changeIntTextfield(data
, -1);
170 static void upButtonCallback(WMWidget
*self
, void *data
)
173 changeIntTextfield(data
, 1);
176 static int cmpExpertOptions(const void *v1
, const void *v2
)
179 const struct expert_option
*opt1
= (struct expert_option
*)v1
;
180 const struct expert_option
*opt2
= (struct expert_option
*)v2
;
182 if ((rc
= strcmp(opt1
->label
, opt2
->label
)) < 0)
189 static void createPanel(Panel
*p
)
191 _Panel
*panel
= (_Panel
*) p
;
197 panel
->box
= WMCreateBox(panel
->parent
);
198 WMSetViewExpandsToParent(WMWidgetView(panel
->box
), 2, 2, 2, 2);
200 sv
= WMCreateScrollView(panel
->box
);
201 WMResizeWidget(sv
, 500, 215);
202 WMMoveWidget(sv
, 12, 10);
203 WMSetScrollViewRelief(sv
, WRSunken
);
204 WMSetScrollViewHasVerticalScroller(sv
, True
);
205 WMSetScrollViewHasHorizontalScroller(sv
, False
);
207 f
= WMCreateFrame(panel
->box
);
208 WMResizeWidget(f
, 495, wlengthof(expert_options
) * 25 + 8);
209 WMSetFrameRelief(f
, WRFlat
);
211 udb
= WMGetStandardUserDefaults();
212 qsort(expert_options
, wlengthof(expert_options
), sizeof(expert_options
[0]), cmpExpertOptions
);
213 for (i
= 0; i
< wlengthof(expert_options
); i
++) {
214 if (expert_options
[i
].class != OPTION_WMAKER_INT
) {
215 panel
->swi
[i
] = WMCreateSwitchButton(f
);
216 WMResizeWidget(panel
->swi
[i
], FRAME_WIDTH
- 40, 25);
217 WMMoveWidget(panel
->swi
[i
], 5, 5 + i
* 25);
219 WMSetButtonText(panel
->swi
[i
], _(expert_options
[i
].label
));
222 switch (expert_options
[i
].class) {
224 if (GetStringForKey(expert_options
[i
].op_name
))
225 state
= GetBoolForKey(expert_options
[i
].op_name
);
227 state
= expert_options
[i
].def_state
;
230 case OPTION_WMAKER_ARRAY
: {
231 char *str
= GetStringForKey(expert_options
[i
].op_name
);
232 state
= expert_options
[i
].def_state
;
233 if (str
&& strcasecmp(str
, "None") == 0)
239 state
= WMGetUDBoolForKey(udb
, expert_options
[i
].op_name
);
242 case OPTION_WMAKER_INT
:
248 panel
->textfield
[i
] = WMCreateTextField(f
);
249 WMResizeWidget(panel
->textfield
[i
], 41, 20);
250 WMMoveWidget(panel
->textfield
[i
], 22, 7 + i
* 25);
252 down
= WMCreateCommandButton(f
);
253 WMSetButtonImage(down
, WMGetSystemPixmap(WMWidgetScreen(down
), WSIArrowDown
));
254 WMSetButtonAltImage(down
,
255 WMGetSystemPixmap(WMWidgetScreen(down
), WSIHighlightedArrowDown
));
256 WMSetButtonImagePosition(down
, WIPImageOnly
);
257 WMSetButtonAction(down
, downButtonCallback
, panel
->textfield
[i
]);
258 WMResizeWidget(down
, 16, 16);
259 WMMoveWidget(down
, 5, 9 + i
* 25);
261 up
= WMCreateCommandButton(f
);
262 WMSetButtonImage(up
, WMGetSystemPixmap(WMWidgetScreen(up
), WSIArrowUp
));
263 WMSetButtonAltImage(up
, WMGetSystemPixmap(WMWidgetScreen(up
), WSIHighlightedArrowUp
));
264 WMSetButtonImagePosition(up
, WIPImageOnly
);
265 WMSetButtonAction(up
, upButtonCallback
, panel
->textfield
[i
]);
266 WMResizeWidget(up
, 16, 16);
267 WMMoveWidget(up
, 64, 9 + i
* 25);
269 label
= WMCreateLabel(f
);
270 WMSetLabelText(label
, _(expert_options
[i
].label
));
271 WMResizeWidget(label
, FRAME_WIDTH
- 99, 25);
272 WMMoveWidget(label
, 85, 5 + i
* 25);
274 if (GetStringForKey(expert_options
[i
].op_name
))
275 state
= GetIntegerForKey(expert_options
[i
].op_name
);
277 state
= expert_options
[i
].def_state
;
279 sprintf(tmp
, "%d", state
);
280 WMSetTextFieldText(panel
->textfield
[i
], tmp
);
287 wwarning("export_options[%d].class = %d, this should not happen\n",
288 i
, expert_options
[i
].class);
290 state
= expert_options
[i
].def_state
;
293 if (expert_options
[i
].class != OPTION_WMAKER_INT
)
294 WMSetButtonSelected(panel
->swi
[i
], state
);
297 WMMapSubwidgets(panel
->box
);
298 WMSetScrollViewContentView(sv
, WMWidgetView(f
));
299 WMRealizeWidget(panel
->box
);
302 static void storeDefaults(_Panel
*panel
)
304 WMUserDefaults
*udb
= WMGetStandardUserDefaults();
307 for (i
= 0; i
< wlengthof(expert_options
); i
++) {
308 switch (expert_options
[i
].class) {
310 SetBoolForKey(WMGetButtonSelected(panel
->swi
[i
]), expert_options
[i
].op_name
);
313 case OPTION_WMAKER_ARRAY
:
314 if (WMGetButtonSelected(panel
->swi
[i
])) {
315 /* check if the array was not manually modified */
316 char *str
= GetStringForKey(expert_options
[i
].op_name
);
317 if (str
&& strcasecmp(str
, "None") == 0)
318 RemoveObjectForKey(expert_options
[i
].op_name
);
321 SetStringForKey("None", expert_options
[i
].op_name
);
325 WMSetUDBoolForKey(udb
, WMGetButtonSelected(panel
->swi
[i
]), expert_options
[i
].op_name
);
328 case OPTION_WMAKER_INT
:
333 text
= WMGetTextFieldText(panel
->textfield
[i
]);
337 SetIntegerForKey(value
, expert_options
[i
].op_name
);
344 Panel
*InitExpert(WMWidget
*parent
)
348 panel
= wmalloc(sizeof(_Panel
));
350 panel
->sectionName
= _("Expert User Preferences");
352 panel
->description
= _("Options for people who know what they're doing...\n"
353 "Also has some other misc. options.");
355 panel
->parent
= parent
;
357 panel
->callbacks
.createWidgets
= createPanel
;
358 panel
->callbacks
.updateDomain
= storeDefaults
;
360 AddSection(panel
, ICON_FILE
);