29
29
CAROUSEL_MAX_POSTER_COUNT = 8
30
30
CAROUSEL_MIN_POSTER_COUNT = 1
31
31
CAROUSEL_ICON_SIZE = 4*mkit.EM
32
#CAROUSEL_POSTER_CORNER_RADIUS = int(0.8*mkit.EM)
33
CAROUSEL_POSTER_MIN_WIDTH = 11*mkit.EM
34
CAROUSEL_POSTER_MIN_HEIGHT = min(64, 4*mkit.EM) + 5*mkit.EM
35
CAROUSEL_PAGING_DOT_SIZE = max(8, int(0.6*mkit.EM+0.5))
37
33
# as per spec transition timeout should be 15000 (15 seconds)
38
34
CAROUSEL_TRANSITION_TIMEOUT = 15000
199
195
appname = app[AppStore.COL_APP_NAME]
200
196
pkgname = app[AppStore.COL_PKGNAME]
201
popcon = app[AppStore.COL_POPCON]
202
self.emit("application-selected", Application(appname, pkgname, "", popcon))
203
self.emit("application-activated", Application(appname, pkgname, "", popcon))
197
rating = app[AppStore.COL_RATING]
198
self.emit("application-selected", Application(appname, pkgname, "", rating))
199
self.emit("application-activated", Application(appname, pkgname, "", rating))
206
202
def _on_category_clicked(self, cat_btn, cat):
336
332
# all into one label to make it more i18n friendly
337
333
linkbutton = mkit.HLinkButton(label)
338
334
linkbutton.set_underline(True)
339
linkbutton.set_subdued(True)
335
#linkbutton.set_subdued(True)
340
336
self.hbox.pack_start(linkbutton, False, False)
341
337
# Translators: full sentence will be: Welcome back! There is/are %(len)i new recommendation/s for you.
342
338
self.hbox.pack_start(gtk.Label(_("for you.")), False, False)
454
450
sorted_cats = categories_sorted_by_name(self.categories)
456
452
for cat in sorted_cats:
457
if cat.untranslated_name not in ('Featured',
453
if 'carousel-only' not in cat.flags:
459
454
#enquirer.set_query(cat.query)
460
455
## limiting the size here does not make it faster
461
456
#matches = enquirer.get_mset(0, len(self.db))
614
608
self._build_subcat_view(root_category, num_items)
617
def build(self, desktopdir):
618
self.in_subsection = True
619
self.set_subcategory(self.root_category)
611
#def build(self, desktopdir):
612
#self.in_subsection = True
613
#self.set_subcategory(self.root_category)
623
617
class CarouselView(mkit.FramedSection):
713
707
# number of posters we should have given available space
714
n = width / CAROUSEL_POSTER_MIN_WIDTH
715
n = (width - n*self.hbox.get_spacing()) / CAROUSEL_POSTER_MIN_WIDTH
708
n = width / CarouselPoster.WIDTH
709
n = (width - n*self.hbox.get_spacing()) / CarouselPoster.WIDTH
716
710
n = max(CAROUSEL_MIN_POSTER_COUNT, n)
717
711
n = min(CAROUSEL_MAX_POSTER_COUNT, n)
973
967
class SubcategoryButton(mkit.VLinkButton):
976
MAX_WIDTH = None#9*mkit.EM
977
MAX_HEIGHT = None#11*mkit.EM
970
MAX_WIDTH = 12*mkit.EM
971
MAX_HEIGHT = 9*mkit.EM
979
973
def __init__(self, markup, icon_name, icons):
980
974
mkit.VLinkButton.__init__(self, markup, icon_name, self.ICON_SIZE, icons)
981
self.set_border_width(mkit.BORDER_WIDTH_MED)
982
self.set_size_request(self.get_size_request()[0],
983
self.MAX_HEIGHT or self.get_size_request()[1])
975
self.set_border_width(mkit.BORDER_WIDTH_SMALL)
976
self.set_max_width(self.MAX_WIDTH)
977
#self.set_max_width(self.MAX_HEIGHT)
978
self.box.set_size_request(self.MAX_WIDTH, self.MAX_HEIGHT)
987
982
class CarouselPoster(mkit.VLinkButton):
989
987
def __init__(self, markup='None', icon_name='None', icon_size=48, icons=None):
990
988
mkit.VLinkButton.__init__(self, markup, icon_name, icon_size, icons)
992
self.set_border_width(mkit.BORDER_WIDTH_LARGE)
990
self.set_border_width(mkit.BORDER_WIDTH_SMALL)
993
991
self.set_internal_spacing(mkit.SPACING_SMALL)
992
self.box.set_size_request(self.WIDTH, self.HEIGHT)
995
994
self.label.set_justify(gtk.JUSTIFY_CENTER)
996
995
self.image.set_size_request(icon_size, icon_size)
997
self.box.set_size_request(-1, CAROUSEL_POSTER_MIN_HEIGHT)
1000
998
self._target_icon_size = icon_size
1002
1000
# we inhibit the native gtk drawing for both the Image and Label
1003
1001
self.connect('expose-event', lambda w, e: True)
1004
self.connect('size-allocate', self._on_allocate)
1006
1003
# a11y for poster
1007
# self.set_property("can-focus", True)
1004
self.set_property("can-focus", True)
1008
1005
self.a11y = self.get_accessible()
1011
def _on_allocate(self, widget, allocation):
1012
ia = self.label.allocation # label allocation
1013
layout = self.label.get_layout()
1014
layout.set_width(ia.width*pango.SCALE)
1015
layout.set_wrap(pango.WRAP_WORD)
1018
1008
def set_application(self, app):
1216
1207
class PagingDot(mkit.LinkButton):
1209
DOT_SIZE = max(8, int(0.6*mkit.EM+0.5))
1218
1211
def __init__(self, page_number):
1219
1212
mkit.LinkButton.__init__(self, None, None, None)
1220
self.set_size_request(-1, CAROUSEL_PAGING_DOT_SIZE)
1213
self.set_size_request(-1, self.DOT_SIZE)
1221
1214
self.is_selected = False
1222
1215
self.page_number = page_number