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"); title ? title : "termite");
} }
static void update_font_size(VteTerminal *vte, int update, GtkWindow *window) { static void update_font_scale(VteTerminal *vte, gdouble update) {
const PangoFontDescription *desc = vte_terminal_get_font(vte); gdouble scale = vte_terminal_get_font_scale(vte);
int size = pango_font_description_get_size(desc); vte_terminal_set_font_scale(vte, scale + update);
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));
}
}
} }
gboolean window_state_cb(GtkWindow *, GdkEventWindowState *event, keybind_info *info) { 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); overlay_show(&info->panel, overlay_mode::urlselect, nullptr);
break; break;
case GDK_KEY_plus: case GDK_KEY_plus:
update_font_size(vte, 1, info->config.size_hints ? info->window : nullptr); update_font_scale(vte, 0.1);
break; break;
case GDK_KEY_minus: case GDK_KEY_minus:
update_font_size(vte, -1, info->config.size_hints ? info->window : nullptr); update_font_scale(vte, -0.1);
break; break;
} }
return TRUE; return TRUE;