Merge lp:~unity-team/unity/unity.fix-636602 into lp:unity

Proposed by Mirco Müller
Status: Merged
Approved by: Gord Allott
Approved revision: no longer in the source branch.
Merged at revision: 498
Proposed branch: lp:~unity-team/unity/unity.fix-636602
Merge into: lp:unity
Diff against target: 195 lines (+97/-13)
4 files modified
unity-private/Makefile.am (+1/-0)
unity-private/panel/panel-divider.vala (+81/-0)
unity-private/panel/panel-home-button.vala (+10/-13)
unity-private/panel/panel-view.vala (+5/-0)
To merge this branch: bzr merge lp:~unity-team/unity/unity.fix-636602
Reviewer Review Type Date Requested Status
Gord Allott (community) Approve
Review via email: mp+35293@code.launchpad.net

Description of the change

A new class called Unity.Panel.Divider has been added to fix LP: #636602. This adds a special Ctk.Image actor between the home-button and menubar/window-buttons to hold the dividing groove artwork. The padding is intentionally part of the artwork-image, because clutk/clutter would otherwise stretch the divider-groove itself to the full width (groove + right padding).

This branch needs the artwork introduced with lp:~unity-team/unity-asset-pool/unity-asset-pool.fix-636602

To post a comment you must log in.
Revision history for this message
Gord Allott (gordallott) wrote :

