[gnome-boxes/wip/ui-files: 9/10] sidebar: Get rid of redundant Clutter actors



commit 852a1c165489d43562ae4e818cdbf536854d2fd5
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Jan 8 19:40:39 2014 +0000

    sidebar: Get rid of redundant Clutter actors

 data/gtk-style.css  |    9 +++++++++
 src/properties.vala |    2 +-
 src/sidebar.vala    |   50 ++------------------------------------------------
 3 files changed, 12 insertions(+), 49 deletions(-)
---
diff --git a/data/gtk-style.css b/data/gtk-style.css
index 367ae92..7d8fe30 100644
--- a/data/gtk-style.css
+++ b/data/gtk-style.css
@@ -18,6 +18,15 @@ BoxesMiniGraph {
     color: #393939;
 }
 
+.sidebar {
+    background-image: url("icons/boxes-gray.png");
+    border-image-repeat: stretch;
+    border-image-source: url("icons/boxes-dark.png");
+    border-style: solid;
+    border-width: 2px 8px 2px 0;
+    box-shadow: 2px 0 2px rgba(0,0,0,0.5);
+}
+
 .sidebar GtkTreeView:selected {
     background-color: @boxes_selected_color;
     border-width: 2px 8px 2px 0;
diff --git a/src/properties.vala b/src/properties.vala
index 748d942..38af5c9 100644
--- a/src/properties.vala
+++ b/src/properties.vala
@@ -272,7 +272,7 @@ private class Boxes.Properties: GLib.Object, Boxes.UI {
         grid.column_spacing = 2;
         grid.row_spacing = 10;
         grid.margin_left = 10;
-        grid.margin_right = 10 + Sidebar.shadow_width;
+        grid.margin_right = 10;
         grid.margin_bottom = 30;
         grid.margin_top = 10;
 
diff --git a/src/sidebar.vala b/src/sidebar.vala
index f796ceb..0d85b78 100644
--- a/src/sidebar.vala
+++ b/src/sidebar.vala
@@ -10,14 +10,12 @@ private enum Boxes.SidebarPage {
 }
 
 private class Boxes.Sidebar: GLib.Object, Boxes.UI {
-    public Clutter.Actor actor { get { return bin_actor; } }
+    public Clutter.Actor actor { get { return gtk_actor; } }
     public UIState previous_ui_state { get; protected set; }
     public UIState ui_state { get; protected set; }
     public Notebook notebook;
     private uint width;
 
-    public static const int shadow_width = 7;
-    private Clutter.Actor bin_actor;
     private GtkClutter.Actor gtk_actor; // the sidebar box
 
     public Sidebar () {
@@ -42,58 +40,14 @@ private class Boxes.Sidebar: GLib.Object, Boxes.UI {
     }
 
     private void setup_sidebar () {
-        bin_actor = new Clutter.Actor ();
-        var bin = new Clutter.BinLayout (Clutter.BinAlignment.START,
-                                         Clutter.BinAlignment.START);
-        bin_actor.set_layout_manager (bin);
-        bin_actor.name = "sidebar-bin";
-
-        var shadow = new Clutter.Actor ();
-        shadow.set_width (shadow_width);
-        var canvas = new Clutter.Canvas ();
-        canvas.draw.connect ( (cr, w, h) => {
-            var p = new Cairo.Pattern.linear (0, 0, w, 0);
-            p.add_color_stop_rgba (0, 0, 0, 0, 0.4);
-            p.add_color_stop_rgba (0.7, 0, 0, 0, 0.0);
-            cr.set_source (p);
-            cr.set_operator (Cairo.Operator.SOURCE);
-            cr.rectangle (0, 0, w, h);
-            cr.fill ();
-
-            return true;
-        });
-        canvas.set_size (shadow_width, 1);
-        shadow.set_content (canvas);
-        shadow.set_content_gravity (Clutter.ContentGravity.RESIZE_FILL);
-        shadow.set_content_scaling_filters (Clutter.ScalingFilter.NEAREST, Clutter.ScalingFilter.NEAREST);
-        shadow.x_align = Clutter.ActorAlign.END;
-        shadow.x_expand = true;
-        shadow.y_expand = true;
-        bin_actor.add_child (shadow);
-
-        var background = new GtkClutter.Texture ();
-        background.name = "sidebar-background";
-        try {
-            var pixbuf = load_asset ("boxes-gray.png");
-            background.set_from_pixbuf (pixbuf);
-        } catch (GLib.Error e) {
-            warning ("Failed to load asset 'boxes-gray.png': %s", e.message);
-        }
-        background.set_repeat (true, true);
-        background.set_margin_right (shadow_width);
-        background.x_expand = true;
-        background.y_expand = true;
-        bin_actor.add (background);
-
         notebook = new Gtk.Notebook ();
         gtk_actor = new GtkClutter.Actor.with_contents (notebook);
         gtk_actor.get_widget ().get_style_context ().add_class ("boxes-bg");
         gtk_actor.name = "sidebar";
         gtk_actor.x_expand = true;
         gtk_actor.y_expand = true;
-        bin_actor.add_child (gtk_actor);
+
         notebook.get_style_context ().add_class (Gtk.STYLE_CLASS_SIDEBAR);
-        notebook.get_style_context ().add_class ("boxes-bg");
         notebook.set_size_request ((int) width, 100);
         notebook.show_tabs = false;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]