; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; GNU General Public License for more details.

;; 'isolate' delete everything but the selection contents

(define (script-fu-sg-isolate image drawable)
  (gimp-image-undo-group-start image)
  (if (= (car (gimp-drawable-is-layer drawable)) TRUE)
    (gimp-layer-add-alpha drawable))
  (gimp-selection-invert image)
  (gimp-edit-clear drawable)
  (gimp-selection-invert image)
  (gimp-image-undo-group-end image)
  (gimp-displays-flush)
  )

(script-fu-register "script-fu-sg-isolate"
  "Isolate"
  "Remove all content except the selection"
  "Saul Goode"
  "saulgoode"
  "5/21/2007"
  "*"
  SF-IMAGE    "Image"    0
  SF-DRAWABLE "Drawable" 0
  )
(script-fu-menu-register "script-fu-sg-isolate"
  "<Image>/Edit/Cut"
  )
