Merge lp:~nataliabidart/ubuntu-sso-client/resize-so-password-can-be-changed into lp:ubuntu-sso-client

Proposed by Natalia Bidart
Status: Merged
Approved by: Chad Miller
Approved revision: 659
Merged at revision: 656
Proposed branch: lp:~nataliabidart/ubuntu-sso-client/resize-so-password-can-be-changed
Merge into: lp:ubuntu-sso-client
Diff against target: 183 lines (+48/-45)
3 files modified
data/ui.glade (+9/-2)
ubuntu_sso/gtk/gui.py (+25/-26)
ubuntu_sso/gtk/tests/test_gui.py (+14/-17)
To merge this branch: bzr merge lp:~nataliabidart/ubuntu-sso-client/resize-so-password-can-be-changed
Reviewer Review Type Date Requested Status
Chad Miller (community) Approve
dobey (community) Approve
Review via email: mp+42135@code.launchpad.net

Commit message

* Added a gtk.Notebook to ensure proper window resize at startup (LP: #682669).
* Also, enabled window resizing to be more user friendly.

Description of the change

To test, first let's reproduce the problem on trunk. In an updated trunk, run:

* killall ubuntu-sso-login; DEBUG=True PYTHONPATH=. ./bin/ubuntu-sso-login
* open d-feet and execute the 'login' method of the com.ubuntu.sso service, /com/ubuntu/sso/credentials interface. Pass parameters like this:

'Test', {}

Then, in the newly shown GTK ui, click on "I've forgotten my password" button and enter the email address:

<email address hidden>

and hit Next. You'll see the resulting screen and you'll be scared (3 text entries that doesn't fit the main window).

Now, using this proposed branch repeat the procedure (be sure to close and re open d-feet) and check that the main window now has proper size for all the screens.
If you feel brave enough you could change the font dpi from System -> Preferences -> Appearence -> Fonts -> Details (I've tried with 200 dpi).

To post a comment you must log in.
659. By Natalia Bidart

Reverting changes to setup.py

Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
Chad Miller (cmiller) wrote :

Instead of catching size-allocations and performing some arithmetic magic, I think you should let them pass through.

In ubuntu_sso/gtk/gui.py

- obj.connect('size-allocate', self.on_size_allocate)

Now, you can remove .on_size_allocate altogether.

review: Needs Fixing
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

We need to connect to size-allocate to make labels resize properly on window resizing.

Revision history for this message
Chad Miller (cmiller) wrote :

I see the problem with resized wrapping Labels now.

I still think this signal shouldn't be touched, but I don't have a better idea at present.

I say the new behavior is a "Low" bug and it should be in Launchpad. A bad fix for a High-impact bug is okay for now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/ui.glade'
2--- data/ui.glade 2010-11-22 18:14:26 +0000
3+++ data/ui.glade 2010-11-29 17:47:47 +0000
4@@ -4,7 +4,6 @@
5 <!-- interface-naming-policy project-wide -->
6 <object class="GtkWindow" id="window">
7 <property name="border_width">10</property>
8- <property name="resizable">False</property>
9 <property name="window_position">center</property>
10 <signal name="delete_event" handler="on_close_clicked"/>
11 <child>
12@@ -49,7 +48,15 @@
13 </packing>
14 </child>
15 <child>
16- <placeholder/>
17+ <object class="GtkNotebook" id="content">
18+ <property name="visible">True</property>
19+ <property name="can_focus">True</property>
20+ <property name="show_tabs">False</property>
21+ <property name="show_border">False</property>
22+ </object>
23+ <packing>
24+ <property name="position">3</property>
25+ </packing>
26 </child>
27 </object>
28 </child>
29
30=== modified file 'ubuntu_sso/gtk/gui.py'
31--- ubuntu_sso/gtk/gui.py 2010-11-22 18:14:26 +0000
32+++ ubuntu_sso/gtk/gui.py 2010-11-29 17:47:47 +0000
33@@ -269,6 +269,7 @@
34 self.app_label = '<b>%s</b>' % self.app_name
35 self.tc_url = tc_url
36 self.help_text = help_text
37+ self.login_only = login_only
38 self.close_callback = close_callback
39 self.user_email = None
40 self.user_password = None
41@@ -333,25 +334,7 @@
42 self.request_password_token_vbox,
43 self.set_new_password_vbox)
44
45- self._append_page(self._build_processing_page())
46- self._append_page(self._build_finish_page())
47- self._append_page(self._build_login_page())
48- self._append_page(self._build_request_password_token_page())
49- self._append_page(self._build_set_new_password_page())
50- self._append_page(self._build_verify_email_page())
51-
52- if not login_only:
53- self._append_page(self._build_enter_details_page())
54- self._append_page(self._build_tc_page())
55- self.login_button.grab_focus()
56- self._set_current_page(self.enter_details_vbox)
57- else:
58- self.login_back_button.hide()
59- self.login_ok_button.grab_focus()
60- self.login_vbox.help_text = help_text
61- self._set_current_page(self.login_vbox)
62-
63- self.window.connect('size-allocate', self.on_size_allocate)
64+ self._append_pages()
65
66 self._signals = {
67 'CaptchaGenerated':
68@@ -502,9 +485,29 @@
69
70 # build pages
71
72+ def _append_pages(self):
73+ """Append all the requires pages to main widget."""
74+ self._append_page(self._build_processing_page())
75+ self._append_page(self._build_finish_page())
76+ self._append_page(self._build_login_page())
77+ self._append_page(self._build_request_password_token_page())
78+ self._append_page(self._build_set_new_password_page())
79+ self._append_page(self._build_verify_email_page())
80+
81+ if not self.login_only:
82+ self._append_page(self._build_enter_details_page())
83+ self._append_page(self._build_tc_page())
84+ self.login_button.grab_focus()
85+ self._set_current_page(self.enter_details_vbox)
86+ else:
87+ self.login_back_button.hide()
88+ self.login_ok_button.grab_focus()
89+ self.login_vbox.help_text = self.help_text
90+ self._set_current_page(self.login_vbox)
91+
92 def _append_page(self, page):
93 """Append 'page' to the 'window'."""
94- self.window.get_children()[0].pack_start(page)
95+ self.content.append_page(page)
96
97 def _set_header(self, header):
98 """Set 'header' as the window title and header."""
99@@ -525,11 +528,7 @@
100 else:
101 self.warning_label.set_text('')
102
103- for page in self.pages:
104- if page is current_page:
105- page.show()
106- else:
107- page.hide()
108+ self.content.set_current_page(self.content.page_num(current_page))
109
110 if current_page.default_widget is not None:
111 current_page.default_widget.grab_default()
112@@ -748,7 +747,7 @@
113
114 def on_size_allocate(self, widget, allocation):
115 """The widget can re rezised, embrase it!."""
116- widget.set_size_request(allocation.width, allocation.height)
117+ widget.set_size_request(allocation.width - 2, -1)
118
119 def on_close_clicked(self, *args, **kwargs):
120 """Call self.close_callback if defined."""
121
122=== modified file 'ubuntu_sso/gtk/tests/test_gui.py'
123--- ubuntu_sso/gtk/tests/test_gui.py 2010-11-22 15:28:59 +0000
124+++ ubuntu_sso/gtk/tests/test_gui.py 2010-11-29 17:47:47 +0000
125@@ -438,16 +438,12 @@
126 self.assertEqual(entry.warning, message)
127
128 def assert_pages_visibility(self, **kwargs):
129- """The pages has the correct visibility."""
130- for i in self.pages:
131- kwargs.setdefault(i, False)
132-
133- msg = 'page %r must %sbe visible.'
134- for name, expected in kwargs.iteritems():
135- page = getattr(self.ui, '%s_vbox' % name)
136- actual = page.get_property('visible')
137- self.assertEqual(expected, actual,
138- msg % (name, '' if expected else 'not '))
139+ """The page 'name' is the current page for the content notebook."""
140+ msg = 'page %r must be self.ui.content\'s current page.'
141+ (name, _), = kwargs.items()
142+ page = getattr(self.ui, '%s_vbox' % name)
143+ self.assertEqual(self.ui.content.get_current_page(),
144+ self.ui.content.page_num(page), msg % name)
145
146 def click_join_with_valid_data(self):
147 """Move to the next page after entering details."""
148@@ -510,9 +506,9 @@
149 """The main window is shown at startup."""
150 self.assertTrue(self.ui.window.get_property('visible'))
151
152- def test_main_window_is_not_resizable(self):
153- """The main window can not be resized."""
154- self.assertFalse(self.ui.window.get_property('resizable'))
155+ def test_main_window_is_resizable(self):
156+ """The main window can be resized."""
157+ self.assertTrue(self.ui.window.get_property('resizable'))
158
159 def test_closing_main_window_calls_close_callback(self):
160 """The close_callback is called when closing the main window."""
161@@ -571,9 +567,9 @@
162 ui.on_close_clicked()
163 # no crash when close_callback is None
164
165- def test_pages_are_packed_into_window(self):
166- """All the pages are packed in the main window."""
167- children = self.ui.window.get_children()[0].get_children()
168+ def test_pages_are_packed_into_container(self):
169+ """All the pages are packed in the main container."""
170+ children = self.ui.content.get_children()
171 for page_name in self.pages:
172 page = getattr(self.ui, '%s_vbox' % page_name)
173 self.assertIn(page, children)
174@@ -602,7 +598,8 @@
175 for label in labels:
176 widget = getattr(self.ui, label)
177 widget.emit('size-allocate', gtk.gdk.Rectangle(1, 2, 3, 4))
178- self.assertEqual(widget.get_size_request(), (3, 4), msg % (label,))
179+ self.assertEqual(widget.get_size_request(), (3 - 2, -1),
180+ msg % (label,))
181
182 def test_password_fields_are_password(self):
183 """Password fields have the is_password flag set."""

Subscribers

People subscribed via source and target branches