Merge lp:~chrismcginlay/ubuntuone-control-panel/fixes_715820 into lp:ubuntuone-control-panel

Proposed by Chris McGinlay
Status: Merged
Approved by: Natalia Bidart
Approved revision: 73
Merged at revision: 80
Proposed branch: lp:~chrismcginlay/ubuntuone-control-panel/fixes_715820
Merge into: lp:ubuntuone-control-panel
Diff against target: 290 lines (+107/-22)
2 files modified
ubuntuone/controlpanel/gtk/gui.py (+29/-8)
ubuntuone/controlpanel/gtk/tests/test_gui.py (+78/-14)
To merge this branch: bzr merge lp:~chrismcginlay/ubuntuone-control-panel/fixes_715820
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
Natalia Bidart (community) Approve
Review via email: mp+50417@code.launchpad.net

Commit message

- Implement tooltips for Connect/Disconnect and Account/Cloud/Devices (LP:715820).

Description of the change

Implement tooltips for Connect/Disconnect and Account/Cloud/Devices (LP:715820)
Modified _update_status(), adding tooltip-None argument after callback argument
Modified ManagementPanel.__init__(), using set_tooltip_text()
Set up corresponding tests, asserting existence and validity of tooltips.

To post a comment you must log in.
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Chris,

Thanks for working on this! The branch is good to go except for a few things that need fixing:

* the adding of tooltip=None in _update_status should be the last argument, to maintain compatibility of the function API.

* for completeness sake, you should add tooltips (and the matching tests) for the rest of the buttons (ENABLE, RESTART, START, STOP). See below for proper strings to use as tooltips.

* tooltip strings should be (always start with an action since is a button tooltip):

    CONNECT_TOOLTIP = _('Connect the file sync service with your personal cloud.')
    DISCONNECT_TOOLTIP = _('Disconnect the file sync service from your personal cloud.')
    ENABLE_TOOLTIP = _('Enable the file sync service.')
    RESTART_TOOLTIP = _('Restart the file sync service.')
    START_TOOLTIP = _('Start the file sync service.')
    STOP_TOOLTIP = _('Stop the file sync service.')

    DASHBOARD_BUTTON_TOOLTIP = _('View your personal details and service summary.')
    DEVICES_BUTTON_TOOLTIP = _('Manage devices registered with your personal cloud.')
    VOLUMES_BUTTON_TOOLTIP = _('Manage your cloud folders.')

* fix a couple of docstrings to be PEP-257 compliant:

        """The file sync status is disconnected.
        * The correct connection status is displayed.
        * The button has a tooltip.
        * The correct connect tooltip is set.

        """

should be

        """The file sync status is disconnected.

        * The correct connection status is displayed.
        * The button has a tooltip.
        * The correct connect tooltip is set.

        """

(same for docstring in test_on_file_sync_status_syncing).

* Instead of duplicate the adding of the assertions

        self.assertTrue(self.ui.button.get_has_tooltip())
        self.assertEqual(self.ui.button.get_tooltip_text(),
                         self.ui.DISCONNECT_TOOLTIP)

modify assert_status_correct to receive the tooltip and assert over it in only one place.

One again, thanks a lot! This is pretty close to be landed.

review: Needs Fixing
73. By Chris McGinlay

Added tooltip strings for enable/disable/start/stop sync states along with testcases
Moved tooltip argument in _update_status to end of argument list
Introduced tooltip=None argument in assert_status_correct to streamline assertion tests.
Fixed docstrings for tooltip testcases.

Revision history for this message
Chris McGinlay (chrismcginlay) wrote :

Hi Naty, thank you for suggestions and advice. I hope these are implemented correctly and have updated branch to be reviewed. On running my latest control panel tonight it seems a little slow when manually testing disconnect/reconnect. Probably is due to a local Internet connectivity issue here, although you might want to try it too. All test cases pass, except the 1 skipped.

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

Very good! Thanks for working on this.

review: Approve
Revision history for this message
Roberto Alsina (ralsina) wrote :

