From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19002 invoked by alias); 28 Aug 2003 01:46:28 -0000 Mailing-List: contact guile-gtk-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: guile-gtk-owner@sources.redhat.com Received: (qmail 18994 invoked from network); 28 Aug 2003 01:46:27 -0000 Received: from unknown (HELO snoopy.pacific.net.au) (61.8.0.36) by sources.redhat.com with SMTP; 28 Aug 2003 01:46:27 -0000 Received: from sunny.pacific.net.au (sunny.pacific.net.au [203.2.228.40]) by snoopy.pacific.net.au (8.12.3/8.12.3/Debian-6.4) with ESMTP id h7S1kL0J002232 for ; Thu, 28 Aug 2003 11:46:22 +1000 Received: from wisma.pacific.net.au (wisma.pacific.net.au [210.23.129.72]) by sunny.pacific.net.au with ESMTP id h7S1kLkv019051 for ; Thu, 28 Aug 2003 11:46:21 +1000 (EST) Received: from localhost (ppp99.dyn228.pacific.net.au [203.143.228.99]) by wisma.pacific.net.au (8.12.9/8.12.9) with ESMTP id h7S1kJvj026119 for ; Thu, 28 Aug 2003 11:46:20 +1000 (EST) Received: from gg by localhost with local (Exim 3.35 #1 (Debian)) id 19sBrS-0004Ms-00; Thu, 28 Aug 2003 11:46:06 +1000 To: guile-gtk@sources.redhat.com Subject: gdk-window-new options From: Kevin Ryde Mail-Copies-To: never Date: Thu, 28 Aug 2003 01:46:00 -0000 Message-ID: <87y8xek10j.fsf@zip.com.au> User-Agent: Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.3 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-SW-Source: 2003-q3/txt/msg00063.txt.bz2 --=-=-= Content-length: 537 * gdk-support.c (gdk_window_new_interp): Add remaining optional GdkWindowAttr keyword arguments, inline fill_window_attrs, no need to dup and free the title string, initialize keywords and use them in examining the args. * guile-gtk.h (sgtk_gdk_colormap_info, sgtk_gdk_cursor_info, sgtk_gdk_visual_info): Add declarations. New code below. I think the little keyword snarfer could be used in gtk-support.c too, I suspect kw_flags and kw_type might be at risk of being garbage collected. --=-=-= Content-Type: text/x-csrc Content-Disposition: attachment; filename=gdk-window-new.c Content-length: 3902 extern sgtk_boxed_info sgtk_gdk_colormap_info; extern sgtk_boxed_info sgtk_gdk_cursor_info; extern sgtk_boxed_info sgtk_gdk_visual_info; #define SGTK_KEYWORD(c_name, scheme_name) \ SCM_SNARF_HERE(static SCM c_name) \ SCM_SNARF_INIT(c_name = scm_permanent_object \ (scm_make_keyword_from_dash_symbol \ (scm_str2symbol ("-" scheme_name)))) SGTK_KEYWORD (kw_colormap, "colormap"); SGTK_KEYWORD (kw_cursor, "cursor"); SGTK_KEYWORD (kw_override_redirect, "override-redirect"); SGTK_KEYWORD (kw_title, "title"); SGTK_KEYWORD (kw_visual, "visual"); SGTK_KEYWORD (kw_wmclass, "wmclass"); SGTK_KEYWORD (kw_x, "x"); SGTK_KEYWORD (kw_y, "y"); /* The Gtk documentation doesn't seem to say whether NULL is allowed in the various fields of GdkWindowAttr. The code looks like it's probably fine for the cursor, but not for the visual. Let's insist on actual objects and strings for now. */ GdkWindow * gdk_window_new_interp (GdkWindow *parent, int width, int height, GdkEventMask event_mask, GdkWindowClass window_class, GdkWindowType window_type, SCM rest) #define FUNC_NAME "gdk-window-new" { GdkWindowAttr attr; gint mask; GdkWindow *w; SCM key, val; unsigned long argnum; attr.event_mask = event_mask; attr.width = width; attr.height = height; attr.wclass = window_class; attr.window_type = window_type; mask = 0; argnum = 6; for (;;) { if (! SCM_CONSP (rest)) break; key = SCM_CAR (rest); rest = SCM_CDR (rest); if (! SCM_CONSP (rest)) scm_misc_error (FUNC_NAME, "missing argument to keyword ~A", scm_list_1 (key)); argnum += 2; val = SCM_CAR (rest); rest = SCM_CDR (rest); if (SCM_EQ_P (key, kw_colormap)) { SCM_ASSERT (sgtk_valid_boxed (val, &sgtk_gdk_colormap_info), val, argnum, FUNC_NAME); attr.colormap = (GdkColormap*) sgtk_scm2boxed (val); mask |= GDK_WA_COLORMAP; } else if (SCM_EQ_P (key, kw_cursor)) { SCM_ASSERT (sgtk_valid_boxed (val, &sgtk_gdk_cursor_info), val, argnum, FUNC_NAME); attr.cursor = (GdkCursor*) sgtk_scm2boxed (val); mask |= GDK_WA_CURSOR; } else if (SCM_EQ_P (key, kw_override_redirect)) { attr.override_redirect = ! SCM_FALSEP (val); mask |= GDK_WA_NOREDIR; } else if (SCM_EQ_P (key, kw_title)) { SCM_VALIDATE_STRING (argnum, val); attr.title = SCM_STRING_CHARS (val); mask |= GDK_WA_TITLE; } else if (SCM_EQ_P (key, kw_visual)) { SCM_ASSERT (sgtk_valid_boxed (val, &sgtk_gdk_visual_info), val, argnum, FUNC_NAME); attr.visual = (GdkVisual*) sgtk_scm2boxed (val); mask |= GDK_WA_VISUAL; } else if (SCM_EQ_P (key, kw_wmclass)) { SCM val2; if (! SCM_CONSP (rest)) scm_misc_error (FUNC_NAME, "missing second argument to keyword ~A", scm_list_1 (key)); val2 = SCM_CAR (rest); rest = SCM_CDR (rest); SCM_VALIDATE_STRING (argnum, val); argnum++; SCM_VALIDATE_STRING (argnum, val2); attr.wmclass_name = SCM_STRING_CHARS (val); attr.wmclass_class = SCM_STRING_CHARS (val); mask |= GDK_WA_WMCLASS; } else if (SCM_EQ_P (key, kw_x)) { attr.x = scm_num2short (val, argnum, FUNC_NAME); mask |= GDK_WA_X; } else if (SCM_EQ_P (key, kw_y)) { attr.y = scm_num2short (val, argnum, FUNC_NAME); mask |= GDK_WA_Y; } else scm_misc_error (FUNC_NAME, "unknown keyword ~A", scm_list_1 (key)); } w = gdk_window_new (parent, &attr, mask); /* ensure title string and boxed types are kept alive */ scm_remember_upto_here (rest); return w; } --=-=-=--