Merge lp:~larsu/gnome-terminal/update-restore-transparency-patch into lp:~ubuntu-desktop/gnome-terminal/ubuntu

Proposed by Lars Karlitski
Status: Needs review
Proposed branch: lp:~larsu/gnome-terminal/update-restore-transparency-patch
Merge into: lp:~ubuntu-desktop/gnome-terminal/ubuntu
Diff against target: 445 lines (+193/-134)
1 file modified
debian/patches/0001-Restore-transparency.patch (+193/-134)
To merge this branch: bzr merge lp:~larsu/gnome-terminal/update-restore-transparency-patch
Reviewer Review Type Date Requested Status
VCS imports Pending
Review via email: mp+221049@code.launchpad.net

This proposal supersedes a proposal from 2014-05-27.

Description of the change

Update restore transparency patch

Remove getting the transparency from the theme to avoid the additional preference.

Also set app-paintable on the window directly (when it is actually transparent) instead of setting it from the widget. The window now paints its background so that nothing but the terminal widget is transparent.

To post a comment you must log in.

Unmerged revisions

126. By Lars Karlitski

Transparency patch: only set app-paintable when the window is actually transparent

125. By Lars Karlitski

Update restore transparency patch

Remove getting the transparency from the theme to avoid the additional
preference.

Also set app-paintable on the window directly instead of setting it from the
widget. The window now paints its background so that nothing but the terminal
widget is transparent.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/patches/0001-Restore-transparency.patch'
2--- debian/patches/0001-Restore-transparency.patch 2014-05-16 11:54:11 +0000
3+++ debian/patches/0001-Restore-transparency.patch 2014-05-27 09:38:10 +0000
4@@ -1,4 +1,4 @@
5-From cd92f2088377bd2b5145ec56f4dab50adcf29881 Mon Sep 17 00:00:00 2001
6+From 4e059adba38aef1397df1c8a8c58986059af7306 Mon Sep 17 00:00:00 2001
7 From: Debarshi Ray <debarshir@gnome.org>
8 Date: Mon, 12 May 2014 14:57:18 +0200
9 Subject: [PATCH] Restore transparency
10@@ -14,15 +14,15 @@
11 src/profile-editor.c | 10 +++++
12 src/profile-preferences.ui | 92 ++++++++++++++++++++++++++++++++++++++
13 src/terminal-schemas.h | 3 ++
14- src/terminal-screen.c | 23 +++++++++-
15- src/terminal-window.c | 7 +++
16- 6 files changed, 143 insertions(+), 1 deletion(-)
17+ src/terminal-screen.c | 19 +++++++-
18+ src/terminal-window.c | 77 ++++++++++++++++++++++++++++---
19+ 6 files changed, 204 insertions(+), 6 deletions(-)
20
21-Index: b/src/org.gnome.Terminal.gschema.xml
22-===================================================================
23+diff --git a/src/org.gnome.Terminal.gschema.xml b/src/org.gnome.Terminal.gschema.xml
24+index 94eeae9..ab7e914 100644
25 --- a/src/org.gnome.Terminal.gschema.xml
26 +++ b/src/org.gnome.Terminal.gschema.xml
27-@@ -326,6 +326,20 @@
28+@@ -326,6 +326,15 @@
29 <default>'current'</default>
30 <summary>Which encoding to use</summary>
31 </key>
32@@ -30,11 +30,6 @@
33 + <default>false</default>
34 + <summary>Whether to use a transparent background</summary>
35 + </key>
36-+ <key name="use-theme-transparency" type="b">
37-+ <default>true</default>
38-+ <summary>Whether to use the value of TerminalScreen-background-darkness,
39-+ if available, from the theme for the transparency value.</summary>
40-+ </key>
41 + <key name="background-transparency-percent" type="i">
42 + <default>50</default>
43 + <summary>Adjust the amount of transparency</summary>
44@@ -43,42 +38,11 @@
45 </schema>
46
47 <!-- Keybinding settings -->
48-Index: b/src/profile-editor.c
49-===================================================================
50+diff --git a/src/profile-editor.c b/src/profile-editor.c
51+index 1b3e855..9ab66c8 100644
52 --- a/src/profile-editor.c
53 +++ b/src/profile-editor.c
54-@@ -34,6 +34,7 @@
55- #include "terminal-util.h"
56- #include "terminal-profiles-list.h"
57- #include "terminal-libgsystem.h"
58-+#include "terminal-window.h"
59-
60- typedef struct _TerminalColorScheme TerminalColorScheme;
61-
62-@@ -711,6 +712,7 @@
63- GtkWidget *editor, *w;
64- gs_free char *uuid = NULL;
65- guint i;
66-+ gfloat style_darkness;
67-
68- editor = g_object_get_data (G_OBJECT (profile), "editor-window");
69- if (editor)
70-@@ -782,6 +784,14 @@
71- profile);
72- }
73-
74-+ gtk_widget_style_get (GTK_WIDGET (
75-+ terminal_window_get_active (TERMINAL_WINDOW (transient_parent))),
76-+ "background-darkness", &style_darkness,
77-+ NULL);
78-+ gtk_widget_set_visible (gtk_builder_get_object (
79-+ builder,
80-+ "use-theme-transparency-checkbutton"), style_darkness >= 0);
81-+
82- profile_palette_notify_colorpickers_cb (profile, TERMINAL_PROFILE_PALETTE_KEY, editor);
83- g_signal_connect (profile, "changed::" TERMINAL_PROFILE_PALETTE_KEY,
84- G_CALLBACK (profile_palette_notify_colorpickers_cb),
85-@@ -1026,6 +1036,28 @@
86+@@ -1026,6 +1026,16 @@ terminal_profile_edit (GSettings *profile,
87 gtk_builder_get_object (builder, "rewrap-on-resize-checkbutton"),
88 "active", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
89
90@@ -91,24 +55,12 @@
91 + g_settings_bind (profile, TERMINAL_PROFILE_BACKGROUND_TRANSPARENCY_PERCENT,
92 + gtk_builder_get_object (builder, "background-transparent-adjustment"),
93 + "value", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
94-+ g_settings_bind (profile, TERMINAL_PROFILE_USE_THEME_TRANSPARENCY,
95-+ gtk_builder_get_object (builder, "use-theme-transparency-checkbutton"),
96-+ "active", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
97-+
98-+ if (style_darkness >= 0)
99-+ g_settings_bind (profile, TERMINAL_PROFILE_USE_THEME_TRANSPARENCY,
100-+ gtk_builder_get_object (builder, "use-transparent-background-box"),
101-+ "sensitive",
102-+ G_SETTINGS_BIND_GET |
103-+ G_SETTINGS_BIND_INVERT_BOOLEAN |
104-+ G_SETTINGS_BIND_NO_SENSITIVITY);
105-+
106 +
107 terminal_util_bind_mnemonic_label_sensitivity (editor);
108
109 terminal_util_dialog_focus_widget (editor, widget_name);
110-Index: b/src/profile-preferences.ui
111-===================================================================
112+diff --git a/src/profile-preferences.ui b/src/profile-preferences.ui
113+index f648938..2b068f0 100644
114 --- a/src/profile-preferences.ui
115 +++ b/src/profile-preferences.ui
116 @@ -23,6 +23,11 @@
117@@ -123,7 +75,7 @@
118 <object class="GtkListStore" id="model1">
119 <columns>
120 <!-- column-name gchararray -->
121-@@ -1228,6 +1233,122 @@
122+@@ -1228,6 +1233,93 @@
123 <property name="position">1</property>
124 </packing>
125 </child>
126@@ -214,109 +166,54 @@
127 + <property name="position">2</property>
128 + </packing>
129 + </child>
130-+ <child>
131-+ <object class="GtkBox" id="use-theme-transparency-box">
132-+ <property name="visible">True</property>
133-+ <property name="can_focus">False</property>
134-+ <property name="orientation">horizontal</property>
135-+ <property name="spacing">12</property>
136-+ <child>
137-+ <object class="GtkCheckButton" id="use-theme-transparency-checkbutton">
138-+ <property name="label" translatable="yes">Use transparency from system theme</property>
139-+ <property name="visible">True</property>
140-+ <property name="can_focus">True</property>
141-+ <property name="receives_default">False</property>
142-+ <property name="use_underline">True</property>
143-+ <property name="xalign">0</property>
144-+ <property name="draw_indicator">True</property>
145-+ </object>
146-+ <packing>
147-+ <property name="expand">False</property>
148-+ <property name="fill">False</property>
149-+ <property name="position">0</property>
150-+ </packing>
151-+ </child>
152-+ </object>
153-+ <packing>
154-+ <property name="expand">True</property>
155-+ <property name="fill">True</property>
156-+ <property name="position">3</property>
157-+ </packing>
158-+ </child>
159 </object>
160 </child>
161 </object>
162-Index: b/src/terminal-schemas.h
163-===================================================================
164+diff --git a/src/terminal-schemas.h b/src/terminal-schemas.h
165+index 443cf7b..c242857 100644
166 --- a/src/terminal-schemas.h
167 +++ b/src/terminal-schemas.h
168-@@ -65,6 +65,10 @@
169+@@ -65,6 +65,9 @@ G_BEGIN_DECLS
170 #define TERMINAL_PROFILE_VISIBLE_NAME_KEY "visible-name"
171 #define TERMINAL_PROFILE_WORD_CHARS_KEY "word-chars"
172
173 +#define TERMINAL_PROFILE_USE_TRANSPARENT_BACKGROUND "use-transparent-background"
174-+#define TERMINAL_PROFILE_USE_THEME_TRANSPARENCY "use-theme-transparency"
175 +#define TERMINAL_PROFILE_BACKGROUND_TRANSPARENCY_PERCENT "background-transparency-percent"
176 +
177 #define TERMINAL_SETTING_CONFIRM_CLOSE_KEY "confirm-close"
178 #define TERMINAL_SETTING_DEFAULT_SHOW_MENUBAR_KEY "default-show-menubar"
179 #define TERMINAL_SETTING_DARK_THEME_KEY "dark-theme"
180-Index: b/src/terminal-screen.c
181-===================================================================
182+diff --git a/src/terminal-screen.c b/src/terminal-screen.c
183+index ac971c0..2fe2ea1 100644
184 --- a/src/terminal-screen.c
185 +++ b/src/terminal-screen.c
186-@@ -539,6 +539,10 @@
187-
188- g_type_class_add_private (object_class, sizeof (TerminalScreenPrivate));
189-
190-+ gtk_widget_class_install_style_property (widget_class,
191-+ g_param_spec_float ("background-darkness", NULL, NULL, -1, 1, -1,
192-+ G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
193-+
194- /* Precompile the regexes */
195- n_url_regexes = G_N_ELEMENTS (url_regex_patterns);
196- url_regexes = g_new0 (GRegex*, n_url_regexes);
197-@@ -792,7 +796,10 @@
198+@@ -792,7 +792,9 @@ terminal_screen_profile_changed_cb (GSettings *profile,
199 prop_name == I_(TERMINAL_PROFILE_BACKGROUND_COLOR_KEY) ||
200 prop_name == I_(TERMINAL_PROFILE_BOLD_COLOR_SAME_AS_FG_KEY) ||
201 prop_name == I_(TERMINAL_PROFILE_BOLD_COLOR_KEY) ||
202 - prop_name == I_(TERMINAL_PROFILE_PALETTE_KEY))
203 + prop_name == I_(TERMINAL_PROFILE_PALETTE_KEY) ||
204 + prop_name == I_(TERMINAL_PROFILE_USE_TRANSPARENT_BACKGROUND) ||
205-+ prop_name == I_(TERMINAL_PROFILE_BACKGROUND_TRANSPARENCY_PERCENT) ||
206-+ prop_name == I_(TERMINAL_PROFILE_USE_THEME_TRANSPARENCY))
207++ prop_name == I_(TERMINAL_PROFILE_BACKGROUND_TRANSPARENCY_PERCENT))
208 update_color_scheme (screen);
209
210 if (!prop_name || prop_name == I_(TERMINAL_PROFILE_AUDIBLE_BELL_KEY))
211-@@ -857,6 +864,10 @@
212+@@ -857,6 +859,8 @@ update_color_scheme (TerminalScreen *screen)
213 GdkRGBA fg, bg, bold, theme_fg, theme_bg;
214 GdkRGBA *boldp;
215 GtkStyleContext *context;
216-+ GtkWidget *toplevel;
217-+ gboolean transparent, theme_transparent;
218++ gboolean transparent;
219 + guint16 opacity;
220-+ gfloat style_darkness;
221
222 context = gtk_widget_get_style_context (widget);
223 gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &theme_fg);
224-@@ -880,6 +891,33 @@
225+@@ -880,6 +884,19 @@ update_color_scheme (TerminalScreen *screen)
226 vte_terminal_set_colors_rgba (VTE_TERMINAL (screen), &fg, &bg,
227 colors, n_colors);
228 vte_terminal_set_color_bold_rgba (VTE_TERMINAL (screen), boldp);
229 +
230-+
231-+ theme_transparent = g_settings_get_boolean (profile, TERMINAL_PROFILE_USE_THEME_TRANSPARENCY);
232 + transparent = g_settings_get_boolean (profile, TERMINAL_PROFILE_USE_TRANSPARENT_BACKGROUND);
233-+
234-+ gtk_widget_style_get (GTK_WIDGET (screen),
235-+ "background-darkness", &style_darkness,
236-+ NULL);
237-+
238-+ if (theme_transparent && style_darkness >= 0)
239-+ {
240-+ opacity = (guint16) (G_MAXUINT16 * style_darkness);
241-+ }
242-+ else if (transparent)
243++ if (transparent)
244 + {
245 + gint transparency_percent;
246 +
247@@ -327,17 +224,140 @@
248 + opacity = G_MAXUINT16;
249 +
250 + vte_terminal_set_opacity (VTE_TERMINAL (screen), opacity);
251-+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (screen));
252-+ if (toplevel != NULL && gtk_widget_is_toplevel (toplevel))
253-+ gtk_widget_set_app_paintable (toplevel, transparent);
254 }
255
256 void
257-Index: b/src/terminal-window.c
258-===================================================================
259+diff --git a/src/terminal-window.c b/src/terminal-window.c
260+index db06b3f..31b8516 100644
261 --- a/src/terminal-window.c
262 +++ b/src/terminal-window.c
263-@@ -2619,6 +2619,8 @@
264+@@ -1234,6 +1234,23 @@ position_menu_under_widget (GtkMenu *menu,
265+ }
266+
267+ static void
268++terminal_window_update_transparency (TerminalWindow *window)
269++{
270++ TerminalWindowPrivate *priv = window->priv;
271++ gboolean is_transparent = FALSE;
272++
273++ if (priv->active_screen)
274++ {
275++ GSettings *profile;
276++
277++ profile = terminal_screen_get_profile (priv->active_screen);
278++ is_transparent = g_settings_get_boolean (profile, TERMINAL_PROFILE_USE_TRANSPARENT_BACKGROUND);
279++ }
280++
281++ gtk_widget_set_app_paintable (GTK_WIDGET (window), is_transparent);
282++}
283++
284++static void
285+ terminal_set_profile_toggled_callback (GtkToggleAction *action,
286+ TerminalWindow *window)
287+ {
288+@@ -1252,6 +1269,8 @@ terminal_set_profile_toggled_callback (GtkToggleAction *action,
289+ g_signal_handlers_block_by_func (priv->active_screen, G_CALLBACK (profile_set_callback), window);
290+ terminal_screen_set_profile (priv->active_screen, profile);
291+ g_signal_handlers_unblock_by_func (priv->active_screen, G_CALLBACK (profile_set_callback), window);
292++
293++ terminal_window_update_transparency (window);
294+ }
295+
296+ static void
297+@@ -1295,7 +1314,26 @@ profile_visible_name_notify_cb (GSettings *profile,
298+ }
299+
300+ static void
301+-disconnect_profiles_from_actions_in_group (GtkActionGroup *action_group)
302++profile_background_transparency_notify_cb (GSettings *profile,
303++ const char *key,
304++ gpointer user_data)
305++{
306++ TerminalWindow *window = user_data;
307++ TerminalWindowPrivate *priv = window->priv;
308++ GSettings *active_profile;
309++
310++ if (priv->active_screen)
311++ active_profile = terminal_screen_get_profile (priv->active_screen);
312++ else
313++ active_profile = NULL;
314++
315++ if (profile == active_profile)
316++ terminal_window_update_transparency (window);
317++}
318++
319++static void
320++disconnect_profiles_from_actions_in_group (TerminalWindow *window,
321++ GtkActionGroup *action_group)
322+ {
323+ GList *actions, *l;
324+
325+@@ -1310,6 +1348,7 @@ disconnect_profiles_from_actions_in_group (GtkActionGroup *action_group)
326+ continue;
327+
328+ g_signal_handlers_disconnect_by_func (profile, G_CALLBACK (profile_visible_name_notify_cb), action);
329++ g_signal_handlers_disconnect_by_func (profile, G_CALLBACK (profile_background_transparency_notify_cb), window);
330+ }
331+ g_list_free (actions);
332+ }
333+@@ -1370,7 +1409,7 @@ terminal_window_update_set_profile_menu (TerminalWindow *window)
334+
335+ if (priv->profiles_action_group != NULL)
336+ {
337+- disconnect_profiles_from_actions_in_group (priv->profiles_action_group);
338++ disconnect_profiles_from_actions_in_group (window, priv->profiles_action_group);
339+ gtk_ui_manager_remove_action_group (priv->ui_manager,
340+ priv->profiles_action_group);
341+ priv->profiles_action_group = NULL;
342+@@ -1426,6 +1465,8 @@ terminal_window_update_set_profile_menu (TerminalWindow *window)
343+ profile_visible_name_notify_cb (profile, TERMINAL_PROFILE_VISIBLE_NAME_KEY, GTK_ACTION (profile_action));
344+ g_signal_connect (profile, "changed::" TERMINAL_PROFILE_VISIBLE_NAME_KEY,
345+ G_CALLBACK (profile_visible_name_notify_cb), profile_action);
346++ g_signal_connect (profile, "changed::" TERMINAL_PROFILE_USE_TRANSPARENT_BACKGROUND,
347++ G_CALLBACK (profile_background_transparency_notify_cb), window);
348+ g_signal_connect (profile_action, "toggled",
349+ G_CALLBACK (terminal_set_profile_toggled_callback), window);
350+
351+@@ -1463,6 +1504,8 @@ terminal_window_create_new_terminal_action (TerminalWindow *window,
352+ profile_visible_name_notify_cb (profile, TERMINAL_PROFILE_VISIBLE_NAME_KEY, action);
353+ g_signal_connect (profile, "changed::" TERMINAL_PROFILE_VISIBLE_NAME_KEY,
354+ G_CALLBACK (profile_visible_name_notify_cb), action);
355++ g_signal_connect (profile, "changed::" TERMINAL_PROFILE_USE_TRANSPARENT_BACKGROUND,
356++ G_CALLBACK (profile_background_transparency_notify_cb), window);
357+ g_signal_connect (action, "activate", callback, window);
358+
359+ gtk_action_group_add_action (priv->new_terminal_action_group, action);
360+@@ -1488,7 +1531,7 @@ terminal_window_update_new_terminal_menus (TerminalWindow *window)
361+
362+ if (priv->new_terminal_action_group != NULL)
363+ {
364+- disconnect_profiles_from_actions_in_group (priv->new_terminal_action_group);
365++ disconnect_profiles_from_actions_in_group (window, priv->new_terminal_action_group);
366+ gtk_ui_manager_remove_action_group (priv->ui_manager,
367+ priv->new_terminal_action_group);
368+ priv->new_terminal_action_group = NULL;
369+@@ -2271,6 +2314,20 @@ terminal_window_realize (GtkWidget *widget)
370+ }
371+
372+ static gboolean
373++terminal_window_draw (GtkWidget *widget,
374++ cairo_t *cr)
375++{
376++ GtkStyleContext *context = gtk_widget_get_style_context (widget);
377++ int width = gtk_widget_get_allocated_width (widget);
378++ int height = gtk_widget_get_allocated_height (widget);
379++
380++ gtk_render_background (context, cr, 0, 0, width, height);
381++ gtk_render_frame (context, cr, 0, 0, width, height);
382++
383++ return GTK_WIDGET_CLASS (terminal_window_parent_class)->draw (widget, cr);
384++}
385++
386++static gboolean
387+ terminal_window_state_event (GtkWidget *widget,
388+ GdkEventWindowState *event)
389+ {
390+@@ -2619,6 +2676,8 @@ terminal_window_init (TerminalWindow *window)
391 TerminalWindowPrivate *priv;
392 TerminalApp *app;
393 TerminalSettingsList *profiles_list;
394@@ -346,7 +366,7 @@
395 GtkActionGroup *action_group;
396 GtkAction *action;
397 GtkUIManager *manager;
398-@@ -2634,6 +2636,11 @@
399+@@ -2634,6 +2693,11 @@ terminal_window_init (TerminalWindow *window)
400
401 gtk_widget_init_template (GTK_WIDGET (window));
402
403@@ -358,3 +378,42 @@
404 uuid_generate (u);
405 uuid_unparse (u, uuidstr);
406 priv->uuid = g_strdup (uuidstr);
407+@@ -2799,6 +2863,7 @@ terminal_window_class_init (TerminalWindowClass *klass)
408+
409+ widget_class->show = terminal_window_show;
410+ widget_class->realize = terminal_window_realize;
411++ widget_class->draw = terminal_window_draw;
412+ widget_class->window_state_event = terminal_window_state_event;
413+ widget_class->screen_changed = terminal_window_screen_changed;
414+ widget_class->style_updated = terminal_window_style_updated;
415+@@ -2839,9 +2904,9 @@ terminal_window_dispose (GObject *object)
416+ }
417+
418+ if (priv->profiles_action_group != NULL)
419+- disconnect_profiles_from_actions_in_group (priv->profiles_action_group);
420++ disconnect_profiles_from_actions_in_group (window, priv->profiles_action_group);
421+ if (priv->new_terminal_action_group != NULL)
422+- disconnect_profiles_from_actions_in_group (priv->new_terminal_action_group);
423++ disconnect_profiles_from_actions_in_group (window, priv->new_terminal_action_group);
424+
425+ app = terminal_app_get ();
426+ profiles_list = terminal_app_get_profiles_list (app);
427+@@ -2959,6 +3024,7 @@ profile_set_callback (TerminalScreen *screen,
428+ return;
429+
430+ terminal_window_update_set_profile_menu_active_profile (window);
431++ terminal_window_update_transparency (window);
432+ }
433+
434+ static void
435+@@ -3334,6 +3400,7 @@ mdi_screen_switched_cb (TerminalMdiContainer *container,
436+ terminal_window_update_copy_sensitivity (screen, window);
437+ terminal_window_update_zoom_sensitivity (window);
438+ terminal_window_update_search_sensitivity (screen, window);
439++ terminal_window_update_transparency (window);
440+ }
441+
442+ static void
443+--
444+2.0.0.rc0
445+

Subscribers

People subscribed via source and target branches

to all changes: