Files
wmaker/WPrefs.app/Expert.c
T

185 lines
5.2 KiB
C
Raw Normal View History

1998-09-29 22:36:29 +00:00
/* Expert.c- expert user options
2004-10-12 21:28:27 +00:00
*
1998-10-21 14:43:47 +00:00
* WPrefs - Window Maker Preferences Program
2004-10-12 21:28:27 +00:00
*
2003-01-16 23:30:45 +00:00
* Copyright (c) 1998-2003 Alfredo K. Kojima
2004-10-12 21:28:27 +00:00
*
1998-09-29 22:36:29 +00:00
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1998-09-29 22:36:29 +00:00
*/
#include "WPrefs.h"
/* This structure containts the list of all the check-buttons to display in the
* expert tab of the window with the corresponding information for effect
*/
static const struct {
char *label; /* Text displayed to user */
int def_state; /* True/False: the default value, if not defined in current config */
enum {
OPTION_WMAKER,
OPTION_USERDEF
} class;
char *op_name; /* The identifier for the option in the config file */
} expert_options[] = {
{ N_("Disable miniwindows (icons for minimized windows). For use with KDE/GNOME."),
/* default: */ False, OPTION_WMAKER, "DisableMiniwindows" },
{ N_("Do not set non-WindowMaker specific parameters (do not use xset)."),
/* default: */ False, OPTION_USERDEF, "NoXSetStuff" },
{ N_("Automatically save session when exiting Window Maker."),
/* default: */ False, OPTION_WMAKER, "SaveSessionOnExit" },
{ N_("Use SaveUnder in window frames, icons, menus and other objects."),
/* default: */ False, OPTION_WMAKER, "UseSaveUnders" },
{ N_("Disable confirmation panel for the Kill command."),
/* default: */ False, OPTION_WMAKER, "DontConfirmKill" },
{ N_("Disable selection animation for selected icons."),
/* default: */ False, OPTION_WMAKER, "DisableBlinking" },
{ N_("Smooth font edges (needs restart)."),
/* default: */ True, OPTION_WMAKER, "AntialiasedText" },
{ N_("Cycle windows only on the active head."),
/* default: */ False, OPTION_WMAKER, "CycleActiveHeadOnly" },
{ N_("Show workspace title on Clip."),
/* default: */ True, OPTION_WMAKER, "ShowClipTitle" },
{ N_("Highlight the icon of the application when it has the focus."),
/* default: */ True, OPTION_WMAKER, "HighlightActiveApp" },
#ifdef XKB_MODELOCK
{ N_("Enable keyboard language switch button in window titlebars."),
/* default: */ False, OPTION_WMAKER, "KbdModeLock" }
#endif /* XKB_MODELOCK */
};
1998-09-29 22:36:29 +00:00
typedef struct _Panel {
2009-08-20 00:59:40 +02:00
WMBox *box;
char *sectionName;
1999-04-25 01:49:46 +00:00
2009-08-20 00:59:40 +02:00
char *description;
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
CallbackRec callbacks;
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
WMWidget *parent;
1998-09-29 22:36:29 +00:00
WMButton *swi[sizeof(expert_options) / sizeof(expert_options[0])];
1998-09-29 22:36:29 +00:00
} _Panel;
#define ICON_FILE "expert"
2009-08-20 00:59:40 +02:00
static void createPanel(Panel * p)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
_Panel *panel = (_Panel *) p;
2010-04-02 12:05:53 +02:00
WMScrollView *sv;
WMFrame *f;
WMUserDefaults *udb;
int i, state;
2009-08-20 00:59:40 +02:00
panel->box = WMCreateBox(panel->parent);
WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);
1998-09-29 22:36:29 +00:00
2010-04-02 12:05:53 +02:00
sv = WMCreateScrollView(panel->box);
WMResizeWidget(sv, 500, 215);
WMMoveWidget(sv, 12, 10);
WMSetScrollViewRelief(sv, WRSunken);
WMSetScrollViewHasVerticalScroller(sv, True);
WMSetScrollViewHasHorizontalScroller(sv, False);
f = WMCreateFrame(panel->box);
WMResizeWidget(f, 495, (sizeof(expert_options) / sizeof(expert_options[0])) * 25 + 8);
2010-04-02 12:05:53 +02:00
WMSetFrameRelief(f, WRFlat);
udb = WMGetStandardUserDefaults();
for (i = 0; i < sizeof(expert_options) / sizeof(expert_options[0]); i++) {
2010-04-02 12:05:53 +02:00
panel->swi[i] = WMCreateSwitchButton(f);
2009-08-20 00:59:40 +02:00
WMResizeWidget(panel->swi[i], FRAME_WIDTH - 40, 25);
2010-04-02 12:05:53 +02:00
WMMoveWidget(panel->swi[i], 5, 5 + i * 25);
2004-10-12 21:28:27 +00:00
WMSetButtonText(panel->swi[i], _(expert_options[i].label));
switch (expert_options[i].class) {
case OPTION_WMAKER:
if (GetStringForKey(expert_options[i].op_name))
state = GetBoolForKey(expert_options[i].op_name);
else
state = expert_options[i].def_state;
break;
case OPTION_USERDEF:
state = WMGetUDBoolForKey(udb, expert_options[i].op_name);
break;
}
WMSetButtonSelected(panel->swi[i], state);
}
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
WMMapSubwidgets(panel->box);
2010-04-02 12:05:53 +02:00
WMSetScrollViewContentView(sv, WMWidgetView(f));
WMRealizeWidget(panel->box);
1998-09-29 22:36:29 +00:00
}
2009-08-20 00:59:40 +02:00
static void storeDefaults(_Panel * panel)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
WMUserDefaults *udb = WMGetStandardUserDefaults();
int i;
1998-09-29 22:36:29 +00:00
for (i = 0; i < sizeof(expert_options) / sizeof(expert_options[0]); i++) {
switch (expert_options[i].class) {
case OPTION_WMAKER:
SetBoolForKey(WMGetButtonSelected(panel->swi[i]), expert_options[i].op_name);
break;
1998-09-29 22:36:29 +00:00
case OPTION_USERDEF:
WMSetUDBoolForKey(udb, WMGetButtonSelected(panel->swi[i]), expert_options[i].op_name);
break;
}
}
1998-09-29 22:36:29 +00:00
}
2009-08-20 00:59:40 +02:00
Panel *InitExpert(WMScreen * scr, WMWidget * parent)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
_Panel *panel;
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
panel = wmalloc(sizeof(_Panel));
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
panel->sectionName = _("Expert User Preferences");
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
panel->description = _("Options for people who know what they're doing...\n"
"Also has some other misc. options.");
1999-04-25 01:49:46 +00:00
2009-08-20 00:59:40 +02:00
panel->parent = parent;
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
panel->callbacks.createWidgets = createPanel;
panel->callbacks.updateDomain = storeDefaults;
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
AddSection(panel, ICON_FILE);
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
return panel;
1998-09-29 22:36:29 +00:00
}