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

Proposed by Victor Martinez
Status: Merged
Merged at revision: 240
Proposed branch: lp:~victored/granite/lp-998963
Merge into: lp:~elementary-pantheon/granite/granite
Diff against target: 235 lines (+84/-58)
6 files modified
demo/main.vala (+0/-6)
lib/CMakeLists.txt (+1/-0)
lib/Main.vala (+3/-0)
lib/Widgets/AboutDialog.vala (+6/-23)
lib/Widgets/DecoratedWindow.vala (+43/-29)
lib/Widgets/LightWindow.vala (+31/-0)
To merge this branch: bzr merge lp:~victored/granite/lp-998963
Reviewer Review Type Date Requested Status
Cody Garver (community) Approve
Review via email: mp+105757@code.launchpad.net

Description of the change

Fix alignment in Granite.Widgets.DecoratedWindow [lp:998963] and look of DecoratedWindow and AboutDialog under other themes.

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

Hey victored, will you move the LightWindow class to its own file?

Revision history for this message
Victor Martinez (victored) wrote :

Yeah, I forgot to do that. Thank you for reminding me :)

lp:~victored/granite/lp-998963 updated
237. By Victor Martinez

Move Granite.Widgets.LightWindow to a separate file

Revision history for this message
Victor Martinez (victored) wrote :

