#| nokogiri-gnome.jl -- some code to use GNOME widgets -*- lisp -*-

   $Id: stock.jl.gnome,v 1.7.4.3 2002/04/13 20:53:27 jsh Exp $

   Copyright (C) 2000 John Harper <john@dcs.warwick.ac.uk>

   This file is part of sawfish.

   sawfish 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, or (at your option)
   any later version.

   sawfish 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.

   You should have received a copy of the GNU General Public License
   along with sawfish; see the file COPYING.  If not, write to
   the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|#

(define-structure sawfish.gtk.stock

    (export stock-button
	    simple-dialog
	    about-dialog
	    make-url-widget)

    (open rep
	  gui.gtk-2.gtk
	  gui.gtk-2.gnome-ui)

  ;; same as in gtk now
  (define (stock-button type)
    (gtk-button-new-from-stock
     (case type
       ((ok) "gtk-ok")
       ((cancel) "gtk-cancel")
       ((revert) "gtk-revert-to-saved")
       ((apply) "gtk-apply")
       ((yes) "gtk-yes")
       ((no) "gtk-no")
       ((close) "gtk-close")
       ((help) "gtk-help"))))

  (define (simple-dialog title widget #!optional ok-callback main-window)

    (let ((window (gnome-dialog-new title (if ok-callback
					      '(ok cancel)
					    '(ok)))))

      (gtk-window-set-wmclass window "ok_cancel_dialog" "Nokogiri")
      (when main-window
	(gnome-dialog-set-parent window main-window))
      (gtk-container-add (gnome-dialog-vbox window) widget)

      (g-signal-connect window "clicked"
			(lambda (w button)
			  (if (and (= button 0) ok-callback)
			      (ok-callback))
			  (gtk-widget-destroy w)))
      (g-signal-connect window "delete_event" gtk-widget-destroy)

      (gtk-widget-show window)
      (gtk-window-set-modal window t)
      (gtk-widget-grab-focus widget)

      window))

  (define (about-dialog title version copyright
			authors comments #!key logo extra)
    (let ((widget (gnome-about-new title version copyright
				   authors comments logo)))
      (when extra
	(gtk-box-pack-start (gnome-dialog-vbox widget) extra t))
      (gtk-widget-show widget)
      widget))

  (define (make-url-widget url label) (gnome-href-new url label)))
