From 2ecbede658258d2e2056fcce244e8a313e846d8b Mon Sep 17 00:00:00 2001 From: Neil Jagdish Patel Date: Thu, 29 Jul 2010 23:51:38 +0100 Subject: Hook up to bamf somewhat (bzr r403.3.3) --- unity-private/panel/panel-window-buttons.vala | 57 +++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 4 deletions(-) (limited to 'unity-private/panel') diff --git a/unity-private/panel/panel-window-buttons.vala b/unity-private/panel/panel-window-buttons.vala index 111a8be38..961f28caa 100644 --- a/unity-private/panel/panel-window-buttons.vala +++ b/unity-private/panel/panel-window-buttons.vala @@ -25,22 +25,51 @@ namespace Unity.Panel private WindowButton minimise; private WindowButton maximise; + private unowned Bamf.Matcher matcher; + public WindowButtons () { Object (orientation:Ctk.Orientation.HORIZONTAL, - spacing:4, + spacing:2, homogeneous:false); } construct { + close = new WindowButton ("close.png"); + pack (close, false, false); + close.show (); + + minimise = new WindowButton ("minimize.png"); + pack (minimise, false, false); + minimise.show (); + + maximise = new WindowButton ("maximize.png"); + pack (maximise, false, false); + maximise.show (); + + matcher = Bamf.Matcher.get_default (); + matcher.active_window_changed.connect (on_active_window_changed); + } + + private void on_active_window_changed (GLib.Object? object, + GLib.Object? object1) + { + Bamf.View? old_view = object as Bamf.View; + Bamf.View? new_view = object1 as Bamf.View; + + if (new_view is Bamf.Window) + { + string name = new_view.get_name (); + debug ("Active window changed: %s", name); + } } private override void get_preferred_width (float for_height, out float min_width, out float nat_width) { - min_width = 70.0f; + min_width = 72.0f; nat_width = min_width; } } @@ -50,6 +79,7 @@ namespace Unity.Panel public static const string AMBIANCE = "/usr/share/themes/Ambiance/metacity-1"; public string filename { get; construct; } + public Clutter.Actor bg; public WindowButton (string filename) { @@ -60,12 +90,31 @@ namespace Unity.Panel { try { - var bg = new Clutter.Texture.from_file (AMBIANCE + "/" + filename + ".png"); - set_background_for_state (Ctk.ActorState.STATE_NORMAL, bg); + bg = new Ctk.Image.from_filename (20, AMBIANCE + "/" + filename); + add_actor (bg); + bg.show (); } catch (Error e) { warning (@"Unable to load window button theme: You need Ambiance installed: $(e.message)"); } + + notify["state"].connect (() => { + switch (state) + { + case Ctk.ActorState.STATE_NORMAL: + bg.opacity = 255; + break; + + case Ctk.ActorState.STATE_PRELIGHT: + bg.opacity = 120; + break; + + case Ctk.ActorState.STATE_ACTIVE: + default: + bg.opacity = 50; + break; + } + }); } private override void get_preferred_width (float for_height, -- cgit v1.2.3