def _append_comments(self, downloader, app, comments, has_more): """ Append given Entropy WebService Document objects to the comment area. """ self.__clean_non_comment_boxes() # make sure we didn't leave stuff here as well self.__clean_my_non_comment_boxes() if not comments: self.__show_no_comments() return if has_more: button_box = Gtk.HButtonBox() button = Gtk.Button() button.set_label(_("Older comments")) button.set_alignment(0.5, 0.5) def _enqueue_download(widget): widget.get_parent().destroy() spinner = Gtk.Spinner() spinner.set_size_request(StockEms.XXLARGE, StockEms.XXLARGE) spinner.set_tooltip_text(_("Loading older comments...")) spinner.set_name("comment-box-spinner") self._app_comments_box.pack_end(spinner, False, False, 3) spinner.show() spinner.start() downloader.enqueue_download() button.connect("clicked", _enqueue_download) button_box.pack_start(button, False, False, 0) self._app_comments_box.pack_start(button_box, False, False, 1) button_box.show_all() idx = 0 length = len(comments) # can be None webserv = self._entropy_ws.get(app.get_details().channelname) for doc in comments: idx += 1 box = CommentBox(self._nc, self._avc, webserv, doc, is_last=(not has_more and (idx == length))) box.connect("destroy", self._on_comment_box_destroy) box.render() self._app_comments_box.pack_end(box, False, False, 2) box.show()
def _submit_success(doc): box = CommentBox(self._nc, self._avc, webserv, doc, is_last=True) box.connect("destroy", self._on_comment_box_destroy) self.__clean_my_non_comment_boxes() box.render() self._app_my_comments_box.pack_start(box, False, False, 2) box.show() self._app_my_comments_box.show() nbox = NotificationBox( _("Your comment has been submitted!"), message_type=Gtk.MessageType.INFO, context_id=self.COMMENT_NOTIFICATION_CONTEXT_ID) nbox.add_destroy_button(_("Ok, great!")) self._app_comment_text_buffer.set_text("") self._nc.append(nbox, timeout=10)