Ok, it's on a separate file now

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 'demo/main.vala'
2--- demo/main.vala 2012-04-27 13:26:24 +0000
3+++ demo/main.vala 2012-05-15 04:30:26 +0000
4@@ -266,12 +266,6 @@
5 general.column_spacing = 6;
6 general.row_spacing = 6;
7
8- var c = new Gtk.CssProvider ();
9- try {
10- c.load_from_data ("*{background-image:none;background-color:alpha (#fff, 0);}", -1);
11- } catch (Error e) { warning (e.message); }
12- general.get_parent ().get_style_context ().add_provider (c, 20000);
13-
14 light_window.add (grid);
15 light_window.show_all ();
16 });
17
18=== modified file 'lib/CMakeLists.txt'
19--- lib/CMakeLists.txt 2012-05-05 17:23:21 +0000
20+++ lib/CMakeLists.txt 2012-05-15 04:30:26 +0000
21@@ -77,6 +77,7 @@
22 Widgets/ContractorView.vala
23 Widgets/ContractorMenu.vala
24 Widgets/DecoratedWindow.vala
25+ Widgets/LightWindow.vala
26 Widgets/StatusBar.vala
27 Main.vala
28 config.vapi
29
30=== modified file 'lib/Main.vala'
31--- lib/Main.vala 2012-03-18 23:07:11 +0000
32+++ lib/Main.vala 2012-05-15 04:30:26 +0000
33@@ -22,6 +22,9 @@
34
35 /* STYLE CLASSES */
36 public const string STYLE_CLASS_CONTENT_VIEW = "content-view";
37+ public const string STYLE_CLASS_CONTENT_VIEW_WINDOW = "content-view-window";
38+ public const string STYLE_CLASS_DECORATED_WINDOW = "decorated-window";
39+
40
41 public void init () {
42 if (!Thread.supported ())
43
44=== modified file 'lib/Widgets/AboutDialog.vala'
45--- lib/Widgets/AboutDialog.vala 2012-05-11 07:35:52 +0000
46+++ lib/Widgets/AboutDialog.vala 2012-05-15 04:30:26 +0000
47@@ -73,19 +73,6 @@
48 border-radius: 200px;
49 }
50 """;
51-
52- private const string WINDOW_STYLESHEET = """
53- .window {
54- background-image:none;
55- background-color:@bg_color;
56-
57- border-radius: 6px;
58-
59- border-width:1px;
60- border-style: solid;
61- border-color: alpha (#000, 0.25);
62- }
63- """;
64
65 int shadow_blur = 15;
66 int shadow_x = 0;
67@@ -105,22 +92,18 @@
68 help_button_style_provider.load_from_data(HELP_BUTTON_STYLESHEET, -1);
69 }
70 catch (Error e) {
71- warning ("GraniteWidgetsAboutDialog: %s. Some widgets will not look as intended", e.message);
72+ warning ("%s. Some widgets will not look as intended", e.message);
73 }
74-
75+
76 var draw_ref = new Gtk.Window ();
77- var window_style_provider = new Gtk.CssProvider ();
78- try {
79- window_style_provider.load_from_data (WINDOW_STYLESHEET, -1);
80- } catch (Error e) { warning (e.message); }
81- draw_ref.get_style_context ().add_provider (window_style_provider, STYLE_PROVIDER_PRIORITY_FALLBACK);
82- draw_ref.get_style_context ().add_class ("content-view-window");
83-
84+ draw_ref.get_style_context ().add_class (STYLE_CLASS_CONTENT_VIEW_WINDOW);
85+ DecoratedWindow.set_default_theming (draw_ref, action_area);
86+ action_area.get_style_context ().add_class (STYLE_CLASS_CONTENT_VIEW);
87+
88 this.decorated = false;
89 this.set_visual (this.get_screen ().get_rgba_visual ());
90 this.app_paintable = true;
91
92- action_area.get_style_context ().add_class ("content-view");
93 action_area.margin = 4;
94 action_area.margin_bottom = 8;
95 this.get_content_area ().margin = 10;
96
97=== modified file 'lib/Widgets/DecoratedWindow.vala'
98--- lib/Widgets/DecoratedWindow.vala 2012-05-08 00:22:47 +0000
99+++ lib/Widgets/DecoratedWindow.vala 2012-05-15 04:30:26 +0000
100@@ -25,18 +25,46 @@
101 [CCode (cname="get_close_pixbuf")]
102 internal extern Gdk.Pixbuf get_close_pixbuf ();
103
104- public const string DEFAULT_STYLE = """
105- .decorated-window {
106- background-image:none;
107- background-color:@bg_color;
108- border-radius:6px;
109- border-width:1px;
110- border-style:solid;
111- border-color:alpha (#000, 0.35);
112- }
113- """;
114-
115 public class DecoratedWindow : CompositedWindow {
116+
117+ const string DECORATED_WINDOW_STYLESHEET = """
118+ .decorated-window {
119+ background-image:none;
120+ background-color:@bg_color;
121+ border-radius:6px;
122+ border-width:1px;
123+ border-style:solid;
124+ border-color:alpha (#000, 0.35);
125+ }
126+ """;
127+
128+ const string DECORATED_WINDOW_WORKAROUNDS_STYLESHEET = """
129+ .decorated-window * {
130+ background-image:none;
131+ background-color:alpha (#fff, 0.0);
132+ }
133+ """;
134+
135+ public static void set_default_theming (Gtk.Window ref_window, Gtk.Widget content) {
136+ var window_css_provider = new Gtk.CssProvider ();
137+ var content_css_provider = new Gtk.CssProvider ();
138+
139+ try {
140+ window_css_provider.load_from_data (DECORATED_WINDOW_STYLESHEET, -1);
141+ content_css_provider.load_from_data (DECORATED_WINDOW_WORKAROUNDS_STYLESHEET, -1);
142+ } catch (Error e) {
143+ warning (e.message);
144+ }
145+
146+ ref_window.get_style_context ().add_class (STYLE_CLASS_DECORATED_WINDOW);
147+ ref_window.get_style_context ().add_provider (window_css_provider, Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK);
148+
149+ // Add workarounds
150+ content.get_style_context ().add_class (STYLE_CLASS_DECORATED_WINDOW);
151+ content.get_style_context ().add_provider (content_css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION );
152+ }
153+
154+
155 bool _show_close_button = true;
156 public bool show_close_button {
157 get {
158@@ -79,16 +107,8 @@
159 this.box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
160 this.draw_ref = new Gtk.Window ();
161
162- var css = new Gtk.CssProvider ();
163-
164- try {
165- css.load_from_data (DEFAULT_STYLE, -1);
166- } catch (Error e) {
167- warning (e.message);
168- }
169-
170- draw_ref.get_style_context ().add_class ("decorated-window");
171- draw_ref.get_style_context ().add_provider (css, Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK);
172+ // set theming
173+ set_default_theming (draw_ref, box);
174
175 close_img = get_close_pixbuf ();
176
177@@ -101,7 +121,8 @@
178 this.button_press_event.connect (on_button_press);
179
180 base.add (this.box);
181- this.box.margin = SHADOW_BLUR;
182+
183+ this.box.margin = SHADOW_BLUR + 1;
184 }
185
186 public new void add (Gtk.Widget w) {
187@@ -173,12 +194,5 @@
188 }
189 }
190
191- public class LightWindow : DecoratedWindow {
192-
193- public LightWindow () {
194- box.get_style_context ().add_class (STYLE_CLASS_CONTENT_VIEW);
195- draw_ref.get_style_context ().add_class ("content-view-window");
196- }
197- }
198 }
199
200
201=== added file 'lib/Widgets/LightWindow.vala'
202--- lib/Widgets/LightWindow.vala 1970-01-01 00:00:00 +0000
203+++ lib/Widgets/LightWindow.vala 2012-05-15 04:30:26 +0000
204@@ -0,0 +1,31 @@
205+// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
206+/*
207+ * Copyright (c) 2012 Granite Developers
208+ *
209+ * This library is free software; you can redistribute it and/or
210+ * modify it under the terms of the GNU Lesser General Public License as
211+ * published by the Free Software Foundation; either version 2 of the
212+ * License, or (at your option) any later version.
213+ *
214+ * This is distributed in the hope that it will be useful,
215+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
216+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
217+ * Lesser General Public License for more details.
218+ *
219+ * You should have received a copy of the GNU Lesser General Public
220+ * License along with this program; see the file COPYING. If not,
221+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
222+ * Boston, MA 02111-1307, USA.
223+ *
224+ * Authored by: Tom Beckmann <tombeckmann@online.de>
225+ */
226+
227+namespace Granite.Widgets {
228+ public class LightWindow : DecoratedWindow {
229+
230+ public LightWindow () {
231+ box.get_style_context ().add_class (STYLE_CLASS_CONTENT_VIEW);
232+ draw_ref.get_style_context ().add_class (STYLE_CLASS_CONTENT_VIEW_WINDOW);
233+ }
234+ }
235+}

Subscribers

People subscribed via source and target branches