Merge lp:~robert-ancell/unity-greeter/session-badges into lp:unity-greeter

Proposed by Robert Ancell
Status: Merged
Merged at revision: 313
Proposed branch: lp:~robert-ancell/unity-greeter/session-badges
Merge into: lp:unity-greeter
Diff against target: 262 lines (+86/-32)
2 files modified
data/Makefile.am (+6/-2)
src/user-list.vala (+80/-30)
To merge this branch: bzr merge lp:~robert-ancell/unity-greeter/session-badges
Reviewer Review Type Date Requested Status
Michael Terry (community) Needs Fixing
Robert Ancell Needs Resubmitting
Review via email: mp+93771@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Michael Terry (mterry) wrote :

Two things:
1) As you know, Otto just gave us a new generic icon to use instead of the cog.

2) Do the following: Change a user's session to something like KDE. Then press the up arrow key. The name/cog will scroll as expected, but the cog image will change as it scrolls away back to the default instead of KDE. It should stay as KDE as it scrolls off.

Also, this is just a note for us that doesn't need to be fixed in this branch, but test-mode users should have different default sessions. Right now they all use the default.

review: Needs Fixing
Revision history for this message
Michael Terry (mterry) wrote :

I'm fixing the 'test users should have different default sessions' issue in my session-change-animation branch, FYI.

313. By Robert Ancell

Add unknown badge, draw correct badge when scrolling

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

Updated, please re-review.

It seems we should make the session a parameter of the UserEntry class, but I'll leave the code as-is for this patch.

Revision history for this message
Robert Ancell (robert-ancell) :
review: Needs Resubmitting
Revision history for this message
Michael Terry (mterry) wrote :

Better! Now I'm noticing that the session icon bounces at the end of the scroll. It doesn't smoothly glide into place like trunk does. Approved if you fix that.

