コード例 #1
0
 def _build_delete_flag_ui(self,
                           current_user_reviewer,
                           delete_error=False,
                           modify_error=False):
     if delete_error:
         self._delete_ui_update('error', current_user_reviewer, 'deleting')
     elif modify_error:
         self._delete_ui_update('error', current_user_reviewer, 'modifying')
     else:
         m = '<small>%s</small>'
         if current_user_reviewer:
             self.edit = Link(m % _('Edit'))
             self.edit.set_name("subtle-label")
             self.delete = Link(m % _('Delete'))
             self.delete.set_name("subtle-label")
             self.flagbox.pack_start(self.edit, False, False, 0)
             self.flagbox.pack_start(self.delete, False, False, 0)
             self.edit.connect('clicked', self._on_modify_clicked)
             self.delete.connect('clicked', self._on_delete_clicked)
         else:
             # Translators: This link is for flagging a review as inappropriate.
             # To minimize repetition, if at all possible, keep it to a single word.
             # If your language has an obvious verb, it won't need a question mark.
             self.complain = Link(m % _('Inappropriate?'))
             self.complain.set_name("subtle-label")
             self.complain.set_sensitive(network_state_is_connected())
             self.flagbox.pack_start(self.complain, False, False, 0)
             self.complain.connect('clicked', self._on_report_abuse_clicked)
         self.flagbox.show_all()
         return
コード例 #2
0
ファイル: reviews.py プロジェクト: cs2c/AppStream
 def _build_delete_flag_ui(self, current_user_reviewer, delete_error=False,
     modify_error=False):
     if delete_error:
         self._delete_ui_update('error', current_user_reviewer, 'deleting')
     elif modify_error:
         self._delete_ui_update('error', current_user_reviewer, 'modifying')
     else:
         m = '<small>%s</small>'
         if current_user_reviewer:
             self.edit = Link(m % _('Edit'))
             self.edit.set_name("subtle-label")
             self.delete = Link(m % _('Delete'))
             self.delete.set_name("subtle-label")
             self.flagbox.pack_start(self.edit, False, False, 0)
             self.flagbox.pack_start(self.delete, False, False, 0)
             self.edit.connect('clicked', self._on_modify_clicked)
             self.delete.connect('clicked', self._on_delete_clicked)
         else:
             # Translators: This link is for flagging a review as
             # inappropriate.  To minimize repetition, if at all possible,
             # keep it to a single word.  If your language has an obvious
             # verb, it won't need a question mark.
             self.complain = Link(m % _('Inappropriate?'))
             self.complain.set_name("subtle-label")
             self.complain.set_sensitive(network_state_is_connected())
             self.flagbox.pack_start(self.complain, False, False, 0)
             self.complain.connect('clicked', self._on_report_abuse_clicked)
         self.flagbox.show_all()
コード例 #3
0
    def _update_selected_row(self, view, tr, path=None):
        sel = view.get_selection()
        if not sel:
            return False
        model, rows = sel.get_selected_rows()
        if not rows: 
            return False
        row = rows[0]
        if self.rowref_is_category(row):
            return False

        # update active app, use row-ref as argument
        self.expand_path(row)

        app = model[row][AppGenericStore.COL_ROW_DATA]

        # make sure this is not a category (LP: #848085)
        if self.rowref_is_category(app):
            return False

        action_btn = tr.get_button_by_name(
                            CellButtonIDs.ACTION)
        #if not action_btn: return False

        if self.appmodel.is_installed(app):
            action_btn.set_variant(self.VARIANT_REMOVE)
            action_btn.set_sensitive(True)
            action_btn.show()
        elif self.appmodel.is_available(app):
            if self.appmodel.is_purchasable(app):
                action_btn.set_variant(self.VARIANT_PURCHASE)
            else:
                action_btn.set_variant(self.VARIANT_INSTALL)

            action_btn.set_sensitive(True)
            action_btn.show()

            if not network_state_is_connected():
                action_btn.set_sensitive(False)
                self.app_view.emit("application-selected",
                                   self.appmodel.get_application(app))
                return
        else:
            action_btn.set_sensitive(False)
            action_btn.hide()
            self.app_view.emit("application-selected",
                               self.appmodel.get_application(app))
            return

        if self.appmodel.get_transaction_progress(app) > 0:
            action_btn.set_sensitive(False)
        elif self.pressed and self.focal_btn == action_btn:
            action_btn.set_state(Gtk.StateFlags.ACTIVE)
        else:
            action_btn.set_state(Gtk.StateFlags.NORMAL)

        self.app_view.emit(
            "application-selected", self.appmodel.get_application(app))
        return False
