add a [hints] section

This commit is contained in:
Simon Gomizelj 2012-09-28 19:27:10 -04:00 committed by Daniel Micay
parent 58ab9cad0f
commit e5340a90dc
1 changed files with 12 additions and 13 deletions

View File

@ -814,10 +814,10 @@ auto get_config_string(std::bind(get_config<char *>, g_key_file_get_string,
auto get_config_double(std::bind(get_config<double>, g_key_file_get_double, auto get_config_double(std::bind(get_config<double>, g_key_file_get_double,
_1, _2, _3, _4)); _1, _2, _3, _4));
static bool get_config_color(GKeyFile *config, const char *key, GdkColor *color) { static bool get_config_color(GKeyFile *config, const char *section, const char *key, GdkColor *color) {
char *cfgstr; char *cfgstr;
bool success = false; bool success = false;
if (get_config_string(config, "colors", key, &cfgstr)) { if (get_config_string(config, section, key, &cfgstr)) {
if (gdk_color_parse(cfgstr, color)) { if (gdk_color_parse(cfgstr, color)) {
success = true; success = true;
} else { } else {
@ -910,12 +910,11 @@ static void load_config(GtkWindow *window, VteTerminal *vte, config_info *info,
g_free(cfgstr); g_free(cfgstr);
} }
if (get_config_string(config, "options", "hint_font", &cfgstr)) { if (get_config_string(config, "hints", "font", &cfgstr)) {
hints.font = pango_font_description_from_string(cfgstr); hints.font = pango_font_description_from_string(cfgstr);
g_free(cfgstr); g_free(cfgstr);
} }
if (get_config_string(config, "options", "word_chars", &cfgstr)) { if (get_config_string(config, "options", "word_chars", &cfgstr)) {
vte_terminal_set_word_chars(vte, cfgstr); vte_terminal_set_word_chars(vte, cfgstr);
g_free(cfgstr); g_free(cfgstr);
@ -981,7 +980,7 @@ static void load_config(GtkWindow *window, VteTerminal *vte, config_info *info,
for (unsigned i = 0; i < palette_size; i++) { for (unsigned i = 0; i < palette_size; i++) {
snprintf(color_key, sizeof color_key, "color%u", i); snprintf(color_key, sizeof color_key, "color%u", i);
if (!get_config_color(config, color_key, &palette[i])) { if (!get_config_color(config, "colors", color_key, &palette[i])) {
if (i < 16) { if (i < 16) {
palette[i].blue = (i & 4) ? 0xc000 : 0; palette[i].blue = (i & 4) ? 0xc000 : 0;
palette[i].green = (i & 2) ? 0xc000 : 0; palette[i].green = (i & 2) ? 0xc000 : 0;
@ -1007,27 +1006,27 @@ static void load_config(GtkWindow *window, VteTerminal *vte, config_info *info,
} }
} }
vte_terminal_set_colors(vte, nullptr, nullptr, palette, palette_size); vte_terminal_set_colors(vte, nullptr, nullptr, palette, palette_size);
if (get_config_color(config, "foreground", &color)) { if (get_config_color(config, "colors", "foreground", &color)) {
vte_terminal_set_color_foreground(vte, &color); vte_terminal_set_color_foreground(vte, &color);
} }
if (get_config_color(config, "foreground_bold", &color)) { if (get_config_color(config, "colors", "foreground_bold", &color)) {
vte_terminal_set_color_bold(vte, &color); vte_terminal_set_color_bold(vte, &color);
} }
if (get_config_color(config, "foreground_dim", &color)) { if (get_config_color(config, "colors", "foreground_dim", &color)) {
vte_terminal_set_color_dim(vte, &color); vte_terminal_set_color_dim(vte, &color);
} }
if (get_config_color(config, "background", &color)) { if (get_config_color(config, "colors", "background", &color)) {
vte_terminal_set_color_background(vte, &color); vte_terminal_set_color_background(vte, &color);
vte_terminal_set_background_tint_color(vte, &color); vte_terminal_set_background_tint_color(vte, &color);
} }
if (get_config_color(config, "cursor", &color)) { if (get_config_color(config, "colors", "cursor", &color)) {
vte_terminal_set_color_cursor(vte, &color); vte_terminal_set_color_cursor(vte, &color);
} }
if (get_config_color(config, "highlight", &color)) { if (get_config_color(config, "colors", "highlight", &color)) {
vte_terminal_set_color_highlight(vte, &color); vte_terminal_set_color_highlight(vte, &color);
} }
if (get_config_color(config, "hint_foreground", &color)) { if (get_config_color(config, "hints", "foreground", &color)) {
hints.fg = cairo_pattern_create_rgb(color.red / 65535.0, hints.fg = cairo_pattern_create_rgb(color.red / 65535.0,
color.green / 65535.0, color.green / 65535.0,
color.blue / 65535.0); color.blue / 65535.0);
@ -1035,7 +1034,7 @@ static void load_config(GtkWindow *window, VteTerminal *vte, config_info *info,
hints.fg = cairo_pattern_create_rgb(1, 1, 1); hints.fg = cairo_pattern_create_rgb(1, 1, 1);
} }
if (get_config_color(config, "hint_background", &color)) { if (get_config_color(config, "hints", "background", &color)) {
hints.bg = cairo_pattern_create_rgb(color.red / 65535.0, hints.bg = cairo_pattern_create_rgb(color.red / 65535.0,
color.green / 65535.0, color.green / 65535.0,
color.blue / 65535.0); color.blue / 65535.0);