Merge lp:~gary-lasker/software-center/tos_buy_button_fix_lp961216 into lp:software-center

Proposed by Gary Lasker
Status: Merged
Merged at revision: 2910
Proposed branch: lp:~gary-lasker/software-center/tos_buy_button_fix_lp961216
Merge into: lp:software-center
Diff against target: 102 lines (+32/-5)
4 files modified
softwarecenter/ui/gtk3/panes/availablepane.py (+11/-0)
softwarecenter/ui/gtk3/views/purchaseview.py (+4/-0)
softwarecenter/ui/gtk3/widgets/apptreeview.py (+16/-4)
softwarecenter/ui/gtk3/widgets/cellrenderers.py (+1/-1)
To merge this branch: bzr merge lp:~gary-lasker/software-center/tos_buy_button_fix_lp961216
Reviewer Review Type Date Requested Status
Michael Vogt Approve
Gary Lasker (community) Needs Resubmitting
Review via email: mp+98754@code.launchpad.net

Description of the change

This branch fixes bug 961216, where the "Buy" button on the details page stays insensitive after declining the ToS dialog. See the bug for more details and steps to reproduce.

The same problem for the "Buy" button in the list view is also fixed now.

Thanks Mr. Reviewer Man

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

Thanks for this branch.

I think we need to add a comment here to explain why we do something different here than in the other
surrounding code. Or even better move the code that make the button sensitive again closer
to where the purchase was declined.

Looking at the bug there is also the case that clicking on "buy" in the listview will make the button
no longer respond.

Revision history for this message
Gary Lasker (gary-lasker) wrote :

Yes, as I said in my initial comment, this MP is for the details page case. I have the code in progress to fix the list view case, and that would have followed today with a second MP.

This one is a very small change as I was trying to make a "surgical" fix with minimal code churn at this late date in the cycle, and in fact the fix does the trick fine with no regressions. But if there is an alternate and cleaner approach that will take care of both the listview and detailsview cases, I'll find that now and implement it.

Thanks mvo!

Revision history for this message
Gary Lasker (gary-lasker) :
review: Needs Fixing
2909. By Gary Lasker

REFACTOR: reimplement the opt-out status using a signal, not working for the list view case yet

2910. By Gary Lasker

make it work for the list view case also, and remove debug statements

2911. By Gary Lasker

remove a remaining debug statement, woops

2912. By Gary Lasker

pep8 ftw

Revision history for this message
Gary Lasker (gary-lasker) wrote :

Hi mvo! Ok, I reimplemented using a signal that is used for both the details view and the list view cases. Both work correctly now. Please re-review and let me know if anything else needs changing.

Thanks again!

review: Needs Resubmitting
Revision history for this message
Michael Vogt (mvo) wrote :

Hello Gary, thanks for your work on this branch. This is fine and covers all cases and the code is
nice and elegant.

review: Approve
Revision history for this message
Gary Lasker (gary-lasker) wrote :