コード例 #4
0
ファイル: recommendations.py プロジェクト: pombredanne/shop
 def _on_transaction_finished(self, backend, result):
     if result.pkgname in self.recommended_apps_viewed:
         self.recommended_apps_viewed.remove(result.pkgname)
         if network_state_is_connected():
             # let the recommendations service know that a
             # recommended item has been successfully installed
             # (there is no need to monitor for an error, etc., for this)
             self.recommender_agent.post_implicit_feedback(result.pkgname, RecommenderFeedbackActions.INSTALLED)
コード例 #5
0
    def _update_selected_row(self, view, tr, path=None):
        sel = view.get_selection()
        if not sel:
            return False
        model, rows = sel.get_selected_rows()
        if not rows:
            return False
        row = rows[0]
        if self.rowref_is_category(row):
            return False

        # update active app, use row-ref as argument
        self.expand_path(row)

        app = model[row][AppGenericStore.COL_ROW_DATA]

        # make sure this is not a category (LP: #848085)
        if self.rowref_is_category(app):
            return False

        action_btn = tr.get_button_by_name(CellButtonIDs.ACTION)
        #if not action_btn: return False

        if self.appmodel.is_installed(app):
            action_btn.set_variant(self.VARIANT_REMOVE)
            action_btn.set_sensitive(True)
            action_btn.show()
        elif self.appmodel.is_available(app):
            if self.appmodel.is_purchasable(app):
                action_btn.set_variant(self.VARIANT_PURCHASE)
            else:
                action_btn.set_variant(self.VARIANT_INSTALL)

            action_btn.set_sensitive(True)
            action_btn.show()

            if not network_state_is_connected():
                action_btn.set_sensitive(False)
                self.app_view.emit("application-selected",
                                   self.appmodel.get_application(app))
                return
        else:
            action_btn.set_sensitive(False)
            action_btn.hide()
            self.app_view.emit("application-selected",
                               self.appmodel.get_application(app))
            return

        if self.appmodel.get_transaction_progress(app) > 0:
            action_btn.set_sensitive(False)
        elif self.pressed and self.focal_btn == action_btn:
            action_btn.set_state(Gtk.StateFlags.ACTIVE)
        else:
            action_btn.set_state(Gtk.StateFlags.NORMAL)

        self.app_view.emit("application-selected",
                           self.appmodel.get_application(app))
        return False
コード例 #6
0
ファイル: reviews.py プロジェクト: pombredanne/shop
 def _on_network_state_change(self):
     is_connected = network_state_is_connected()
     if is_connected:
         self.new_review.set_sensitive(True)
         if self.no_network_msg:
             self.no_network_msg.hide()
     else:
         self.new_review.set_sensitive(False)
         if self.no_network_msg:
             self.no_network_msg.show()
コード例 #7
0
ファイル: recommendations.py プロジェクト: sti-lyneos/shop
 def _on_transaction_finished(self, backend, result):
     if result.pkgname in self.recommended_apps_viewed:
         self.recommended_apps_viewed.remove(result.pkgname)
         if network_state_is_connected():
             # let the recommendations service know that a
             # recommended item has been successfully installed
             # (there is no need to monitor for an error, etc., for this)
             self.recommender_agent.post_implicit_feedback(
                     result.pkgname,
                     RecommenderFeedbackActions.INSTALLED)
