~evfool/software-center/lp927426

« back to all changes in this revision

Viewing changes to softwarecenter/ui/gtk3/views/catview_gtk.py

  • Committer: Kiwinote
  • Date: 2012-03-15 22:36:31 UTC
  • mfrom: (2867 trunk)
  • mto: This revision was merged to the branch mainline in revision 2881.
  • Revision ID: kiwinote@gmail.com-20120315223631-lvea6t5sydpkkqni
mergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
from softwarecenter.ui.gtk3.widgets.containers import (
38
38
     FramedHeaderBox, FramedBox, FlowableGrid)
39
39
from softwarecenter.ui.gtk3.widgets.recommendations import (
40
 
                                        RecommendationsPanelLobby)
 
40
                                        RecommendationsPanelLobby,
 
41
                                        RecommendationsPanelCategory)
41
42
from softwarecenter.ui.gtk3.widgets.exhibits import (
42
43
                                        ExhibitBanner, FeaturedExhibit)
43
44
from softwarecenter.ui.gtk3.widgets.buttons import (LabelTile,
530
531
        self.current_category = None
531
532
        self.departments = None
532
533
        self.top_rated = None
533
 
        self.recommended_for_you = None
 
534
        self.recommended_for_you_in_cat = None
534
535
        self.appcount = None
535
536
 
536
537
        # widgetry
572
573
        self.vbox.pack_start(self.top_rated_frame, False, True, 0)
573
574
        return
574
575
 
 
576
    def _update_recommended_for_you_in_cat_content(self, category):
 
577
        if (self.recommended_for_you_in_cat and
 
578
            self.recommended_for_you_in_cat.get_parent()):
 
579
            self.vbox.remove(self.recommended_for_you_in_cat)
 
580
        self.recommended_for_you_in_cat = RecommendationsPanelCategory(
 
581
                                                                    self,
 
582
                                                                   category)
 
583
        # only show the panel in the categories view when the user
 
584
        # is opted in to the recommender service
 
585
        # FIXME: this is needed vs. a simple hide() on the widget because
 
586
        #        we do a show_all on the view
 
587
        if self.recommended_for_you_in_cat.recommender_agent.is_opted_in():
 
588
            self.vbox.pack_start(self.recommended_for_you_in_cat,
 
589
                                        False, False, 0)
 
590
 
575
591
    def _update_subcat_departments(self, category, num_items):
576
592
        self.departments.remove_all()
577
593
 
648
664
        # changing order of methods changes order that they appear in the page
649
665
        self._append_subcat_departments()
650
666
        self._append_sub_top_rated()
 
667
        # NOTE that the recommended for you in category view is built and added
 
668
        # in the _update_recommended_for_you_in_cat method (and so is not
 
669
        # needed here)
651
670
        self._append_appcount()
652
671
        self._built = True
653
672
        return
655
674
    def _update_subcat_view(self, category, num_items=0):
656
675
        num_items = self._update_subcat_departments(category, num_items)
657
676
        self._update_sub_top_rated_content(category)
 
677
        self._update_recommended_for_you_in_cat_content(category)
658
678
        self._update_appcount(num_items)
659
679
        self.show_all()
660
680
        return
698
718
def get_test_window_catview():
699
719
 
700
720
    def on_category_selected(view, cat):
701
 
        print("on_category_selected %s %s" % view, cat)
 
721
        print "on_category_selected view: ", view
 
722
        print "on_category_selected cat: ", cat
702
723
 
703
724
    from softwarecenter.db.pkginfo import get_pkg_info
704
725
    cache = get_pkg_info()
723
744
 
724
745
    # gui
725
746
    win = Gtk.Window()
726
 
    n = Gtk.Notebook()
 
747
    notebook = Gtk.Notebook()
727
748
 
728
749
    from softwarecenter.paths import APP_INSTALL_PATH
729
750
    view = LobbyViewGtk(datadir, APP_INSTALL_PATH,
732
753
 
733
754
    scroll = Gtk.ScrolledWindow()
734
755
    scroll.add(view)
735
 
    n.append_page(scroll, Gtk.Label(label="Lobby"))
 
756
    notebook.append_page(scroll, Gtk.Label(label="Lobby"))
736
757
 
737
758
    # find a cat in the LobbyView that has subcategories
738
759
    subcat_cat = None
749
770
 
750
771
    scroll = Gtk.ScrolledWindow()
751
772
    scroll.add(view)
752
 
    n.append_page(scroll, Gtk.Label(label="Subcats"))
 
773
    notebook.append_page(scroll, Gtk.Label(label="Subcats"))
753
774
 
754
 
    win.add(n)
 
775
    win.add(notebook)
755
776
    win.set_size_request(800, 800)
756
777
    win.show_all()
757
778
    win.connect('destroy', Gtk.main_quit)