Ejemplo n.º 1
0
 def test_langcode_to_name(self):
     self.assertEqual(langcode_to_name("de"), "German")
Ejemplo n.º 2
0
    def __init__(self, parent):
        Gtk.VBox.__init__(self)
        self.set_spacing(12)
        self.logged_in_person = get_person_from_config()

        self._parent = parent
        # this is a list of review data (softwarecenter.backend.reviews.Review)
        self.reviews = []
        # global review stats, this includes ratings in different languages
        self.global_review_stats = None
        # usefulness stuff
        self.useful_votes = UsefulnessCache()
        self.logged_in_person = None

        # add header label
        label = Gtk.Label()
        label.set_markup('<big><b>%s</b></big>' % _("Reviews"))
        label.set_padding(6, 6)
        label.set_use_markup(True)
        label.set_alignment(0, 0.5)
        self.header = Gtk.HBox()
        self.header.pack_start(label, False, False, 0)

        # header
        self.header.set_spacing(StockEms.MEDIUM)

        # review sort method
        self.sort_combo = Gtk.ComboBoxText()
        self._current_sort = 0
        for sort_method in ReviewSortMethods.REVIEW_SORT_LIST_ENTRIES:
            self.sort_combo.append_text(_(sort_method))
        self.sort_combo.set_active(self._current_sort)
        self.sort_combo.connect('changed', self._on_sort_method_changed)
        self.header.pack_end(self.sort_combo, False, False, 3)

        # change language
        self.review_language = Gtk.ComboBox()
        cell = Gtk.CellRendererText()
        self.review_language.pack_start(cell, True)
        self.review_language.add_attribute(cell, "text", COL_LANGNAME)
        self.review_language_model = Gtk.ListStore(str, str)
        for lang in get_languages():
            self.review_language_model.append((langcode_to_name(lang), lang))
        self.review_language_model.append((_('Any language'), 'any'))
        self.review_language.set_model(self.review_language_model)
        self.review_language.set_active(0)
        self.review_language.connect(
            "changed", self._on_different_review_language_clicked)
        self.header.pack_end(self.review_language, False, True, 0)

        self.pack_start(self.header, False, False, 0)
        self.reviews_info_hbox = Gtk.HBox()
        self.new_review = Link(_('Write your own review'))
        self.new_review.connect('clicked', lambda w: self.emit('new-review'))
        self.reviews_info_hbox.pack_start(self.new_review, False, False,
                                          StockEms.SMALL)
        self.pack_start(self.reviews_info_hbox, True, True, 0)
        # this is where the reviews end up
        self.vbox = Gtk.VBox()
        self.vbox.set_spacing(24)
        self.pack_end(self.vbox, True, True, 0)

        # ensure network state updates
        self.no_network_msg = None
        watcher = get_network_watcher()
        watcher.connect("changed",
                        lambda w, s: self._on_network_state_change())

        self.show_all()