diff --git a/ChangeLog b/ChangeLog index 914b524..78dcc69 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4589,3 +4589,7 @@ Wed Apr 24 16:56:48 2002 Michael Jennings (mej) Fixed bug where initial options would get parsed even if they were part of a -e/--exec expression. ---------------------------------------------------------------------- +Wed Apr 24 22:27:51 2002 Michael Jennings (mej) + +Save buttonbar info when we save theme settings. +---------------------------------------------------------------------- diff --git a/src/font.c b/src/font.c index e601b06..f505653 100644 --- a/src/font.c +++ b/src/font.c @@ -315,6 +315,31 @@ font_cache_find_info(const char *name, unsigned char type) { return (NULL); } +const char * +get_font_name(void *info) +{ + cachefont_t *current; + + REQUIRE_RVAL(info != NULL, NULL); + + D_FONT(("get_font_name(%8p) called.\n", info)); + + /* This is also a simple search, but it returns the fontinfo rather than the cache entry. */ + for (current = font_cache; current; current = current->next) { + D_FONT((" -> Checking current (%8p), type == %d, name == %s\n", current, current->type, NONULL(current->name))); + if ((current->type == FONT_TYPE_X) && (((void *) current->fontinfo.xfontinfo) == info)) { + D_FONT((" -> Match!\n")); + return current->name; +#if UNUSED_BLOCK + } else if ((current->type == FONT_TYPE_TTF) && (0)) { + } else if ((current->type == FONT_TYPE_FNLIB) && (0)) { +#endif + } + } + D_FONT(("No matches found. =(\n")); + return (NULL); +} + /* load_font() is the function that should be used to allocate fonts. */ void * load_font(const char *name, const char *fallback, unsigned char type) diff --git a/src/font.h b/src/font.h index 4c02e55..28fe03a 100644 --- a/src/font.h +++ b/src/font.h @@ -94,6 +94,7 @@ extern void font_cache_clear(void); extern void *load_font(const char *, const char *, unsigned char); extern void free_font(const void *); extern void change_font(int, const char *); +extern const char *get_font_name(void *); extern void set_shadow_color_by_name(unsigned char, const char *); extern void set_shadow_color_by_pixel(unsigned char, Pixel); extern unsigned char parse_font_fx(const char *line); diff --git a/src/options.c b/src/options.c index 41d269e..11acbe8 100644 --- a/src/options.c +++ b/src/options.c @@ -2546,7 +2546,7 @@ parse_bbar(char *buff, void *state) if (text == icon) { text = NULL; } else { - text = get_word(1, text); + text = get_word(2, buff); } if (!text && !icon) { print_error("Parse error in file %s, line %lu: Missing button specifications\n", file_peek_path(), file_peek_line()); @@ -3287,6 +3287,7 @@ save_config(char *path, unsigned char save_theme) struct stat fst; simage_t *simg; action_t *action; + buttonbar_t *bbar; D_OPTIONS(("Saving %s config to \"%s\"\n", (save_theme ? "theme" : "user"), NONULL(path))); @@ -3818,6 +3819,67 @@ save_config(char *path, unsigned char save_theme) fprintf(fp, "end xim\n\n"); #endif + if (save_theme) { + for (bbar = buttonbar; bbar; bbar = bbar->next) { + unsigned long tmp; + button_t *b; + + fprintf(fp, "begin button_bar\n"); + fprintf(fp, " font '%s'\n", NONULL(get_font_name(bbar->font))); + if (bbar_is_top_docked(bbar)) { + fprintf(fp, " dock top\n"); + } else if (bbar_is_bottom_docked(bbar)) { + fprintf(fp, " dock bottom\n"); + } else { + fprintf(fp, " dock none\n"); + } + fprintf(fp, " visible %s\n", (bbar_is_visible(bbar) ? "yes" : "no")); + for (b = bbar->buttons; b; b = b->next) { + if (b->len) { + fprintf(fp, " button \"%s\" ", safe_print_string(b->text, b->len)); + } else { + fprintf(fp, " button "); + } + if (b->icon && b->icon->iml) { + imlib_context_set_image(b->icon->iml->im); + fprintf(fp, "icon \"%s\" ", NONULL(imlib_image_get_filename())); + } + fprintf(fp, "action "); + if (b->type == ACTION_STRING) { + fprintf(fp, "string '%s'\n", safe_print_string(b->action.string, -1)); + } else if (b->type == ACTION_ECHO) { + fprintf(fp, "echo '%s'\n", safe_print_string(b->action.string, -1)); + } else if (b->type == ACTION_MENU) { + fprintf(fp, "menu \"%s\"\n", (b->action.menu)->title); + } else if (b->type == ACTION_SCRIPT) { + fprintf(fp, "script '%s'\n", b->action.script); + } + } + for (b = bbar->rbuttons; b; b = b->next) { + if (b->len) { + fprintf(fp, " rbutton \"%s\" ", safe_print_string(b->text, b->len)); + } else { + fprintf(fp, " rbutton "); + } + if (b->icon && b->icon->iml) { + imlib_context_set_image(b->icon->iml->im); + fprintf(fp, "icon \"%s\" ", NONULL(imlib_image_get_filename())); + } + fprintf(fp, "action "); + if (b->type == ACTION_STRING) { + fprintf(fp, "string '%s'\n", safe_print_string(b->action.string, -1)); + } else if (b->type == ACTION_ECHO) { + fprintf(fp, "echo '%s'\n", safe_print_string(b->action.string, -1)); + } else if (b->type == ACTION_MENU) { + fprintf(fp, "menu \"%s\"\n", (b->action.menu)->title); + } else if (b->type == ACTION_SCRIPT) { + fprintf(fp, "script '%s'\n", b->action.script); + } + } + } + fprintf(fp, "end button_bar\n\n"); + } + fprintf(fp, "begin toggles\n"); fprintf(fp, " map_alert %d\n", (Options & Opt_map_alert ? 1 : 0)); fprintf(fp, " visual_bell %d\n", (Options & Opt_visual_bell ? 1 : 0));