Window Maker 0.95.4
[wmaker-crm.git] / WPrefs.app / Expert.c
blobd82bc6ff1bddd54b049e0288f77ebfa0c3f1b854
1 /* Expert.c- expert user options
3 * WPrefs - Window Maker Preferences Program
5 * Copyright (c) 1998-2003 Alfredo K. Kojima
7 * 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.
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.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "WPrefs.h"
24 /* This structure containts the list of all the check-buttons to display in the
25 * expert tab of the window with the corresponding information for effect
27 static const struct {
28 char *label; /* Text displayed to user */
30 int def_state; /* True/False: the default value, if not defined in current config */
32 enum {
33 OPTION_WMAKER,
34 OPTION_USERDEF
35 } class;
37 char *op_name; /* The identifier for the option in the config file */
39 } expert_options[] = {
41 { N_("Disable miniwindows (icons for minimized windows). For use with KDE/GNOME."),
42 /* default: */ False, OPTION_WMAKER, "DisableMiniwindows" },
44 { N_("Do not set non-WindowMaker specific parameters (do not use xset)."),
45 /* default: */ False, OPTION_USERDEF, "NoXSetStuff" },
47 { N_("Automatically save session when exiting Window Maker."),
48 /* default: */ False, OPTION_WMAKER, "SaveSessionOnExit" },
50 { N_("Use SaveUnder in window frames, icons, menus and other objects."),
51 /* default: */ False, OPTION_WMAKER, "UseSaveUnders" },
53 { N_("Disable confirmation panel for the Kill command."),
54 /* default: */ False, OPTION_WMAKER, "DontConfirmKill" },
56 { N_("Disable selection animation for selected icons."),
57 /* default: */ False, OPTION_WMAKER, "DisableBlinking" },
59 { N_("Smooth font edges (needs restart)."),
60 /* default: */ True, OPTION_WMAKER, "AntialiasedText" },
62 { N_("Cycle windows only on the active head."),
63 /* default: */ False, OPTION_WMAKER, "CycleActiveHeadOnly" },
65 { N_("Ignore minimized windows when cycling."),
66 /* default: */ False, OPTION_WMAKER, "CycleIgnoreMinimized" },
68 { N_("Show workspace title on Clip."),
69 /* default: */ True, OPTION_WMAKER, "ShowClipTitle" },
71 { N_("Highlight the icon of the application when it has the focus."),
72 /* default: */ True, OPTION_WMAKER, "HighlightActiveApp" },
74 #ifdef XKB_MODELOCK
75 { N_("Enable keyboard language switch button in window titlebars."),
76 /* default: */ False, OPTION_WMAKER, "KbdModeLock" }
77 #endif /* XKB_MODELOCK */
82 typedef struct _Panel {
83 WMBox *box;
84 char *sectionName;
86 char *description;
88 CallbackRec callbacks;
90 WMWidget *parent;
92 WMButton *swi[sizeof(expert_options) / sizeof(expert_options[0])];
94 } _Panel;
96 #define ICON_FILE "expert"
99 static void createPanel(Panel * p)
101 _Panel *panel = (_Panel *) p;
102 WMScrollView *sv;
103 WMFrame *f;
104 WMUserDefaults *udb;
105 int i, state;
107 panel->box = WMCreateBox(panel->parent);
108 WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);
110 sv = WMCreateScrollView(panel->box);
111 WMResizeWidget(sv, 500, 215);
112 WMMoveWidget(sv, 12, 10);
113 WMSetScrollViewRelief(sv, WRSunken);
114 WMSetScrollViewHasVerticalScroller(sv, True);
115 WMSetScrollViewHasHorizontalScroller(sv, False);
117 f = WMCreateFrame(panel->box);
118 WMResizeWidget(f, 495, (sizeof(expert_options) / sizeof(expert_options[0])) * 25 + 8);
119 WMSetFrameRelief(f, WRFlat);
121 udb = WMGetStandardUserDefaults();
122 for (i = 0; i < sizeof(expert_options) / sizeof(expert_options[0]); i++) {
123 panel->swi[i] = WMCreateSwitchButton(f);
124 WMResizeWidget(panel->swi[i], FRAME_WIDTH - 40, 25);
125 WMMoveWidget(panel->swi[i], 5, 5 + i * 25);
127 WMSetButtonText(panel->swi[i], _(expert_options[i].label));
129 switch (expert_options[i].class) {
130 case OPTION_WMAKER:
131 if (GetStringForKey(expert_options[i].op_name))
132 state = GetBoolForKey(expert_options[i].op_name);
133 else
134 state = expert_options[i].def_state;
135 break;
137 case OPTION_USERDEF:
138 state = WMGetUDBoolForKey(udb, expert_options[i].op_name);
139 break;
142 WMSetButtonSelected(panel->swi[i], state);
145 WMMapSubwidgets(panel->box);
146 WMSetScrollViewContentView(sv, WMWidgetView(f));
147 WMRealizeWidget(panel->box);
150 static void storeDefaults(_Panel * panel)
152 WMUserDefaults *udb = WMGetStandardUserDefaults();
153 int i;
155 for (i = 0; i < sizeof(expert_options) / sizeof(expert_options[0]); i++) {
156 switch (expert_options[i].class) {
157 case OPTION_WMAKER:
158 SetBoolForKey(WMGetButtonSelected(panel->swi[i]), expert_options[i].op_name);
159 break;
161 case OPTION_USERDEF:
162 WMSetUDBoolForKey(udb, WMGetButtonSelected(panel->swi[i]), expert_options[i].op_name);
163 break;
168 Panel *InitExpert(WMScreen * scr, WMWidget * parent)
170 _Panel *panel;
172 panel = wmalloc(sizeof(_Panel));
174 panel->sectionName = _("Expert User Preferences");
176 panel->description = _("Options for people who know what they're doing...\n"
177 "Also has some other misc. options.");
179 panel->parent = parent;
181 panel->callbacks.createWidgets = createPanel;
182 panel->callbacks.updateDomain = storeDefaults;
184 AddSection(panel, ICON_FILE);
186 return panel;