<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.5 on Thu Mar 19 02:14:19 2009 -->
+<!--Generated with glade3 3.4.5 on Thu Mar 19 02:56:11 2009 -->
<glade-interface>
<widget class="GtkWindow" id="window1">
<property name="title" translatable="yes">Text Editor</property>
<signal name="clicked" handler="save-as"/>
</widget>
</child>
+ <child>
+ <widget class="GtkToolButton" id="toolbutton5">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Eval</property>
+ <property name="stock_id">gtk-execute</property>
+ <signal name="clicked" handler="eval"/>
+ </widget>
+ <packing>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
<?xml version="1.0"?>
-<!--Generated with glade3 3.4.5 on Thu Mar 19 02:14:19 2009 -->
+<!--Generated with glade3 3.4.5 on Thu Mar 19 02:56:11 2009 -->
<interface>
<object class="GtkUIManager" id="uimanager1">
<child>
<signal handler="save-as" name="clicked"/>
</object>
</child>
+ <child>
+ <object class="GtkToolButton" id="toolbutton5">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Eval</property>
+ <property name="stock_id">gtk-execute</property>
+ <signal handler="eval" name="clicked"/>
+ </object>
+ <packing>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
:logo-icon-name "accessories-text-editor")))
(dialog-run d)
(object-destroy d)))
- (quit (&rest args) (object-destroy window)))
+ (quit (&rest args) (object-destroy window))
+ (cb-eval (&rest args)
+ (let ((buffer (text-view-buffer text-view)))
+ (multiple-value-bind (i1 i2) (text-buffer-get-selection-bounds buffer)
+ (when (and i1 i2)
+ (with-gtk-message-error-handler
+ (let* ((text (text-buffer-slice buffer i1 i2))
+ (value (eval (read-from-string text)))
+ (value-str (format nil "~A" value)))
+ (text-buffer-delete buffer i1 i2)
+ (text-buffer-insert buffer value-str))))))))
(builder-connect-signals-simple builder `(("new" ,#'new)
("open" ,#'cb-open)
("save" ,#'save)
("paste" ,#'paste)
("delete" ,#'cb-delete)
("about" ,#'about)
- ("quit" ,#'quit)))
+ ("quit" ,#'quit)
+ ("eval" ,#'cb-eval)))
(g-signal-connect window "destroy" (lambda (w) (declare (ignore w)) (gtk-main-quit)))
(g-signal-connect (text-view-buffer text-view) "changed" (lambda (b) (declare (ignore b)) (setf modified-p t) (set-properties)))
(widget-show window)