1 /* Expert.c- expert user options
3 * WPrefs - Window Maker Preferences Program
5 * Copyright (c) 2014 Window Maker Team
6 * Copyright (c) 1998-2003 Alfredo K. Kojima
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 /* This structure containts the list of all the check-buttons to display in the
26 * expert tab of the window with the corresponding information for effect
28 static struct expert_option
{
29 const char *label
; /* Text displayed to user */
31 int def_state
; /* True/False: the default value, if not defined in current config */
40 const char *op_name
; /* The identifier for the option in the config file */
42 } expert_options
[] = {
44 { N_("Disable miniwindows (icons for minimized windows). For use with KDE/GNOME."),
45 /* default: */ False
, OPTION_WMAKER
, "DisableMiniwindows" },
47 { N_("Ignore decoration hints for GTK applications."),
48 /* default: */ False
, OPTION_WMAKER
, "IgnoreGtkHints" },
50 { N_("Enable workspace pager."),
51 /* default: */ False
, OPTION_WMAKER
, "EnableWorkspacePager" },
53 { N_("Do not set non-WindowMaker specific parameters (do not use xset)."),
54 /* default: */ False
, OPTION_USERDEF
, "NoXSetStuff" },
56 { N_("Automatically save session when exiting Window Maker."),
57 /* default: */ False
, OPTION_WMAKER
, "SaveSessionOnExit" },
59 { N_("Use SaveUnder in window frames, icons, menus and other objects."),
60 /* default: */ False
, OPTION_WMAKER
, "UseSaveUnders" },
62 { N_("Disable confirmation panel for the Kill command."),
63 /* default: */ False
, OPTION_WMAKER
, "DontConfirmKill" },
65 { N_("Disable selection animation for selected icons."),
66 /* default: */ False
, OPTION_WMAKER
, "DisableBlinking" },
68 { N_("Smooth font edges (needs restart)."),
69 /* default: */ True
, OPTION_WMAKER
, "AntialiasedText" },
71 { N_("Cycle windows only on the active head."),
72 /* default: */ False
, OPTION_WMAKER
, "CycleActiveHeadOnly" },
74 { N_("Ignore minimized windows when cycling."),
75 /* default: */ False
, OPTION_WMAKER
, "CycleIgnoreMinimized" },
77 { N_("Show switch panel when cycling windows."),
78 /* default: */ True
, OPTION_WMAKER_ARRAY
, "SwitchPanelImages" },
80 { N_("Show workspace title on Clip."),
81 /* default: */ True
, OPTION_WMAKER
, "ShowClipTitle" },
83 { N_("Highlight the icon of the application when it has the focus."),
84 /* default: */ True
, OPTION_WMAKER
, "HighlightActiveApp" },
87 { N_("Enable keyboard language switch button in window titlebars."),
88 /* default: */ False
, OPTION_WMAKER
, "KbdModeLock" },
89 #endif /* XKB_MODELOCK */
91 { N_("Maximize (snap) a window to edge or corner by dragging."),
92 /* default: */ False
, OPTION_WMAKER
, "WindowSnapping" },
94 { N_("Distance from edge to begin window snap."),
95 /* default: */ 1, OPTION_WMAKER_INT
, "SnapEdgeDetect" },
97 { N_("Distance from corner to begin window snap."),
98 /* default: */ 10, OPTION_WMAKER_INT
, "SnapCornerDetect" },
100 { N_("Snapping a window to the top maximizes it to the full screen."),
101 /* default: */ False
, OPTION_WMAKER
, "SnapToTopMaximizesFullscreen" },
103 { N_("Allow move half-maximized windows between multiple screens."),
104 /* default: */ False
, OPTION_WMAKER
, "MoveHalfMaximizedWindowsBetweenScreens" },
106 { N_("Alternative transitions between states for half maximized windows."),
107 /* default: */ False
, OPTION_WMAKER
, "AlternativeHalfMaximized" },
109 { N_("Move mouse pointer with half maximized windows."),
110 /* default: */ False
, OPTION_WMAKER
, "PointerWithHalfMaxWindows" },
112 { N_("Open dialogs in the same workspace as their owners."),
113 /* default: */ False
, OPTION_WMAKER
, "OpenTransientOnOwnerWorkspace" },
115 { N_("Wrap dock-attached icons around the screen edges."),
116 /* default: */ True
, OPTION_WMAKER
, "WrapAppiconsInDock" },
118 { N_("Double click on titlebar maximize a window to full screen."),
119 /* default: */ False
, OPTION_WMAKER
, "DbClickFullScreen" },
121 { N_("Close rootmenu when mouse (left or right) is clicked outside focus."),
122 /* default: */ False
, OPTION_WMAKER
, "CloseRootMenuByLeftOrRightMouseClick" },
123 { N_("Keep dock on primary head."),
124 /* default: */ False
, OPTION_WMAKER
, "KeepDockOnPrimaryHead"},
130 typedef struct _Panel
{
136 CallbackRec callbacks
;
140 WMButton
*swi
[wlengthof_nocheck(expert_options
)];
142 WMTextField
*textfield
[wlengthof_nocheck(expert_options
)];
146 #define ICON_FILE "expert"
148 static void changeIntTextfield(void *data
, int delta
)
150 WMTextField
*textfield
;
151 char *text
, buffer
[12];
154 textfield
= (WMTextField
*)data
;
155 text
= WMGetTextFieldText(textfield
);
159 sprintf(buffer
, "%d", value
);
160 WMSetTextFieldText(textfield
, buffer
);
163 static void downButtonCallback(WMWidget
*self
, void *data
)
166 changeIntTextfield(data
, -1);
169 static void upButtonCallback(WMWidget
*self
, void *data
)
172 changeIntTextfield(data
, 1);
175 static int cmpExpertOptions(const void *v1
, const void *v2
)
178 const struct expert_option
*opt1
= (struct expert_option
*)v1
;
179 const struct expert_option
*opt2
= (struct expert_option
*)v2
;
181 if ((rc
= strcmp(opt1
->label
, opt2
->label
)) < 0)
188 static void createPanel(Panel
*p
)
190 _Panel
*panel
= (_Panel
*) p
;
196 panel
->box
= WMCreateBox(panel
->parent
);
197 WMSetViewExpandsToParent(WMWidgetView(panel
->box
), 2, 2, 2, 2);
199 sv
= WMCreateScrollView(panel
->box
);
200 WMResizeWidget(sv
, 500, 215);
201 WMMoveWidget(sv
, 12, 10);
202 WMSetScrollViewRelief(sv
, WRSunken
);
203 WMSetScrollViewHasVerticalScroller(sv
, True
);
204 WMSetScrollViewHasHorizontalScroller(sv
, False
);
206 f
= WMCreateFrame(panel
->box
);
207 WMResizeWidget(f
, 495, wlengthof(expert_options
) * 25 + 8);
208 WMSetFrameRelief(f
, WRFlat
);
210 udb
= WMGetStandardUserDefaults();
211 qsort(expert_options
, wlengthof(expert_options
), sizeof(expert_options
[0]), cmpExpertOptions
);
212 for (i
= 0; i
< wlengthof(expert_options
); i
++) {
213 if (expert_options
[i
].class != OPTION_WMAKER_INT
) {
214 panel
->swi
[i
] = WMCreateSwitchButton(f
);
215 WMResizeWidget(panel
->swi
[i
], FRAME_WIDTH
- 40, 25);
216 WMMoveWidget(panel
->swi
[i
], 5, 5 + i
* 25);
218 WMSetButtonText(panel
->swi
[i
], _(expert_options
[i
].label
));
221 switch (expert_options
[i
].class) {
223 if (GetStringForKey(expert_options
[i
].op_name
))
224 state
= GetBoolForKey(expert_options
[i
].op_name
);
226 state
= expert_options
[i
].def_state
;
229 case OPTION_WMAKER_ARRAY
: {
230 char *str
= GetStringForKey(expert_options
[i
].op_name
);
231 state
= expert_options
[i
].def_state
;
232 if (str
&& strcasecmp(str
, "None") == 0)
238 state
= WMGetUDBoolForKey(udb
, expert_options
[i
].op_name
);
241 case OPTION_WMAKER_INT
:
247 panel
->textfield
[i
] = WMCreateTextField(f
);
248 WMResizeWidget(panel
->textfield
[i
], 41, 20);
249 WMMoveWidget(panel
->textfield
[i
], 22, 7 + i
* 25);
251 down
= WMCreateCommandButton(f
);
252 WMSetButtonImage(down
, WMGetSystemPixmap(WMWidgetScreen(down
), WSIArrowDown
));
253 WMSetButtonAltImage(down
,
254 WMGetSystemPixmap(WMWidgetScreen(down
), WSIHighlightedArrowDown
));
255 WMSetButtonImagePosition(down
, WIPImageOnly
);
256 WMSetButtonAction(down
, downButtonCallback
, panel
->textfield
[i
]);
257 WMResizeWidget(down
, 16, 16);
258 WMMoveWidget(down
, 5, 9 + i
* 25);
260 up
= WMCreateCommandButton(f
);
261 WMSetButtonImage(up
, WMGetSystemPixmap(WMWidgetScreen(up
), WSIArrowUp
));
262 WMSetButtonAltImage(up
, WMGetSystemPixmap(WMWidgetScreen(up
), WSIHighlightedArrowUp
));
263 WMSetButtonImagePosition(up
, WIPImageOnly
);
264 WMSetButtonAction(up
, upButtonCallback
, panel
->textfield
[i
]);
265 WMResizeWidget(up
, 16, 16);
266 WMMoveWidget(up
, 64, 9 + i
* 25);
268 label
= WMCreateLabel(f
);
269 WMSetLabelText(label
, _(expert_options
[i
].label
));
270 WMResizeWidget(label
, FRAME_WIDTH
- 99, 25);
271 WMMoveWidget(label
, 85, 5 + i
* 25);
273 if (GetStringForKey(expert_options
[i
].op_name
))
274 state
= GetIntegerForKey(expert_options
[i
].op_name
);
276 state
= expert_options
[i
].def_state
;
278 sprintf(tmp
, "%d", state
);
279 WMSetTextFieldText(panel
->textfield
[i
], tmp
);
286 wwarning("export_options[%d].class = %d, this should not happen\n",
287 i
, expert_options
[i
].class);
289 state
= expert_options
[i
].def_state
;
292 if (expert_options
[i
].class != OPTION_WMAKER_INT
)
293 WMSetButtonSelected(panel
->swi
[i
], state
);
296 WMMapSubwidgets(panel
->box
);
297 WMSetScrollViewContentView(sv
, WMWidgetView(f
));
298 WMRealizeWidget(panel
->box
);
301 static void storeDefaults(_Panel
*panel
)
303 WMUserDefaults
*udb
= WMGetStandardUserDefaults();
306 for (i
= 0; i
< wlengthof(expert_options
); i
++) {
307 switch (expert_options
[i
].class) {
309 SetBoolForKey(WMGetButtonSelected(panel
->swi
[i
]), expert_options
[i
].op_name
);
312 case OPTION_WMAKER_ARRAY
:
313 if (WMGetButtonSelected(panel
->swi
[i
])) {
314 /* check if the array was not manually modified */
315 char *str
= GetStringForKey(expert_options
[i
].op_name
);
316 if (str
&& strcasecmp(str
, "None") == 0)
317 RemoveObjectForKey(expert_options
[i
].op_name
);
320 SetStringForKey("None", expert_options
[i
].op_name
);
324 WMSetUDBoolForKey(udb
, WMGetButtonSelected(panel
->swi
[i
]), expert_options
[i
].op_name
);
327 case OPTION_WMAKER_INT
:
332 text
= WMGetTextFieldText(panel
->textfield
[i
]);
336 SetIntegerForKey(value
, expert_options
[i
].op_name
);
343 Panel
*InitExpert(WMWidget
*parent
)
347 panel
= wmalloc(sizeof(_Panel
));
349 panel
->sectionName
= _("Expert User Preferences");
351 panel
->description
= _("Options for people who know what they're doing...\n"
352 "Also has some other misc. options.");
354 panel
->parent
= parent
;
356 panel
->callbacks
.createWidgets
= createPanel
;
357 panel
->callbacks
.updateDomain
= storeDefaults
;
359 AddSection(panel
, ICON_FILE
);