← Back to team overview

elementaryart team mailing list archive

[Merge] lp:~victored/granite/lp-998963 into lp:granite

 

Victor Eduardo has proposed merging lp:~victored/granite/lp-998963 into lp:granite.

Requested reviews:
  elementary Pantheon team (elementary-pantheon)
Related bugs:
  Bug #998963 in Granite: "Track display pop out on album cover view not aligned properly"
  https://bugs.launchpad.net/granite/+bug/998963

For more details, see:
https://code.launchpad.net/~victored/granite/lp-998963/+merge/105757

Fix alignment in Granite.Widgets.DecoratedWindow [lp:998963] and look of DecoratedWindow and AboutDialog under other themes.
-- 
https://code.launchpad.net/~victored/granite/lp-998963/+merge/105757
Your team elementaryart (old) is subscribed to branch lp:granite.
=== modified file 'demo/main.vala'
--- demo/main.vala	2012-04-27 13:26:24 +0000
+++ demo/main.vala	2012-05-15 04:02:25 +0000
@@ -266,12 +266,6 @@
             general.column_spacing = 6;
             general.row_spacing = 6;
             
-            var c = new Gtk.CssProvider ();
-            try {
-                c.load_from_data ("*{background-image:none;background-color:alpha (#fff, 0);}", -1);
-            } catch (Error e) { warning (e.message); }
-            general.get_parent ().get_style_context ().add_provider (c, 20000);
-            
             light_window.add (grid);
             light_window.show_all ();
         });

=== modified file 'lib/Main.vala'
--- lib/Main.vala	2012-03-18 23:07:11 +0000
+++ lib/Main.vala	2012-05-15 04:02:25 +0000
@@ -22,6 +22,9 @@
 
     /* STYLE CLASSES */
     public const string STYLE_CLASS_CONTENT_VIEW = "content-view";
+    public const string STYLE_CLASS_CONTENT_VIEW_WINDOW = "content-view-window";
+    public const string STYLE_CLASS_DECORATED_WINDOW = "decorated-window";
+
 
     public void init () {
         if (!Thread.supported ())

=== modified file 'lib/Widgets/AboutDialog.vala'
--- lib/Widgets/AboutDialog.vala	2012-05-11 07:35:52 +0000
+++ lib/Widgets/AboutDialog.vala	2012-05-15 04:02:25 +0000
@@ -73,19 +73,6 @@
                 border-radius: 200px;
             }
         """;
-
-        private const string WINDOW_STYLESHEET = """
-            .window {
-                background-image:none;
-                background-color:@bg_color;
-                
-                border-radius: 6px;
-                
-                border-width:1px;
-                border-style: solid;
-                border-color: alpha (#000, 0.25);
-            }
-        """;
         
         int shadow_blur = 15;
         int shadow_x    = 0;
@@ -105,22 +92,18 @@
                 help_button_style_provider.load_from_data(HELP_BUTTON_STYLESHEET, -1);
             }
             catch (Error e) {
-                warning ("GraniteWidgetsAboutDialog: %s. Some widgets will not look as intended", e.message);
+                warning ("%s. Some widgets will not look as intended", e.message);
             }
-            
+
             var draw_ref = new Gtk.Window ();
-            var window_style_provider = new Gtk.CssProvider ();
-            try {
-                window_style_provider.load_from_data (WINDOW_STYLESHEET, -1);
-            } catch (Error e) { warning (e.message); }
-            draw_ref.get_style_context ().add_provider (window_style_provider, STYLE_PROVIDER_PRIORITY_FALLBACK);
-            draw_ref.get_style_context ().add_class ("content-view-window");
-            
+            draw_ref.get_style_context ().add_class (STYLE_CLASS_CONTENT_VIEW_WINDOW);
+            DecoratedWindow.set_default_theming (draw_ref, action_area);
+            action_area.get_style_context ().add_class (STYLE_CLASS_CONTENT_VIEW);
+
             this.decorated = false;
             this.set_visual (this.get_screen ().get_rgba_visual ());
             this.app_paintable = true;
 
-            action_area.get_style_context ().add_class ("content-view");
             action_area.margin = 4;
             action_area.margin_bottom = 8;
             this.get_content_area ().margin = 10;

=== modified file 'lib/Widgets/DecoratedWindow.vala'
--- lib/Widgets/DecoratedWindow.vala	2012-05-08 00:22:47 +0000
+++ lib/Widgets/DecoratedWindow.vala	2012-05-15 04:02:25 +0000
@@ -25,18 +25,46 @@
     [CCode (cname="get_close_pixbuf")]
     internal extern Gdk.Pixbuf get_close_pixbuf ();
 
-    public const string DEFAULT_STYLE = """
-        .decorated-window {
-            background-image:none;
-            background-color:@bg_color;
-            border-radius:6px;
-            border-width:1px;
-            border-style:solid;
-            border-color:alpha (#000, 0.35);
-        }
-    """;
-
     public class DecoratedWindow : CompositedWindow {
+
+        const string DECORATED_WINDOW_STYLESHEET = """
+            .decorated-window {
+                background-image:none;
+                background-color:@bg_color;
+                border-radius:6px;
+                border-width:1px;
+                border-style:solid;
+                border-color:alpha (#000, 0.35);
+            }
+        """;
+
+        const string DECORATED_WINDOW_WORKAROUNDS_STYLESHEET = """
+            .decorated-window * {
+                background-image:none;
+                background-color:alpha (#fff, 0.0);
+            }
+        """;
+
+        public static void set_default_theming (Gtk.Window ref_window, Gtk.Widget content) {
+            var window_css_provider = new Gtk.CssProvider ();
+            var content_css_provider = new Gtk.CssProvider ();
+
+            try {
+                window_css_provider.load_from_data (DECORATED_WINDOW_STYLESHEET, -1);
+                content_css_provider.load_from_data (DECORATED_WINDOW_WORKAROUNDS_STYLESHEET, -1);
+            } catch (Error e) {
+                warning (e.message);
+            }
+
+            ref_window.get_style_context ().add_class (STYLE_CLASS_DECORATED_WINDOW);
+            ref_window.get_style_context ().add_provider (window_css_provider, Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK);
+
+            // Add workarounds
+            content.get_style_context ().add_class (STYLE_CLASS_DECORATED_WINDOW);
+            content.get_style_context ().add_provider (content_css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION	);
+        }
+
+
         bool _show_close_button = true;
         public bool show_close_button {
             get {
@@ -79,16 +107,8 @@
             this.box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
             this.draw_ref = new Gtk.Window ();
 
-            var css = new Gtk.CssProvider ();
-
-            try {
-                css.load_from_data (DEFAULT_STYLE, -1);
-            } catch (Error e) {
-                warning (e.message);
-            }
-
-            draw_ref.get_style_context ().add_class ("decorated-window");
-            draw_ref.get_style_context ().add_provider (css, Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK);
+            // set theming
+            set_default_theming (draw_ref, box);
 
             close_img = get_close_pixbuf ();
 
@@ -101,7 +121,8 @@
             this.button_press_event.connect (on_button_press);
 
             base.add (this.box);
-            this.box.margin = SHADOW_BLUR;
+
+            this.box.margin = SHADOW_BLUR + 1;
         }
 
         public new void add (Gtk.Widget w) {
@@ -177,7 +198,7 @@
 
         public LightWindow () {
             box.get_style_context ().add_class (STYLE_CLASS_CONTENT_VIEW);
-            draw_ref.get_style_context ().add_class ("content-view-window");
+            draw_ref.get_style_context ().add_class (STYLE_CLASS_CONTENT_VIEW_WINDOW);
         }
     }
 }


Follow ups