approved, works well. works a little weird in the popup version, but thats not a problem

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'unity-private/Makefile.am'
2--- unity-private/Makefile.am 2010-08-26 17:04:48 +0000
3+++ unity-private/Makefile.am 2010-09-13 15:48:49 +0000
4@@ -76,6 +76,7 @@
5
6 panel_sources = \
7 panel/panel-background.vala \
8+ panel/panel-divider.vala \
9 panel/panel-home-button.vala \
10 panel/panel-indicator-background.vala \
11 panel/panel-indicator-bar.vala \
12
13=== added file 'unity-private/panel/panel-divider.vala'
14--- unity-private/panel/panel-divider.vala 1970-01-01 00:00:00 +0000
15+++ unity-private/panel/panel-divider.vala 2010-09-13 15:48:49 +0000
16@@ -0,0 +1,81 @@
17+/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
18+/*
19+ * Copyright (C) 2010 Canonical Ltd
20+ *
21+ * This program is free software: you can redistribute it and/or modify
22+ * it under the terms of the GNU General Public License version 3 as
23+ * published by the Free Software Foundation.
24+ *
25+ * This program is distributed in the hope that it will be useful,
26+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
27+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28+ * GNU General Public License for more details.
29+ *
30+ * You should have received a copy of the GNU General Public License
31+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
32+ *
33+ * Authored by Mirco Müller <mirco.mueller@canonical.com>
34+ *
35+ */
36+
37+namespace Unity.Panel
38+{
39+ public class Divider : Ctk.Image
40+ {
41+ public Shell shell { get; construct; }
42+ private Clutter.Texture bg;
43+
44+ public Divider (Shell shell)
45+ {
46+ Object (reactive:true, shell:shell);
47+
48+ shell.mode_changed.connect (on_mode_changed);
49+
50+ Unity.Testing.ObjectRegistry.get_default ().register ("PanelDivider",
51+ this);
52+ }
53+
54+ construct
55+ {
56+ try
57+ {
58+ bg = new Clutter.Texture.from_file (
59+ "/usr/share/unity/themes/divider.png");
60+ }
61+ catch (Error e)
62+ {
63+ warning ("Could not load bg-texture for divider: %s", e.message);
64+ }
65+
66+ set_background (bg);
67+ }
68+
69+ /* the current divider-artwork is two pixels wide */
70+ private override void get_preferred_width (float for_height,
71+ out float min_width,
72+ out float nat_width)
73+ {
74+ // the width of six pixels is made up of two pixels for the divider itself
75+ // and four pixels for the padding; the padding needs to be in the image
76+ // of the artwork, because otherwise clutk/clutter would stretch the two
77+ // pixel divider across the whole width
78+ min_width = 6.0f;
79+ nat_width = 6.0f;
80+ }
81+
82+ private void on_mode_changed (ShellMode mode)
83+ {
84+ if (mode == ShellMode.MINIMIZED)
85+ {
86+ set_background (bg);
87+ }
88+ else
89+ {
90+ set_background (null);
91+ }
92+
93+ do_queue_redraw ();
94+ }
95+
96+ }
97+}
98
99=== modified file 'unity-private/panel/panel-home-button.vala'
100--- unity-private/panel/panel-home-button.vala 2010-09-09 07:08:56 +0000
101+++ unity-private/panel/panel-home-button.vala 2010-09-13 15:48:49 +0000
102@@ -28,7 +28,6 @@
103 private Clutter.Texture bfb_bg_normal;
104 private Clutter.Texture bfb_bg_prelight;
105 private Clutter.Texture bfb_bg_active;
106- private bool search_shown;
107
108 public HomeButton (Shell shell)
109 {
110@@ -52,7 +51,7 @@
111
112 notify["state"].connect (on_state_changed);
113
114- width += 3.0f;
115+ //width += 3.0f;
116
117 glow = new Ctk.EffectGlow ();
118 glow.set_color ({ 255, 255, 255, 255 });
119@@ -98,8 +97,6 @@
120 set_background_for_state (Ctk.ActorState.STATE_NORMAL, bfb_bg_normal);
121 set_background_for_state (Ctk.ActorState.STATE_PRELIGHT, bfb_bg_prelight);
122 set_background_for_state (Ctk.ActorState.STATE_ACTIVE, bfb_bg_active);
123-
124- search_shown = false;
125 }
126
127 private override void allocate (Clutter.ActorBox box,
128@@ -111,9 +108,10 @@
129 float pheight;
130 Ctk.Padding pad = { 0 };
131
132- // 2.0f are added so the home-button groove aligns with the
133- // right edge of the launcher, this fixes LP: #630031
134- lwidth = 2.0f + (float) shell.get_launcher_width_foobar ();
135+ // 1.0f are subtracted so the groove dividing home-button and
136+ // the rest of the panel aligns with the right edge of the
137+ // launcher, this fixes LP: #630031
138+ lwidth = (float) shell.get_launcher_width_foobar () - 1.0f;
139 pheight = (float) shell.get_panel_height_foobar ();
140 theme_image.get_preferred_size (out cwidth, out cheight,
141 out cwidth, out cheight);
142@@ -180,10 +178,11 @@
143 out float min_width,
144 out float nat_width)
145 {
146- // 2.0f are added so the home-button groove aligns with the
147- // right edge of the launcher, this fixes LP: #630031
148- min_width = 2.0f + shell.get_launcher_width_foobar ();
149- nat_width = 2.0f + shell.get_launcher_width_foobar ();
150+ // 1.0f are subtracted so the groove dividing home-button and
151+ // the rest of the panel aligns with the right edge of the
152+ // launcher, this fixes LP: #630031
153+ min_width = shell.get_launcher_width_foobar () - 1.0f;
154+ nat_width = shell.get_launcher_width_foobar () - 1.0f;
155 }
156
157 private void on_mode_changed (ShellMode mode)
158@@ -193,14 +192,12 @@
159 set_background_for_state (Ctk.ActorState.STATE_NORMAL, bfb_bg_normal);
160 set_background_for_state (Ctk.ActorState.STATE_PRELIGHT, bfb_bg_prelight);
161 set_background_for_state (Ctk.ActorState.STATE_ACTIVE, bfb_bg_active);
162- search_shown = false;
163 }
164 else
165 {
166 set_background_for_state (Ctk.ActorState.STATE_NORMAL, null);
167 set_background_for_state (Ctk.ActorState.STATE_PRELIGHT, null);
168 set_background_for_state (Ctk.ActorState.STATE_ACTIVE, null);
169- search_shown = true;
170 }
171
172 do_queue_redraw ();
173
174=== modified file 'unity-private/panel/panel-view.vala'
175--- unity-private/panel/panel-view.vala 2010-08-02 09:16:36 +0000
176+++ unity-private/panel/panel-view.vala 2010-09-13 15:48:49 +0000
177@@ -33,6 +33,7 @@
178 Ctk.HBox hbox;
179 Background bground;
180 HomeButton home_button;
181+ Divider divider;
182 WindowButtons window_buttons;
183 MenuBar menu_bar;
184 SystemTray system_tray;
185@@ -68,6 +69,10 @@
186 hbox.pack (home_button, false, true);
187 home_button.show ();
188
189+ divider = new Divider (shell);
190+ hbox.pack (divider, false, false);
191+ divider.show ();
192+
193 window_buttons = new WindowButtons ();
194 hbox.pack (window_buttons, false, true);
195 window_buttons.show ();