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
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" }
122 typedef struct _Panel
{
128 CallbackRec callbacks
;
132 WMButton
*swi
[wlengthof_nocheck(expert_options
)];
134 WMTextField
*textfield
[wlengthof_nocheck(expert_options
)];
138 #define ICON_FILE "expert"
140 static void changeIntTextfield(void *data
, int delta
)
142 WMTextField
*textfield
;
146 textfield
= (WMTextField
*)data
;
147 text
= WMGetTextFieldText(textfield
);
150 sprintf(text
, "%d", value
);
151 WMSetTextFieldText(textfield
, text
);
154 static void downButtonCallback(WMWidget
*self
, void *data
)
157 changeIntTextfield(data
, -1);
160 static void upButtonCallback(WMWidget
*self
, void *data
)
163 changeIntTextfield(data
, 1);
166 static void createPanel(Panel
*p
)
168 _Panel
*panel
= (_Panel
*) p
;
174 panel
->box
= WMCreateBox(panel
->parent
);
175 WMSetViewExpandsToParent(WMWidgetView(panel
->box
), 2, 2, 2, 2);
177 sv
= WMCreateScrollView(panel
->box
);
178 WMResizeWidget(sv
, 500, 215);
179 WMMoveWidget(sv
, 12, 10);
180 WMSetScrollViewRelief(sv
, WRSunken
);
181 WMSetScrollViewHasVerticalScroller(sv
, True
);
182 WMSetScrollViewHasHorizontalScroller(sv
, False
);
184 f
= WMCreateFrame(panel
->box
);
185 WMResizeWidget(f
, 495, wlengthof(expert_options
) * 25 + 8);
186 WMSetFrameRelief(f
, WRFlat
);
188 udb
= WMGetStandardUserDefaults();
189 for (i
= 0; i
< wlengthof(expert_options
); i
++) {
190 if (expert_options
[i
].class != OPTION_WMAKER_INT
) {
191 panel
->swi
[i
] = WMCreateSwitchButton(f
);
192 WMResizeWidget(panel
->swi
[i
], FRAME_WIDTH
- 40, 25);
193 WMMoveWidget(panel
->swi
[i
], 5, 5 + i
* 25);
195 WMSetButtonText(panel
->swi
[i
], _(expert_options
[i
].label
));
198 switch (expert_options
[i
].class) {
200 if (GetStringForKey(expert_options
[i
].op_name
))
201 state
= GetBoolForKey(expert_options
[i
].op_name
);
203 state
= expert_options
[i
].def_state
;
206 case OPTION_WMAKER_ARRAY
: {
207 char *str
= GetStringForKey(expert_options
[i
].op_name
);
208 state
= expert_options
[i
].def_state
;
209 if (str
&& strcasecmp(str
, "None") == 0)
215 state
= WMGetUDBoolForKey(udb
, expert_options
[i
].op_name
);
218 case OPTION_WMAKER_INT
:
224 panel
->textfield
[i
] = WMCreateTextField(f
);
225 WMResizeWidget(panel
->textfield
[i
], 41, 20);
226 WMMoveWidget(panel
->textfield
[i
], 22, 7 + i
* 25);
228 down
= WMCreateCommandButton(f
);
229 WMSetButtonImage(down
, WMGetSystemPixmap(WMWidgetScreen(down
), WSIArrowDown
));
230 WMSetButtonAltImage(down
,
231 WMGetSystemPixmap(WMWidgetScreen(down
), WSIHighlightedArrowDown
));
232 WMSetButtonImagePosition(down
, WIPImageOnly
);
233 WMSetButtonAction(down
, downButtonCallback
, panel
->textfield
[i
]);
234 WMResizeWidget(down
, 16, 16);
235 WMMoveWidget(down
, 5, 9 + i
* 25);
237 up
= WMCreateCommandButton(f
);
238 WMSetButtonImage(up
, WMGetSystemPixmap(WMWidgetScreen(up
), WSIArrowUp
));
239 WMSetButtonAltImage(up
, WMGetSystemPixmap(WMWidgetScreen(up
), WSIHighlightedArrowUp
));
240 WMSetButtonImagePosition(up
, WIPImageOnly
);
241 WMSetButtonAction(up
, upButtonCallback
, panel
->textfield
[i
]);
242 WMResizeWidget(up
, 16, 16);
243 WMMoveWidget(up
, 64, 9 + i
* 25);
245 label
= WMCreateLabel(f
);
246 WMSetLabelText(label
, _(expert_options
[i
].label
));
247 WMResizeWidget(label
, FRAME_WIDTH
- 99, 25);
248 WMMoveWidget(label
, 85, 5 + i
* 25);
250 if (GetStringForKey(expert_options
[i
].op_name
))
251 state
= GetIntegerForKey(expert_options
[i
].op_name
);
253 state
= expert_options
[i
].def_state
;
255 sprintf(tmp
, "%d", state
);
256 WMSetTextFieldText(panel
->textfield
[i
], tmp
);
263 wwarning("export_options[%d].class = %d, this should not happen\n",
264 i
, expert_options
[i
].class);
266 state
= expert_options
[i
].def_state
;
269 if (expert_options
[i
].class != OPTION_WMAKER_INT
)
270 WMSetButtonSelected(panel
->swi
[i
], state
);
273 WMMapSubwidgets(panel
->box
);
274 WMSetScrollViewContentView(sv
, WMWidgetView(f
));
275 WMRealizeWidget(panel
->box
);
278 static void storeDefaults(_Panel
*panel
)
280 WMUserDefaults
*udb
= WMGetStandardUserDefaults();
283 for (i
= 0; i
< wlengthof(expert_options
); i
++) {
284 switch (expert_options
[i
].class) {
286 SetBoolForKey(WMGetButtonSelected(panel
->swi
[i
]), expert_options
[i
].op_name
);
289 case OPTION_WMAKER_ARRAY
:
290 if (WMGetButtonSelected(panel
->swi
[i
])) {
291 /* check if the array was not manually modified */
292 char *str
= GetStringForKey(expert_options
[i
].op_name
);
293 if (str
&& strcasecmp(str
, "None") == 0)
294 RemoveObjectForKey(expert_options
[i
].op_name
);
297 SetStringForKey("None", expert_options
[i
].op_name
);
301 WMSetUDBoolForKey(udb
, WMGetButtonSelected(panel
->swi
[i
]), expert_options
[i
].op_name
);
304 case OPTION_WMAKER_INT
:
309 text
= WMGetTextFieldText(panel
->textfield
[i
]);
312 SetIntegerForKey(value
, expert_options
[i
].op_name
);
319 Panel
*InitExpert(WMWidget
*parent
)
323 panel
= wmalloc(sizeof(_Panel
));
325 panel
->sectionName
= _("Expert User Preferences");
327 panel
->description
= _("Options for people who know what they're doing...\n"
328 "Also has some other misc. options.");
330 panel
->parent
= parent
;
332 panel
->callbacks
.createWidgets
= createPanel
;
333 panel
->callbacks
.updateDomain
= storeDefaults
;
335 AddSection(panel
, ICON_FILE
);