コード例 #8
0
 def _on_network_state_change(self):
     is_connected = network_state_is_connected()
     if is_connected:
         self.new_review.set_sensitive(True)
         if self.no_network_msg:
             self.no_network_msg.hide()
     else:
         self.new_review.set_sensitive(False)
         if self.no_network_msg:
             self.no_network_msg.show()
コード例 #9
0
ファイル: recommendations.py プロジェクト: sti-lyneos/shop
 def opt_in_to_recommendations_service(self):
     # first we verify the ubuntu sso login/oath status, and if that is good
     # we upload the user profile here, and only after this is finished
     # do we fire the request for recommendations and finally display
     # them here -- a spinner is shown for this process (the spec
     # wants a progress bar, but we don't have access to real-time
     # progress info)
     if network_state_is_connected():
         self._try_sso_login()
     else:
         self._show_no_network_view()
         self.recommender_agent.recommender_opt_in_requested(True)
         self.emit("recommendations-opt-in")
コード例 #10
0
ファイル: recommendations.py プロジェクト: pombredanne/shop
 def _on_application_activated(self, tile, app):
     self.emit("application-activated", app)
     # we only report on items if the user has opted-in to the
     # recommendations service
     if self.recommender_agent.is_opted_in():
         self.recommended_apps_viewed.add(app.pkgname)
         if network_state_is_connected():
             # let the recommendations service know that a
             # recommended item has been viewed (if it is
             # subsequently installed we will send an additional
             # signal to indicate that, in on_transaction_finished)
             # (there is no need to monitor for an error, etc., for this)
             self.recommender_agent.post_implicit_feedback(app.pkgname, RecommenderFeedbackActions.VIEWED)
コード例 #11
0
 def opt_in_to_recommendations_service(self):
     # first we verify the ubuntu sso login/oath status, and if that is good
     # we upload the user profile here, and only after this is finished
     # do we fire the request for recommendations and finally display
     # them here -- a spinner is shown for this process (the spec
     # wants a progress bar, but we don't have access to real-time
     # progress info)
     if network_state_is_connected():
         self._try_sso_login()
     else:
         self._show_no_network_view()
         self.recommender_agent.recommender_opt_in_requested(True)
         self.emit("recommendations-opt-in")
コード例 #12
0
ファイル: recommendations.py プロジェクト: sti-lyneos/shop
 def _whoami_error(self, ssologin, e):
     self.spinner_notebook.hide_spinner()
     # FIXME: there is a race condition here if the network state changed
     #        between the call and this check, to fix this properly the
     #        spawn_helper/piston-generic-helper will need to return
     #        better error information though
     if not network_state_is_connected():
         # if there is an error in the SSO whois, first just check if we
         # have network access and if we do no, just hide the panel
         self._show_no_network_view()
     else:
         # an error that is not network related indicates that the user's
         # token has likely been revoked or invalidated on the server, for
         # this case we want to reset the user's opt-in status
         self.opt_out_of_recommendations_service()
コード例 #13
0
ファイル: recommendations.py プロジェクト: sti-lyneos/shop
 def _on_application_activated(self, tile, app):
     self.emit("application-activated", app)
     # we only report on items if the user has opted-in to the
     # recommendations service
     if self.recommender_agent.is_opted_in():
         self.recommended_apps_viewed.add(app.pkgname)
         if network_state_is_connected():
             # let the recommendations service know that a
             # recommended item has been viewed (if it is
             # subsequently installed we will send an additional
             # signal to indicate that, in on_transaction_finished)
             # (there is no need to monitor for an error, etc., for this)
             self.recommender_agent.post_implicit_feedback(
                     app.pkgname,
                     RecommenderFeedbackActions.VIEWED)
