~didrocks/software-center/fix-never-visible-tech-items

« back to all changes in this revision

Viewing changes to softwarecenter/view/catview_gtk.py

merged the reviews branch into trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
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))
36
32
 
37
33
# as per spec transition timeout should be 15000 (15 seconds)
38
34
CAROUSEL_TRANSITION_TIMEOUT =    15000
198
194
        app = btn.app
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))
204
200
        return False
205
201
 
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)
455
451
 
456
452
        for cat in sorted_cats:
457
 
            if cat.untranslated_name not in ('Featured',
458
 
                                             u"What\u2019s New"):
 
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))
519
514
 
520
515
        # sections
521
516
        self.departments = None
522
 
        self.build(desktopdir)
523
517
        return
524
518
 
525
519
    def _on_allocate(self, widget, allocation):
614
608
        self._build_subcat_view(root_category, num_items)
615
609
        return
616
610
 
617
 
    def build(self, desktopdir):
618
 
        self.in_subsection = True
619
 
        self.set_subcategory(self.root_category)
620
 
        return
 
611
    #def build(self, desktopdir):
 
612
        #self.in_subsection = True
 
613
        #self.set_subcategory(self.root_category)
 
614
        #return
621
615
 
622
616
 
623
617
class CarouselView(mkit.FramedSection):
711
705
            return
712
706
 
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)
718
712
 
973
967
class SubcategoryButton(mkit.VLinkButton):
974
968
 
975
969
    ICON_SIZE = 48
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
978
972
 
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)
984
979
        return
985
980
 
986
981
 
987
982
class CarouselPoster(mkit.VLinkButton):
988
983
 
 
984
    WIDTH = 11*mkit.EM
 
985
    HEIGHT = 10*mkit.EM
 
986
 
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)
991
989
 
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)
994
993
 
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)
998
996
 
999
997
        self.app = None
1000
998
        self._target_icon_size = icon_size
1001
999
 
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)
1005
1002
 
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()
1009
1006
        return
1010
1007
 
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)
1016
 
        return
1017
 
 
1018
1008
    def set_application(self, app):
1019
1009
        self.app = app
1020
1010
 
1031
1021
 
1032
1022
        if not self.image.window:
1033
1023
            self.box.pack_start(self.image, False)
 
1024
            self.box.reorder_child(self.image, 0)
1034
1025
            self.image.show()
1035
1026
        return
1036
1027
 
1172
1163
        #print max_w, self.vbox.allocation.width
1173
1164
        w = 0
1174
1165
        for i in range(int(n_pages)):
1175
 
            w += CAROUSEL_PAGING_DOT_SIZE + mkit.SPACING_MED
 
1166
            w += PagingDot.DOT_SIZE + mkit.SPACING_MED
1176
1167
 
1177
1168
            if w > max_w:
1178
1169
                rowbox = gtk.HBox(spacing=mkit.SPACING_MED)
1180
1171
                row.add(rowbox)
1181
1172
 
1182
1173
                self.vbox.pack_start(row, expand=True)
1183
 
                w = CAROUSEL_PAGING_DOT_SIZE + mkit.SPACING_MED
 
1174
                w = PagingDot.DOT_SIZE + mkit.SPACING_MED
1184
1175
 
1185
1176
            dot = PagingDot(i)
1186
1177
            rowbox.pack_start(dot, False)
1215
1206
 
1216
1207
class PagingDot(mkit.LinkButton):
1217
1208
 
 
1209
    DOT_SIZE =       max(8, int(0.6*mkit.EM+0.5))
 
1210
 
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
1223
1216
 
1228
1221
        return
1229
1222
 
1230
1223
    def calc_width(self):
1231
 
        return CAROUSEL_PAGING_DOT_SIZE
 
1224
        return self.DOT_SIZE
1232
1225
 
1233
1226
    def draw(self, cr, a, expose_area, alpha):
1234
1227
        cr.save()