+1, great work Chris!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntuone/controlpanel/gtk/gui.py'
2--- ubuntuone/controlpanel/gtk/gui.py 2011-02-22 19:28:14 +0000
3+++ ubuntuone/controlpanel/gtk/gui.py 2011-02-22 23:51:33 +0000
4@@ -1132,6 +1132,15 @@
5 START = _('Start')
6 STOP = _('Stop')
7
8+ CONNECT_TOOLTIP = _('Connect the file sync service '
9+ 'with your personal cloud')
10+ DISCONNECT_TOOLTIP = _('Disconnect the file sync service '
11+ 'from your personal cloud')
12+ ENABLE_TOOLTIP = _('Enable the file sync service')
13+ RESTART_TOOLTIP = _('Restart the file sync service')
14+ START_TOOLTIP = _('Start the file sync service')
15+ STOP_TOOLTIP = _('Stop the file sync service')
16+
17 def __init__(self):
18 gtk.HBox.__init__(self)
19 ControlPanelMixin.__init__(self)
20@@ -1166,7 +1175,8 @@
21 error_handler=error_handler)
22 self.show_all()
23
24- def _update_status(self, msg, action, callback, icon=None, color=None):
25+ def _update_status(self, msg, action, callback,
26+ icon=None, color=None, tooltip=None):
27 """Update the status info."""
28 if icon is not None:
29 foreground = '' if color is None else 'foreground="%s"' % color
30@@ -1178,6 +1188,8 @@
31 self.button.set_uri(action)
32 self.button.set_sensitive(True)
33 self.button.set_data('callback', callback)
34+ if tooltip is not None:
35+ self.button.set_tooltip_text(tooltip)
36
37 def _on_button_clicked(self, button):
38 """Button was clicked, act accordingly the label."""
39@@ -1190,48 +1202,49 @@
40 """Backend notifies of file sync status being disabled."""
41 self._update_status(self.FILE_SYNC_DISABLED,
42 self.ENABLE, self.on_enable_clicked,
43- '✘', 'red')
44+ '✘', 'red', self.ENABLE_TOOLTIP)
45
46 @log_call(logger.info)
47 def on_file_sync_status_starting(self, msg):
48 """Backend notifies of file sync status being starting."""
49 self._update_status(self.FILE_SYNC_STARTING,
50 self.STOP, self.on_stop_clicked,
51- '⇅', ORANGE)
52+ '⇅', ORANGE, self.STOP_TOOLTIP)
53
54 @log_call(logger.info)
55 def on_file_sync_status_stopped(self, msg):
56 """Backend notifies of file sync being stopped."""
57 self._update_status(self.FILE_SYNC_STOPPED,
58 self.START, self.on_start_clicked,
59- '✘', 'red')
60+ '✘', 'red', self.START_TOOLTIP)
61
62 @log_call(logger.info)
63 def on_file_sync_status_disconnected(self, msg):
64 """Backend notifies of file sync status being ready."""
65 self._update_status(self.FILE_SYNC_DISCONNECTED,
66 self.CONNECT, self.on_connect_clicked,
67- '✘', 'red')
68+ '✘', 'red', self.CONNECT_TOOLTIP,)
69
70 @log_call(logger.info)
71 def on_file_sync_status_syncing(self, msg):
72 """Backend notifies of file sync status being syncing."""
73 self._update_status(self.FILE_SYNC_SYNCING,
74 self.DISCONNECT, self.on_disconnect_clicked,
75- '⇅', ORANGE)
76+ '⇅', ORANGE, self.DISCONNECT_TOOLTIP)
77
78 @log_call(logger.info)
79 def on_file_sync_status_idle(self, msg):
80 """Backend notifies of file sync status being idle."""
81 self._update_status(self.FILE_SYNC_IDLE,
82 self.DISCONNECT, self.on_disconnect_clicked,
83- '✔', 'green')
84+ '✔', 'green', self.DISCONNECT_TOOLTIP)
85
86 @log_call(logger.error)
87 def on_file_sync_status_error(self, error_dict=None):
88 """Backend notifies of an error when fetching file sync status."""
89 self._update_status(WARNING_MARKUP % self.FILE_SYNC_ERROR,
90- self.RESTART, self.on_restart_clicked)
91+ self.RESTART, self.on_restart_clicked,
92+ tooltip=self.RESTART_TOOLTIP)
93
94 @log_call(logger.error)
95 def on_files_start_error(self, error_dict=None):
96@@ -1286,6 +1299,11 @@
97 QUOTA_LABEL = _('Using %(used)s of %(total)s (%(percentage).1f%%)')
98 DASHBOARD_BUTTON_NAME = 'Account'
99 DEVICES_BUTTON_NAME = 'Devices'
100+ DASHBOARD_BUTTON_TOOLTIP = _('View your personal details '
101+ 'and service summary.')
102+ DEVICES_BUTTON_TOOLTIP = _('Manage devices registered '
103+ 'with your personal cloud.')
104+ VOLUMES_BUTTON_TOOLTIP = _('Manage your cloud folders.')
105
106 def __init__(self, main_window=None):
107 gtk.VBox.__init__(self)
108@@ -1333,11 +1351,14 @@
109 self.notebook.insert_page(getattr(self, tab), position=page_num)
110
111 self.dashboard_button.set_name(self.DASHBOARD_BUTTON_NAME)
112+ self.dashboard_button.set_tooltip_text(self.DASHBOARD_BUTTON_TOOLTIP)
113
114 self.volumes_button.connect('clicked', lambda b: self.volumes.load())
115 self.services_button.connect('clicked', lambda b: self.services.load())
116+ self.volumes_button.set_tooltip_text(self.VOLUMES_BUTTON_TOOLTIP)
117
118 self.devices_button.set_name(self.DEVICES_BUTTON_NAME)
119+ self.devices_button.set_tooltip_text(self.DEVICES_BUTTON_TOOLTIP)
120 self.devices_button.connect('clicked', lambda b: self.devices.load())
121 self.devices.connect('local-device-removed',
122 lambda widget: self.emit('local-device-removed'))
123
124=== modified file 'ubuntuone/controlpanel/gtk/tests/test_gui.py'
125--- ubuntuone/controlpanel/gtk/tests/test_gui.py 2011-02-22 19:28:14 +0000
126+++ ubuntuone/controlpanel/gtk/tests/test_gui.py 2011-02-22 23:51:33 +0000
127@@ -2052,13 +2052,15 @@
128
129 klass = gui.FileSyncStatus
130
131- def assert_status_correct(self, status, action=None, callback=None):
132+ def assert_status_correct(self, status, action=None,
133+ callback=None, tooltip=None):
134 """The shown status is correct.
135
136 * The ui's label shows 'status'.
137 * If action is not None, the ui's button shows that 'action' as label
138 and when clicking it, 'self._set_called' gets executed.
139 * If action is None, the ui's button should be hidden.
140+ * If a tooltip is required, then it exists with correct text.
141
142 """
143 self.assertTrue(self.ui.label.get_visible())
144@@ -2080,6 +2082,12 @@
145 else:
146 self.assertFalse(self.ui.button.get_visible())
147
148+ if tooltip is not None:
149+ self.assertTrue(self.ui.button.get_has_tooltip())
150+ self.assertEqual(self.ui.button.get_tooltip_text(), tooltip)
151+ else:
152+ self.assertFalse(self.ui.button.get_has_tooltip())
153+
154 def test_is_a_box(self):
155 """Inherits from gtk.Box."""
156 self.assertIsInstance(self.ui, gui.gtk.Box)
157@@ -2121,52 +2129,88 @@
158 self.assert_backend_called('file_sync_status', ())
159
160 def test_on_file_sync_status_disabled(self):
161- """The file sync is disabled."""
162+ """The file sync is disabled.
163+
164+ * The correct connection status is displayed.
165+ * The button has a tooltip with correct text.
166+
167+ """
168 self.patch(self.ui, 'on_enable_clicked', self._set_called)
169 self.ui.on_file_sync_status_disabled('msg')
170
171 self.assert_status_correct(self.ui.FILE_SYNC_DISABLED,
172- action=self.ui.ENABLE)
173+ action=self.ui.ENABLE,
174+ tooltip=self.ui.ENABLE_TOOLTIP)
175
176 def test_on_file_sync_status_starting(self):
177- """The file sync status is starting."""
178+ """The file sync status is starting.
179+
180+ * The correct connection status is displayed.
181+ * The button has a tooltip with correct text.
182+
183+ """
184 self.patch(self.ui, 'on_stop_clicked', self._set_called)
185 self.ui.on_file_sync_status_starting('msg')
186
187 self.assert_status_correct(self.ui.FILE_SYNC_STARTING,
188- action=self.ui.STOP)
189+ action=self.ui.STOP,
190+ tooltip=self.ui.STOP_TOOLTIP)
191
192 def test_on_file_sync_status_stopped(self):
193- """The file sync is stopped."""
194+ """The file sync is stopped.
195+
196+ * The correct connection status is displayed.
197+ * The button has a tooltip with correct text.
198+
199+ """
200 self.patch(self.ui, 'on_start_clicked', self._set_called)
201 self.ui.on_file_sync_status_stopped('msg')
202
203 self.assert_status_correct(self.ui.FILE_SYNC_STOPPED,
204- action=self.ui.START)
205+ action=self.ui.START,
206+ tooltip=self.ui.START_TOOLTIP)
207
208 def test_on_file_sync_status_disconnected(self):
209- """The file sync status is disconnected."""
210+ """The file sync status is disconnected.
211+
212+ * The correct connection status is displayed.
213+ * The button has a tooltip with correct text.
214+
215+ """
216 self.patch(self.ui, 'on_connect_clicked', self._set_called)
217 self.ui.on_file_sync_status_disconnected('msg')
218
219 self.assert_status_correct(self.ui.FILE_SYNC_DISCONNECTED,
220- action=self.ui.CONNECT)
221+ action=self.ui.CONNECT,
222+ tooltip=self.ui.CONNECT_TOOLTIP)
223
224 def test_on_file_sync_status_syncing(self):
225- """The file sync status is syncing."""
226+ """The file sync status is syncing.
227+
228+ * The correct connection status is displayed.
229+ * The button has a tooltip with correct text.
230+
231+ """
232 self.patch(self.ui, 'on_disconnect_clicked', self._set_called)
233 self.ui.on_file_sync_status_syncing('msg')
234
235 self.assert_status_correct(self.ui.FILE_SYNC_SYNCING,
236- action=self.ui.DISCONNECT)
237+ action=self.ui.DISCONNECT,
238+ tooltip=self.ui.DISCONNECT_TOOLTIP)
239
240 def test_on_file_sync_status_idle(self):
241- """The file sync status is idle."""
242+ """The file sync status is idle.
243+
244+ * The correct connection status is displayed.
245+ * The button has a tooltip with correct text.
246+
247+ """
248 self.patch(self.ui, 'on_disconnect_clicked', self._set_called)
249 self.ui.on_file_sync_status_idle('msg')
250
251 self.assert_status_correct(self.ui.FILE_SYNC_IDLE,
252- action=self.ui.DISCONNECT)
253+ action=self.ui.DISCONNECT,
254+ tooltip=self.ui.DISCONNECT_TOOLTIP)
255
256 def test_on_file_sync_status_error(self):
257 """The file sync status couldn't be retrieved."""
258@@ -2174,7 +2218,9 @@
259 self.ui.on_file_sync_status_error({'error_msg': 'error msg'})
260
261 msg = gui.WARNING_MARKUP % self.ui.FILE_SYNC_ERROR
262- self.assert_status_correct(msg, action=self.ui.RESTART)
263+ self.assert_status_correct(msg,
264+ action=self.ui.RESTART,
265+ tooltip=self.ui.RESTART_TOOLTIP)
266
267 def test_on_files_start_error(self):
268 """The files service could not be started."""
269@@ -2405,3 +2451,21 @@
270 """The devices_button widget has the proper name."""
271 self.assertEqual(self.ui.devices_button.get_name(),
272 self.ui.DEVICES_BUTTON_NAME)
273+
274+ def test_devices_button_tooltip(self):
275+ """The devices button widget has the proper tooltip."""
276+ self.assertTrue(self.ui.devices_button.get_has_tooltip())
277+ self.assertEqual(self.ui.devices_button.get_tooltip_text(),
278+ self.ui.DEVICES_BUTTON_TOOLTIP)
279+
280+ def test_dashboard_button_tooltip(self):
281+ """The dashboard button widget has the proper tooltip."""
282+ self.assertTrue(self.ui.dashboard_button.get_has_tooltip())
283+ self.assertEqual(self.ui.dashboard_button.get_tooltip_text(),
284+ self.ui.DASHBOARD_BUTTON_TOOLTIP)
285+
286+ def test_volumes_button_tooltip(self):
287+ """The volumes button widget has the proper tooltip."""
288+ self.assertTrue(self.ui.volumes_button.get_has_tooltip())
289+ self.assertEqual(self.ui.volumes_button.get_tooltip_text(),
290+ self.ui.VOLUMES_BUTTON_TOOLTIP)

Subscribers

People subscribed via source and target branches