Merge lp:~mterry/unity-greeter/q-ui-nits into lp:unity-greeter

Proposed by Michael Terry
Status: Merged
Approved by: Robert Ancell
Approved revision: 576
Merged at revision: 584
Proposed branch: lp:~mterry/unity-greeter/q-ui-nits
Merge into: lp:unity-greeter
Diff against target: 339 lines (+105/-30)
7 files modified
data/Makefile.am (+1/-0)
src/greeter-list.vala (+24/-16)
src/main-window.vala (+33/-2)
src/menubar.vala (+9/-5)
src/prompt-box.vala (+25/-5)
src/user-list.vala (+12/-1)
tests/test.vala (+1/-1)
To merge this branch: bzr merge lp:~mterry/unity-greeter/q-ui-nits
Reviewer Review Type Date Requested Status
Robert Ancell Approve
Review via email: mp+123820@code.launchpad.net

Description of the change

This branch implements a set of four UI changes that Design requested for 12.10.

To post a comment you must log in.
Revision history for this message
Michael Terry (mterry) wrote :

Note that this needs UIFe approval first.

Revision history for this message
Robert Ancell (robert-ancell) wrote :

Code looks good, approved if gets UIFe.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/Makefile.am'
2--- data/Makefile.am 2012-09-07 13:28:19 +0000
3+++ data/Makefile.am 2012-09-12 14:45:28 +0000
4@@ -14,6 +14,7 @@
5 message.png \
6 recovery_console_badge.png \
7 remote_login_help.png \
8+ shadow.png \
9 ubuntu_badge.png \
10 unknown_badge.png
11
12
13=== added file 'data/shadow.png'
14Binary files data/shadow.png 1970-01-01 00:00:00 +0000 and data/shadow.png 2012-09-12 14:45:28 +0000 differ
15=== modified file 'src/greeter-list.vala'
16--- src/greeter-list.vala 2012-09-04 13:35:33 +0000
17+++ src/greeter-list.vala 2012-09-12 14:45:28 +0000
18@@ -85,11 +85,11 @@
19 get
20 {
21 /* First, get grid row number as if menubar weren't there */
22- var row = (MenuBar.HEIGHT + get_allocated_height ()) / grid_size;
23+ var row = (MainWindow.MENUBAR_HEIGHT + get_allocated_height ()) / grid_size;
24 row = row - DEFAULT_BOX_HEIGHT; /* and no default dash box */
25 row = row / 2; /* and in the middle */
26 /* Now calculate y pixel spot keeping in mind menubar's allocation */
27- return row * grid_size - MenuBar.HEIGHT;
28+ return row * grid_size - MainWindow.MENUBAR_HEIGHT;
29 }
30 }
31
32@@ -436,20 +436,28 @@
33
34 protected virtual int get_position_y (double position)
35 {
36- double grid_number = position;
37-
38- if (position >= 0.0 && position < 1.0)
39- {
40- var grids = get_greeter_box_height_grids ();
41- grid_number = position * grids; /* scaled to height of greeter box */
42- }
43- else if (position >= 1.0)
44- {
45- var grids = get_greeter_box_height_grids ();
46- grid_number = position + grids - 1.0;
47- }
48-
49- return get_greeter_box_y () + (int)(grid_number * grid_size);
50+ // Most position heights are just the grid height. Except for the one
51+ // right above the greeter box and the greeter box itself. The greeter
52+ // box is some number of grids to start with. And it is smaller by a
53+ // bit, while the one above it is larger by the same amount, in order
54+ // to line up names outside the greeter box in the middle of their
55+ // grid, while the name inside the box is near the bottom of its first
56+ // box.
57+ int one_above_height = grid_size + PromptBox.NAME_MARGIN_TOP;
58+ int box_height = get_greeter_box_height_grids () * grid_size -
59+ PromptBox.NAME_MARGIN_TOP;
60+ double offset;
61+
62+ if (position < -1)
63+ offset = (position + 1) * grid_size - one_above_height;
64+ else if (position < 0)
65+ offset = position * one_above_height;
66+ else if (position < 1)
67+ offset = position * box_height;
68+ else
69+ offset = (position - 1) * grid_size + box_height;
70+
71+ return get_greeter_box_y () + (int)offset;
72 }
73
74 private void move_entry (PromptBox entry, double position)
75
76=== modified file 'src/main-window.vala'
77--- src/main-window.vala 2012-09-04 09:19:45 +0000
78+++ src/main-window.vala 2012-09-12 14:45:28 +0000
79@@ -31,6 +31,9 @@
80
81 public ListStack stack;
82
83+ // Menubar is smaller, but with shadow, we reserve more space
84+ public static const int MENUBAR_HEIGHT = 32;
85+
86 construct
87 {
88 events |= Gdk.EventMask.POINTER_MOTION_MASK;
89@@ -58,9 +61,37 @@
90 login_box.show ();
91 background.add (login_box);
92
93+ /* Box for menubar shadow */
94+ var menubox = new Gtk.EventBox ();
95+ var menualign = new Gtk.Alignment (0.0f, 0.0f, 1.0f, 0.0f);
96+ try
97+ {
98+ var shadow_path = Path.build_filename (Config.PKGDATADIR,
99+ "shadow.png", null);
100+ var style = new Gtk.CssProvider ();
101+ style.load_from_data ("* {background-color: transparent;
102+ background-image: url('%s');
103+ background-repeat: repeat;
104+ }".printf(shadow_path), -1);
105+ var context = menubox.get_style_context ();
106+ context.add_provider (style,
107+ Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
108+ }
109+ catch (Error e)
110+ {
111+ debug ("Internal error loading menubox style: %s", e.message);
112+ }
113+ menubox.set_size_request (-1, MENUBAR_HEIGHT);
114+ menubox.show ();
115+ menualign.show ();
116+ menubox.add (menualign);
117+ login_box.add (menubox);
118+ UnityGreeter.add_style_class (menualign);
119+ UnityGreeter.add_style_class (menubox);
120+
121 menubar = new MenuBar (background, accel_group);
122 menubar.show ();
123- login_box.add (menubar);
124+ menualign.add (menubar);
125 UnityGreeter.add_style_class (menubar);
126
127 hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
128@@ -70,7 +101,7 @@
129
130 var align = new Gtk.Alignment (0.5f, 0.5f, 0.0f, 0.0f);
131 align.set_size_request (grid_size, -1);
132- align.margin_bottom = MenuBar.HEIGHT; /* offset for menubar at top */
133+ align.margin_bottom = MENUBAR_HEIGHT; /* offset for menubar at top */
134 align.show ();
135 hbox.add (align);
136
137
138=== modified file 'src/menubar.vala'
139--- src/menubar.vala 2012-09-04 14:45:06 +0000
140+++ src/menubar.vala 2012-09-12 14:45:28 +0000
141@@ -65,13 +65,13 @@
142
143 public class MenuBar : Gtk.MenuBar
144 {
145- public static const int HEIGHT = 32;
146 public Background? background { get; construct; default = null; }
147 public bool high_contrast { get; private set; default = false; }
148 public Gtk.Window? keyboard_window { get; private set; default = null; }
149-
150 public Gtk.AccelGroup? accel_group { get; construct; }
151
152+ private static const int HEIGHT = 24;
153+
154 public MenuBar (Background bg, Gtk.AccelGroup ag)
155 {
156 Object (background: bg, accel_group: ag);
157@@ -162,12 +162,10 @@
158 }
159 catch (Error e)
160 {
161- debug ("Internal error loading session chooser style: %s", e.message);
162+ debug ("Internal error loading menubar style: %s", e.message);
163 }
164
165 setup_indicators ();
166-
167- set_size_request (-1, HEIGHT);
168 }
169
170 ~MenuBar ()
171@@ -181,6 +179,12 @@
172 }
173 }
174
175+ public override void get_preferred_height (out int min, out int nat)
176+ {
177+ min = HEIGHT;
178+ nat = HEIGHT;
179+ }
180+
181 private void greeter_set_env (string key, string val)
182 {
183 GLib.Environment.set_variable (key, val, true);
184
185=== modified file 'src/prompt-box.vala'
186--- src/prompt-box.vala 2012-08-27 23:02:51 +0000
187+++ src/prompt-box.vala 2012-09-12 14:45:28 +0000
188@@ -20,6 +20,8 @@
189
190 public class PromptBox : FadableBox
191 {
192+ public static const int NAME_MARGIN_TOP = 12;
193+
194 public signal void respond (string[] response);
195 public signal void login ();
196 public signal void show_options ();
197@@ -43,6 +45,8 @@
198 private Gtk.Fixed fixed;
199 private Gtk.Widget zone; /* when overlapping zone we are fully expanded */
200
201+ private int name_grid_height = grid_size - NAME_MARGIN_TOP;
202+
203 /* Expanded widgets */
204 protected Gtk.Grid box_grid;
205 protected Gtk.Grid name_grid;
206@@ -115,7 +119,7 @@
207
208 active_indicator = new ActiveIndicator ();
209 active_indicator.valign = Gtk.Align.START;
210- active_indicator.margin_top = 18;
211+ active_indicator.margin_top = 12 + NAME_MARGIN_TOP;
212 active_indicator.show ();
213 box_grid.attach (active_indicator, COL_ACTIVE, last_row, 1, 1);
214
215@@ -137,6 +141,7 @@
216
217 small_active_indicator = new ActiveIndicator ();
218 small_active_indicator.valign = Gtk.Align.CENTER;
219+ small_active_indicator.margin_top = NAME_MARGIN_TOP;
220 small_active_indicator.show ();
221 small_box_grid.attach (small_active_indicator, 0, 0, 1, 1);
222
223@@ -172,10 +177,11 @@
224 name_label = new FadingLabel ("");
225 name_label.override_font (Pango.FontDescription.from_string ("Ubuntu 13"));
226 name_label.override_color (Gtk.StateFlags.NORMAL, { 1.0f, 1.0f, 1.0f, 1.0f });
227+ name_label.margin_top = NAME_MARGIN_TOP;
228 name_label.valign = Gtk.Align.START;
229 name_label.vexpand = true;
230 name_label.xalign = 0.0f;
231- name_label.set_size_request (-1, grid_size);
232+ name_label.set_size_request (-1, name_grid_height);
233 name_label.show ();
234 name_grid.attach (name_label, COL_NAME_LABEL, ROW_NAME, 1, 1);
235
236@@ -191,7 +197,8 @@
237
238 var align = new Gtk.Alignment (0.5f, 0.5f, 0.0f, 0.0f);
239 align.valign = Gtk.Align.START;
240- align.set_size_request (-1, grid_size);
241+ align.margin_top = NAME_MARGIN_TOP;
242+ align.set_size_request (-1, name_grid_height);
243 align.add (message_image);
244 align.show ();
245 name_grid.attach (align, COL_NAME_MESSAGE, ROW_NAME, 1, 1);
246@@ -200,6 +207,7 @@
247 option_button.hexpand = true;
248 option_button.halign = Gtk.Align.END;
249 option_button.valign = Gtk.Align.START;
250+ option_button.margin_top = NAME_MARGIN_TOP;
251 option_button.focus_on_click = false;
252 option_button.relief = Gtk.ReliefStyle.NONE;
253 option_button.get_accessible ().set_name (_("Session Options"));
254@@ -207,6 +215,16 @@
255 option_image = new CachedImage (null);
256 option_image.show ();
257 UnityGreeter.add_style_class (option_button);
258+ try
259+ {
260+ var style = new Gtk.CssProvider ();
261+ style.load_from_data ("* {padding: 2px;}", -1);
262+ option_button.get_style_context ().add_provider (style, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
263+ }
264+ catch (Error e)
265+ {
266+ debug ("Internal error loading session chooser style: %s", e.message);
267+ }
268 option_button.add (option_image);
269 name_grid.attach (option_button, COL_NAME_OPTIONS, ROW_NAME, 1, 1);
270
271@@ -223,8 +241,9 @@
272 small_name_label = new FadingLabel ("");
273 small_name_label.override_font (Pango.FontDescription.from_string ("Ubuntu 13"));
274 small_name_label.override_color (Gtk.StateFlags.NORMAL, { 1.0f, 1.0f, 1.0f, 1.0f });
275+ small_name_label.margin_top = NAME_MARGIN_TOP;
276 small_name_label.xalign = 0.0f;
277- small_name_label.set_size_request (-1, grid_size);
278+ small_name_label.set_size_request (-1, name_grid_height);
279 small_name_label.show ();
280 small_name_grid.attach (small_name_label, 1, 0, 1, 1);
281
282@@ -232,7 +251,8 @@
283 small_message_image.pixbuf = message_image.pixbuf;
284
285 var align = new Gtk.Alignment (0.5f, 0.5f, 0.0f, 0.0f);
286- align.set_size_request (-1, grid_size);
287+ align.margin_top = NAME_MARGIN_TOP;
288+ align.set_size_request (-1, name_grid_height);
289 align.add (small_message_image);
290 align.show ();
291 small_name_grid.attach (align, 2, 0, 1, 1);
292
293=== modified file 'src/user-list.vala'
294--- src/user-list.vala 2012-09-12 14:32:39 +0000
295+++ src/user-list.vala 2012-09-12 14:45:28 +0000
296@@ -832,11 +832,21 @@
297 UnityGreeter.singleton.pop_list ();
298 }
299
300+ private bool should_show_session_badge ()
301+ {
302+ if (UnityGreeter.singleton.test_mode)
303+ return get_selected_id () != "no-badge";
304+ else
305+ return LightDM.get_sessions ().length () > 1;
306+ }
307+
308 private Gdk.Pixbuf? get_badge ()
309 {
310 if (selected_entry is UserPromptBox)
311 {
312- if (session == null)
313+ if (!should_show_session_badge ())
314+ return null;
315+ else if (session == null)
316 return SessionList.get_badge (default_session);
317 else
318 return SessionList.get_badge (session);
319@@ -1022,6 +1032,7 @@
320 { "four-layouts", "Four Layouts", "*", "de\tdvorak;ca;gb;fr\toss", false, false, null },
321 { "hy-layout", "Layout Is 'hy'", "*", "am\teastern-alt", false, false, null }, /* inherits parent layout's short_desc */
322 { "no-response", "No Response", "*", null, false, false, null },
323+ { "no-badge", "No Badge", "*", null, false, false, null },
324 { "", "", null, null, false, false, null }
325 };
326 private List<string> test_backgrounds;
327
328=== modified file 'tests/test.vala'
329--- tests/test.vala 2012-09-07 14:49:10 +0000
330+++ tests/test.vala 2012-09-12 14:45:28 +0000
331@@ -135,7 +135,7 @@
332 // Wait until remote login appears
333 scroll_to_remote_login (list);
334
335- GLib.assert (list.num_entries() == 29);
336+ GLib.assert (list.num_entries() == 30);
337
338 // Make sure we are at the beginning of the list
339 do_scroll (list, GreeterList.ScrollTarget.START);

Subscribers

People subscribed via source and target branches