Wed Apr 5 21:48:39 PDT 2000 Michael Jennings <mej@eterm.org>

There are now two different sets of settings you can save.  You can
	save user settings, which are the things that one would generally
	consider to be user-specific (toggles, text colors, etc.).  You can
	also save theme settings, which saves *everything*, including the
	stuff that user settings don't include (like imageclasses, menus,
	etc.).  Settings are saved to user.cfg and theme.cfg, respectively.

	Also, Eterm will now detect if it cannot write to the location from
	which it got the theme (i.e., a system-wide directory), and will fall
	back on ~/.Eterm/themes/<theme>.  It WILL create this directory tree
	if it does not already exist.

	Hopefully this will make more people happy. :-)


SVN revision: 2440
This commit is contained in:
Michael Jennings 2000-04-06 04:52:52 +00:00
parent d922e2ce53
commit ac4f703548
17 changed files with 494 additions and 298 deletions

View File

@ -3414,3 +3414,20 @@ Mon Apr 3 16:42:06 PDT 2000 Michael Jennings <mej@eterm.org>
Added a --buttonbar option to force on/off all your buttonbars.
-------------------------------------------------------------------------------
Wed Apr 5 21:48:39 PDT 2000 Michael Jennings <mej@eterm.org>
There are now two different sets of settings you can save. You can
save user settings, which are the things that one would generally
consider to be user-specific (toggles, text colors, etc.). You can
also save theme settings, which saves *everything*, including the
stuff that user settings don't include (like imageclasses, menus,
etc.). Settings are saved to user.cfg and theme.cfg, respectively.
Also, Eterm will now detect if it cannot write to the location from
which it got the theme (i.e., a system-wide directory), and will fall
back on ~/.Eterm/themes/<theme>. It WILL create this directory tree
if it does not already exist.
Hopefully this will make more people happy. :-)
-------------------------------------------------------------------------------

View File

@ -329,6 +329,7 @@
#undef KS_HOME
#undef KS_END
#undef CONFIG_BUFF
#undef PKGDATADIR
/* Leave that blank line there!! Autoheader needs it.

View File

@ -655,6 +655,9 @@ AC_PREFIX(gcc)
if test "$prefix" = "NONE"; then
prefix=$ac_default_prefix
fi
if test "$exec_prefix" = "NONE"; then
exec_prefix=$prefix
fi
dnl Stack Tracing toys
AC_ARG_ENABLE(stack-trace, [ --disable-stack-trace disable stack trace on abnormal termination],
@ -708,7 +711,15 @@ AC_CHECK_LIB(Kenny, life_signs, , [
])
fi
AC_DEFINE_UNQUOTED(CONFIG_SEARCH_PATH, "~/.Eterm/themes:~/.Eterm:${prefix}/share/Eterm/themes:${prefix}/share/Eterm")
CONFIG_SEARCH_PATH=`eval eval eval eval eval echo "${datadir}/$PACKAGE/themes:${datadir}/$PACKAGE"`
AC_DEFINE_UNQUOTED(CONFIG_SEARCH_PATH, "~/.Eterm/themes:~/.Eterm:$CONFIG_SEARCH_PATH")
# Do replacements on theme files and such. All variables to be replaced
# by this routine MUST be exported before the awk script runs.
if test "X$PKGDATADIR" = "X" ; then
PKGDATADIR=`eval eval eval eval echo "$datadir/$PACKAGE"`
fi
export PKGDATADIR
AC_DEFINE_UNQUOTED(PKGDATADIR, "$PKGDATADIR")
CFLAGS=${CFLAGS--O}
LDFLAGS=${LDFLAGS--O}
@ -729,12 +740,6 @@ AM_CONFIG_HEADER(config.h)
AC_OUTPUT(Makefile bg/Makefile doc/Makefile utils/Makefile libmej/Makefile
pix/Makefile src/Makefile themes/Makefile Eterm.spec)
# Do replacements on theme files and such. All variables to be replaced
# by this routine MUST be exported before the awk script runs.
if test "X$PKGDATADIR" = "X" ; then
PKGDATADIR=`eval eval eval eval echo "$datadir/$PACKAGE"`
fi
export PKGDATADIR
# Mega evals to make sure all the relative variables get resolved.
BINDIR=`eval eval eval eval echo ${bindir}`
export BINDIR bindir prefix exec_prefix datadir PACKAGE

View File

@ -154,10 +154,24 @@ action_add(unsigned short mod, unsigned char button, KeySym keysym, action_type_
action->type = type;
action->keysym = keysym;
switch(type) {
case ACTION_STRING: action->handler = (action_handler_t) action_handle_string; action->param.string = StrDup((char *) param); break;
case ACTION_ECHO: action->handler = (action_handler_t) action_handle_echo; action->param.string = StrDup((char *) param); break;
case ACTION_MENU: action->handler = (action_handler_t) action_handle_menu; action->param.menu = (menu_t *) param; break;
default: break;
case ACTION_STRING:
action->handler = (action_handler_t) action_handle_string;
action->param.string = (char *) MALLOC(strlen((char *) param) + 2);
strcpy(action->param.string, (char *) param);
parse_escaped_string(action->param.string);
break;
case ACTION_ECHO:
action->handler = (action_handler_t) action_handle_echo;
action->param.string = (char *) MALLOC(strlen((char *) param) + 2);
strcpy(action->param.string, (char *) param);
parse_escaped_string(action->param.string);
break;
case ACTION_MENU:
action->handler = (action_handler_t) action_handle_menu;
action->param.menu = (menu_t *) param;
break;
default:
break;
}
action->next = NULL;
D_ACTIONS(("Added action. mod == 0x%08x, button == %d, keysym == 0x%08x\n", action->mod, action->button, action->keysym));

View File

@ -30,7 +30,11 @@ static const char cvs_ident[] = "$Id$";
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include "../libmej/debug.h"
#include "debug.h"
@ -298,6 +302,8 @@ safe_print_string(char *str, unsigned long len)
unsigned long n = 0, i;
if (len == ((unsigned long) -1)) {
len = strlen(str);
} else if (len == ((unsigned long) -2)) {
FREE(ret_buff);
rb_size = 0;
return ((char *) NULL);
@ -346,3 +352,51 @@ add_carriage_returns(unsigned char *buff, unsigned long cnt)
D_CMD(("buff == %8p \"%s\", i == %lu\n", buff, safe_print_string(buff, i), i));
return i;
}
unsigned char
mkdirhier(const char *path)
{
char *str, *pstr;
struct stat dst;
D_CMD(("path == %s\n", path));
str = StrDup(path); /* We need to modify it. */
pstr = str;
if (*pstr == '/') {
pstr++;
}
for (; (pstr = strchr(pstr, '/'));) {
*pstr = 0;
D_CMD(("Looking at \"%s\"\n", str));
if (stat(str, &dst)) {
/* It's not there. Create it. */
D_CMD(("stat() failed. Attempting to create it.\n"));
if (mkdir(str, 0755)) {
/* Couldn't create it. Return failure. */
D_CMD(("mkdir(%s, 0755) failed -- %s\n", str, strerror(errno)));
return 0;
}
} else if (!S_ISDIR(dst.st_mode)) {
/* It's there, but it's not a directory. Fail. */
D_CMD(("\"%s\" exists, but it's not a directory.\n", str));
return 0;
}
*pstr++ = '/';
}
D_CMD(("Looking at \"%s\"\n", str));
if (stat(str, &dst)) {
/* It's not there. Create it. */
D_CMD(("stat() failed. Attempting to create it.\n"));
if (mkdir(str, 0755)) {
/* Couldn't create it. Return failure. */
D_CMD(("mkdir(%s, 0755) failed -- %s\n", str, strerror(errno)));
return 0;
}
} else if (!S_ISDIR(dst.st_mode)) {
/* It's there, but it's not a directory. Fail. */
D_CMD(("\"%s\" exists, but it's not a directory.\n", str));
return 0;
}
D_CMD(("Done!\n"));
return 1;
}

