annotate tests/gtk/gtk-test.el @ 5402:308d34e9f07d

Changed bulk of GPLv2 or later files identified by script
author Mats Lidell <matsl@xemacs.org>
date Thu, 14 Oct 2010 17:15:20 +0200
parents 5efbd1253905
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1 ;;; gtk-test.el --- Test harness for GTK widgets
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
3 ;; Copyright (C) 2000 Free Software Foundation
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
4
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
5 ;; Maintainer: William Perry <wmperry@gnu.org>
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
6 ;; Keywords: tests
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
7
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
9
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5228
diff changeset
10 ;; XEmacs is free software: you can redistribute it and/or modify it
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5228
diff changeset
11 ;; under the terms of the GNU General Public License as published by the
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5228
diff changeset
12 ;; Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5228
diff changeset
13 ;; option) any later version.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
14
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5228
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5228
diff changeset
16 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5228
diff changeset
17 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5228
diff changeset
18 ;; for more details.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
19
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5228
diff changeset
21 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
22
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
23 ;;; Synched up with: Not in FSF
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
24
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
25 ;;; Commentary:
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
26
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
27 (require 'font)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
28
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
29 (setq GTK_TOPLEVEL (lsh 1 4)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
30 GTK_NO_WINDOW (lsh 1 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
31 GTK_REALIZED (lsh 1 6)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
32 GTK_MAPPED (lsh 1 7)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
33 GTK_VISIBLE (lsh 1 8)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
34 GTK_SENSITIVE (lsh 1 9)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
35 GTK_PARENT_SENSITIVE (lsh 1 10)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
36 GTK_CAN_FOCUS (lsh 1 11)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
37 GTK_HAS_FOCUS (lsh 1 12)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
38 GTK_CAN_DEFAULT (lsh 1 13)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
39 GTK_HAS_DEFAULT (lsh 1 14)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
40 GTK_HAS_GRAB (lsh 1 15)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
41 GTK_RC_STYLE (lsh 1 16)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
42 GTK_COMPOSITE_CHILD (lsh 1 17)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
43 GTK_NO_REPARENT (lsh 1 18)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
44 GTK_APP_PAINTABLE (lsh 1 19)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
45 GTK_RECEIVES_DEFAULT (lsh 1 20))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
46
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
47 (defun gtk-widget-visible (widget)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
48 (= (logand (gtk-object-flags widget) GTK_VISIBLE) GTK_VISIBLE))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
49
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
50 (defvar gtk-defined-tests nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
51 "A list describing the defined tests.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
52 Each element is of the form (DESCRIPTION TYPE FUNCTION)")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
53
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
54 (defvar gtk-test-directory nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
55 (defun gtk-test-directory ()
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
56 (if (not gtk-test-directory)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
57 (mapc (lambda (c)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
58 (if (and (not gtk-test-directory)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
59 (string= (file-name-nondirectory (car c)) "gtk-test.el"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
60 (setq gtk-test-directory (file-name-directory (car c)))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
61 load-history))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
62 gtk-test-directory)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
63
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
64 (defvar gtk-test-categories '((container . "Containers")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
65 (basic . "Basic Widgets")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
66 (composite . "Composite Widgets")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
67 (gimp . "Gimp Widgets")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
68 (misc . "Miscellaneous")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
69 (extra . "GTK+ Extra")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
70 (gdk . "GDK Primitives")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
71 (gnome . "GNOME tests"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
72 "An assoc list mapping test categories to friendly names.")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
73
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
74 (defvar gtk-test-open-glyph
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
75 (make-glyph [xpm :data "/* XPM */\nstatic char * book_open_xpm[] = {\n\"16 16 4 1\",\n\" c None s None\",\n\". c black\",\n\"X c #808080\",\n\"o c white\",\n\" \",\n\" .. \",\n\" .Xo. ... \",\n\" .Xoo. ..oo. \",\n\" .Xooo.Xooo... \",\n\" .Xooo.oooo.X. \",\n\" .Xooo.Xooo.X. \",\n\" .Xooo.oooo.X. \",\n\" .Xooo.Xooo.X. \",\n\" .Xooo.oooo.X. \",\n\" .Xoo.Xoo..X. \",\n\" .Xo.o..ooX. \",\n\" .X..XXXXX. \",\n\" ..X....... \",\n\" .. \",\n\" \"};"]))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
76
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
77 (defvar gtk-test-closed-glyph
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
78 (make-glyph [xpm :data "/* XPM */\nstatic char * book_closed_xpm[] = {\n\"16 16 6 1\",\n\" c None s None\",\n\". c black\",\n\"X c red\",\n\"o c yellow\",\n\"O c #808080\",\n\"# c white\",\n\" \",\n\" .. \",\n\" ..XX. \",\n\" ..XXXXX. \",\n\" ..XXXXXXXX. \",\n\".ooXXXXXXXXX. \",\n\"..ooXXXXXXXXX. \",\n\".X.ooXXXXXXXXX. \",\n\".XX.ooXXXXXX.. \",\n\" .XX.ooXXX..#O \",\n\" .XX.oo..##OO. \",\n\" .XX..##OO.. \",\n\" .X.#OO.. \",\n\" ..O.. \",\n\" .. \",\n\" \"};\n"]))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
79
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
80 (defvar gtk-test-mini-page-glyph
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
81 (make-glyph [xpm :data "/* XPM */\nstatic char * mini_page_xpm[] = {\n\"16 16 4 1\",\n\" c None s None\",\n\". c black\",\n\"X c white\",\n\"o c #808080\",\n\" \",\n\" ....... \",\n\" .XXXXX.. \",\n\" .XoooX.X. \",\n\" .XXXXX.... \",\n\" .XooooXoo.o \",\n\" .XXXXXXXX.o \",\n\" .XooooooX.o \",\n\" .XXXXXXXX.o \",\n\" .XooooooX.o \",\n\" .XXXXXXXX.o \",\n\" .XooooooX.o \",\n\" .XXXXXXXX.o \",\n\" ..........o \",\n\" oooooooooo \",\n\" \"};\n"]))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
82
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
83 (defvar gtk-test-mini-gtk-glyph
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
84 (make-glyph [xpm :data "/* XPM */\nstatic char * gtk_mini_xpm[] = {\n\"15 20 17 1\",\n\" c None\",\n\". c #14121F\",\n\"+ c #278828\",\n\"@ c #9B3334\",\n\"# c #284C72\",\n\"$ c #24692A\",\n\"% c #69282E\",\n\"& c #37C539\",\n\"* c #1D2F4D\",\n\"= c #6D7076\",\n\"- c #7D8482\",\n\"; c #E24A49\",\n\"> c #515357\",\n\", c #9B9C9B\",\n\"' c #2FA232\",\n\") c #3CE23D\",\n\"! c #3B6CCB\",\n\" \",\n\" ***> \",\n\" >.*!!!* \",\n\" ***....#*= \",\n\" *!*.!!!**!!# \",\n\" .!!#*!#*!!!!# \",\n\" @%#!.##.*!!$& \",\n\" @;%*!*.#!#')) \",\n\" @;;@%!!*$&)'' \",\n\" @%.%@%$'&)$+' \",\n\" @;...@$'*'*)+ \",\n\" @;%..@$+*.')$ \",\n\" @;%%;;$+..$)# \",\n\" @;%%;@$$$'.$# \",\n\" %;@@;;$$+))&* \",\n\" %;;;@+$&)&* \",\n\" %;;@'))+> \",\n\" %;@'&# \",\n\" >%$$ \",\n\" >= \"};"]))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
85
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
86
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
87 (defun build-option-menu (items history obj)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
88 (let (omenu menu menu-item group i)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
89 (setq omenu (gtk-option-menu-new)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
90 menu (gtk-menu-new)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
91 i 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
92
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
93 (while items
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
94 (setq menu-item (gtk-radio-menu-item-new-with-label group (car (car items))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
95 (gtk-signal-connect menu-item 'activate (cdr (car items)) obj)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
96 (setq group (gtk-radio-menu-item-group menu-item))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
97 (gtk-menu-append menu menu-item)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
98 (if (= i history)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
99 (gtk-check-menu-item-set-active menu-item t))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
100 (gtk-widget-show menu-item)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
101 (setq items (cdr items))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
102 (incf i))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
103
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
104 (gtk-option-menu-set-menu omenu menu)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
105 (gtk-option-menu-set-history omenu history)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
106 omenu))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
107
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
108 (defun gtk-test-notice-destroy (object symbol)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
109 ;; Set variable to NIL to aid in object destruction.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
110 (set symbol nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
111
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
112 (defun gtk-test-make-sample-buttons (box maker)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
113 ;; Create buttons and pack them in a premade BOX.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
114 (mapcar (lambda (name)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
115 (let ((button (funcall maker name)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
116 (gtk-box-pack-start box button t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
117 (gtk-widget-show button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
118 button)) '("button1" "button2" "button3")))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
119
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
120 (make-face 'gtk-test-face-large "A face with a large font, for use in GTK test cases")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
121 (font-set-face-font 'gtk-test-face-large
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
122 (make-font :family '("LucidaBright" "Utopia" "Helvetica" "fixed")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
123 :weight :normal
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
124 :size "36pt"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
125
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
126 (defvar gtk-test-shell nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
127 "Where non-dialog tests should realize their widgets.")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
128
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
129 (defmacro gtk-define-test (title type name-stub dialog-p &rest body)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
130 "Define a GTK demo/test.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
131 TITLE is the friendly name of the test to show to the user.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
132 TYPE is used to sort the items.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
133 NAME-STUB is used to create the function definition.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
134 DIALOG-P must be non-nil for demos that create their own top-level window.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
135 BODY are the forms that actually create the demo.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
136
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
137 They must pack their widgets into the dynamically bound WINDOW variable,
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
138 which is a GtkVBox.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
139 "
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
140 `(progn
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
141 (if (not (assoc ,title gtk-defined-tests))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
142 (push (list ,title (quote ,type)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
143 (quote ,(intern (format "gtk-test-%s" name-stub)))) gtk-defined-tests))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
144 (defun ,(intern (format "gtk-test-%s" name-stub)) ()
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
145 (let ((main-widget (if (not gtk-test-shell)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
146 (gtk-window-new 'toplevel)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
147 (gtk-frame-new ,title)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
148 (window nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
149 (if gtk-test-shell
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
150 (progn
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
151 (mapc 'gtk-widget-destroy (gtk-container-children gtk-test-shell))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
152 (gtk-box-pack-start gtk-test-shell main-widget nil nil 0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
153 (gtk-window-set-title main-widget ,title))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
154 (if ,dialog-p
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
155 (let ((button (gtk-button-new-with-label ,title))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
156 (blank (gtk-event-box-new)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
157 (setq window (gtk-hbox-new nil 0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
158 (gtk-signal-connect button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
159 (lambda (&rest ignored)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
160 (let ((window nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
161 ,@body
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
162 (gtk-widget-show-all window))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
163 (gtk-box-pack-start window
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
164 (gtk-label-new
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
165 (concat "This demo creates an external dialog.\n"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
166 "Activate the button to see the demo."))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
167 nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
168 (gtk-box-pack-start window button nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
169 (gtk-box-pack-start window blank t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
170 (gtk-widget-show-all main-widget))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
171 (setq window (gtk-vbox-new nil 0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
172 ,@body)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
173 (gtk-container-add main-widget window)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
174 (gtk-widget-show-all (or main-widget window))))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
175
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
176
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
177 ;;;; Pixmaps
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
178 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
179 "Pixmaps" misc pixmap nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
180 (let* ((button (gtk-button-new))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
181 (pixmap (gtk-pixmap-new xemacs-logo nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
182 (label (gtk-label-new "Pixmap test"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
183 (hbox (gtk-hbox-new nil 0)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
184 (gtk-box-pack-start window button nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
185 (gtk-widget-show button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
186 (gtk-container-set-border-width hbox 2)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
187 (gtk-container-add hbox pixmap)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
188 (gtk-container-add hbox label)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
189 (gtk-container-add button hbox)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
190 (gtk-widget-show pixmap)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
191 (gtk-widget-show label)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
192 (gtk-widget-show hbox)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
193
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
194
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
195 ;;;; Scrolled windows
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
196 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
197 "Scrolled windows" container create-scrolled-windows nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
198 (let* ((scrolled-win (gtk-scrolled-window-new nil nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
199 (viewport (gtk-viewport-new
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
200 (gtk-scrolled-window-get-hadjustment scrolled-win)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
201 (gtk-scrolled-window-get-vadjustment scrolled-win)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
202 (table (gtk-table-new 20 20 nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
203 (button nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
204 (gtk-container-set-border-width window 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
205 (gtk-container-set-border-width scrolled-win 10)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
206 (gtk-scrolled-window-set-policy scrolled-win 'automatic 'automatic)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
207 (gtk-box-pack-start window scrolled-win t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
208 (gtk-table-set-row-spacings table 10)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
209 (gtk-table-set-col-spacings table 10)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
210 (gtk-scrolled-window-add-with-viewport scrolled-win table)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
211 (gtk-container-set-focus-hadjustment
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
212 table (gtk-scrolled-window-get-hadjustment scrolled-win))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
213 (gtk-container-set-focus-vadjustment
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
214 table (gtk-scrolled-window-get-vadjustment scrolled-win))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
215 (loop for i from 0 to 19 do
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
216 (loop for j from 0 to 19 do
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
217 (setq button (gtk-button-new-with-label (format "button (%d, %d)\n" i j)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
218 (gtk-table-attach-defaults table button i (1+ i) j (1+ j))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
219 (gtk-widget-show-all scrolled-win)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
220
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
221
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
222 ;;;; Lists
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
223 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
224 "List" basic create-list nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
225 (let ((list-items '("hello"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
226 "world"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
227 "blah"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
228 "foo"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
229 "bar"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
230 "argh"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
231 "wmperry"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
232 "is a"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
233 "wussy"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
234 "programmer"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
235 (scrolled-win (gtk-scrolled-window-new nil nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
236 (lyst (gtk-list-new))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
237 (add (gtk-button-new-with-label "add"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
238 (remove (gtk-button-new-with-label "remove")))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
239
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
240 (gtk-scrolled-window-set-policy scrolled-win 'automatic 'automatic)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
241 (gtk-box-pack-start window scrolled-win t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
242 (gtk-widget-show scrolled-win)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
243
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
244 (gtk-list-set-selection-mode lyst 'multiple)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
245 (gtk-list-set-selection-mode lyst 'browse)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
246 (gtk-scrolled-window-add-with-viewport scrolled-win lyst)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
247 (gtk-widget-show lyst)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
248
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
249 (mapc (lambda (i)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
250 (let ((list-item (gtk-list-item-new-with-label i)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
251 (gtk-container-add lyst list-item)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
252 (gtk-widget-show list-item)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
253 list-items)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
254
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
255 (gtk-signal-connect add 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
256 (lambda (obj data) (message "Should add to the list")))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
257 (gtk-box-pack-start window add nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
258 (gtk-widget-show add)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
259
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
260 (gtk-signal-connect remove 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
261 (lambda (obj list)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
262 (if (gtk-list-selection list)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
263 (gtk-list-remove-items list (gtk-list-selection list)))) lyst)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
264 (gtk-box-pack-start window remove nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
265 (gtk-widget-show remove)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
266
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
267 (gtk-signal-connect lyst 'select_child
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
268 (lambda (lyst child ignored)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
269 (message "selected %S %d" child (gtk-list-child-position lyst child))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
270
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
271 (gtk-widget-set-usize scrolled-win 200 75)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
272
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
273 (gtk-signal-connect lyst 'unselect_child (lambda (lyst child ignored)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
274 (message "unselected %S" child)))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
275
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
276
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
277 ;;;; Tooltips
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
278 (defvar gtk-test-tooltips nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
279
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
280 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
281 "Tooltips" composite create-tooltips nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
282 (if (not gtk-test-tooltips)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
283 (setq gtk-test-tooltips (gtk-tooltips-new)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
284 (let ((buttons (gtk-test-make-sample-buttons window 'gtk-toggle-button-new-with-label))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
285 (tips '("This is button 1"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
286 "This is button 2"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
287 "This is button 3. This is also a really long tooltip which probably won't fit on a single line and will therefore need to be wrapped. Hopefully the wrapping will work correctly.")))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
288 (while buttons
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
289 (gtk-tooltips-set-tip gtk-test-tooltips (pop buttons) (pop tips) ""))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
290
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
291
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
292 ;;;; Panes
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
293 (defun toggle-resize (widget child)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
294 (let* ((paned (gtk-widget-parent child))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
295 (is-child1 (eq child (gtk-paned-child1 paned)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
296 resize shrink)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
297 (setq resize (if is-child1
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
298 (gtk-paned-child1-resize paned)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
299 (gtk-paned-child2-resize paned))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
300 shrink (if is-child1
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
301 (gtk-paned-child1-shrink paned)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
302 (gtk-paned-child2-shrink paned)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
303
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
304 (gtk-widget-ref child)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
305 (gtk-container-remove paned child)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
306 (if is-child1
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
307 (gtk-paned-pack1 paned child (not resize) shrink)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
308 (gtk-paned-pack2 paned child (not resize) shrink))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
309 (gtk-widget-unref child)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
310
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
311 (defun toggle-shrink (widget child)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
312 (let* ((paned (gtk-widget-parent child))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
313 (is-child1 (eq child (gtk-paned-child1 paned)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
314 resize shrink)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
315 (setq resize (if is-child1
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
316 (gtk-paned-child1-resize paned)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
317 (gtk-paned-child2-resize paned))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
318 shrink (if is-child1
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
319 (gtk-paned-child1-shrink paned)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
320 (gtk-paned-child2-shrink paned)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
321
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
322 (gtk-widget-ref child)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
323 (gtk-container-remove paned child)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
324 (if is-child1
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
325 (gtk-paned-pack1 paned child resize (not shrink))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
326 (gtk-paned-pack2 paned child resize (not shrink)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
327 (gtk-widget-unref child)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
328
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
329 (defun create-pane-options (widget frame-label label1 label2)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
330 (let (frame table label check-button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
331 (setq frame (gtk-frame-new frame-label))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
332 (gtk-container-set-border-width frame 4)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
333
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
334 (setq table (gtk-table-new 3 2 4))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
335 (gtk-container-add frame table)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
336
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
337 (setq label (gtk-label-new label1))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
338 (gtk-table-attach-defaults table label 0 1 0 1)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
339
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
340 (setq check-button (gtk-check-button-new-with-label "Resize"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
341 (gtk-table-attach-defaults table check-button 0 1 1 2)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
342 (gtk-signal-connect check-button 'toggled 'toggle-resize (gtk-paned-child1 widget))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
343
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
344 (setq check-button (gtk-check-button-new-with-label "Shrink"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
345 (gtk-table-attach-defaults table check-button 0 1 2 3)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
346 (gtk-toggle-button-set-active check-button t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
347 (gtk-signal-connect check-button 'toggled 'toggle-shrink (gtk-paned-child1 widget))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
348
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
349 (setq label (gtk-label-new label2))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
350 (gtk-table-attach-defaults table label 1 2 0 1)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
351
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
352 (setq check-button (gtk-check-button-new-with-label "Resize"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
353 (gtk-table-attach-defaults table check-button 1 2 1 2)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
354 (gtk-toggle-button-set-active check-button t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
355 (gtk-signal-connect check-button 'toggled 'toggle-resize (gtk-paned-child2 widget))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
356
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
357 (setq check-button (gtk-check-button-new-with-label "Shrink"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
358 (gtk-table-attach-defaults table check-button 1 2 2 3)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
359 (gtk-toggle-button-set-active check-button t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
360 (gtk-signal-connect check-button 'toggled 'toggle-shrink (gtk-paned-child2 widget))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
361 frame))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
362
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
363 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
364 "Panes" container panes nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
365 (let (frame hpaned vpaned button vbox)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
366 (gtk-container-set-border-width window 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
367
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
368 (setq vpaned (gtk-vpaned-new))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
369 (gtk-box-pack-start window vpaned t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
370 (gtk-container-set-border-width vpaned 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
371
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
372 (setq hpaned (gtk-hpaned-new))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
373 (gtk-paned-add1 vpaned hpaned)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
374
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
375 (setq frame (gtk-frame-new nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
376 (gtk-frame-set-shadow-type frame 'in)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
377 (gtk-widget-set-usize frame 60 60)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
378 (gtk-paned-add1 hpaned frame)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
379
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
380 (setq button (gtk-button-new-with-label "Hi there"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
381 (gtk-container-add frame button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
382
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
383 (setq frame (gtk-frame-new nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
384 (gtk-frame-set-shadow-type frame 'in)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
385 (gtk-widget-set-usize frame 80 60)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
386 (gtk-paned-add2 hpaned frame)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
387
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
388 (setq frame (gtk-frame-new nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
389 (gtk-frame-set-shadow-type frame 'in)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
390 (gtk-widget-set-usize frame 60 80)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
391 (gtk-paned-add2 vpaned frame)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
392
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
393 ;; Now create toggle buttons to control sizing
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
394 (gtk-box-pack-start window (create-pane-options hpaned "Horizontal" "Left" "Right") nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
395 (gtk-box-pack-start window (create-pane-options vpaned "Vertical" "Top" "Bottom") nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
396 (gtk-widget-show-all window)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
397
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
398
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
399 ;;;; Entry
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
400 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
401 "Entry" basic entry nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
402 (let ((box1 nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
403 (box2 nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
404 (editable-check nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
405 (sensitive-check nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
406 (entry nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
407 (cb nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
408 (button nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
409 (separator nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
410 (cbitems '("item0"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
411 "item1 item1"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
412 "item2 item2 item2"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
413 "item3 item3 item3 item3"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
414 "item4 item4 item4 item4 item4"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
415 "item5 item5 item5 item5 item5 item5"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
416 "item6 item6 item6 item6 item6"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
417 "item7 item7 item7 item7"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
418 "item8 item8 item8"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
419 "item9 item9")))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
420 (gtk-container-set-border-width window 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
421
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
422 (setq box1 (gtk-vbox-new nil 0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
423 (gtk-container-add window box1)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
424 (gtk-widget-show box1)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
425
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
426 (setq box2 (gtk-vbox-new nil 10))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
427 (gtk-container-set-border-width box2 10)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
428 (gtk-box-pack-start box1 box2 t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
429 (gtk-widget-show box2)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
430
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
431 (setq entry (gtk-entry-new))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
432 (gtk-entry-set-text entry "hello world")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
433 (gtk-editable-select-region entry 0 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
434 (gtk-box-pack-start box2 entry t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
435 (gtk-widget-show entry)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
436
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
437 (setq cb (gtk-combo-new))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
438 (gtk-combo-set-popdown-strings cb cbitems)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
439 (gtk-entry-set-text (gtk-combo-entry cb) "hellow world")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
440 (gtk-editable-select-region (gtk-combo-entry cb) 0 -1)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
441 (gtk-box-pack-start box2 cb t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
442 (gtk-widget-show cb)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
443
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
444 (setq editable-check (gtk-check-button-new-with-label "Editable"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
445 (gtk-box-pack-start box2 editable-check nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
446 (gtk-signal-connect editable-check 'toggled
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
447 (lambda (obj data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
448 (gtk-entry-set-editable
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
449 data
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
450 (gtk-toggle-button-get-active obj))) entry)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
451 (gtk-toggle-button-set-active editable-check t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
452 (gtk-widget-show editable-check)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
453
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
454 (setq editable-check (gtk-check-button-new-with-label "Visible"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
455 (gtk-box-pack-start box2 editable-check nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
456 (gtk-signal-connect editable-check 'toggled
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
457 (lambda (obj data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
458 (gtk-entry-set-visibility data
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
459 (gtk-toggle-button-get-active obj))) entry)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
460 (gtk-toggle-button-set-active editable-check t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
461 (gtk-widget-show editable-check)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
463 (setq sensitive-check (gtk-check-button-new-with-label "Sensitive"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
464 (gtk-box-pack-start box2 sensitive-check nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
465 (gtk-signal-connect sensitive-check 'toggled
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
466 (lambda (obj data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
467 (gtk-widget-set-sensitive data
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
468 (gtk-toggle-button-get-active obj))) entry)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
469 (gtk-toggle-button-set-active sensitive-check t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
470 (gtk-widget-show sensitive-check)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
471
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
472
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
473 ;;;; Various built-in dialog types
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
474 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
475 "Font Dialog" composite font-selection t
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
476 (setq window (gtk-font-selection-dialog-new "font selection dialog"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
477 (gtk-font-selection-dialog-set-preview-text window "Set from Emacs Lisp!")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
478 (gtk-signal-connect
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
479 (gtk-font-selection-dialog-cancel-button window)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
480 'clicked (lambda (button dlg)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
481 (gtk-widget-destroy dlg))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
482 window)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
483 (gtk-signal-connect
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
484 (gtk-font-selection-dialog-ok-button window)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
485 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
486 (lambda (button dlg)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
487 (message "Font selected: %s" (gtk-font-selection-dialog-get-font-name dlg)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
488 window))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
489
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
490 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
491 "File Selection Dialog" composite file-selection t
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
492 (let (button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
493 (setq window (gtk-file-selection-new "file selection"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
494 (gtk-signal-connect
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
495 (gtk-file-selection-ok-button window)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
496 'clicked (lambda (obj dlg) (message "You clicked ok: %s"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
497 (gtk-file-selection-get-filename dlg)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
498 window)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
499
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
500 (gtk-signal-connect
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
501 (gtk-file-selection-cancel-button window)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
502 'clicked (lambda (obj dlg) (gtk-widget-destroy dlg)) window)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
503
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
504 (gtk-file-selection-hide-fileop-buttons window)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
505
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
506 (setq button (gtk-button-new-with-label "Hide Fileops"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
507 (gtk-signal-connect
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
508 button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
509 (lambda (obj dlg)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
510 (gtk-file-selection-hide-fileop-buttons dlg)) window)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
511
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
512 (gtk-box-pack-start (gtk-file-selection-action-area window)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
513 button nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
514 (gtk-widget-show button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
515
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
516 (setq button (gtk-button-new-with-label "Show Fileops"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
517 (gtk-signal-connect
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
518 button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
519 (lambda (obj dlg)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
520 (gtk-file-selection-show-fileop-buttons dlg)) window)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
521 (gtk-box-pack-start (gtk-file-selection-action-area window)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
522 button nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
523 (gtk-widget-show button)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
524
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
525 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
526 "Color selection" composite color t
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
527 (setq window (gtk-color-selection-dialog-new "GTK color selection"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
528 (gtk-signal-connect (gtk-color-selection-dialog-cancel-button window)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
529 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
530 (lambda (button data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
531 (gtk-widget-destroy data)) window)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
532 (gtk-signal-connect (gtk-color-selection-dialog-ok-button window)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
533 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
534 (lambda (button data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
535 (let ((rgba (gtk-color-selection-get-color
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
536 (gtk-color-selection-dialog-colorsel data)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
537 r g b a)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
538 (setq r (pop rgba)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
539 g (pop rgba)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
540 b (pop rgba)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
541 a (pop rgba))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
542 (gtk-widget-destroy data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
543 (message-box
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
544 "You selected color: red (%04x) blue (%04x) green (%04x) alpha (%g)"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
545 (* 65535 r) (* 65535 g) (* 65535 b) a)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
546 window))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
547
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
548
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
549 ;;;; Dialog
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
550 (defun gtk-container-specific-children (parent predicate &optional data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
551 (let ((children nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
552 (mapc (lambda (w)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
553 (if (funcall predicate w data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
554 (push w children)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
555 (gtk-container-children parent))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
556 children))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
557
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
558 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
559 "Dialog" basic dialog t
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
560 (let ((button nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
561 (label nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
562 (setq window (gtk-dialog-new))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
563 (gtk-container-set-border-width window 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
564 (gtk-widget-set-usize window 200 110)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
565
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
566 (setq button (gtk-button-new-with-label "OK"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
567 (gtk-box-pack-start (gtk-dialog-action-area window) button t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
568 (gtk-widget-show button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
569 (gtk-signal-connect button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
570 (lambda (obj data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
571 (gtk-widget-destroy data))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
572 window)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
573
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
574 (setq button (gtk-button-new-with-label "Toggle"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
575 (gtk-signal-connect
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
576 button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
577 (lambda (button dlg)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
578 (if (not (gtk-container-specific-children (gtk-dialog-vbox dlg)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
579 (lambda (w ignored)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
580 (= (gtk-object-type w) (gtk-label-get-type)))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
581 (let ((label (gtk-label-new "Dialog Test")))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
582 (gtk-box-pack-start (gtk-dialog-vbox dlg) label t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
583 (gtk-widget-show label))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
584 (mapc 'gtk-widget-destroy
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
585 (gtk-container-specific-children (gtk-dialog-vbox dlg)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
586 (lambda (w ignored)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
587 (= (gtk-object-type w) (gtk-label-get-type)))))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
588 window)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
589 (gtk-box-pack-start (gtk-dialog-action-area window) button t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
590 (gtk-widget-show button)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
591
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
592
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
593 ;;;; Range controls
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
594 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
595 "Range Controls" basic range-controls nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
596 (let* ((adjustment (gtk-adjustment-new 0.0 0.0 101.0 0.1 1.0 1.0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
597 (scale (gtk-hscale-new adjustment))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
598 (scrollbar (gtk-hscrollbar-new adjustment)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
599 (gtk-widget-set-usize scale 150 30)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
600 (gtk-range-set-update-policy scale 'delayed)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
601 (gtk-scale-set-digits scale 2)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
602 (gtk-scale-set-draw-value scale t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
603 (gtk-box-pack-start window scale t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
604 (gtk-widget-show scale)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
605
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
606 (gtk-range-set-update-policy scrollbar 'continuous)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
607 (gtk-box-pack-start window scrollbar t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
608 (gtk-widget-show scrollbar)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
609
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
610
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
611 ;;;; Ruler
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
612 '(gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
613 "Rulers" gimp rulers nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
614 (let* ((table (gtk-table-new 2 2 nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
615 (hruler nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
616 (vruler nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
617 (ebox (gtk-event-box-new)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
618
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
619 (gtk-widget-set-usize ebox 300 300)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
620 (gtk-widget-set-events ebox '(pointer-motion-mask pointer-motion-hint-mask))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
621 (gtk-container-set-border-width ebox 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
622
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
623 (gtk-container-add window ebox)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
624 (gtk-container-add ebox table)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
625 (gtk-widget-show table)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
626
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
627 (setq hruler (gtk-hruler-new))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
628 (gtk-ruler-set-metric hruler 'centimeters)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
629 (gtk-ruler-set-range hruler 100 0 0 20)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
630 (gtk-table-attach table hruler 1 2 0 1 '(expand fill) 'fill 0 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
631 (gtk-widget-show hruler)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
632
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
633 (setq vruler (gtk-vruler-new))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
634 (gtk-ruler-set-range vruler 5 15 0 20)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
635 (gtk-table-attach table vruler 0 1 1 2 'fill '(expand fill) 0 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
636 (gtk-widget-show vruler)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
637
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
638 (gtk-signal-connect
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
639 ebox 'motion_notify_event
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
640 (lambda (object ev data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
641 (gtk-widget-event (car data) ev)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
642 (gtk-widget-event (cdr data) ev))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
643 (cons hruler vruler))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
644
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
645
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
646 ;;;; Toggle button types
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
647 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
648 "Toggle Buttons" basic toggle-buttons nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
649 (gtk-container-set-border-width window 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
650 (gtk-test-make-sample-buttons window 'gtk-toggle-button-new-with-label))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
651
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
652 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
653 "Check Buttons" basic check-buttons nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
654 (gtk-container-set-border-width window 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
655 (gtk-test-make-sample-buttons window 'gtk-check-button-new-with-label))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
656
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
657 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
658 "Radio Buttons" basic radio-buttons nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
659 (gtk-container-set-border-width window 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
660 (let ((group nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
661 (gtk-test-make-sample-buttons window
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
662 (lambda (label)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
663 (let ((button (gtk-radio-button-new-with-label group label)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
664 (setq group (gtk-radio-button-group button))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
665 button)))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
666
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
667
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
668 ;;;; Button weirdness
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
669 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
670 "Buttons" basic buttons nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
671 (let ((box1 nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
672 (box2 nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
673 (table nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
674 (buttons nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
675 (separator nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
676 (connect-buttons (lambda (button1 button2)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
677 (gtk-signal-connect button1 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
678 (lambda (obj data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
679 (if (gtk-widget-visible data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
680 (gtk-widget-hide data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
681 (gtk-widget-show data))) button2))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
682
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
683 (gtk-container-set-border-width window 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
684
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
685 (setq box1 (gtk-vbox-new nil 0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
686 (gtk-container-add window box1)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
687
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
688 (setq table (gtk-table-new 3 3 nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
689 (gtk-table-set-row-spacings table 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
690 (gtk-table-set-col-spacings table 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
691 (gtk-container-set-border-width table 10)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
692 (gtk-box-pack-start box1 table t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
693
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
694 (push (gtk-button-new-with-label "button9") buttons)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
695 (push (gtk-button-new-with-label "button8") buttons)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
696 (push (gtk-button-new-with-label "button7") buttons)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
697 (push (gtk-button-new-with-label "button6") buttons)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
698 (push (gtk-button-new-with-label "button5") buttons)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
699 (push (gtk-button-new-with-label "button4") buttons)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
700 (push (gtk-button-new-with-label "button3") buttons)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
701 (push (gtk-button-new-with-label "button2") buttons)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
702 (push (gtk-button-new-with-label "button1") buttons)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
703
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
704 (funcall connect-buttons (nth 0 buttons) (nth 1 buttons))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
705 (funcall connect-buttons (nth 1 buttons) (nth 2 buttons))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
706 (funcall connect-buttons (nth 2 buttons) (nth 3 buttons))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
707 (funcall connect-buttons (nth 3 buttons) (nth 4 buttons))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
708 (funcall connect-buttons (nth 4 buttons) (nth 5 buttons))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
709 (funcall connect-buttons (nth 5 buttons) (nth 6 buttons))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
710 (funcall connect-buttons (nth 6 buttons) (nth 7 buttons))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
711 (funcall connect-buttons (nth 7 buttons) (nth 8 buttons))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
712 (funcall connect-buttons (nth 8 buttons) (nth 0 buttons))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
713
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
714 (gtk-table-attach table (nth 0 buttons) 0 1 0 1 '(expand fill) '(expand fill) 0 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
715 (gtk-table-attach table (nth 1 buttons) 1 2 1 2 '(expand fill) '(expand fill) 0 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
716 (gtk-table-attach table (nth 2 buttons) 2 3 2 3 '(expand fill) '(expand fill) 0 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
717 (gtk-table-attach table (nth 3 buttons) 0 1 2 3 '(expand fill) '(expand fill) 0 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
718 (gtk-table-attach table (nth 4 buttons) 2 3 0 1 '(expand fill) '(expand fill) 0 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
719 (gtk-table-attach table (nth 5 buttons) 1 2 2 3 '(expand fill) '(expand fill) 0 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
720 (gtk-table-attach table (nth 6 buttons) 1 2 0 1 '(expand fill) '(expand fill) 0 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
721 (gtk-table-attach table (nth 7 buttons) 2 3 1 2 '(expand fill) '(expand fill) 0 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
722 (gtk-table-attach table (nth 8 buttons) 0 1 1 2 '(expand fill) '(expand fill) 0 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
723 ))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
724
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
725
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
726 ;;;; Testing labels and underlining
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
727 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
728 "Labels" basic labels nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
729 (let ((hbox (gtk-hbox-new nil 5))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
730 (vbox (gtk-vbox-new nil 5))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
731 (frame nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
732 (label nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
733 (gtk-container-add window hbox)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
734 (gtk-box-pack-start hbox vbox nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
735 (gtk-container-set-border-width window 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
736
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
737 (setq frame (gtk-frame-new "Normal Label")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
738 label (gtk-label-new "This is a Normal label"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
739 (gtk-container-add frame label)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
740 (gtk-box-pack-start vbox frame nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
741
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
742 (setq frame (gtk-frame-new "Multi-line Label")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
743 label (gtk-label-new "This is a multi-line label.\nSecond line\nThird line"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
744 (gtk-container-add frame label)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
745 (gtk-box-pack-start vbox frame nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
746
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
747 (setq frame (gtk-frame-new "Left Justified Label")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
748 label (gtk-label-new "This is a Left-Justified\nMulti-line label.\nThird line"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
749 (gtk-label-set-justify label 'left)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
750 (gtk-container-add frame label)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
751 (gtk-box-pack-start vbox frame nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
752
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
753 (setq frame (gtk-frame-new "Right Justified Label")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
754 label (gtk-label-new "This is a Right-Justified\nMulti-line label.\nFourth line, (j/k)"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
755 (gtk-label-set-justify label 'right)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
756 (gtk-container-add frame label)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
757 (gtk-box-pack-start vbox frame nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
758
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
759 ;; Start a second row so that we don't make a ridiculously tall window
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
760 (setq vbox (gtk-vbox-new nil 5))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
761 (gtk-box-pack-start hbox vbox nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
762
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
763 (setq frame (gtk-frame-new "Line wrapped label")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
764 label (gtk-label-new
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
765 (concat "This is an example of a line-wrapped label. It should not be taking "
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
766 "up the entire " ;;; big space to test spacing
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
767 "width allocated to it, but automatically wraps the words to fit. "
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
768 "The time has come, for all good men, to come to the aid of their party. "
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
769 "The sixth sheik's six sheep's sick.\n"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
770 " It supports multiple paragraphs correctly, and correctly adds "
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
771 "many extra spaces. ")))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
772 (gtk-label-set-line-wrap label t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
773 (gtk-container-add frame label)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
774 (gtk-box-pack-start vbox frame nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
775
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
776 (setq frame (gtk-frame-new "Filled, wrapped label")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
777 label (gtk-label-new
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
778 (concat
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
779 "This is an example of a line-wrapped, filled label. It should be taking "
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
780 "up the entire width allocated to it. Here is a seneance to prove "
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
781 "my point. Here is another sentence. "
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
782 "Here comes the sun, do de do de do.\n"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
783 " This is a new paragraph.\n"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
784 " This is another newer, longer, better paragraph. It is coming to an end, "
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
785 "unfortunately.")))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
786 (gtk-label-set-justify label 'fill)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
787 (gtk-label-set-line-wrap label t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
788 (gtk-container-add frame label)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
789 (gtk-box-pack-start vbox frame nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
790
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
791 (setq frame (gtk-frame-new "Underlined label")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
792 label (gtk-label-new (concat "This label is underlined!\n"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
793 "This one is underlined in ÆüËܸì¤ÎÆþÍÑquite a funky fashion")))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
794 (gtk-label-set-justify label 'left)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
795 (gtk-label-set-pattern label "_________________________ _ _________ _ _____ _ __ __ ___ ____ _____")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
796 (gtk-container-add frame label)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
797 (gtk-box-pack-start vbox frame nil nil 0)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
798
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
799
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
800 ;;;; Progress gauges
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
801 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
802 "Progress bars" basic progress nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
803 (let* ((timer nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
804 (adj (gtk-adjustment-new 1 0 100 1 1 1))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
805 (label (gtk-label-new "progress..."))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
806 (pbar (gtk-progress-bar-new-with-adjustment adj))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
807 (button nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
808 (timer (make-itimer)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
809
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
810 ;; The original test used GTK timers, but XEmacs already has
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
811 ;; perfectly good timer support, that ends up mapping onto GTK
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
812 ;; timers anyway, so we'll use those instead.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
813 (set-itimer-function
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
814 timer
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
815 (lambda (bar adj)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
816 (let ((val (gtk-adjustment-value adj)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
817 (setq val (+ 1 (if (>= val 100) 0 val)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
818 (gtk-adjustment-set-value adj val)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
819 (gtk-widget-queue-draw bar))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
820
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
821 (set-itimer-function-arguments timer (list pbar adj))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
822 (set-itimer-uses-arguments timer t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
823 (set-itimer-restart timer 0.1)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
824 (set-itimer-value timer 0.1)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
825 (set-itimer-is-idle timer nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
826
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
827 (gtk-progress-set-format-string pbar "%v%%")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
828 (gtk-signal-connect pbar 'destroy (lambda (obj timer)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
829 (delete-itimer timer)) timer)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
830
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
831 (gtk-misc-set-alignment label 0 0.5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
832 (gtk-box-pack-start window label nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
833 (gtk-widget-show label)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
834 (gtk-widget-set-usize pbar 200 20)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
835 (gtk-box-pack-start window pbar t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
836
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
837 (setq button (gtk-check-button-new-with-label "Show text"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
838 (gtk-box-pack-start window button nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
839 (gtk-signal-connect button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
840 (lambda (button bar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
841 (gtk-progress-set-show-text
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
842 bar
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
843 (gtk-toggle-button-get-active button))) pbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
844 (gtk-widget-show button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
845
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
846 (setq button (gtk-check-button-new-with-label "Discrete blocks"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
847 (gtk-box-pack-start window button nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
848 (gtk-signal-connect button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
849 (lambda (button bar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
850 (gtk-progress-bar-set-bar-style
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
851 bar
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
852 (if (gtk-toggle-button-get-active button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
853 'discrete
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
854 'continuous))) pbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
855 (gtk-widget-show button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
856
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
857 (gtk-widget-show pbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
858
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
859 (activate-itimer timer)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
860
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
861 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
862 "Gamma Curve" gimp gamma-curve nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
863 (let ((curve (gtk-gamma-curve-new)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
864 (gtk-container-add window curve)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
865 (gtk-widget-show-all curve)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
866 (gtk-curve-set-range (gtk-gamma-curve-curve curve) 0 255 0 255)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
867 (gtk-curve-set-gamma (gtk-gamma-curve-curve curve) 2)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
868
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
869
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
870 ;;;; Testing various button boxes and layout strategies.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
871 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
872 "Button Box" container button-box nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
873 (let ((main-vbox (gtk-vbox-new nil 0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
874 (vbox (gtk-vbox-new nil 0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
875 (hbox (gtk-hbox-new nil 0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
876 (frame-horz (gtk-frame-new "Horizontal Button Boxes"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
877 (frame-vert (gtk-frame-new "Vertical Button Boxes"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
878 (create-bbox (lambda (horizontal title spacing child-w child-h layout)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
879 (let ((frame (gtk-frame-new title))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
880 (bbox (if horizontal
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
881 (gtk-hbutton-box-new)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
882 (gtk-vbutton-box-new))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
883 (gtk-container-set-border-width bbox 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
884 (gtk-container-add frame bbox)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
885 (gtk-button-box-set-layout bbox layout)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
886 (gtk-button-box-set-spacing bbox spacing)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
887 (gtk-button-box-set-child-size bbox child-w child-h)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
888 (gtk-container-add bbox (gtk-button-new-with-label "OK"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
889 (gtk-container-add bbox (gtk-button-new-with-label "Cancel"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
890 (gtk-container-add bbox (gtk-button-new-with-label "Help"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
891 frame))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
892
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
893 (gtk-container-set-border-width window 10)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
894 (gtk-container-add window main-vbox)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
895
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
896 (gtk-box-pack-start main-vbox frame-horz t t 10)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
897 (gtk-container-set-border-width vbox 10)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
898 (gtk-container-add frame-horz vbox)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
899
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
900 (gtk-box-pack-start main-vbox frame-vert t t 10)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
901 (gtk-container-set-border-width hbox 10)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
902 (gtk-container-add frame-vert hbox)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
903
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
904 (gtk-box-pack-start vbox (funcall create-bbox t "Spread" 40 85 20 'spread) t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
905 (gtk-box-pack-start vbox (funcall create-bbox t "Edge" 40 85 20 'edge) t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
906 (gtk-box-pack-start vbox (funcall create-bbox t "Start" 40 85 20 'start) t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
907 (gtk-box-pack-start vbox (funcall create-bbox t "End" 40 85 20 'end) t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
908
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
909 (gtk-box-pack-start hbox (funcall create-bbox nil "Spread" 40 85 20 'spread) t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
910 (gtk-box-pack-start hbox (funcall create-bbox nil "Edge" 40 85 20 'edge) t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
911 (gtk-box-pack-start hbox (funcall create-bbox nil "Start" 40 85 20 'start) t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
912 (gtk-box-pack-start hbox (funcall create-bbox nil "End" 40 85 20 'end) t t 0)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
913
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
914
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
915 ;;;; Cursors
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
916 '(gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
917 "Cursors" cursors nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
918 (let ((cursors '(x-cursor arrow based-arrow-down based-arrow-up boat bogosity
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
919 bottom-left-corner bottom-right-corner bottom-side bottom-tee
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
920 box-spiral center-ptr circle clock coffee-mug cross cross-reverse
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
921 crosshair diamond-cross dot dotbox double-arrow draft-large
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
922 draft-small draped-box exchange fleur gobbler gumby hand1 hand2 heart
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
923 icon iron-cross left-ptr left-side left-tee leftbutton ll-angle
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
924 lr-angle man middlebutton mouse pencil pirate plus question-arrow
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
925 right-ptr right-side right-tee rightbutton rtl-logo sailboat
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
926 sb-down-arrow sb-h-double-arrow sb-left-arrow sb-right-arrow
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
927 sb-up-arrow sb-v-double-arrow shuttle sizing spider spraycan star
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
928 target tcross top-left-arrow top-left-corner top-right-corner top-side
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
929 top-tee trek ul-angle umbrella ur-angle watch xterm last-cursor))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
930 (cursor-area nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
931 (adjustment nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
932 (spinner nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
933 (setq cursor-area (gtk-event-box-new)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
934 adjustment (gtk-adjustment-new 0 0 (length cursors) 1 1 1)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
935 spinner (gtk-spin-button-new adjustment 1 3))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
936 (gtk-widget-set-usize cursor-area 200 100)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
937 (gtk-box-pack-start window cursor-area t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
938 (gtk-box-pack-start window spinner nil nil 0)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
939
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
940
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
941 ;;;; Toolbar
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
942 (defun gtk-test-toolbar-create ()
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
943 (let ((toolbar (gtk-toolbar-new 'horizontal 'both)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
944 (gtk-toolbar-set-button-relief toolbar 'none)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
945
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
946 (gtk-toolbar-append-item toolbar
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
947 "Horizonal" "Horizontal toolbar layout" "Toolbar/Horizontal"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
948 (gtk-pixmap-new gtk-test-open-glyph nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
949 (lambda (tbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
950 (gtk-toolbar-set-orientation tbar 'horizontal)) toolbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
951 (gtk-toolbar-append-item toolbar
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
952 "Vertical" "Vertical toolbar layout" "Toolbar/Vertical"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
953 (gtk-pixmap-new gtk-test-open-glyph nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
954 (lambda (tbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
955 (gtk-toolbar-set-orientation tbar 'vertical)) toolbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
956
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
957 (gtk-toolbar-append-space toolbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
958 (gtk-toolbar-append-item toolbar
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
959 "Icons" "Only show toolbar icons" "Toolbar/IconsOnly"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
960 (gtk-pixmap-new gtk-test-open-glyph nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
961 (lambda (tbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
962 (gtk-toolbar-set-style tbar 'icons)) toolbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
963 (gtk-toolbar-append-item toolbar
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
964 "Text" "Only show toolbar text" "Toolbar/TextOnly"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
965 (gtk-pixmap-new gtk-test-open-glyph nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
966 (lambda (tbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
967 (gtk-toolbar-set-style tbar 'text)) toolbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
968 (gtk-toolbar-append-item toolbar
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
969 "Both" "Show toolbar icons and text" "Toolbar/Both"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
970 (gtk-pixmap-new gtk-test-open-glyph nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
971 (lambda (tbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
972 (gtk-toolbar-set-style tbar 'both)) toolbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
973
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
974 (gtk-toolbar-append-space toolbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
975 (gtk-toolbar-append-item toolbar
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
976 "Small" "Use small spaces" ""
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
977 (gtk-pixmap-new gtk-test-open-glyph nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
978 (lambda (tbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
979 (gtk-toolbar-set-space-size tbar 5)) toolbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
980 (gtk-toolbar-append-item toolbar
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
981 "Big" "Use big spaces" ""
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
982 (gtk-pixmap-new gtk-test-open-glyph nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
983 (lambda (tbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
984 (gtk-toolbar-set-space-size tbar 10)) toolbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
985
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
986 (gtk-toolbar-append-space toolbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
987 (gtk-toolbar-append-item toolbar
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
988 "Enable" "Enable tooltips" ""
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
989 (gtk-pixmap-new gtk-test-open-glyph nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
990 (lambda (tbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
991 (gtk-toolbar-set-tooltips tbar t)) toolbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
992 (gtk-toolbar-append-item toolbar
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
993 "Disable" "Disable tooltips" ""
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
994 (gtk-pixmap-new gtk-test-open-glyph nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
995 (lambda (tbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
996 (gtk-toolbar-set-tooltips tbar nil)) toolbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
997
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
998 (gtk-toolbar-append-space toolbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
999 (gtk-toolbar-append-item toolbar
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1000 "Borders" "Show borders" ""
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1001 (gtk-pixmap-new gtk-test-open-glyph nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1002 (lambda (tbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1003 (gtk-toolbar-set-button-relief tbar 'normal)) toolbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1004 (gtk-toolbar-append-item toolbar
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1005 "Borderless" "Hide borders" ""
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1006 (gtk-pixmap-new gtk-test-open-glyph nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1007 (lambda (tbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1008 (gtk-toolbar-set-button-relief tbar 'none)) toolbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1009
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1010 (gtk-toolbar-append-space toolbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1011 (gtk-toolbar-append-item toolbar
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1012 "Empty" "Empty spaces" ""
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1013 (gtk-pixmap-new gtk-test-open-glyph nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1014 (lambda (tbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1015 (gtk-toolbar-set-space-style tbar 'empty)) toolbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1016 (gtk-toolbar-append-item toolbar
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1017 "Lines" "Lines in spaces" ""
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1018 (gtk-pixmap-new gtk-test-open-glyph nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1019 (lambda (tbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1020 (gtk-toolbar-set-space-style tbar 'line)) toolbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1021 (gtk-widget-show-all toolbar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1022 toolbar))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1023
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1024 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1025 "Toolbar" container toolbar nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1026 (gtk-box-pack-start window (gtk-test-toolbar-create) t t 0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1027
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1028
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1029 ;;;; Text
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1030 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1031 "Text" composite text nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1032 (let ((text (gtk-text-new nil nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1033 (scrolled (gtk-scrolled-window-new nil nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1034 (bbox (gtk-hbutton-box-new))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1035 (button nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1036 (gtk-box-pack-start window scrolled t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1037 (gtk-box-pack-start window bbox nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1038 (gtk-widget-set-usize text 500 500)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1039 (gtk-container-add scrolled text)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1040
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1041 (setq button (gtk-check-button-new-with-label "Editable"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1042 (gtk-signal-connect button 'toggled
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1043 (lambda (button text)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1044 (gtk-text-set-editable text (gtk-toggle-button-get-active button))) text)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1045 (gtk-container-add bbox button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1046
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1047 (setq button (gtk-check-button-new-with-label "Wrap words"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1048 (gtk-signal-connect button 'toggled
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1049 (lambda (button text)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1050 (gtk-text-set-word-wrap text (gtk-toggle-button-get-active button))) text)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1051 (gtk-container-add bbox button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1052
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1053 ;; put some default text in there.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1054 (gtk-widget-set-style text 'default)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1055 (let ((faces '(blue bold bold-italic gtk-test-face-large red text-cursor))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1056 (string nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1057 (mapc (lambda (face)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1058 (setq string (format "Sample text in the `%s' face\n" face))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1059 (gtk-text-insert text
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1060 (face-font face)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1061 (face-foreground face)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1062 (face-background face)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1063 string (length string))) faces))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1064
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1065
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1066 ;; Tell the user their rights...
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1067 (let ((file (locate-data-file "COPYING")))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1068 (gtk-text-freeze text)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1069 (save-excursion
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1070 (set-buffer (get-buffer-create " *foo*"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1071 (insert-file-contents file)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1072 (gtk-text-insert text nil nil nil (buffer-string) (point-max))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1073 (kill-buffer (current-buffer))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1074 (gtk-text-thaw text)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1075
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1076
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1077 ;;;; handle box
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1078 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1079 "Handle box" container handles nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1080 (let ((handle nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1081 (hbox (gtk-hbox-new nil 0)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1082
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1083 (gtk-box-pack-start window (gtk-label-new "Above") nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1084 (gtk-box-pack-start window (gtk-hseparator-new) nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1085 (gtk-box-pack-start window hbox t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1086 (gtk-box-pack-start window (gtk-hseparator-new) nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1087 (gtk-box-pack-start window (gtk-label-new "Below") nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1088
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1089 (setq handle (gtk-handle-box-new))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1090 (gtk-container-add handle (gtk-test-toolbar-create))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1091 (gtk-widget-show-all handle)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1092 (gtk-box-pack-start hbox handle nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1093 (gtk-signal-connect handle 'child_attached
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1094 (lambda (box child data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1095 (message "Child widget (%s) attached" child)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1096 (gtk-signal-connect handle 'child_detached
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1097 (lambda (box child data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1098 (message "Child widget (%s) detached" child)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1099
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1100 (setq handle (gtk-handle-box-new))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1101 (gtk-container-add handle (gtk-label-new "Fooo!!!"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1102 (gtk-box-pack-start hbox handle nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1103 (gtk-signal-connect handle 'child_attached
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1104 (lambda (box child data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1105 (message "Child widget (%s) attached" child)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1106 (gtk-signal-connect handle 'child_detached
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1107 (lambda (box child data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1108 (message "Child widget (%s) detached" child)))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1109
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1110
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1111 ;;;; Menus
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1112 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1113 "Menus" basic menus nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1114 (let ((menubar (gtk-menu-bar-new))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1115 (item nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1116 (right-justify nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1117 (gtk-box-pack-start window menubar nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1118 (mapc (lambda (menudesc)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1119 (if (not menudesc)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1120 (setq right-justify t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1121 (setq item (gtk-build-xemacs-menu menudesc))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1122 (gtk-widget-show item)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1123 (if right-justify
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1124 (gtk-menu-item-right-justify item))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1125 (gtk-menu-bar-append menubar item)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1126 default-menubar)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1127
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1128
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1129 ;;;; Spinbutton
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1130 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1131 "Spinbutton" composite spinbutton nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1132 (let (frame vbox vbox2 hbox label spin adj spin2 button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1133
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1134 (gtk-container-set-border-width window 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1135
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1136 (setq frame (gtk-frame-new "Not accelerated")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1137 hbox (gtk-hbox-new nil 0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1138
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1139 (gtk-box-pack-start window frame t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1140 (gtk-container-add frame hbox)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1141
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1142 (setq vbox (gtk-vbox-new nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1143 label (gtk-label-new "Day:")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1144 adj (gtk-adjustment-new 1.0 1.0 31.0 1.0 5.0 0.0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1145 spin (gtk-spin-button-new adj 0 0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1146
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1147 (gtk-misc-set-alignment label 0 0.5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1148 (gtk-spin-button-set-wrap spin t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1149 (gtk-spin-button-set-shadow-type spin 'out)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1150 (gtk-box-pack-start hbox vbox t t 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1151 (gtk-box-pack-start vbox label nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1152 (gtk-box-pack-start vbox spin nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1153
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1154 (setq vbox (gtk-vbox-new nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1155 label (gtk-label-new "Month:")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1156 adj (gtk-adjustment-new 1.0 1.0 12.0 1.0 5.0 0.0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1157 spin (gtk-spin-button-new adj 0 0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1158 (gtk-misc-set-alignment label 0 0.5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1159 (gtk-spin-button-set-wrap spin t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1160 (gtk-spin-button-set-shadow-type spin 'out)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1161 (gtk-box-pack-start hbox vbox t t 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1162 (gtk-box-pack-start vbox label nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1163 (gtk-box-pack-start vbox spin nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1164
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1165 (setq vbox (gtk-vbox-new nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1166 label (gtk-label-new "Year:")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1167 adj (gtk-adjustment-new 1998.0 0.0 2100.0 1.0 100.0 0.0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1168 spin (gtk-spin-button-new adj 0 0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1169 (gtk-misc-set-alignment label 0 0.5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1170 (gtk-spin-button-set-wrap spin t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1171 (gtk-spin-button-set-shadow-type spin 'out)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1172 (gtk-widget-set-usize spin 55 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1173 (gtk-box-pack-start hbox vbox t t 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1174 (gtk-box-pack-start vbox label nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1175 (gtk-box-pack-start vbox spin nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1176
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1177 (setq frame (gtk-frame-new "Accelerated")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1178 vbox (gtk-vbox-new nil 0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1179
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1180 (gtk-box-pack-start window frame t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1181 (gtk-container-add frame vbox)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1182
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1183 (setq hbox (gtk-hbox-new nil 0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1184 (gtk-box-pack-start vbox hbox nil t 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1185
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1186 (setq vbox2 (gtk-vbox-new nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1187 label (gtk-label-new "Value:")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1188 adj (gtk-adjustment-new 0.0 -10000.0 10000.0 0.5 100.0 0.0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1189 spin (gtk-spin-button-new adj 1.0 2))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1190 (gtk-misc-set-alignment label 0 0.5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1191 (gtk-spin-button-set-wrap spin t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1192 (gtk-widget-set-usize spin 100 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1193 (gtk-box-pack-start vbox2 label nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1194 (gtk-box-pack-start vbox2 spin nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1195 (gtk-box-pack-start hbox vbox2 t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1196
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1197 (setq vbox2 (gtk-vbox-new nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1198 label (gtk-label-new "Digits:")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1199 adj (gtk-adjustment-new 2 1 5 1 1 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1200 spin2 (gtk-spin-button-new adj 0 0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1201 (gtk-misc-set-alignment label 0 0.5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1202 (gtk-spin-button-set-wrap spin2 t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1203 (gtk-widget-set-usize spin2 100 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1204 (gtk-box-pack-start vbox2 label nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1205 (gtk-box-pack-start vbox2 spin2 nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1206 (gtk-box-pack-start hbox vbox2 t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1207 (gtk-signal-connect adj 'value_changed
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1208 (lambda (adj spinners)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1209 (gtk-spin-button-set-digits
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1210 (car spinners)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1211 (gtk-spin-button-get-value-as-int (cdr spinners))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1212 (cons spin spin2))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1213
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1214 (setq button (gtk-check-button-new-with-label "Snap to 0.5-ticks"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1215 (gtk-signal-connect button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1216 (lambda (button spin)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1217 (gtk-spin-button-set-snap-to-ticks
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1218 spin
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1219 (gtk-toggle-button-get-active button)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1220 spin)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1221 (gtk-box-pack-start vbox button t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1222 (gtk-toggle-button-set-active button t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1223
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1224 (setq button (gtk-check-button-new-with-label "Numeric only input mode"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1225 (gtk-signal-connect button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1226 (lambda (button spin)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1227 (gtk-spin-button-set-numeric
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1228 spin
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1229 (gtk-toggle-button-get-active button)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1230 spin)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1231 (gtk-box-pack-start vbox button t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1232 (gtk-toggle-button-set-active button t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1233
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1234 (setq label (gtk-label-new ""))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1235
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1236 (setq hbox (gtk-hbutton-box-new))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1237 (gtk-box-pack-start vbox hbox nil t 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1238 (gtk-box-pack-start vbox label nil nil 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1239
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1240 (setq button (gtk-button-new-with-label "Value as int"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1241 (gtk-container-add hbox button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1242 (gtk-signal-connect button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1243 (lambda (obj data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1244 (let ((spin (car data))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1245 (label (cdr data)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1246 (gtk-label-set-text label
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1247 (format "%d"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1248 (gtk-spin-button-get-value-as-int spin)))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1249 (cons spin label))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1250
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1251 (setq button (gtk-button-new-with-label "Value as float"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1252 (gtk-container-add hbox button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1253 (gtk-signal-connect button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1254 (lambda (obj data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1255 (let ((spin (car data))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1256 (label (cdr data)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1257 (gtk-label-set-text label
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1258 (format "%g"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1259 (gtk-spin-button-get-value-as-float spin)))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1260 (cons spin label))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1261
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1262
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1263 ;;;; Reparenting
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1264 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1265 "Reparenting" misc reparenting nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1266 (let ((label (gtk-label-new "Hello World"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1267 (frame-1 (gtk-frame-new "Frame 1"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1268 (frame-2 (gtk-frame-new "Frame 2"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1269 (button nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1270 (hbox (gtk-hbox-new nil 5))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1271 (vbox-1 nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1272 (vbox-2 nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1273 (reparent-func (lambda (button data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1274 (let ((label (car data))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1275 (new-parent (cdr data)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1276 (gtk-widget-reparent label new-parent)))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1277
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1278 (gtk-box-pack-start window hbox t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1279 (gtk-box-pack-start hbox frame-1 t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1280 (gtk-box-pack-start hbox frame-2 t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1281
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1282 (setq vbox-1 (gtk-vbox-new nil 0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1283 (gtk-container-add frame-1 vbox-1)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1284 (setq vbox-2 (gtk-vbox-new nil 0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1285 (gtk-container-add frame-2 vbox-2)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1286
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1287 (setq button (gtk-button-new-with-label "switch"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1288 (gtk-box-pack-start vbox-1 button nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1289 (gtk-signal-connect button 'clicked reparent-func (cons label vbox-2))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1290
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1291 (setq button (gtk-button-new-with-label "switch"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1292 (gtk-box-pack-start vbox-2 button nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1293 (gtk-signal-connect button 'clicked reparent-func (cons label vbox-1))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1294
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1295 (gtk-box-pack-start vbox-2 label nil t 0)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1296
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1297
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1298 ;;;; StatusBar
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1299 (defvar statusbar-counter 1)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1300
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1301 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1302 "Statusbar" composite statusbar nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1303 (let ((bar (gtk-statusbar-new))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1304 (vbox nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1305 (button nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1306
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1307 (setq vbox (gtk-vbox-new nil 0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1308 (gtk-box-pack-start window vbox t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1309 (gtk-box-pack-end window bar t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1310
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1311 (setq button (gtk-button-new-with-label "push something"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1312 (gtk-box-pack-start-defaults vbox button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1313 (gtk-signal-connect button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1314 (lambda (button bar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1315 (gtk-statusbar-push bar 1 (format "something %d" (incf statusbar-counter))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1316 bar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1317
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1318 (setq button (gtk-button-new-with-label "pop"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1319 (gtk-box-pack-start-defaults vbox button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1320 (gtk-signal-connect button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1321 (lambda (button bar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1322 (gtk-statusbar-pop bar 1)) bar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1323
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1324 (setq button (gtk-button-new-with-label "steal #4"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1325 (gtk-box-pack-start-defaults vbox button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1326 (gtk-signal-connect button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1327 (lambda (button bar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1328 (gtk-statusbar-remove bar 1 4)) bar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1329
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1330 (setq button (gtk-button-new-with-label "dump stack"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1331 (gtk-box-pack-start-defaults vbox button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1332 (gtk-widget-set-sensitive button nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1333
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1334 (setq button (gtk-button-new-with-label "test contexts"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1335 (gtk-box-pack-start-defaults vbox button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1336 (gtk-signal-connect button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1337 (lambda (button bar)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1338 (let ((contexts '("any context" "idle messages" "some text"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1339 "hit the mouse" "hit the mouse2")))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1340 (message-box "%s"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1341 (mapconcat
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1342 (lambda (ctx)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1343 (format "context=\"%s\", context_id=%d"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1344 ctx (gtk-statusbar-get-context-id bar ctx)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1345 contexts "\n")))) bar)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1346
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1347
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1348 ;;;; Columned List
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1349 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1350 "Columnar List" composite clist nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1351 (let ((titles '("auto resize" "not resizeable" "max width 100" "min width 50"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1352 "hide column" "Title 5" "Title 6" "Title 7" "Title 8" "Title 9"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1353 "Title 10" "Title 11"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1354 hbox clist button separator scrolled-win check undo-button label)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1355
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1356 (gtk-container-set-border-width window 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1357
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1358 (setq scrolled-win (gtk-scrolled-window-new nil nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1359 (gtk-container-set-border-width scrolled-win 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1360 (gtk-scrolled-window-set-policy scrolled-win 'automatic 'automatic)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1361
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1362 ;; create GtkCList here so we have a pointer to throw at the
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1363 ;; button callbacks -- more is done with it later
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1364 (setq clist (gtk-clist-new-with-titles (length titles) titles))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1365 (gtk-container-add scrolled-win clist)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1366
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1367 ;; Make the columns live up to their titles.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1368 (gtk-clist-set-column-auto-resize clist 0 t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1369 (gtk-clist-set-column-resizeable clist 1 nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1370 (gtk-clist-set-column-max-width clist 2 100)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1371 (gtk-clist-set-column-min-width clist 3 50)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1372
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1373 (gtk-signal-connect clist 'click-column
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1374 (lambda (clist column data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1375 (cond
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1376 ((= column 4)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1377 (gtk-clist-set-column-visibility clist column nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1378 ((= column (gtk-clist-sort-column clist))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1379 (gtk-clist-set-sort-type
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1380 clist (if (eq (gtk-clist-sort-type clist) 'ascending)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1381 'descending
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1382 'ascending)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1383 (t
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1384 (gtk-clist-set-sort-column clist column)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1385 (gtk-clist-sort clist)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1386
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1387 ;; control buttons
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1388 (setq hbox (gtk-hbox-new nil 5))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1389 (gtk-container-set-border-width hbox 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1390 (gtk-box-pack-start window hbox nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1391
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1392 (setq button (gtk-button-new-with-label "Insert Row"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1393 (gtk-box-pack-start hbox button t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1394 (gtk-signal-connect button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1395 (lambda (button clist)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1396 (gtk-clist-append clist
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1397 (list (format "CListRow %05d" (random 10000))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1398 "Column 1"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1399 "Column 2"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1400 "Column 3"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1401 "Column 4"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1402 "Column 5"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1403 "Column 6"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1404 "Column 7"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1405 "Column 8"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1406 "Column 0"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1407 "Column 10"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1408 "Column 11"))) clist)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1409
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1410 (setq button (gtk-button-new-with-label "Add 1,000 Rows with Pixmaps"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1411 (gtk-box-pack-start hbox button t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1412 (gtk-signal-connect button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1413 (lambda (button clist)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1414 (let ((row 0) i)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1415 (gtk-clist-freeze clist)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1416 (loop for i from 0 to 1000 do
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1417 (setq row
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1418 (gtk-clist-append clist
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1419 (list
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1420 (format "CListRow %05d" (random 10000))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1421 "Column 1"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1422 "Column 2"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1423 "Column 3"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1424 "Column 4"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1425 "Column 5"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1426 "Column 6"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1427 "Column 7"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1428 "Column 8"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1429 "Column 0"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1430 "Column 10"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1431 "Column 11")))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1432 (gtk-clist-set-pixtext clist row 3 "gtk+" 5
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1433 gtk-test-mini-gtk-glyph
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1434 nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1435 (gtk-clist-thaw clist))) clist)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1436
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1437 (setq button (gtk-button-new-with-label "Add 10,000 Rows"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1438 (gtk-box-pack-start hbox button t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1439 (gtk-signal-connect button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1440 (lambda (button clist)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1441 (gtk-clist-freeze clist)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1442 (loop for i from 0 to 10000 do
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1443 (gtk-clist-append clist
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1444 (list
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1445 (format "CListRow %05d" (random 10000))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1446 "Column 1"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1447 "Column 2"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1448 "Column 3"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1449 "Column 4"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1450 "Column 5"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1451 "Column 6"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1452 "Column 7"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1453 "Column 8"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1454 "Column 0"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1455 "Column 10"
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1456 "Column 11")))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1457 (gtk-clist-thaw clist)) clist)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1458
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1459 ;; Second layer of buttons
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1460 (setq hbox (gtk-hbox-new nil 5))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1461 (gtk-container-set-border-width hbox 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1462 (gtk-box-pack-start window hbox nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1463
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1464 (setq button (gtk-button-new-with-label "Clear List"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1465 (gtk-box-pack-start hbox button t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1466 (gtk-signal-connect button 'clicked (lambda (button clist)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1467 (gtk-clist-clear clist)) clist)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1468
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1469 (setq button (gtk-button-new-with-label "Remove Selection"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1470 (gtk-box-pack-start hbox button t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1471 (gtk-signal-connect button 'clicked (lambda (button clist)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1472 (error "Do not know how to do this yet.")))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1473 (gtk-widget-set-sensitive button nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1474
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1475 (setq button (gtk-button-new-with-label "Undo Selection"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1476 (gtk-box-pack-start hbox button t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1477 (gtk-signal-connect button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1478 (lambda (button clist) (gtk-clist-undo-selection clist)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1479
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1480 (setq button (gtk-button-new-with-label "Warning Test"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1481 (gtk-box-pack-start hbox button t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1482 (gtk-signal-connect button 'clicked 'ignore)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1483 (gtk-widget-set-sensitive button nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1484
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1485 ;; Third layer of buttons
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1486 (setq hbox (gtk-hbox-new nil 5))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1487 (gtk-container-set-border-width hbox 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1488 (gtk-box-pack-start window hbox nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1489
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1490 (setq button (gtk-check-button-new-with-label "Show Title Buttons"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1491 (gtk-box-pack-start hbox button nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1492 (gtk-signal-connect button 'clicked (lambda (button clist)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1493 (if (gtk-toggle-button-get-active button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1494 (gtk-clist-column-titles-show clist)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1495 (gtk-clist-column-titles-hide clist))) clist)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1496 (gtk-toggle-button-set-active button t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1497
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1498 (setq button (gtk-check-button-new-with-label "Reorderable"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1499 (gtk-box-pack-start hbox check nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1500 (gtk-signal-connect button 'clicked (lambda (button clist)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1501 (gtk-clist-set-reorderable
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1502 clist
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1503 (gtk-toggle-button-get-active button))) clist)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1504 (gtk-toggle-button-set-active button t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1505
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1506 (setq label (gtk-label-new "Selection Mode :"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1507 (gtk-box-pack-start hbox label nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1508
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1509 (gtk-box-pack-start hbox (build-option-menu
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1510 '(("Single" .
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1511 (lambda (item clist)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1512 (gtk-clist-set-selection-mode clist 'single)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1513 ("Browse" .
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1514 (lambda (item clist)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1515 (gtk-clist-set-selection-mode clist 'browse)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1516 ("Multiple" .
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1517 (lambda (item clist)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1518 (gtk-clist-set-selection-mode clist 'multiple)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1519 ("Extended" .
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1520 (lambda (item clist)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1521 (gtk-clist-set-selection-mode clist 'extended))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1522 3 clist) nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1523
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1524 ;; The rest of the clist configuration
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1525 (gtk-box-pack-start window scrolled-win t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1526 (gtk-clist-set-row-height clist 18)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1527 (gtk-widget-set-usize clist -1 300)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1528
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1529 (loop for i from 0 to 11 do
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1530 (gtk-clist-set-column-width clist i 80))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1531
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1532
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1533 ;;;; Notebook
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1534 (defun set-tab-label (notebook page selected-p)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1535 (if page
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1536 (let (label label-box pixwid)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1537 (setq label-box (gtk-hbox-new nil 0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1538 (setq pixwid (gtk-pixmap-new
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1539 (if selected-p gtk-test-open-glyph gtk-test-closed-glyph) nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1540 (gtk-box-pack-start label-box pixwid nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1541 (gtk-misc-set-padding pixwid 3 1) ;
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1542 (setq label (gtk-label-new
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1543 (format "Page %d" (1+ (gtk-notebook-page-num notebook page)))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1544 (gtk-box-pack-start label-box label nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1545 (gtk-widget-show-all label-box)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1546 (gtk-notebook-set-tab-label notebook page label-box))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1547
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1548 (defun page-switch (widget page page-num data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1549 (let ((oldpage (gtk-notebook-get-current-page widget))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1550 (label nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1551 (label-box nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1552 (pixwid nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1553 (if (eq page-num oldpage)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1554 nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1555 (set-tab-label widget (gtk-notebook-get-nth-page widget oldpage) nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1556 (set-tab-label widget (gtk-notebook-get-nth-page widget page-num) t))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1557
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1558 (defun create-pages (notebook start end)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1559 (let (child button label hbox vbox label-box menu-box pixwid i)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1560 (setq i start)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1561 (while (<= i end)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1562 (setq child (gtk-frame-new (format "Page %d" i)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1563 (gtk-container-set-border-width child 10)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1564
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1565 (setq vbox (gtk-vbox-new t 0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1566 (gtk-container-set-border-width vbox 10)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1567 (gtk-container-add child vbox)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1568
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1569 (setq hbox (gtk-hbox-new t 0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1570 (gtk-box-pack-start vbox hbox nil t 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1571
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1572 (setq button (gtk-check-button-new-with-label "Fill Tab"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1573 (gtk-box-pack-start hbox button t t 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1574 (gtk-toggle-button-set-active button t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1575 (gtk-signal-connect
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1576 button 'toggled
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1577 (lambda (button data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1578 (let ((packing (gtk-notebook-query-tab-label-packing (car data) (cdr data))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1579 (gtk-notebook-set-tab-label-packing (car data) (cdr data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1580 (nth 0 packing)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1581 (gtk-toggle-button-get-active button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1582 (nth 2 packing))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1583 (cons notebook child))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1584
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1585 (setq button (gtk-check-button-new-with-label "Expand Tab"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1586 (gtk-box-pack-start hbox button t t 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1587 (gtk-signal-connect
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1588 button 'toggled
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1589 (lambda (button data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1590 (let ((packing (gtk-notebook-query-tab-label-packing (car data) (cdr data))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1591 (gtk-notebook-set-tab-label-packing (car data) (cdr data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1592 (gtk-toggle-button-get-active button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1593 (nth 1 packing) (nth 2 packing))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1594 (cons notebook child))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1595
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1596 (setq button (gtk-check-button-new-with-label "Pack End"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1597 (gtk-box-pack-start hbox button t t 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1598 (gtk-signal-connect
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1599 button 'toggled
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1600 (lambda (button data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1601 (let ((packing (gtk-notebook-query-tab-label-packing (car data) (cdr data))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1602 (gtk-notebook-set-tab-label-packing (car data) (cdr data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1603 (nth 0 packing) (nth 1 packing)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1604 (if (gtk-toggle-button-get-active button) 'end 'start))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1605 (cons notebook child))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1606
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1607 (setq button (gtk-button-new-with-label "Hide Page"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1608 (gtk-box-pack-end vbox button nil nil 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1609 (gtk-signal-connect button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1610 (lambda (ignored child) (gtk-widget-hide child)) child)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1611
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1612 (gtk-widget-show-all child)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1613
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1614 (setq label-box (gtk-hbox-new nil 0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1615 (setq pixwid (gtk-pixmap-new gtk-test-closed-glyph nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1616 (gtk-box-pack-start label-box pixwid nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1617 (gtk-misc-set-padding pixwid 3 1);
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1618 (setq label (gtk-label-new (format "Page %d" i)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1619 (gtk-box-pack-start label-box label nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1620 (gtk-widget-show-all label-box)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1621
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1622 (setq menu-box (gtk-hbox-new nil 0))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1623 (setq pixwid (gtk-pixmap-new gtk-test-closed-glyph nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1624 (gtk-box-pack-start menu-box pixwid nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1625 (gtk-misc-set-padding pixwid 3 1)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1626 (setq label (gtk-label-new (format "Page %d" i)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1627 (gtk-box-pack-start menu-box label nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1628 (gtk-widget-show-all menu-box)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1629 (gtk-notebook-append-page-menu notebook child label-box menu-box)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1630 (incf i))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1631
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1632 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1633 "Notebook" container notebook nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1634 (let (box1 box2 button separator omenu transparent label sample-notebook)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1635 (gtk-container-set-border-width window 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1636
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1637 (setq sample-notebook (gtk-notebook-new))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1638 (gtk-signal-connect sample-notebook 'switch_page 'page-switch)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1639 (gtk-notebook-set-tab-pos sample-notebook 'top)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1640 (gtk-box-pack-start window sample-notebook t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1641 (gtk-container-set-border-width sample-notebook 10)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1642
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1643 (create-pages sample-notebook 1 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1644
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1645 (setq separator (gtk-hseparator-new))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1646 (gtk-box-pack-start window separator nil t 10)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1647
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1648 (setq box2 (gtk-hbox-new nil 5))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1649 (gtk-container-set-border-width box2 10)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1650 (gtk-box-pack-start window box2 nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1651
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1652 (setq button (gtk-check-button-new-with-label "popup menu"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1653 (gtk-box-pack-start box2 button t nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1654 (gtk-signal-connect button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1655 (lambda (button notebook)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1656 (if (gtk-toggle-button-get-active button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1657 (gtk-notebook-popup-enable notebook)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1658 (gtk-notebook-popup-disable notebook))) sample-notebook)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1659
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1660 (setq button (gtk-check-button-new-with-label "homogeneous tabs"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1661 (gtk-box-pack-start box2 button t nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1662 (gtk-signal-connect button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1663 (lambda (button notebook)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1664 (gtk-notebook-set-homogeneous-tabs
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1665 notebook
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1666 (gtk-toggle-button-get-active button))) sample-notebook)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1667
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1668 (setq box2 (gtk-hbox-new nil 5))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1669 (gtk-container-set-border-width box2 10)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1670 (gtk-box-pack-start window box2 nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1671
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1672 (setq label (gtk-label-new "Notebook Style :"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1673 (gtk-box-pack-start box2 label nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1674
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1675 (setq omenu (build-option-menu '(("Standard" .
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1676 (lambda (b n)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1677 (gtk-notebook-set-show-tabs n t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1678 (gtk-notebook-set-scrollable n nil)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1679 ("No tabs" .
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1680 (lambda (b n)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1681 (gtk-notebook-set-show-tabs n nil)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1682 ("Scrollable" .
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1683 (lambda (b n)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1684 (gtk-notebook-set-show-tabs n t)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1685 (gtk-notebook-set-scrollable n t))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1686 0
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1687 sample-notebook))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1688 (gtk-box-pack-start box2 omenu nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1689
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1690 (setq button (gtk-button-new-with-label "Show all pages"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1691 (gtk-box-pack-start box2 button nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1692 (gtk-signal-connect
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1693 button 'clicked (lambda (button notebook)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1694 (mapc 'gtk-widget-show (gtk-container-children notebook)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1695 sample-notebook)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1696
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1697 (setq box2 (gtk-hbox-new t 10))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1698 (gtk-container-set-border-width box2 10)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1699 (gtk-box-pack-start window box2 nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1700
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1701 (setq button (gtk-button-new-with-label "prev"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1702 (gtk-signal-connect button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1703 (lambda (button notebook)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1704 (gtk-notebook-prev-page notebook)) sample-notebook)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1705 (gtk-box-pack-start box2 button t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1706
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1707 (setq button (gtk-button-new-with-label "next"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1708 (gtk-signal-connect button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1709 (lambda (button notebook)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1710 (gtk-notebook-next-page notebook)) sample-notebook)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1711 (gtk-box-pack-start box2 button t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1712
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1713 (setq button (gtk-button-new-with-label "rotate"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1714 (gtk-signal-connect button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1715 (lambda (button notebook)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1716 (gtk-notebook-set-tab-pos
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1717 notebook
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1718 (case (gtk-notebook-tab-pos notebook)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1719 (top 'right)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1720 (right 'bottom)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1721 (bottom 'left)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1722 (left 'top))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1723 sample-notebook)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1724
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1725 (gtk-box-pack-start box2 button t t 0)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1726
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1727
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1728 ;;;; Glade interfaces
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1729 (if (and (featurep 'glade)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1730 (file-exists-p (expand-file-name "gtk-test.glade" (gtk-test-directory))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1731 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1732 "Glade Interface" misc libglade t
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1733 (glade-init)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1734 (glade-xml-get-type)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1735 (let ((xml (glade-xml-new (expand-file-name "gtk-test.glade" (gtk-test-directory))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1736 nil)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1737 (setq window (glade-xml-get-widget xml "main_window"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1738 (glade-xml-signal-autoconnect xml)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1739 (fmakunbound 'gtk-test-libglade))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1740
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1741
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1742 ;;;; CTree
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1743 (defvar gtk-test-ctree-hash nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1744
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1745 (defun gtk-test-ctree-expand-directory (ctree dir parent)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1746 (ignore-errors
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1747 (let ((dirs (directory-files dir t nil nil 5))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1748 (files (directory-files dir t nil nil t))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1749 (node nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1750 (mapc (lambda (d)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1751 (if (or (string-match "/\\.$" d)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1752 (string-match "/\\.\\.$" d))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1753 nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1754 (setq node
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1755 (gtk-ctree-insert-node ctree parent nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1756 (list (file-name-nondirectory d) "")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1757 0 nil nil nil nil nil t))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1758 (puthash node d gtk-test-ctree-hash)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1759 (gtk-ctree-insert-node ctree node nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1760 (list "" "")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1761 0 nil nil nil nil nil nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1762 (gtk-ctree-collapse ctree node)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1763 dirs)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1764 (mapc (lambda (f)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1765 (gtk-ctree-insert-node ctree parent nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1766 (list (file-name-nondirectory f)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1767 (user-login-name (nth 2 (file-attributes f))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1768 0 nil nil nil nil t nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1769 files)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1770 (gtk-clist-columns-autosize ctree))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1771
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1772 (defun gtk-spin-button-new-with-label (label adjustment climb-rate digits)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1773 (let ((box (gtk-hbox-new nil 2))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1774 (spin (gtk-spin-button-new adjustment climb-rate digits))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1775 (lbl (gtk-label-new label)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1776 (gtk-box-pack-start box lbl nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1777 (gtk-box-pack-start box spin t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1778 (cons box spin)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1779
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1780 (gtk-define-test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1781 "Columnar Tree" composite ctree nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1782 (let ((scrolled (gtk-scrolled-window-new nil nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1783 (ctree (gtk-ctree-new-with-titles 2 0 '("File" "Owner")))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1784 (box (gtk-hbutton-box-new))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1785 (button nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1786 (setq gtk-test-ctree-hash (make-hash-table :test 'equal))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1787 (put scrolled 'child ctree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1788 (put scrolled 'height 400)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1789 (put ctree 'line_style 'solid)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1790 (put ctree 'expander_style 'square)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1791
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1792 (gtk-box-pack-start window scrolled t t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1793 (gtk-box-pack-start window box nil nil 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1794
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1795 (gtk-clist-freeze ctree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1796 (gtk-test-ctree-expand-directory ctree "/" nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1797 (gtk-clist-thaw ctree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1798
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1799 (setq button (gtk-button-new-with-label "Expand all"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1800 (put box 'child button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1801 (gtk-signal-connect button 'clicked (lambda (button tree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1802 (gtk-ctree-expand-recursive tree nil)) ctree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1803
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1804 (setq button (gtk-button-new-with-label "Collaps all"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1805 (put box 'child button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1806 (gtk-signal-connect button 'clicked (lambda (button tree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1807 (gtk-ctree-collapse-recursive tree nil)) ctree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1808
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1809 (setq button (gtk-button-new-with-label "Change style"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1810 (put box 'child button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1811 (put button 'sensitive nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1812
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1813 (setq box (gtk-hbox-new t 5))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1814 (gtk-box-pack-start window box nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1815
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1816 (setq button (gtk-button-new-with-label "Select all"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1817 (put box 'child button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1818 (gtk-signal-connect button 'clicked (lambda (button tree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1819 (gtk-ctree-select-recursive tree nil)) ctree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1820
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1821 (setq button (gtk-button-new-with-label "Unselect all"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1822 (put box 'child button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1823 (gtk-signal-connect button 'clicked (lambda (button tree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1824 (gtk-ctree-unselect-recursive tree nil)) ctree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1825
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1826 (setq button (gtk-button-new-with-label "Remove all"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1827 (put box 'child button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1828 (gtk-signal-connect button 'clicked (lambda (button tree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1829 (gtk-clist-freeze tree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1830 (gtk-ctree-recurse
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1831 tree nil
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1832 (lambda (tree subnode data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1833 (gtk-ctree-remove-node tree subnode)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1834 (gtk-clist-thaw tree)) ctree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1835
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1836 (setq button (gtk-check-button-new-with-label "Reorderable"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1837 (put box 'child button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1838 (gtk-signal-connect button 'clicked (lambda (button tree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1839 (put tree 'reorderable
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1840 (gtk-toggle-button-get-active button))) ctree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1841
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1842 (setq box (gtk-hbox-new t 5))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1843 (gtk-box-pack-start window box nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1844
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1845 (gtk-box-pack-start box (build-option-menu
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1846 '(("Dotted" . (lambda (item ctree) (put ctree 'line_style 'dotted)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1847 ("Solid" . (lambda (item ctree) (put ctree 'line_style 'solid)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1848 ("Tabbed" . (lambda (item ctree) (put ctree 'line_style 'tabbed)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1849 ("None" . (lambda (item ctree) (put ctree 'line_style 'none))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1850 0 ctree) nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1851 (gtk-box-pack-start box (build-option-menu
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1852 '(("Square" . (lambda (item ctree) (put ctree 'expander_style 'square)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1853 ("Triangle" . (lambda (item ctree) (put ctree 'expander_style 'triangle)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1854 ("Circular" . (lambda (item ctree) (put ctree 'expander_style 'circular)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1855 ("None" . (lambda (item ctree) (put ctree 'expander_style 'none))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1856 0 ctree) nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1857 (gtk-box-pack-start box (build-option-menu
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1858 '(("Left" . (lambda (item ctree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1859 (gtk-clist-set-column-justification
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1860 ctree (get ctree 'tree_column) 'left)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1861 ("Right" . (lambda (item ctree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1862 (gtk-clist-set-column-justification
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1863 ctree (get ctree 'tree_column) 'right))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1864 0 ctree) nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1865 (gtk-box-pack-start box (build-option-menu
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1866 '(("Single" .
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1867 (lambda (item clist)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1868 (gtk-clist-set-selection-mode clist 'single)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1869 ("Browse" .
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1870 (lambda (item clist)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1871 (gtk-clist-set-selection-mode clist 'browse)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1872 ("Multiple" .
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1873 (lambda (item clist)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1874 (gtk-clist-set-selection-mode clist 'multiple)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1875 ("Extended" .
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1876 (lambda (item clist)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1877 (gtk-clist-set-selection-mode clist 'extended))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1878 3 ctree) nil t 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1879
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1880 (setq box (gtk-hbox-new t 5))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1881 (gtk-box-pack-start window box nil nil 0)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1882
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1883 (let (adj spinner)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1884 (setq adj (gtk-adjustment-new (get ctree 'indent) 0 999 1 5 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1885 spinner (gtk-spin-button-new-with-label "Indent: " adj 1 3))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1886 (put box 'child (car spinner))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1887 (gtk-signal-connect adj 'value-changed
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1888 (lambda (adj tree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1889 (put tree 'indent (truncate (gtk-adjustment-value adj)))) ctree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1890
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1891 (setq adj (gtk-adjustment-new (get ctree 'spacing) 0 999 1 5 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1892 spinner (gtk-spin-button-new-with-label "Spacing: " adj 1 3))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1893 (put box 'child (car spinner))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1894 (gtk-signal-connect adj 'value-changed
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1895 (lambda (adj tree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1896 (put tree 'spacing (truncate (gtk-adjustment-value adj)))) ctree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1897
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1898 (setq adj (gtk-adjustment-new (get ctree 'row_height) 0 999 1 5 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1899 spinner (gtk-spin-button-new-with-label "Row Height: " adj 1 3))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1900 (put box 'child (car spinner))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1901 (gtk-signal-connect adj 'value-changed
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1902 (lambda (adj tree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1903 (put tree 'row_height (truncate (gtk-adjustment-value adj)))) ctree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1904
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1905 (setq button (gtk-check-button-new-with-label "Show logical root"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1906 (put box 'child button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1907 (gtk-signal-connect button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1908 (lambda (button tree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1909 (put tree 'show_stub (gtk-toggle-button-get-active button))) ctree))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1910
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1911 (gtk-signal-connect ctree 'tree-expand
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1912 (lambda (ctree node user-data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1913 (gtk-clist-freeze ctree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1914 (gtk-ctree-recurse
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1915 ctree node
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1916 (lambda (tree subnode user-data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1917 (if (not (equal subnode node))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1918 (gtk-ctree-remove-node tree subnode))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1919 (gtk-test-ctree-expand-directory ctree
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1920 (gethash node gtk-test-ctree-hash)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1921 node)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1922 (gtk-clist-thaw ctree)))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1923
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1924
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1925 ;;;; The main interface
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1926
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1927 (defun gtk-test-view-source (test)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1928 ;; View the source for this test in a XEmacs window.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1929 (if test
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1930 (let ((path (expand-file-name "gtk-test.el" (gtk-test-directory))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1931 (if (not (file-exists-p path))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1932 (error "Could not find source for gtk-test.el"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1933 (find-file path)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1934 (widen)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1935 (goto-char (point-min))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1936 (if (not (re-search-forward (concat "(gtk-define-test[ \t\n]*\"" test "\"") nil t))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1937 (error "Could not find test: %s" test)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1938 (narrow-to-page)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1939 (goto-char (point-min))))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1940
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1941 (defvar gtk-test-selected-test nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1942
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1943 (defun gtk-test ()
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1944 (interactive)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1945 (let ((items nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1946 (box nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1947 (window nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1948 (category-trees nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1949 (tree nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1950 (pane nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1951 (scrolled nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1952 (src-button nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1953 (gc-button nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1954 (standalone-p (not (default-gtk-device)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1955 (close-button nil))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1956 (gtk-init (list invocation-name))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1957 (if standalone-p
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1958 (progn
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1959 (gtk-object-destroy (gtk-adjustment-new 0 0 0 0 0 0))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1960 (ignore-errors
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1961 (or (fboundp 'gtk-test-gnome-pixmaps)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1962 (load-file (expand-file-name "gnome-test.el" (gtk-test-directory))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1963 (or (fboundp 'gtk-test-color-combo)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1964 (load-file (expand-file-name "gtk-extra-test.el" (gtk-test-directory)))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1965 (unwind-protect
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1966 (progn
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1967 (setq window (gtk-dialog-new)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1968 box (gtk-vbox-new nil 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1969 pane (gtk-hpaned-new)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1970 scrolled (gtk-scrolled-window-new nil nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1971 tree (gtk-tree-new)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1972 src-button (gtk-button-new-with-label "View source")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1973 gc-button (gtk-button-new-with-label "Garbage Collect")
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1974 close-button (gtk-button-new-with-label "Quit"))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1975 (gtk-window-set-title window
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1976 (format "%s/GTK %d.%d.%d"
5228
5efbd1253905 Remove all support for InfoDock.
Aidan Kehoe <kehoea@parhasard.net>
parents: 462
diff changeset
1977 "XEmacs"
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1978 emacs-major-version emacs-minor-version
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1979 (or emacs-patch-level emacs-beta-version)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1980
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1981 (gtk-scrolled-window-set-policy scrolled 'automatic 'automatic)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1982 (gtk-scrolled-window-add-with-viewport scrolled tree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1983 (gtk-widget-set-usize scrolled 200 600)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1984
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1985 (gtk-box-pack-start (gtk-dialog-vbox window) pane t t 5)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1986 (gtk-paned-pack1 pane scrolled t nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1987 (gtk-paned-pack2 pane box t nil)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1988 (setq gtk-test-shell box)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1989 (gtk-widget-show-all box)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1990
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1991 (gtk-container-add (gtk-dialog-action-area window) close-button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1992 (gtk-container-add (gtk-dialog-action-area window) src-button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1993 (gtk-container-add (gtk-dialog-action-area window) gc-button)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1994
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1995 (gtk-signal-connect gc-button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1996 (lambda (obj data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1997 (garbage-collect)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1998 (gtk-signal-connect close-button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
1999 (lambda (obj data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2000 (gtk-widget-destroy data)) window)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2001 (gtk-signal-connect src-button 'clicked
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2002 (lambda (obj data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2003 (gtk-test-view-source gtk-test-selected-test)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2004
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2005 ;; Try to be a nice person and sort the tests
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2006 (setq gtk-defined-tests
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2007 (sort gtk-defined-tests
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2008 (lambda (a b)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2009 (string-lessp (car a) (car b)))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2010
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2011 ;; This adds all of the buttons to the window.
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2012 (mapcar (lambda (test)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2013 (let* ((desc (nth 0 test))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2014 (type (nth 1 test))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2015 (func (nth 2 test))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2016 (parent (cdr-safe (assoc type category-trees)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2017 (item (gtk-tree-item-new-with-label desc)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2018 (put item 'test-function func)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2019 (put item 'test-description desc)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2020 (put item 'test-type type)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2021 (gtk-widget-show item)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2022 (if (not parent)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2023 (let ((subtree (gtk-tree-new)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2024 (setq parent (gtk-tree-item-new-with-label
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2025 (or (cdr-safe (assoc type gtk-test-categories))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2026 (symbol-name type))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2027 (gtk-signal-connect subtree 'select-child
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2028 (lambda (tree widget data)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2029 (setq gtk-test-selected-test (get widget 'test-description))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2030 (funcall (get widget 'test-function))))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2031 (gtk-tree-append tree parent)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2032 (gtk-tree-item-set-subtree parent subtree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2033 (setq parent subtree)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2034 (push (cons type parent) category-trees)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2035 (gtk-tree-append parent item)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2036 gtk-defined-tests)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2037 (gtk-widget-show-all window)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2038 (if standalone-p
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2039 (progn
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2040 (gtk-signal-connect window 'destroy (lambda (w d)
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2041 (gtk-main-quit)))
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents:
diff changeset
2042 (gtk-main)))))))