/[gtk-cffi]/gtk-cffi/examples/ex7.lisp
ViewVC logotype

Diff of /gtk-cffi/examples/ex7.lisp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by rklochkov, Mon Apr 25 19:16:08 2011 UTC revision 1.2 by rklochkov, Mon Aug 8 15:02:01 2011 UTC
# Line 1  Line 1 
1  (asdf:oos 'asdf:load-op :gtk-cffi)  (asdf:oos 'asdf:load-op :gtk-cffi)
2  (declaim (optimize speed))  (declaim (optimize speed))
3  (defpackage #:test  (defpackage #:ex7
4    (:use #:common-lisp #:gtk-cffi #:gobject-cffi))    (:use #:common-lisp #:gtk-cffi #:g-object-cffi))
5  (in-package #:test)  (in-package #:ex7)
6    
7    (defvar *window*)
8    (defvar *cell-pix*)
9    
10  (defun main ()  (defun main ()
11    (gtk-init)    (gtk-init)
# Line 14  Line 17 
17    
18    (let ((window (make-instance 'window :width 400 :height 280)))    (let ((window (make-instance 'window :width 400 :height 280)))
19      (setf (gsignal window :destroy) :gtk-main-quit)      (setf (gsignal window :destroy) :gtk-main-quit)
20      (defvar *window* window)      (setf *window* window)
21    
22      (let ((v-box (make-instance 'v-box))      (let ((v-box (make-instance 'v-box))
23            (data '(("01-01-08" "Some event")            (data '(("01-01-08" "Some event")
# Line 53  Description of this event. And this desc Line 56  Description of this event. And this desc
56    
57                    (when (= col 1)                    (when (= col 1)
58                      (setf (property cell-renderer :editable) t)                      (setf (property cell-renderer :editable) t)
59                      (defvar *cell-pix* (make-instance 'cell-renderer-pixbuf))                      (setf *cell-pix* (make-instance 'cell-renderer-pixbuf))
60                      (pack column *cell-pix*)                      (pack column *cell-pix*)
61                      (setf (property *cell-pix* :pixbuf)                      (setf (property *cell-pix* :pixbuf)
62                            (make-instance 'gdk-cffi:pixbuf                            (make-instance 'gdk-cffi:pixbuf
# Line 62  Description of this event. And this desc Line 65  Description of this event. And this desc
65                    (setf (gsignal cell-renderer :edited)                    (setf (gsignal cell-renderer :edited)
66                          (let ((%col col))                          (let ((%col col))
67                            (lambda (cell path new-text)                            (lambda (cell path new-text)
68                                (declare (ignore cell))
69                              (path->iter model path)                              (path->iter model path)
70                              (setf (model-values model                              (setf (model-values model
71                                                  :col %col)                                                  :col %col)
# Line 73  Description of this event. And this desc Line 77  Description of this event. And this desc
77           (gsignal view :button-press-event)           (gsignal view :button-press-event)
78           (lambda (view event)           (lambda (view event)
79             (when (and (eq (gdk-cffi:get-slot event :type) :button-press)             (when (and (eq (gdk-cffi:get-slot event :type) :button-press)
80                        (= (gdk-cffi:get-slot event :button) 1))                        (= (the integer (gdk-cffi:get-slot event :button)) 1))
81               (with-path-at-pos view               (with-path-at-pos view
82                                 (round (gdk-cffi:get-slot event :x))                                 (round (gdk-cffi:get-slot event :x))
83                                 (round (gdk-cffi:get-slot event :y))                                 (round (gdk-cffi:get-slot event :y))
# Line 94  Description of this event. And this desc Line 98  Description of this event. And this desc
98  (defun set-bold (view column)  (defun set-bold (view column)
99    (format t "set ~A~%" column)    (format t "set ~A~%" column)
100    (loop :for col :in (columns view)    (loop :for col :in (columns view)
101          :for i :from 0          :for i :from 0 :to 100
102          :do (progn          :do (progn
103                (setf (font (widget col))                (setf (font (widget col))
104                      (if (equal col column)                      (if (equal col column)
# Line 104  Description of this event. And this desc Line 108  Description of this event. And this desc
108    
109  (defun on-click (view path-list)  (defun on-click (view path-list)
110    (destructuring-bind (path column x y) path-list    (destructuring-bind (path column x y) path-list
111        (declare (ignore y))
112      (let ((cell (get-cell-at column x)))      (let ((cell (get-cell-at column x)))
113        (format t "cell: ~A~%" cell)        (format t "cell: ~A~%" cell)
114        (when (equal cell *cell-pix*)        (when (equal cell *cell-pix*)
# Line 118  Description of this event. And this desc Line 123  Description of this event. And this desc
123              (let ((top-area (v-box dialog)))              (let ((top-area (v-box dialog)))
124                (pack top-area text-view :pack-fill t :expand t)                (pack top-area text-view :pack-fill t :expand t)
125                (show text-view))                (show text-view))
126              (set-position dialog :center-on-parent)              (setf (win-position dialog) :center-on-parent)
127    
128                ;(pack top-area text-view :fill t :expand t))                ;(pack top-area text-view :fill t :expand t))
129              (run dialog)              (run dialog)

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.5