~ubuntu-branches/ubuntu/natty/sawfish/natty

« back to all changes in this revision

Viewing changes to lisp/sawfish/gtk/stock.jl

  • Committer: Bazaar Package Importer
  • Author(s): Luis Rodrigo Gallardo Cruz
  • Date: 2009-11-23 09:05:20 UTC
  • mfrom: (1.2.10 upstream) (3.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20091123090520-3u8sefrr4lmfsiem
Tags: 1:1.5.3-2
* Remove reference to sawMILL in 00debian.jl (Closes: #557250).
* Remove empty doc dirs and replace them with symlinks (Closes: #556991).
* Rename sawfish maintainer scripts with the binary package name.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#| nokogiri-no-gnome.jl -- workaround lack of GNOME widgets -*- lisp -*-
 
2
 
 
3
   $Id: stock.jl.gtk,v 1.9 2003/01/12 20:30:43 jsh Exp $
 
4
 
 
5
   Copyright (C) 2000 John Harper <john@dcs.warwick.ac.uk>
 
6
 
 
7
   This file is part of sawfish.
 
8
 
 
9
   sawfish is free software; you can redistribute it and/or modify it
 
10
   under the terms of the GNU General Public License as published by
 
11
   the Free Software Foundation; either version 2, or (at your option)
 
12
   any later version.
 
13
 
 
14
   sawfish is distributed in the hope that it will be useful, but
 
15
   WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
   GNU General Public License for more details.
 
18
 
 
19
   You should have received a copy of the GNU General Public License
 
20
   along with sawfish; see the file COPYING.  If not, write to
 
21
   the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 
22
|#
 
23
 
 
24
(define-structure sawfish.gtk.stock
 
25
 
 
26
    (export stock-button
 
27
            simple-dialog
 
28
            about-dialog
 
29
            make-url-widget)
 
30
 
 
31
    (open rep
 
32
          gui.gtk-2.gtk
 
33
          sawfish.gtk.widget)
 
34
 
 
35
  ;; same as in gnome now
 
36
  (define (stock-button type)
 
37
    (gtk-button-new-from-stock
 
38
     (case type
 
39
       ((ok) "gtk-ok")
 
40
       ((cancel) "gtk-cancel")
 
41
       ((revert) "gtk-revert-to-saved")
 
42
       ((apply) "gtk-apply")
 
43
       ((yes) "gtk-yes")
 
44
       ((no) "gtk-no")
 
45
       ((close) "gtk-close")
 
46
       ((help) "gtk-help"))))
 
47
 
 
48
  (define (simple-dialog title widget #!optional ok-callback main-window)
 
49
 
 
50
    (let ((window (gtk-window-new 'toplevel))
 
51
          (vbox (gtk-vbox-new nil box-spacing))
 
52
          (hbbox (gtk-hbutton-box-new))
 
53
          (ok (stock-button 'ok))
 
54
          (cancel (and ok-callback (stock-button 'cancel))))
 
55
 
 
56
      (define (on-cancel)
 
57
        (gtk-widget-destroy window))
 
58
 
 
59
      (define (on-ok)
 
60
        (ok-callback)
 
61
        (gtk-widget-destroy window))
 
62
          
 
63
      (gtk-window-set-title window title)
 
64
      (gtk-window-set-wmclass window "ok_cancel_dialog" "Nokogiri")
 
65
      (gtk-container-set-border-width window box-border)
 
66
      (when main-window
 
67
        (gtk-window-set-transient-for window main-window))
 
68
 
 
69
      (gtk-box-set-spacing hbbox button-box-spacing)
 
70
      (gtk-button-box-set-layout hbbox 'end)
 
71
      (when cancel
 
72
        (gtk-box-pack-end hbbox cancel))
 
73
      (gtk-box-pack-end hbbox ok)
 
74
      (gtk-box-pack-end vbox hbbox)
 
75
      (gtk-container-add window vbox)
 
76
      (gtk-widget-show-all vbox)
 
77
 
 
78
      (gtk-container-add vbox widget)
 
79
 
 
80
      (when cancel
 
81
        (g-signal-connect cancel "clicked" on-cancel))
 
82
      (g-signal-connect ok "clicked" (if ok-callback on-ok on-cancel))
 
83
      (g-signal-connect window "delete_event" on-cancel)
 
84
 
 
85
      (gtk-widget-show window)
 
86
      (gtk-window-set-modal window t)
 
87
      (gtk-widget-grab-focus widget)
 
88
 
 
89
      window))
 
90
 
 
91
  (define (about-dialog title version copyright
 
92
                        authors comments #!key logo extra)
 
93
    (declare (unused logo))
 
94
    (let* ((box (gtk-vbox-new nil 4))
 
95
           (text-view (gtk-text-view-new))
 
96
           (text-buffer (gtk-text-view-get-buffer text-view)))
 
97
      (define (insert s)
 
98
        (gtk-text-buffer-insert-at-cursor text-buffer s (length s)))
 
99
      (insert (format nil "%s %s\n" title version))
 
100
      (insert (format nil "%s\n\n" copyright))
 
101
      (when authors
 
102
        (insert "Authors:\n")
 
103
        (mapc (lambda (x) (insert (format nil "    %s\n" x))) authors))
 
104
      (insert (format nil "\n%s\n" comments))
 
105
      (gtk-text-view-set-editable text-view nil)
 
106
      (gtk-container-add box text-view)
 
107
      (when extra
 
108
        (gtk-box-pack-end box extra))
 
109
      (gtk-widget-show-all box)
 
110
      (simple-dialog "About" box)))
 
111
 
 
112
  (define (make-url-widget url label)
 
113
    (gtk-label-new (format nil "%s <%s>" label url))))