Port font scaling to the new VTE API

Closes #195
This commit is contained in:
Simon Gomizelj 2014-11-10 20:11:20 -05:00
parent f9f285e5ba
commit bed98f83e8
1 changed files with 5 additions and 22 deletions

View File

@ -640,26 +640,9 @@ void window_title_cb(VteTerminal *vte, gboolean *dynamic_title) {
title ? title : "termite");
}
static void update_font_size(VteTerminal *vte, int update, GtkWindow *window) {
const PangoFontDescription *desc = vte_terminal_get_font(vte);
int size = pango_font_description_get_size(desc);
if (!pango_font_description_get_size_is_absolute(desc))
update *= PANGO_SCALE;
size += update;
if (size > 0) {
PangoFontDescription *new_desc = pango_font_description_copy(desc);
pango_font_description_set_size(new_desc, size);
vte_terminal_set_font(vte, new_desc);
pango_font_description_free(new_desc);
if (window) {
set_size_hints(window, (int)vte_terminal_get_char_width(vte),
(int)vte_terminal_get_char_height(vte));
}
}
static void update_font_scale(VteTerminal *vte, gdouble update) {
gdouble scale = vte_terminal_get_font_scale(vte);
vte_terminal_set_font_scale(vte, scale + update);
}
gboolean window_state_cb(GtkWindow *, GdkEventWindowState *event, keybind_info *info) {
@ -814,10 +797,10 @@ gboolean key_press_cb(VteTerminal *vte, GdkEventKey *event, keybind_info *info)
overlay_show(&info->panel, overlay_mode::urlselect, nullptr);
break;
case GDK_KEY_plus:
update_font_size(vte, 1, info->config.size_hints ? info->window : nullptr);
update_font_scale(vte, 0.1);
break;
case GDK_KEY_minus:
update_font_size(vte, -1, info->config.size_hints ? info->window : nullptr);
update_font_scale(vte, -0.1);
break;
}
return TRUE;