Add option for enabling size hints for the window

Cleaned up per discussion on #112
This commit is contained in:
Evan Purkhiser 2013-08-06 22:27:37 -04:00 committed by Simon Gomizelj
parent f4f21ebb89
commit 7982fac85c
2 changed files with 26 additions and 2 deletions

3
config
View File

@ -32,6 +32,9 @@ cursor_shape = block
# (default if unset: all graphic non-punctuation/space characters)
#word_chars = -A-Za-z0-9,./?%&#:_=+@~
# set size hints for the window
#size_hints = false
[colors]
foreground = #dcdccc
foreground_bold = #ffffff

View File

@ -88,7 +88,7 @@ struct hint_info {
struct config_info {
hint_info hints;
char *browser;
gboolean dynamic_title, urgent_on_bell, clickable_url, opacity_set, pseudo_transparency;
gboolean dynamic_title, urgent_on_bell, clickable_url, opacity_set, pseudo_transparency, size_hints;
int tag;
char *config_file;
};
@ -151,6 +151,21 @@ static void set_opacity(GtkWidget *window, VteTerminal *vte, double opacity, gbo
}
}
static void set_size_hints(GtkWindow *window, int char_width, int char_height)
{
static const GdkWindowHints wh = (GdkWindowHints)(GDK_HINT_RESIZE_INC | GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE);
GdkGeometry hints;
hints.base_width = char_width;
hints.base_height = char_height;
hints.min_width = char_width;
hints.min_height = char_height;
hints.width_inc = char_width;
hints.height_inc = char_height;
gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &hints, wh);
}
static void launch_in_directory(VteTerminal *vte) {
const char *uri = vte_terminal_get_current_directory_uri(vte);
if (!uri) {
@ -1175,6 +1190,7 @@ static void set_config(GtkWindow *window, VteTerminal *vte, config_info *info,
info->urgent_on_bell = cfg_bool("urgent_on_bell", TRUE);
info->clickable_url = cfg_bool("clickable_url", TRUE);
info->pseudo_transparency = cfg_bool("pseudo_transparency", FALSE);
info->size_hints = cfg_bool("size_hints", FALSE);
if (info->clickable_url) {
info->tag =
@ -1245,6 +1261,11 @@ static void set_config(GtkWindow *window, VteTerminal *vte, config_info *info,
}
}
if (info->size_hints) {
set_size_hints(GTK_WINDOW(window), (int)vte_terminal_get_char_width(vte),
(int)vte_terminal_get_char_height(vte));
}
load_theme(window, vte, config, info->hints);
}/*}}}*/
@ -1344,7 +1365,7 @@ int main(int argc, char **argv) {
nullptr},
{vi_mode::insert, 0, 0, 0, 0},
{{nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, 0, 0, 0},
nullptr, FALSE, FALSE, FALSE, FALSE, FALSE, -1, config_file}
nullptr, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, -1, config_file}
};
load_config(GTK_WINDOW(window), vte, &info.config, geometry ? nullptr : &geometry);