review: Needs Fixing

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-02-16 01:45:10 +0000
3+++ data/Makefile.am 2012-02-20 23:16:19 +0000
4@@ -7,9 +7,13 @@
5 a11y.svg \
6 arrow.png \
7 cof.png \
8- cog.png \
9 logo.png \
10- message.png
11+ message.png \
12+ gnome_badge.png \
13+ kde_badge.png \
14+ recovery_console_badge.png \
15+ ubuntu_badge.png \
16+ unknown_badge.png
17
18 @GSETTINGS_RULES@
19 gsettings_SCHEMAS = com.canonical.unity-greeter.gschema.xml
20
21=== removed file 'data/cog.png'
22Binary files data/cog.png 2011-08-24 03:15:08 +0000 and data/cog.png 1970-01-01 00:00:00 +0000 differ
23=== added file 'data/gnome_badge.png'
24Binary files data/gnome_badge.png 1970-01-01 00:00:00 +0000 and data/gnome_badge.png 2012-02-20 23:16:19 +0000 differ
25=== added file 'data/kde_badge.png'
26Binary files data/kde_badge.png 1970-01-01 00:00:00 +0000 and data/kde_badge.png 2012-02-20 23:16:19 +0000 differ
27=== added file 'data/recovery_console_badge.png'
28Binary files data/recovery_console_badge.png 1970-01-01 00:00:00 +0000 and data/recovery_console_badge.png 2012-02-20 23:16:19 +0000 differ
29=== added file 'data/ubuntu_badge.png'
30Binary files data/ubuntu_badge.png 1970-01-01 00:00:00 +0000 and data/ubuntu_badge.png 2012-02-20 23:16:19 +0000 differ
31=== added file 'data/unknown_badge.png'
32Binary files data/unknown_badge.png 1970-01-01 00:00:00 +0000 and data/unknown_badge.png 2012-02-20 23:16:19 +0000 differ
33=== modified file 'src/user-list.vala'
34--- src/user-list.vala 2012-02-16 01:45:10 +0000
35+++ src/user-list.vala 2012-02-20 23:16:19 +0000
36@@ -74,9 +74,15 @@
37 private DashEntry prompt_entry;
38 private DashButton login_button;
39 private Fadable prompt_widget_to_show;
40- private Gtk.Button options_button;
41+ private Gtk.Button session_button;
42+ private Gtk.Image session_image;
43 private Menu options_menu;
44- private Gdk.Pixbuf options_pixbuf;
45+ private Gdk.Pixbuf unknown_badge_pixbuf;
46+ private Gdk.Pixbuf gnome_badge_pixbuf;
47+ private Gdk.Pixbuf kde_badge_pixbuf;
48+ private Gdk.Pixbuf recovery_console_badge_pixbuf;
49+ private Gdk.Pixbuf ubuntu_badge_pixbuf;
50+
51 unowned GLib.SList<SessionMenuItem> session_group = null;
52
53 private bool complete = false;
54@@ -138,6 +144,32 @@
55 }
56 }
57
58+ private Gdk.Pixbuf? last_session_badge = null;
59+ private Gdk.Pixbuf? session_badge
60+ {
61+ get
62+ {
63+ switch (session)
64+ {
65+ case "ubuntu":
66+ case "ubuntu-2d":
67+ /* NOTE: For legacy reasons 'gnome' is actually Ubuntu */
68+ case "gnome":
69+ return ubuntu_badge_pixbuf;
70+ case "gnome-classic":
71+ case "gnome-fallback":
72+ case "gnome-shell":
73+ return gnome_badge_pixbuf;
74+ case "kde":
75+ return kde_badge_pixbuf;
76+ case "xterm":
77+ return recovery_console_badge_pixbuf;
78+ default:
79+ return unknown_badge_pixbuf;
80+ }
81+ }
82+ }
83+
84 public UserList (Background bg, MenuBar mb)
85 {
86 background = bg;
87@@ -174,23 +206,27 @@
88
89 try
90 {
91- options_pixbuf = new Gdk.Pixbuf.from_file (Path.build_filename (Config.PKGDATADIR, "cog.png", null));
92+ unknown_badge_pixbuf = new Gdk.Pixbuf.from_file (Path.build_filename (Config.PKGDATADIR, "unknown_badge.png", null));
93+ gnome_badge_pixbuf = new Gdk.Pixbuf.from_file (Path.build_filename (Config.PKGDATADIR, "gnome_badge.png"));
94+ kde_badge_pixbuf = new Gdk.Pixbuf.from_file (Path.build_filename (Config.PKGDATADIR, "kde_badge.png"));
95+ recovery_console_badge_pixbuf = new Gdk.Pixbuf.from_file (Path.build_filename (Config.PKGDATADIR, "recovery_console_badge.png"));
96+ ubuntu_badge_pixbuf = new Gdk.Pixbuf.from_file (Path.build_filename (Config.PKGDATADIR, "ubuntu_badge.png"));
97 }
98 catch (Error e)
99 {
100- debug ("Error loading cog image: %s", e.message);
101+ debug ("Error loading image: %s", e.message);
102 }
103
104- options_button = new Gtk.Button ();
105- options_button.focus_on_click = false;
106- options_button.get_accessible ().set_name (_("Session Options"));
107- var image = new Gtk.Image.from_pixbuf (options_pixbuf);
108- image.show ();
109- options_button.relief = Gtk.ReliefStyle.NONE;
110- options_button.add (image);
111- options_button.clicked.connect (options_button_clicked_cb);
112- options_button.show ();
113- add_with_class (options_button);
114+ session_button = new Gtk.Button ();
115+ session_button.focus_on_click = false;
116+ session_button.get_accessible ().set_name (_("Session Options"));
117+ session_image = new Gtk.Image.from_pixbuf (session_badge);
118+ session_image.show ();
119+ session_button.relief = Gtk.ReliefStyle.NONE;
120+ session_button.add (session_image);
121+ session_button.clicked.connect (session_button_clicked_cb);
122+ session_button.show ();
123+ add_with_class (session_button);
124
125 options_menu = new Menu (background);
126 UnityGreeter.add_style_class (options_menu);
127@@ -344,9 +380,18 @@
128 item.session_name = name;
129 item.label = label;
130 item.show ();
131+ item.toggled.connect (session_changed_cb);
132 options_menu.append (item);
133 session_group = (GLib.SList<SessionMenuItem>) item.get_group ();
134 }
135+
136+ private void session_changed_cb (Gtk.CheckMenuItem item)
137+ {
138+ if (!item.active)
139+ return;
140+
141+ session_image.set_from_pixbuf (session_badge);
142+ }
143
144 private UserEntry? find_entry (string name)
145 {
146@@ -425,7 +470,7 @@
147 private void options_menu_position_cb (Gtk.Menu menu, out int x, out int y, out bool push_in)
148 {
149 Gtk.Allocation button_allocation;
150- options_button.get_allocation (out button_allocation);
151+ session_button.get_allocation (out button_allocation);
152
153 get_window ().get_origin (out x, out y);
154 x += button_allocation.x;
155@@ -433,7 +478,7 @@
156 push_in = true;
157 }
158
159- private void options_button_clicked_cb ()
160+ private void session_button_clicked_cb ()
161 {
162 options_menu.popup (null, null, options_menu_position_cb, 0, Gtk.get_current_event_time ());
163 }
164@@ -472,12 +517,14 @@
165 prompt_widget_to_show.fade_in ();
166 prompt_widget_to_show = null;
167 }
168- options_button.show ();
169+ session_button.show ();
170 user_displayed ();
171 }
172
173 private void select_entry (UserEntry entry, double direction)
174 {
175+ last_session_badge = session_badge;
176+
177 if (!get_realized ())
178 {
179 /* Just note it for the future if we haven't been realized yet */
180@@ -516,7 +563,7 @@
181
182 prompt_entry.hide ();
183 login_button.hide ();
184- options_button.hide ();
185+ session_button.hide ();
186 }
187
188 scroll_target_location = new_target;
189@@ -570,10 +617,10 @@
190 child_allocation.y = allocation.y + box_y + grid_size / 4;
191 child_allocation.width = grid_size;
192 child_allocation.height = grid_size;
193- options_button.size_allocate (child_allocation);
194+ session_button.size_allocate (child_allocation);
195 }
196
197- private void draw_entry (Cairo.Context c, UserEntry entry, double alpha = 0.5, bool in_box = false)
198+ private void draw_entry (Cairo.Context c, UserEntry entry, double alpha = 0.5, bool in_box = false, Gdk.Pixbuf? badge = null)
199 {
200 c.save ();
201
202@@ -626,20 +673,19 @@
203 c.restore ();
204
205 /* Now draw options button if we're animating in the box */
206- if (in_box && scroll_timer.is_running && options_pixbuf != null)
207+ if (in_box && scroll_timer.is_running && badge != null)
208 {
209 c.save ();
210- var xpadding = (grid_size - options_pixbuf.width) / 2;
211- var ypadding = (grid_size - options_pixbuf.height) / 2;
212+ var xpadding = (grid_size - badge.width) / 2;
213+ var ypadding = (grid_size - badge.height) / 2;
214 c.translate (box_width * grid_size - grid_size - grid_size / 4 + xpadding, grid_size / 4 - ypadding - border);
215- Gdk.cairo_set_source_pixbuf (c, options_pixbuf, 0, 0);
216+ Gdk.cairo_set_source_pixbuf (c, badge, 0, 0);
217 c.paint ();
218 c.restore ();
219 }
220 }
221
222- private void draw_entry_at_position (Cairo.Context c, UserEntry entry,
223- double position, bool in_box = false)
224+ private void draw_entry_at_position (Cairo.Context c, UserEntry entry, double position, bool in_box = false, Gdk.Pixbuf? badge = null)
225 {
226 c.save ();
227 c.translate (0, position * grid_size);
228@@ -648,7 +694,7 @@
229 alpha = 1.0 + position / (n_above + 1);
230 else
231 alpha = 1.0 - (position - 2) / (n_below + 1);
232- draw_entry (c, entry, alpha, in_box);
233+ draw_entry (c, entry, alpha, in_box, badge);
234 c.restore ();
235 }
236
237@@ -688,10 +734,14 @@
238 c.rectangle (0, border * 2, box_width * grid_size, box_height * grid_size - border * 5);
239 c.clip ();
240
241+ var badge = last_session_badge;
242+ if (entry == selected_entry)
243+ badge = session_badge;
244+
245 if (position <= 0) /* top of box, normal pace */
246- draw_entry_at_position (c, entry, position, true);
247+ draw_entry_at_position (c, entry, position, true, badge);
248 else /* bottom of box; pace must put across bottom halfway through animation */
249- draw_entry_at_position (c, entry, position * box_height * 2, true);
250+ draw_entry_at_position (c, entry, position * box_height * 2, true, badge);
251
252 c.restore ();
253 }
254@@ -726,7 +776,7 @@
255 draw_entry (c, selected_entry, 1.0, true);
256 c.restore ();
257
258- c.restore();
259+ c.restore ();
260 }
261
262 if ((error != null || message != null) && !scroll_timer.is_running)

Subscribers

People subscribed via source and target branches