Thanks Michael. :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'softwarecenter/ui/gtk3/panes/availablepane.py'
--- softwarecenter/ui/gtk3/panes/availablepane.py 2012-03-19 21:01:41 +0000
+++ softwarecenter/ui/gtk3/panes/availablepane.py 2012-03-22 23:35:23 +0000
@@ -149,6 +149,8 @@
149 self.on_purchase_failed)149 self.on_purchase_failed)
150 self.purchase_view.connect("purchase-cancelled-by-user",150 self.purchase_view.connect("purchase-cancelled-by-user",
151 self.on_purchase_cancelled_by_user)151 self.on_purchase_cancelled_by_user)
152 self.purchase_view.connect("terms-of-service-declined",
153 self.on_terms_of_service_declined)
152 self.purchase_view.connect("purchase-needs-spinner",154 self.purchase_view.connect("purchase-needs-spinner",
153 self.on_purchase_needs_spinner)155 self.on_purchase_needs_spinner)
154156
@@ -260,6 +262,15 @@
260 def on_purchase_cancelled_by_user(self, widget):262 def on_purchase_cancelled_by_user(self, widget):
261 self._return_to_appdetails_view()263 self._return_to_appdetails_view()
262264
265 def on_terms_of_service_declined(self, widget):
266 """ The Terms of Service dialog was declined by the user, so we just
267 reset the purchase button in case they want another chance
268 """
269 if self.is_app_details_view_showing():
270 self.app_details_view.pkg_statusbar.button.set_sensitive(True)
271 elif self.is_applist_view_showing():
272 self.app_view.tree_view.reset_action_button()
273
263 def _return_to_appdetails_view(self):274 def _return_to_appdetails_view(self):
264 vm = get_viewmanager()275 vm = get_viewmanager()
265 vm.nav_back()276 vm.nav_back()
266277
=== modified file 'softwarecenter/ui/gtk3/views/purchaseview.py'
--- softwarecenter/ui/gtk3/views/purchaseview.py 2012-03-19 14:38:10 +0000
+++ softwarecenter/ui/gtk3/views/purchaseview.py 2012-03-22 23:35:23 +0000
@@ -93,6 +93,9 @@
93 'purchase-cancelled-by-user': (GObject.SignalFlags.RUN_LAST,93 'purchase-cancelled-by-user': (GObject.SignalFlags.RUN_LAST,
94 None,94 None,
95 ()),95 ()),
96 'terms-of-service-declined': (GObject.SignalFlags.RUN_LAST,
97 None,
98 ()),
96 'purchase-needs-spinner': (GObject.SignalFlags.RUN_LAST,99 'purchase-needs-spinner': (GObject.SignalFlags.RUN_LAST,
97 None,100 None,
98 (bool, )),101 (bool, )),
@@ -145,6 +148,7 @@
145 for the item specified148 for the item specified
146 """149 """
147 if not self._ask_for_tos_acceptance_if_needed():150 if not self._ask_for_tos_acceptance_if_needed():
151 self.emit("terms-of-service-declined")
148 return False152 return False
149153
150 self.init_view()154 self.init_view()
151155
=== modified file 'softwarecenter/ui/gtk3/widgets/apptreeview.py'
--- softwarecenter/ui/gtk3/widgets/apptreeview.py 2012-03-20 16:34:24 +0000
+++ softwarecenter/ui/gtk3/widgets/apptreeview.py 2012-03-22 23:35:23 +0000
@@ -172,6 +172,18 @@
172 def rowref_is_category(self, rowref):172 def rowref_is_category(self, rowref):
173 return isinstance(rowref, CategoryRowReference)173 return isinstance(rowref, CategoryRowReference)
174174
175 def reset_action_button(self):
176 """ Set the current row's action button sensitivity to the
177 specified value
178 """
179 if self.selected_row_renderer:
180 action_btn = self.selected_row_renderer.get_button_by_name(
181 CellButtonIDs.ACTION)
182 if action_btn:
183 action_btn.set_sensitive(True)
184 pkgname = self.db.get_pkgname(self.selected_doc)
185 self._check_remove_pkg_from_blocklist(pkgname)
186
175 def _on_realize(self, widget, tr):187 def _on_realize(self, widget, tr):
176 # connect to backend events once self is realized so handlers188 # connect to backend events once self is realized so handlers
177 # have access to the TreeView's initialised Gdk.Window189 # have access to the TreeView's initialised Gdk.Window
@@ -270,11 +282,11 @@
270 self._update_selected_row(view, tr, path)282 self._update_selected_row(view, tr, path)
271283
272 def _update_selected_row(self, view, tr, path=None):284 def _update_selected_row(self, view, tr, path=None):
273 # keep track of the currently selected row renderer for use when285 # keep track of the currently selected row renderer and associated
274 # calculating icon size and coordinate values for the Unity286 # doc for use when updating the widgets and for use with the Unity
275 # launcher integration feature287 # integration feature
276 self.selected_row_renderer = tr288 self.selected_row_renderer = tr
277 ##289 self.selected_doc = tr.application
278 sel = view.get_selection()290 sel = view.get_selection()
279 if not sel:291 if not sel:
280 return False292 return False
281293
=== modified file 'softwarecenter/ui/gtk3/widgets/cellrenderers.py'
--- softwarecenter/ui/gtk3/widgets/cellrenderers.py 2012-03-12 12:43:52 +0000
+++ softwarecenter/ui/gtk3/widgets/cellrenderers.py 2012-03-22 23:35:23 +0000
@@ -529,7 +529,7 @@
529 self.current_variant = current_var529 self.current_variant = current_var
530530
531 def is_sensitive(self):531 def is_sensitive(self):
532 return self.state == Gtk.StateFlags.INSENSITIVE532 return self.state is not Gtk.StateFlags.INSENSITIVE
533533
534 def render(self, context, cr, layout):534 def render(self, context, cr, layout):
535 if not self.visible:535 if not self.visible:

Subscribers

People subscribed via source and target branches