Files
wmaker/src/wdefaults.c
T

563 lines
16 KiB
C
Raw Normal View History

1998-09-29 22:36:29 +00:00
/* wdefaults.c - window specific defaults
2004-10-12 21:28:27 +00:00
*
1998-10-21 14:43:47 +00:00
* Window Maker window manager
2004-10-12 21:28:27 +00:00
*
2003-01-16 23:30:45 +00:00
* Copyright (c) 1997-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 "wconfig.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
2011-03-24 16:07:20 +01:00
#include <strings.h>
1998-09-29 22:36:29 +00:00
#include <ctype.h>
2004-10-12 21:28:27 +00:00
1998-09-29 22:36:29 +00:00
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <wraster.h>
#include "WindowMaker.h"
#include "window.h"
#include "screen.h"
#include "funcs.h"
#include "workspace.h"
#include "defaults.h"
#include "icon.h"
2012-06-06 07:50:05 +02:00
#define APPLY_VAL(value, flag, attrib) \
if (value) {attr->flag = getBool(attrib, value); \
if (mask) mask->flag = 1;}
1998-09-29 22:36:29 +00:00
/* Global stuff */
extern WPreferences wPreferences;
extern WDDomain *WDWindowAttributes;
/* Local stuff */
/* type converters */
2009-08-20 00:59:40 +02:00
static int getBool(WMPropList *, WMPropList *);
static char *getString(WMPropList *, WMPropList *);
static WMPropList *ANoTitlebar = NULL;
static WMPropList *ANoResizebar;
static WMPropList *ANoMiniaturizeButton;
static WMPropList *ANoMiniaturizable;
static WMPropList *ANoCloseButton;
static WMPropList *ANoBorder;
static WMPropList *ANoHideOthers;
static WMPropList *ANoMouseBindings;
static WMPropList *ANoKeyBindings;
2009-08-20 00:59:40 +02:00
static WMPropList *ANoAppIcon; /* app */
static WMPropList *AKeepOnTop;
static WMPropList *AKeepOnBottom;
static WMPropList *AOmnipresent;
static WMPropList *ASkipWindowList;
static WMPropList *ASkipSwitchPanel;
static WMPropList *AKeepInsideScreen;
static WMPropList *AUnfocusable;
static WMPropList *AAlwaysUserIcon;
static WMPropList *AStartMiniaturized;
static WMPropList *AStartMaximized;
2009-08-20 00:59:40 +02:00
static WMPropList *AStartHidden; /* app */
static WMPropList *ADontSaveSession; /* app */
static WMPropList *AEmulateAppIcon;
2011-04-18 21:00:49 +02:00
static WMPropList *AFocusAcrossWorkspace;
static WMPropList *AFullMaximize;
2009-08-20 00:59:40 +02:00
static WMPropList *ASharedAppIcon; /* app */
#ifdef XKB_BUTTON_HINT
static WMPropList *ANoLanguageButton;
#endif
static WMPropList *AStartWorkspace;
static WMPropList *AIcon;
static WMPropList *AnyWindow;
static WMPropList *No;
1998-09-29 22:36:29 +00:00
static void init_wdefaults(void)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
AIcon = WMCreatePLString("Icon");
ANoTitlebar = WMCreatePLString("NoTitlebar");
ANoResizebar = WMCreatePLString("NoResizebar");
ANoMiniaturizeButton = WMCreatePLString("NoMiniaturizeButton");
ANoMiniaturizable = WMCreatePLString("NoMiniaturizable");
2009-08-20 00:59:40 +02:00
ANoCloseButton = WMCreatePLString("NoCloseButton");
ANoBorder = WMCreatePLString("NoBorder");
ANoHideOthers = WMCreatePLString("NoHideOthers");
ANoMouseBindings = WMCreatePLString("NoMouseBindings");
ANoKeyBindings = WMCreatePLString("NoKeyBindings");
ANoAppIcon = WMCreatePLString("NoAppIcon");
AKeepOnTop = WMCreatePLString("KeepOnTop");
AKeepOnBottom = WMCreatePLString("KeepOnBottom");
AOmnipresent = WMCreatePLString("Omnipresent");
ASkipWindowList = WMCreatePLString("SkipWindowList");
ASkipSwitchPanel = WMCreatePLString("SkipSwitchPanel");
2009-08-20 00:59:40 +02:00
AKeepInsideScreen = WMCreatePLString("KeepInsideScreen");
AUnfocusable = WMCreatePLString("Unfocusable");
AAlwaysUserIcon = WMCreatePLString("AlwaysUserIcon");
AStartMiniaturized = WMCreatePLString("StartMiniaturized");
AStartHidden = WMCreatePLString("StartHidden");
AStartMaximized = WMCreatePLString("StartMaximized");
ADontSaveSession = WMCreatePLString("DontSaveSession");
AEmulateAppIcon = WMCreatePLString("EmulateAppIcon");
2011-04-18 21:00:49 +02:00
AFocusAcrossWorkspace = WMCreatePLString("FocusAcrossWorkspace");
2009-08-20 00:59:40 +02:00
AFullMaximize = WMCreatePLString("FullMaximize");
ASharedAppIcon = WMCreatePLString("SharedAppIcon");
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
ANoLanguageButton = WMCreatePLString("NoLanguageButton");
#endif
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
AStartWorkspace = WMCreatePLString("StartWorkspace");
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
AnyWindow = WMCreatePLString("*");
No = WMCreatePLString("No");
1998-09-29 22:36:29 +00:00
}
2012-06-06 07:50:05 +02:00
/* Returns the correct WMPropList, using instance+class or instance, or class, or default */
2009-08-20 00:59:40 +02:00
static WMPropList *get_value(WMPropList * dict_win, WMPropList * dict_class, WMPropList * dict_name,
WMPropList * dict_any, WMPropList * option, WMPropList * default_value,
Bool useGlobalDefault)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
WMPropList *value;
if (dict_win) {
value = WMGetFromPLDictionary(dict_win, option);
if (value)
return value;
}
if (dict_name) {
value = WMGetFromPLDictionary(dict_name, option);
if (value)
return value;
}
if (dict_class) {
value = WMGetFromPLDictionary(dict_class, option);
if (value)
return value;
}
if (!useGlobalDefault)
return NULL;
if (dict_any) {
value = WMGetFromPLDictionary(dict_any, option);
if (value)
return value;
}
return default_value;
1998-09-29 22:36:29 +00:00
}
2012-06-06 07:50:05 +02:00
static WMPropList *get_value_from_instanceclass(char *value)
{
WMPropList *key, *val = NULL;
if (!value)
return NULL;
key = WMCreatePLString(value);
WMPLSetCaseSensitive(True);
if (WDWindowAttributes->dictionary)
val = key ? WMGetFromPLDictionary(WDWindowAttributes->dictionary, key) : NULL;
if (key)
WMReleasePropList(key);
WMPLSetCaseSensitive(False);
return val;
}
1999-01-06 15:22:33 +00:00
/*
*----------------------------------------------------------------------
* wDefaultFillAttributes--
* Retrieves attributes for the specified instance/class and
* fills attr with it. Values that are actually defined are also
* set in mask. If useGlobalDefault is True, the default for
* all windows ("*") will be used for when no values are found
2004-10-12 21:28:27 +00:00
* for that instance/class.
*
1999-01-06 15:22:33 +00:00
*----------------------------------------------------------------------
*/
void wDefaultFillAttributes(char *instance, char *class,
WWindowAttributes *attr, WWindowAttributes *mask,
Bool useGlobalDefault)
1998-09-29 22:36:29 +00:00
{
2012-06-06 07:50:05 +02:00
WMPropList *value, *dw, *dc, *dn, *da;
char *buffer;
2009-08-20 00:59:40 +02:00
2012-06-06 07:50:05 +02:00
dw = dc = dn = da = NULL;
2009-08-20 00:59:40 +02:00
2012-06-06 07:50:05 +02:00
if (!ANoTitlebar)
init_wdefaults();
2012-06-06 07:50:05 +02:00
if (class && instance) {
buffer = StrConcatDot(instance, class);
dw = get_value_from_instanceclass(buffer);
2009-08-20 00:59:40 +02:00
wfree(buffer);
}
2012-06-06 07:50:05 +02:00
dn = get_value_from_instanceclass(instance);
dc = get_value_from_instanceclass(class);
2009-08-20 00:59:40 +02:00
WMPLSetCaseSensitive(True);
2012-06-06 07:50:05 +02:00
if ((WDWindowAttributes->dictionary) && (useGlobalDefault))
da = WMGetFromPLDictionary(WDWindowAttributes->dictionary, AnyWindow);
1999-01-06 15:22:33 +00:00
2009-08-20 00:59:40 +02:00
/* get the data */
value = get_value(dw, dc, dn, da, ANoTitlebar, No, useGlobalDefault);
APPLY_VAL(value, no_titlebar, ANoTitlebar);
2001-12-17 04:02:33 +00:00
2009-08-20 00:59:40 +02:00
value = get_value(dw, dc, dn, da, ANoResizebar, No, useGlobalDefault);
APPLY_VAL(value, no_resizebar, ANoResizebar);
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
value = get_value(dw, dc, dn, da, ANoMiniaturizeButton, No, useGlobalDefault);
APPLY_VAL(value, no_miniaturize_button, ANoMiniaturizeButton);
2001-12-17 04:02:33 +00:00
value = get_value(dw, dc, dn, da, ANoMiniaturizable, No, useGlobalDefault);
APPLY_VAL(value, no_miniaturizable, ANoMiniaturizable);
2009-08-20 00:59:40 +02:00
value = get_value(dw, dc, dn, da, ANoCloseButton, No, useGlobalDefault);
APPLY_VAL(value, no_close_button, ANoCloseButton);
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
value = get_value(dw, dc, dn, da, ANoBorder, No, useGlobalDefault);
APPLY_VAL(value, no_border, ANoBorder);
2000-01-14 16:30:56 +00:00
2009-08-20 00:59:40 +02:00
value = get_value(dw, dc, dn, da, ANoHideOthers, No, useGlobalDefault);
APPLY_VAL(value, no_hide_others, ANoHideOthers);
2001-12-17 04:02:33 +00:00
2009-08-20 00:59:40 +02:00
value = get_value(dw, dc, dn, da, ANoMouseBindings, No, useGlobalDefault);
APPLY_VAL(value, no_bind_mouse, ANoMouseBindings);
2001-12-17 04:02:33 +00:00
2009-08-20 00:59:40 +02:00
value = get_value(dw, dc, dn, da, ANoKeyBindings, No, useGlobalDefault);
APPLY_VAL(value, no_bind_keys, ANoKeyBindings);
2001-12-17 04:02:33 +00:00
2009-08-20 00:59:40 +02:00
value = get_value(dw, dc, dn, da, ANoAppIcon, No, useGlobalDefault);
APPLY_VAL(value, no_appicon, ANoAppIcon);
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
value = get_value(dw, dc, dn, da, ASharedAppIcon, No, useGlobalDefault);
APPLY_VAL(value, shared_appicon, ASharedAppIcon);
2001-12-17 04:02:33 +00:00
2009-08-20 00:59:40 +02:00
value = get_value(dw, dc, dn, da, AKeepOnTop, No, useGlobalDefault);
APPLY_VAL(value, floating, AKeepOnTop);
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
value = get_value(dw, dc, dn, da, AKeepOnBottom, No, useGlobalDefault);
APPLY_VAL(value, sunken, AKeepOnBottom);
1998-11-23 11:32:19 +00:00
2009-08-20 00:59:40 +02:00
value = get_value(dw, dc, dn, da, AOmnipresent, No, useGlobalDefault);
APPLY_VAL(value, omnipresent, AOmnipresent);
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
value = get_value(dw, dc, dn, da, ASkipWindowList, No, useGlobalDefault);
APPLY_VAL(value, skip_window_list, ASkipWindowList);
2004-10-12 21:28:27 +00:00
value = get_value(dw, dc, dn, da, ASkipSwitchPanel, No, useGlobalDefault);
APPLY_VAL(value, skip_switchpanel, ASkipSwitchPanel);
2009-08-20 00:59:40 +02:00
value = get_value(dw, dc, dn, da, AKeepInsideScreen, No, useGlobalDefault);
APPLY_VAL(value, dont_move_off, AKeepInsideScreen);
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
value = get_value(dw, dc, dn, da, AUnfocusable, No, useGlobalDefault);
APPLY_VAL(value, no_focusable, AUnfocusable);
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
value = get_value(dw, dc, dn, da, AAlwaysUserIcon, No, useGlobalDefault);
APPLY_VAL(value, always_user_icon, AAlwaysUserIcon);
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
value = get_value(dw, dc, dn, da, AStartMiniaturized, No, useGlobalDefault);
APPLY_VAL(value, start_miniaturized, AStartMiniaturized);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
value = get_value(dw, dc, dn, da, AStartHidden, No, useGlobalDefault);
APPLY_VAL(value, start_hidden, AStartHidden);
1999-01-06 15:22:33 +00:00
2009-08-20 00:59:40 +02:00
value = get_value(dw, dc, dn, da, AStartMaximized, No, useGlobalDefault);
APPLY_VAL(value, start_maximized, AStartMaximized);
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
value = get_value(dw, dc, dn, da, ADontSaveSession, No, useGlobalDefault);
APPLY_VAL(value, dont_save_session, ADontSaveSession);
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
value = get_value(dw, dc, dn, da, AEmulateAppIcon, No, useGlobalDefault);
APPLY_VAL(value, emulate_appicon, AEmulateAppIcon);
1998-09-29 22:36:29 +00:00
2011-04-18 21:00:49 +02:00
value = get_value(dw, dc, dn, da, AFocusAcrossWorkspace, No, useGlobalDefault);
APPLY_VAL(value, focus_across_wksp, AFocusAcrossWorkspace);
2009-08-20 00:59:40 +02:00
value = get_value(dw, dc, dn, da, AFullMaximize, No, useGlobalDefault);
APPLY_VAL(value, full_maximize, AFullMaximize);
1999-03-09 14:58:01 +00:00
#ifdef XKB_BUTTON_HINT
2009-08-20 00:59:40 +02:00
value = get_value(dw, dc, dn, da, ANoLanguageButton, No, useGlobalDefault);
APPLY_VAL(value, no_language_button, ANoLanguageButton);
#endif
2009-08-20 00:59:40 +02:00
/* clean up */
WMPLSetCaseSensitive(False);
1998-09-29 22:36:29 +00:00
}
static WMPropList *get_generic_value(char *instance, char *class,
2010-04-12 23:31:59 +02:00
WMPropList *option, Bool noDefault)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
WMPropList *value, *key, *dict;
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
value = NULL;
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
WMPLSetCaseSensitive(True);
1998-09-29 22:36:29 +00:00
2012-03-30 15:35:19 +02:00
/* Search the icon name using class and instance */
2009-08-20 00:59:40 +02:00
if (class && instance) {
char *buffer;
2001-10-10 18:52:14 +00:00
2009-08-20 00:59:40 +02:00
buffer = wmalloc(strlen(class) + strlen(instance) + 2);
sprintf(buffer, "%s.%s", instance, class);
key = WMCreatePLString(buffer);
wfree(buffer);
1999-09-16 02:58:56 +00:00
2009-08-20 00:59:40 +02:00
dict = WMGetFromPLDictionary(WDWindowAttributes->dictionary, key);
WMReleasePropList(key);
1998-09-29 22:36:29 +00:00
2012-03-30 15:35:19 +02:00
if (dict)
2009-08-20 00:59:40 +02:00
value = WMGetFromPLDictionary(dict, option);
}
1998-09-29 22:36:29 +00:00
2012-03-30 15:35:19 +02:00
/* Search the icon name using instance */
2009-08-20 00:59:40 +02:00
if (!value && instance) {
key = WMCreatePLString(instance);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
dict = WMGetFromPLDictionary(WDWindowAttributes->dictionary, key);
WMReleasePropList(key);
2012-03-30 15:35:19 +02:00
if (dict)
2009-08-20 00:59:40 +02:00
value = WMGetFromPLDictionary(dict, option);
}
1998-09-29 22:36:29 +00:00
2012-03-30 15:35:19 +02:00
/* Search the icon name using class */
2009-08-20 00:59:40 +02:00
if (!value && class) {
key = WMCreatePLString(class);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
dict = WMGetFromPLDictionary(WDWindowAttributes->dictionary, key);
WMReleasePropList(key);
2004-10-12 21:28:27 +00:00
2012-03-30 15:35:19 +02:00
if (dict)
2009-08-20 00:59:40 +02:00
value = WMGetFromPLDictionary(dict, option);
}
1998-09-29 22:36:29 +00:00
2012-03-30 15:35:19 +02:00
/* Search the default icon name - See noDefault argument! */
2009-08-20 00:59:40 +02:00
if (!value && !noDefault) {
2012-03-30 15:35:19 +02:00
/* AnyWindow is "*" - see wdefaults.c */
2009-08-20 00:59:40 +02:00
dict = WMGetFromPLDictionary(WDWindowAttributes->dictionary, AnyWindow);
2004-10-12 21:28:27 +00:00
2012-03-30 15:35:19 +02:00
if (dict)
2009-08-20 00:59:40 +02:00
value = WMGetFromPLDictionary(dict, option);
}
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
WMPLSetCaseSensitive(False);
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
return value;
1998-09-29 22:36:29 +00:00
}
2012-02-14 13:13:55 +00:00
RImage *wDefaultGetImage(WScreen * scr, char *winstance, char *wclass, int max_size)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
char *file_name;
char *path;
RImage *image;
1998-09-29 22:36:29 +00:00
2012-03-30 15:35:19 +02:00
/* Get the file name of the image, using instance and class */
file_name = wDefaultGetIconFile(winstance, wclass, False);
2009-08-20 00:59:40 +02:00
if (!file_name)
return NULL;
2004-10-12 21:28:27 +00:00
2012-03-30 15:35:19 +02:00
/* Search the file image in the icon paths */
2009-08-20 00:59:40 +02:00
path = FindImage(wPreferences.icon_path, file_name);
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
if (!path) {
wwarning(_("could not find icon file \"%s\""), file_name);
return NULL;
}
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
image = RLoadImage(scr->rcontext, path, 0);
2012-03-30 15:35:19 +02:00
if (!image)
wwarning(_("error loading image file \"%s\": %s"), path, RMessageForError(RErrorCode));
2012-03-30 15:35:19 +02:00
2009-08-20 00:59:40 +02:00
wfree(path);
1998-09-29 22:36:29 +00:00
2012-02-14 13:13:55 +00:00
image = wIconValidateIconSize(scr, image, max_size);
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
return image;
1998-09-29 22:36:29 +00:00
}
2009-08-20 00:59:40 +02:00
int wDefaultGetStartWorkspace(WScreen * scr, char *instance, char *class)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
WMPropList *value;
int w;
2009-08-20 00:59:40 +02:00
char *tmp;
1998-09-29 22:36:29 +00:00
2012-03-30 15:35:19 +02:00
if (!ANoTitlebar)
init_wdefaults();
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
if (!WDWindowAttributes->dictionary)
return -1;
2004-10-12 21:28:27 +00:00
value = get_generic_value(instance, class, AStartWorkspace, False);
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
if (!value)
return -1;
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
tmp = getString(AStartWorkspace, value);
1998-09-29 22:36:29 +00:00
2009-08-20 00:59:40 +02:00
if (!tmp || strlen(tmp) == 0)
return -1;
1999-04-10 18:27:21 +00:00
/* Get the workspace number for the workspace name */
w = wGetWorkspaceNumber(scr, tmp);
2009-08-20 00:59:40 +02:00
return w;
1998-09-29 22:36:29 +00:00
}
/* Get the name of the Icon File. If noDefault is False, then, default value included */
char *wDefaultGetIconFile(char *instance, char *class, Bool noDefault)
{
WMPropList *value;
char *tmp;
if (!ANoTitlebar)
init_wdefaults();
if (!WDWindowAttributes->dictionary)
return NULL;
value = get_generic_value(instance, class, AIcon, noDefault);
if (!value)
return NULL;
tmp = getString(AIcon, value);
return tmp;
}
2009-08-20 00:59:40 +02:00
void wDefaultChangeIcon(WScreen * scr, char *instance, char *class, char *file)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
WDDomain *db = WDWindowAttributes;
WMPropList *icon_value = NULL, *value, *attr, *key, *def_win, *def_icon = NULL;
WMPropList *dict = db->dictionary;
int same = 0;
if (!dict) {
dict = WMCreatePLDictionary(NULL, NULL);
2012-03-30 15:35:19 +02:00
if (dict)
2009-08-20 00:59:40 +02:00
db->dictionary = dict;
2012-03-30 15:35:19 +02:00
else
2009-08-20 00:59:40 +02:00
return;
}
WMPLSetCaseSensitive(True);
if (instance && class) {
char *buffer;
2012-06-06 07:50:05 +02:00
buffer = StrConcatDot(instance, class);
2009-08-20 00:59:40 +02:00
key = WMCreatePLString(buffer);
wfree(buffer);
} else if (instance) {
key = WMCreatePLString(instance);
} else if (class) {
key = WMCreatePLString(class);
} else {
key = WMRetainPropList(AnyWindow);
}
if (file) {
value = WMCreatePLString(file);
icon_value = WMCreatePLDictionary(AIcon, value, NULL);
WMReleasePropList(value);
2012-03-30 15:35:19 +02:00
if ((def_win = WMGetFromPLDictionary(dict, AnyWindow)) != NULL)
2009-08-20 00:59:40 +02:00
def_icon = WMGetFromPLDictionary(def_win, AIcon);
if (def_icon && !strcmp(WMGetFromPLString(def_icon), file))
same = 1;
}
if ((attr = WMGetFromPLDictionary(dict, key)) != NULL) {
if (WMIsPLDictionary(attr)) {
if (icon_value != NULL && !same)
WMMergePLDictionaries(attr, icon_value, False);
else
WMRemoveFromPLDictionary(attr, AIcon);
}
} else if (icon_value != NULL && !same) {
WMPutInPLDictionary(dict, key, icon_value);
}
2012-03-30 15:35:19 +02:00
if (!wPreferences.flags.noupdates)
2009-08-20 00:59:40 +02:00
UpdateDomainFile(db);
WMReleasePropList(key);
if (icon_value)
WMReleasePropList(icon_value);
WMPLSetCaseSensitive(False);
1998-09-29 22:36:29 +00:00
}
/* --------------------------- Local ----------------------- */
2009-08-20 00:59:40 +02:00
static int getBool(WMPropList * key, WMPropList * value)
1998-09-29 22:36:29 +00:00
{
2009-08-20 00:59:40 +02:00
char *val;
if (!WMIsPLString(value)) {
wwarning(_("Wrong option format for key \"%s\". Should be %s."),
WMGetFromPLString(key), "Boolean");
return 0;
}
val = WMGetFromPLString(value);
if ((val[1] == '\0' && (val[0] == 'y' || val[0] == 'Y' || val[0] == 'T' || val[0] == 't' || val[0] == '1'))
|| (strcasecmp(val, "YES") == 0 || strcasecmp(val, "TRUE") == 0)) {
return 1;
} else if ((val[1] == '\0'
&& (val[0] == 'n' || val[0] == 'N' || val[0] == 'F' || val[0] == 'f' || val[0] == '0'))
|| (strcasecmp(val, "NO") == 0 || strcasecmp(val, "FALSE") == 0)) {
return 0;
} else {
wwarning(_("can't convert \"%s\" to boolean"), val);
/* We return False if we can't convert to BOOLEAN.
* This is because all options defaults to False.
* -1 is not checked and thus is interpreted as True,
* which is not good.*/
return 0;
}
1998-09-29 22:36:29 +00:00
}
2004-10-12 21:28:27 +00:00
/* WARNING: Do not free the value returned by this function!! */
2009-08-20 00:59:40 +02:00
static char *getString(WMPropList * key, WMPropList * value)
2004-10-12 21:28:27 +00:00
{
2009-08-20 00:59:40 +02:00
if (!WMIsPLString(value)) {
wwarning(_("Wrong option format for key \"%s\". Should be %s."), WMGetFromPLString(key), "String");
return NULL;
}
2004-10-12 21:28:27 +00:00
2009-08-20 00:59:40 +02:00
return WMGetFromPLString(value);
1998-09-29 22:36:29 +00:00
}