Merge lp:~aaronp/software-center/top-rated-gtk3-fixes into lp:software-center

Proposed by Aaron Peachey on 2011-08-21
Status: Merged
Merged at revision: 2159
Proposed branch: lp:~aaronp/software-center/top-rated-gtk3-fixes
Merge into: lp:software-center
Diff against target: 171 lines (+45/-56)
2 files modified
debian/changelog (+11/-1)
softwarecenter/ui/gtk3/views/catview_gtk.py (+34/-55)
To merge this branch: bzr merge lp:~aaronp/software-center/top-rated-gtk3-fixes
Reviewer Review Type Date Requested Status
Michael Vogt 2011-08-21 Approve on 2011-08-22
Review via email: mp+72332@code.launchpad.net

Description of the change

1. Fixes bug LP: #830272 for gtk3 - remove 'More' from top rated screens in subcategories and increase number of tiles to 12.
2. Simplify code in catview_gtk.py for gtk3 by providing a single method to add tiles to FlowableGrids rather than repeating the same code in all append_xxxxxx methods.

To post a comment you must log in.
Michael Vogt (mvo) wrote :

Thanks, I love the _add_tiles_to_flowgrid() fix!

I renamed qty to amount, I'm not a native speaker, but it feels a tiny bit more readable this way (and used min() while I was at it).

In the code:
+ frame.set_header_label(_('Top Rated %s' % self.header))
this part will cause issues with i18n. it needs to be
set_header_label(_('Top Rated %s') % self.header)
(not the slightly different parenthesis).

With the later, it will translate into e.g. "Superbewertung %s" and then the header is added.

When the parentheses are different it will first add the header and then try to translate. But that will fail as in gettext it expectes the "%s" in the string and will not find a match if that is not there (the string it will search for will be something like "Top Rated Internet" but the gettext catalogue only has "Top Rated %s").

