From doug.south at gmail.com Thu Feb 24 04:02:00 2011 From: doug.south at gmail.com (Doug South) Date: Wed, 23 Feb 2011 23:02:00 -0500 Subject: [cl-gtk2-devel] GtkDrawingArea Message-ID: Hi, New to Lisp and Gtk... I'm trying to use a GtkDrawingArea with cl-gtk2 and am wondering if it is possible. I didn't have much luck with: (asdf:operate 'asdf:load-op :cl-gtk2-gtk) (defun draw-test () (gtk:within-main-loop (let ((drawing-area (make-instance 'gtk:drawing-area :width 1500 :height 300)) (window (make-instance 'gtk:gtk-window :type :toplevel :title "Drawing Test"))) (gtk:container-add window drawing-area) (gobject:g-signal-connect drawing-area "expose" #'expose-event) (gobject:g-signal-connect window "expose" #'expose-event) (gtk:widget-show window :all t)))) (let ((output *standard-output*)) (defun expose-event (&rest b) (format output "~a" b)) (defun what-is-object (object) (describe object output))) I'm not concerned with the expose events (though they are not being called in either case). I'd expect the window to have a 1500 x 300 widget in it, but it appears as if there is no widget in it (and is only 200 x 200). As a sanity check, I tried doing the same thing in C: #include gboolean on_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data) { gdk_draw_arc (widget->window, widget->style->fg_gc[gtk_widget_get_state(widget)], TRUE, 0, 0, widget->allocation.width, widget->allocation.height, 0, 64 * 360); return TRUE; } int main(int argc, char *argv[]) { GtkWidget *window; GtkWidget *drawing_area; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); drawing_area = gtk_drawing_area_new(); gtk_widget_set_size_request(drawing_area, 1500, 300); gtk_container_add(GTK_CONTAINER(window), drawing_area); g_signal_connect(drawing_area, "expose-event", G_CALLBACK(on_expose_event), NULL); gtk_widget_show_all(window); gtk_main(); return 0; } This time the expose event does something a bit more useful, but the main point is that the window _IS_ 1500 x 300 (with a nice ellipse in it). I even tried commenting out the signal connect just to check my logic, and I still get the size of window I'd expect. So, the questions regarding cl-gtk2-gtk are: 1) Am I setting the drawing area size correctly? 2) Am I adding the drawing area correctly? (I've added labels and buttons successfully with cl-gtk2-gtk while going through the C Gtk tutorial) 3) Is there another package I need to install beyond cl-gtk2-gtk? 4) Something obvious that I'm not aware of? Thanks in advance, Doug South From aerique at xs4all.nl Thu Feb 24 12:21:28 2011 From: aerique at xs4all.nl (Erik Winkels) Date: Thu, 24 Feb 2011 13:21:28 +0100 Subject: [cl-gtk2-devel] GtkDrawingArea In-Reply-To: References: Message-ID: <20110224122128.GA26855@xs4all.nl> Hello Doug, On Wed, Feb 23, 2011 at 11:02:00PM -0500, Doug South wrote: > > I'm trying to use a GtkDrawingArea with cl-gtk2 and am wondering if it > is possible. I didn't have much luck with: [...] > (let ((drawing-area (make-instance 'gtk:drawing-area :width 1500 > :height 300)) [...] > As a sanity check, I tried doing the same thing in C: [...] > gtk_widget_set_size_request(drawing_area, 1500, 300); I don't have a recent cl-gtk2 on hand, but have you looked at the sample code that comes with it to see how things should be done? For example, if you look at gtk/gtk.demo.lisp you'll see that heights and widths are mostly set using {height,width}-request: (let* ((window (make-instance 'gtk-window :title "Test pixbuf" :width-request 600 :height-request 240)) However, I couldn't find a specific DrawingArea example. There's one in my Black Tie library but it uses an UI designed with Glade: http://github.com/aerique/black-tie/tree/master/examples Regards, Erik From doug.south at gmail.com Thu Feb 24 12:46:31 2011 From: doug.south at gmail.com (Doug South) Date: Thu, 24 Feb 2011 07:46:31 -0500 Subject: [cl-gtk2-devel] GtkDrawingArea In-Reply-To: <20110224122128.GA26855@xs4all.nl> References: <20110224122128.GA26855@xs4all.nl> Message-ID: On Thu, Feb 24, 2011 at 7:21 AM, Erik Winkels wrote: > Hello Doug, [snip] > For example, if you look at gtk/gtk.demo.lisp you'll see that heights and > widths are mostly set using {height,width}-request: > > ? ?(let* ((window (make-instance 'gtk-window :title "Test pixbuf" :width-request 600 :height-request 240)) > Ah, thanks for that. Some sanity now. :) Regards, Doug From gas.hale at gmail.com Wed Feb 23 08:29:49 2011 From: gas.hale at gmail.com (Alessandro Serra) Date: Wed, 23 Feb 2011 09:29:49 +0100 Subject: [cl-gtk2-devel] compiling with ECL Message-ID: Hi, I found a few problems compiling cl-gtk2 with ECL. ========= gdk/gdk.objects.lisp 940c940 < "gdk_colormap_get_screeen" nil))) --- > "gdk_colormap_get_screen" nil))) ========= glib/gobject.object.high.lisp 165,169c183,191 < (loop < while (not (null g-type)) < for lisp-type = (gethash (gtype-name g-type) *registered-object-types*) < when lisp-type do (return lisp-type) < do (setf g-type (g-type-parent g-type)))) --- > (do ((gt g-type (g-type-parent gt)) (lisp-type nil)) > ((or (null gt) lisp-type) lisp-type) > (setf lisp-type (gethash (gtype-name gt) *registered-object-types*)))) ==================== Thanks for the great package! Alessandro -- The basic tool for the manipulation of reality is the manipulation of words. If you can control the meaning of words, you can control the people who must use the words. ? ? ? ? ? ? ? ? ?? How To Build A Universe That Doesn't Fall Apart Two Days Later ? ? ? ? ? ? ? ? ?? Philip K. Dick