Merge lp:~tintou/pantheon-greeter/greeter-no-pixbuf into lp:~elementary-pantheon/pantheon-greeter/trunk

Proposed by Corentin Noël
Status: Merged
Approved by: Danielle Foré
Approved revision: 511
Merged at revision: 511
Proposed branch: lp:~tintou/pantheon-greeter/greeter-no-pixbuf
Merge into: lp:~elementary-pantheon/pantheon-greeter/trunk
Diff against target: 203 lines (+25/-78)
6 files modified
src/Avatar.vala (+7/-2)
src/LoginBox.vala (+2/-13)
src/LoginOptions/LoginOption.vala (+10/-39)
src/LoginOptions/UserLogin.vala (+6/-17)
src/PantheonGreeter.vala (+0/-3)
src/UserList.vala (+0/-4)
To merge this branch: bzr merge lp:~tintou/pantheon-greeter/greeter-no-pixbuf
Reviewer Review Type Date Requested Status
elementary Pantheon team Pending
Review via email: mp+313498@code.launchpad.net

Commit message

Use widgets instead of pixbufs

To post a comment you must log in.
511. By Corentin Noël

Use widgets instead of pixbufs

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Avatar.vala'
2--- src/Avatar.vala 2016-09-25 22:28:27 +0000
3+++ src/Avatar.vala 2016-12-17 22:20:38 +0000
4@@ -28,8 +28,13 @@
5 construct {
6 var container_widget = (Gtk.Container)this.get_widget ();
7
8- var avatar = new Granite.Widgets.Avatar ();
9- avatar.pixbuf = user.avatar;
10+ var path = user.avatar_path;
11+ Granite.Widgets.Avatar avatar;
12+ if (path != null) {
13+ avatar = new Granite.Widgets.Avatar.from_file (path, 96);
14+ } else {
15+ avatar = new Granite.Widgets.Avatar.with_default_icon (96);
16+ }
17
18 container_widget.add (avatar);
19
20
21=== modified file 'src/LoginBox.vala'
22--- src/LoginBox.vala 2016-10-26 21:05:40 +0000
23+++ src/LoginBox.vala 2016-12-17 22:20:38 +0000
24@@ -20,7 +20,6 @@
25 */
26
27 public class LoginBox : GtkClutter.Actor, LoginMask {
28- private Avatar avatar;
29 private CredentialsAreaActor credentials_actor;
30
31 bool _selected = false;
32@@ -74,13 +73,8 @@
33 start_login ();
34 });
35
36- if (user.avatar_ready) {
37- create_avatar ();
38- } else {
39- user.avatar_updated.connect (() => {
40- create_avatar ();
41- });
42- }
43+ var avatar = new Avatar (user);
44+ add_child (avatar);
45 }
46
47 /**
48@@ -92,11 +86,6 @@
49 PantheonGreeter.login_gateway.login_with_mask (this, user.is_guest);
50 }
51
52- private void create_avatar () {
53- avatar = new Avatar (user);
54- add_child (avatar);
55- }
56-
57 public void pass_focus () {
58 // We can't start the login when the login option isn't
59 // providing a name without user interaction.
60
61=== modified file 'src/LoginOptions/LoginOption.vala'
62--- src/LoginOptions/LoginOption.vala 2016-09-25 14:23:22 +0000
63+++ src/LoginOptions/LoginOption.vala 2016-12-17 22:20:38 +0000
64@@ -19,32 +19,10 @@
65 */
66
67 public abstract class LoginOption : Object {
68-
69- protected static Gdk.Pixbuf default_avatar;
70-
71-
72- private Gdk.Pixbuf _avatar;
73- public Gdk.Pixbuf avatar {
74- get {
75- lock (_avatar) return _avatar;
76- }
77- protected set {
78- lock (_avatar) _avatar = value;
79- }
80- }
81- /**
82- * True if and only if the avatar of this login option is from now on
83- * considered constant and you can safely ignore the avatar_updated
84- * signal.
85- */
86- public bool avatar_ready { get; protected set; default = true; }
87- public signal void avatar_updated ();
88-
89 public int index { get; private set; }
90
91 protected LoginOption (int index) {
92 this.index = index;
93- _avatar = default_avatar;
94 }
95
96 public string get_markup () {
97@@ -52,28 +30,21 @@
98 }
99
100 /**
101- * Loads the default avatar and is called once at startup.
102- */
103- public static void load_default_avatar () {
104- try {
105- default_avatar = Gtk.IconTheme.get_default ().
106- load_icon ("avatar-default", 96, 0);
107- } catch {
108- warning ("Couldn't load default wallpaper");
109- }
110- }
111-
112- /**
113- * Each LoginOption can load their own avatar-image here.
114- */
115- public virtual async void load_avatar () { }
116-
117- /**
118 * The name of this login how it shall be presented to the user.
119 */
120 public abstract string display_name { get; }
121
122 /**
123+ * Path to the avatar of this user or null
124+ * in case he has none.
125+ */
126+ public virtual string? avatar_path {
127+ get {
128+ return null;
129+ }
130+ }
131+
132+ /**
133 * Path to the background-image of this user or ""
134 * in case he has none.
135 */
136
137=== modified file 'src/LoginOptions/UserLogin.vala'
138--- src/LoginOptions/UserLogin.vala 2016-09-25 14:23:22 +0000
139+++ src/LoginOptions/UserLogin.vala 2016-12-17 22:20:38 +0000
140@@ -25,7 +25,12 @@
141 public UserLogin (int index, LightDM.User user) {
142 base (index);
143 this.lightdm_user = user;
144- avatar_ready = false;
145+ }
146+
147+ public override string? avatar_path {
148+ get {
149+ return lightdm_user.image;
150+ }
151 }
152
153 public override string background {
154@@ -57,20 +62,4 @@
155 return lightdm_user.session;
156 }
157 }
158-
159- public override async void load_avatar () {
160- try {
161- File file = File.new_for_path (lightdm_user.image);
162- InputStream stream = yield file.read_async (GLib.Priority.DEFAULT);
163- var buf = new Gdk.Pixbuf.from_stream_at_scale (stream, 96, 96, true);
164- avatar = buf;
165- } catch (Error e) {
166- message ("Using default-avatar instead of " + lightdm_user.image);
167- }
168- Idle.add (() => {
169- avatar_ready = true;
170- avatar_updated ();
171- return false;
172- });
173- }
174 }
175
176=== modified file 'src/PantheonGreeter.vala'
177--- src/PantheonGreeter.vala 2016-06-18 22:54:03 +0000
178+++ src/PantheonGreeter.vala 2016-12-17 22:20:38 +0000
179@@ -109,9 +109,6 @@
180 warning (e.message);
181 }
182
183- message ("Loading default-avatar...");
184- LoginOption.load_default_avatar ();
185-
186 message ("Building UI...");
187
188 clutter = new GtkClutter.Embed ();
189
190=== modified file 'src/UserList.vala'
191--- src/UserList.vala 2016-02-25 21:46:48 +0000
192+++ src/UserList.vala 2016-12-17 22:20:38 +0000
193@@ -76,10 +76,6 @@
194 index++;
195 }
196 size = index;
197-
198- foreach (LoginOption user in users) {
199- user.load_avatar.begin ();
200- }
201 }
202
203 public LoginOption get_user (int i) {

Subscribers

People subscribed via source and target branches