move transparency setting to config file

This commit is contained in:
Daniel Micay 2012-06-07 21:05:31 -04:00
parent 92c3e955a6
commit 1294bd21ed
3 changed files with 22 additions and 14 deletions

View File

@ -1,8 +1,5 @@
static const char *url_regex = "(ftp|http)s?://[-a-zA-Z0-9.?$%&/=_~#.,:;+()]*"; static const char *url_regex = "(ftp|http)s?://[-a-zA-Z0-9.?$%&/=_~#.,:;+()]*";
// 0.0: opaque, 1.0: transparent
//#define TRANSPARENCY 0.2
static const char *term = "vte-256color"; static const char *term = "vte-256color";
// keybindings // keybindings

View File

@ -254,10 +254,11 @@ static bool get_config_ ## NAME (GKeyFile *config, const char *group, const char
MAKE_GET_CONFIG_FUNCTION(boolean, gboolean) MAKE_GET_CONFIG_FUNCTION(boolean, gboolean)
MAKE_GET_CONFIG_FUNCTION(integer, gint) MAKE_GET_CONFIG_FUNCTION(integer, gint)
MAKE_GET_CONFIG_FUNCTION(string, gchar *) MAKE_GET_CONFIG_FUNCTION(string, gchar *)
MAKE_GET_CONFIG_FUNCTION(double, gdouble)
static void load_config(GtkWindow *window, VteTerminal *vte, static void load_config(GtkWindow *window, VteTerminal *vte,
gboolean *dynamic_title, gboolean *urgent_on_bell, gboolean *dynamic_title, gboolean *urgent_on_bell,
gboolean *clickable_url) { gboolean *clickable_url, double *transparency) {
static const char *filename = "termite.cfg"; static const char *filename = "termite.cfg";
const gchar *dir = g_get_user_config_dir(); const gchar *dir = g_get_user_config_dir();
@ -335,6 +336,11 @@ static void load_config(GtkWindow *window, VteTerminal *vte,
g_free(cfgstr); g_free(cfgstr);
} }
gdouble cfgdouble;
if (get_config_double(config, "options", "transparency", &cfgdouble)) {
*transparency = cfgdouble;
}
GdkColor foreground, background, cursor, palette[16]; GdkColor foreground, background, cursor, palette[16];
static const char *color_names[8] = {"black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"}; static const char *color_names[8] = {"black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"};
@ -467,18 +473,20 @@ int main(int argc, char **argv) {
g_signal_connect(overlay, "get-child-position", G_CALLBACK(position_overlay_cb), NULL); g_signal_connect(overlay, "get-child-position", G_CALLBACK(position_overlay_cb), NULL);
gboolean dynamic_title = FALSE, urgent_on_bell = FALSE, clickable_url = FALSE; gboolean dynamic_title = FALSE, urgent_on_bell = FALSE, clickable_url = FALSE;
load_config(GTK_WINDOW(window), VTE_TERMINAL(vte), &dynamic_title, &urgent_on_bell, &clickable_url); double transparency = 0.0;
load_config(GTK_WINDOW(window), VTE_TERMINAL(vte), &dynamic_title,
&urgent_on_bell, &clickable_url, &transparency);
#ifdef TRANSPARENCY if (transparency > 0.0) {
GdkScreen *screen = gtk_widget_get_screen(window); GdkScreen *screen = gtk_widget_get_screen(window);
GdkVisual *visual = gdk_screen_get_rgba_visual(screen); GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
if (!visual) { if (!visual) {
visual = gdk_screen_get_system_visual(screen); visual = gdk_screen_get_system_visual(screen);
}
gtk_widget_set_visual(window, visual);
vte_terminal_set_background_saturation(VTE_TERMINAL(vte), transparency);
vte_terminal_set_opacity(VTE_TERMINAL(vte), (guint16)(0xffff * (1 - transparency)));
} }
gtk_widget_set_visual(window, visual);
vte_terminal_set_background_saturation(VTE_TERMINAL(vte), TRANSPARENCY);
vte_terminal_set_opacity(VTE_TERMINAL(vte), (guint16)(0xffff * (1 - TRANSPARENCY)));
#endif
if (clickable_url) { if (clickable_url) {
int tmp = vte_terminal_match_add_gregex(VTE_TERMINAL(vte), int tmp = vte_terminal_match_add_gregex(VTE_TERMINAL(vte),

View File

@ -12,6 +12,9 @@ font = Monospace 9
scrollback_lines = 1000 scrollback_lines = 1000
#icon_name = terminal #icon_name = terminal
# 0.0: opaque, 1.0: transparent
transparency = 0.0
# SYSTEM, ON or OFF # SYSTEM, ON or OFF
cursor_blink = SYSTEM cursor_blink = SYSTEM