Merge lp:~azzar1/software-properties/new-auth-dialog into lp:software-properties
- new-auth-dialog
- Merge into main
Status: | Merged |
---|---|
Approved by: | Sebastien Bacher |
Approved revision: | 1044 |
Merged at revision: | 1062 |
Proposed branch: | lp:~azzar1/software-properties/new-auth-dialog |
Merge into: | lp:software-properties |
Diff against target: |
569 lines (+243/-202) (has conflicts) 3 files modified
data/gtkbuilder/dialog-auth.ui (+96/-80) debian/changelog (+12/-0) softwareproperties/gtk/DialogAuth.py (+135/-122) Text conflict in debian/changelog |
To merge this branch: | bzr merge lp:~azzar1/software-properties/new-auth-dialog |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sebastien Bacher | Approve | ||
Review via email: mp+345483@code.launchpad.net |
Commit message
Implement new design for authentication dialog according to https:/
Description of the change
- 1038. By Andrea Azzarone
-
Merge trunk.
- 1039. By Andrea Azzarone
-
Merge with trunk.
Andrea Azzarone (azzar1) wrote : | # |
- 1040. By Andrea Azzarone
-
Merge with trunk.
- 1041. By Andrea Azzarone
-
Refactor dialog-auth.ui and DialogAuth.py
Andrea Azzarone (azzar1) wrote : | # |
I updated the code to sync it with the one used in gnome-software.
Sebastien Bacher (seb128) wrote : | # |
Thank you for the work, looks good to me, some small details
* that's not the exact same string but in https:/
'Ubuntu One account' where you wrote '*A*ccount' ... is that wanted?
* The dialog is titled "software-
* When I click on the sign in/register button (on disco, testing with an hacked lsb-release to have the UI showing) I get that error
'Traceback (most recent call last):
File "/usr/lib/
self.
TypeError: _button_
- 1042. By Andrea Azzarone
-
s/Account/account/g
- 1043. By Andrea Azzarone
-
DialogAuth: Show an empty titlebar
- 1044. By Andrea Azzarone
-
DialogAuth: remove extra self argument to _button_
add_another_ clicked_ cb()
Andrea Azzarone (azzar1) wrote : | # |
> Thank you for the work, looks good to me, some small details
>
> * that's not the exact same string but in https:/
> t.com/19801137/
> string
>
> 'Ubuntu One account' where you wrote '*A*ccount' ... is that wanted?
>
> * The dialog is titled "software-
> we get ride of the title or use something better/more user friendly?
>
> * When I click on the sign in/register button (on disco, testing with an
> hacked lsb-release to have the UI showing) I get that error
>
> 'Traceback (most recent call last):
> File "/usr/lib/
> line 237, in _button_
> self._button_
> TypeError: _button_
> were given'
Branch updated!
Sebastien Bacher (seb128) wrote : | # |
Looks good now!
Preview Diff
1 | === modified file 'data/gtkbuilder/dialog-auth.ui' | |||
2 | --- data/gtkbuilder/dialog-auth.ui 2018-03-21 14:05:30 +0000 | |||
3 | +++ data/gtkbuilder/dialog-auth.ui 2019-01-17 18:48:56 +0000 | |||
4 | @@ -1,114 +1,130 @@ | |||
5 | 1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
7 | 2 | <!-- Generated with glade 3.20.4 --> | 2 | <!-- Generated with glade 3.22.1 --> |
8 | 3 | <interface> | 3 | <interface> |
9 | 4 | <requires lib="gtk+" version="3.10"/> | 4 | <requires lib="gtk+" version="3.10"/> |
10 | 5 | <object class="GtkListStore" id="liststore_account"> | ||
11 | 6 | <columns> | ||
12 | 7 | <!-- column-name Id --> | ||
13 | 8 | <column type="gchararray"/> | ||
14 | 9 | <!-- column-name Email --> | ||
15 | 10 | <column type="gchararray"/> | ||
16 | 11 | <!-- column-name Account --> | ||
17 | 12 | <column type="GObject"/> | ||
18 | 13 | </columns> | ||
19 | 14 | </object> | ||
20 | 5 | <object class="GtkDialog" id="dialog_auth"> | 15 | <object class="GtkDialog" id="dialog_auth"> |
21 | 6 | <property name="can_focus">False</property> | ||
22 | 7 | <property name="resizable">False</property> | 16 | <property name="resizable">False</property> |
23 | 8 | <property name="modal">True</property> | ||
24 | 9 | <property name="destroy_with_parent">True</property> | ||
25 | 10 | <property name="type_hint">dialog</property> | 17 | <property name="type_hint">dialog</property> |
27 | 11 | <property name="deletable">False</property> | 18 | <child> |
28 | 19 | <placeholder/> | ||
29 | 20 | </child> | ||
30 | 12 | <child internal-child="vbox"> | 21 | <child internal-child="vbox"> |
33 | 13 | <object class="GtkBox" id="box_dialog"> | 22 | <object class="GtkBox"> |
34 | 14 | <property name="can_focus">False</property> | 23 | <property name="border_width">6</property> |
35 | 15 | <property name="orientation">vertical</property> | 24 | <property name="orientation">vertical</property> |
36 | 16 | <property name="spacing">2</property> | 25 | <property name="spacing">2</property> |
37 | 17 | <child internal-child="action_area"> | 26 | <child internal-child="action_area"> |
40 | 18 | <object class="GtkButtonBox" id="dialog-action_area1"> | 27 | <object class="GtkButtonBox"> |
41 | 19 | <property name="can_focus">False</property> | 28 | <child> |
42 | 29 | <object class="GtkButton" id="button_add_another"> | ||
43 | 30 | <property name="label" translatable="yes">Add another…</property> | ||
44 | 31 | <property name="visible">True</property> | ||
45 | 32 | <property name="can_focus">True</property> | ||
46 | 33 | <property name="receives_default">True</property> | ||
47 | 34 | <signal name="clicked" handler="_button_add_another_clicked_cb" swapped="no"/> | ||
48 | 35 | </object> | ||
49 | 36 | <packing> | ||
50 | 37 | <property name="expand">True</property> | ||
51 | 38 | <property name="secondary">True</property> | ||
52 | 39 | <property name="non_homogeneous">True</property> | ||
53 | 40 | </packing> | ||
54 | 41 | </child> | ||
55 | 42 | <child> | ||
56 | 43 | <object class="GtkButton" id="button_cancel"> | ||
57 | 44 | <property name="label" translatable="yes">Cancel</property> | ||
58 | 45 | <property name="visible">True</property> | ||
59 | 46 | <property name="can_focus">True</property> | ||
60 | 47 | <property name="receives_default">True</property> | ||
61 | 48 | <signal name="clicked" handler="_button_cancel_clicked_cb" swapped="no"/> | ||
62 | 49 | </object> | ||
63 | 50 | <packing> | ||
64 | 51 | <property name="expand">True</property> | ||
65 | 52 | <property name="non_homogeneous">True</property> | ||
66 | 53 | </packing> | ||
67 | 54 | </child> | ||
68 | 55 | <child> | ||
69 | 56 | <object class="GtkButton" id="button_continue"> | ||
70 | 57 | <property name="visible">True</property> | ||
71 | 58 | <property name="can_focus">True</property> | ||
72 | 59 | <property name="receives_default">True</property> | ||
73 | 60 | <signal name="clicked" handler="_button_continue_clicked_cb" swapped="no"/> | ||
74 | 61 | </object> | ||
75 | 62 | <packing> | ||
76 | 63 | <property name="expand">True</property> | ||
77 | 64 | <property name="non_homogeneous">True</property> | ||
78 | 65 | </packing> | ||
79 | 66 | </child> | ||
80 | 20 | </object> | 67 | </object> |
81 | 21 | <packing> | 68 | <packing> |
85 | 22 | <property name="expand">False</property> | 69 | <property name="expand">True</property> |
83 | 23 | <property name="fill">False</property> | ||
84 | 24 | <property name="position">0</property> | ||
86 | 25 | </packing> | 70 | </packing> |
87 | 26 | </child> | 71 | </child> |
88 | 27 | <child> | 72 | <child> |
90 | 28 | <object class="GtkGrid" id="main_grid"> | 73 | <object class="GtkBox"> |
91 | 29 | <property name="visible">True</property> | 74 | <property name="visible">True</property> |
93 | 30 | <property name="can_focus">False</property> | 75 | <property name="halign">start</property> |
94 | 31 | <property name="border_width">12</property> | 76 | <property name="border_width">12</property> |
97 | 32 | <property name="row_spacing">12</property> | 77 | <property name="spacing">18</property> |
96 | 33 | <property name="column_spacing">12</property> | ||
98 | 34 | <child> | 78 | <child> |
100 | 35 | <object class="GtkLabel" id="label_title"> | 79 | <object class="GtkImage"> |
101 | 36 | <property name="visible">True</property> | 80 | <property name="visible">True</property> |
107 | 37 | <property name="can_focus">False</property> | 81 | <property name="halign">start</property> |
108 | 38 | <property name="hexpand">True</property> | 82 | <property name="valign">start</property> |
109 | 39 | <property name="label" translatable="yes">To enable Livepatch choose an Ubuntu Single Sign-on account.</property> | 83 | <property name="icon_name">software-properties</property> |
110 | 40 | <property name="wrap">True</property> | 84 | <property name="icon_size">6</property> |
106 | 41 | <property name="xalign">0</property> | ||
111 | 42 | </object> | 85 | </object> |
112 | 43 | <packing> | ||
113 | 44 | <property name="left_attach">0</property> | ||
114 | 45 | <property name="top_attach">0</property> | ||
115 | 46 | </packing> | ||
116 | 47 | </child> | 86 | </child> |
117 | 48 | <child> | 87 | <child> |
119 | 49 | <object class="GtkFrame" id="main_frame"> | 88 | <object class="GtkBox" id="box_auth"> |
120 | 50 | <property name="visible">True</property> | 89 | <property name="visible">True</property> |
123 | 51 | <property name="can_focus">False</property> | 90 | <property name="halign">start</property> |
124 | 52 | <property name="label_xalign">0</property> | 91 | <property name="orientation">vertical</property> |
125 | 92 | <property name="spacing">12</property> | ||
126 | 53 | <child> | 93 | <child> |
128 | 54 | <object class="GtkListBox" id="listbox_accounts"> | 94 | <object class="GtkLabel" id="label_header"> |
129 | 95 | <property name="name">label_header</property> | ||
130 | 55 | <property name="visible">True</property> | 96 | <property name="visible">True</property> |
133 | 56 | <property name="can_focus">False</property> | 97 | <property name="halign">start</property> |
134 | 57 | <property name="selection_mode">none</property> | 98 | <property name="valign">start</property> |
135 | 99 | <property name="use_markup">True</property> | ||
136 | 100 | <property name="justify">fill</property> | ||
137 | 101 | <property name="wrap">True</property> | ||
138 | 102 | <property name="max_width_chars">40</property> | ||
139 | 103 | </object> | ||
140 | 104 | </child> | ||
141 | 105 | <child> | ||
142 | 106 | <object class="GtkComboBox" id="combobox_account"> | ||
143 | 107 | <property name="halign">start</property> | ||
144 | 108 | <property name="model">liststore_account</property> | ||
145 | 58 | <child> | 109 | <child> |
162 | 59 | <object class="GtkListBoxRow" id="listboxrow_new_account"> | 110 | <object class="GtkCellRendererText"/> |
163 | 60 | <property name="visible">True</property> | 111 | <attributes> |
164 | 61 | <property name="can_focus">False</property> | 112 | <attribute name="text">1</attribute> |
165 | 62 | <child> | 113 | </attributes> |
150 | 63 | <object class="GtkLabel" id="label_new_account"> | ||
151 | 64 | <property name="height_request">48</property> | ||
152 | 65 | <property name="visible">True</property> | ||
153 | 66 | <property name="can_focus">False</property> | ||
154 | 67 | <property name="halign">center</property> | ||
155 | 68 | <property name="valign">center</property> | ||
156 | 69 | <property name="label" translatable="yes"><b>Use another account...</b></property> | ||
157 | 70 | <property name="use_markup">True</property> | ||
158 | 71 | <property name="justify">center</property> | ||
159 | 72 | </object> | ||
160 | 73 | </child> | ||
161 | 74 | </object> | ||
166 | 75 | </child> | 114 | </child> |
167 | 76 | </object> | 115 | </object> |
168 | 77 | </child> | 116 | </child> |
169 | 117 | <child> | ||
170 | 118 | <object class="GtkLabel" id="label_account"> | ||
171 | 119 | <property name="halign">start</property> | ||
172 | 120 | </object> | ||
173 | 121 | </child> | ||
174 | 78 | </object> | 122 | </object> |
175 | 79 | <packing> | ||
176 | 80 | <property name="left_attach">0</property> | ||
177 | 81 | <property name="top_attach">1</property> | ||
178 | 82 | <property name="width">2</property> | ||
179 | 83 | </packing> | ||
180 | 84 | </child> | 123 | </child> |
181 | 85 | </object> | 124 | </object> |
209 | 86 | <packing> | 125 | </child> |
210 | 87 | <property name="expand">False</property> | 126 | </object> |
211 | 88 | <property name="fill">True</property> | 127 | </child> |
185 | 89 | <property name="position">1</property> | ||
186 | 90 | </packing> | ||
187 | 91 | </child> | ||
188 | 92 | </object> | ||
189 | 93 | </child> | ||
190 | 94 | <child type="titlebar"> | ||
191 | 95 | <object class="GtkHeaderBar"> | ||
192 | 96 | <property name="visible">True</property> | ||
193 | 97 | <property name="can_focus">False</property> | ||
194 | 98 | <property name="title" translatable="yes">Choose an account</property> | ||
195 | 99 | <child> | ||
196 | 100 | <object class="GtkButton" id="button_cancel"> | ||
197 | 101 | <property name="label">gtk-cancel</property> | ||
198 | 102 | <property name="visible">True</property> | ||
199 | 103 | <property name="can_focus">True</property> | ||
200 | 104 | <property name="receives_default">True</property> | ||
201 | 105 | <property name="use_stock">True</property> | ||
202 | 106 | </object> | ||
203 | 107 | </child> | ||
204 | 108 | </object> | ||
205 | 109 | </child> | ||
206 | 110 | <action-widgets> | ||
207 | 111 | <action-widget response="-6">button_cancel</action-widget> | ||
208 | 112 | </action-widgets> | ||
212 | 113 | </object> | 128 | </object> |
213 | 114 | </interface> | 129 | </interface> |
214 | 130 | |||
215 | 115 | 131 | ||
216 | === modified file 'debian/changelog' | |||
217 | --- debian/changelog 2019-01-16 16:02:03 +0000 | |||
218 | +++ debian/changelog 2019-01-17 18:48:56 +0000 | |||
219 | @@ -1,3 +1,4 @@ | |||
220 | 1 | <<<<<<< TREE | ||
221 | 1 | software-properties (0.96.31) UNRELEASED; urgency=medium | 2 | software-properties (0.96.31) UNRELEASED; urgency=medium |
222 | 2 | 3 | ||
223 | 3 | * Remove the migration script, it was online needed until bionic | 4 | * Remove the migration script, it was online needed until bionic |
224 | @@ -12,6 +13,17 @@ | |||
225 | 12 | 13 | ||
226 | 13 | -- Sebastien Bacher <seb128@ubuntu.com> Tue, 15 Jan 2019 10:48:27 +0100 | 14 | -- Sebastien Bacher <seb128@ubuntu.com> Tue, 15 Jan 2019 10:48:27 +0100 |
227 | 14 | 15 | ||
228 | 16 | ======= | ||
229 | 17 | software-properties (0.96.30) UNRELEASED; urgency=medium | ||
230 | 18 | |||
231 | 19 | * data/gtkbuilder/dialog-auth.ui: Update design of the authentication | ||
232 | 20 | dialog. | ||
233 | 21 | * softwareproperties/gtk/DialogAuth.py: Implement new design of the | ||
234 | 22 | authentication dialog. | ||
235 | 23 | |||
236 | 24 | -- Andrea Azzarone <andrea.azzarone@canonical.com> Wed, 19 Dec 2018 15:47:56 +0000 | ||
237 | 25 | |||
238 | 26 | >>>>>>> MERGE-SOURCE | ||
239 | 15 | software-properties (0.96.29) disco; urgency=medium | 27 | software-properties (0.96.29) disco; urgency=medium |
240 | 16 | 28 | ||
241 | 17 | * SoftwarePropertiesGtk.py: when checking a package's depends for DKMS also | 29 | * SoftwarePropertiesGtk.py: when checking a package's depends for DKMS also |
242 | 18 | 30 | ||
243 | === modified file 'softwareproperties/gtk/DialogAuth.py' | |||
244 | --- softwareproperties/gtk/DialogAuth.py 2018-03-21 15:52:33 +0000 | |||
245 | +++ softwareproperties/gtk/DialogAuth.py 2019-01-17 18:48:56 +0000 | |||
246 | @@ -19,6 +19,7 @@ | |||
247 | 19 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | 19 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
248 | 20 | # USA | 20 | # USA |
249 | 21 | 21 | ||
250 | 22 | from enum import IntEnum | ||
251 | 22 | import os | 23 | import os |
252 | 23 | 24 | ||
253 | 24 | from gettext import gettext as _ | 25 | from gettext import gettext as _ |
254 | @@ -28,9 +29,13 @@ | |||
255 | 28 | 29 | ||
256 | 29 | import gi | 30 | import gi |
257 | 30 | gi.require_version('Goa', '1.0') | 31 | gi.require_version('Goa', '1.0') |
259 | 31 | from gi.repository import Gio, GLib, Goa, GObject, Gtk | 32 | from gi.repository import Gio, GLib, Goa, Gtk |
260 | 32 | import logging | 33 | import logging |
261 | 33 | 34 | ||
262 | 35 | class Column(IntEnum): | ||
263 | 36 | ID = 0 | ||
264 | 37 | MAIL = 1 | ||
265 | 38 | ACCOUNT = 2 | ||
266 | 34 | 39 | ||
267 | 35 | class DialogAuth: | 40 | class DialogAuth: |
268 | 36 | 41 | ||
269 | @@ -38,68 +43,126 @@ | |||
270 | 38 | """setup up the gtk dialog""" | 43 | """setup up the gtk dialog""" |
271 | 39 | self.parent = parent | 44 | self.parent = parent |
272 | 40 | 45 | ||
276 | 41 | setup_ui(self, os.path.join(datadir, "gtkbuilder", | 46 | setup_ui(self, os.path.join(datadir, "gtkbuilder", "dialog-auth.ui"), |
277 | 42 | "dialog-auth.ui"), domain="software-properties") | 47 | domain="software-properties") |
275 | 43 | self.label_title.set_max_width_chars(50) | ||
278 | 44 | 48 | ||
279 | 45 | self.dialog = self.dialog_auth | 49 | self.dialog = self.dialog_auth |
281 | 46 | self.dialog.use_header_bar = True | 50 | self.dialog.set_title('') |
282 | 51 | self.dialog.set_deletable(False) | ||
283 | 47 | self.dialog.set_transient_for(parent) | 52 | self.dialog.set_transient_for(parent) |
284 | 48 | 53 | ||
286 | 49 | self.listboxrow_new_account.account = None | 54 | self.button_continue.grab_focus() |
287 | 50 | 55 | ||
288 | 51 | self.account = None | 56 | self.account = None |
289 | 52 | self.dispose_on_new_account = False | 57 | self.dispose_on_new_account = False |
290 | 53 | self.goa_client = Goa.Client.new_sync(None) | 58 | self.goa_client = Goa.Client.new_sync(None) |
291 | 54 | 59 | ||
293 | 55 | self.listbox_accounts.connect('row-activated', self._listbox_accounts_row_activated_cb) | 60 | self._setup_model() |
294 | 61 | self._check_ui(select=False) | ||
295 | 56 | 62 | ||
296 | 57 | # Be ready to other accounts | 63 | # Be ready to other accounts |
297 | 58 | self.goa_client.connect('account-added', self._account_added_cb) | 64 | self.goa_client.connect('account-added', self._account_added_cb) |
298 | 59 | self.goa_client.connect('account-removed', self._account_removed_cb) | 65 | self.goa_client.connect('account-removed', self._account_removed_cb) |
299 | 60 | 66 | ||
300 | 61 | self._setup_listbox_accounts() | ||
301 | 62 | self._check_ui() | ||
302 | 63 | |||
303 | 64 | def run(self): | 67 | def run(self): |
304 | 65 | res = self.dialog.run() | 68 | res = self.dialog.run() |
305 | 66 | self.dialog.hide() | 69 | self.dialog.hide() |
306 | 67 | return res | 70 | return res |
307 | 68 | 71 | ||
323 | 69 | def _check_ui(self): | 72 | def _setup_model(self): |
309 | 70 | rows = self.listbox_accounts.get_children() | ||
310 | 71 | has_accounts = len(rows) > 1 | ||
311 | 72 | |||
312 | 73 | if has_accounts: | ||
313 | 74 | title = _('To continue choose an Ubuntu Single Sign-On account.') | ||
314 | 75 | new_account = _('Use another account…') | ||
315 | 76 | else: | ||
316 | 77 | title = _('To continue you need an Ubuntu Single Sign-On account.') | ||
317 | 78 | new_account = _('Sign In…') | ||
318 | 79 | |||
319 | 80 | self.label_title.set_text(title) | ||
320 | 81 | self.label_new_account.set_markup('<b>{}</b>'.format(new_account)) | ||
321 | 82 | |||
322 | 83 | def _setup_listbox_accounts(self): | ||
324 | 84 | for obj in self.goa_client.get_accounts(): | 73 | for obj in self.goa_client.get_accounts(): |
336 | 85 | account = obj.get_account() | 74 | self._add_account(obj.get_account(), select=False) |
337 | 86 | if self._is_account_supported(account): | 75 | |
338 | 87 | self._add_account(account) | 76 | def _set_header(self, label): |
339 | 88 | 77 | self.label_header.set_markup( | |
340 | 89 | def _is_account_supported(self, account): | 78 | "<span size='larger' weight='bold'>%s</span>" % label) |
341 | 90 | return account.props.provider_type == 'ubuntusso' | 79 | |
342 | 91 | 80 | def _check_ui(self, select): | |
343 | 92 | def _add_account(self, account): | 81 | naccounts = len(self.liststore_account) |
344 | 93 | row = self._create_row(account) | 82 | |
345 | 94 | self.listbox_accounts.prepend(row) | 83 | if naccounts == 0: |
346 | 95 | self._check_ui() | 84 | self._set_header( |
347 | 85 | _('To use Livepatch, you need to use an Ubuntu One account.')) | ||
348 | 86 | self.combobox_account.set_visible(False) | ||
349 | 87 | self.label_account.set_visible(False) | ||
350 | 88 | self.button_add_another.set_visible(False) | ||
351 | 89 | self.button_continue.set_label(_('Sign In / Register…')) | ||
352 | 90 | elif naccounts == 1: | ||
353 | 91 | self._set_header( | ||
354 | 92 | _('To use Livepatch, you need to use your Ubuntu One account.')) | ||
355 | 93 | self.combobox_account.set_visible(False) | ||
356 | 94 | self.label_account.set_visible(True) | ||
357 | 95 | self.label_account.set_text(self.liststore_account[0][Column.MAIL]) | ||
358 | 96 | self.button_add_another.set_visible(True) | ||
359 | 97 | self.button_continue.set_label(_('Continue')) | ||
360 | 98 | else: | ||
361 | 99 | self._set_header( | ||
362 | 100 | _('To use Livepatch, you need to use an Ubuntu One account.')) | ||
363 | 101 | self.button_add_another.set_visible(True) | ||
364 | 102 | self.combobox_account.set_visible(True) | ||
365 | 103 | self.label_account.set_visible(False) | ||
366 | 104 | self.button_continue.set_label(_('Use')) | ||
367 | 105 | if select: | ||
368 | 106 | self.combobox_account.set_active(naccounts-1) | ||
369 | 107 | elif self.combobox_account.get_active() == -1: | ||
370 | 108 | self.combobox_account.set_active(0) | ||
371 | 109 | |||
372 | 110 | def _ignore_account(self, account): | ||
373 | 111 | return account.props.provider_type != 'ubuntusso' | ||
374 | 112 | |||
375 | 113 | def _get_account_iter(self, account): | ||
376 | 114 | row = self.liststore_account.get_iter_first() | ||
377 | 115 | while row is not None: | ||
378 | 116 | account_id = self.liststore_account.get_value(row, Column.ID) | ||
379 | 117 | if account_id == account.props.id: | ||
380 | 118 | return row | ||
381 | 119 | row = self.liststore_account.iter_next(row) | ||
382 | 120 | return None | ||
383 | 121 | |||
384 | 122 | def _add_account(self, account, select): | ||
385 | 123 | if self._ignore_account(account): | ||
386 | 124 | return | ||
387 | 125 | |||
388 | 126 | account_iter = self._get_account_iter(account) | ||
389 | 127 | if account_iter is not None: | ||
390 | 128 | return | ||
391 | 129 | |||
392 | 130 | account_iter = self.liststore_account.append() | ||
393 | 131 | self.liststore_account.set(account_iter, | ||
394 | 132 | [Column.ID, Column.MAIL, Column.ACCOUNT], | ||
395 | 133 | [account.props.id, account.props.presentation_identity, account]) | ||
396 | 134 | self._check_ui(select) | ||
397 | 96 | 135 | ||
398 | 97 | def _remove_account(self, account): | 136 | def _remove_account(self, account): |
404 | 98 | for row in self.listbox_accounts.get_children(): | 137 | if self._ignore_account(account): |
405 | 99 | if row.account == account: | 138 | return |
406 | 100 | row.destroy() | 139 | |
407 | 101 | self._check_ui() | 140 | account_iter = self._get_account_iter(account) |
408 | 102 | break | 141 | if account_iter is None: |
409 | 142 | return | ||
410 | 143 | |||
411 | 144 | self.liststore_account.remove(account_iter) | ||
412 | 145 | self._check_ui(select=False) | ||
413 | 146 | |||
414 | 147 | def _response_if_valid(self, account): | ||
415 | 148 | def cb(source, res, data): | ||
416 | 149 | try: | ||
417 | 150 | source.call_ensure_credentials_finish(res) | ||
418 | 151 | valid = True | ||
419 | 152 | except GLib.Error as e: | ||
420 | 153 | valid = False | ||
421 | 154 | |||
422 | 155 | if not valid: | ||
423 | 156 | try: | ||
424 | 157 | self._spawn_goa_with_args(account.props.id, None) | ||
425 | 158 | except GLib.Error as e: | ||
426 | 159 | logging.warning ('Failed to spawn gnome-control-center: %s', | ||
427 | 160 | e.message) | ||
428 | 161 | else: | ||
429 | 162 | self.account = account | ||
430 | 163 | self.dialog.response(Gtk.ResponseType.OK) | ||
431 | 164 | |||
432 | 165 | account.call_ensure_credentials(None, cb, None) | ||
433 | 103 | 166 | ||
434 | 104 | def _build_dbus_params(self, action, arg): | 167 | def _build_dbus_params(self, action, arg): |
435 | 105 | builder = GLib.VariantBuilder.new(GLib.VariantType.new('av')) | 168 | builder = GLib.VariantBuilder.new(GLib.VariantType.new('av')) |
436 | @@ -118,7 +181,8 @@ | |||
437 | 118 | v = GLib.Variant.new_variant(s) | 181 | v = GLib.Variant.new_variant(s) |
438 | 119 | builder.add_value(v) | 182 | builder.add_value(v) |
439 | 120 | 183 | ||
441 | 121 | array = GLib.Variant.new_tuple(GLib.Variant.new_string('online-accounts'), builder.end()) | 184 | array = GLib.Variant.new_tuple( |
442 | 185 | GLib.Variant.new_string('online-accounts'), builder.end()) | ||
443 | 122 | array = GLib.Variant.new_variant(array) | 186 | array = GLib.Variant.new_variant(array) |
444 | 123 | 187 | ||
445 | 124 | param = GLib.Variant.new_tuple( | 188 | param = GLib.Variant.new_tuple( |
446 | @@ -135,94 +199,43 @@ | |||
447 | 135 | 'org.gtk.Actions', None) | 199 | 'org.gtk.Actions', None) |
448 | 136 | 200 | ||
449 | 137 | param = self._build_dbus_params(action, arg) | 201 | param = self._build_dbus_params(action, arg) |
523 | 138 | timeout = 10*60*1000 # 10 minutes should be enough to create an account | 202 | proxy.call_sync('Activate', param, Gio.DBusCallFlags.NONE, -1, None) |
451 | 139 | proxy.call_sync('Activate', param, Gio.DBusCallFlags.NONE, timeout, None) | ||
452 | 140 | |||
453 | 141 | def _create_row(self, account): | ||
454 | 142 | identity = account.props.presentation_identity | ||
455 | 143 | provider_name = account.props.provider_name | ||
456 | 144 | |||
457 | 145 | row = Gtk.ListBoxRow.new() | ||
458 | 146 | row.show() | ||
459 | 147 | |||
460 | 148 | hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 6) | ||
461 | 149 | hbox.set_hexpand(True) | ||
462 | 150 | hbox.show() | ||
463 | 151 | |||
464 | 152 | image = Gtk.Image.new_from_icon_name('avatar-default', Gtk.IconSize.DIALOG) | ||
465 | 153 | image.set_pixel_size(48) | ||
466 | 154 | image.show() | ||
467 | 155 | hbox.pack_start(image, False, False, 0) | ||
468 | 156 | |||
469 | 157 | vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 2) | ||
470 | 158 | vbox.set_valign(Gtk.Align.CENTER) | ||
471 | 159 | vbox.show() | ||
472 | 160 | hbox.pack_start(vbox, False, False, 0) | ||
473 | 161 | |||
474 | 162 | if identity: | ||
475 | 163 | ilabel = Gtk.Label.new() | ||
476 | 164 | ilabel.set_halign(Gtk.Align.START) | ||
477 | 165 | ilabel.set_markup('<b>{}</b>'.format(identity)) | ||
478 | 166 | ilabel.show() | ||
479 | 167 | vbox.pack_start(ilabel, True, True, 0) | ||
480 | 168 | |||
481 | 169 | if provider_name: | ||
482 | 170 | plabel = Gtk.Label.new() | ||
483 | 171 | plabel.set_halign(Gtk.Align.START) | ||
484 | 172 | plabel.set_markup('<small><span foreground=\"#555555\">{}</span></small>'.format(provider_name)) | ||
485 | 173 | plabel.show() | ||
486 | 174 | vbox.pack_start(plabel, True, True, 0) | ||
487 | 175 | |||
488 | 176 | warning_icon = Gtk.Image.new_from_icon_name('dialog-warning-symbolic', Gtk.IconSize.BUTTON) | ||
489 | 177 | warning_icon.set_no_show_all(True) | ||
490 | 178 | warning_icon.set_margin_end (15) | ||
491 | 179 | hbox.pack_end(warning_icon, False, False, 0) | ||
492 | 180 | |||
493 | 181 | row.add(hbox) | ||
494 | 182 | |||
495 | 183 | account.bind_property('attention-needed', warning_icon, 'visible', | ||
496 | 184 | GObject.BindingFlags.DEFAULT | GObject.BindingFlags.SYNC_CREATE) | ||
497 | 185 | |||
498 | 186 | row.account = account | ||
499 | 187 | return row | ||
500 | 188 | |||
501 | 189 | # Signals handlers | ||
502 | 190 | def _listbox_accounts_row_activated_cb(self, listbox, row): | ||
503 | 191 | account = row.account | ||
504 | 192 | |||
505 | 193 | if account is None: | ||
506 | 194 | # TODO (azzar1): there is no easy way to put this to false | ||
507 | 195 | # if the user close the windows without adding an account. | ||
508 | 196 | # We need to discuss with goa's upstream to support such usercases | ||
509 | 197 | try: | ||
510 | 198 | self._spawn_goa_with_args('add', 'ubuntusso') | ||
511 | 199 | self.dispose_on_new_account = True | ||
512 | 200 | except GLib.Error as e: | ||
513 | 201 | logging.warning ('Failed to spawing gnome-control-center: %s', e.message) | ||
514 | 202 | else: | ||
515 | 203 | if account.props.attention_needed: | ||
516 | 204 | try: | ||
517 | 205 | self._spawn_goa_with_args(account.props.id, None) | ||
518 | 206 | except GLib.Error as e: | ||
519 | 207 | logging.warning ('Failed to spawing gnome-control-center: %s', e.message) | ||
520 | 208 | else: | ||
521 | 209 | self.account = account | ||
522 | 210 | self.dialog.response(Gtk.ResponseType.OK) | ||
524 | 211 | 203 | ||
525 | 212 | def _account_added_cb(self, goa_client, goa_object): | 204 | def _account_added_cb(self, goa_client, goa_object): |
526 | 213 | account = goa_object.get_account() | 205 | account = goa_object.get_account() |
528 | 214 | if not self._is_account_supported(account): | 206 | if self._ignore_account(account): |
529 | 215 | return | 207 | return |
530 | 216 | if not self.dispose_on_new_account: | 208 | if not self.dispose_on_new_account: |
532 | 217 | self._add_account(account) | 209 | self._add_account(account, True) |
533 | 218 | else: | 210 | else: |
536 | 219 | self.account = account | 211 | self._response_if_valid(account) |
535 | 220 | self.dialog.response(Gtk.ResponseType.OK) | ||
537 | 221 | 212 | ||
538 | 222 | def _account_removed_cb(self, goa_client, goa_object): | 213 | def _account_removed_cb(self, goa_client, goa_object): |
539 | 223 | account = goa_object.get_account() | 214 | account = goa_object.get_account() |
541 | 224 | if self._is_account_supported(account): | 215 | if not self._ignore_account(account): |
542 | 225 | self._remove_account(account) | 216 | self._remove_account(account) |
543 | 226 | 217 | ||
546 | 227 | 218 | def _button_add_another_clicked_cb(self, button): | |
547 | 228 | 219 | try: | |
548 | 220 | # There is no easy way to put this to false if the user close the | ||
549 | 221 | # windows without adding an account. | ||
550 | 222 | self._spawn_goa_with_args('add', 'ubuntusso') | ||
551 | 223 | self.dispose_on_new_account = True | ||
552 | 224 | except GLib.Error as e: | ||
553 | 225 | logging.warning ('Failed to spawn control-center: %s', e.message) | ||
554 | 226 | |||
555 | 227 | def _button_cancel_clicked_cb(self, button): | ||
556 | 228 | self.dialog.response(Gtk.ResponseType.CANCEL) | ||
557 | 229 | |||
558 | 230 | def _button_continue_clicked_cb(self, button): | ||
559 | 231 | naccounts = len(self.liststore_account) | ||
560 | 232 | |||
561 | 233 | account = None | ||
562 | 234 | if naccounts >= 1: | ||
563 | 235 | active_index = self.combobox_account.get_active() | ||
564 | 236 | account = self.liststore_account[active_index][Column.ACCOUNT] | ||
565 | 237 | |||
566 | 238 | if account is None: | ||
567 | 239 | self._button_add_another_clicked_cb(self.button_add_another) | ||
568 | 240 | else: | ||
569 | 241 | self._response_if_valid(account) |
Merge with trunk and changelog entry updated.