I fixed that tiny issue during the merge.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2011-08-19 19:48:18 +0000
3+++ debian/changelog 2011-08-21 11:59:17 +0000
4@@ -11,8 +11,18 @@
5 - gtk3 fixes
6 * softwarecenter/ui/gtk3/widgets/stars.py:
7 - add get_rating() to make the submit_review_gtk3.py work
8+
9+ [ Aaron Peachey ]
10+ * softwarecenter/ui/gtk3/views/catview_gtk.py:
11+ - remove 'More' button from sub-category top rated sections
12+ - increase number of apps in top-rated feature frames from 8 to 12
13+ - add sub category name into frame header for subcategory toprated
14+ (LP: #830272)
15+ * softwarecenter/ui/gtk3/views/catview_gtk.py:
16+ - provide standard method for adding tiles to Flowable grid to
17+ simplify repeated append code (and DRY)
18
19- -- Michael Vogt <michael.vogt@ubuntu.com> Fri, 19 Aug 2011 14:52:03 +0200
20+ -- Aaron Peachey <alpeachey@gmail.com> Sun, 21 Aug 2011 21:51:34 +1000
21
22 software-center (4.1.17) oneiric; urgency=low
23
24
25=== modified file 'softwarecenter/ui/gtk3/views/catview_gtk.py'
26--- softwarecenter/ui/gtk3/views/catview_gtk.py 2011-08-18 18:36:55 +0000
27+++ softwarecenter/ui/gtk3/views/catview_gtk.py 2011-08-21 11:59:17 +0000
28@@ -143,6 +143,25 @@
29 self.connect("size-allocate", self.on_size_allocate)
30 return
31
32+ def _add_tiles_to_flowgrid(self, docs, flowgrid, qty):
33+ '''Adds application tiles to a FlowableGrid:
34+ docs = xapian documents (apps)
35+ flowgrid = the FlowableGrid to add tiles to
36+ qty = number of tiles to add from start of doc range'''
37+ if len(docs) < qty:
38+ qty = len(docs)
39+
40+ for doc in docs[0:qty]:
41+ name = self.helper.get_appname(doc)
42+ icon_pb = self.helper.get_icon_at_size(doc, 48, 48)
43+ stats = self.helper.get_review_stats(doc)
44+ categories = self.helper.get_categories(doc)
45+ tile = FeaturedTile(name, icon_pb, stats, categories)
46+ tile.connect('clicked', self.on_app_clicked,
47+ self.helper.get_application(doc))
48+ flowgrid.add_child(tile)
49+ return
50+
51 def on_size_allocate(self, widget, _):
52 a = widget.get_allocation()
53 prev = self._prev_alloc
54@@ -345,7 +364,7 @@
55 enq = AppEnquire(self.cache, self.db)
56 app_filter = AppFilter(self.db, self.cache)
57 enq.set_query(toprated_cat.query,
58- limit=8,
59+ limit=TOP_RATED_CAROUSEL_LIMIT,
60 sortmode=toprated_cat.sortmode,
61 filter=app_filter,
62 nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE,
63@@ -360,16 +379,10 @@
64 frame.add(self.toprated)
65 self.right_column.pack_start(frame, True, True, 0)
66
67- helper = AppPropertiesHelper(self.db, self.cache, self.icons)
68- for doc in enq.get_documents():
69- name = helper.get_appname(doc)
70- icon_pb = helper.get_icon_at_size(doc, 48, 48)
71- stats = helper.get_review_stats(doc)
72- categories = helper.get_categories(doc)
73- tile = FeaturedTile(name, icon_pb, stats, categories)
74- tile.connect('clicked', self.on_app_clicked,
75- helper.get_application(doc))
76- self.toprated.add_child(tile)
77+ self.helper = AppPropertiesHelper(self.db, self.cache, self.icons)
78+ docs = enq.get_documents()
79+ self._add_tiles_to_flowgrid(docs, self.toprated, TOP_RATED_CAROUSEL_LIMIT)
80+ return
81
82
83 def _append_featured(self):
84@@ -395,16 +408,9 @@
85 frame.add(self.featured)
86 self.right_column.pack_start(frame, True, True, 0)
87
88- helper = AppPropertiesHelper(self.db, self.cache, self.icons)
89- for doc in enq.get_documents():
90- name = helper.get_appname(doc)
91- icon_pb = helper.get_icon_at_size(doc, 48, 48)
92- stats = helper.get_review_stats(doc)
93- categories = helper.get_categories(doc)
94- tile = FeaturedTile(name, icon_pb, stats, categories)
95- tile.connect('clicked', self.on_app_clicked,
96- helper.get_application(doc))
97- self.featured.add_child(tile)
98+ self.helper = AppPropertiesHelper(self.db, self.cache, self.icons)
99+ docs = enq.get_documents()
100+ self._add_tiles_to_flowgrid(docs, self.featured, 8)
101 return
102
103 def _append_recommendations(self):
104@@ -426,16 +432,9 @@
105 frame.header_implements_more_button()
106 self.right_column.pack_start(frame, True, True, 0)
107
108- helper = AppPropertiesHelper(self.db, self.cache, self.icons)
109- for doc in enq.get_documents():
110- name = helper.get_appname(doc)
111- icon_pb = helper.get_icon_at_size(doc, 48, 48)
112- stats = helper.get_review_stats(doc)
113- categories = helper.get_categories(doc)
114- tile = FeaturedTile(name, icon_pb, stats, categories)
115- tile.connect('clicked', self.on_app_clicked,
116- helper.get_application(doc))
117- self.featured.add_child(tile)
118+ self.helper = AppPropertiesHelper(self.db, self.cache, self.icons)
119+ docs = enq.get_documents()
120+ self._add_tiles_to_flowgrid(docs, self.featured, 12)
121 return
122
123 def _append_appcount(self, supported_only=False):
124@@ -514,27 +513,14 @@
125 frame = FramedHeaderBox()
126 # set x/y-alignment and x/y-expand
127 #~ frame.set(0.5, 0.0, 1.0, 1.0)
128- frame.set_header_label(_("Top Rated"))
129- frame.header_implements_more_button()
130+ frame.set_header_label(_('Top Rated %s' % self.header))
131 frame.pack_start(self.toprated, True, True, 0)
132 # append the departments section to the page
133 self.vbox.pack_start(frame, False, True, 0)
134 self.toprated_frame = frame
135 else:
136 self.toprated.remove_all()
137-
138- # ensure that we update the more button
139- cat_with_toprated_search = copy.copy(category)
140- cat_with_toprated_search.sortmode = SortMethods.BY_TOP_RATED
141- cat_with_toprated_search.item_limit = TOP_RATED_CAROUSEL_LIMIT
142- # disconnect old handler (if there is one)
143- try:
144- self.toprated_frame.more.disconnect_by_func(
145- self.on_category_clicked)
146- except TypeError:
147- pass
148- self.toprated_frame.more.connect(
149- 'clicked', self.on_category_clicked, cat_with_toprated_search)
150+ self.toprated_frame.set_header_label(_('Top Rated %s' % self.header))
151
152 # and fill the toprated grid
153 self.enquire.set_query(category.query,
154@@ -544,15 +530,8 @@
155 nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE,
156 nonblocking_load=False)
157
158- for doc in self.enquire.get_documents()[0:8]:
159- name = self.helper.get_appname(doc)
160- icon_pb = self.helper.get_icon_at_size(doc, 48, 48)
161- stats = self.helper.get_review_stats(doc)
162- categories = self.helper.get_categories(doc)
163- tile = FeaturedTile(name, icon_pb, stats, categories)
164- tile.connect('clicked', self.on_app_clicked,
165- self.helper.get_application(doc))
166- self.toprated.add_child(tile)
167+ docs = self.enquire.get_documents()
168+ self._add_tiles_to_flowgrid(docs, self.toprated, TOP_RATED_CAROUSEL_LIMIT)
169 return
170
171 def _append_subcat_departments(self, root_category, num_items):

Subscribers

People subscribed via source and target branches