def _on_resource_request_starting(self, view, frame, res, req, resp):
     lang = get_language()
     if lang:
         message = req.get_message()
         if message:
             headers = message.get_property("request-headers")
             headers.append("Accept-Language", lang)
Beispiel #2
0
 def query_exhibits(self):
     cmd = self.HELPER_CMD[:]
     cmd.append("exhibits")
     cmd.append(get_language())
     spawner = SpawnHelper()
     spawner.connect("data-available", self._on_exhibits_data_available)
     spawner.connect("error", lambda spawner, err: self.emit("error", err))
     spawner.run(cmd)
 def buy_app(self):
     """ initiate the purchase transaction """
     lang = get_language()
     distro = self.distro.get_codename()
     url = self.distro.PURCHASE_APP_URL % (lang, distro, urlencode({
                 'archive_id' : self.appdetails.ppaname, 
                 'arch' : get_current_arch() ,
                 }))
     
     self.emit("purchase-requested", self.app, url)
Beispiel #4
0
 def _query_available(self, series_name, arch_tag, for_qa):
     language = get_language()
     if not series_name:
         series_name = self.distro.get_codename()
     if not arch_tag:
         arch_tag = get_current_arch()
     # build the command
     cmd = self.HELPER_CMD[:]
     if for_qa:
         cmd.append("available_apps_qa")
     else:
         cmd.append("available_apps")
     cmd += [language,
             series_name,
             arch_tag,
             ]
     spawner = SpawnHelper()
     spawner.connect("data-available", self._on_query_available_data)
     spawner.connect("error", lambda spawner, err: self.emit("error", err))
     spawner.run(cmd)
Beispiel #5
0
    def __init__(self, cache, db, distro=None):
        self.cache = cache
        self.db = db
        self.distro = distro
        if not self.distro:
            self.distro = softwarecenter.distro.get_distro()
        fname = "%s_%s" % (uri_to_filename(self.distro.REVIEWS_SERVER),
                           "review-stats-pkgnames.p")
        self.REVIEW_STATS_CACHE_FILE = os.path.join(SOFTWARE_CENTER_CACHE_DIR,
                                                    fname)
        self.REVIEW_STATS_BSDDB_FILE = "%s__%s.%s.db" % (
            self.REVIEW_STATS_CACHE_FILE, 
            bdb.DB_VERSION_MAJOR, 
            bdb.DB_VERSION_MINOR)

        self.language = get_language()
        if os.path.exists(self.REVIEW_STATS_CACHE_FILE):
            try:
                self.REVIEW_STATS_CACHE = pickle.load(open(self.REVIEW_STATS_CACHE_FILE))
                self._cache_version_old = self._missing_histogram_in_cache()
            except:
                LOG.exception("review stats cache load failure")
                os.rename(self.REVIEW_STATS_CACHE_FILE, self.REVIEW_STATS_CACHE_FILE+".fail")
Beispiel #6
0
    def configure_reviews_ui(self):
        """ this needs to be called after add_reviews, it will actually
            show the reviews
        """
        #print 'Review count: %s' % len(self.reviews)

        try:
            self.install_first_label.hide()
        except AttributeError:
            pass
        
        self._clear_vbox(self.vbox)

        # network sensitive stuff, only show write_review if connected,
        # add msg about offline cache usage if offline
        is_connected = network_state_is_connected()
        self.no_network_msg = self._add_no_network_connection_msg()

        # only show new_review for installed stuff
        is_installed = (self._parent.app_details and
                        self._parent.app_details.pkg_state == PkgStates.INSTALLED)

        # show/hide new review button
        if is_installed:
            self.new_review.show()
        else:
            self.new_review.hide()
            # if there are no reviews, the install to review text appears 
            # where the reviews usually are (LP #823255)
            if self.reviews:
                self._install_to_review()

        # always hide spinner and call _fill (fine if there is nothing to do)
        self.hide_spinner()
        self._fill()
        self.vbox.show_all()

        if self.reviews:
            # adjust label if we have reviews
            if self._any_reviews_current_user():
                self.new_review.hide()
            else:
                self.new_review.set_label(_("Write your own review"))
        else:
            # no reviews, either offer to write one or show "none"
            if is_installed and is_connected:
                self._be_the_first_to_review()
            else:
                self.vbox.pack_start(NoReviewYet(), True, True, 0)

        # if there are no reviews, try english as fallback
        language = get_language()
        if (len(self.reviews) == 0 and
            self.global_review_stats and
            self.global_review_stats.ratings_total > 0 and
            language != "en"):
            button = Gtk.Button(_("Show reviews in english"))
            button.connect(
                "clicked", self._on_different_review_language_clicked)
            button.show()
            self.vbox.pack_start(button, True, True, 0)                

        # aaronp: removed check to see if the length of reviews is divisible by
        # the batch size to allow proper fixing of LP: #794060 as when a review
        # is submitted and appears in the list, the pagination will break this
        # check and make it unreliable
        # if self.reviews and len(self.reviews) % REVIEWS_BATCH_PAGE_SIZE == 0:
        if self.reviews:
            button = Gtk.Button(_("Check for more reviews"))
            button.connect("clicked", self._on_more_reviews_clicked)
            button.show()
            self.vbox.pack_start(button, False, False, 0)

        # always run this here to make update the current ui based on the
        # network state
        self._on_network_state_change()
        return