wmaker: Clear maximized flag of a maximized window when moved.
[wmaker-crm.git] / WPrefs.app / Expert.c
blobaee45fb9075639371215666cf53b107e9583c20a
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.
23 #include "WPrefs.h"
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 const struct {
29 const char *label; /* Text displayed to user */
31 int def_state; /* True/False: the default value, if not defined in current config */
33 enum {
34 OPTION_WMAKER,
35 OPTION_WMAKER_ARRAY,
36 OPTION_USERDEF
37 } class;
39 const char *op_name; /* The identifier for the option in the config file */
41 } expert_options[] = {
43 { N_("Disable miniwindows (icons for minimized windows). For use with KDE/GNOME."),
44 /* default: */ False, OPTION_WMAKER, "DisableMiniwindows" },
46 { N_("Do not set non-WindowMaker specific parameters (do not use xset)."),
47 /* default: */ False, OPTION_USERDEF, "NoXSetStuff" },
49 { N_("Automatically save session when exiting Window Maker."),
50 /* default: */ False, OPTION_WMAKER, "SaveSessionOnExit" },
52 { N_("Use SaveUnder in window frames, icons, menus and other objects."),
53 /* default: */ False, OPTION_WMAKER, "UseSaveUnders" },
55 { N_("Disable confirmation panel for the Kill command."),
56 /* default: */ False, OPTION_WMAKER, "DontConfirmKill" },
58 { N_("Disable selection animation for selected icons."),
59 /* default: */ False, OPTION_WMAKER, "DisableBlinking" },
61 { N_("Smooth font edges (needs restart)."),
62 /* default: */ True, OPTION_WMAKER, "AntialiasedText" },
64 { N_("Cycle windows only on the active head."),
65 /* default: */ False, OPTION_WMAKER, "CycleActiveHeadOnly" },
67 { N_("Ignore minimized windows when cycling."),
68 /* default: */ False, OPTION_WMAKER, "CycleIgnoreMinimized" },
70 { N_("Show switch panel when cycling windows."),
71 /* default: */ True, OPTION_WMAKER_ARRAY, "SwitchPanelImages" },
73 { N_("Show workspace title on Clip."),
74 /* default: */ True, OPTION_WMAKER, "ShowClipTitle" },
76 { N_("Highlight the icon of the application when it has the focus."),
77 /* default: */ True, OPTION_WMAKER, "HighlightActiveApp" },
79 #ifdef XKB_MODELOCK
80 { N_("Enable keyboard language switch button in window titlebars."),
81 /* default: */ False, OPTION_WMAKER, "KbdModeLock" }
82 #endif /* XKB_MODELOCK */
84 { N_("Enable window snapping."),
85 /* default: */ False, OPTION_WMAKER, "WindowSnapping" },
90 typedef struct _Panel {
91 WMBox *box;
92 char *sectionName;
94 char *description;
96 CallbackRec callbacks;
98 WMWidget *parent;
100 WMButton *swi[sizeof(expert_options) / sizeof(expert_options[0])];
102 } _Panel;
104 #define ICON_FILE "expert"
107 static void createPanel(Panel *p)
109 _Panel *panel = (_Panel *) p;
110 WMScrollView *sv;
111 WMFrame *f;
112 WMUserDefaults *udb;
113 int i, state;
115 panel->box = WMCreateBox(panel->parent);
116 WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);
118 sv = WMCreateScrollView(panel->box);
119 WMResizeWidget(sv, 500, 215);
120 WMMoveWidget(sv, 12, 10);
121 WMSetScrollViewRelief(sv, WRSunken);
122 WMSetScrollViewHasVerticalScroller(sv, True);
123 WMSetScrollViewHasHorizontalScroller(sv, False);
125 f = WMCreateFrame(panel->box);
126 WMResizeWidget(f, 495, wlengthof(expert_options) * 25 + 8);
127 WMSetFrameRelief(f, WRFlat);
129 udb = WMGetStandardUserDefaults();
130 for (i = 0; i < wlengthof(expert_options); i++) {
131 panel->swi[i] = WMCreateSwitchButton(f);
132 WMResizeWidget(panel->swi[i], FRAME_WIDTH - 40, 25);
133 WMMoveWidget(panel->swi[i], 5, 5 + i * 25);
135 WMSetButtonText(panel->swi[i], _(expert_options[i].label));
137 switch (expert_options[i].class) {
138 case OPTION_WMAKER:
139 if (GetStringForKey(expert_options[i].op_name))
140 state = GetBoolForKey(expert_options[i].op_name);
141 else
142 state = expert_options[i].def_state;
143 break;
145 case OPTION_WMAKER_ARRAY: {
146 char *str = GetStringForKey(expert_options[i].op_name);
147 state = expert_options[i].def_state;
148 if (str && strcasecmp(str, "None") == 0)
149 state = False;
151 break;
153 case OPTION_USERDEF:
154 state = WMGetUDBoolForKey(udb, expert_options[i].op_name);
155 break;
157 default:
158 #ifdef DEBUG
159 wwarning("export_options[%d].class = %d, this should not happen\n",
160 i, expert_options[i].class);
161 #endif
162 state = expert_options[i].def_state;
163 break;
165 WMSetButtonSelected(panel->swi[i], state);
168 WMMapSubwidgets(panel->box);
169 WMSetScrollViewContentView(sv, WMWidgetView(f));
170 WMRealizeWidget(panel->box);
173 static void storeDefaults(_Panel *panel)
175 WMUserDefaults *udb = WMGetStandardUserDefaults();
176 int i;
178 for (i = 0; i < wlengthof(expert_options); i++) {
179 switch (expert_options[i].class) {
180 case OPTION_WMAKER:
181 SetBoolForKey(WMGetButtonSelected(panel->swi[i]), expert_options[i].op_name);
182 break;
184 case OPTION_WMAKER_ARRAY:
185 if (WMGetButtonSelected(panel->swi[i])) {
186 /* check if the array was not manually modified */
187 char *str = GetStringForKey(expert_options[i].op_name);
188 if (str && strcasecmp(str, "None") == 0)
189 RemoveObjectForKey(expert_options[i].op_name);
191 else
192 SetStringForKey("None", expert_options[i].op_name);
193 break;
195 case OPTION_USERDEF:
196 WMSetUDBoolForKey(udb, WMGetButtonSelected(panel->swi[i]), expert_options[i].op_name);
197 break;
202 Panel *InitExpert(WMWidget *parent)
204 _Panel *panel;
206 panel = wmalloc(sizeof(_Panel));
208 panel->sectionName = _("Expert User Preferences");
210 panel->description = _("Options for people who know what they're doing...\n"
211 "Also has some other misc. options.");
213 panel->parent = parent;
215 panel->callbacks.createWidgets = createPanel;
216 panel->callbacks.updateDomain = storeDefaults;
218 AddSection(panel, ICON_FILE);
220 return panel;