Merge lp:~victored/granite/lp-1002050 into lp:~elementary-pantheon/granite/granite

Proposed by Victor Martinez
Status: Merged
Merged at revision: 249
Proposed branch: lp:~victored/granite/lp-1002050
Merge into: lp:~elementary-pantheon/granite/granite
Diff against target: 145 lines (+40/-33)
3 files modified
lib/Widgets/AboutDialog.vala (+4/-1)
lib/Widgets/DecoratedWindow.vala (+30/-28)
lib/Widgets/LightWindow.vala (+6/-4)
To merge this branch: bzr merge lp:~victored/granite/lp-1002050
Reviewer Review Type Date Requested Status
Cody Garver (community) Approve
Review via email: mp+107910@code.launchpad.net

Description of the change

This branch fixes bug #1002050 by passing and setting the style classes at construct time.

I've had no problems using custom theming for DecoratedWindow on Noise, but for some reason it didn't work well for the LightWindow class. Probably a bug in GTK+?

To post a comment you must log in.
Revision history for this message
Cody Garver (codygarver) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/Widgets/AboutDialog.vala'
2--- lib/Widgets/AboutDialog.vala 2012-05-22 08:15:07 +0000
3+++ lib/Widgets/AboutDialog.vala 2012-05-30 03:44:19 +0000
4@@ -97,7 +97,10 @@
5
6 var draw_ref = new Gtk.Window ();
7 draw_ref.get_style_context ().add_class (STYLE_CLASS_CONTENT_VIEW_WINDOW);
8- DecoratedWindow.set_default_theming (draw_ref, action_area);
9+
10+ // Apply DecoratedWindow's theming
11+ DecoratedWindow.set_default_theming (draw_ref);
12+
13 action_area.get_style_context ().add_class (STYLE_CLASS_CONTENT_VIEW);
14
15 this.decorated = false;
16
17=== modified file 'lib/Widgets/DecoratedWindow.vala'
18--- lib/Widgets/DecoratedWindow.vala 2012-05-20 20:44:51 +0000
19+++ lib/Widgets/DecoratedWindow.vala 2012-05-30 03:44:19 +0000
20@@ -27,44 +27,38 @@
21
22 public class DecoratedWindow : CompositedWindow {
23
24- const string DECORATED_WINDOW_STYLESHEET = """
25+ const string DECORATED_WINDOW_FALLBACK_STYLESHEET = """
26 .decorated-window {
27+ border-style:solid;
28+ border-color:alpha (#000, 0.35);
29 background-image:none;
30 background-color:@bg_color;
31 border-radius:6px;
32- border-width:1px;
33- border-style:solid;
34- border-color:alpha (#000, 0.35);
35- }
36- """;
37-
38- const string DECORATED_WINDOW_WORKAROUNDS_STYLESHEET = """
39- .decorated-window * {
40- background-image:none;
41- background-color:alpha (#fff, 0.0);
42- }
43- """;
44-
45- public static void set_default_theming (Gtk.Window ref_window, Gtk.Widget content) {
46- var window_css_provider = new Gtk.CssProvider ();
47- var content_css_provider = new Gtk.CssProvider ();
48+ }
49+ """;
50+
51+ // Currently not overridable
52+ const string DECORATED_WINDOW_STYLESHEET = """
53+ .decorated-window { border-width:1px; }
54+ """;
55+
56+ public static void set_default_theming (Gtk.Window ref_window) {
57+ var normal_style = new Gtk.CssProvider ();
58+ var fallback_style = new Gtk.CssProvider ();
59
60 try {
61- window_css_provider.load_from_data (DECORATED_WINDOW_STYLESHEET, -1);
62- content_css_provider.load_from_data (DECORATED_WINDOW_WORKAROUNDS_STYLESHEET, -1);
63+ normal_style.load_from_data (DECORATED_WINDOW_STYLESHEET, -1);
64+ fallback_style.load_from_data (DECORATED_WINDOW_FALLBACK_STYLESHEET, -1);
65 } catch (Error e) {
66 warning (e.message);
67 }
68
69 ref_window.get_style_context ().add_class (STYLE_CLASS_DECORATED_WINDOW);
70- ref_window.get_style_context ().add_provider (window_css_provider, Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK);
71
72- // Add workarounds
73- content.get_style_context ().add_class (STYLE_CLASS_DECORATED_WINDOW);
74- content.get_style_context ().add_provider (content_css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION );
75+ ref_window.get_style_context ().add_provider (normal_style, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
76+ ref_window.get_style_context ().add_provider (fallback_style, Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK);
77 }
78
79-
80 bool _show_close_button = true;
81 public bool show_close_button {
82 get {
83@@ -115,7 +109,7 @@
84 set { _title.label = value; }
85 }
86
87- public DecoratedWindow (string title = "") {
88+ public DecoratedWindow (string title = "", string? window_style = null, string? content_style = null) {
89 this.resizable = true;
90 this.has_resize_grip = false;
91 this.window_position = Gtk.WindowPosition.CENTER_ON_PARENT;
92@@ -130,7 +124,14 @@
93 this.draw_ref = new Gtk.Window ();
94
95 // set theming
96- set_default_theming (draw_ref, box);
97+ set_default_theming (draw_ref);
98+
99+ // extra theming
100+ if (window_style != null && window_style != "")
101+ draw_ref.get_style_context ().add_class (window_style);
102+
103+ if (content_style != null && content_style != "")
104+ box.get_style_context ().add_class (content_style);
105
106 close_img = get_close_pixbuf ();
107
108@@ -144,11 +145,12 @@
109
110 box.pack_start (_title, false);
111
112+ box.margin = SHADOW_BLUR + 1; // SHADOW_BLUR + border_width
113+
114 base.add (this.box);
115-
116- this.box.margin = SHADOW_BLUR + 1;
117 }
118
119+
120 public new void add (Gtk.Widget w) {
121 this.box.pack_start (w);
122 }
123
124=== modified file 'lib/Widgets/LightWindow.vala'
125--- lib/Widgets/LightWindow.vala 2012-05-18 17:13:53 +0000
126+++ lib/Widgets/LightWindow.vala 2012-05-30 03:44:19 +0000
127@@ -21,12 +21,14 @@
128 */
129
130 namespace Granite.Widgets {
131+
132 public class LightWindow : DecoratedWindow {
133
134- public LightWindow (string title="") {
135- base (title);
136- box.get_style_context ().add_class (STYLE_CLASS_CONTENT_VIEW);
137- draw_ref.get_style_context ().add_class (STYLE_CLASS_CONTENT_VIEW_WINDOW);
138+ public LightWindow (string title = "") {
139+ base (title, STYLE_CLASS_CONTENT_VIEW_WINDOW, STYLE_CLASS_CONTENT_VIEW);
140 }
141+
142 }
143+
144 }
145+

Subscribers

People subscribed via source and target branches