コード例 #14
0
 def _whoami_error(self, ssologin, e):
     self.spinner_notebook.hide_spinner()
     # FIXME: there is a race condition here if the network state changed
     #        between the call and this check, to fix this properly the
     #        spawn_helper/piston-generic-helper will need to return
     #        better error information though
     if not network_state_is_connected():
         # if there is an error in the SSO whois, first just check if we
         # have network access and if we do no, just hide the panel
         self._hide_recommended_for_you_panel()
     else:
         # an error that is not network related indicates that the user's
         # token has likely been revoked or invalidated on the server, for
         # this case we want to reset the user's opt-in status
         self.opt_out_of_recommendations_service()
コード例 #15
0
 def _on_network_state_change(self):
     """ show/hide widgets based on network connection state """
     # FIXME: make this dynamic show/hide on network changes
     # FIXME2: make ti actually work, later show_all() kill it
     #         currently
     if network_state_is_connected():
         self.likebox.show()
         self.useful.show()
         self.flagbox.show()
     else:
         self.likebox.hide()
         # we hide the useful box because if its there it says something
         # like "10 people found this useful. Did you?" but you can't
         # actually submit anything without network
         self.useful.hide()
         self.flagbox.hide()
コード例 #16
0
ファイル: reviews.py プロジェクト: pombredanne/shop
 def _on_network_state_change(self):
     """ show/hide widgets based on network connection state """
     # FIXME: make this dynamic show/hide on network changes
     # FIXME2: make ti actually work, later show_all() kill it
     #         currently
     if network_state_is_connected():
         self.likebox.show()
         self.useful.show()
         self.flagbox.show()
     else:
         self.likebox.hide()
         # we hide the useful box because if its there it says something
         # like "10 people found this useful. Did you?" but you can't
         # actually submit anything without network
         self.useful.hide()
         self.flagbox.hide()
コード例 #17
0
    def _on_motion(self, tree, event, tr):
        window = self.get_window()
        x, y = int(event.x), int(event.y)
        if not self._xy_is_over_focal_row(x, y):
            window.set_cursor(None)
            return

        path = tree.get_path_at_pos(x, y)
        if not path:
            window.set_cursor(None)
            return

        rowref = self.get_rowref(tree.get_model(), path[0])
        if not rowref:
            return

        if self.rowref_is_category(rowref):
            window.set_cursor(None)
            return

        model = tree.get_model()
        app = model[path[0]][AppGenericStore.COL_ROW_DATA]
        if (not network_state_is_connected()
                and not self.appmodel.is_installed(app)):
            for btn_id in self.ACTION_BTNS:
                btn_id = tr.get_button_by_name(CellButtonIDs.ACTION)
                btn_id.set_sensitive(False)

        use_hand = False
        for btn in tr.get_buttons():
            if btn.state == Gtk.StateFlags.INSENSITIVE:
                continue

            if btn.point_in(x, y):
                use_hand = True
                if self.focal_btn is btn:
                    btn.set_state(Gtk.StateFlags.ACTIVE)
                elif not self.pressed:
                    btn.set_state(Gtk.StateFlags.PRELIGHT)
            else:
                if btn.state != Gtk.StateFlags.NORMAL:
                    btn.set_state(Gtk.StateFlags.NORMAL)

        if use_hand:
            window.set_cursor(self._cursor_hand)
        else:
            window.set_cursor(None)
