source: trunk/third/rep-gtk/examples/rep-ui @ 18404

Revision 18404, 1.4 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18403, which included commits to RCS files with non-trunk default branches.
  • Property svn:executable set to *
Line 
1#!/bin/sh
2exec rep "$0" "$@"
3!#
4
5(require 'gui.gtk-2.gtk)
6(require 'gui.gtk-2.libglade)
7
8(defvar xml nil)
9
10(defun output (data)
11  (let
12      ((text-widget (glade-xml-get-widget xml "text1")))
13    (when (integerp data)
14      (setq data (make-string 1 data)))
15    (gtk-text-insert text-widget nil nil nil data (length data))))
16
17(defun entry-key-press (widget event)
18  (when (string= (gdk-event-string event) "\r")
19    ;; RET
20    (let
21        ((input (gtk-entry-get-text widget))
22         error result string)
23      (output (format nil "\n%s\n" input))
24      (setq result (condition-case data
25                       (let
26                           ((standard-output output))
27                         (eval (read-from-string input)))
28                     (error
29                      (setq error t)
30                      data)))
31      (let
32          ((print-escape t))
33        (setq string (format nil "%s %S\n"
34                             (if error "error-->" "  =>") result)))
35      (output string)
36      (gtk-entry-set-text widget ""))))
37
38(defun window-closed (widget)
39  (gtk-main-quit))
40
41(setq xml (or (glade-xml-new
42               (local-file-name
43                (expand-file-name "./rep-ui.glade"
44                                  (file-name-directory load-filename))))
45              (error "something bad happened")))
46
47;; focus the entry
48(let
49    ((entry (glade-xml-get-widget xml "entry1")))
50  (gtk-widget-grab-focus entry));
51
52(output (format nil "[ rep %s -- %s ]\n\n" rep-version rep-build-id))
53
54(glade-xml-signal-autoconnect xml)
55(gtk-main)
56
57;; Local variables:
58;; major-mode: lisp-mode
59;; End:
Note: See TracBrowser for help on using the repository browser.