Merge lp:~mterry/unity-greeter/center-names into lp:unity-greeter

Proposed by Michael Terry
Status: Merged
Approved by: Robert Ancell
Approved revision: 629
Merged at revision: 687
Proposed branch: lp:~mterry/unity-greeter/center-names
Merge into: lp:unity-greeter
Diff against target: 190 lines (+27/-43)
2 files modified
src/greeter-list.vala (+6/-15)
src/prompt-box.vala (+21/-28)
To merge this branch: bzr merge lp:~mterry/unity-greeter/center-names
Reviewer Review Type Date Requested Status
Unity Greeter Development Team Pending
Review via email: mp+139572@code.launchpad.net

Description of the change

This fixes some spacing and alignment issues around the names and option button.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/greeter-list.vala'
--- src/greeter-list.vala 2012-09-28 19:22:56 +0000
+++ src/greeter-list.vala 2012-12-12 21:00:36 +0000
@@ -436,28 +436,19 @@
436436
437 protected virtual int get_position_y (double position)437 protected virtual int get_position_y (double position)
438 {438 {
439 // Most position heights are just the grid height. Except for the one439 // Most position heights are just the grid height. Except for the
440 // right above the greeter box and the greeter box itself. The greeter440 // greeter box itself.
441 // box is some number of grids to start with. And it is smaller by a441 int box_height = get_greeter_box_height_grids () * grid_size;
442 // bit, while the one above it is larger by the same amount, in order
443 // to line up names outside the greeter box in the middle of their
444 // grid, while the name inside the box is near the bottom of its first
445 // box.
446 int one_above_height = grid_size + PromptBox.NAME_MARGIN_TOP;
447 int box_height = get_greeter_box_height_grids () * grid_size -
448 PromptBox.NAME_MARGIN_TOP;
449 double offset;442 double offset;
450443
451 if (position < -1)444 if (position < 0)
452 offset = (position + 1) * grid_size - one_above_height;445 offset = position * grid_size;
453 else if (position < 0)
454 offset = position * one_above_height;
455 else if (position < 1)446 else if (position < 1)
456 offset = position * box_height;447 offset = position * box_height;
457 else448 else
458 offset = (position - 1) * grid_size + box_height;449 offset = (position - 1) * grid_size + box_height;
459450
460 return get_greeter_box_y () + (int)Math.round(offset);451 return box_y + (int)Math.round(offset);
461 }452 }
462453
463 private void move_entry (PromptBox entry, double position)454 private void move_entry (PromptBox entry, double position)
464455
=== modified file 'src/prompt-box.vala'
--- src/prompt-box.vala 2012-12-06 21:06:54 +0000
+++ src/prompt-box.vala 2012-12-12 21:00:36 +0000
@@ -20,8 +20,6 @@
2020
21public class PromptBox : FadableBox21public class PromptBox : FadableBox
22{22{
23 public static const int NAME_MARGIN_TOP = 12;
24
25 public signal void respond (string[] response);23 public signal void respond (string[] response);
26 public signal void login ();24 public signal void login ();
27 public signal void show_options ();25 public signal void show_options ();
@@ -45,8 +43,6 @@
45 private Gtk.Fixed fixed;43 private Gtk.Fixed fixed;
46 private Gtk.Widget zone; /* when overlapping zone we are fully expanded */44 private Gtk.Widget zone; /* when overlapping zone we are fully expanded */
4745
48 private int name_grid_height = grid_size - NAME_MARGIN_TOP;
49
50 /* Expanded widgets */46 /* Expanded widgets */
51 protected Gtk.Grid box_grid;47 protected Gtk.Grid box_grid;
52 protected Gtk.Grid name_grid;48 protected Gtk.Grid name_grid;
@@ -101,13 +97,11 @@
101 fixed.show ();97 fixed.show ();
102 add (fixed);98 add (fixed);
10399
104 /* Create fully expanded version of ourselves */
105 name_grid = create_name_grid ();
106
107 box_grid = new Gtk.Grid ();100 box_grid = new Gtk.Grid ();
108 box_grid.column_spacing = 4;101 box_grid.column_spacing = 4;
109 box_grid.row_spacing = 3;102 box_grid.row_spacing = 3;
110 box_grid.margin_bottom = 10;103 box_grid.margin_top = GreeterList.BORDER;
104 box_grid.margin_bottom = 6;
111 box_grid.expand = true;105 box_grid.expand = true;
112106
113 /** Grid layout:107 /** Grid layout:
@@ -119,7 +113,7 @@
119113
120 active_indicator = new ActiveIndicator ();114 active_indicator = new ActiveIndicator ();
121 active_indicator.valign = Gtk.Align.START;115 active_indicator.valign = Gtk.Align.START;
122 active_indicator.margin_top = 11 + NAME_MARGIN_TOP;116 active_indicator.margin_top = (grid_size - active_indicator.pixbuf.get_height ()) / 2;
123 active_indicator.show ();117 active_indicator.show ();
124 box_grid.attach (active_indicator, COL_ACTIVE, last_row, 1, 1);118 box_grid.attach (active_indicator, COL_ACTIVE, last_row, 1, 1);
125119
@@ -129,6 +123,9 @@
129 box_grid.attach (dummy_indicator, COL_SPACER, last_row, 1, 1);123 box_grid.attach (dummy_indicator, COL_SPACER, last_row, 1, 1);
130124
131 box_grid.show ();125 box_grid.show ();
126
127 /* Create fully expanded version of ourselves */
128 name_grid = create_name_grid ();
132 box_grid.attach (name_grid, COL_CONTENT, last_row, 1, 1);129 box_grid.attach (name_grid, COL_CONTENT, last_row, 1, 1);
133130
134 /* Now prep small versions of the above normal widgets. These are131 /* Now prep small versions of the above normal widgets. These are
@@ -140,8 +137,8 @@
140 small_box_grid.show ();137 small_box_grid.show ();
141138
142 small_active_indicator = new ActiveIndicator ();139 small_active_indicator = new ActiveIndicator ();
143 small_active_indicator.valign = Gtk.Align.CENTER;140 small_active_indicator.valign = Gtk.Align.START;
144 small_active_indicator.margin_top = NAME_MARGIN_TOP;141 small_active_indicator.margin_top = (grid_size - small_active_indicator.pixbuf.get_height ()) / 2;
145 small_active_indicator.show ();142 small_active_indicator.show ();
146 small_box_grid.attach (small_active_indicator, 0, 0, 1, 1);143 small_box_grid.attach (small_active_indicator, 0, 0, 1, 1);
147144
@@ -177,11 +174,12 @@
177 name_label = new FadingLabel ("");174 name_label = new FadingLabel ("");
178 name_label.override_font (Pango.FontDescription.from_string ("Ubuntu 13"));175 name_label.override_font (Pango.FontDescription.from_string ("Ubuntu 13"));
179 name_label.override_color (Gtk.StateFlags.NORMAL, { 1.0f, 1.0f, 1.0f, 1.0f });176 name_label.override_color (Gtk.StateFlags.NORMAL, { 1.0f, 1.0f, 1.0f, 1.0f });
180 name_label.margin_top = NAME_MARGIN_TOP;
181 name_label.valign = Gtk.Align.START;177 name_label.valign = Gtk.Align.START;
182 name_label.vexpand = true;178 name_label.vexpand = true;
179 name_label.yalign = 0.5f;
183 name_label.xalign = 0.0f;180 name_label.xalign = 0.0f;
184 name_label.set_size_request (-1, name_grid_height);181 name_label.margin_left = 2;
182 name_label.set_size_request (-1, grid_size);
185 name_label.show ();183 name_label.show ();
186 name_grid.attach (name_label, COL_NAME_LABEL, ROW_NAME, 1, 1);184 name_grid.attach (name_label, COL_NAME_LABEL, ROW_NAME, 1, 1);
187185
@@ -197,8 +195,7 @@
197195
198 var align = new Gtk.Alignment (0.5f, 0.5f, 0.0f, 0.0f);196 var align = new Gtk.Alignment (0.5f, 0.5f, 0.0f, 0.0f);
199 align.valign = Gtk.Align.START;197 align.valign = Gtk.Align.START;
200 align.margin_top = NAME_MARGIN_TOP;198 align.set_size_request (-1, grid_size);
201 align.set_size_request (-1, name_grid_height);
202 align.add (message_image);199 align.add (message_image);
203 align.show ();200 align.show ();
204 name_grid.attach (align, COL_NAME_MESSAGE, ROW_NAME, 1, 1);201 name_grid.attach (align, COL_NAME_MESSAGE, ROW_NAME, 1, 1);
@@ -207,7 +204,8 @@
207 option_button.hexpand = true;204 option_button.hexpand = true;
208 option_button.halign = Gtk.Align.END;205 option_button.halign = Gtk.Align.END;
209 option_button.valign = Gtk.Align.START;206 option_button.valign = Gtk.Align.START;
210 option_button.margin_top = NAME_MARGIN_TOP;207 // Keep as much space on top as on the right
208 option_button.margin_top = active_indicator.pixbuf.get_width () + box_grid.column_spacing;
211 option_button.focus_on_click = false;209 option_button.focus_on_click = false;
212 option_button.relief = Gtk.ReliefStyle.NONE;210 option_button.relief = Gtk.ReliefStyle.NONE;
213 option_button.get_accessible ().set_name (_("Session Options"));211 option_button.get_accessible ().set_name (_("Session Options"));
@@ -240,9 +238,10 @@
240 small_name_label = new FadingLabel ("");238 small_name_label = new FadingLabel ("");
241 small_name_label.override_font (Pango.FontDescription.from_string ("Ubuntu 13"));239 small_name_label.override_font (Pango.FontDescription.from_string ("Ubuntu 13"));
242 small_name_label.override_color (Gtk.StateFlags.NORMAL, { 1.0f, 1.0f, 1.0f, 1.0f });240 small_name_label.override_color (Gtk.StateFlags.NORMAL, { 1.0f, 1.0f, 1.0f, 1.0f });
243 small_name_label.margin_top = NAME_MARGIN_TOP;241 small_name_label.yalign = 0.5f;
244 small_name_label.xalign = 0.0f;242 small_name_label.xalign = 0.0f;
245 small_name_label.set_size_request (-1, name_grid_height);243 small_name_label.margin_left = 2;
244 small_name_label.set_size_request (-1, grid_size);
246 small_name_label.show ();245 small_name_label.show ();
247 small_name_grid.attach (small_name_label, 1, 0, 1, 1);246 small_name_grid.attach (small_name_label, 1, 0, 1, 1);
248247
@@ -250,8 +249,7 @@
250 small_message_image.pixbuf = message_image.pixbuf;249 small_message_image.pixbuf = message_image.pixbuf;
251250
252 var align = new Gtk.Alignment (0.5f, 0.5f, 0.0f, 0.0f);251 var align = new Gtk.Alignment (0.5f, 0.5f, 0.0f, 0.0f);
253 align.margin_top = NAME_MARGIN_TOP;252 align.set_size_request (-1, grid_size);
254 align.set_size_request (-1, name_grid_height);
255 align.add (small_message_image);253 align.add (small_message_image);
256 align.show ();254 align.show ();
257 small_name_grid.attach (align, 2, 0, 1, 1);255 small_name_grid.attach (align, 2, 0, 1, 1);
@@ -639,23 +637,18 @@
639 debug ("Could not load active image: %s", e.message);637 debug ("Could not load active image: %s", e.message);
640 }638 }
641 notify["active"].connect (() => { queue_draw (); });639 notify["active"].connect (() => { queue_draw (); });
640 xalign = 0.0f;
642 }641 }
643642
644 public override void get_preferred_width (out int min, out int nat)643 public override void get_preferred_width (out int min, out int nat)
645 {644 {
646 if (pixbuf != null)645 min = 8;
647 min = pixbuf.get_width ();
648 else
649 min = 0;
650 nat = min;646 nat = min;
651 }647 }
652648
653 public override void get_preferred_height (out int min, out int nat)649 public override void get_preferred_height (out int min, out int nat)
654 {650 {
655 if (pixbuf != null)651 min = 7;
656 min = pixbuf.get_height ();
657 else
658 min = 0;
659 nat = min;652 nat = min;
660 }653 }
661654

Subscribers

People subscribed via source and target branches