Ejemplo n.º 1
0
    def _clear(self):
        objs = self.get_selection()
        qty = len(objs)
        if qty < 1:
            raise SelectionError('There are no objects selected')

        msg = stoqlib_ngettext(
            _('Delete this item?'),
            _('Delete these %d items?') % qty,
            qty)
        delete_label = stoqlib_ngettext(
            _("Delete item"),
            _("Delete items"),
            qty)

        keep_label = stoqlib_ngettext(
            _("Keep it"),
            _("Keep them"),
            qty)
        if not yesno(msg, gtk.RESPONSE_NO, delete_label, keep_label):
            return
        self.emit('before-delete-items', objs)
        if qty == len(self.klist):
            self.klist.clear()
        else:
            for obj in objs:
                self.klist.remove(obj)
        self.klist.unselect_all()
        self._update_sensitivity()
        self.emit('after-delete-items')
Ejemplo n.º 2
0
 def _edit(self):
     if not self._can_edit:
         return
     objs = self.get_selection()
     qty = len(objs)
     if qty != 1:
         raise SelectionError(
             ("Please select only one item before choosing Edit."
              "\nThere are currently %d items selected") % qty)
     self._edit_model(objs[0])