View File

@ -30,6 +30,9 @@
/************ Macros and Definitions ************/
#define MAKE_CTRL_CHAR(c) ((c) == '?' ? 127 : ((toupper(c)) - '@'))
#define CAN_READ(s) (((s.st_mode) & S_IROTH) || ((my_ruid == (int)(s.st_uid)) && ((s.st_mode) & S_IRUSR)) || ((my_rgid == (int)(s.st_gid)) && ((s.st_mode) & S_IRGRP)))
#define CAN_WRITE(s) (((s.st_mode) & S_IWOTH) || ((my_ruid == (int)(s.st_uid)) && ((s.st_mode) & S_IWUSR)) || ((my_rgid == (int)(s.st_gid)) && ((s.st_mode) & S_IWGRP)))
/************ Function Prototypes ************/
_XFUNCPROTOBEGIN
@ -44,6 +47,7 @@ extern const char *search_path(const char *pathlist, const char *file, const cha
extern const char *find_file(const char *file, const char *ext);
extern char *safe_print_string(char *buff, unsigned long len);
extern unsigned long add_carriage_returns(unsigned char *buff, unsigned long cnt);
extern unsigned char mkdirhier(const char *);
_XFUNCPROTOEND

View File

@ -3997,9 +3997,8 @@ post_parse(void)
}
unsigned char
save_config(char *path)
save_config(char *path, unsigned char save_theme)
{
register FILE *fp;
register short i;
char *tmp_str, dt_stamp[50];
@ -4009,12 +4008,68 @@ save_config(char *path)
simage_t *simg;
action_t *action;
D_OPTIONS(("Saving %s config to \"%s\"\n", (save_theme ? "theme" : "user"), NONULL(path)));
cur_tm = localtime(&cur_time);
if (!path) {
path = (char *) MALLOC(PATH_MAX + 1);
snprintf(path, PATH_MAX, "%s/%s", getenv("ETERM_THEME_ROOT"), (rs_config_file ? rs_config_file : USER_CFG));
path[PATH_MAX] = 0;
if (save_theme) {
if (!path) {
path = (char *) MALLOC(PATH_MAX + 1);
strncpy(path, (theme_dir ? theme_dir : PKGDATADIR "/themes/Eterm"), PATH_MAX - sizeof("/" THEME_CFG));
path[PATH_MAX] = 0;
if (stat(path, &fst) || !S_ISDIR(fst.st_mode) || !CAN_WRITE(fst)) {
char *tmp = NULL;
D_OPTIONS(("Problem with \"%s\". S_ISDIR == %d, CAN_WRITE == %d\n", path, S_ISDIR(fst.st_mode), CAN_WRITE(fst)));
if (theme_dir) {
tmp = strrchr(theme_dir, '/');
if (tmp) {
*tmp++ = 0;
}
}
snprintf(path, PATH_MAX, "%s/.Eterm/themes/%s", getenv("HOME"), (tmp ? tmp : "Eterm"));
D_OPTIONS(("Trying \"%s\" instead, tmp == \"%s\"\n", path, tmp));
if (tmp) {
*(--tmp) = '/';
}
if (!mkdirhier(path) || (stat(path, &fst) && !CAN_WRITE(fst))) {
print_error("I couldn't write to \"%s\" or \"%s\". I give up.", (theme_dir ? theme_dir : PKGDATADIR "/themes/Eterm"), path);
return errno;
}
}
strcat(path, "/" THEME_CFG);
D_OPTIONS(("Final path is \"%s\"\n", path));
path[PATH_MAX] = 0;
}
} else {
if (!path) {
path = (char *) MALLOC(PATH_MAX + 1);
strncpy(path, (user_dir ? user_dir : PKGDATADIR "/themes/Eterm"), PATH_MAX - sizeof("/" USER_CFG));
path[PATH_MAX] = 0;
if (stat(path, &fst) || !S_ISDIR(fst.st_mode) || !CAN_WRITE(fst)) {
char *tmp = NULL;
D_OPTIONS(("Problem with \"%s\". S_ISDIR == %d, CAN_WRITE == %d\n", path, S_ISDIR(fst.st_mode), CAN_WRITE(fst)));
if (user_dir) {
tmp = strrchr(user_dir, '/');
if (tmp) {
*tmp++ = 0;
}
}
snprintf(path, PATH_MAX, "%s/.Eterm/themes/%s", getenv("HOME"), (tmp ? tmp : "Eterm"));
D_OPTIONS(("Trying \"%s\" instead, tmp == \"%s\"\n", path, tmp));
if (tmp) {
*(--tmp) = '/';
}
if (!mkdirhier(path) || (stat(path, &fst) && !CAN_WRITE(fst))) {
print_error("I couldn't write to \"%s\" or \"%s\". I give up.", (user_dir ? user_dir : PKGDATADIR "/themes/Eterm"), path);
return errno;
}
}
strcat(path, "/" USER_CFG);
D_OPTIONS(("Final path is \"%s\"\n", path));
path[PATH_MAX] = 0;
}
}
if (!lstat(path, &fst)) {
char bak_path[PATH_MAX], timestamp[16];
@ -4070,16 +4125,18 @@ save_config(char *path)
fprintf(fp, " end color\n\n");
fprintf(fp, " begin attributes\n");
if (rs_geometry) {
fprintf(fp, " geometry %s\n", rs_geometry);
}
XFetchName(Xdisplay, TermWin.parent, &tmp_str);
fprintf(fp, " title %s\n", tmp_str);
fprintf(fp, " name %s\n", rs_name);
XGetIconName(Xdisplay, TermWin.parent, &tmp_str);
fprintf(fp, " iconname %s\n", tmp_str);
if (rs_desktop != -1) {
fprintf(fp, " desktop %d\n", rs_desktop);
if (save_theme) {
if (rs_geometry) {
fprintf(fp, " geometry %s\n", rs_geometry);
}
XFetchName(Xdisplay, TermWin.parent, &tmp_str);
fprintf(fp, " title %s\n", tmp_str);
fprintf(fp, " name %s\n", rs_name);
XGetIconName(Xdisplay, TermWin.parent, &tmp_str);
fprintf(fp, " iconname %s\n", tmp_str);
if (rs_desktop != -1) {
fprintf(fp, " desktop %d\n", rs_desktop);
}
}
fprintf(fp, " scrollbar_type %s\n", (scrollbar_get_type() == SCROLLBAR_XTERM ? "xterm" : (scrollbar_get_type() == SCROLLBAR_MOTIF ? "motif" : "next")));
fprintf(fp, " scrollbar_width %d\n", scrollbar_anchor_width());
@ -4096,17 +4153,18 @@ save_config(char *path)
#endif
fprintf(fp, " end attributes\n\n");
fprintf(fp, " begin imageclasses\n");
fprintf(fp, " path \"%s\"\n", rs_path);
if (rs_icon != NULL) {
fprintf(fp, " icon %s\n", rs_icon);
}
if (rs_anim_delay) {
/* FIXME: Do something here! */
}
for (i = 0; i < image_max; i++) {
fprintf(fp, " begin image\n");
switch (i) {
if (save_theme) {
fprintf(fp, " begin imageclasses\n");
fprintf(fp, " path \"%s\"\n", rs_path);
if (rs_icon != NULL) {
fprintf(fp, " icon %s\n", rs_icon);
}
if (rs_anim_delay) {
/* FIXME: Do something here! */
}
for (i = 0; i < image_max; i++) {
fprintf(fp, " begin image\n");
switch (i) {
case image_bg: fprintf(fp, " type background\n"); break;
case image_sb: fprintf(fp, " type trough\n"); break;
case image_sa: fprintf(fp, " type anchor\n"); break;
@ -4122,263 +4180,265 @@ save_config(char *path)
case image_bbar: fprintf(fp, " type button_bar\n"); break;
case image_gbar: fprintf(fp, " type grab_bar\n"); break;
case image_dialog: fprintf(fp, " type dialog_box\n"); break;
}
fprintf(fp, " mode ");
switch (images[i].mode & MODE_MASK) {
}
fprintf(fp, " mode ");
switch (images[i].mode & MODE_MASK) {
case MODE_IMAGE: fprintf(fp, "image"); break;
case MODE_TRANS: fprintf(fp, "trans"); break;
case MODE_VIEWPORT: fprintf(fp, "viewport"); break;
case MODE_AUTO: fprintf(fp, "auto"); break;
default: fprintf(fp, "solid"); break;
}
if (images[i].mode & ALLOW_MASK) {
fprintf(fp, " allow");
if (image_mode_is(i, ALLOW_IMAGE)) {
fprintf(fp, " image");
}
if (image_mode_is(i, ALLOW_TRANS)) {
fprintf(fp, " trans");
}
if (image_mode_is(i, ALLOW_VIEWPORT)) {
fprintf(fp, " viewport");
}
if (image_mode_is(i, ALLOW_AUTO)) {
fprintf(fp, " auto");
}
}
fprintf(fp, "\n");
/* Now save each state. */
simg = images[i].norm;
fprintf(fp, " state normal\n");
if (simg->fg || simg->bg) {
fprintf(fp, " color 0x%08x 0x%08x\n", (unsigned int) simg->fg, (unsigned int) simg->bg);
}
if (simg->iml->im) {
fprintf(fp, " file %s\n", NONULL(simg->iml->im->filename));
}
fprintf(fp, " geom %hdx%hd+%hd+%hd", simg->pmap->w, simg->pmap->h, simg->pmap->x, simg->pmap->y);
if (simg->pmap->op & OP_TILE) {
fprintf(fp, ":tiled");
}
if ((simg->pmap->op & OP_SCALE) || ((simg->pmap->op & OP_HSCALE) && (simg->pmap->op & OP_VSCALE))) {
fprintf(fp, ":scaled");
} else if (simg->pmap->op & OP_HSCALE) {
fprintf(fp, ":hscaled");
} else if (simg->pmap->op & OP_VSCALE) {
fprintf(fp, ":vscaled");
}
if (simg->pmap->op & OP_PROPSCALE) {
fprintf(fp, ":propscaled");
}
fprintf(fp, "\n");
if (simg->iml->mod) {
fprintf(fp, " colormod image 0x%02x 0x%02x 0x%02x\n", simg->iml->mod->brightness, simg->iml->mod->contrast, simg->iml->mod->gamma);
}
if (simg->iml->rmod) {
fprintf(fp, " colormod red 0x%02x 0x%02x 0x%02x\n", simg->iml->rmod->brightness, simg->iml->rmod->contrast, simg->iml->rmod->gamma);
}
if (simg->iml->gmod) {
fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness, simg->iml->gmod->contrast, simg->iml->gmod->gamma);
}
if (simg->iml->bmod) {
fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness, simg->iml->bmod->contrast, simg->iml->bmod->gamma);
}
if (simg->iml->border) {
fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, simg->iml->border->top, simg->iml->border->bottom);
}
if (simg->iml->bevel) {
fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), simg->iml->bevel->edges->left, simg->iml->bevel->edges->right, simg->iml->bevel->edges->top, simg->iml->bevel->edges->bottom);
}
if (simg->iml->pad) {
fprintf(fp, " padding %hu %hu %hu %hu\n", simg->iml->pad->left, simg->iml->pad->right, simg->iml->pad->top, simg->iml->pad->bottom);
}
/* Selected state */
if (images[i].selected != images[i].norm) {
simg = images[i].selected;
fprintf(fp, " state selected\n");
if (simg->fg || simg->bg) {
fprintf(fp, " color 0x%08x 0x%08x\n", (unsigned int) simg->fg, (unsigned int) simg->bg);
}
if (simg->iml->im) {
fprintf(fp, " file %s\n", NONULL(simg->iml->im->filename));
}
fprintf(fp, " geom %hdx%hd+%hd+%hd", simg->pmap->w, simg->pmap->h, simg->pmap->x, simg->pmap->y);
if (simg->pmap->op & OP_TILE) {
fprintf(fp, ":tiled");
}
if ((simg->pmap->op & OP_SCALE) || ((simg->pmap->op & OP_HSCALE) && (simg->pmap->op & OP_VSCALE))) {
fprintf(fp, ":scaled");
} else if (simg->pmap->op & OP_HSCALE) {
fprintf(fp, ":hscaled");
} else if (simg->pmap->op & OP_VSCALE) {
fprintf(fp, ":vscaled");
}
if (simg->pmap->op & OP_PROPSCALE) {
fprintf(fp, ":propscaled");
}
fprintf(fp, "\n");
if (simg->iml->mod) {
fprintf(fp, " colormod image 0x%02x 0x%02x 0x%02x\n", simg->iml->mod->brightness, simg->iml->mod->contrast, simg->iml->mod->gamma);
}
if (simg->iml->rmod) {
fprintf(fp, " colormod red 0x%02x 0x%02x 0x%02x\n", simg->iml->rmod->brightness, simg->iml->rmod->contrast, simg->iml->rmod->gamma);
}
if (simg->iml->gmod) {
fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness, simg->iml->gmod->contrast, simg->iml->gmod->gamma);
}
if (simg->iml->bmod) {
fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness, simg->iml->bmod->contrast, simg->iml->bmod->gamma);
}
if (simg->iml->border) {
fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, simg->iml->border->top, simg->iml->border->bottom);
}
if (simg->iml->bevel) {
fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), simg->iml->bevel->edges->left, simg->iml->bevel->edges->right, simg->iml->bevel->edges->top, simg->iml->bevel->edges->bottom);
}
if (simg->iml->pad) {
fprintf(fp, " padding %hu %hu %hu %hu\n", simg->iml->pad->left, simg->iml->pad->right, simg->iml->pad->top, simg->iml->pad->bottom);
}
}
/* Clicked state */
if (images[i].clicked != images[i].norm) {
simg = images[i].clicked;
fprintf(fp, " state clicked\n");
if (simg->fg || simg->bg) {
fprintf(fp, " color 0x%08x 0x%08x\n", (unsigned int) simg->fg, (unsigned int) simg->bg);
}
if (simg->iml->im) {
fprintf(fp, " file %s\n", NONULL(simg->iml->im->filename));
}
fprintf(fp, " geom %hdx%hd+%hd+%hd", simg->pmap->w, simg->pmap->h, simg->pmap->x, simg->pmap->y);
if (simg->pmap->op & OP_TILE) {
fprintf(fp, ":tiled");
}
if ((simg->pmap->op & OP_SCALE) || ((simg->pmap->op & OP_HSCALE) && (simg->pmap->op & OP_VSCALE))) {
fprintf(fp, ":scaled");
} else if (simg->pmap->op & OP_HSCALE) {
fprintf(fp, ":hscaled");
} else if (simg->pmap->op & OP_VSCALE) {
fprintf(fp, ":vscaled");
}
if (simg->pmap->op & OP_PROPSCALE) {
fprintf(fp, ":propscaled");
}
fprintf(fp, "\n");
if (simg->iml->mod) {
fprintf(fp, " colormod image 0x%02x 0x%02x 0x%02x\n", simg->iml->mod->brightness, simg->iml->mod->contrast, simg->iml->mod->gamma);
}
if (simg->iml->rmod) {
fprintf(fp, " colormod red 0x%02x 0x%02x 0x%02x\n", simg->iml->rmod->brightness, simg->iml->rmod->contrast, simg->iml->rmod->gamma);
}
if (simg->iml->gmod) {
fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness, simg->iml->gmod->contrast, simg->iml->gmod->gamma);
}
if (simg->iml->bmod) {
fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness, simg->iml->bmod->contrast, simg->iml->bmod->gamma);
}
if (simg->iml->border) {
fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, simg->iml->border->top, simg->iml->border->bottom);
}
if (simg->iml->bevel) {
fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), simg->iml->bevel->edges->left, simg->iml->bevel->edges->right, simg->iml->bevel->edges->top, simg->iml->bevel->edges->bottom);
}
if (simg->iml->pad) {
fprintf(fp, " padding %hu %hu %hu %hu\n", simg->iml->pad->left, simg->iml->pad->right, simg->iml->pad->top, simg->iml->pad->bottom);
}
}
/* Disabled state */
if (images[i].disabled != images[i].norm) {
simg = images[i].disabled;
fprintf(fp, " state disabled\n");
if (simg->fg || simg->bg) {
fprintf(fp, " color 0x%08x 0x%08x\n", (unsigned int) simg->fg, (unsigned int) simg->bg);
}
if (simg->iml->im) {
fprintf(fp, " file %s\n", NONULL(simg->iml->im->filename));
}
fprintf(fp, " geom %hdx%hd+%hd+%hd", simg->pmap->w, simg->pmap->h, simg->pmap->x, simg->pmap->y);
if (simg->pmap->op & OP_TILE) {
fprintf(fp, ":tiled");
}
if ((simg->pmap->op & OP_SCALE) || ((simg->pmap->op & OP_HSCALE) && (simg->pmap->op & OP_VSCALE))) {
fprintf(fp, ":scaled");
} else if (simg->pmap->op & OP_HSCALE) {
fprintf(fp, ":hscaled");
} else if (simg->pmap->op & OP_VSCALE) {
fprintf(fp, ":vscaled");
}
if (simg->pmap->op & OP_PROPSCALE) {
fprintf(fp, ":propscaled");
}
fprintf(fp, "\n");
if (simg->iml->mod) {
fprintf(fp, " colormod image 0x%02x 0x%02x 0x%02x\n", simg->iml->mod->brightness, simg->iml->mod->contrast, simg->iml->mod->gamma);
}
if (simg->iml->rmod) {
fprintf(fp, " colormod red 0x%02x 0x%02x 0x%02x\n", simg->iml->rmod->brightness, simg->iml->rmod->contrast, simg->iml->rmod->gamma);
}
if (simg->iml->gmod) {
fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness, simg->iml->gmod->contrast, simg->iml->gmod->gamma);
}
if (simg->iml->bmod) {
fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness, simg->iml->bmod->contrast, simg->iml->bmod->gamma);
}
if (simg->iml->border) {
fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, simg->iml->border->top, simg->iml->border->bottom);
}
if (simg->iml->bevel) {
fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), simg->iml->bevel->edges->left, simg->iml->bevel->edges->right,
simg->iml->bevel->edges->top, simg->iml->bevel->edges->bottom);
}
if (simg->iml->pad) {
fprintf(fp, " padding %hu %hu %hu %hu\n", simg->iml->pad->left, simg->iml->pad->right, simg->iml->pad->top, simg->iml->pad->bottom);
}
}
fprintf(fp, " end image\n");
}
if (images[i].mode & ALLOW_MASK) {
fprintf(fp, " allow");
if (image_mode_is(i, ALLOW_IMAGE)) {
fprintf(fp, " image");
fprintf(fp, " end imageclasses\n\n");
for (i = 0; i < menu_list->nummenus; i++) {
menu_t *menu = menu_list->menus[i];
unsigned short j;
fprintf(fp, " begin menu\n");
fprintf(fp, " title \"%s\"\n", menu->title);
if (menu->font) {
unsigned long tmp;
if ((XGetFontProperty(menu->font, XA_FONT_NAME, &tmp)) == True) {
fprintf(fp, " font \"%s\"\n", ((char *) tmp));
}
}
if (image_mode_is(i, ALLOW_TRANS)) {
fprintf(fp, " trans");
}
if (image_mode_is(i, ALLOW_VIEWPORT)) {
fprintf(fp, " viewport");
}
if (image_mode_is(i, ALLOW_AUTO)) {
fprintf(fp, " auto");
for (j = 0; j < menu->numitems; j++) {
menuitem_t *item = menu->items[j];
if (item->type == MENUITEM_SEP) {
fprintf(fp, " -\n");
} else {
fprintf(fp, " begin menuitem\n");
fprintf(fp, " text \"%s\"\n", item->text);
if (item->rtext) {
fprintf(fp, " rtext \"%s\"\n", item->rtext);
}
fprintf(fp, " action ");
if (item->type == MENUITEM_STRING) {
fprintf(fp, "string \"%s\"\n", safe_print_string(item->action.string, -1));
} else if (item->type == MENUITEM_ECHO) {
fprintf(fp, "echo \"%s\"\n", safe_print_string(item->action.string, -1));
} else if (item->type == MENUITEM_SUBMENU) {
fprintf(fp, "submenu \"%s\"\n", (item->action.submenu)->title);
}
fprintf(fp, " end\n");
}
}
fprintf(fp, " end menu\n");
}
fprintf(fp, "\n");
/* Now save each state. */
simg = images[i].norm;
fprintf(fp, " state normal\n");
if (simg->fg || simg->bg) {
fprintf(fp, " color 0x%08x 0x%08x\n", (unsigned int) simg->fg, (unsigned int) simg->bg);
}
if (simg->iml->im) {
fprintf(fp, " file %s\n", NONULL(simg->iml->im->filename));
}
fprintf(fp, " geom %hdx%hd+%hd+%hd", simg->pmap->w, simg->pmap->h, simg->pmap->x, simg->pmap->y);
if (simg->pmap->op & OP_TILE) {
fprintf(fp, ":tiled");
}
if ((simg->pmap->op & OP_SCALE) || ((simg->pmap->op & OP_HSCALE) && (simg->pmap->op & OP_VSCALE))) {
fprintf(fp, ":scaled");
} else if (simg->pmap->op & OP_HSCALE) {
fprintf(fp, ":hscaled");
} else if (simg->pmap->op & OP_VSCALE) {
fprintf(fp, ":vscaled");
}
if (simg->pmap->op & OP_PROPSCALE) {
fprintf(fp, ":propscaled");
}
fprintf(fp, "\n");
if (simg->iml->mod) {
fprintf(fp, " colormod image 0x%02x 0x%02x 0x%02x\n", simg->iml->mod->brightness, simg->iml->mod->contrast, simg->iml->mod->gamma);
}
if (simg->iml->rmod) {
fprintf(fp, " colormod red 0x%02x 0x%02x 0x%02x\n", simg->iml->rmod->brightness, simg->iml->rmod->contrast, simg->iml->rmod->gamma);
}
if (simg->iml->gmod) {
fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness, simg->iml->gmod->contrast, simg->iml->gmod->gamma);
}
if (simg->iml->bmod) {
fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness, simg->iml->bmod->contrast, simg->iml->bmod->gamma);
}
if (simg->iml->border) {
fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, simg->iml->border->top, simg->iml->border->bottom);
}
if (simg->iml->bevel) {
fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), simg->iml->bevel->edges->left, simg->iml->bevel->edges->right, simg->iml->bevel->edges->top, simg->iml->bevel->edges->bottom);
}
if (simg->iml->pad) {
fprintf(fp, " padding %hu %hu %hu %hu\n", simg->iml->pad->left, simg->iml->pad->right, simg->iml->pad->top, simg->iml->pad->bottom);
}
/* Selected state */
if (images[i].selected != images[i].norm) {
simg = images[i].selected;
fprintf(fp, " state selected\n");
if (simg->fg || simg->bg) {
fprintf(fp, " color 0x%08x 0x%08x\n", (unsigned int) simg->fg, (unsigned int) simg->bg);
}
if (simg->iml->im) {
fprintf(fp, " file %s\n", NONULL(simg->iml->im->filename));
}
fprintf(fp, " geom %hdx%hd+%hd+%hd", simg->pmap->w, simg->pmap->h, simg->pmap->x, simg->pmap->y);
if (simg->pmap->op & OP_TILE) {
fprintf(fp, ":tiled");
}
if ((simg->pmap->op & OP_SCALE) || ((simg->pmap->op & OP_HSCALE) && (simg->pmap->op & OP_VSCALE))) {
fprintf(fp, ":scaled");
} else if (simg->pmap->op & OP_HSCALE) {
fprintf(fp, ":hscaled");
} else if (simg->pmap->op & OP_VSCALE) {
fprintf(fp, ":vscaled");
}
if (simg->pmap->op & OP_PROPSCALE) {
fprintf(fp, ":propscaled");
}
fprintf(fp, "\n");
if (simg->iml->mod) {
fprintf(fp, " colormod image 0x%02x 0x%02x 0x%02x\n", simg->iml->mod->brightness, simg->iml->mod->contrast, simg->iml->mod->gamma);
}
if (simg->iml->rmod) {
fprintf(fp, " colormod red 0x%02x 0x%02x 0x%02x\n", simg->iml->rmod->brightness, simg->iml->rmod->contrast, simg->iml->rmod->gamma);
}
if (simg->iml->gmod) {
fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness, simg->iml->gmod->contrast, simg->iml->gmod->gamma);
}
if (simg->iml->bmod) {
fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness, simg->iml->bmod->contrast, simg->iml->bmod->gamma);
}
if (simg->iml->border) {
fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, simg->iml->border->top, simg->iml->border->bottom);
}
if (simg->iml->bevel) {
fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), simg->iml->bevel->edges->left, simg->iml->bevel->edges->right, simg->iml->bevel->edges->top, simg->iml->bevel->edges->bottom);
}
if (simg->iml->pad) {
fprintf(fp, " padding %hu %hu %hu %hu\n", simg->iml->pad->left, simg->iml->pad->right, simg->iml->pad->top, simg->iml->pad->bottom);
}
}
/* Clicked state */
if (images[i].clicked != images[i].norm) {
simg = images[i].clicked;
fprintf(fp, " state clicked\n");
if (simg->fg || simg->bg) {
fprintf(fp, " color 0x%08x 0x%08x\n", (unsigned int) simg->fg, (unsigned int) simg->bg);
}
if (simg->iml->im) {
fprintf(fp, " file %s\n", NONULL(simg->iml->im->filename));
}
fprintf(fp, " geom %hdx%hd+%hd+%hd", simg->pmap->w, simg->pmap->h, simg->pmap->x, simg->pmap->y);
if (simg->pmap->op & OP_TILE) {
fprintf(fp, ":tiled");
}
if ((simg->pmap->op & OP_SCALE) || ((simg->pmap->op & OP_HSCALE) && (simg->pmap->op & OP_VSCALE))) {
fprintf(fp, ":scaled");
} else if (simg->pmap->op & OP_HSCALE) {
fprintf(fp, ":hscaled");
} else if (simg->pmap->op & OP_VSCALE) {
fprintf(fp, ":vscaled");
}
if (simg->pmap->op & OP_PROPSCALE) {
fprintf(fp, ":propscaled");
}
fprintf(fp, "\n");
if (simg->iml->mod) {
fprintf(fp, " colormod image 0x%02x 0x%02x 0x%02x\n", simg->iml->mod->brightness, simg->iml->mod->contrast, simg->iml->mod->gamma);
}
if (simg->iml->rmod) {
fprintf(fp, " colormod red 0x%02x 0x%02x 0x%02x\n", simg->iml->rmod->brightness, simg->iml->rmod->contrast, simg->iml->rmod->gamma);
}
if (simg->iml->gmod) {
fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness, simg->iml->gmod->contrast, simg->iml->gmod->gamma);
}
if (simg->iml->bmod) {
fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness, simg->iml->bmod->contrast, simg->iml->bmod->gamma);
}
if (simg->iml->border) {
fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, simg->iml->border->top, simg->iml->border->bottom);
}
if (simg->iml->bevel) {
fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), simg->iml->bevel->edges->left, simg->iml->bevel->edges->right, simg->iml->bevel->edges->top, simg->iml->bevel->edges->bottom);
}
if (simg->iml->pad) {
fprintf(fp, " padding %hu %hu %hu %hu\n", simg->iml->pad->left, simg->iml->pad->right, simg->iml->pad->top, simg->iml->pad->bottom);
}
}
/* Disabled state */
if (images[i].disabled != images[i].norm) {
simg = images[i].disabled;
fprintf(fp, " state disabled\n");
if (simg->fg || simg->bg) {
fprintf(fp, " color 0x%08x 0x%08x\n", (unsigned int) simg->fg, (unsigned int) simg->bg);
}
if (simg->iml->im) {
fprintf(fp, " file %s\n", NONULL(simg->iml->im->filename));
}
fprintf(fp, " geom %hdx%hd+%hd+%hd", simg->pmap->w, simg->pmap->h, simg->pmap->x, simg->pmap->y);
if (simg->pmap->op & OP_TILE) {
fprintf(fp, ":tiled");
}
if ((simg->pmap->op & OP_SCALE) || ((simg->pmap->op & OP_HSCALE) && (simg->pmap->op & OP_VSCALE))) {
fprintf(fp, ":scaled");
} else if (simg->pmap->op & OP_HSCALE) {
fprintf(fp, ":hscaled");
} else if (simg->pmap->op & OP_VSCALE) {
fprintf(fp, ":vscaled");
}
if (simg->pmap->op & OP_PROPSCALE) {
fprintf(fp, ":propscaled");
}
fprintf(fp, "\n");
if (simg->iml->mod) {
fprintf(fp, " colormod image 0x%02x 0x%02x 0x%02x\n", simg->iml->mod->brightness, simg->iml->mod->contrast, simg->iml->mod->gamma);
}
if (simg->iml->rmod) {
fprintf(fp, " colormod red 0x%02x 0x%02x 0x%02x\n", simg->iml->rmod->brightness, simg->iml->rmod->contrast, simg->iml->rmod->gamma);
}
if (simg->iml->gmod) {
fprintf(fp, " colormod green 0x%02x 0x%02x 0x%02x\n", simg->iml->gmod->brightness, simg->iml->gmod->contrast, simg->iml->gmod->gamma);
}
if (simg->iml->bmod) {
fprintf(fp, " colormod blue 0x%02x 0x%02x 0x%02x\n", simg->iml->bmod->brightness, simg->iml->bmod->contrast, simg->iml->bmod->gamma);
}
if (simg->iml->border) {
fprintf(fp, " border %hu %hu %hu %hu\n", simg->iml->border->left, simg->iml->border->right, simg->iml->border->top, simg->iml->border->bottom);
}
if (simg->iml->bevel) {
fprintf(fp, " bevel %s %hu %hu %hu %hu\n", ((simg->iml->bevel->up) ? "up" : "down"), simg->iml->bevel->edges->left, simg->iml->bevel->edges->right, simg->iml->bevel->edges->top, simg->iml->bevel->edges->bottom);
}
if (simg->iml->pad) {
fprintf(fp, " padding %hu %hu %hu %hu\n", simg->iml->pad->left, simg->iml->pad->right, simg->iml->pad->top, simg->iml->pad->bottom);
}
}
fprintf(fp, " end image\n");
}
fprintf(fp, " end imageclasses\n\n");
for (i = 0; i < menu_list->nummenus; i++) {
menu_t *menu = menu_list->menus[i];
unsigned short j;
fprintf(fp, " begin menu\n");
fprintf(fp, " title \"%s\"\n", menu->title);
if (menu->font) {
unsigned long tmp;
if ((XGetFontProperty(menu->font, XA_FONT_NAME, &tmp)) == True) {
fprintf(fp, " font \"%s\"\n", ((char *) tmp));
}
}
for (j = 0; j < menu->numitems; j++) {
menuitem_t *item = menu->items[j];
if (item->type == MENUITEM_SEP) {
fprintf(fp, " -\n");
} else {
fprintf(fp, " begin menuitem\n");
fprintf(fp, " text \"%s\"\n", item->text);
if (item->rtext) {
fprintf(fp, " rtext \"%s\"\n", item->rtext);
}
fprintf(fp, " action ");
if (item->type == MENUITEM_STRING) {
fprintf(fp, "string \"%s\"\n", item->action.string);
} else if (item->type == MENUITEM_ECHO) {
fprintf(fp, "echo \"%s\"\n", item->action.string);
} else if (item->type == MENUITEM_SUBMENU) {
fprintf(fp, "submenu \"%s\"\n", (item->action.submenu)->title);
}
fprintf(fp, " end\n");
}
}
fprintf(fp, " end menu\n");
}
fprintf(fp, "\n");
fprintf(fp, " begin actions\n");
for (action = action_list; action; action = action->next) {
@ -4435,9 +4495,9 @@ save_config(char *path)
}
fprintf(fp, " to ");
if (action->type == ACTION_STRING) {
fprintf(fp, "string \"%s\"\n", action->param.string);
fprintf(fp, "string \"%s\"\n", safe_print_string(action->param.string, -1));
} else if (action->type == ACTION_ECHO) {
fprintf(fp, "echo \"%s\"\n", action->param.string);
fprintf(fp, "echo \"%s\"\n", safe_print_string(action->param.string, -1));
} else if (action->type == ACTION_MENU) {
fprintf(fp, "menu \"%s\"\n", (action->param.menu)->title);
}
@ -4538,7 +4598,7 @@ save_config(char *path)
fprintf(fp, " border_width %d\n", TermWin.internalBorder);
fprintf(fp, " term_name %s\n", getenv("TERM"));
fprintf(fp, " debug %d\n", debug_level);
if (rs_execArgs) {
if (save_theme && rs_execArgs) {
fprintf(fp, " exec ");
for (i = 0; rs_execArgs[i]; i++) {
fprintf(fp, "'%s' ", rs_execArgs[i]);

View File

@ -84,6 +84,9 @@
# define BBAR_FORCE_TOGGLE (0x03)
# define SAVE_THEME_CONFIG ((unsigned char) 1)
# define SAVE_USER_CONFIG ((unsigned char) 0)
#define BOOL_OPT_ISTRUE(s) (!strcasecmp((s), true_vals[0]) || !strcasecmp((s), true_vals[1]) \
|| !strcasecmp((s), true_vals[2]) || !strcasecmp((s), true_vals[3]))
#define BOOL_OPT_ISFALSE(s) (!strcasecmp((s), false_vals[0]) || !strcasecmp((s), false_vals[1]) \
@ -256,7 +259,7 @@ extern char *conf_parse(char *conf_name, const char *dir, const char *path);
extern char *conf_parse_theme(char *theme, char *conf_name, unsigned char fallback);
extern void init_defaults(void);
extern void post_parse(void);
unsigned char save_config(char *);
unsigned char save_config(char *, unsigned char);
_XFUNCPROTOEND

View File

@ -2170,9 +2170,14 @@ xterm_seq(int op, const char *str)
/* Save current config */
nstr = (char *) strsep(&tnstr, ";");
if (nstr && *nstr) {
save_config(nstr);
valptr = (char *) strsep(&tnstr, ";");
if (!strcasecmp(nstr, "theme")) {
save_config(valptr, SAVE_THEME_CONFIG);
} else {
save_config(valptr, SAVE_USER_CONFIG);
}
} else {
save_config(NULL);
save_config(NULL, SAVE_USER_CONFIG);
}
break;
case 72:

View File

@ -917,9 +917,13 @@ begin menu
end
separator
begin menuitem
text "Save Settings..."
text "Save User Settings..."
action string "\e]6;71\a"
end
begin menuitem
text "Save Theme Settings..."
action string "\e]6;71;theme\a"
end
begin menuitem
text "Exit"
action string "\e]6;70\a"

View File

@ -903,6 +903,10 @@ begin menu
action submenu Terminal
end
-
begin menuitem
text "New Window..."
action string "\e]6;73;Eterm\a"
end
begin menuitem
text "Version"
action string "\e[8n"
@ -913,9 +917,13 @@ begin menu
end
separator
begin menuitem
text "Save Settings..."
text "Save User Settings..."
action string "\e]6;71\a"
end
begin menuitem
text "Save Theme Settings..."
action string "\e]6;71;theme\a"
end
begin menuitem
text "Exit"
action string "\e]6;70\a"

View File

@ -917,9 +917,13 @@ begin menu
end
separator
begin menuitem
text "Save Settings..."
text "Save User Settings..."
action string "\e]6;71\a"
end
begin menuitem
text "Save Theme Settings..."
action string "\e]6;71;theme\a"
end
begin menuitem
text "Exit"
action string "\e]6;70\a"

View File

@ -983,6 +983,7 @@ begin menu
STRING_ITEM(`Version', `\e[8n')
STRING_ITEM(`Status', `\e[9n')
separator
STRING_ITEM(`Save Settings...', `\e]6;71\a')
STRING_ITEM(`Save User Settings...', `\e]6;71\a')
STRING_ITEM(`Save Theme Settings...', `\e]6;71;theme\a')
STRING_ITEM(`Exit', `\e]6;70\a')
end

View File

@ -1127,9 +1127,13 @@ begin menu
end
separator
begin menuitem
text "Save Settings..."
text "Save User Settings..."
action string "\e]6;71\a"
end
begin menuitem
text "Save Theme Settings..."
action string "\e]6;71;theme\a"
end
begin menuitem
text "Exit"
action string "\e]6;70\a"

View File

@ -917,9 +917,13 @@ begin menu
end
separator
begin menuitem
text "Save Settings..."
text "Save User Settings..."
action string "\e]6;71\a"
end
begin menuitem
text "Save Theme Settings..."
action string "\e]6;71;theme\a"
end
begin menuitem
text "Exit"
action string "\e]6;70\a"

View File

@ -1061,9 +1061,13 @@ begin menu
end
separator
begin menuitem
text "Save Settings..."
text "Save User Settings..."
action string "\e]6;71\a"
end
begin menuitem
text "Save Theme Settings..."
action string "\e]6;71;theme\a"
end
begin menuitem
text "Exit"
action string "\e]6;70\a"

View File

@ -917,9 +917,13 @@ begin menu
end
separator
begin menuitem
text "Save Settings..."
text "Save User Settings..."
action string "\e]6;71\a"
end
begin menuitem
text "Save Theme Settings..."
action string "\e]6;71;theme\a"
end
begin menuitem
text "Exit"
action string "\e]6;70\a"