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

Proposed by Gary Lasker on 2012-03-21
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 on 2012-03-23
Gary Lasker (community) Resubmit on 2012-03-23
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.
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.

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!

Gary Lasker (gary-lasker) :
review: Needs Fixing
2909. By Gary Lasker on 2012-03-22

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

2910. By Gary Lasker on 2012-03-22

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

2911. By Gary Lasker on 2012-03-22

remove a remaining debug statement, woops

2912. By Gary Lasker on 2012-03-22

pep8 ftw

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: Resubmit
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
Gary Lasker (gary-lasker) wrote :

Thanks Michael. :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/ui/gtk3/panes/availablepane.py'
2--- softwarecenter/ui/gtk3/panes/availablepane.py 2012-03-19 21:01:41 +0000
3+++ softwarecenter/ui/gtk3/panes/availablepane.py 2012-03-22 23:35:23 +0000
4@@ -149,6 +149,8 @@
5 self.on_purchase_failed)
6 self.purchase_view.connect("purchase-cancelled-by-user",
7 self.on_purchase_cancelled_by_user)
8+ self.purchase_view.connect("terms-of-service-declined",
9+ self.on_terms_of_service_declined)
10 self.purchase_view.connect("purchase-needs-spinner",
11 self.on_purchase_needs_spinner)
12
13@@ -260,6 +262,15 @@
14 def on_purchase_cancelled_by_user(self, widget):
15 self._return_to_appdetails_view()
16
17+ def on_terms_of_service_declined(self, widget):
18+ """ The Terms of Service dialog was declined by the user, so we just
19+ reset the purchase button in case they want another chance
20+ """
21+ if self.is_app_details_view_showing():
22+ self.app_details_view.pkg_statusbar.button.set_sensitive(True)
23+ elif self.is_applist_view_showing():
24+ self.app_view.tree_view.reset_action_button()
25+
26 def _return_to_appdetails_view(self):
27 vm = get_viewmanager()
28 vm.nav_back()
29
30=== modified file 'softwarecenter/ui/gtk3/views/purchaseview.py'
31--- softwarecenter/ui/gtk3/views/purchaseview.py 2012-03-19 14:38:10 +0000
32+++ softwarecenter/ui/gtk3/views/purchaseview.py 2012-03-22 23:35:23 +0000
33@@ -93,6 +93,9 @@
34 'purchase-cancelled-by-user': (GObject.SignalFlags.RUN_LAST,
35 None,
36 ()),
37+ 'terms-of-service-declined': (GObject.SignalFlags.RUN_LAST,
38+ None,
39+ ()),
40 'purchase-needs-spinner': (GObject.SignalFlags.RUN_LAST,
41 None,
42 (bool, )),
43@@ -145,6 +148,7 @@
44 for the item specified
45 """
46 if not self._ask_for_tos_acceptance_if_needed():
47+ self.emit("terms-of-service-declined")
48 return False
49
50 self.init_view()
51
52=== modified file 'softwarecenter/ui/gtk3/widgets/apptreeview.py'
53--- softwarecenter/ui/gtk3/widgets/apptreeview.py 2012-03-20 16:34:24 +0000
54+++ softwarecenter/ui/gtk3/widgets/apptreeview.py 2012-03-22 23:35:23 +0000
55@@ -172,6 +172,18 @@
56 def rowref_is_category(self, rowref):
57 return isinstance(rowref, CategoryRowReference)
58
59+ def reset_action_button(self):
60+ """ Set the current row's action button sensitivity to the
61+ specified value
62+ """
63+ if self.selected_row_renderer:
64+ action_btn = self.selected_row_renderer.get_button_by_name(
65+ CellButtonIDs.ACTION)
66+ if action_btn:
67+ action_btn.set_sensitive(True)
68+ pkgname = self.db.get_pkgname(self.selected_doc)
69+ self._check_remove_pkg_from_blocklist(pkgname)
70+
71 def _on_realize(self, widget, tr):
72 # connect to backend events once self is realized so handlers
73 # have access to the TreeView's initialised Gdk.Window
74@@ -270,11 +282,11 @@
75 self._update_selected_row(view, tr, path)
76
77 def _update_selected_row(self, view, tr, path=None):
78- # keep track of the currently selected row renderer for use when
79- # calculating icon size and coordinate values for the Unity
80- # launcher integration feature
81+ # keep track of the currently selected row renderer and associated
82+ # doc for use when updating the widgets and for use with the Unity
83+ # integration feature
84 self.selected_row_renderer = tr
85- ##
86+ self.selected_doc = tr.application
87 sel = view.get_selection()
88 if not sel:
89 return False
90
91=== modified file 'softwarecenter/ui/gtk3/widgets/cellrenderers.py'
92--- softwarecenter/ui/gtk3/widgets/cellrenderers.py 2012-03-12 12:43:52 +0000
93+++ softwarecenter/ui/gtk3/widgets/cellrenderers.py 2012-03-22 23:35:23 +0000
94@@ -529,7 +529,7 @@
95 self.current_variant = current_var
96
97 def is_sensitive(self):
98- return self.state == Gtk.StateFlags.INSENSITIVE
99+ return self.state is not Gtk.StateFlags.INSENSITIVE
100
101 def render(self, context, cr, layout):
102 if not self.visible:

Subscribers

People subscribed via source and target branches