From rgo at interzet.ru Fri Aug 17 11:03:25 2012 From: rgo at interzet.ru (Timofey Misarenkov) Date: Fri, 17 Aug 2012 15:03:25 +0400 Subject: [cl-gtk2-devel] Tictactoe Message-ID: <20120817150325.561da3aa.rgo@interzet.ru> Hi. I plaing around cl-gtk2, and tried to code tictactoe example from gtk-tutorial. I have some success and below the code showing it. But one question remains: how can I define new signal? In the original code, in tictactoe_class_init function there are lines: tictactoe_signals[TICTACTOE_SIGNAL] = g_signal_new ("tictactoe", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (TictactoeClass, tictactoe), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); Is it possible to rewrite this lines on cl-gtk2? Here the already working code (without signal creation): (require :cl-gtk2-gtk) (defclass tictactoe (gtk:table) ((buttons :initform (make-array '(3 3)) :accessor ttt-buttons)) (:metaclass gobject:gobject-class)) (gobject:register-object-type-implementation "tictactoe-class" tictactoe "GtkTable" nil nil) (defmethod initialize-instance :after ((ttt tictactoe) &rest initargs) (setf (gtk:table-n-columns ttt) 3 (gtk:table-n-rows ttt) 3 (gtk:table-homogeneous ttt) t) (loop for i from 0 below 3 do (loop for j from 0 below 3 do (setf (aref (ttt-buttons ttt) i j) (let ((b (make-instance 'gtk:toggle-button))) (gtk:table-attach ttt b i (1+ i) j (1+ j)) (gobject:g-signal-connect b "toggled" #'(lambda (b) (declare (ignore b)) (format t "Button toggled~%"))) (setf (gtk:widget-height-request b) 20 (gtk:widget-width-request b) 20) (gtk:widget-show b) b))))) (gtk:within-main-loop (let ((window (make-instance 'gtk:gtk-window :type :toplevel :window-position :center :title "Tictactoe")) (ttt (make-instance 'tictactoe))) (gtk:container-add window ttt) (gtk:widget-show window))) -- Timofey Misarenkov