mirror of
https://github.com/dguglielmi/sunny-overlay.git
synced 2025-12-06 20:22:38 +01:00
269 lines
13 KiB
Diff
269 lines
13 KiB
Diff
diff -dNur a/src/org.gnome.Terminal.gschema.xml b/src/org.gnome.Terminal.gschema.xml
|
|
--- a/src/org.gnome.Terminal.gschema.xml 2014-06-23 19:54:22.000000000 +0200
|
|
+++ b/src/org.gnome.Terminal.gschema.xml 2014-08-09 18:19:58.288956513 +0200
|
|
@@ -326,6 +326,16 @@
|
|
<default>'current'</default>
|
|
<summary>Which encoding to use</summary>
|
|
</key>
|
|
+ <key name="use-transparent-background" type="b">
|
|
+ <default>false</default>
|
|
+ <summary>Whether to use a transparent background</summary>
|
|
+ </key>
|
|
+ <key name="background-transparency-percent" type="i">
|
|
+ <default>50</default>
|
|
+ <range min="0" max="100"/>
|
|
+ <summary>Adjust the amount of transparency</summary>
|
|
+ <description>A value between 0 and 100, where 0 is opaque and 100 is fully transparent.</description>
|
|
+ </key>
|
|
</schema>
|
|
|
|
<!-- Keybinding settings -->
|
|
diff -dNur a/src/profile-editor.c b/src/profile-editor.c
|
|
--- a/src/profile-editor.c 2014-06-23 19:54:22.000000000 +0200
|
|
+++ b/src/profile-editor.c 2014-08-09 18:19:58.284956575 +0200
|
|
@@ -1026,6 +1026,16 @@
|
|
gtk_builder_get_object (builder, "rewrap-on-resize-checkbutton"),
|
|
"active", 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);
|
|
+
|
|
terminal_util_bind_mnemonic_label_sensitivity (editor);
|
|
|
|
terminal_util_dialog_focus_widget (editor, widget_name);
|
|
diff -dNur a/src/profile-preferences.ui b/src/profile-preferences.ui
|
|
--- a/src/profile-preferences.ui 2014-06-23 19:54:22.000000000 +0200
|
|
+++ b/src/profile-preferences.ui 2014-08-09 18:19:58.288956513 +0200
|
|
@@ -23,6 +23,11 @@
|
|
<property name="step_increment">1</property>
|
|
<property name="page_increment">100</property>
|
|
</object>
|
|
+ <object class="GtkAdjustment" id="background-transparent-adjustment">
|
|
+ <property name="upper">100</property>
|
|
+ <property name="step_increment">1</property>
|
|
+ <property name="page_increment">10</property>
|
|
+ </object>
|
|
<object class="GtkListStore" id="model1">
|
|
<columns>
|
|
<!-- column-name gchararray -->
|
|
@@ -1228,6 +1233,93 @@
|
|
<property name="position">1</property>
|
|
</packing>
|
|
</child>
|
|
+ <child>
|
|
+ <object class="GtkBox" id="use-transparent-background-box">
|
|
+ <property name="visible">True</property>
|
|
+ <property name="can_focus">False</property>
|
|
+ <property name="orientation">horizontal</property>
|
|
+ <property name="spacing">12</property>
|
|
+ <child>
|
|
+ <object class="GtkCheckButton" id="use-transparent-background">
|
|
+ <property name="label" translatable="yes">Use t_ransparent background</property>
|
|
+ <property name="visible">True</property>
|
|
+ <property name="can_focus">True</property>
|
|
+ <property name="receives_default">False</property>
|
|
+ <property name="use_underline">True</property>
|
|
+ <property name="xalign">0</property>
|
|
+ <property name="draw_indicator">True</property>
|
|
+ </object>
|
|
+ <packing>
|
|
+ <property name="expand">False</property>
|
|
+ <property name="fill">False</property>
|
|
+ <property name="position">0</property>
|
|
+ </packing>
|
|
+ </child>
|
|
+ <child>
|
|
+ <object class="GtkBox" id="background-transparent-scale-box">
|
|
+ <property name="visible">True</property>
|
|
+ <property name="can_focus">False</property>
|
|
+ <property name="orientation">horizontal</property>
|
|
+ <property name="spacing">6</property>
|
|
+ <child>
|
|
+ <object class="GtkLabel" id="background-transparent-min-label">
|
|
+ <property name="visible">True</property>
|
|
+ <property name="can_focus">False</property>
|
|
+ <property name="xalign">0.5</property>
|
|
+ <property name="label" translatable="yes">none</property>
|
|
+ <style>
|
|
+ <class name="dim-label"/>
|
|
+ </style>
|
|
+ </object>
|
|
+ <packing>
|
|
+ <property name="expand">False</property>
|
|
+ <property name="fill">False</property>
|
|
+ <property name="position">0</property>
|
|
+ </packing>
|
|
+ </child>
|
|
+ <child>
|
|
+ <object class="GtkScale" id="background-transparent-scale">
|
|
+ <property name="visible">True</property>
|
|
+ <property name="can_focus">True</property>
|
|
+ <property name="adjustment">background-transparent-adjustment</property>
|
|
+ <property name="draw_value">False</property>
|
|
+ </object>
|
|
+ <packing>
|
|
+ <property name="expand">True</property>
|
|
+ <property name="fill">True</property>
|
|
+ <property name="position">1</property>
|
|
+ </packing>
|
|
+ </child>
|
|
+ <child>
|
|
+ <object class="GtkLabel" id="background-transparent-max-label">
|
|
+ <property name="visible">True</property>
|
|
+ <property name="can_focus">False</property>
|
|
+ <property name="xalign">0.5</property>
|
|
+ <property name="label" translatable="yes">full</property>
|
|
+ <style>
|
|
+ <class name="dim-label"/>
|
|
+ </style>
|
|
+ </object>
|
|
+ <packing>
|
|
+ <property name="expand">False</property>
|
|
+ <property name="fill">False</property>
|
|
+ <property name="position">2</property>
|
|
+ </packing>
|
|
+ </child>
|
|
+ </object>
|
|
+ <packing>
|
|
+ <property name="expand">True</property>
|
|
+ <property name="fill">True</property>
|
|
+ <property name="position">1</property>
|
|
+ </packing>
|
|
+ </child>
|
|
+ </object>
|
|
+ <packing>
|
|
+ <property name="expand">True</property>
|
|
+ <property name="fill">True</property>
|
|
+ <property name="position">2</property>
|
|
+ </packing>
|
|
+ </child>
|
|
</object>
|
|
</child>
|
|
</object>
|
|
diff -dNur a/src/terminal-schemas.h b/src/terminal-schemas.h
|
|
--- a/src/terminal-schemas.h 2014-06-23 19:54:22.000000000 +0200
|
|
+++ b/src/terminal-schemas.h 2014-08-09 18:19:58.288956513 +0200
|
|
@@ -65,6 +65,9 @@
|
|
#define TERMINAL_PROFILE_VISIBLE_NAME_KEY "visible-name"
|
|
#define TERMINAL_PROFILE_WORD_CHARS_KEY "word-chars"
|
|
|
|
+#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_DARK_THEME_KEY "dark-theme"
|
|
diff -dNur a/src/terminal-screen.c b/src/terminal-screen.c
|
|
--- a/src/terminal-screen.c 2014-06-23 19:54:22.000000000 +0200
|
|
+++ b/src/terminal-screen.c 2014-08-09 18:19:58.288956513 +0200
|
|
@@ -792,7 +792,9 @@
|
|
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))
|
|
@@ -857,6 +859,9 @@
|
|
GdkRGBA fg, bg, bold, theme_fg, theme_bg;
|
|
GdkRGBA *boldp;
|
|
GtkStyleContext *context;
|
|
+ GtkWidget *toplevel;
|
|
+ gboolean transparent;
|
|
+ guint16 opacity;
|
|
|
|
context = gtk_widget_get_style_context (widget);
|
|
gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &theme_fg);
|
|
@@ -880,6 +885,22 @@
|
|
vte_terminal_set_colors_rgba (VTE_TERMINAL (screen), &fg, &bg,
|
|
colors, n_colors);
|
|
vte_terminal_set_color_bold_rgba (VTE_TERMINAL (screen), boldp);
|
|
+
|
|
+ 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);
|
|
+ opacity = (guint16) (G_MAXUINT16 * (100 - transparency_percent) / 100.0);
|
|
+ }
|
|
+ else
|
|
+ opacity = G_MAXUINT16;
|
|
+
|
|
+ vte_terminal_set_opacity (VTE_TERMINAL (screen), opacity);
|
|
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (screen));
|
|
+ if (toplevel != NULL && gtk_widget_is_toplevel (toplevel))
|
|
+ gtk_widget_set_app_paintable (toplevel, transparent);
|
|
}
|
|
|
|
void
|
|
diff -dNur a/src/terminal-window.c b/src/terminal-window.c
|
|
--- a/src/terminal-window.c 2014-06-23 19:54:23.000000000 +0200
|
|
+++ b/src/terminal-window.c 2014-08-09 18:19:58.288956513 +0200
|
|
@@ -2271,6 +2271,26 @@
|
|
}
|
|
|
|
static gboolean
|
|
+terminal_window_draw (GtkWidget *widget,
|
|
+ cairo_t *cr)
|
|
+{
|
|
+ if (gtk_widget_get_app_paintable (widget))
|
|
+ {
|
|
+ GtkStyleContext *context;
|
|
+ int width;
|
|
+ int height;
|
|
+
|
|
+ context = gtk_widget_get_style_context (widget);
|
|
+ width = gtk_widget_get_allocated_width (widget);
|
|
+ height = gtk_widget_get_allocated_height (widget);
|
|
+ gtk_render_background (context, cr, 0, 0, width, height);
|
|
+ gtk_render_frame (context, cr, 0, 0, width, height);
|
|
+ }
|
|
+
|
|
+ return GTK_WIDGET_CLASS (terminal_window_parent_class)->draw (widget, cr);
|
|
+}
|
|
+
|
|
+static gboolean
|
|
terminal_window_state_event (GtkWidget *widget,
|
|
GdkEventWindowState *event)
|
|
{
|
|
@@ -2619,6 +2639,8 @@
|
|
TerminalWindowPrivate *priv;
|
|
TerminalApp *app;
|
|
TerminalSettingsList *profiles_list;
|
|
+ GdkScreen *screen;
|
|
+ GdkVisual *visual;
|
|
GtkActionGroup *action_group;
|
|
GtkAction *action;
|
|
GtkUIManager *manager;
|
|
@@ -2634,6 +2656,11 @@
|
|
|
|
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);
|
|
@@ -2799,6 +2826,7 @@
|
|
|
|
widget_class->show = terminal_window_show;
|
|
widget_class->realize = terminal_window_realize;
|
|
+ widget_class->draw = terminal_window_draw;
|
|
widget_class->window_state_event = terminal_window_state_event;
|
|
widget_class->screen_changed = terminal_window_screen_changed;
|
|
widget_class->style_updated = terminal_window_style_updated;
|