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
=== modified file 'debian/changelog'
--- debian/changelog 2011-08-19 19:48:18 +0000
+++ debian/changelog 2011-08-21 11:59:17 +0000
@@ -11,8 +11,18 @@
11 - gtk3 fixes11 - gtk3 fixes
12 * softwarecenter/ui/gtk3/widgets/stars.py:12 * softwarecenter/ui/gtk3/widgets/stars.py:
13 - add get_rating() to make the submit_review_gtk3.py work13 - add get_rating() to make the submit_review_gtk3.py work
14
15 [ Aaron Peachey ]
16 * softwarecenter/ui/gtk3/views/catview_gtk.py:
17 - remove 'More' button from sub-category top rated sections
18 - increase number of apps in top-rated feature frames from 8 to 12
19 - add sub category name into frame header for subcategory toprated
20 (LP: #830272)
21 * softwarecenter/ui/gtk3/views/catview_gtk.py:
22 - provide standard method for adding tiles to Flowable grid to
23 simplify repeated append code (and DRY)
1424
15 -- Michael Vogt <michael.vogt@ubuntu.com> Fri, 19 Aug 2011 14:52:03 +020025 -- Aaron Peachey <alpeachey@gmail.com> Sun, 21 Aug 2011 21:51:34 +1000
1626
17software-center (4.1.17) oneiric; urgency=low27software-center (4.1.17) oneiric; urgency=low
1828
1929
=== modified file 'softwarecenter/ui/gtk3/views/catview_gtk.py'
--- softwarecenter/ui/gtk3/views/catview_gtk.py 2011-08-18 18:36:55 +0000
+++ softwarecenter/ui/gtk3/views/catview_gtk.py 2011-08-21 11:59:17 +0000
@@ -143,6 +143,25 @@
143 self.connect("size-allocate", self.on_size_allocate)143 self.connect("size-allocate", self.on_size_allocate)
144 return144 return
145145
146 def _add_tiles_to_flowgrid(self, docs, flowgrid, qty):
147 '''Adds application tiles to a FlowableGrid:
148 docs = xapian documents (apps)
149 flowgrid = the FlowableGrid to add tiles to
150 qty = number of tiles to add from start of doc range'''
151 if len(docs) < qty:
152 qty = len(docs)
153
154 for doc in docs[0:qty]:
155 name = self.helper.get_appname(doc)
156 icon_pb = self.helper.get_icon_at_size(doc, 48, 48)
157 stats = self.helper.get_review_stats(doc)
158 categories = self.helper.get_categories(doc)
159 tile = FeaturedTile(name, icon_pb, stats, categories)
160 tile.connect('clicked', self.on_app_clicked,
161 self.helper.get_application(doc))
162 flowgrid.add_child(tile)
163 return
164
146 def on_size_allocate(self, widget, _):165 def on_size_allocate(self, widget, _):
147 a = widget.get_allocation()166 a = widget.get_allocation()
148 prev = self._prev_alloc167 prev = self._prev_alloc
@@ -345,7 +364,7 @@
345 enq = AppEnquire(self.cache, self.db)364 enq = AppEnquire(self.cache, self.db)
346 app_filter = AppFilter(self.db, self.cache)365 app_filter = AppFilter(self.db, self.cache)
347 enq.set_query(toprated_cat.query,366 enq.set_query(toprated_cat.query,
348 limit=8,367 limit=TOP_RATED_CAROUSEL_LIMIT,
349 sortmode=toprated_cat.sortmode,368 sortmode=toprated_cat.sortmode,
350 filter=app_filter,369 filter=app_filter,
351 nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE,370 nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE,
@@ -360,16 +379,10 @@
360 frame.add(self.toprated)379 frame.add(self.toprated)
361 self.right_column.pack_start(frame, True, True, 0)380 self.right_column.pack_start(frame, True, True, 0)
362381
363 helper = AppPropertiesHelper(self.db, self.cache, self.icons)382 self.helper = AppPropertiesHelper(self.db, self.cache, self.icons)
364 for doc in enq.get_documents():383 docs = enq.get_documents()
365 name = helper.get_appname(doc)384 self._add_tiles_to_flowgrid(docs, self.toprated, TOP_RATED_CAROUSEL_LIMIT)
366 icon_pb = helper.get_icon_at_size(doc, 48, 48)385 return
367 stats = helper.get_review_stats(doc)
368 categories = helper.get_categories(doc)
369 tile = FeaturedTile(name, icon_pb, stats, categories)
370 tile.connect('clicked', self.on_app_clicked,
371 helper.get_application(doc))
372 self.toprated.add_child(tile)
373 386
374387
375 def _append_featured(self):388 def _append_featured(self):
@@ -395,16 +408,9 @@
395 frame.add(self.featured)408 frame.add(self.featured)
396 self.right_column.pack_start(frame, True, True, 0)409 self.right_column.pack_start(frame, True, True, 0)
397410
398 helper = AppPropertiesHelper(self.db, self.cache, self.icons)411 self.helper = AppPropertiesHelper(self.db, self.cache, self.icons)
399 for doc in enq.get_documents():412 docs = enq.get_documents()
400 name = helper.get_appname(doc)413 self._add_tiles_to_flowgrid(docs, self.featured, 8)
401 icon_pb = helper.get_icon_at_size(doc, 48, 48)
402 stats = helper.get_review_stats(doc)
403 categories = helper.get_categories(doc)
404 tile = FeaturedTile(name, icon_pb, stats, categories)
405 tile.connect('clicked', self.on_app_clicked,
406 helper.get_application(doc))
407 self.featured.add_child(tile)
408 return414 return
409415
410 def _append_recommendations(self):416 def _append_recommendations(self):
@@ -426,16 +432,9 @@
426 frame.header_implements_more_button()432 frame.header_implements_more_button()
427 self.right_column.pack_start(frame, True, True, 0)433 self.right_column.pack_start(frame, True, True, 0)
428434
429 helper = AppPropertiesHelper(self.db, self.cache, self.icons)435 self.helper = AppPropertiesHelper(self.db, self.cache, self.icons)
430 for doc in enq.get_documents():436 docs = enq.get_documents()
431 name = helper.get_appname(doc)437 self._add_tiles_to_flowgrid(docs, self.featured, 12)
432 icon_pb = helper.get_icon_at_size(doc, 48, 48)
433 stats = helper.get_review_stats(doc)
434 categories = helper.get_categories(doc)
435 tile = FeaturedTile(name, icon_pb, stats, categories)
436 tile.connect('clicked', self.on_app_clicked,
437 helper.get_application(doc))
438 self.featured.add_child(tile)
439 return438 return
440439
441 def _append_appcount(self, supported_only=False):440 def _append_appcount(self, supported_only=False):
@@ -514,27 +513,14 @@
514 frame = FramedHeaderBox()513 frame = FramedHeaderBox()
515 # set x/y-alignment and x/y-expand514 # set x/y-alignment and x/y-expand
516 #~ frame.set(0.5, 0.0, 1.0, 1.0)515 #~ frame.set(0.5, 0.0, 1.0, 1.0)
517 frame.set_header_label(_("Top Rated"))516 frame.set_header_label(_('Top Rated %s' % self.header))
518 frame.header_implements_more_button()
519 frame.pack_start(self.toprated, True, True, 0)517 frame.pack_start(self.toprated, True, True, 0)
520 # append the departments section to the page518 # append the departments section to the page
521 self.vbox.pack_start(frame, False, True, 0)519 self.vbox.pack_start(frame, False, True, 0)
522 self.toprated_frame = frame520 self.toprated_frame = frame
523 else:521 else:
524 self.toprated.remove_all()522 self.toprated.remove_all()
525523 self.toprated_frame.set_header_label(_('Top Rated %s' % self.header))
526 # ensure that we update the more button
527 cat_with_toprated_search = copy.copy(category)
528 cat_with_toprated_search.sortmode = SortMethods.BY_TOP_RATED
529 cat_with_toprated_search.item_limit = TOP_RATED_CAROUSEL_LIMIT
530 # disconnect old handler (if there is one)
531 try:
532 self.toprated_frame.more.disconnect_by_func(
533 self.on_category_clicked)
534 except TypeError:
535 pass
536 self.toprated_frame.more.connect(
537 'clicked', self.on_category_clicked, cat_with_toprated_search)
538524
539 # and fill the toprated grid525 # and fill the toprated grid
540 self.enquire.set_query(category.query,526 self.enquire.set_query(category.query,
@@ -544,15 +530,8 @@
544 nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE,530 nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE,
545 nonblocking_load=False)531 nonblocking_load=False)
546532
547 for doc in self.enquire.get_documents()[0:8]:533 docs = self.enquire.get_documents()
548 name = self.helper.get_appname(doc)534 self._add_tiles_to_flowgrid(docs, self.toprated, TOP_RATED_CAROUSEL_LIMIT)
549 icon_pb = self.helper.get_icon_at_size(doc, 48, 48)
550 stats = self.helper.get_review_stats(doc)
551 categories = self.helper.get_categories(doc)
552 tile = FeaturedTile(name, icon_pb, stats, categories)
553 tile.connect('clicked', self.on_app_clicked,
554 self.helper.get_application(doc))
555 self.toprated.add_child(tile)
556 return535 return
557536
558 def _append_subcat_departments(self, root_category, num_items):537 def _append_subcat_departments(self, root_category, num_items):

Subscribers

People subscribed via source and target branches