コード例 #18
0
    def _on_motion(self, tree, event, tr):
        window = self.get_window()
        x, y = int(event.x), int(event.y)
        if not self._xy_is_over_focal_row(x, y):
            window.set_cursor(None)
            return

        path = tree.get_path_at_pos(x, y)
        if not path:
            window.set_cursor(None)
            return

        rowref = self.get_rowref(tree.get_model(), path[0])
        if not rowref: return

        if self.rowref_is_category(rowref):
            window.set_cursor(None)
            return

        model = tree.get_model()
        app = model[path[0]][AppGenericStore.COL_ROW_DATA]
        if (not network_state_is_connected() and
            not self.appmodel.is_installed(app)):
            for btn_id in self.ACTION_BTNS:
                btn_id = tr.get_button_by_name(CellButtonIDs.ACTION)
                btn_id.set_sensitive(False)

        use_hand = False
        for btn in tr.get_buttons():
            if btn.state == Gtk.StateFlags.INSENSITIVE:
                continue

            if btn.point_in(x, y):
                use_hand = True
                if self.focal_btn is btn:
                    btn.set_state(Gtk.StateFlags.ACTIVE)
                elif not self.pressed:
                    btn.set_state(Gtk.StateFlags.PRELIGHT)
            else:
                if btn.state != Gtk.StateFlags.NORMAL:
                    btn.set_state(Gtk.StateFlags.NORMAL)

        if use_hand:
            window.set_cursor(self._cursor_hand)
        else:
            window.set_cursor(None)
        return
コード例 #19
0
 def __init__(self, db, properties_helper):
     RecommendationsPanel.__init__(self)
     self.db = db
     self.properties_helper = properties_helper
     self.subcategory = None
     self.set_header_label(_(u"Recommended For You"))
     self.recommended_for_you_content = None
     # .is_opted_in() means either "successfully opted-in" or
     #                             "requested opt-in" (but not done yet)
     if self.recommender_agent.is_opted_in():
         if network_state_is_connected():
             self._try_sso_login()
         else:
             if self.recommender_agent.opt_in_requested:
                 # the user has opted in but has not yet completed the
                 # initial recommender profile upload, therefore there
                 # are no cached values available yet to display
                 self._show_no_network_view()
             else:
                 # display cached recommendations
                 self._update_recommended_for_you_content()
     else:
         self._show_opt_in_view()
コード例 #20
0
ファイル: recommendations.py プロジェクト: sti-lyneos/shop
 def __init__(self, db, properties_helper):
     RecommendationsPanel.__init__(self)
     self.db = db
     self.properties_helper = properties_helper
     self.subcategory = None
     self.set_header_label(_(u"Recommended For You"))
     self.recommended_for_you_content = None
     # .is_opted_in() means either "successfully opted-in" or
     #                             "requested opt-in" (but not done yet)
     if self.recommender_agent.is_opted_in():
         if network_state_is_connected():
             self._try_sso_login()
         else:
             if self.recommender_agent.opt_in_requested:
                 # the user has opted in but has not yet completed the
                 # initial recommender profile upload, therefore there
                 # are no cached values available yet to display
                 self._show_no_network_view()
             else:
                 # display cached recommendations
                 self._update_recommended_for_you_content()
     else:
         self._show_opt_in_view()
コード例 #21
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()

        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 (self.get_active_review_language() != 'any'
                    and self.global_review_stats
                    and self.global_review_stats.ratings_total > 0):
                self.vbox.pack_start(NoReviewRelaxLanguage(), True, True, 0)
            elif is_installed and is_connected:
                self._be_the_first_to_review()
            else:
                self.vbox.pack_start(NoReviewYet(), 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(label=_("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()
コード例 #22
0
ファイル: rnr.py プロジェクト: pombredanne/shop
 def _update_rnrclient_offline_state(self):
     # this needs the lp:~mvo/piston-mini-client/offline-mode branch
     self.rnrclient._offline_mode = not network_state_is_connected()
コード例 #23
0
ファイル: reviews.py プロジェクト: pombredanne/shop
    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()

        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 (self.get_active_review_language() != 'any' and
                    self.global_review_stats and
                    self.global_review_stats.ratings_total > 0):
                self.vbox.pack_start(NoReviewRelaxLanguage(), True, True, 0)
            elif is_installed and is_connected:
                self._be_the_first_to_review()
            else:
                self.vbox.pack_start(NoReviewYet(), 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()
コード例 #24
0
 def _update_rnrclient_offline_state(self):
     # this needs the lp:~mvo/piston-mini-client/offline-mode branch
     self.rnrclient._offline_mode = not network_state_is_connected()