From 1cb63cd1c90cb5bfc8ed2e6d161a7b96c51d8a29 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Mon, 12 May 2014 14:57:18 +0200 Subject: [PATCH] Restore transparency The transparency settings were removed as a side effect of 2bff4b63ed3ceef6055e35563e9b0b33ad57349d This restores them and you will need a compositing window manager to use it. The background image setting, also known as faux transparency, was not restored. --- src/org.gnome.Terminal.gschema.xml | 10 ++++ src/profile-editor.c | 11 ++++ src/profile-preferences.ui | 92 ++++++++++++++++++++++++++++++++++++ src/terminal-schemas.h | 3 + src/terminal-screen.c | 22 ++++++++- src/terminal-window.c | 7 +++ 6 files changed, 144 insertions(+), 1 deletions(-) Index: gnome-terminal-3.17.91/src/org.gnome.Terminal.gschema.xml =================================================================== --- gnome-terminal-3.17.91.orig/src/org.gnome.Terminal.gschema.xml +++ gnome-terminal-3.17.91/src/org.gnome.Terminal.gschema.xml @@ -334,6 +334,16 @@ 'narrow' Whether ambiguous-width characters are narrow or wide when using UTF-8 encoding + + false + Whether to use a transparent background + + + 50 + + Adjust the amount of transparency + A value between 0 and 100, where 0 is opaque and 100 is fully transparent. + Index: gnome-terminal-3.17.91/src/profile-editor.c =================================================================== --- gnome-terminal-3.17.91.orig/src/profile-editor.c +++ gnome-terminal-3.17.91/src/profile-editor.c @@ -1097,7 +1097,18 @@ terminal_profile_edit (GSettings *profi "active-id", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET); + g_settings_bind (profile, TERMINAL_PROFILE_USE_TRANSPARENT_BACKGROUND, + gtk_builder_get_object (builder, "use-transparent-background"), + "active", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET); + g_settings_bind (profile, TERMINAL_PROFILE_USE_TRANSPARENT_BACKGROUND, + gtk_builder_get_object (builder, "background-transparent-scale-box"), + "sensitive", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_NO_SENSITIVITY); + g_settings_bind (profile, TERMINAL_PROFILE_BACKGROUND_TRANSPARENCY_PERCENT, + gtk_builder_get_object (builder, "background-transparent-adjustment"), + "value", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET); + /* Finished! */ + terminal_util_bind_mnemonic_label_sensitivity (editor); terminal_util_dialog_focus_widget (editor, widget_name); Index: gnome-terminal-3.17.91/src/profile-preferences.ui =================================================================== --- gnome-terminal-3.17.91.orig/src/profile-preferences.ui +++ gnome-terminal-3.17.91/src/profile-preferences.ui @@ -23,6 +23,11 @@ 1 100 + + 100 + 1 + 10 + @@ -991,6 +996,93 @@ 1 + + + True + False + horizontal + 12 + + + Use t_ransparent background + True + True + False + True + 0 + True + + + False + False + 0 + + + + + True + False + horizontal + 6 + + + True + False + 0.5 + none + + + + False + False + 0 + + + + + True + True + background-transparent-adjustment + False + + + True + True + 1 + + + + + True + False + 0.5 + full + + + + False + False + 2 + + + + + True + True + 1 + + + + + True + True + 2 + + Index: gnome-terminal-3.17.91/src/terminal-schemas.h =================================================================== --- gnome-terminal-3.17.91.orig/src/terminal-schemas.h +++ gnome-terminal-3.17.91/src/terminal-schemas.h @@ -63,6 +63,9 @@ G_BEGIN_DECLS #define TERMINAL_PROFILE_VISIBLE_NAME_KEY "visible-name" #define TERMINAL_PROFILE_WORD_CHAR_EXCEPTIONS_KEY "word-char-exceptions" +#define TERMINAL_PROFILE_USE_TRANSPARENT_BACKGROUND "use-transparent-background" +#define TERMINAL_PROFILE_BACKGROUND_TRANSPARENCY_PERCENT "background-transparency-percent" + #define TERMINAL_SETTING_CONFIRM_CLOSE_KEY "confirm-close" #define TERMINAL_SETTING_DEFAULT_SHOW_MENUBAR_KEY "default-show-menubar" #define TERMINAL_SETTING_ENABLE_MENU_BAR_ACCEL_KEY "menu-accelerator-enabled" Index: gnome-terminal-3.17.91/src/terminal-screen.c =================================================================== --- gnome-terminal-3.17.91.orig/src/terminal-screen.c +++ gnome-terminal-3.17.91/src/terminal-screen.c @@ -765,7 +765,9 @@ terminal_screen_profile_changed_cb (GSet prop_name == I_(TERMINAL_PROFILE_BACKGROUND_COLOR_KEY) || prop_name == I_(TERMINAL_PROFILE_BOLD_COLOR_SAME_AS_FG_KEY) || prop_name == I_(TERMINAL_PROFILE_BOLD_COLOR_KEY) || - prop_name == I_(TERMINAL_PROFILE_PALETTE_KEY)) + prop_name == I_(TERMINAL_PROFILE_PALETTE_KEY) || + prop_name == I_(TERMINAL_PROFILE_USE_TRANSPARENT_BACKGROUND) || + prop_name == I_(TERMINAL_PROFILE_BACKGROUND_TRANSPARENCY_PERCENT)) update_color_scheme (screen); if (!prop_name || prop_name == I_(TERMINAL_PROFILE_AUDIBLE_BELL_KEY)) @@ -831,6 +833,8 @@ update_color_scheme (TerminalScreen *scr GdkRGBA fg, bg, bold, theme_fg, theme_bg; GdkRGBA *boldp; GtkStyleContext *context; + GtkWidget *toplevel; + gboolean transparent; context = gtk_widget_get_style_context (widget); gtk_style_context_get_color (context, gtk_style_context_get_state (context), &theme_fg); @@ -851,9 +855,25 @@ update_color_scheme (TerminalScreen *scr boldp = NULL; colors = terminal_g_settings_get_rgba_palette (priv->profile, TERMINAL_PROFILE_PALETTE_KEY, &n_colors); + + transparent = g_settings_get_boolean (profile, TERMINAL_PROFILE_USE_TRANSPARENT_BACKGROUND); + if (transparent) + { + gint transparency_percent; + + transparency_percent = g_settings_get_int (profile, TERMINAL_PROFILE_BACKGROUND_TRANSPARENCY_PERCENT); + bg.alpha = (100 - transparency_percent) / 100.0; + } + else + bg.alpha = 1.0; + vte_terminal_set_colors (VTE_TERMINAL (screen), &fg, &bg, colors, n_colors); vte_terminal_set_color_bold (VTE_TERMINAL (screen), boldp); + + toplevel = gtk_widget_get_toplevel (GTK_WIDGET (screen)); + if (toplevel != NULL && gtk_widget_is_toplevel (toplevel)) + gtk_widget_set_app_paintable (toplevel, transparent); } static void Index: gnome-terminal-3.17.91/src/terminal-window.c =================================================================== --- gnome-terminal-3.17.91.orig/src/terminal-window.c +++ gnome-terminal-3.17.91/src/terminal-window.c @@ -2586,6 +2586,8 @@ terminal_window_init (TerminalWindow *wi TerminalWindowPrivate *priv; TerminalApp *app; TerminalSettingsList *profiles_list; + GdkScreen *screen; + GdkVisual *visual; GtkActionGroup *action_group; GtkAction *action; GtkUIManager *manager; @@ -2601,6 +2603,11 @@ terminal_window_init (TerminalWindow *wi gtk_widget_init_template (GTK_WIDGET (window)); + screen = gtk_widget_get_screen (GTK_WIDGET (window)); + visual = gdk_screen_get_rgba_visual (screen); + if (visual != NULL) + gtk_widget_set_visual (GTK_WIDGET (window), visual); + uuid_generate (u); uuid_unparse (u, uuidstr); priv->uuid = g_strdup (uuidstr);